📄 tclint.h
字号:
/* * tclInt.h -- * * Declarations of things used internally by the Tcl interpreter. * * Copyright (c) 1987-1993 The Regents of the University of California. * Copyright (c) 1994-1997 Sun Microsystems, Inc. * Copyright (c) 1993-1997 Lucent Technologies. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * * SCCS: @(#) tclInt.h 1.16 98/08/10 15:44:18 */#ifndef _TCLINT#define _TCLINT/* * Common include files needed by most of the Tcl source files are * included here, so that system-dependent personalizations for the * include files only have to be made in once place. This results * in a few extra includes, but greater modularity. The order of * the three groups of #includes is important. For example, stdio.h * is needed by tcl.h, and the _ANSI_ARGS_ declaration in tcl.h is * needed by stdlib.h in some configurations. */#include <stdio.h>#ifndef _TCL#include "tcl.h"#endif#ifndef _REGEXP#include "tclRegexp.h"#endif#include <ctype.h>#ifdef NO_LIMITS_H# include "../compat/limits.h"#else# include <limits.h>#endif#ifdef NO_STDLIB_H# include "../compat/stdlib.h"#else# include <stdlib.h>#endif#ifdef NO_STRING_H#include "../compat/string.h"#else#include <string.h>#endif#if defined(__STDC__) || defined(HAS_STDARG)# include <stdarg.h>#else# include <varargs.h>#endif#ifdef BUILD_tcl# undef TCL_STORAGE_CLASS# define TCL_STORAGE_CLASS DLLEXPORT#endif/* * The following procedures allow namespaces to be customized to * support special name resolution rules for commands/variables. * */struct Tcl_ResolvedVarInfo;typedef Tcl_Var (Tcl_ResolveRuntimeVarProc) _ANSI_ARGS_(( Tcl_Interp* interp, struct Tcl_ResolvedVarInfo *vinfoPtr));typedef void (Tcl_ResolveVarDeleteProc) _ANSI_ARGS_(( struct Tcl_ResolvedVarInfo *vinfoPtr));/* * The following structure encapsulates the routines needed to resolve a * variable reference at runtime. Any variable specific state will typically * be appended to this structure. */typedef struct Tcl_ResolvedVarInfo { Tcl_ResolveRuntimeVarProc *fetchProc; Tcl_ResolveVarDeleteProc *deleteProc;} Tcl_ResolvedVarInfo;typedef int (Tcl_ResolveCompiledVarProc) _ANSI_ARGS_(( Tcl_Interp* interp, char* name, int length, Tcl_Namespace *context, Tcl_ResolvedVarInfo **rPtr));typedef int (Tcl_ResolveVarProc) _ANSI_ARGS_(( Tcl_Interp* interp, char* name, Tcl_Namespace *context, int flags, Tcl_Var *rPtr));typedef int (Tcl_ResolveCmdProc) _ANSI_ARGS_((Tcl_Interp* interp, char* name, Tcl_Namespace *context, int flags, Tcl_Command *rPtr)); typedef struct Tcl_ResolverInfo { Tcl_ResolveCmdProc *cmdResProc; /* Procedure handling command name * resolution. */ Tcl_ResolveVarProc *varResProc; /* Procedure handling variable name * resolution for variables that * can only be handled at runtime. */ Tcl_ResolveCompiledVarProc *compiledVarResProc; /* Procedure handling variable name * resolution at compile time. */} Tcl_ResolverInfo;/* *---------------------------------------------------------------- * Data structures related to namespaces. *---------------------------------------------------------------- *//* * The structure below defines a namespace. * Note: the first five fields must match exactly the fields in a * Tcl_Namespace structure (see tcl.h). If you change one, be sure to * change the other. */typedef struct Namespace { char *name; /* The namespace's simple (unqualified) * name. This contains no ::'s. The name of * the global namespace is "" although "::" * is an synonym. */ char *fullName; /* The namespace's fully qualified name. * This starts with ::. */ ClientData clientData; /* An arbitrary value associated with this * namespace. */ Tcl_NamespaceDeleteProc *deleteProc; /* Procedure invoked when deleting the * namespace to, e.g., free clientData. */ struct Namespace *parentPtr; /* Points to the namespace that contains * this one. NULL if this is the global * namespace. */ Tcl_HashTable childTable; /* Contains any child namespaces. Indexed * by strings; values have type * (Namespace *). */ long nsId; /* Unique id for the namespace. */ Tcl_Interp *interp; /* The interpreter containing this * namespace. */ int flags; /* OR-ed combination of the namespace * status flags NS_DYING and NS_DEAD * listed below. */ int activationCount; /* Number of "activations" or active call * frames for this namespace that are on * the Tcl call stack. The namespace won't * be freed until activationCount becomes * zero. */ int refCount; /* Count of references by namespaceName * * objects. The namespace can't be freed * until refCount becomes zero. */ Tcl_HashTable cmdTable; /* Contains all the commands currently * registered in the namespace. Indexed by * strings; values have type (Command *). * Commands imported by Tcl_Import have * Command structures that point (via an * ImportedCmdRef structure) to the * Command structure in the source * namespace's command table. */ Tcl_HashTable varTable; /* Contains all the (global) variables * currently in this namespace. Indexed * by strings; values have type (Var *). */ char **exportArrayPtr; /* Points to an array of string patterns * specifying which commands are exported. * A pattern may include "string match" * style wildcard characters to specify * multiple commands; however, no namespace * qualifiers are allowed. NULL if no * export patterns are registered. */ int numExportPatterns; /* Number of export patterns currently * registered using "namespace export". */ int maxExportPatterns; /* Mumber of export patterns for which * space is currently allocated. */ int cmdRefEpoch; /* Incremented if a newly added command * shadows a command for which this * namespace has already cached a Command * * pointer; this causes all its cached * Command* pointers to be invalidated. */ int resolverEpoch; /* Incremented whenever the name resolution * rules change for this namespace; this * invalidates all byte codes compiled in * the namespace, causing the code to be * recompiled under the new rules. */ Tcl_ResolveCmdProc *cmdResProc; /* If non-null, this procedure overrides * the usual command resolution mechanism * in Tcl. This procedure is invoked * within Tcl_FindCommand to resolve all * command references within the namespace. */ Tcl_ResolveVarProc *varResProc; /* If non-null, this procedure overrides * the usual variable resolution mechanism * in Tcl. This procedure is invoked * within Tcl_FindNamespaceVar to resolve all * variable references within the namespace * at runtime. */ Tcl_ResolveCompiledVarProc *compiledVarResProc; /* If non-null, this procedure overrides * the usual variable resolution mechanism * in Tcl. This procedure is invoked * within LookupCompiledLocal to resolve * variable references within the namespace * at compile time. */} Namespace;/* * Flags used to represent the status of a namespace: * * NS_DYING - 1 means Tcl_DeleteNamespace has been called to delete the * namespace but there are still active call frames on the Tcl * stack that refer to the namespace. When the last call frame * referring to it has been popped, it's variables and command * will be destroyed and it will be marked "dead" (NS_DEAD). * The namespace can no longer be looked up by name. * NS_DEAD - 1 means Tcl_DeleteNamespace has been called to delete the * namespace and no call frames still refer to it. Its * variables and command have already been destroyed. This bit * allows the namespace resolution code to recognize that the * namespace is "deleted". When the last namespaceName object * in any byte code code unit that refers to the namespace has * been freed (i.e., when the namespace's refCount is 0), the * namespace's storage will be freed. */#define NS_DYING 0x01#define NS_DEAD 0x02/* * Flag passed to TclGetNamespaceForQualName to have it create all namespace * components of a namespace-qualified name that cannot be found. The new * namespaces are created within their specified parent. Note that this * flag's value must not conflict with the values of the flags * TCL_GLOBAL_ONLY, TCL_NAMESPACE_ONLY, and FIND_ONLY_NS (defined in * tclNamesp.c). */#define CREATE_NS_IF_UNKNOWN 0x800/* *---------------------------------------------------------------- * Data structures related to variables. These are used primarily * in tclVar.c *---------------------------------------------------------------- *//* * The following structure defines a variable trace, which is used to * invoke a specific C procedure whenever certain operations are performed * on a variable. */typedef struct VarTrace { Tcl_VarTraceProc *traceProc;/* Procedure to call when operations given * by flags are performed on variable. */ ClientData clientData; /* Argument to pass to proc. */ int flags; /* What events the trace procedure is * interested in: OR-ed combination of * TCL_TRACE_READS, TCL_TRACE_WRITES, and * TCL_TRACE_UNSETS. */ struct VarTrace *nextPtr; /* Next in list of traces associated with * a particular variable. */} VarTrace;/* * When a variable trace is active (i.e. its associated procedure is * executing), one of the following structures is linked into a list * associated with the variable's interpreter. The information in * the structure is needed in order for Tcl to behave reasonably * if traces are deleted while traces are active. */typedef struct ActiveVarTrace { struct Var *varPtr; /* Variable that's being traced. */ struct ActiveVarTrace *nextPtr; /* Next in list of all active variable * traces for the interpreter, or NULL * if no more. */ VarTrace *nextTracePtr; /* Next trace to check after current * trace procedure returns; if this * trace gets deleted, must update pointer * to avoid using free'd memory. */} ActiveVarTrace;/* * The following structure describes an enumerative search in progress on * an array variable; this are invoked with options to the "array" * command. */typedef struct ArraySearch { int id; /* Integer id used to distinguish among * multiple concurrent searches for the * same array. */ struct Var *varPtr; /* Pointer to array variable that's being * searched. */ Tcl_HashSearch search; /* Info kept by the hash module about * progress through the array. */ Tcl_HashEntry *nextEntry; /* Non-null means this is the next element * to be enumerated (it's leftover from * the Tcl_FirstHashEntry call or from * an "array anymore" command). NULL * means must call Tcl_NextHashEntry * to get value to return. */ struct ArraySearch *nextPtr;/* Next in list of all active searches * for this variable, or NULL if this is * the last one. */} ArraySearch;/* * The structure below defines a variable, which associates a string name * with a Tcl_Obj value. These structures are kept in procedure call frames * (for local variables recognized by the compiler) or in the heap (for * global variables and any variable not known to the compiler). For each * Var structure in the heap, a hash table entry holds the variable name and * a pointer to the Var structure. */typedef struct Var {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -