📄 tclint.h
字号:
/*
* tclInt.h --
*
* Declarations of things used internally by the Tcl interpreter.
*
* Copyright 1987-1991 Regents of the University of California
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
* fee is hereby granted, provided that the above copyright
* notice appear in all copies. The University of California
* makes no representations about the suitability of this
* software for any purpose. It is provided "as is" without
* express or implied warranty.
*
* $Id: tclInt.h,v 1.1.1.1 2001/04/29 20:34:56 karll Exp $
*/
#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 _TCLHASH
#include "tclHash.h"
#endif
#ifndef _REGEXP
#include "regexp.h"
#endif
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
/* #include <varargs.h> */
/*
* At present (12/91) not all stdlib.h implementations declare strtod.
* The declaration below is here to ensure that it's declared, so that
* the compiler won't take the default approach of assuming it returns
* an int. There's no ANSI prototype for it because there would end
* up being too many conflicts with slightly-different prototypes.
*/
//extern double strtod(void);
/*
*----------------------------------------------------------------
* 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 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 string value. Pointers to these structures are kept as the
* values of hash table entries, and the name of each variable is stored
* in the hash entry.
*/
typedef struct Var {
int valueLength; /* Holds the number of non-null bytes
* actually occupied by the variable's
* current value in value.string (extra
* space is sometimes left for expansion).
* For array and global variables this is
* meaningless. */
int valueSpace; /* Total number of bytes of space allocated
* at value. */
int upvarUses; /* Counts number of times variable is
* is referenced via global or upvar variables
* (i.e. how many variables have "upvarPtr"
* pointing to this variable). Variable
* can't be deleted until this count reaches
* 0. */
VarTrace *tracePtr; /* First in list of all traces set for this
* variable. */
ArraySearch *searchPtr; /* First in list of all searches active
* for this variable, or NULL if none. */
int flags; /* Miscellaneous bits of information about
* variable. See below for definitions. */
union {
char string[4]; /* String value of variable. The actual
* length of this field is given by the
* valueSpace field above. */
Tcl_HashTable *tablePtr;/* For array variables, this points to
* information about the hash table used
* to implement the associative array.
* Points to malloc-ed data. */
Tcl_HashEntry *upvarPtr;
/* If this is a global variable being
* referred to in a procedure, or a variable
* created by "upvar", this field points to
* the hash table entry for the higher-level
* variable. */
} value; /* MUST BE LAST FIELD IN STRUCTURE!!! */
} Var;
/*
* Flag bits for variables:
*
* VAR_ARRAY - 1 means this is an array variable rather
* than a scalar variable.
* VAR_UPVAR - 1 means this variable just contains a
* pointer to another variable that has the
* real value. Variables like this come
* about through the "upvar" and "global"
* commands.
* VAR_UNDEFINED - 1 means that the variable is currently
* undefined. Undefined variables usually
* go away completely, but if an undefined
* variable has a trace on it, or if it is
* a global variable being used by a procedure,
* then it stays around even when undefined.
* VAR_ELEMENT_ACTIVE - Used only in array variables; 1 means that
* an element of the array is currently being
* manipulated in some way, so that it isn't
* safe to delete the whole array.
* VAR_TRACE_ACTIVE - 1 means that trace processing is currently
* underway for a read or write access, so
* new read or write accesses should not cause
* trace procedures to be called and the
* variable can't be deleted.
*/
#define VAR_ARRAY 1
#define VAR_UPVAR 2
#define VAR_UNDEFINED 4
#define VAR_ELEMENT_ACTIVE 0x10
#define VAR_TRACE_ACTIVE 0x20
#define VAR_SEARCHES_POSSIBLE 0x40
/*
*----------------------------------------------------------------
* Data structures related to procedures. These are used primarily
* in tclProc.c
*----------------------------------------------------------------
*/
/*
* The structure below defines an argument to a procedure, which
* consists of a name and an (optional) default value.
*/
typedef struct Arg {
struct Arg *nextPtr; /* Next argument for this procedure,
* or NULL if this is the last argument. */
char *defValue; /* Pointer to arg's default value, or NULL
* if no default value. */
char name[4]; /* Name of argument starts here. The name
* is followed by space for the default,
* if there is one. The actual size of this
* field will be as large as necessary to
* hold both name and default value. THIS
* MUST BE THE LAST FIELD IN THE STRUCTURE!! */
} Arg;
/*
* The structure below defines a command procedure, which consists of
* a collection of Tcl commands plus information about arguments and
* variables.
*/
typedef struct Proc {
struct Interp *iPtr; /* Interpreter for which this command
* is defined. */
char *command; /* Command that constitutes the body of
* the procedure (dynamically allocated). */
Arg *argPtr; /* Pointer to first of procedure's formal
* arguments, or NULL if none. */
} Proc;
/*
* The structure below defines a command trace. This is used to allow Tcl
* clients to find out whenever a command is about to be executed.
*/
typedef struct Trace {
int level; /* Only trace commands at nesting level
* less than or equal to this. */
Tcl_CmdTraceProc *proc; /* Procedure to call to trace command. */
ClientData clientData; /* Arbitrary value to pass to proc. */
struct Trace *nextPtr; /* Next in list of traces for this interp. */
} Trace;
/*
* The structure below defines a frame, which is a procedure invocation.
* These structures exist only while procedures are being executed, and
* provide a sort of call stack.
*/
typedef struct CallFrame {
Tcl_HashTable varTable; /* Hash table containing all of procedure's
* local variables. */
int level; /* Level of this procedure, for "uplevel"
* purposes (i.e. corresponds to nesting of
* callerVarPtr's, not callerPtr's). 1 means
* outer-most procedure, 0 means top-level. */
int argc; /* This and argv below describe name and
* arguments for this procedure invocation. */
char **argv; /* Array of arguments. */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -