Index: configure =================================================================== diff -u -ra0faba200038c44cda56f3f421361563b4bd95d7 -rc01b411cdc631fd8e3eea9bf8fea985837a2b4b3 --- configure (.../configure) (revision a0faba200038c44cda56f3f421361563b4bd95d7) +++ configure (.../configure) (revision c01b411cdc631fd8e3eea9bf8fea985837a2b4b3) @@ -5562,7 +5562,7 @@ vars="nsf.c nsfError.c nsfObjectData.c nsfProfile.c \ nsfDebug.c nsfUtil.c nsfObj.c nsfPointer.c nsfEnumerationType.c \ - nsfCmdDefinitions.c nsfShadow.c nsfCompile.c aolstub.c \${srcdir}/generic/${stubdir}/nsfStubInit.${OBJEXT}" + nsfCmdDefinitions.c nsfFunPtrHashTable.c nsfShadow.c nsfCompile.c aolstub.c \${srcdir}/generic/${stubdir}/nsfStubInit.${OBJEXT}" for i in $vars; do case $i in \$*) Index: configure.ac =================================================================== diff -u -ra0faba200038c44cda56f3f421361563b4bd95d7 -rc01b411cdc631fd8e3eea9bf8fea985837a2b4b3 --- configure.ac (.../configure.ac) (revision a0faba200038c44cda56f3f421361563b4bd95d7) +++ configure.ac (.../configure.ac) (revision c01b411cdc631fd8e3eea9bf8fea985837a2b4b3) @@ -221,7 +221,7 @@ stubdir=stubs${TCL_MAJOR_VERSION}.${TCL_MINOR_VERSION} TEA_ADD_SOURCES([nsf.c nsfError.c nsfObjectData.c nsfProfile.c \ nsfDebug.c nsfUtil.c nsfObj.c nsfPointer.c nsfEnumerationType.c \ - nsfCmdDefinitions.c nsfShadow.c nsfCompile.c aolstub.c \${srcdir}/generic/${stubdir}/nsfStubInit.${OBJEXT}]) + nsfCmdDefinitions.c nsfFunPtrHashTable.c nsfShadow.c nsfCompile.c aolstub.c \${srcdir}/generic/${stubdir}/nsfStubInit.${OBJEXT}]) TEA_ADD_HEADERS([generic/nsf.h generic/nsfInt.h generic/${stubdir}/nsfDecls.h generic/${stubdir}/nsfIntDecls.h]) TEA_ADD_INCLUDES([]) TEA_ADD_LIBS([]) Index: generic/nsfCmdDefinitions.c =================================================================== diff -u -r760d5e6aa44c07331fea3c109385c309d906779c -rc01b411cdc631fd8e3eea9bf8fea985837a2b4b3 --- generic/nsfCmdDefinitions.c (.../nsfCmdDefinitions.c) (revision 760d5e6aa44c07331fea3c109385c309d906779c) +++ generic/nsfCmdDefinitions.c (.../nsfCmdDefinitions.c) (revision c01b411cdc631fd8e3eea9bf8fea985837a2b4b3) @@ -1,10 +1,11 @@ /* * nsfCmdDefinitions.c -- * - * Provide API for registering method definitions - * and obtaining this data for introspection + * Provide an API for registering method definitions + * and obtaining these meta-data for introspection. * * Copyright (C) 2014-2016 Gustaf Neumann + * Copyright (C) 2016 Stefan Sobernig * * Vienna University of Economics and Business * Institute of Information Systems and New Media @@ -43,156 +44,11 @@ static int Register(Tcl_Interp *interp, Nsf_methodDefinition *methodDefinition); - /* - * Defintions for HashType cmdPtr. - * - * Background: since it is not guaranteed that sizeof(function pointer) == - * sizeof(data pointer) (or sizeof(function pointer) <= sizeof(data pointer)), - * passing function pointers via data pointers - which is the default tcl hash - * types do - is dangerous. So we define our own type that allows to hash on - * function pointers safely. - * - */ -static unsigned int CmdPtrKey(Tcl_HashTable *tablePtr, VOID *keyPtr); -static int CompareCmdPtrKeys(VOID *keyPtr, Tcl_HashEntry *hPtr); -static Tcl_HashEntry *AllocCmdPtrEntry(Tcl_HashTable *tablePtr, VOID *keyPtr); - -typedef struct cmdPtrEntry_t { - Tcl_ObjCmdProc *proc; -} cmdPtrEntry_t; - -static Tcl_HashKeyType cmdPtrHashKeyType = { - 1, /* version*/ - 0, /* flags */ - CmdPtrKey, /* hashKeyProc*/ - CompareCmdPtrKeys, /* compareKeysProc */ - AllocCmdPtrEntry, /* allocEntryProc */ - NULL, /* freeEntryProc */ -}; - -/* *---------------------------------------------------------------------- - * - * CmdPtrKey -- - * - * Compute a unsigned int hash value from a function pointer. - * - * Results: - * Hash value. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -static unsigned int -CmdPtrKey( - Tcl_HashTable *tablePtr, /* Hash table. */ - VOID *keyPtr) /* Key from which to compute hash value. */ -{ - cmdPtrEntry_t *cmdEntryPtr = (cmdPtrEntry_t *)keyPtr; - Tcl_ObjCmdProc *value = cmdEntryPtr->proc; - - //fprintf(stderr, "=== hash from %p = %u // 0x%x\n", (void *)value, PTR2UINT(value), PTR2UINT(value)); - /* - * This is a very simple approach for obtaining a hash value. Maybe one - * needs a more sophisticated approach with wierd endians machines. - */ - return PTR2UINT(value); - - /* - as a reference: tcl's string hash functions - - register unsigned int result; - register int c; - result = 0; - - for (c=*string++ ; c ; c=*string++) { - result += (result<<3) + c; - } - return result; - */ -} - -/* - *---------------------------------------------------------------------- - * - * CompareCmdPtrKeys -- - * - * Compares two cmd ptr keys. - * - * Results: - * The return value is 0 if they are different and 1 if they are the - * same. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -static int -CompareCmdPtrKeys( - VOID *keyPtr, /* New key to compare. */ - Tcl_HashEntry *hPtr) /* Existing key to compare. */ -{ - cmdPtrEntry_t *cmdEntryPtr = (cmdPtrEntry_t *)keyPtr; - Tcl_ObjCmdProc *existingValue; - - memcpy(&existingValue, &hPtr->key.oneWordValue, sizeof(Tcl_ObjCmdProc *)); - - //fprintf(stderr, "=== compare new %p existing %p\n", (void *)cmdPtr->proc, (void *)existingValue); - - return cmdEntryPtr->proc == existingValue; -} - -/* - *---------------------------------------------------------------------- - * - * AllocCmdPtrEntry -- - * - * Allocate space for a Tcl_HashEntry containing the cmd ptr - * - * Results: - * The return value is a pointer to the created entry. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ -static Tcl_HashEntry * -AllocCmdPtrEntry( - Tcl_HashTable *tablePtr, /* Hash table. */ - VOID *keyPtr) /* Key to store in the hash table entry. */ -{ - cmdPtrEntry_t *cmdEntryPtr = (cmdPtrEntry_t *)keyPtr; - Tcl_HashEntry *hPtr; - unsigned int size; - Tcl_ObjCmdProc *value = cmdEntryPtr->proc; - - size = sizeof(Tcl_HashEntry) + (sizeof(Tcl_ObjCmdProc *)) - sizeof(hPtr->key); - if (size < sizeof(Tcl_HashEntry)) { - size = sizeof(Tcl_HashEntry); - } - //fprintf(stderr, "=== alloc entry %p\n", (void *)value); - hPtr = (Tcl_HashEntry *) ckalloc(size); - - //fprintf(stderr, "=== trying to copy %ld bytes from %p to %p\n", sizeof(Tcl_ObjCmdProc *), (void *)value, &hPtr->key.oneWordValue); - memcpy(&hPtr->key.oneWordValue, &value, sizeof(Tcl_ObjCmdProc *)); - - hPtr->clientData = 0; - - return hPtr; -} - -/* - *---------------------------------------------------------------------- * Nsf_CmdDefinitionInit -- * - * Initialize cmd definition structures + * Initialize the hash-table structure for storing the method definitions. * * Results: * None. @@ -210,8 +66,9 @@ NsfMutexLock(&cmdDefinitonMutex); if (cmdDefinitonRefCount == 0) { - // Tcl_InitHashTable(cmdDefinitonHashTablePtr, TCL_ONE_WORD_KEYS); - Tcl_InitCustomHashTable(cmdDefinitonHashTablePtr, TCL_CUSTOM_PTR_KEYS, &cmdPtrHashKeyType); + /* Tcl_InitHashTable(cmdDefinitonHashTablePtr, TCL_ONE_WORD_KEYS); */ + /* Tcl_InitCustomHashTable(cmdDefinitonHashTablePtr, TCL_CUSTOM_PTR_KEYS, &cmdPtrHashKeyType); */ + Nsf_InitFunPtrHashTable(cmdDefinitonHashTablePtr); } cmdDefinitonRefCount++; @@ -251,10 +108,10 @@ *---------------------------------------------------------------------- * Nsf_CmdDefinitionGet -- * - * Obtain the definiton for a registered proc + * Obtain the definiton for a previously registered proc. * * Results: - * method definition or NULL + * A pointer to a Method definition or NULL. * * Side effects: * None. @@ -264,15 +121,13 @@ Nsf_methodDefinition * Nsf_CmdDefinitionGet(Tcl_ObjCmdProc *proc) { Tcl_HashEntry *hPtr; - cmdPtrEntry_t cmdEntry; nonnull_assert(proc != NULL); //fprintf(stderr, "=== Lookup proc %p\n", proc); - cmdEntry.proc = proc; NsfMutexLock(&cmdDefinitonMutex); - hPtr = Tcl_FindHashEntry(cmdDefinitonHashTablePtr, (const char *)&cmdEntry); + hPtr = Nsf_FindFunPtrHashEntry(cmdDefinitonHashTablePtr, (Nsf_AnyFun *)proc); NsfMutexUnlock(&cmdDefinitonMutex); if (hPtr != NULL) { @@ -286,7 +141,7 @@ *---------------------------------------------------------------------- * Register -- * - * Register a method Definition + * Register a method definition. * * Results: * Tcl result code. @@ -302,17 +157,17 @@ Register(Tcl_Interp *interp, Nsf_methodDefinition *methodDefinition) { Tcl_HashEntry *hPtr; int isNew; - cmdPtrEntry_t cmdEntry; + /* cmdPtrEntry_t cmdEntry; */ nonnull_assert(interp != NULL); nonnull_assert(methodDefinition != NULL); //fprintf(stderr, "=== Register proc %p with name %s\n", methodDefinition->proc, methodDefinition->methodName); - cmdEntry.proc = methodDefinition->proc; + /* cmdEntry.proc = methodDefinition->proc; */ NsfMutexLock(&cmdDefinitonMutex); - hPtr = Tcl_CreateHashEntry(cmdDefinitonHashTablePtr, (const char *)&cmdEntry, &isNew); + hPtr = Nsf_CreateFunPtrHashEntry(cmdDefinitonHashTablePtr, (Nsf_AnyFun *)methodDefinition->proc, &isNew); /* Tcl_CreateHashEntry(cmdDefinitonHashTablePtr, (const char *)&cmdEntry, &isNew);*/ NsfMutexUnlock(&cmdDefinitonMutex); - + if (isNew != 0) { Tcl_SetHashValue(hPtr, methodDefinition); return TCL_OK; Index: generic/nsfEnumerationType.c =================================================================== diff -u -r16a02881bff0a0d626d0045dfd96660338d0c314 -rc01b411cdc631fd8e3eea9bf8fea985837a2b4b3 --- generic/nsfEnumerationType.c (.../nsfEnumerationType.c) (revision 16a02881bff0a0d626d0045dfd96660338d0c314) +++ generic/nsfEnumerationType.c (.../nsfEnumerationType.c) (revision c01b411cdc631fd8e3eea9bf8fea985837a2b4b3) @@ -1,10 +1,11 @@ /* * nsfEnumerationType.c -- * - * Provide API for registering enumeration types - * and obtaining their domain. + * Provide an API for registering enumeration types + * and obtaining their domains. * * Copyright (C) 2014 Gustaf Neumann + * Copyright (C) 2016 Stefan Sobernig * * Vienna University of Economics and Business * Institute of Information Systems and New Media @@ -46,7 +47,7 @@ *---------------------------------------------------------------------- * Nsf_EnumerationTypeInit -- * - * Initialize enumeration type converters + * Initialize a hash table to keep the enumeration-type converters. * * Results: * None. @@ -64,7 +65,8 @@ NsfMutexLock(&enumerationMutex); if (enumerationTypeRefCount == 0) { - Tcl_InitHashTable(enumerationHashTablePtr, TCL_STRING_KEYS); + /* Tcl_InitHashTable(enumerationHashTablePtr, TCL_STRING_KEYS); */ + Nsf_InitFunPtrHashTable(enumerationHashTablePtr); } enumerationTypeRefCount++; @@ -75,10 +77,10 @@ *---------------------------------------------------------------------- * Nsf_EnumerationTypeRegister -- * - * Register an array of enumeration types + * Registers an array of enumeration types upon NSF initialization. * * Results: - * TCL_OK + * Tcl result code. * * Side effects: * None. @@ -106,27 +108,29 @@ *---------------------------------------------------------------------- * Nsf_EnumerationTypeGetDomain -- * - * Obtain the domain from an enumeration type converter + * Obtain the domain (i.e., the permitted enumeration literals) for a given + * enumeration-type converter. * - * Results: - * domain as a string or NULL, if not successful + * Results: + * Domain of permitted enumeration literals as a string or NULL, if + * not successful. * * Side effects: - * None. + * Sets a mutex lock. * *---------------------------------------------------------------------- */ const char * Nsf_EnumerationTypeGetDomain(Nsf_TypeConverter *converter) { Tcl_HashEntry *hPtr; - Tcl_HashSearch hSrch; + /* Tcl_HashSearch hSrch; */ const char* domain = NULL; nonnull_assert(converter != NULL); NsfMutexLock(&enumerationMutex); - - for (hPtr = Tcl_FirstHashEntry(enumerationHashTablePtr, &hSrch); hPtr != NULL; + hPtr = Nsf_FindFunPtrHashEntry(enumerationHashTablePtr, (Nsf_AnyFun *)converter); + /* for (hPtr = Tcl_FirstHashEntry(enumerationHashTablePtr, &hSrch); hPtr != NULL; hPtr = Tcl_NextHashEntry(&hSrch)) { Nsf_TypeConverter *ptr = (Nsf_TypeConverter *)Tcl_GetHashValue(hPtr); @@ -135,22 +139,27 @@ break; } } + */ NsfMutexUnlock(&enumerationMutex); + if (hPtr != NULL) { + domain = Tcl_GetHashValue(hPtr); + } + return domain; } /* *---------------------------------------------------------------------- * Register -- * - * Register a enumeration type converter and its domain. + * Register a enumeration-type converter and its domain. * * Results: * Tcl result code. * * Side effects: - * None. + * Sets a mutex lock. * *---------------------------------------------------------------------- */ @@ -164,11 +173,12 @@ nonnull_assert(converter != NULL); NsfMutexLock(&enumerationMutex); - hPtr = Tcl_CreateHashEntry(enumerationHashTablePtr, domain, &isNew); + hPtr = Nsf_CreateFunPtrHashEntry(enumerationHashTablePtr, (Nsf_AnyFun *)converter, &isNew); + // hPtr = Tcl_CreateHashEntry(enumerationHashTablePtr, domain, &isNew); NsfMutexUnlock(&enumerationMutex); if (isNew != 0) { - Tcl_SetHashValue(hPtr, converter); + Tcl_SetHashValue(hPtr, domain); } else { /* * In general, it would make sense to return an error here, but for Index: generic/nsfFunPtrHashTable.c =================================================================== diff -u --- generic/nsfFunPtrHashTable.c (revision 0) +++ generic/nsfFunPtrHashTable.c (revision c01b411cdc631fd8e3eea9bf8fea985837a2b4b3) @@ -0,0 +1,282 @@ +/* + * nsfFunPtrHashTable.c -- + * + * Provide a custom Tcl hash table type, using function pointers + * as hash keys, and a slim wrapper around Tcl's HashTable + * API to manage them. + * + * Copyright (C) 2016 Gustaf Neumann + * Copyright (C) 2016 Stefan Sobernig + * + * Vienna University of Economics and Business + * Institute of Information Systems and New Media + * A-1020, Welthandelsplatz 1 + * Vienna, Austria + * + * This work is licensed under the MIT License http://www.opensource.org/licenses/MIT + * + * Copyright: + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + */ + + +#include "nsfInt.h" + +/* + * Defintions for HashType funPtr. + * + * Background: since it is not guaranteed that sizeof(function + * pointer) == sizeof(data pointer) (or sizeof(function pointer) <= + * sizeof(data pointer)), passing function pointers via data pointers + * - which is what default tcl hash types do - is potentially + * dangerous. Therefore, and on top, it is not allowed under ISO + * C. So, we define our own type that allows to hash on function + * pointers safely. + * + */ +static unsigned int FunPtrKey(Tcl_HashTable *tablePtr, VOID *keyPtr); +static int CompareFunPtrKeys(VOID *keyPtr, Tcl_HashEntry *hPtr); +static Tcl_HashEntry *AllocFunPtrEntry(Tcl_HashTable *tablePtr, VOID *keyPtr); + +typedef struct funPtrEntry_t { + Nsf_AnyFun *funPtr; +} funPtrEntry_t; + +static Tcl_HashKeyType funPtrHashKeyType = { + 1, /* version*/ + 0, /* flags */ + FunPtrKey, /* hashKeyProc*/ + CompareFunPtrKeys, /* compareKeysProc */ + AllocFunPtrEntry, /* allocEntryProc */ + NULL, /* freeEntryProc */ +}; + +/* + *---------------------------------------------------------------------- + * + * FunPtrKey -- + * + * Computes an unsigned int hash value from a function pointer. + * + * Results: + * Returns the computed hash. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +static unsigned int +FunPtrKey( + Tcl_HashTable *tablePtr, /* Hash table. */ + VOID *keyPtr) /* Key from which to compute hash value. */ +{ + funPtrEntry_t *e = (funPtrEntry_t *)keyPtr; + Nsf_AnyFun *value = e->funPtr; + + //fprintf(stderr, "=== hash from %p = %u // 0x%x\n", (void *)value, PTR2UINT(value), PTR2UINT(value)); + /* + * This is a very simple approach for obtaining a hash value. Maybe one + * needs a more sophisticated approach with wierd endians machines. + */ + return PTR2UINT(value); + + /* + as a reference: tcl's string hash functions + + register unsigned int result; + register int c; + result = 0; + + for (c=*string++ ; c ; c=*string++) { + result += (result<<3) + c; + } + return result; + */ +} + +/* + *---------------------------------------------------------------------- + * + * CompareFunPtrKeys -- + * + * Compares two function pointer keys. + * + * Results: + * The return value is 0 if they are different and 1 if they are the + * same. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +static int +CompareFunPtrKeys( + VOID *keyPtr, /* New key to compare. */ + Tcl_HashEntry *hPtr) /* Existing key to compare. */ +{ + funPtrEntry_t *e = (funPtrEntry_t *)keyPtr; + Nsf_AnyFun *existingValue; + + memcpy(&existingValue, &hPtr->key.oneWordValue, sizeof(Nsf_AnyFun *)); + + //fprintf(stderr, "=== compare new %p existing %p\n", (void *)cmdPtr->proc, (void *)existingValue); + + return e->funPtr == existingValue; +} + +/* + *---------------------------------------------------------------------- + * + * AllocFunPtrEntry -- + * + * Allocate space for a Tcl_HashEntry containing the function pointer. + * + * Results: + * The return value is a pointer to the created entry. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ +static Tcl_HashEntry * +AllocFunPtrEntry( + Tcl_HashTable *tablePtr, /* Hash table. */ + VOID *keyPtr) /* Key to store in the hash table entry. */ +{ + funPtrEntry_t *e = (funPtrEntry_t *)keyPtr; + Tcl_HashEntry *hPtr; + unsigned int size; + Nsf_AnyFun *value = e->funPtr; + + size = sizeof(Tcl_HashEntry) + (sizeof(Nsf_AnyFun *)) - sizeof(hPtr->key); + if (size < sizeof(Tcl_HashEntry)) { + size = sizeof(Tcl_HashEntry); + } + /* fprintf(stderr, "=== alloc entry %p\n", (void *)value); */ + hPtr = (Tcl_HashEntry *) ckalloc(size); + + /* fprintf(stderr, "=== trying to copy %ld bytes from %p to %p\n", + sizeof(Nsf_AnyFun *), (void *)value, &hPtr->key.oneWordValue); */ + memcpy(&hPtr->key.oneWordValue, &value, sizeof(Nsf_AnyFun *)); + + hPtr->clientData = 0; + + return hPtr; +} + +/* + *---------------------------------------------------------------------- + * Nsf_InitFunPtrHashTable -- + * + * Initializes a hash table structure providing for function + * pointers as hash keys. It is a slim wrapper around + * Tcl_InitCustomHashTable(). + * + * Results: + * None. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ +void +Nsf_InitFunPtrHashTable(Tcl_HashTable *tablePtr) { + + nonnull_assert(tablePtr != NULL); + + Tcl_InitCustomHashTable(tablePtr, TCL_CUSTOM_PTR_KEYS, &funPtrHashKeyType); + +} + +/* + *---------------------------------------------------------------------- + * Nsf_CreateFunPtrHashEntry -- + * + * Creates or finds an entry based on a given function-pointer + * key. It is a slim wrapper around Tcl_CreateHashEntry(). + * + * Results: + * Returns a pointer to the matching entry. + * + * Side effects: + * A new entry may be stored in the hash table. + * + *---------------------------------------------------------------------- + */ + +Tcl_HashEntry * +Nsf_CreateFunPtrHashEntry(Tcl_HashTable *tablePtr, Nsf_AnyFun *key, int *isNew) { + Tcl_HashEntry *hPtr; + funPtrEntry_t entry; + + nonnull_assert(tablePtr != NULL); + nonnull_assert(key != NULL); + + entry.funPtr = key; + hPtr = Tcl_CreateHashEntry(tablePtr, (const char *)&entry, isNew); + return hPtr; + +} + +/* + *---------------------------------------------------------------------- + * Nsf_FindFunPtrHashEntry -- + * + * Finds the entry with a matching function-pointer key in a given + * table. It is a slim wrapper around Tcl_FindHashEntry(). + * + * Results: + * Returns a pointer to the matching entry, or NULL. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +Tcl_HashEntry * +Nsf_FindFunPtrHashEntry(Tcl_HashTable *tablePtr, Nsf_AnyFun *key) { + Tcl_HashEntry *hPtr; + funPtrEntry_t entry; + + nonnull_assert(tablePtr != NULL); + nonnull_assert(key != NULL); + + entry.funPtr = key; + hPtr = Tcl_FindHashEntry(tablePtr, (const char *)&entry); + return hPtr; + +} + +/* + * Local Variables: + * mode: c + * c-basic-offset: 2 + * fill-column: 78 + * indent-tabs-mode: nil + * End: + */ Index: generic/nsfInt.h =================================================================== diff -u -r6c041dc5e75dfb3fc2c119ca2cfdc1824968f293 -rc01b411cdc631fd8e3eea9bf8fea985837a2b4b3 --- generic/nsfInt.h (.../nsfInt.h) (revision 6c041dc5e75dfb3fc2c119ca2cfdc1824968f293) +++ generic/nsfInt.h (.../nsfInt.h) (revision c01b411cdc631fd8e3eea9bf8fea985837a2b4b3) @@ -1220,17 +1220,34 @@ void NsfStringIncrFree(NsfStringIncrStruct *iss) nonnull(1); + /* - * Nsf Enumeration type interface + * Interface for NSF's custom hash tables supporting function + * pointers as keys. + * */ + +typedef void (Nsf_AnyFun)(); + +EXTERN void Nsf_InitFunPtrHashTable(Tcl_HashTable *tablePtr) + nonnull(1); +EXTERN Tcl_HashEntry *Nsf_CreateFunPtrHashEntry(Tcl_HashTable *tablePtr, Nsf_AnyFun *key, int *isNew) + nonnull(1) nonnull(2); +EXTERN Tcl_HashEntry *Nsf_FindFunPtrHashEntry(Tcl_HashTable *tablePtr, Nsf_AnyFun *key) + nonnull(1) nonnull(2); + + +/* + * NSF enumeration-type interface + */ EXTERN void Nsf_EnumerationTypeInit(Tcl_Interp *interp) nonnull(1); EXTERN const char *Nsf_EnumerationTypeGetDomain(Nsf_TypeConverter *converter) nonnull(1); /* - * Nsf Cmd definition interface + * NSF command definitions interface */ EXTERN void Nsf_CmdDefinitionInit(Tcl_Interp *interp) nonnull(1);