📄 tcl.h
字号:
typedef int (Tcl_CompareHashKeysProc) _ANSI_ARGS_((VOID *keyPtr, Tcl_HashEntry *hPtr));typedef Tcl_HashEntry *(Tcl_AllocHashEntryProc) _ANSI_ARGS_(( Tcl_HashTable *tablePtr, VOID *keyPtr));typedef void (Tcl_FreeHashEntryProc) _ANSI_ARGS_((Tcl_HashEntry *hPtr));/* * This flag controls whether the hash table stores the hash of a key, or * recalculates it. There should be no reason for turning this flag off * as it is completely binary and source compatible unless you directly * access the bucketPtr member of the Tcl_HashTableEntry structure. This * member has been removed and the space used to store the hash value. */#ifndef TCL_HASH_KEY_STORE_HASH# define TCL_HASH_KEY_STORE_HASH 1#endif/* * Structure definition for an entry in a hash table. No-one outside * Tcl should access any of these fields directly; use the macros * defined below. */struct Tcl_HashEntry { Tcl_HashEntry *nextPtr; /* Pointer to next entry in this * hash bucket, or NULL for end of * chain. */ Tcl_HashTable *tablePtr; /* Pointer to table containing entry. */#if TCL_HASH_KEY_STORE_HASH# if TCL_PRESERVE_BINARY_COMPATABILITY VOID *hash; /* Hash value, stored as pointer to * ensure that the offsets of the * fields in this structure are not * changed. */# else unsigned int hash; /* Hash value. */# endif#else Tcl_HashEntry **bucketPtr; /* Pointer to bucket that points to * first entry in this entry's chain: * used for deleting the entry. */#endif ClientData clientData; /* Application stores something here * with Tcl_SetHashValue. */ union { /* Key has one of these forms: */ char *oneWordValue; /* One-word value for key. */ Tcl_Obj *objPtr; /* Tcl_Obj * key value. */ int words[1]; /* Multiple integer words for key. * The actual size will be as large * as necessary for this table's * keys. */ char string[4]; /* String for key. The actual size * will be as large as needed to hold * the key. */ } key; /* MUST BE LAST FIELD IN RECORD!! */};/* * Flags used in Tcl_HashKeyType. * * TCL_HASH_KEY_RANDOMIZE_HASH: * There are some things, pointers for example * which don't hash well because they do not use * the lower bits. If this flag is set then the * hash table will attempt to rectify this by * randomising the bits and then using the upper * N bits as the index into the table. */#define TCL_HASH_KEY_RANDOMIZE_HASH 0x1/* * Structure definition for the methods associated with a hash table * key type. */#define TCL_HASH_KEY_TYPE_VERSION 1struct Tcl_HashKeyType { int version; /* Version of the table. If this structure is * extended in future then the version can be * used to distinguish between different * structures. */ int flags; /* Flags, see above for details. */ /* Calculates a hash value for the key. If this is NULL then the pointer * itself is used as a hash value. */ Tcl_HashKeyProc *hashKeyProc; /* Compares two keys and returns zero if they do not match, and non-zero * if they do. If this is NULL then the pointers are compared. */ Tcl_CompareHashKeysProc *compareKeysProc; /* Called to allocate memory for a new entry, i.e. if the key is a * string then this could allocate a single block which contains enough * space for both the entry and the string. Only the key field of the * allocated Tcl_HashEntry structure needs to be filled in. If something * else needs to be done to the key, i.e. incrementing a reference count * then that should be done by this function. If this is NULL then Tcl_Alloc * is used to allocate enough space for a Tcl_HashEntry and the key pointer * is assigned to key.oneWordValue. */ Tcl_AllocHashEntryProc *allocEntryProc; /* Called to free memory associated with an entry. If something else needs * to be done to the key, i.e. decrementing a reference count then that * should be done by this function. If this is NULL then Tcl_Free is used * to free the Tcl_HashEntry. */ Tcl_FreeHashEntryProc *freeEntryProc;};/* * Structure definition for a hash table. Must be in tcl.h so clients * can allocate space for these structures, but clients should never * access any fields in this structure. */#define TCL_SMALL_HASH_TABLE 4struct Tcl_HashTable { Tcl_HashEntry **buckets; /* Pointer to bucket array. Each * element points to first entry in * bucket's hash chain, or NULL. */ Tcl_HashEntry *staticBuckets[TCL_SMALL_HASH_TABLE]; /* Bucket array used for small tables * (to avoid mallocs and frees). */ int numBuckets; /* Total number of buckets allocated * at **bucketPtr. */ int numEntries; /* Total number of entries present * in table. */ int rebuildSize; /* Enlarge table when numEntries gets * to be this large. */ int downShift; /* Shift count used in hashing * function. Designed to use high- * order bits of randomized keys. */ int mask; /* Mask value used in hashing * function. */ int keyType; /* Type of keys used in this table. * It's either TCL_CUSTOM_KEYS, * TCL_STRING_KEYS, TCL_ONE_WORD_KEYS, * or an integer giving the number of * ints that is the size of the key. */#if TCL_PRESERVE_BINARY_COMPATABILITY Tcl_HashEntry *(*findProc) _ANSI_ARGS_((Tcl_HashTable *tablePtr, CONST char *key)); Tcl_HashEntry *(*createProc) _ANSI_ARGS_((Tcl_HashTable *tablePtr, CONST char *key, int *newPtr));#endif Tcl_HashKeyType *typePtr; /* Type of the keys used in the * Tcl_HashTable. */};/* * Structure definition for information used to keep track of searches * through hash tables: */typedef struct Tcl_HashSearch { Tcl_HashTable *tablePtr; /* Table being searched. */ int nextIndex; /* Index of next bucket to be * enumerated after present one. */ Tcl_HashEntry *nextEntryPtr; /* Next entry to be enumerated in the * the current bucket. */} Tcl_HashSearch;/* * Acceptable key types for hash tables: * * TCL_STRING_KEYS: The keys are strings, they are copied into * the entry. * TCL_ONE_WORD_KEYS: The keys are pointers, the pointer is stored * in the entry. * TCL_CUSTOM_TYPE_KEYS: The keys are arbitrary types which are copied * into the entry. * TCL_CUSTOM_PTR_KEYS: The keys are pointers to arbitrary types, the * pointer is stored in the entry. * * While maintaining binary compatability the above have to be distinct * values as they are used to differentiate between old versions of the * hash table which don't have a typePtr and new ones which do. Once binary * compatability is discarded in favour of making more wide spread changes * TCL_STRING_KEYS can be the same as TCL_CUSTOM_TYPE_KEYS, and * TCL_ONE_WORD_KEYS can be the same as TCL_CUSTOM_PTR_KEYS because they * simply determine how the key is accessed from the entry and not the * behaviour. */#define TCL_STRING_KEYS 0#define TCL_ONE_WORD_KEYS 1#if TCL_PRESERVE_BINARY_COMPATABILITY# define TCL_CUSTOM_TYPE_KEYS -2# define TCL_CUSTOM_PTR_KEYS -1#else# define TCL_CUSTOM_TYPE_KEYS TCL_STRING_KEYS# define TCL_CUSTOM_PTR_KEYS TCL_ONE_WORD_KEYS#endif/* * Macros for clients to use to access fields of hash entries: */#define Tcl_GetHashValue(h) ((h)->clientData)#define Tcl_SetHashValue(h, value) ((h)->clientData = (ClientData) (value))#if TCL_PRESERVE_BINARY_COMPATABILITY# define Tcl_GetHashKey(tablePtr, h) \ ((char *) (((tablePtr)->keyType == TCL_ONE_WORD_KEYS || \ (tablePtr)->keyType == TCL_CUSTOM_PTR_KEYS) \ ? (h)->key.oneWordValue \ : (h)->key.string))#else# define Tcl_GetHashKey(tablePtr, h) \ ((char *) (((tablePtr)->keyType == TCL_ONE_WORD_KEYS) \ ? (h)->key.oneWordValue \ : (h)->key.string))#endif/* * Macros to use for clients to use to invoke find and create procedures * for hash tables: */#if TCL_PRESERVE_BINARY_COMPATABILITY# define Tcl_FindHashEntry(tablePtr, key) \ (*((tablePtr)->findProc))(tablePtr, key)# define Tcl_CreateHashEntry(tablePtr, key, newPtr) \ (*((tablePtr)->createProc))(tablePtr, key, newPtr)#else /* !TCL_PRESERVE_BINARY_COMPATABILITY *//* * Macro to use new extended version of Tcl_InitHashTable. */# define Tcl_InitHashTable(tablePtr, keyType) \ Tcl_InitHashTableEx(tablePtr, keyType, NULL)#endif /* TCL_PRESERVE_BINARY_COMPATABILITY *//* * Flag values to pass to Tcl_DoOneEvent to disable searches * for some kinds of events: */#define TCL_DONT_WAIT (1<<1)#define TCL_WINDOW_EVENTS (1<<2)#define TCL_FILE_EVENTS (1<<3)#define TCL_TIMER_EVENTS (1<<4)#define TCL_IDLE_EVENTS (1<<5) /* WAS 0x10 ???? */#define TCL_ALL_EVENTS (~TCL_DONT_WAIT)/* * The following structure defines a generic event for the Tcl event * system. These are the things that are queued in calls to Tcl_QueueEvent * and serviced later by Tcl_DoOneEvent. There can be many different * kinds of events with different fields, corresponding to window events, * timer events, etc. The structure for a particular event consists of * a Tcl_Event header followed by additional information specific to that * event. */struct Tcl_Event { Tcl_EventProc *proc; /* Procedure to call to service this event. */ struct Tcl_Event *nextPtr; /* Next in list of pending events, or NULL. */};/* * Positions to pass to Tcl_QueueEvent: */typedef enum { TCL_QUEUE_TAIL, TCL_QUEUE_HEAD, TCL_QUEUE_MARK} Tcl_QueuePosition;/* * Values to pass to Tcl_SetServiceMode to specify the behavior of notifier * event routines. */#define TCL_SERVICE_NONE 0#define TCL_SERVICE_ALL 1/* * The following structure keeps is used to hold a time value, either as * an absolute time (the number of seconds from the epoch) or as an * elapsed time. On Unix systems the epoch is Midnight Jan 1, 1970 GMT. * On Macintosh systems the epoch is Midnight Jan 1, 1904 GMT. */typedef struct Tcl_Time { long sec; /* Seconds. */ long usec; /* Microseconds. */} Tcl_Time;typedef void (Tcl_SetTimerProc) _ANSI_ARGS_((Tcl_Time *timePtr));typedef int (Tcl_WaitForEventProc) _ANSI_ARGS_((Tcl_Time *timePtr));/* * Bits to pass to Tcl_CreateFileHandler and Tcl_CreateChannelHandler * to indicate what sorts of events are of interest: */#define TCL_READABLE (1<<1)#define TCL_WRITABLE (1<<2)#define TCL_EXCEPTION (1<<3)/* * Flag values to pass to Tcl_OpenCommandChannel to indicate the * disposition of the stdio handles. TCL_STDIN, TCL_STDOUT, TCL_STDERR, * are also used in Tcl_GetStdChannel. */#define TCL_STDIN (1<<1) #define TCL_STDOUT (1<<2)#define TCL_STDERR (1<<3)#define TCL_ENFORCE_MODE (1<<4)/* * Bits passed to Tcl_DriverClose2Proc to indicate which side of a channel * should be closed. */#define TCL_CLOSE_READ (1<<1)#define TCL_CLOSE_WRITE (1<<2)/* * Value to use as the closeProc for a channel that supports the * close2Proc interface. */#define TCL_CLOSE2PROC ((Tcl_DriverCloseProc *)1)/* * Channel version tag. This was introduced in 8.3.2/8.4. */#define TCL_CHANNEL_VERSION_1 ((Tcl_ChannelTypeVersion) 0x1)#define TCL_CHANNEL_VERSION_2 ((Tcl_ChannelTypeVersion) 0x2)#define TCL_CHANNEL_VERSION_3 ((Tcl_ChannelTypeVersion) 0x3)/* * Typedefs for the various operations in a channel type: */typedef int (Tcl_DriverBlockModeProc) _ANSI_ARGS_(( ClientData instanceData, int mode));typedef int (Tcl_DriverCloseProc) _ANSI_ARGS_((ClientData instanceData, Tcl_Interp *interp));typedef int (Tcl_DriverClose2Proc) _ANSI_ARGS_((ClientData instanceData, Tcl_Interp *interp, int flags));typedef int (Tcl_DriverInputProc) _ANSI_ARGS_((ClientData instanceData, char *buf, int toRead, int *errorCodePtr));typedef int (Tcl_DriverOutputProc) _ANSI_ARGS_((ClientData instanceData, CONST84 char *buf, int toWrite, int *errorCodePtr));typedef int (Tcl_DriverSeekProc) _ANSI_ARGS_((ClientData instanceData, long offset, int mode, int *errorCodePtr));typedef int (Tcl_DriverSetOptionProc) _ANSI_ARGS_(( ClientData instanceData, Tcl_Interp *interp, CONST char *optionName, CONST char *value));typedef int (Tcl_DriverGetOptionProc) _ANSI_ARGS_(( ClientData instanceData, Tcl_Interp *interp, CONST84 char *optionName, Tcl_DString *dsPtr));typedef void (Tcl_DriverWatchProc) _ANSI_ARGS_(( ClientData instanceData, int mask));typedef int (Tcl_DriverGetHandleProc) _ANSI_ARGS_(( ClientData instanceData, int direction, ClientData *handlePtr));typedef int (Tcl_DriverFlushProc) _ANSI_ARGS_(( ClientData instanceData));typedef int (Tcl_DriverHandlerProc) _ANSI_ARGS_(( ClientData instanceData, int interestMask));typedef Tcl_WideInt (Tcl_DriverWideSeekProc) _ANSI_ARGS_(( ClientData instanceData, Tcl_WideInt offset, int mode, int *errorCodePtr));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -