本文整理汇总了C++中Tcl_SetHashValue函数的典型用法代码示例。如果您正苦于以下问题:C++ Tcl_SetHashValue函数的具体用法?C++ Tcl_SetHashValue怎么用?C++ Tcl_SetHashValue使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Tcl_SetHashValue函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Tk_InternAtom
Atom
Tk_InternAtom(
Tk_Window tkwin, /* Window token; map name to atom for this
* window's display. */
const char *name) /* Name to turn into atom. */
{
TkDisplay *dispPtr;
Tcl_HashEntry *hPtr;
int isNew;
dispPtr = ((TkWindow *) tkwin)->dispPtr;
if (!dispPtr->atomInit) {
AtomInit(dispPtr);
}
hPtr = Tcl_CreateHashEntry(&dispPtr->nameTable, name, &isNew);
if (isNew) {
Tcl_HashEntry *hPtr2;
Atom atom;
atom = XInternAtom(dispPtr->display, name, False);
Tcl_SetHashValue(hPtr, atom);
hPtr2 = Tcl_CreateHashEntry(&dispPtr->atomTable, (char*) atom, &isNew);
Tcl_SetHashValue(hPtr2, Tcl_GetHashKey(&dispPtr->nameTable, hPtr));
}
return (Atom) Tcl_GetHashValue(hPtr);
}
示例2: InitKeyMaps
static void
InitKeyMaps()
{
Tcl_HashEntry *hPtr;
KeyInfo *kPtr;
int dummy;
Tcl_InitHashTable(&keycodeTable, TCL_ONE_WORD_KEYS);
for (kPtr = keyArray; kPtr->keycode != 0; kPtr++) {
hPtr = Tcl_CreateHashEntry(&keycodeTable, (char *) kPtr->keycode,
&dummy);
Tcl_SetHashValue(hPtr, kPtr->keysym);
}
Tcl_InitHashTable(&vkeyTable, TCL_ONE_WORD_KEYS);
for (kPtr = vituralkeyArray; kPtr->keycode != 0; kPtr++) {
hPtr = Tcl_CreateHashEntry(&vkeyTable, (char *) kPtr->keycode,
&dummy);
Tcl_SetHashValue(hPtr, kPtr->keysym);
}
KCHRPtr = (Ptr) GetScriptManagerVariable(smKCHRCache);
if (!KCHRPtr){
fprintf(stderr,"GetScriptManagerVariable failed\n");
}
initialized = 1;
}
示例3: AtomInit
static void
AtomInit(
TkDisplay *dispPtr)/* Display to initialize. */
{
Tcl_HashEntry *hPtr;
Atom atom;
dispPtr->atomInit = 1;
Tcl_InitHashTable(&dispPtr->nameTable, TCL_STRING_KEYS);
Tcl_InitHashTable(&dispPtr->atomTable, TCL_ONE_WORD_KEYS);
for (atom = 1; atom <= XA_LAST_PREDEFINED; atom++) {
const char *name;
int isNew;
hPtr = Tcl_FindHashEntry(&dispPtr->atomTable, (char *) atom);
if (hPtr != NULL) {
continue;
}
name = atomNameArray[atom - 1];
hPtr = Tcl_CreateHashEntry(&dispPtr->nameTable, name, &isNew);
Tcl_SetHashValue(hPtr, atom);
name = Tcl_GetHashKey(&dispPtr->nameTable, hPtr);
hPtr = Tcl_CreateHashEntry(&dispPtr->atomTable, (char *) atom, &isNew);
Tcl_SetHashValue(hPtr, name);
}
}
示例4: Tcl_CreateHashEntry
static Tcl_Obj *Ttk_Use(
Tcl_Interp *interp,
Tcl_HashTable *table,
Allocator allocate,
Tk_Window tkwin,
Tcl_Obj *objPtr)
{
int newEntry;
Tcl_HashEntry *entryPtr =
Tcl_CreateHashEntry(table,Tcl_GetString(objPtr),&newEntry);
Tcl_Obj *cacheObj;
if (!newEntry) {
return Tcl_GetHashValue(entryPtr);
}
cacheObj = Tcl_DuplicateObj(objPtr);
Tcl_IncrRefCount(cacheObj);
if (allocate(interp, tkwin, cacheObj)) {
Tcl_SetHashValue(entryPtr, cacheObj);
return cacheObj;
} else {
Tcl_DecrRefCount(cacheObj);
Tcl_SetHashValue(entryPtr, NULL);
Tcl_BackgroundException(interp, TCL_ERROR);
return NULL;
}
}
示例5: Itcl_RegisterClassCommand
ClientData
Itcl_RegisterClassCommand(
Tcl_Interp *interp,
Tcl_Namespace *nsPtr,
const char *cmdName,
ClientData clientData)
{
Tcl_HashEntry *hPtr;
Tcl_HashTable *tablePtr;
ItclResolvingInfo *iriPtr;
int isNew;
iriPtr = Tcl_GetAssocData(interp, ITCL_RESOLVE_DATA, NULL);
hPtr = Tcl_CreateHashEntry(&iriPtr->resolveCmds, nsPtr->fullName, &isNew);
if (isNew) {
tablePtr = (Tcl_HashTable *)ckalloc(sizeof(Tcl_HashTable));
Tcl_InitHashTable(tablePtr, TCL_STRING_KEYS);
Tcl_SetHashValue(hPtr, tablePtr);
} else {
tablePtr = Tcl_GetHashValue(hPtr);
}
hPtr = Tcl_CreateHashEntry(tablePtr, cmdName, &isNew);
if (isNew) {
Tcl_SetHashValue(hPtr, clientData);
}
return Tcl_GetHashValue(hPtr);
}
示例6: IvyBindCmd
static int
IvyBindCmd(ClientData clientData,
Tcl_Interp *interp,
int argc,
const char **argv)
{
filter_struct *filter;
Tcl_HashEntry *entry;
int dummy;
char msg[INTEGER_SPACE];
if (argc != 3) {
Tcl_AppendResult(interp, "wrong # of args: \"",
argv[0], " filter script\"", (char *) NULL);
return TCL_ERROR;
}
filter = (filter_struct *) ckalloc(sizeof(filter_struct));
filter->filter = ckalloc(strlen(argv[1])+1); /* regexp */
strcpy(filter->filter, argv[1]);
filter->script = ckalloc(strlen(argv[2])+1); /* callback proc name */
strcpy(filter->script, argv[2]);
filter->id = IvyBindMsg(IvyMsgCB, (void *) filter, filter->filter, NULL); /* MsgPtr id */
filter->interp = interp;
entry = Tcl_CreateHashEntry(&filter_table, (char *) (long) filter_id, &dummy);
Tcl_SetHashValue(entry, (ClientData) filter);
sprintf(msg, "%d", filter_id);
filter_id++;
Tcl_SetResult(interp, msg, TCL_VOLATILE);
return TCL_OK;
}
示例7: Nsf_PointerAdd
/*
*----------------------------------------------------------------------
*
* Nsf_PointerAdd --
*
* Add an entry to our locally maintained hash table and set its
* value to the provided valuePtr. The keys are generated based on
* the passed type and the counter obtained from the type
* registration.
*
* Results:
* Tcl result code
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
int
Nsf_PointerAdd(Tcl_Interp *interp, char *buffer, size_t size, const char *typeName, void *valuePtr) {
int *counterPtr;
nonnull_assert(interp != NULL);
nonnull_assert(buffer != NULL);
nonnull_assert(typeName != NULL);
nonnull_assert(valuePtr != NULL);
counterPtr = Nsf_PointerTypeLookup(typeName);
if (counterPtr != NULL) {
Tcl_DString ds, *dsPtr = &ds;
Tcl_HashEntry *hPtr;
int isNew;
Tcl_DStringInit(dsPtr);
Tcl_DStringAppend(dsPtr, typeName, -1);
Tcl_DStringAppend(dsPtr, ":%d", 3);
NsfMutexLock(&pointerMutex);
snprintf(buffer, size, Tcl_DStringValue(dsPtr), (*counterPtr)++);
hPtr = Tcl_CreateHashEntry(pointerHashTablePtr, buffer, &isNew);
NsfMutexUnlock(&pointerMutex);
Tcl_SetHashValue(hPtr, valuePtr);
/*fprintf(stderr, "Nsf_PointerAdd key '%s' prefix '%s' => %p value %p\n", buffer, typeName, hPtr, valuePtr);*/
Tcl_DStringFree(dsPtr);
} else {
return NsfPrintError(interp, "no type converter for %s registered", typeName);
}
return TCL_OK;
}
示例8: SetSigMapValue
void
SetSigMapValue (
SignalMapEntry *entryPtr,
ClientData clientData)
{
Tcl_SetHashValue(entryPtr, clientData);
}
示例9: Ttk_CreateTheme
Ttk_Theme
Ttk_CreateTheme(
Tcl_Interp *interp, /* Interpreter in which to create theme */
const char *name, /* Name of the theme to create. */
Ttk_Theme parent) /* Parent/fallback theme, NULL for default */
{
StylePackageData *pkgPtr = GetStylePackageData(interp);
Tcl_HashEntry *entryPtr;
int newEntry;
Theme *themePtr;
entryPtr = Tcl_CreateHashEntry(&pkgPtr->themeTable, name, &newEntry);
if (!newEntry) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"Theme %s already exists", name));
Tcl_SetErrorCode(interp, "TTK", "THEME", "EXISTS", NULL);
return NULL;
}
/*
* Initialize new theme:
*/
if (!parent) parent = pkgPtr->defaultTheme;
themePtr = NewTheme(pkgPtr->cache, parent);
Tcl_SetHashValue(entryPtr, themePtr);
return themePtr;
}
示例10: tn_dup
TNPtr
tn_dup (TPtr dst, TNPtr src)
{
TNPtr dstn;
dstn = tn_new (dst, Tcl_GetString (src->name));
if (src->attr) {
int i, new;
Tcl_HashSearch hs;
Tcl_HashEntry* he;
Tcl_HashEntry* dhe;
CONST char* key;
Tcl_Obj* val;
dstn->attr = ALLOC (Tcl_HashTable);
Tcl_InitHashTable(dstn->attr, TCL_STRING_KEYS);
for(i = 0, he = Tcl_FirstHashEntry(src->attr, &hs);
he != NULL;
he = Tcl_NextHashEntry(&hs), i++) {
key = Tcl_GetHashKey (src->attr, he);
val = (Tcl_Obj*) Tcl_GetHashValue(he);
dhe = Tcl_CreateHashEntry(dstn->attr, key, &new);
Tcl_IncrRefCount (val);
Tcl_SetHashValue (dhe, (ClientData) val);
}
}
示例11: Init_Cmd
/*
* Initialize a Duktape intepreter.
* Return value: string token of the form "::duktape::(integer)".
* Side effects: creates an Duktape heap.
*/
static int
Init_Cmd(ClientData cdata, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
duk_context *ctx;
Tcl_HashEntry *hashPtr;
int isNew;
Tcl_Obj *token;
if (objc != 1) {
Tcl_WrongNumArgs(interp, 1, objv, USAGE_INIT);
return TCL_ERROR;
}
ctx = duk_create_heap_default();
if (ctx == NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(ERROR_CREATE, -1));
return TCL_ERROR;
}
DUKTCL_CDATA->counter++;
token = Tcl_ObjPrintf(NS "::%d", DUKTCL_CDATA->counter);
hashPtr = Tcl_CreateHashEntry(&DUKTCL_CDATA->table, Tcl_GetString(token),
&isNew);
Tcl_SetHashValue(hashPtr, (ClientData) ctx);
Tcl_SetObjResult(interp, token);
return TCL_OK;
}
示例12: CreateSlave
static Slave *
CreateSlave(
Tk_Window tkwin, /* Token for desired slave. */
Tk_OptionTable table)
{
Tcl_HashEntry *hPtr;
register Slave *slavePtr;
int isNew;
TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr;
hPtr = Tcl_CreateHashEntry(&dispPtr->slaveTable, (char *) tkwin, &isNew);
if (!isNew) {
return Tcl_GetHashValue(hPtr);
}
/*
* No preexisting slave structure for that window, so make a new one and
* populate it with some default values.
*/
slavePtr = ckalloc(sizeof(Slave));
memset(slavePtr, 0, sizeof(Slave));
slavePtr->tkwin = tkwin;
slavePtr->inTkwin = None;
slavePtr->anchor = TK_ANCHOR_NW;
slavePtr->borderMode = BM_INSIDE;
slavePtr->optionTable = table;
Tcl_SetHashValue(hPtr, slavePtr);
Tk_CreateEventHandler(tkwin, StructureNotifyMask, SlaveStructureProc,
slavePtr);
return slavePtr;
}
示例13: TkpDefineNativeBitmaps
void
TkpDefineNativeBitmaps(void)
{
Tcl_HashTable *tablePtr = TkGetBitmapPredefTable();
BuiltInIcon *builtInPtr;
for (builtInPtr = builtInIcons; builtInPtr->name != NULL; builtInPtr++) {
Tcl_HashEntry *predefHashPtr;
const char * name;
int isNew;
name = Tk_GetUid(builtInPtr->name);
predefHashPtr = Tcl_CreateHashEntry(tablePtr, name, &isNew);
if (isNew) {
TkPredefBitmap *predefPtr = (TkPredefBitmap *)
ckalloc(sizeof(TkPredefBitmap));
NativeIcon *nativeIconPtr = (NativeIcon *)
ckalloc(sizeof(NativeIcon));
nativeIconPtr->id = builtInPtr->id;
nativeIconPtr->type = builtInPtr->type;
predefPtr->source = (char *) nativeIconPtr;
predefPtr->width = builtInPtr->size;
predefPtr->height = builtInPtr->size;
predefPtr->native = 1;
Tcl_SetHashValue(predefHashPtr, predefPtr);
}
}
}
示例14: RegisterTcpServerInterpCleanup
static void
RegisterTcpServerInterpCleanup(
Tcl_Interp *interp, /* Interpreter for which we want to be
* informed of deletion. */
AcceptCallback *acceptCallbackPtr)
/* The accept callback record whose interp
* field we want set to NULL when the
* interpreter is deleted. */
{
Tcl_HashTable *hTblPtr; /* Hash table for accept callback records to
* smash when the interpreter will be
* deleted. */
Tcl_HashEntry *hPtr; /* Entry for this record. */
int isNew; /* Is the entry new? */
hTblPtr = (Tcl_HashTable *)
Tcl_GetAssocData(interp, "tclTCPAcceptCallbacks", NULL);
if (hTblPtr == NULL) {
hTblPtr = (Tcl_HashTable *) ckalloc((unsigned) sizeof(Tcl_HashTable));
Tcl_InitHashTable(hTblPtr, TCL_ONE_WORD_KEYS);
(void) Tcl_SetAssocData(interp, "tclTCPAcceptCallbacks",
TcpAcceptCallbacksDeleteProc, hTblPtr);
}
hPtr = Tcl_CreateHashEntry(hTblPtr, (char *) acceptCallbackPtr, &isNew);
if (!isNew) {
Tcl_Panic("RegisterTcpServerCleanup: damaged accept record table");
}
Tcl_SetHashValue(hPtr, acceptCallbackPtr);
}
示例15: create_name_hash
void
create_name_hash( FILE *fd )
{
char line[MAX_LINE_SIZE];
Tcl_HashEntry *hash_entry=NULL;
int new_entry=0;
Tcl_InitHashTable( &htbl, TCL_STRING_KEYS );
while ( bu_fgets( line, MAX_LINE_SIZE, fd ) ) {
char *part_no, *desc, *ptr;
ptr = strtok( line, " \t\n" );
if ( !ptr )
bu_exit( 1, "%s: *****Error processing part name file at line:\n\t%s\n", progname,line );
part_no = bu_strdup( ptr );
lower_case( part_no );
ptr = strtok( (char *)NULL, " \t\n" );
if ( !ptr )
bu_exit( 1, "%s: *****Error processing part name file at line:\n\t%s\n", progname,line );
desc = bu_strdup( ptr );
lower_case( desc );
hash_entry = Tcl_CreateHashEntry( &htbl, part_no, &new_entry );
if ( new_entry ) {
Tcl_SetHashValue( hash_entry, desc );
} else {
bu_free( (char *)part_no, "part_no" );
bu_free( (char *)desc, "desc" );
}
}
}