/* * Ttk_GetElement -- * Look up an element implementation by name in a given theme. * If not found, try generic element names in this theme, then * repeat the lookups in the parent theme. * If not found, return the null element. */ Ttk_ElementImpl Ttk_GetElement(Ttk_Theme themePtr, const char *elementName) { Tcl_HashEntry *entryPtr; const char *dot = elementName; /* * Check if element has already been registered: */ entryPtr = Tcl_FindHashEntry(&themePtr->elementTable, elementName); if (entryPtr) { return (Ttk_ElementImpl)Tcl_GetHashValue(entryPtr); } /* * Check generic names: */ while (!entryPtr && ((dot = strchr(dot, '.')) != NULL)) { dot++; entryPtr = Tcl_FindHashEntry(&themePtr->elementTable, dot); } if (entryPtr) { return (ElementImpl *)Tcl_GetHashValue(entryPtr); } /* * Check parent theme: */ if (themePtr->parentPtr) { return Ttk_GetElement(themePtr->parentPtr, elementName); } /* * Not found, and this is the root theme; return null element, "". * (@@@ SHOULD: signal a background error) */ entryPtr = Tcl_FindHashEntry(&themePtr->elementTable, ""); /* ASSERT: entryPtr != 0 */ return (Ttk_ElementImpl)Tcl_GetHashValue(entryPtr); }
ClientData NextSigMapEntry ( SignalMapSearch *searchPtr) { Tcl_HashEntry *entryPtr; entryPtr = Tcl_NextHashEntry(searchPtr); if (entryPtr != NULL) { return Tcl_GetHashValue(entryPtr); } else { return NULL; } }
/* * Ttk_StyleMap -- * Look up state-specific option value from specified style. */ Tcl_Obj *Ttk_StyleMap(Ttk_Style style, const char *optionName, Ttk_State state) { while (style) { Tcl_HashEntry *entryPtr = Tcl_FindHashEntry(&style->settingsTable, optionName); if (entryPtr) { Ttk_StateMap stateMap = Tcl_GetHashValue(entryPtr); return Ttk_StateMapLookup(NULL, stateMap, state); } style = style->parentStyle; } return 0; }
static TkBitmap * GetBitmapFromObj( Tk_Window tkwin, /* Window in which the bitmap will be used. */ Tcl_Obj *objPtr) /* The object that describes the desired * bitmap. */ { TkBitmap *bitmapPtr; Tcl_HashEntry *hashPtr; TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr; if (objPtr->typePtr != &tkBitmapObjType) { InitBitmapObj(objPtr); } bitmapPtr = objPtr->internalRep.twoPtrValue.ptr1; if (bitmapPtr != NULL) { if ((bitmapPtr->resourceRefCount > 0) && (Tk_Display(tkwin) == bitmapPtr->display)) { return bitmapPtr; } hashPtr = bitmapPtr->nameHashPtr; FreeBitmapObj(objPtr); } else { hashPtr = Tcl_FindHashEntry(&dispPtr->bitmapNameTable, Tcl_GetString(objPtr)); if (hashPtr == NULL) { goto error; } } /* * At this point we've got a hash table entry, off of which hang one or * more TkBitmap structures. See if any of them will work. */ for (bitmapPtr = Tcl_GetHashValue(hashPtr); bitmapPtr != NULL; bitmapPtr = bitmapPtr->nextPtr) { if (Tk_Display(tkwin) == bitmapPtr->display) { objPtr->internalRep.twoPtrValue.ptr1 = bitmapPtr; bitmapPtr->objRefCount++; return bitmapPtr; } } error: Tcl_Panic("GetBitmapFromObj called with non-existent bitmap!"); /* * The following code isn't reached; it's just there to please compilers. */ return NULL; }
/* Get material pointer from material name */ int get_material(const char *mat_name, material_t **mat ) { Tcl_HashEntry *entry; entry = Tcl_FindHashEntry(&g_hier_material_table, mat_name); if (0 == entry) { return TCL_ERROR; } else { *mat = (material_t*)Tcl_GetHashValue(entry); } return TCL_OK; }
/* Destroy the RR hash for a sender, and all its associated values. */ void Delete_RR_Hash(member *the_member) { Tcl_HashTable *the_table = &the_member->RR_Hash; Tcl_HashEntry *the_entry; Tcl_HashSearch the_search; the_entry = Tcl_FirstHashEntry(the_table, &the_search); while (the_entry != NULL) { free(Tcl_GetHashValue(the_entry)); the_entry = Tcl_NextHashEntry(&the_search); } Tcl_DeleteHashTable(the_table); }
void tn_delete (TNPtr n) { T* t = n->tree; /* We assume that the node either has no parent or siblings anymore, * or that their presence does not matter. The node may still have * children. They are deleted recursively. That is the situation * where the parent/sibling information does not matter anymore, and * can be ignored. */ tn_notleaf (n); tn_notnode (n); Tcl_DecrRefCount (n->name); n->name = NULL; Tcl_DeleteHashEntry (n->he); n->he = NULL; if (n->child) { int i; for (i = 0; i < n->nchildren; i++) { ASSERT_BOUNDS (i, n->nchildren); tn_delete (n->child [i]); n->child [i] = NULL; } ckfree ((char*) n->child); n->child = NULL; n->nchildren = 0; n->maxchildren = 0; } if (n->attr) { Tcl_HashSearch hs; Tcl_HashEntry* he; for(he = Tcl_FirstHashEntry(n->attr, &hs); he != NULL; he = Tcl_NextHashEntry(&hs)) { Tcl_DecrRefCount ((Tcl_Obj*) Tcl_GetHashValue(he)); } Tcl_DeleteHashTable(n->attr); ckfree ((char*) n->attr); n->attr = NULL; } ckfree ((char*) n); }
void * TclpThreadDataKeyGet( Tcl_ThreadDataKey *keyPtr) /* Identifier for the data chunk, really * (int**) */ { Tcl_HashTable *hashTablePtr = ThreadStorageGetHashTable(Tcl_GetCurrentThread()); Tcl_HashEntry *hPtr = Tcl_FindHashEntry(hashTablePtr, (char *) keyPtr); if (hPtr == NULL) { return NULL; } return Tcl_GetHashValue(hPtr); }
static void FuzzyVoteAccumSet (Tcl_HashTable *accum, List<AccumElement> *bins, int x, int y, int scale, int val) { int loc[3]; loc[0] = x; loc[1] = y; loc[2] = scale; Tcl_HashEntry *entry = Tcl_FindHashEntry(accum,(char*)loc); AccumElement *elem = (AccumElement*)(Tcl_GetHashValue(entry)); bins[elem->value].unchain(elem); if (val>255) val = 255; bins[val].addLast(elem); elem->value = val; }
void Ttk_DeleteTagTable(Ttk_TagTable tagTable) { Tcl_HashSearch search; Tcl_HashEntry *entryPtr; entryPtr = Tcl_FirstHashEntry(&tagTable->tags, &search); while (entryPtr != NULL) { DeleteTag(tagTable, Tcl_GetHashValue(entryPtr)); entryPtr = Tcl_NextHashEntry(&search); } Tcl_DeleteHashTable(&tagTable->tags); ckfree((void*)tagTable); }
ClientData FirstSigMapEntry ( SignalMap *sigmapPtr, SignalMapSearch *searchPtr) { Tcl_HashEntry *entryPtr; entryPtr = Tcl_FirstHashEntry(sigmapPtr, searchPtr); if (entryPtr != NULL) { return Tcl_GetHashValue(entryPtr); } else { return NULL; } }
static void FuzzyVoteAccumZero (Tcl_HashTable *accum, List<AccumElement> *bins, int x, int y, int scale) { int loc[3]; loc[0] = x; loc[1] = y; loc[2] = scale; Tcl_HashEntry *entry = Tcl_FindHashEntry(accum,(char*)loc); if (entry == NULL) return; AccumElement *elem = (AccumElement*)(Tcl_GetHashValue(entry)); bins[elem->value].unchain(elem); bins[0].addLast(elem); elem->value = 0; }
void TkDeleteAllImages( TkMainInfo *mainPtr) /* Structure describing application that is * going away. */ { Tcl_HashSearch search; Tcl_HashEntry *hPtr; for (hPtr = Tcl_FirstHashEntry(&mainPtr->imageTable, &search); hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) { EventuallyDeleteImage(Tcl_GetHashValue(hPtr), 1); } Tcl_DeleteHashTable(&mainPtr->imageTable); }
Tcl_DBusBus *DBus_GetConnection(Tcl_Interp *interp, Tcl_Obj *const name) { Tcl_HashEntry *entry; Tcl_DBusBus *dbus; entry = Tcl_FindHashEntry(&bus, (char *) name); if (entry == NULL) return NULL; dbus = (Tcl_DBusBus *) Tcl_GetHashValue(entry); entry = Tcl_FindHashEntry(dbus->snoop, (char *) interp); if (entry != NULL) return dbus; else return NULL; }
int HTUTree_replaceNode_tcl(ClientData clientData, Tcl_Interp *interp, int argc, char **argv) { if (argc == 5) { char *tree_key = argv[1]; const char *realm = argv[2]; const char *path = argv[3]; char *void_key = argv[4]; if ( tree_key && realm && path) { Tcl_HashEntry *tree_entry = Tcl_FindHashEntry(&HTableUTree, tree_key); Tcl_HashEntry *void_entry = Tcl_FindHashEntry(&HTableVoid, void_key); if ( tree_entry && void_entry ) { HTUTree *tree = Tcl_GetHashValue(tree_entry); void *context = Tcl_GetHashValue(void_entry); BOOL result = HTUTree_replaceNode(tree, realm, path, context); Tcl_AppendResult(interp, result ? "YES" : "NO", NULL); return TCL_OK; } } Tcl_AppendResult(interp, bad_vars, NULL); return TCL_ERROR; } Tcl_AppendResult(interp, bad_vars, NULL); return TCL_ERROR; }
void * Nsf_PointerTypeLookup(const char* typeName) { const Tcl_HashEntry *hPtr; nonnull_assert(typeName != NULL); NsfMutexLock(&pointerMutex); hPtr = Tcl_CreateHashEntry(pointerHashTablePtr, typeName, NULL); NsfMutexUnlock(&pointerMutex); if (hPtr != NULL) { return Tcl_GetHashValue(hPtr); } return NULL; }
/* *-------------------------------------------------------------- * * Table_ClearHashTable -- * This procedure is invoked to clear a STRING_KEY hash table, * freeing the string entries and then deleting the hash table. * The hash table cannot be used after calling this, except to * be freed or reinitialized. * * Results: * Cached info will be lost. * * Side effects: * Can cause redraw. * See the user documentation. * *-------------------------------------------------------------- */ void Table_ClearHashTable(Tcl_HashTable *hashTblPtr) { Tcl_HashEntry *entryPtr; Tcl_HashSearch search; char *value; for (entryPtr = Tcl_FirstHashEntry(hashTblPtr, &search); entryPtr != NULL; entryPtr = Tcl_NextHashEntry(&search)) { value = (char *) Tcl_GetHashValue(entryPtr); if (value != NULL) ckfree(value); } Tcl_DeleteHashTable(hashTblPtr); }
static Slave * FindSlave( Tk_Window tkwin) /* Token for desired slave. */ { Tcl_HashEntry *hPtr; register Slave *slavePtr; TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr; hPtr = Tcl_FindHashEntry(&dispPtr->slaveTable, (char *) tkwin); if (hPtr == NULL) { return NULL; } slavePtr = (Slave *) Tcl_GetHashValue(hPtr); return slavePtr; }
static Master * FindMaster( Tk_Window tkwin) /* Token for desired master. */ { Tcl_HashEntry *hPtr; register Master *masterPtr; TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr; hPtr = Tcl_FindHashEntry(&dispPtr->masterTable, (char *) tkwin); if (hPtr == NULL) { return NULL; } masterPtr = (Master *) Tcl_GetHashValue(hPtr); return masterPtr; }
int Tk_GetElementId( const char *name) /* Name of the element. */ { ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); Tcl_HashEntry *entryPtr; int genericId = -1; char *dot; /* * Find the element Id. */ entryPtr = Tcl_FindHashEntry(&tsdPtr->elementTable, name); if (entryPtr) { return PTR2INT(Tcl_GetHashValue(entryPtr)); } /* * Element not found. If the given name was derived, then first search for * the generic element. If found, create the new derived element. */ dot = strchr(name, '.'); if (!dot) { return -1; } genericId = Tk_GetElementId(dot+1); if (genericId == -1) { return -1; } if (!tsdPtr->elements[genericId].created) { /* * The generic element was created implicitly and thus has no real * existence. */ return -1; } else { /* * The generic element was created explicitly. Create the derived * element. */ return CreateElement(name, 1); } }
/* HashTableToDict -- * Helper routine. Converts a TCL_STRING_KEYS Tcl_HashTable * with Tcl_Obj * entries into a dictionary. */ static Tcl_Obj* HashTableToDict(Tcl_HashTable *ht) { Tcl_HashSearch search; Tcl_Obj *result = Tcl_NewListObj(0, NULL); Tcl_HashEntry *entryPtr = Tcl_FirstHashEntry(ht, &search); while (entryPtr != NULL) { Tcl_Obj *nameObj = Tcl_NewStringObj(Tcl_GetHashKey(ht, entryPtr),-1); Tcl_Obj *valueObj = Tcl_GetHashValue(entryPtr); Tcl_ListObjAppendElement(NULL, result, nameObj); Tcl_ListObjAppendElement(NULL, result, valueObj); entryPtr = Tcl_NextHashEntry(&search); } return result; }
static AP_Result tcl_delete_all(AP_World *ignore) { Tcl_HashEntry *entry; Tcl_HashSearch search; for (entry = Tcl_FirstHashEntry(&tcl_interp_name_table, &search); entry; entry = Tcl_NextHashEntry(&search)) { Tcl_DeleteInterp(Tcl_GetHashValue(entry)); } Tcl_DeleteHashTable(&tcl_interp_name_table); Tcl_InitHashTable(&tcl_interp_name_table, TCL_STRING_KEYS); return AP_SUCCESS; }
static Ttk_Theme LookupTheme( Tcl_Interp *interp, /* where to leave error messages */ StylePackageData *pkgPtr, /* style package master record */ const char *name) /* theme name */ { Tcl_HashEntry *entryPtr; entryPtr = Tcl_FindHashEntry(&pkgPtr->themeTable, name); if (!entryPtr) { Tcl_ResetResult(interp); Tcl_AppendResult(interp, "theme \"", name, "\" doesn't exist", NULL); return NULL; } return (Ttk_Theme)Tcl_GetHashValue(entryPtr); }
void Tfp_ArrayDestroy( Tfp_ArrayType *arr ) { Tcl_HashEntry *p; Tcl_HashSearch s; if (arr->cleanProc != (Tfp_ArrayDeleteProc *) NULL) { for (p = Tcl_FirstHashEntry( arr->table, &s ); p != (Tcl_HashEntry *) NULL; p = Tcl_NextHashEntry( &s )) { (*arr->cleanProc) ( Tcl_GetHashValue( p ) ); } } Tcl_DeleteHashTable( arr->table ); Tcl_Free( (char *) arr->table ); Tcl_Free( (char *) arr ); }
static void ChangeTagPriority( TkText *textPtr, /* Information about text widget. */ TkTextTag *tagPtr, /* Tag whose priority is to be changed. */ int prio) /* New priority for tag. */ { int low, high, delta; register TkTextTag *tagPtr2; Tcl_HashEntry *hPtr; Tcl_HashSearch search; if (prio < 0) { prio = 0; } if (prio >= textPtr->sharedTextPtr->numTags) { prio = textPtr->sharedTextPtr->numTags-1; } if (prio == tagPtr->priority) { return; } if (prio < tagPtr->priority) { low = prio; high = tagPtr->priority-1; delta = 1; } else { low = tagPtr->priority+1; high = prio; delta = -1; } /* * Adjust first the 'sel' tag, then all others from the hash table */ if ((textPtr->selTagPtr->priority >= low) && (textPtr->selTagPtr->priority <= high)) { textPtr->selTagPtr->priority += delta; } for (hPtr = Tcl_FirstHashEntry(&textPtr->sharedTextPtr->tagTable, &search); hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) { tagPtr2 = Tcl_GetHashValue(hPtr); if ((tagPtr2->priority >= low) && (tagPtr2->priority <= high)) { tagPtr2->priority += delta; } } tagPtr->priority = prio; }
Tk_Image Tk_GetImage( Tcl_Interp *interp, /* Place to leave error message if image can't * be found. */ Tk_Window tkwin, /* Token for window in which image will be * used. */ const char *name, /* Name of desired image. */ Tk_ImageChangedProc *changeProc, /* Function to invoke when redisplay is needed * because image's pixels or size changed. */ ClientData clientData) /* One-word argument to pass to damageProc. */ { Tcl_HashEntry *hPtr; ImageMaster *masterPtr; Image *imagePtr; hPtr = Tcl_FindHashEntry(&((TkWindow *) tkwin)->mainPtr->imageTable, name); if (hPtr == NULL) { goto noSuchImage; } masterPtr = Tcl_GetHashValue(hPtr); if (masterPtr->typePtr == NULL) { goto noSuchImage; } if (masterPtr->deleted) { goto noSuchImage; } imagePtr = ckalloc(sizeof(Image)); imagePtr->tkwin = tkwin; imagePtr->display = Tk_Display(tkwin); imagePtr->masterPtr = masterPtr; imagePtr->instanceData = masterPtr->typePtr->getProc(tkwin, masterPtr->masterData); imagePtr->changeProc = changeProc; imagePtr->widgetClientData = clientData; imagePtr->nextPtr = masterPtr->instancePtr; masterPtr->instancePtr = imagePtr; return (Tk_Image) imagePtr; noSuchImage: if (interp) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "image \"%s\" doesn't exist", name)); Tcl_SetErrorCode(interp, "TK", "LOOKUP", "IMAGE", name, NULL); } return NULL; }
int mpsa_GetSim( Tcl_Interp *interp, char *Label, mpsa_Simulation **Simulation ) { Tcl_HashEntry *Entry; Entry = Tcl_FindHashEntry(&mpsa_SimHashTable, Label); if(Entry == NULL) { Tcl_AppendResult(interp, "Error obtaining simulation named ", Label, (char *) NULL); return MPSA_FAIL; } else { *Simulation = (mpsa_Simulation *) Tcl_GetHashValue(Entry); } return MPSA_OKAY; }
static int FuzzyVoteAccumGet (Tcl_HashTable *accum, List<AccumElement> *bins, int x, int y, int scale) { int loc[3]; loc[0] = x; loc[1] = y; loc[2] = scale; Tcl_HashEntry *entry = Tcl_FindHashEntry(accum,(char*)loc); if (entry == NULL) { int newentry; entry = Tcl_CreateHashEntry(accum,(char*)loc,&newentry); AccumElement *elem = new AccumElement(x,y,scale,0,0,0); Tcl_SetHashValue(entry,elem); bins[0].addLast(elem); } return ((AccumElement*)(Tcl_GetHashValue(entry)))->value; }
void DBus_CheckProc(ClientData data, int flags) { DBusDispatchStatus dispatch; Tcl_HashEntry *hPtr; Tcl_HashSearch search; Tcl_DBusBus *dbus; if (!(flags & TCL_IDLE_EVENTS)) return; for (hPtr = Tcl_FirstHashEntry(&bus, &search); hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) { dbus = (Tcl_DBusBus *) Tcl_GetHashValue(hPtr); /* Drain the message queue */ do dispatch = dbus_connection_dispatch(dbus->conn); while (dispatch == DBUS_DISPATCH_DATA_REMAINS); } }
int DBus_MethodCleanup(Tcl_Interp *interp, Tcl_HashTable *members) { Tcl_HashEntry *memberPtr; Tcl_HashSearch search; Tcl_DBusMethodData *method; for (memberPtr = Tcl_FirstHashEntry(members, &search); memberPtr != NULL; memberPtr = Tcl_NextHashEntry(&search)) { method = Tcl_GetHashValue(memberPtr); if (method->interp == interp) { Tcl_DecrRefCount(method->script); ckfree((char *) method); Tcl_DeleteHashEntry(memberPtr); } } return Tcl_CheckHashEmpty(members); }