Compare commits

...
Author SHA1 Message Date
dkf 8841ba90ee Use C enums instead of clusters of #defines 2021-04-17 23:26:50 +00:00
34 changed files with 1419 additions and 1289 deletions
+389 -326
View File
@@ -527,33 +527,38 @@ typedef void (Tcl_ThreadCreateProc) (ClientData clientData);
* Flag values passed to Tcl_StringCaseMatch.
*/
#define TCL_MATCH_NOCASE (1<<0)
enum TclStringCaseMatchFlags {
TCL_MATCH_NOCASE = (1<<0)
};
/*
* Flag values passed to Tcl_GetRegExpFromObj.
*/
#define TCL_REG_BASIC 000000 /* BREs (convenience). */
#define TCL_REG_EXTENDED 000001 /* EREs. */
#define TCL_REG_ADVF 000002 /* Advanced features in EREs. */
#define TCL_REG_ADVANCED 000003 /* AREs (which are also EREs). */
#define TCL_REG_QUOTE 000004 /* No special characters, none. */
#define TCL_REG_NOCASE 000010 /* Ignore case. */
#define TCL_REG_NOSUB 000020 /* Don't care about subexpressions. */
#define TCL_REG_EXPANDED 000040 /* Expanded format, white space &
* comments. */
#define TCL_REG_NLSTOP 000100 /* \n doesn't match . or [^ ] */
#define TCL_REG_NLANCH 000200 /* ^ matches after \n, $ before. */
#define TCL_REG_NEWLINE 000300 /* Newlines are line terminators. */
#define TCL_REG_CANMATCH 001000 /* Report details on partial/limited
* matches. */
enum TclRegExpObjFlags {
TCL_REG_BASIC = 00000, /* BREs (convenience). */
TCL_REG_EXTENDED = 00001, /* EREs. */
TCL_REG_ADVF = 00002, /* Advanced features in EREs. */
TCL_REG_ADVANCED = 00003, /* AREs (which are also EREs). */
TCL_REG_QUOTE = 00004, /* No special characters, none. */
TCL_REG_NOCASE = 00010, /* Ignore case. */
TCL_REG_NOSUB = 00020, /* Don't care about subexpressions. */
TCL_REG_EXPANDED = 00040, /* Expanded format, white space & comments. */
TCL_REG_NLSTOP = 00100, /* \n doesn't match . or [^ ] */
TCL_REG_NLANCH = 00200, /* ^ matches after \n, $ before. */
TCL_REG_NEWLINE = 00300, /* Newlines are line terminators. */
TCL_REG_CANMATCH = 01000 /* Report details on partial/limited
* matches. */
};
/*
* Flags values passed to Tcl_RegExpExecObj.
*/
#define TCL_REG_NOTBOL 0001 /* Beginning of string does not match ^. */
#define TCL_REG_NOTEOL 0002 /* End of string does not match $. */
enum TclRegExpExecFlags {
TCL_REG_NOTBOL = 0001, /* Beginning of string does not match ^. */
TCL_REG_NOTEOL = 0002 /* End of string does not match $. */
};
/*
* Structures filled in by Tcl_RegExpInfo. Note that all offset values are
@@ -592,25 +597,36 @@ typedef struct stat *Tcl_OldStat_;
* Tcl_GetObjResult() or Tcl_GetStringResult() to read the interpreter's
* result. See the SetResult man page for details. Besides this result, the
* command function returns an integer code, which is one of the following:
*
* TCL_OK Command completed normally; the interpreter's result
* contains the command's result.
* TCL_ERROR The command couldn't be completed successfully; the
* interpreter's result describes what went wrong.
* TCL_RETURN The command requests that the current function return;
* the interpreter's result contains the function's
* return value.
* TCL_BREAK The command requests that the innermost loop be
* exited; the interpreter's result is meaningless.
* TCL_CONTINUE Go on to the next iteration of the current loop; the
* interpreter's result is meaningless.
*/
#define TCL_OK 0
#define TCL_ERROR 1
#define TCL_RETURN 2
#define TCL_BREAK 3
#define TCL_CONTINUE 4
enum TclStandardResultCodes {
TCL_OK = 0, /* Command completed normally; the
* interpreter's result contains the command's
* result. */
TCL_ERROR = 1, /* The command couldn't be completed
* successfully; the interpreter's result
* describes what went wrong. */
TCL_RETURN = 2, /* The command requests that the current
* function return; the interpreter's result
* contains the function's return value. */
TCL_BREAK = 3, /* The command requests that the innermost
* loop be exited; the interpreter's result is
* meaningless (conventionally the empty
* string). */
TCL_CONTINUE = 4 /* Go on to the next iteration of the current
* loop; the interpreter's result is
* meaningless (conventionally the empty
* string). */
/*
* NOTE: This is NOT a closed set! Application-specific result codes
* appear in the wild, usually for doing some sort of "fast exception".
* They all behave the same, like an error except that no stack trace is
* accumulated in the errorInfo. Because there's no registry of codes
* used, they are all reserved to applications; library code cannot safely
* use them.
*/
};
#if !defined(TCL_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9
#define TCL_RESULT_SIZE 200
@@ -621,10 +637,12 @@ typedef struct stat *Tcl_OldStat_;
* Flags to control what substitutions are performed by Tcl_SubstObj():
*/
#define TCL_SUBST_COMMANDS 001
#define TCL_SUBST_VARIABLES 002
#define TCL_SUBST_BACKSLASHES 004
#define TCL_SUBST_ALL 007
enum TclSubstControlFlags {
TCL_SUBST_COMMANDS = 001,
TCL_SUBST_VARIABLES = 002,
TCL_SUBST_BACKSLASHES = 004,
TCL_SUBST_ALL = 007
};
/*
* Argument descriptors for math function callbacks in expressions:
@@ -963,55 +981,56 @@ typedef struct Tcl_DString {
/*
* Flag values passed to Tcl_ConvertElement.
* TCL_DONT_USE_BRACES forces it not to enclose the element in braces, but to
* use backslash quoting instead.
* TCL_DONT_QUOTE_HASH disables the default quoting of the '#' character. It
* is safe to leave the hash unquoted when the element is not the first
* element of a list, and this flag can be used by the caller to indicate
* that condition.
*/
#define TCL_DONT_USE_BRACES 1
#define TCL_DONT_QUOTE_HASH 8
enum TclConvertElementFlags {
TCL_DONT_USE_BRACES = 1, /* Force Tcl_ConvertElement not to enclose the
* element in braces, but to use backslash
* quoting instead.*/
TCL_DONT_QUOTE_HASH = 8 /* Disable the default quoting of the '#'
* character. It is safe to leave the hash
* unquoted when the element is not the first
* element of a list, and this flag can be
* used by the caller to indicate that
* condition. */
};
/*
* Flags that may be passed to Tcl_GetIndexFromObj.
* TCL_EXACT disallows abbreviated strings.
* TCL_INDEX_TEMP_TABLE disallows caching of lookups. A possible use case is
* a table that will not live long enough to make it worthwhile.
*/
#define TCL_EXACT 1
#define TCL_INDEX_TEMP_TABLE 2
enum TclGetIndexFromObjFlags {
TCL_EXACT = 1, /* Disallow abbreviated strings. */
TCL_INDEX_TEMP_TABLE = 2 /* Disallow caching of lookups. A possible use
* case is a table that will not live long
* enough to make it worthwhile. */
};
/*
*----------------------------------------------------------------------------
* Flag values passed to Tcl_RecordAndEval, Tcl_EvalObj, Tcl_EvalObjv.
* WARNING: these bit choices must not conflict with the bit choices for
* evalFlag bits in tclInt.h!
*
* Meanings:
* TCL_NO_EVAL: Just record this command
* TCL_EVAL_GLOBAL: Execute script in global namespace
* TCL_EVAL_DIRECT: Do not compile this script
* TCL_EVAL_INVOKE: Magical Tcl_EvalObjv mode for aliases/ensembles
* o Run in iPtr->lookupNsPtr or global namespace
* o Cut out of error traces
* o Don't reset the flags controlling ensemble
* error message rewriting.
* TCL_CANCEL_UNWIND: Magical Tcl_CancelEval mode that causes the
* stack for the script in progress to be
* completely unwound.
* TCL_EVAL_NOERR: Do no exception reporting at all, just return
* as the caller will report.
*/
#define TCL_NO_EVAL 0x010000
#define TCL_EVAL_GLOBAL 0x020000
#define TCL_EVAL_DIRECT 0x040000
#define TCL_EVAL_INVOKE 0x080000
#define TCL_CANCEL_UNWIND 0x100000
#define TCL_EVAL_NOERR 0x200000
enum TclEvalFlags {
TCL_NO_EVAL = 0x010000, /* Just record this command */
TCL_EVAL_GLOBAL = 0x020000, /* Execute script in global namespace */
TCL_EVAL_DIRECT = 0x040000, /* Do not compile this script */
TCL_EVAL_INVOKE = 0x080000, /* Magical Tcl_EvalObjv mode for
* aliases/ensembles
* o Run in iPtr->lookupNsPtr or global
* namespace
* o Cut out of error traces
* o Don't reset the flags controlling
* ensemble error message rewriting. */
TCL_CANCEL_UNWIND = 0x100000,
/* Magical Tcl_CancelEval mode that causes the
* stack for the script in progress to be
* completely unwound. */
TCL_EVAL_NOERR = 0x200000 /* Do no exception reporting at all, just
* return as the caller will report. */
};
/*
* Special freeProc values that may be passed to Tcl_SetResult (see the man
@@ -1028,45 +1047,48 @@ typedef struct Tcl_DString {
* TCL_CANCEL_UNWIND, above.
*/
#define TCL_GLOBAL_ONLY 1
#define TCL_NAMESPACE_ONLY 2
#define TCL_APPEND_VALUE 4
#define TCL_LIST_ELEMENT 8
#define TCL_TRACE_READS 0x10
#define TCL_TRACE_WRITES 0x20
#define TCL_TRACE_UNSETS 0x40
#define TCL_TRACE_DESTROYED 0x80
enum TclVariableFlags {
TCL_GLOBAL_ONLY = 1,
TCL_NAMESPACE_ONLY = 2,
TCL_APPEND_VALUE = 4,
TCL_LIST_ELEMENT = 8,
TCL_TRACE_READS = 0x10,
TCL_TRACE_WRITES = 0x20,
TCL_TRACE_UNSETS = 0x40,
TCL_TRACE_DESTROYED = 0x80,
#if !defined(TCL_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9
#define TCL_INTERP_DESTROYED 0x100
TCL_INTERP_DESTROYED = 0x100,
#endif
#define TCL_LEAVE_ERR_MSG 0x200
#define TCL_TRACE_ARRAY 0x800
TCL_LEAVE_ERR_MSG = 0x200,
TCL_TRACE_ARRAY = 0x800,
#ifndef TCL_REMOVE_OBSOLETE_TRACES
/* Required to support old variable/vdelete/vinfo traces. */
#define TCL_TRACE_OLD_STYLE 0x1000
/* Required to support old variable/vdelete/vinfo traces. */
TCL_TRACE_OLD_STYLE = 0x1000,
#endif
/* Indicate the semantics of the result of a trace. */
#define TCL_TRACE_RESULT_DYNAMIC 0x8000
#define TCL_TRACE_RESULT_OBJECT 0x10000
/* Indicate the semantics of the result of a trace. */
TCL_TRACE_RESULT_DYNAMIC = 0x8000,
TCL_TRACE_RESULT_OBJECT = 0x10000
};
/*
* Flag values for ensemble commands.
*/
#define TCL_ENSEMBLE_PREFIX 0x02/* Flag value to say whether to allow
enum TclEnsembleFlags {
TCL_ENSEMBLE_PREFIX = 0x02 /* Flag value to say whether to allow
* unambiguous prefixes of commands or to
* require exact matches for command names. */
};
/*
* Flag values passed to command-related functions.
*/
#define TCL_TRACE_RENAME 0x2000
#define TCL_TRACE_DELETE 0x4000
#define TCL_ALLOW_INLINE_COMPILATION 0x20000
enum TclCommandFlags {
TCL_TRACE_RENAME = 0x2000,
TCL_TRACE_DELETE = 0x4000,
TCL_ALLOW_INLINE_COMPILATION = 0x20000
};
/*
* The TCL_PARSE_PART1 flag is deprecated and has no effect. The part1 is now
@@ -1083,28 +1105,30 @@ typedef struct Tcl_DString {
* Types for linked variables:
*/
#define TCL_LINK_INT 1
#define TCL_LINK_DOUBLE 2
#define TCL_LINK_BOOLEAN 3
#define TCL_LINK_STRING 4
#define TCL_LINK_WIDE_INT 5
#define TCL_LINK_CHAR 6
#define TCL_LINK_UCHAR 7
#define TCL_LINK_SHORT 8
#define TCL_LINK_USHORT 9
#define TCL_LINK_UINT 10
enum TclLinkVariableTypes {
TCL_LINK_INT = 1,
TCL_LINK_DOUBLE = 2,
TCL_LINK_BOOLEAN = 3,
TCL_LINK_STRING = 4,
TCL_LINK_WIDE_INT = 5,
TCL_LINK_CHAR = 6,
TCL_LINK_UCHAR = 7,
TCL_LINK_SHORT = 8,
TCL_LINK_USHORT = 9,
TCL_LINK_UINT = 10,
TCL_LINK_FLOAT = 13,
TCL_LINK_WIDE_UINT = 14,
TCL_LINK_CHARS = 15,
TCL_LINK_BINARY = 16,
#if defined(TCL_WIDE_INT_IS_LONG) || defined(_WIN32) || defined(__CYGWIN__)
#define TCL_LINK_LONG ((sizeof(long) != sizeof(int)) ? TCL_LINK_WIDE_INT : TCL_LINK_INT)
#define TCL_LINK_ULONG ((sizeof(long) != sizeof(int)) ? TCL_LINK_WIDE_UINT : TCL_LINK_UINT)
TCL_LINK_LONG = ((sizeof(long) != sizeof(int)) ? TCL_LINK_WIDE_INT : TCL_LINK_INT),
TCL_LINK_ULONG = ((sizeof(long) != sizeof(int)) ? TCL_LINK_WIDE_UINT : TCL_LINK_UINT),
#else
#define TCL_LINK_LONG 11
#define TCL_LINK_ULONG 12
TCL_LINK_LONG = 11,
TCL_LINK_ULONG = 12,
#endif
#define TCL_LINK_FLOAT 13
#define TCL_LINK_WIDE_UINT 14
#define TCL_LINK_CHARS 15
#define TCL_LINK_BINARY 16
#define TCL_LINK_READ_ONLY 0x80
TCL_LINK_READ_ONLY = 0x80
};
/*
*----------------------------------------------------------------------------
@@ -1152,21 +1176,23 @@ struct Tcl_HashEntry {
/*
* 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.
* TCL_HASH_KEY_SYSTEM_HASH - If this flag is set then all memory internally
* allocated for the hash table that is not for an
* entry will use the system heap.
*/
#define TCL_HASH_KEY_RANDOMIZE_HASH 0x1
#define TCL_HASH_KEY_SYSTEM_HASH 0x2
enum TclHashKeyFlags {
TCL_HASH_KEY_RANDOMIZE_HASH = 0x1,
/* 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. */
TCL_HASH_KEY_SYSTEM_HASH = 0x2
/* If this flag is set then all memory
* internally allocated for the hash table
* that is not for an entry will use the
* system heap. */
};
/*
* Structure definition for the methods associated with a hash table key type.
@@ -1307,12 +1333,14 @@ typedef struct {
* 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)
enum TclDoOneEventFlags {
TCL_DONT_WAIT = (1<<1),
TCL_WINDOW_EVENTS = (1<<2),
TCL_FILE_EVENTS = (1<<3),
TCL_TIMER_EVENTS = (1<<4),
TCL_IDLE_EVENTS = (1<<5), /* WAS 0x10 ???? */
TCL_ALL_EVENTS = (~TCL_DONT_WAIT)
};
/*
* The following structure defines a generic event for the Tcl event system.
@@ -1341,8 +1369,10 @@ typedef enum {
* event routines.
*/
#define TCL_SERVICE_NONE 0
#define TCL_SERVICE_ALL 1
enum TclServiceModes {
TCL_SERVICE_NONE = 0,
TCL_SERVICE_ALL = 1
};
/*
* The following structure keeps is used to hold a time value, either as an
@@ -1371,9 +1401,11 @@ typedef void (Tcl_ScaleTimeProc) (Tcl_Time *timebuf, ClientData clientData);
* indicate what sorts of events are of interest:
*/
#define TCL_READABLE (1<<1)
#define TCL_WRITABLE (1<<2)
#define TCL_EXCEPTION (1<<3)
enum TclChannelHandlerFlags {
TCL_READABLE = (1<<1),
TCL_WRITABLE = (1<<2),
TCL_EXCEPTION = (1<<3)
};
/*
* Flag values to pass to Tcl_OpenCommandChannel to indicate the disposition
@@ -1381,18 +1413,22 @@ typedef void (Tcl_ScaleTimeProc) (Tcl_Time *timebuf, ClientData clientData);
* Tcl_GetStdChannel.
*/
#define TCL_STDIN (1<<1)
#define TCL_STDOUT (1<<2)
#define TCL_STDERR (1<<3)
#define TCL_ENFORCE_MODE (1<<4)
enum TclOpenCommandChannelFlags {
TCL_STDIN = (1<<1),
TCL_STDOUT = (1<<2),
TCL_STDERR = (1<<3),
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)
enum TclChannelCloseFlags {
TCL_CLOSE_READ = (1<<1),
TCL_CLOSE_WRITE = (1<<2)
};
/*
* Value to use as the closeProc for a channel that supports the close2Proc
@@ -1417,8 +1453,10 @@ typedef void (Tcl_ScaleTimeProc) (Tcl_Time *timebuf, ClientData clientData);
* TIP #218: Channel Actions, Ids for Tcl_DriverThreadActionProc.
*/
#define TCL_CHANNEL_THREAD_INSERT (0)
#define TCL_CHANNEL_THREAD_REMOVE (1)
enum TclChannelThreadActionOperations {
TCL_CHANNEL_THREAD_INSERT = 0,
TCL_CHANNEL_THREAD_REMOVE = 1
};
/*
* Typedefs for the various operations in a channel type:
@@ -1479,8 +1517,8 @@ typedef struct Tcl_ChannelType {
/* Version of the channel type. */
Tcl_DriverCloseProc *closeProc;
/* Function to call to close the channel, or
* NULL or TCL_CLOSE2PROC if the close2Proc should be
* used instead. */
* NULL or TCL_CLOSE2PROC if the close2Proc
* should be used instead. */
Tcl_DriverInputProc *inputProc;
/* Function to call for input on channel. */
Tcl_DriverOutputProc *outputProc;
@@ -1547,9 +1585,10 @@ typedef struct Tcl_ChannelType {
* to the blockModeProc function in the above structure.
*/
#define TCL_MODE_BLOCKING 0 /* Put channel into blocking mode. */
#define TCL_MODE_NONBLOCKING 1 /* Put channel into nonblocking
* mode. */
enum TclChannelBlockModeFlags {
TCL_MODE_BLOCKING = 0, /* Put channel into blocking mode. */
TCL_MODE_NONBLOCKING = 1 /* Put channel into nonblocking mode. */
};
/*
*----------------------------------------------------------------------------
@@ -1578,27 +1617,33 @@ typedef struct Tcl_GlobTypeData {
* Type and permission definitions for glob command.
*/
#define TCL_GLOB_TYPE_BLOCK (1<<0)
#define TCL_GLOB_TYPE_CHAR (1<<1)
#define TCL_GLOB_TYPE_DIR (1<<2)
#define TCL_GLOB_TYPE_PIPE (1<<3)
#define TCL_GLOB_TYPE_FILE (1<<4)
#define TCL_GLOB_TYPE_LINK (1<<5)
#define TCL_GLOB_TYPE_SOCK (1<<6)
#define TCL_GLOB_TYPE_MOUNT (1<<7)
enum TclGlobTypes {
TCL_GLOB_TYPE_BLOCK = (1<<0),
TCL_GLOB_TYPE_CHAR = (1<<1),
TCL_GLOB_TYPE_DIR = (1<<2),
TCL_GLOB_TYPE_PIPE = (1<<3),
TCL_GLOB_TYPE_FILE = (1<<4),
TCL_GLOB_TYPE_LINK = (1<<5),
TCL_GLOB_TYPE_SOCK = (1<<6),
TCL_GLOB_TYPE_MOUNT = (1<<7)
};
#define TCL_GLOB_PERM_RONLY (1<<0)
#define TCL_GLOB_PERM_HIDDEN (1<<1)
#define TCL_GLOB_PERM_R (1<<2)
#define TCL_GLOB_PERM_W (1<<3)
#define TCL_GLOB_PERM_X (1<<4)
enum TclGlobPermissions {
TCL_GLOB_PERM_RONLY = (1<<0),
TCL_GLOB_PERM_HIDDEN = (1<<1),
TCL_GLOB_PERM_R = (1<<2),
TCL_GLOB_PERM_W = (1<<3),
TCL_GLOB_PERM_X = (1<<4)
};
/*
* Flags for the unload callback function.
*/
#define TCL_UNLOAD_DETACH_FROM_INTERPRETER (1<<0)
#define TCL_UNLOAD_DETACH_FROM_PROCESS (1<<1)
enum TclUnloadFlags {
TCL_UNLOAD_DETACH_FROM_INTERPRETER = (1<<0),
TCL_UNLOAD_DETACH_FROM_PROCESS = (1<<1)
};
/*
* Typedefs for the various filesystem operations:
@@ -1804,8 +1849,10 @@ typedef struct Tcl_Filesystem {
* TCL_CREATE_HARD_LINK - Create a hard link.
*/
#define TCL_CREATE_SYMBOLIC_LINK 0x01
#define TCL_CREATE_HARD_LINK 0x02
enum TclFileLinkActions {
TCL_CREATE_SYMBOLIC_LINK = 0x01,
TCL_CREATE_HARD_LINK = 0x02
};
/*
*----------------------------------------------------------------------------
@@ -1848,99 +1895,101 @@ typedef struct Tcl_Token {
/*
* Type values defined for Tcl_Token structures. These values are defined as
* mask bits so that it's easy to check for collections of types.
*
* TCL_TOKEN_WORD - The token describes one word of a command,
* from the first non-blank character of the word
* (which may be " or {) up to but not including
* the space, semicolon, or bracket that
* terminates the word. NumComponents counts the
* total number of sub-tokens that make up the
* word. This includes, for example, sub-tokens
* of TCL_TOKEN_VARIABLE tokens.
* TCL_TOKEN_SIMPLE_WORD - This token is just like TCL_TOKEN_WORD except
* that the word is guaranteed to consist of a
* single TCL_TOKEN_TEXT sub-token.
* TCL_TOKEN_TEXT - The token describes a range of literal text
* that is part of a word. NumComponents is
* always 0.
* TCL_TOKEN_BS - The token describes a backslash sequence that
* must be collapsed. NumComponents is always 0.
* TCL_TOKEN_COMMAND - The token describes a command whose result
* must be substituted into the word. The token
* includes the enclosing brackets. NumComponents
* is always 0.
* TCL_TOKEN_VARIABLE - The token describes a variable substitution,
* including the dollar sign, variable name, and
* array index (if there is one) up through the
* right parentheses. NumComponents tells how
* many additional tokens follow to represent the
* variable name. The first token will be a
* TCL_TOKEN_TEXT token that describes the
* variable name. If the variable is an array
* reference then there will be one or more
* additional tokens, of type TCL_TOKEN_TEXT,
* TCL_TOKEN_BS, TCL_TOKEN_COMMAND, and
* TCL_TOKEN_VARIABLE, that describe the array
* index; numComponents counts the total number
* of nested tokens that make up the variable
* reference, including sub-tokens of
* TCL_TOKEN_VARIABLE tokens.
* TCL_TOKEN_SUB_EXPR - The token describes one subexpression of an
* expression, from the first non-blank character
* of the subexpression up to but not including
* the space, brace, or bracket that terminates
* the subexpression. NumComponents counts the
* total number of following subtokens that make
* up the subexpression; this includes all
* subtokens for any nested TCL_TOKEN_SUB_EXPR
* tokens. For example, a numeric value used as a
* primitive operand is described by a
* TCL_TOKEN_SUB_EXPR token followed by a
* TCL_TOKEN_TEXT token. A binary subexpression
* is described by a TCL_TOKEN_SUB_EXPR token
* followed by the TCL_TOKEN_OPERATOR token for
* the operator, then TCL_TOKEN_SUB_EXPR tokens
* for the left then the right operands.
* TCL_TOKEN_OPERATOR - The token describes one expression operator.
* An operator might be the name of a math
* function such as "abs". A TCL_TOKEN_OPERATOR
* token is always preceded by one
* TCL_TOKEN_SUB_EXPR token for the operator's
* subexpression, and is followed by zero or more
* TCL_TOKEN_SUB_EXPR tokens for the operator's
* operands. NumComponents is always 0.
* TCL_TOKEN_EXPAND_WORD - This token is just like TCL_TOKEN_WORD except
* that it marks a word that began with the
* literal character prefix "{*}". This word is
* marked to be expanded - that is, broken into
* words after substitution is complete.
*/
#define TCL_TOKEN_WORD 1
#define TCL_TOKEN_SIMPLE_WORD 2
#define TCL_TOKEN_TEXT 4
#define TCL_TOKEN_BS 8
#define TCL_TOKEN_COMMAND 16
#define TCL_TOKEN_VARIABLE 32
#define TCL_TOKEN_SUB_EXPR 64
#define TCL_TOKEN_OPERATOR 128
#define TCL_TOKEN_EXPAND_WORD 256
enum TclTokenTypes {
TCL_TOKEN_WORD = 1, /* The token describes one word of a command,
* from the first non-blank character of the
* word (which may be " or {) up to but not
* including the space, semicolon, or bracket
* that terminates the word. NumComponents
* counts the total number of sub-tokens that
* make up the word. This includes, for
* example, sub-tokens of TCL_TOKEN_VARIABLE
* tokens. */
TCL_TOKEN_SIMPLE_WORD = 2, /* This token is just like TCL_TOKEN_WORD
* except that the word is guaranteed to
* consist of a single TCL_TOKEN_TEXT
* sub-token. */
TCL_TOKEN_TEXT = 4, /* The token describes a range of literal text
* that is part of a word. NumComponents is
* always 0. */
TCL_TOKEN_BS = 8, /* The token describes a backslash sequence
* that must be collapsed. NumComponents is
* always 0. */
TCL_TOKEN_COMMAND = 16, /* The token describes a command whose result
* must be substituted into the word. The
* token includes the enclosing brackets.
* NumComponents is always 0. */
TCL_TOKEN_VARIABLE = 32, /* The token describes a variable
* substitution, including the dollar sign,
* variable name, and array index (if there is
* one) up through the right parentheses.
* NumComponents tells how many additional
* tokens follow to represent the variable
* name. The first token will be a
* TCL_TOKEN_TEXT token that describes the
* variable name. If the variable is an array
* reference then there will be one or more
* additional tokens, of type TCL_TOKEN_TEXT,
* TCL_TOKEN_BS, TCL_TOKEN_COMMAND, and
* TCL_TOKEN_VARIABLE, that describe the array
* index; numComponents counts the total
* number of nested tokens that make up the
* variable reference, including sub-tokens of
* TCL_TOKEN_VARIABLE tokens. */
TCL_TOKEN_SUB_EXPR = 64, /* The token describes one subexpression of an
* expression, from the first non-blank
* character of the subexpression up to but
* not including the space, brace, or bracket
* that terminates the subexpression.
* NumComponents counts the total number of
* following subtokens that make up the
* subexpression; this includes all subtokens
* for any nested TCL_TOKEN_SUB_EXPR tokens.
* For example, a numeric value used as a
* primitive operand is described by a
* TCL_TOKEN_SUB_EXPR token followed by a
* TCL_TOKEN_TEXT token. A binary
* subexpression is described by a
* TCL_TOKEN_SUB_EXPR token followed by the
* TCL_TOKEN_OPERATOR token for the operator,
* then TCL_TOKEN_SUB_EXPR tokens for the left
* then the right operands. */
TCL_TOKEN_OPERATOR = 128, /* The token describes one expression
* operator. An operator might be the name of
* a math function such as "abs". A
* TCL_TOKEN_OPERATOR token is always preceded
* by one TCL_TOKEN_SUB_EXPR token for the
* operator's subexpression, and is followed
* by zero or more TCL_TOKEN_SUB_EXPR tokens
* for the operator's operands. NumComponents
* is always 0. */
TCL_TOKEN_EXPAND_WORD = 256 /* This token is just like TCL_TOKEN_WORD
* except that it marks a word that began with
* the literal character prefix "{*}". This
* word is marked to be expanded - that is,
* broken into words after substitution is
* complete. */
};
/*
* Parsing error types. On any parsing error, one of these values will be
* stored in the error field of the Tcl_Parse structure defined below.
*/
#define TCL_PARSE_SUCCESS 0
#define TCL_PARSE_QUOTE_EXTRA 1
#define TCL_PARSE_BRACE_EXTRA 2
#define TCL_PARSE_MISSING_BRACE 3
#define TCL_PARSE_MISSING_BRACKET 4
#define TCL_PARSE_MISSING_PAREN 5
#define TCL_PARSE_MISSING_QUOTE 6
#define TCL_PARSE_MISSING_VAR_BRACE 7
#define TCL_PARSE_SYNTAX 8
#define TCL_PARSE_BAD_NUMBER 9
enum TclParsingErrors {
TCL_PARSE_SUCCESS = 0,
TCL_PARSE_QUOTE_EXTRA = 1,
TCL_PARSE_BRACE_EXTRA = 2,
TCL_PARSE_MISSING_BRACE = 3,
TCL_PARSE_MISSING_BRACKET = 4,
TCL_PARSE_MISSING_PAREN = 5,
TCL_PARSE_MISSING_QUOTE = 6,
TCL_PARSE_MISSING_VAR_BRACE = 7,
TCL_PARSE_SYNTAX = 8,
TCL_PARSE_BAD_NUMBER = 9
};
/*
* A structure of the following type is filled in by Tcl_ParseCommand. It
@@ -2035,52 +2084,53 @@ typedef struct Tcl_EncodingType {
/*
* The following definitions are used as values for the conversion control
* flags argument when converting text from one character set to another:
*
* TCL_ENCODING_START - Signifies that the source buffer is the first
* block in a (potentially multi-block) input
* stream. Tells the conversion function to reset
* to an initial state and perform any
* initialization that needs to occur before the
* first byte is converted. If the source buffer
* contains the entire input stream to be
* converted, this flag should be set.
* TCL_ENCODING_END - Signifies that the source buffer is the last
* block in a (potentially multi-block) input
* stream. Tells the conversion routine to
* perform any finalization that needs to occur
* after the last byte is converted and then to
* reset to an initial state. If the source
* buffer contains the entire input stream to be
* converted, this flag should be set.
* TCL_ENCODING_STOPONERROR - If set, the converter returns immediately upon
* encountering an invalid byte sequence or a
* source character that has no mapping in the
* target encoding. If clear, the converter
* substitues the problematic character(s) with
* one or more "close" characters in the
* destination buffer and then continues to
* convert the source.
* TCL_ENCODING_NO_TERMINATE - If set, Tcl_ExternalToUtf does not append a
* terminating NUL byte. Since it does not need
* an extra byte for a terminating NUL, it fills
* all dstLen bytes with encoded UTF-8 content if
* needed. If clear, a byte is reserved in the
* dst space for NUL termination, and a
* terminating NUL is appended.
* TCL_ENCODING_CHAR_LIMIT - If set and dstCharsPtr is not NULL, then
* Tcl_ExternalToUtf takes the initial value of
* *dstCharsPtr as a limit of the maximum number
* of chars to produce in the encoded UTF-8
* content. Otherwise, the number of chars
* produced is controlled only by other limiting
* factors.
*/
#define TCL_ENCODING_START 0x01
#define TCL_ENCODING_END 0x02
#define TCL_ENCODING_STOPONERROR 0x04
#define TCL_ENCODING_NO_TERMINATE 0x08
#define TCL_ENCODING_CHAR_LIMIT 0x10
enum TclEncodingFlags {
TCL_ENCODING_START = 1, /* Signifies that the source buffer is the
* first block in a (potentially multi-block)
* input stream. Tells the conversion function
* to reset to an initial state and perform
* any initialization that needs to occur
* before the first byte is converted. If the
* source buffer contains the entire input
* stream to be converted, this flag should be
* set. */
TCL_ENCODING_END = 2, /* Signifies that the source buffer is the
* last block in a (potentially multi-block)
* input stream. Tells the conversion routine
* to perform any finalization that needs to
* occur after the last byte is converted and
* then to reset to an initial state. If the
* source buffer contains the entire input
* stream to be converted, this flag should be
* set. */
TCL_ENCODING_STOPONERROR = 4,
/* If set, the converter returns immediately
* upon encountering an invalid byte sequence
* or a source character that has no mapping
* in the target encoding. If clear, the
* converter substitues the problematic
* character(s) with one or more "close"
* characters in the destination buffer and
* then continues to convert the source.*/
TCL_ENCODING_NO_TERMINATE = 8,
/* If set, Tcl_ExternalToUtf does not append a
* terminating NUL byte. Since it does not
* need an extra byte for a terminating NUL,
* it fills all dstLen bytes with encoded
* UTF-8 content if needed. If clear, a byte
* is reserved in the dst space for NUL
* termination, and a terminating NUL is
* appended. */
TCL_ENCODING_CHAR_LIMIT = 16/* If set and dstCharsPtr is not NULL, then
* Tcl_ExternalToUtf takes the initial value
* of *dstCharsPtr as a limit of the maximum
* number of chars to produce in the encoded
* UTF-8 content. Otherwise, the number of
* chars produced is controlled only by other
* limiting factors. */
};
/*
* The following definitions are the error codes returned by the conversion
@@ -2163,8 +2213,10 @@ typedef struct Tcl_Config {
* interpreter. Used for Tcl_{Add,Remove}LimitHandler type argument.
*/
#define TCL_LIMIT_COMMANDS 0x01
#define TCL_LIMIT_TIME 0x02
enum TclLimitHandlerTypes {
TCL_LIMIT_COMMANDS = 0x01,
TCL_LIMIT_TIME = 0x02
};
/*
* Structure containing information about a limit handler to be called when a
@@ -2218,15 +2270,17 @@ typedef struct {
* documentation for details.
*/
#define TCL_ARGV_CONSTANT 15
#define TCL_ARGV_INT 16
#define TCL_ARGV_STRING 17
#define TCL_ARGV_REST 18
#define TCL_ARGV_FLOAT 19
#define TCL_ARGV_FUNC 20
#define TCL_ARGV_GENFUNC 21
#define TCL_ARGV_HELP 22
#define TCL_ARGV_END 23
enum TclArgvInfoTypes {
TCL_ARGV_CONSTANT = 15,
TCL_ARGV_INT = 16,
TCL_ARGV_STRING = 17,
TCL_ARGV_REST = 18,
TCL_ARGV_FLOAT = 19,
TCL_ARGV_FUNC = 20,
TCL_ARGV_GENFUNC = 21,
TCL_ARGV_HELP = 22,
TCL_ARGV_END = 23
};
/*
* Types of callback functions for the TCL_ARGV_FUNC and TCL_ARGV_GENFUNC
@@ -2260,18 +2314,20 @@ typedef int (Tcl_ArgvGenFuncProc)(ClientData clientData, Tcl_Interp *interp,
* Tcl_ZlibStreamInit functions.
*/
#define TCL_ZLIB_FORMAT_RAW 1
#define TCL_ZLIB_FORMAT_ZLIB 2
#define TCL_ZLIB_FORMAT_GZIP 4
#define TCL_ZLIB_FORMAT_AUTO 8
enum TclZlibFlags {
TCL_ZLIB_FORMAT_RAW = 1,
TCL_ZLIB_FORMAT_ZLIB = 2,
TCL_ZLIB_FORMAT_GZIP = 4,
TCL_ZLIB_FORMAT_AUTO = 8,
/*
* Constants that describe whether the stream is to operate in compressing or
* decompressing mode.
*/
/*
* Constants that describe whether the stream is to operate in compressing
* or decompressing mode.
*/
#define TCL_ZLIB_STREAM_DEFLATE 16
#define TCL_ZLIB_STREAM_INFLATE 32
TCL_ZLIB_STREAM_DEFLATE = 16,
TCL_ZLIB_STREAM_INFLATE = 32
};
/*
* Constants giving compression levels. Use of TCL_ZLIB_COMPRESS_DEFAULT is
@@ -2287,25 +2343,32 @@ typedef int (Tcl_ArgvGenFuncProc)(ClientData clientData, Tcl_Interp *interp,
* Constants for types of flushing, used with Tcl_ZlibFlush.
*/
#define TCL_ZLIB_NO_FLUSH 0
#define TCL_ZLIB_FLUSH 2
#define TCL_ZLIB_FULLFLUSH 3
#define TCL_ZLIB_FINALIZE 4
enum TclZlibFlushModes {
TCL_ZLIB_NO_FLUSH = 0,
TCL_ZLIB_FLUSH = 2,
TCL_ZLIB_FULLFLUSH = 3,
TCL_ZLIB_FINALIZE = 4
};
/*
*----------------------------------------------------------------------------
* Definitions needed for the Tcl_LoadFile function. [TIP #416]
*/
#define TCL_LOAD_GLOBAL 1
#define TCL_LOAD_LAZY 2
enum TclLoadFileFlags {
TCL_LOAD_GLOBAL = 1,
TCL_LOAD_LAZY = 2
};
/*
*----------------------------------------------------------------------------
* Definitions needed for the Tcl_OpenTcpServerEx function. [TIP #456]
*/
#define TCL_TCPSERVER_REUSEADDR (1<<0)
#define TCL_TCPSERVER_REUSEPORT (1<<1)
enum TclOpenTcpServerFlags {
TCL_TCPSERVER_REUSEADDR = (1<<0),
TCL_TCPSERVER_REUSEPORT = (1<<1)
};
/*
* Constants for special int-typed values, see TIP #494
+8 -6
View File
@@ -86,12 +86,14 @@ typedef struct {
* following values.
*/
#define SORTMODE_ASCII 0
#define SORTMODE_INTEGER 1
#define SORTMODE_REAL 2
#define SORTMODE_COMMAND 3
#define SORTMODE_DICTIONARY 4
#define SORTMODE_ASCII_NC 8
enum SortModeFlags {
SORTMODE_ASCII = 0,
SORTMODE_INTEGER = 1,
SORTMODE_REAL = 2,
SORTMODE_COMMAND = 3,
SORTMODE_DICTIONARY = 4,
SORTMODE_ASCII_NC = 8
};
/*
* Forward declarations for procedures defined in this file:
+73 -84
View File
@@ -123,26 +123,27 @@ enum Marks {
* store a NODE_TYPE code.
*/
#define NODE_TYPE 0xC0
enum NodeTypeFlags {
NODE_TYPE = 0xC0,
/*
* The four category values are LEAF, UNARY, and BINARY, explained below, and
* "uncategorized", which is used either temporarily, until context determines
* which of the other three categories is correct, or for lexemes like
* INVALID, which aren't really lexemes at all, but indicators of a parsing
* error. Note that the codes must be distinct to distinguish categories, but
* need not take the form of a bit array.
*/
/*
* The four category values are LEAF, UNARY, and BINARY, explained below,
* and "uncategorized", which is used either temporarily, until context
* determines which of the other three categories is correct, or for
* lexemes like INVALID, which aren't really lexemes at all, but
* indicators of a parsing error. Note that the codes must be distinct to
* distinguish categories, but need not take the form of a bit array.
*/
#define BINARY 0x40 /* This lexeme is a binary operator. An OpNode
BINARY = 0x40, /* This lexeme is a binary operator. An OpNode
* representing it should go into the parse
* tree, and two operands should be parsed for
* it in the expression. */
#define UNARY 0x80 /* This lexeme is a unary operator. An OpNode
UNARY = 0x80, /* This lexeme is a unary operator. An OpNode
* representing it should go into the parse
* tree, and one operand should be parsed for
* it in the expression. */
#define LEAF 0xC0 /* This lexeme is a leaf operand in the parse
LEAF = 0xC0 /* This lexeme is a leaf operand in the parse
* tree. No OpNode will be placed in the tree
* for it. Either a literal value will be
* appended to the list of literals in this
@@ -150,47 +151,42 @@ enum Marks {
* be appended in a Tcl_Parse struct to
* represent those leaves that require some
* form of substitution. */
};
/* Uncategorized lexemes */
enum LexemeTypes {
/* Uncategorized lexemes */
#define PLUS 1 /* Ambiguous. Resolves to UNARY_PLUS or
PLUS = 1, /* Ambiguous. Resolves to UNARY_PLUS or
* BINARY_PLUS according to context. */
#define MINUS 2 /* Ambiguous. Resolves to UNARY_MINUS or
MINUS = 2, /* Ambiguous. Resolves to UNARY_MINUS or
* BINARY_MINUS according to context. */
#define BAREWORD 3 /* Ambigous. Resolves to BOOLEAN or to
BAREWORD = 3, /* Ambigous. Resolves to BOOLEAN or to
* FUNCTION or a parse error according to
* context and value. */
#define INCOMPLETE 4 /* A parse error. Used only when the single
INCOMPLETE = 4, /* A parse error. Used only when the single
* "=" is encountered. */
#define INVALID 5 /* A parse error. Used when any punctuation
INVALID = 5, /* A parse error. Used when any punctuation
* appears that's not a supported operator. */
#define COMMENT 6 /* Comment. Lasts to end of line or end of
COMMENT = 6, /* Comment. Lasts to end of line or end of
* expression, whichever comes first. */
/* Leaf lexemes */
/* Leaf lexemes */
#define NUMBER (LEAF | 1)
/* For literal numbers */
#define SCRIPT (LEAF | 2)
/* Script substitution; [foo] */
#define BOOLEAN (LEAF | BAREWORD)
/* For literal booleans */
#define BRACED (LEAF | 4)
/* Braced string; {foo bar} */
#define VARIABLE (LEAF | 5)
/* Variable substitution; $x */
#define QUOTED (LEAF | 6)
/* Quoted string; "foo $bar [soom]" */
#define EMPTY (LEAF | 7)
/* Used only for an empty argument list to a
NUMBER = (LEAF | 1), /* For literal numbers */
SCRIPT = (LEAF | 2), /* Script substitution; [foo] */
BOOLEAN = (LEAF | BAREWORD),/* For literal booleans */
BRACED = (LEAF | 4), /* Braced string; {foo bar} */
VARIABLE = (LEAF | 5), /* Variable substitution; $x */
QUOTED = (LEAF | 6), /* Quoted string; "foo $bar [soom]" */
EMPTY = (LEAF | 7), /* Used only for an empty argument list to a
* function. Represents the empty string
* within parens in the expression: rand() */
/* Unary operator lexemes */
/* Unary operator lexemes */
#define UNARY_PLUS (UNARY | PLUS)
#define UNARY_MINUS (UNARY | MINUS)
#define FUNCTION (UNARY | BAREWORD)
UNARY_PLUS = (UNARY | PLUS),
UNARY_MINUS = (UNARY | MINUS),
FUNCTION = (UNARY | BAREWORD),
/* This is a bit of "creative interpretation"
* on the part of the parser. A function call
* is parsed into the parse tree according to
@@ -206,69 +202,62 @@ enum Marks {
* include such exceptional handling in the
* code against the need we would otherwise
* have for more lexeme categories. */
#define START (UNARY | 4)
/* This lexeme isn't parsed from the
START = (UNARY | 4), /* This lexeme isn't parsed from the
* expression text at all. It represents the
* start of the expression and sits at the
* root of the parse tree where it serves as
* the start/end point of traversals. */
#define OPEN_PAREN (UNARY | 5)
/* Another bit of creative interpretation,
OPEN_PAREN = (UNARY | 5), /* Another bit of creative interpretation,
* where we treat "(" as a unary operator with
* the sub-expression between it and its
* matching ")" as its operand. See
* CLOSE_PAREN below. */
#define NOT (UNARY | 6)
#define BIT_NOT (UNARY | 7)
NOT = (UNARY | 6),
BIT_NOT = (UNARY | 7),
/* Binary operator lexemes */
/* Binary operator lexemes */
#define BINARY_PLUS (BINARY | PLUS)
#define BINARY_MINUS (BINARY | MINUS)
#define COMMA (BINARY | 3)
/* The "," operator is a low precedence binary
BINARY_PLUS = (BINARY | PLUS),
BINARY_MINUS = (BINARY | MINUS),
COMMA = (BINARY | 3), /* The "," operator is a low precedence binary
* operator that separates the arguments in a
* function call. The additional constraint
* that this operator can only legally appear
* at the right places within a function call
* argument list are hard coded within
* ParseExpr(). */
#define MULT (BINARY | 4)
#define DIVIDE (BINARY | 5)
#define MOD (BINARY | 6)
#define LESS (BINARY | 7)
#define GREATER (BINARY | 8)
#define BIT_AND (BINARY | 9)
#define BIT_XOR (BINARY | 10)
#define BIT_OR (BINARY | 11)
#define QUESTION (BINARY | 12)
/* These two lexemes make up the */
#define COLON (BINARY | 13)
/* ternary conditional operator, $x ? $y : $z.
* ParseExpr(). */
MULT = (BINARY | 4),
DIVIDE = (BINARY | 5),
MOD = (BINARY | 6),
LESS = (BINARY | 7),
GREATER = (BINARY | 8),
BIT_AND = (BINARY | 9),
BIT_XOR = (BINARY | 10),
BIT_OR = (BINARY | 11),
QUESTION = (BINARY | 12), /* These two lexemes make up the */
COLON = (BINARY | 13), /* ternary conditional operator, $x ? $y : $z.
* We treat them as two binary operators to
* avoid another lexeme category, and code the
* additional constraints directly in
* ParseExpr(). For instance, the right
* operand of a "?" operator must be a ":"
* operator. */
#define LEFT_SHIFT (BINARY | 14)
#define RIGHT_SHIFT (BINARY | 15)
#define LEQ (BINARY | 16)
#define GEQ (BINARY | 17)
#define EQUAL (BINARY | 18)
#define NEQ (BINARY | 19)
#define AND (BINARY | 20)
#define OR (BINARY | 21)
#define STREQ (BINARY | 22)
#define STRNEQ (BINARY | 23)
#define EXPON (BINARY | 24)
/* Unlike the other binary operators, EXPON is
LEFT_SHIFT = (BINARY | 14),
RIGHT_SHIFT = (BINARY | 15),
LEQ = (BINARY | 16),
GEQ = (BINARY | 17),
EQUAL = (BINARY | 18),
NEQ = (BINARY | 19),
AND = (BINARY | 20),
OR = (BINARY | 21),
STREQ = (BINARY | 22),
STRNEQ = (BINARY | 23),
EXPON = (BINARY | 24), /* Unlike the other binary operators, EXPON is
* right associative and this distinction is
* coded directly in ParseExpr(). */
#define IN_LIST (BINARY | 25)
#define NOT_IN_LIST (BINARY | 26)
#define CLOSE_PAREN (BINARY | 27)
/* By categorizing the CLOSE_PAREN lexeme as a
IN_LIST = (BINARY | 25),
NOT_IN_LIST = (BINARY | 26),
CLOSE_PAREN = (BINARY | 27),/* By categorizing the CLOSE_PAREN lexeme as a
* BINARY operator, the normal parsing rules
* for binary operators assure that a close
* paren will not directly follow another
@@ -283,17 +272,17 @@ enum Marks {
* parse tree. The sub-expression between
* parens becomes the single argument of the
* matching OPEN_PAREN unary operator. */
#define STR_LT (BINARY | 28)
#define STR_GT (BINARY | 29)
#define STR_LEQ (BINARY | 30)
#define STR_GEQ (BINARY | 31)
#define END (BINARY | 32)
/* This lexeme represents the end of the
STR_LT = (BINARY | 28),
STR_GT = (BINARY | 29),
STR_LEQ = (BINARY | 30),
STR_GEQ = (BINARY | 31),
END = (BINARY | 32), /* This lexeme represents the end of the
* string being parsed. Treating it as a
* binary operator follows the same logic as
* the CLOSE_PAREN lexeme and END pairs with
* START, in the same way that CLOSE_PAREN
* pairs with OPEN_PAREN. */
};
/*
* When ParseExpr() builds the parse tree it must choose which operands to
+264 -276
View File
@@ -395,21 +395,17 @@ typedef struct CompileEnv {
* CmdLocation map, and the compilation AuxData array.
*/
/*
* A PRECOMPILED bytecode struct is one that was generated from a compiled
* image rather than implicitly compiled from source
*/
#define TCL_BYTECODE_PRECOMPILED 0x0001
/*
* When a bytecode is compiled, interp or namespace resolvers have not been
* applied yet: this is indicated by the TCL_BYTECODE_RESOLVE_VARS flag.
*/
#define TCL_BYTECODE_RESOLVE_VARS 0x0002
#define TCL_BYTECODE_RECOMPILE 0x0004
enum BytecodeFlags {
TCL_BYTECODE_PRECOMPILED = 0x0001,
/* A PRECOMPILED bytecode struct is one that
* was generated from a compiled image rather
* than implicitly compiled from source. */
TCL_BYTECODE_RESOLVE_VARS = 0x0002,
/* When a bytecode is compiled, interp or
* namespace resolvers have not been applied
* yet: this is indicated by the this flag. */
TCL_BYTECODE_RECOMPILE = 0x0004
};
typedef struct ByteCode {
TclHandle interpHandle; /* Handle for interpreter containing the
@@ -540,316 +536,306 @@ typedef struct ByteCode {
* tclExecute.c.
*/
/* Opcodes 0 to 9 */
#define INST_DONE 0
#define INST_PUSH1 1
#define INST_PUSH4 2
#define INST_POP 3
#define INST_DUP 4
#define INST_STR_CONCAT1 5
#define INST_INVOKE_STK1 6
#define INST_INVOKE_STK4 7
#define INST_EVAL_STK 8
#define INST_EXPR_STK 9
#ifdef _BUILD_TCL_EXECUTE
#define IS_DEPRECATED /* nothing */
#else
#define IS_DEPRECATED TCL_DEPRECATED_API("no longer used")
#endif /* _BUILD_TCL_EXECUTE*/
/* Opcodes 10 to 23 */
#define INST_LOAD_SCALAR1 10
#define INST_LOAD_SCALAR4 11
#define INST_LOAD_SCALAR_STK 12
#define INST_LOAD_ARRAY1 13
#define INST_LOAD_ARRAY4 14
#define INST_LOAD_ARRAY_STK 15
#define INST_LOAD_STK 16
#define INST_STORE_SCALAR1 17
#define INST_STORE_SCALAR4 18
#define INST_STORE_SCALAR_STK 19
#define INST_STORE_ARRAY1 20
#define INST_STORE_ARRAY4 21
#define INST_STORE_ARRAY_STK 22
#define INST_STORE_STK 23
enum TclBytecodeOpcodes {
/* Opcodes 0 to 9: Basic operations */
INST_DONE = 0,
INST_PUSH1 = 1,
INST_PUSH4 = 2,
INST_POP = 3,
INST_DUP = 4,
INST_STR_CONCAT1 = 5,
INST_INVOKE_STK1 = 6,
INST_INVOKE_STK4 = 7,
INST_EVAL_STK = 8,
INST_EXPR_STK = 9,
/* Opcodes 24 to 33 */
#define INST_INCR_SCALAR1 24
#define INST_INCR_SCALAR_STK 25
#define INST_INCR_ARRAY1 26
#define INST_INCR_ARRAY_STK 27
#define INST_INCR_STK 28
#define INST_INCR_SCALAR1_IMM 29
#define INST_INCR_SCALAR_STK_IMM 30
#define INST_INCR_ARRAY1_IMM 31
#define INST_INCR_ARRAY_STK_IMM 32
#define INST_INCR_STK_IMM 33
/* Opcodes 10 to 23: LOAD and STORE */
INST_LOAD_SCALAR1 = 10,
INST_LOAD_SCALAR4 = 11,
INST_LOAD_SCALAR_STK = 12,
INST_LOAD_ARRAY1 = 13,
INST_LOAD_ARRAY4 = 14,
INST_LOAD_ARRAY_STK = 15,
INST_LOAD_STK = 16,
INST_STORE_SCALAR1 = 17,
INST_STORE_SCALAR4 = 18,
INST_STORE_SCALAR_STK = 19,
INST_STORE_ARRAY1 = 20,
INST_STORE_ARRAY4 = 21,
INST_STORE_ARRAY_STK = 22,
INST_STORE_STK = 23,
/* Opcodes 34 to 39 */
#define INST_JUMP1 34
#define INST_JUMP4 35
#define INST_JUMP_TRUE1 36
#define INST_JUMP_TRUE4 37
#define INST_JUMP_FALSE1 38
#define INST_JUMP_FALSE4 39
/* Opcodes 24 to 33: INCR */
INST_INCR_SCALAR1 = 24,
INST_INCR_SCALAR_STK = 25,
INST_INCR_ARRAY1 = 26,
INST_INCR_ARRAY_STK = 27,
INST_INCR_STK = 28,
INST_INCR_SCALAR1_IMM = 29,
INST_INCR_SCALAR_STK_IMM = 30,
INST_INCR_ARRAY1_IMM = 31,
INST_INCR_ARRAY_STK_IMM = 32,
INST_INCR_STK_IMM = 33,
/* Opcodes 40 to 64 */
#define INST_LOR 40
#define INST_LAND 41
#define INST_BITOR 42
#define INST_BITXOR 43
#define INST_BITAND 44
#define INST_EQ 45
#define INST_NEQ 46
#define INST_LT 47
#define INST_GT 48
#define INST_LE 49
#define INST_GE 50
#define INST_LSHIFT 51
#define INST_RSHIFT 52
#define INST_ADD 53
#define INST_SUB 54
#define INST_MULT 55
#define INST_DIV 56
#define INST_MOD 57
#define INST_UPLUS 58
#define INST_UMINUS 59
#define INST_BITNOT 60
#define INST_LNOT 61
#define INST_CALL_BUILTIN_FUNC1 62
#define INST_CALL_FUNC1 63
#define INST_TRY_CVT_TO_NUMERIC 64
/* Opcodes 34 to 39: JUMP */
INST_JUMP1 = 34,
INST_JUMP4 = 35,
INST_JUMP_TRUE1 = 36,
INST_JUMP_TRUE4 = 37,
INST_JUMP_FALSE1 = 38,
INST_JUMP_FALSE4 = 39,
/* Opcodes 65 to 66 */
#define INST_BREAK 65
#define INST_CONTINUE 66
/* Opcodes 40 to 64: Expression implementation */
INST_LOR = 40,
INST_LAND = 41,
INST_BITOR = 42,
INST_BITXOR = 43,
INST_BITAND = 44,
INST_EQ = 45,
INST_NEQ = 46,
INST_LT = 47,
INST_GT = 48,
INST_LE = 49,
INST_GE = 50,
INST_LSHIFT = 51,
INST_RSHIFT = 52,
INST_ADD = 53,
INST_SUB = 54,
INST_MULT = 55,
INST_DIV = 56,
INST_MOD = 57,
INST_UPLUS = 58,
INST_UMINUS = 59,
INST_BITNOT = 60,
INST_LNOT = 61,
#ifndef NO_DEPRECATED_BYTECODES
INST_CALL_BUILTIN_FUNC1 IS_DEPRECATED = 62,
INST_CALL_FUNC1 IS_DEPRECATED = 63,
#endif
INST_TRY_CVT_TO_NUMERIC = 64,
/* Opcodes 67 to 68 */
#define INST_FOREACH_START4 67 /* DEPRECATED */
#define INST_FOREACH_STEP4 68 /* DEPRECATED */
/* Opcodes 65 to 66: Local exceptions */
INST_BREAK = 65,
INST_CONTINUE = 66,
/* Opcodes 69 to 72 */
#define INST_BEGIN_CATCH4 69
#define INST_END_CATCH 70
#define INST_PUSH_RESULT 71
#define INST_PUSH_RETURN_CODE 72
#ifndef NO_DEPRECATED_BYTECODES
/* Opcodes 67 to 68: Old Foreach */
INST_FOREACH_START4 IS_DEPRECATED = 67,
INST_FOREACH_STEP4 IS_DEPRECATED = 68,
#endif
/* Opcodes 73 to 78 */
#define INST_STR_EQ 73
#define INST_STR_NEQ 74
#define INST_STR_CMP 75
#define INST_STR_LEN 76
#define INST_STR_INDEX 77
#define INST_STR_MATCH 78
/* Opcodes 69 to 72: Catch */
INST_BEGIN_CATCH4 = 69,
INST_END_CATCH = 70,
INST_PUSH_RESULT = 71,
INST_PUSH_RETURN_CODE = 72,
/* Opcodes 78 to 81 */
#define INST_LIST 79
#define INST_LIST_INDEX 80
#define INST_LIST_LENGTH 81
/* Opcodes 73 to 78: misc string ops */
INST_STR_EQ = 73,
INST_STR_NEQ = 74,
INST_STR_CMP = 75,
INST_STR_LEN = 76,
INST_STR_INDEX = 77,
INST_STR_MATCH = 78,
/* Opcodes 82 to 87 */
#define INST_APPEND_SCALAR1 82
#define INST_APPEND_SCALAR4 83
#define INST_APPEND_ARRAY1 84
#define INST_APPEND_ARRAY4 85
#define INST_APPEND_ARRAY_STK 86
#define INST_APPEND_STK 87
/* Opcodes 78 to 81: misc list ops */
INST_LIST = 79,
INST_LIST_INDEX = 80,
INST_LIST_LENGTH = 81,
/* Opcodes 88 to 93 */
#define INST_LAPPEND_SCALAR1 88
#define INST_LAPPEND_SCALAR4 89
#define INST_LAPPEND_ARRAY1 90
#define INST_LAPPEND_ARRAY4 91
#define INST_LAPPEND_ARRAY_STK 92
#define INST_LAPPEND_STK 93
/* Opcodes 82 to 87: APPEND */
INST_APPEND_SCALAR1 = 82,
INST_APPEND_SCALAR4 = 83,
INST_APPEND_ARRAY1 = 84,
INST_APPEND_ARRAY4 = 85,
INST_APPEND_ARRAY_STK = 86,
INST_APPEND_STK = 87,
/* TIP #22 - LINDEX operator with flat arg list */
/* Opcodes 88 to 93: LAPPEND */
INST_LAPPEND_SCALAR1 = 88,
INST_LAPPEND_SCALAR4 = 89,
INST_LAPPEND_ARRAY1 = 90,
INST_LAPPEND_ARRAY4 = 91,
INST_LAPPEND_ARRAY_STK = 92,
INST_LAPPEND_STK = 93,
#define INST_LIST_INDEX_MULTI 94
/* TIP #22 - LINDEX operator with flat arg list */
INST_LIST_INDEX_MULTI = 94,
/*
* TIP #33 - 'lset' command. Code gen also required a Forth-like
* OVER operation.
*/
/* TIP #33 - 'lset' command. Code gen also required a Forth-like OVER
* operation. */
INST_OVER = 95,
INST_LSET_LIST = 96,
INST_LSET_FLAT = 97,
#define INST_OVER 95
#define INST_LSET_LIST 96
#define INST_LSET_FLAT 97
/* TIP#90 - 'return' command. */
INST_RETURN_IMM = 98,
/* TIP#90 - 'return' command. */
/* TIP#123 - exponentiation operator. */
INST_EXPON = 99,
#define INST_RETURN_IMM 98
/* TIP #157 - {*}... (word expansion) language syntax support. */
INST_EXPAND_START = 100,
INST_EXPAND_STKTOP = 101,
INST_INVOKE_EXPANDED = 102,
/* TIP#123 - exponentiation operator. */
/* TIP #57 - 'lassign' command. Code generation requires immediate LINDEX
* and LRANGE operators. */
INST_LIST_INDEX_IMM = 103,
INST_LIST_RANGE_IMM = 104,
#define INST_EXPON 99
INST_START_CMD = 105,
/* TIP #157 - {*}... (word expansion) language syntax support. */
INST_LIST_IN = 106,
INST_LIST_NOT_IN = 107,
#define INST_EXPAND_START 100
#define INST_EXPAND_STKTOP 101
#define INST_INVOKE_EXPANDED 102
INST_PUSH_RETURN_OPTIONS = 108,
INST_RETURN_STK = 109,
/*
* TIP #57 - 'lassign' command. Code generation requires immediate
* LINDEX and LRANGE operators.
*/
/* Dictionary (TIP#111) related commands. */
INST_DICT_GET = 110,
INST_DICT_SET = 111,
INST_DICT_UNSET = 112,
INST_DICT_INCR_IMM = 113,
INST_DICT_APPEND = 114,
INST_DICT_LAPPEND = 115,
INST_DICT_FIRST = 116,
INST_DICT_NEXT = 117,
INST_DICT_DONE = 118,
INST_DICT_UPDATE_START = 119,
INST_DICT_UPDATE_END = 120,
#define INST_LIST_INDEX_IMM 103
#define INST_LIST_RANGE_IMM 104
/* Instruction to support jumps defined by tables (instead of the classic
* [switch] technique of chained comparisons). */
INST_JUMP_TABLE = 121,
#define INST_START_CMD 105
/* Instructions to support compilation of global, variable, upvar and
* [namespace upvar]. */
INST_UPVAR = 122,
INST_NSUPVAR = 123,
INST_VARIABLE = 124,
#define INST_LIST_IN 106
#define INST_LIST_NOT_IN 107
/* Instruction to support compiling syntax error to bytecode */
INST_SYNTAX = 125,
#define INST_PUSH_RETURN_OPTIONS 108
#define INST_RETURN_STK 109
/* Instruction to reverse N items on top of stack */
INST_REVERSE = 126,
/*
* Dictionary (TIP#111) related commands.
*/
/* regexp instruction */
INST_REGEXP = 127,
#define INST_DICT_GET 110
#define INST_DICT_SET 111
#define INST_DICT_UNSET 112
#define INST_DICT_INCR_IMM 113
#define INST_DICT_APPEND 114
#define INST_DICT_LAPPEND 115
#define INST_DICT_FIRST 116
#define INST_DICT_NEXT 117
#define INST_DICT_DONE 118
#define INST_DICT_UPDATE_START 119
#define INST_DICT_UPDATE_END 120
/* For [info exists] compilation */
INST_EXIST_SCALAR = 128,
INST_EXIST_ARRAY = 129,
INST_EXIST_ARRAY_STK = 130,
INST_EXIST_STK = 131,
/*
* Instruction to support jumps defined by tables (instead of the classic
* [switch] technique of chained comparisons).
*/
/* For [subst] compilation */
INST_NOP = 132,
INST_RETURN_CODE_BRANCH = 133,
#define INST_JUMP_TABLE 121
/* For [unset] compilation */
INST_UNSET_SCALAR = 134,
INST_UNSET_ARRAY = 135,
INST_UNSET_ARRAY_STK = 136,
INST_UNSET_STK = 137,
/*
* Instructions to support compilation of global, variable, upvar and
* [namespace upvar].
*/
/* For [dict with], [dict exists], [dict create] and [dict merge] */
INST_DICT_EXPAND = 138,
INST_DICT_RECOMBINE_STK = 139,
INST_DICT_RECOMBINE_IMM = 140,
INST_DICT_EXISTS = 141,
INST_DICT_VERIFY = 142,
#define INST_UPVAR 122
#define INST_NSUPVAR 123
#define INST_VARIABLE 124
/* For [string map] and [regsub] compilation */
INST_STR_MAP = 143,
INST_STR_FIND = 144,
INST_STR_FIND_LAST = 145,
INST_STR_RANGE_IMM = 146,
INST_STR_RANGE = 147,
/* Instruction to support compiling syntax error to bytecode */
/* For operations to do with coroutines and other NRE-manipulators */
INST_YIELD = 148,
INST_COROUTINE_NAME = 149,
INST_TAILCALL = 150,
#define INST_SYNTAX 125
/* For compilation of basic information operations */
INST_NS_CURRENT = 151,
INST_INFO_LEVEL_NUM = 152,
INST_INFO_LEVEL_ARGS = 153,
INST_RESOLVE_COMMAND = 154,
/* Instruction to reverse N items on top of stack */
/* For compilation relating to TclOO */
INST_TCLOO_SELF = 155,
INST_TCLOO_CLASS = 156,
INST_TCLOO_NS = 157,
INST_TCLOO_IS_OBJECT = 158,
#define INST_REVERSE 126
/* For compilation of [array] subcommands */
INST_ARRAY_EXISTS_STK = 159,
INST_ARRAY_EXISTS_IMM = 160,
INST_ARRAY_MAKE_STK = 161,
INST_ARRAY_MAKE_IMM = 162,
/* regexp instruction */
INST_INVOKE_REPLACE = 163,
#define INST_REGEXP 127
INST_LIST_CONCAT = 164,
/* For [info exists] compilation */
#define INST_EXIST_SCALAR 128
#define INST_EXIST_ARRAY 129
#define INST_EXIST_ARRAY_STK 130
#define INST_EXIST_STK 131
INST_EXPAND_DROP = 165,
/* For [subst] compilation */
#define INST_NOP 132
#define INST_RETURN_CODE_BRANCH 133
/* New foreach implementation */
INST_FOREACH_START = 166,
INST_FOREACH_STEP = 167,
INST_FOREACH_END = 168,
INST_LMAP_COLLECT = 169,
/* For [unset] compilation */
#define INST_UNSET_SCALAR 134
#define INST_UNSET_ARRAY 135
#define INST_UNSET_ARRAY_STK 136
#define INST_UNSET_STK 137
/* For compilation of [string trim] and related */
INST_STR_TRIM = 170,
INST_STR_TRIM_LEFT = 171,
INST_STR_TRIM_RIGHT = 172,
/* For [dict with], [dict exists], [dict create] and [dict merge] */
#define INST_DICT_EXPAND 138
#define INST_DICT_RECOMBINE_STK 139
#define INST_DICT_RECOMBINE_IMM 140
#define INST_DICT_EXISTS 141
#define INST_DICT_VERIFY 142
INST_CONCAT_STK = 173,
/* For [string map] and [regsub] compilation */
#define INST_STR_MAP 143
#define INST_STR_FIND 144
#define INST_STR_FIND_LAST 145
#define INST_STR_RANGE_IMM 146
#define INST_STR_RANGE 147
INST_STR_UPPER = 174,
INST_STR_LOWER = 175,
INST_STR_TITLE = 176,
INST_STR_REPLACE = 177,
/* For operations to do with coroutines and other NRE-manipulators */
#define INST_YIELD 148
#define INST_COROUTINE_NAME 149
#define INST_TAILCALL 150
INST_ORIGIN_COMMAND = 178,
/* For compilation of basic information operations */
#define INST_NS_CURRENT 151
#define INST_INFO_LEVEL_NUM 152
#define INST_INFO_LEVEL_ARGS 153
#define INST_RESOLVE_COMMAND 154
INST_TCLOO_NEXT = 179,
INST_TCLOO_NEXT_CLASS = 180,
/* For compilation relating to TclOO */
#define INST_TCLOO_SELF 155
#define INST_TCLOO_CLASS 156
#define INST_TCLOO_NS 157
#define INST_TCLOO_IS_OBJECT 158
INST_YIELD_TO_INVOKE = 181,
/* For compilation of [array] subcommands */
#define INST_ARRAY_EXISTS_STK 159
#define INST_ARRAY_EXISTS_IMM 160
#define INST_ARRAY_MAKE_STK 161
#define INST_ARRAY_MAKE_IMM 162
INST_NUM_TYPE = 182,
INST_TRY_CVT_TO_BOOLEAN = 183,
INST_STR_CLASS = 184,
#define INST_INVOKE_REPLACE 163
INST_LAPPEND_LIST = 185,
INST_LAPPEND_LIST_ARRAY = 186,
INST_LAPPEND_LIST_ARRAY_STK = 187,
INST_LAPPEND_LIST_STK = 188,
#define INST_LIST_CONCAT 164
INST_CLOCK_READ = 189,
#define INST_EXPAND_DROP 165
INST_DICT_GET_DEF = 190,
/* New foreach implementation */
#define INST_FOREACH_START 166
#define INST_FOREACH_STEP 167
#define INST_FOREACH_END 168
#define INST_LMAP_COLLECT 169
/* TIP 461 */
INST_STR_LT = 191,
INST_STR_GT = 192,
INST_STR_LE = 193,
INST_STR_GE = 194,
/* For compilation of [string trim] and related */
#define INST_STR_TRIM 170
#define INST_STR_TRIM_LEFT 171
#define INST_STR_TRIM_RIGHT 172
#define INST_CONCAT_STK 173
#define INST_STR_UPPER 174
#define INST_STR_LOWER 175
#define INST_STR_TITLE 176
#define INST_STR_REPLACE 177
#define INST_ORIGIN_COMMAND 178
#define INST_TCLOO_NEXT 179
#define INST_TCLOO_NEXT_CLASS 180
#define INST_YIELD_TO_INVOKE 181
#define INST_NUM_TYPE 182
#define INST_TRY_CVT_TO_BOOLEAN 183
#define INST_STR_CLASS 184
#define INST_LAPPEND_LIST 185
#define INST_LAPPEND_LIST_ARRAY 186
#define INST_LAPPEND_LIST_ARRAY_STK 187
#define INST_LAPPEND_LIST_STK 188
#define INST_CLOCK_READ 189
#define INST_DICT_GET_DEF 190
/* TIP 461 */
#define INST_STR_LT 191
#define INST_STR_GT 192
#define INST_STR_LE 193
#define INST_STR_GE 194
/* The last opcode */
#define LAST_INST_OPCODE 194
/* The last opcode */
LAST_INST_OPCODE = 194
};
/*
* Table describing the Tcl bytecode instructions: their name (for displaying
@@ -1237,9 +1223,11 @@ MODULE_SCOPE int TclPushProcCallFrame(ClientData clientData,
#define TclFetchAuxData(envPtr, index) \
(envPtr)->auxDataArrayPtr[(index)].clientData
#define LITERAL_ON_HEAP 0x01
#define LITERAL_CMD_NAME 0x02
#define LITERAL_UNSHARED 0x04
enum LiteralFlags {
LITERAL_ON_HEAP = 0x01,
LITERAL_CMD_NAME = 0x02,
LITERAL_UNSHARED = 0x04
};
/*
* Macro used to manually adjust the stack requirements; used in cases where
+1 -1
View File
@@ -950,7 +950,7 @@ Tcl_DictObjPut(
TclInvalidateStringRep(dictPtr);
hPtr = CreateChainEntry(dict, keyPtr, &isNew);
dict->refCount++;
TclFreeIntRep(dictPtr)
TclFreeIntRep(dictPtr);
DictSetIntRep(dictPtr, dict);
Tcl_IncrRefCount(valuePtr);
if (!isNew) {
+17 -9
View File
@@ -127,10 +127,12 @@ typedef struct {
* file.
*/
#define ENCODING_SINGLEBYTE 0
#define ENCODING_DOUBLEBYTE 1
#define ENCODING_MULTIBYTE 2
#define ENCODING_ESCAPE 3
enum EncodingTypes {
ENCODING_SINGLEBYTE = 0,
ENCODING_DOUBLEBYTE = 1,
ENCODING_MULTIBYTE = 2,
ENCODING_ESCAPE = 3
};
/*
* A list of directories in which Tcl should look for *.enc files. This list
@@ -510,11 +512,17 @@ FillEncodingFileMap(void)
*---------------------------------------------------------------------------
*/
/* This flags must not conflict with other TCL_ENCODING_* flags in tcl.h */
#define TCL_ENCODING_MODIFIED 0x20 /* Converting NULL bytes to 0xC0 0x80 */
/* Since TCL_ENCODING_MODIFIED is only used for utf-8 and
* TCL_ENCODING_LE is only used for utf-16/ucs-2, re-use the same value */
#define TCL_ENCODING_LE TCL_ENCODING_MODIFIED /* Little-endian encoding */
/* These flags must not conflict with other TCL_ENCODING_* flags in tcl.h */
enum EncodingFlags {
TCL_ENCODING_MODIFIED = 0x20,
/* Converting NULL bytes to 0xC0 0x80 */
/*
* Since TCL_ENCODING_MODIFIED is only used for utf-8 and TCL_ENCODING_LE
* is only used for utf-16/ucs-2, re-use the same value.
*/
TCL_ENCODING_LE = TCL_ENCODING_MODIFIED
/* Little-endian encoding */
};
void
TclInitEncodingSubsystem(void)
+2
View File
@@ -15,6 +15,8 @@
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#define _BUILD_TCL_EXECUTE 1 /* Disable some warnings */
#include "tclInt.h"
#include "tclCompile.h"
#include "tclOOInt.h"
+11 -7
View File
@@ -68,18 +68,22 @@ static int ExecuteCallback(TransformChannelData *ctrl,
* the procedure what to do with the result of the script it calls.
*/
#define TRANSMIT_DONT 0 /* No transfer to do. */
#define TRANSMIT_DOWN 1 /* Transfer to the underlying channel. */
#define TRANSMIT_SELF 2 /* Transfer into our channel. */
#define TRANSMIT_IBUF 3 /* Transfer to internal input buffer. */
#define TRANSMIT_NUM 4 /* Transfer number to 'maxRead'. */
enum TransmitAction {
TRANSMIT_DONT = 0, /* No transfer to do. */
TRANSMIT_DOWN = 1, /* Transfer to the underlying channel. */
TRANSMIT_SELF = 2, /* Transfer into our channel. */
TRANSMIT_IBUF = 3, /* Transfer to internal input buffer. */
TRANSMIT_NUM = 4 /* Transfer number to 'maxRead'. */
};
/*
* Codes for 'preserve' of 'ExecuteCallback'.
*/
#define P_PRESERVE 1
#define P_NO_PRESERVE 0
enum PreserveFlags {
P_PRESERVE = 1,
P_NO_PRESERVE = 0
};
/*
* Strings for the action codes delivered to the script implementing a
+14 -20
View File
@@ -44,7 +44,7 @@ static void ReflectThread(ClientData clientData, int action);
static int ReflectEventRun(Tcl_Event *ev, int flags);
static int ReflectEventDelete(Tcl_Event *ev, ClientData cd);
#endif
static long long ReflectSeekWide(ClientData clientData,
static long long ReflectSeekWide(ClientData clientData,
long long offset, int mode, int *errorCodePtr);
#ifndef TCL_NO_DEPRECATED
static int ReflectSeek(ClientData clientData, long offset,
@@ -58,8 +58,8 @@ static int ReflectSetOption(ClientData clientData,
const char *newValue);
static int ReflectTruncate(ClientData clientData,
long long length);
static void TimerRunRead(ClientData clientData);
static void TimerRunWrite(ClientData clientData);
static void TimerRunRead(ClientData clientData);
static void TimerRunWrite(ClientData clientData);
/*
* The C layer channel type/driver definition used by the reflection.
@@ -104,33 +104,27 @@ typedef struct {
* Tcl level part of the channel. NULL here
* signals the channel is dead because the
* interpreter/thread containing its Tcl
* command is gone.
*/
* command is gone. */
#if TCL_THREADS
Tcl_ThreadId thread; /* Thread the 'interp' belongs to. == Handler thread */
Tcl_ThreadId owner; /* Thread owning the structure. == Channel thread */
Tcl_ThreadId thread; /* Thread the 'interp' belongs to. == Handler
* thread */
Tcl_ThreadId owner; /* Thread owning the structure. == Channel
* thread */
#endif
Tcl_Obj *cmd; /* Callback command prefix */
Tcl_Obj *methods; /* Methods to append to command prefix */
Tcl_Obj *name; /* Name of the channel as created */
int mode; /* Mask of R/W mode */
int interest; /* Mask of events the channel is interested
* in. */
int dead; /* Boolean signal that some operations
* should no longer be attempted. */
Tcl_TimerToken readTimer; /*
A token for the timer that is scheduled in
order to call Tcl_NotifyChannel when the
channel is readable
*/
Tcl_TimerToken writeTimer; /*
A token for the timer that is scheduled in
order to call Tcl_NotifyChannel when the
channel is writable
*/
Tcl_TimerToken readTimer; /* A token for the timer that is scheduled in
* order to call Tcl_NotifyChannel when the
* channel is readable */
Tcl_TimerToken writeTimer; /* A token for the timer that is scheduled in
* order to call Tcl_NotifyChannel when the
* channel is writable */
/*
* Note regarding the usage of timers.
+30 -35
View File
@@ -476,8 +476,10 @@ static int TransformLimit(ReflectedTransform *rtPtr,
* Operation codes for TransformFlush().
*/
#define FLUSH_WRITE 1
#define FLUSH_DISCARD 0
enum FlushOperations {
FLUSH_WRITE = 1,
FLUSH_DISCARD = 0
};
/*
* Main methods to plug into the 'chan' ensemble'. ==================
@@ -1113,7 +1115,6 @@ ReflectInput(
goto stop;
}
/*
* The buffer is exhausted, but the caller wants even more. We now
* have to go to the underlying channel, get more bytes and then
@@ -1149,12 +1150,10 @@ ReflectInput(
goto stop;
}
readBytes = Tcl_ReadRaw(rtPtr->parent,
(char *) Tcl_SetByteArrayLength(bufObj, toRead), toRead);
if (readBytes < 0) {
if (Tcl_InputBlocked(rtPtr->parent) && (gotBytes > 0)) {
/*
* Down channel is blocked and offers zero additional bytes.
* The nonzero gotBytes already returned makes the total
@@ -1165,11 +1164,10 @@ ReflectInput(
}
/*
* Either the down channel is not blocked (a real error)
* or it is and there are gotBytes==0 byte copied so far.
* In either case, pass up the error, so we either report
* any real error, or do not mistakenly signal EOF by
* returning 0 to the caller.
* Either the down channel is not blocked (a real error) or it is
* and there are gotBytes==0 byte copied so far. In either case,
* pass up the error, so we either report any real error, or do
* not mistakenly signal EOF by returning 0 to the caller.
*/
*errorCodePtr = Tcl_GetErrno();
@@ -1177,34 +1175,33 @@ ReflectInput(
}
if (readBytes == 0) {
/*
* Zero returned from Tcl_ReadRaw() always indicates EOF
* on the down channel.
* Zero returned from Tcl_ReadRaw() always indicates EOF on the
* down channel.
*/
rtPtr->eofPending = 1;
/*
* Now this is a bit different. The partial data waiting is
* converted and returned.
*/
if (HAS(rtPtr->methods, METH_DRAIN)) {
if (!TransformDrain(rtPtr, errorCodePtr)) {
goto error;
}
}
if (ResultLength(&rtPtr->result) == 0) {
/*
* Now this is a bit different. The partial data waiting is
* converted and returned.
* The drain delivered nothing.
*/
if (HAS(rtPtr->methods, METH_DRAIN)) {
if (!TransformDrain(rtPtr, errorCodePtr)) {
goto error;
}
}
goto stop;
}
if (ResultLength(&rtPtr->result) == 0) {
/*
* The drain delivered nothing.
*/
goto stop;
}
continue; /* at: while (toRead > 0) */
continue; /* at: while (toRead > 0) */
} /* readBytes == 0 */
/*
@@ -1388,16 +1385,15 @@ ReflectSeekWide(
curPos = -1;
} else {
curPos = Tcl_ChannelSeekProc(parent->typePtr)(
parent->instanceData, offset, seekMode,
errorCodePtr);
parent->instanceData, offset, seekMode, errorCodePtr);
}
#else
*errorCodePtr = EINVAL;
curPos = -1;
#endif
} else {
curPos = Tcl_ChannelWideSeekProc(parent->typePtr)(parent->instanceData, offset,
seekMode, errorCodePtr);
curPos = Tcl_ChannelWideSeekProc(parent->typePtr)(parent->instanceData,
offset, seekMode, errorCodePtr);
}
if (curPos == -1) {
Tcl_SetErrno(*errorCodePtr);
@@ -1423,8 +1419,7 @@ ReflectSeek(
* routine.
*/
return ReflectSeekWide(clientData, offset, seekMode,
errorCodePtr);
return ReflectSeekWide(clientData, offset, seekMode, errorCodePtr);
}
#endif
+268 -246
View File
@@ -230,7 +230,9 @@ typedef struct Tcl_ResolverInfo {
* (Bug #835020)
*/
#define TCL_AVOID_RESOLVERS 0x40000
enum ResolutionFlags {
TCL_AVOID_RESOLVERS = 0x40000
};
/*
*----------------------------------------------------------------
@@ -283,7 +285,7 @@ typedef struct Namespace {
* synonym. */
char *fullName; /* The namespace's fully qualified name. This
* starts with ::. */
void *clientData; /* An arbitrary value associated with this
void *clientData; /* An arbitrary value associated with this
* namespace. */
Tcl_NamespaceDeleteProc *deleteProc;
/* Procedure invoked when deleting the
@@ -366,7 +368,8 @@ typedef struct Namespace {
* LookupCompiledLocal to resolve variable
* references within the namespace at compile
* time. */
unsigned int exportLookupEpoch; /* Incremented whenever a command is added to
unsigned int exportLookupEpoch;
/* Incremented whenever a command is added to
* a namespace, removed from a namespace or
* the exports of a namespace are changed.
* Allows TIP#112-driven command lists to be
@@ -413,44 +416,50 @@ struct NamespacePathEntry {
/*
* 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
* 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.
* NS_KILLED - 1 means that TclTeardownNamespace has already been called on
* this namespace and it should not be called again [Bug 1355942]
* NS_SUPPRESS_COMPILATION -
* Marks the commands in this namespace for not being compiled,
* forcing them to be looked up every time.
*/
#define NS_DYING 0x01
#define NS_DEAD 0x02
#define NS_KILLED 0x04
#define NS_SUPPRESS_COMPILATION 0x08
enum NamespaceFlags {
NS_DYING = 0x01, /* 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 = 0x02, /* 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 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. */
NS_KILLED = 0x04, /* TclTeardownNamespace has already been
* called on this namespace and it should not
* be called again. [Bug 1355942] */
NS_SUPPRESS_COMPILATION = 0x08
/* Marks the commands in this namespace for
* not being compiled, forcing them to be
* looked up every time. */
};
/*
* Flags passed to TclGetNamespaceForQualName:
* Flags passed to TclGetNamespaceForQualName. Also:
*
* TCL_GLOBAL_ONLY - (see tcl.h) Look only in the global ns.
* TCL_NAMESPACE_ONLY - (see tcl.h) Look only in the context ns.
* TCL_CREATE_NS_IF_UNKNOWN - Create unknown namespaces.
* TCL_FIND_ONLY_NS - The name sought is a namespace name.
*/
#define TCL_CREATE_NS_IF_UNKNOWN 0x800
#define TCL_FIND_ONLY_NS 0x1000
enum GetNamespaceFlags {
TCL_CREATE_NS_IF_UNKNOWN = 0x800,
/* Create unknown namespaces. */
TCL_FIND_ONLY_NS = 0x1000 /* The name sought is a namespace name. */
};
/*
* The client data for an ensemble command. This consists of the table of
@@ -534,10 +543,13 @@ typedef struct EnsembleConfig {
* Various bits for the EnsembleConfig.flags field.
*/
#define ENSEMBLE_DEAD 0x1 /* Flag value to say that the ensemble is dead
enum EnsembleFlags {
ENSEMBLE_DEAD = 0x1, /* Flag value to say that the ensemble is dead
* and on its way out. */
#define ENSEMBLE_COMPILE 0x4 /* Flag to enable bytecode compilation of an
* ensemble. */
ENSEMBLE_COMPILE = 0x4 /* Flag to enable bytecode compilation of an
* ensemble. Possible candidate for some sort
* of exposure to the public interface? */
};
/*
*----------------------------------------------------------------
@@ -554,7 +566,7 @@ typedef struct EnsembleConfig {
typedef struct VarTrace {
Tcl_VarTraceProc *traceProc;/* Procedure to call when operations given by
* flags are performed on variable. */
void *clientData; /* Argument to pass to proc. */
void *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,
@@ -573,14 +585,14 @@ typedef struct CommandTrace {
Tcl_CommandTraceProc *traceProc;
/* Procedure to call when operations given by
* flags are performed on command. */
void *clientData; /* Argument to pass to proc. */
void *clientData; /* Argument to pass to proc. */
int flags; /* What events the trace procedure is
* interested in: OR-ed combination of
* TCL_TRACE_RENAME, TCL_TRACE_DELETE. */
struct CommandTrace *nextPtr;
/* Next in list of traces associated with a
* particular command. */
unsigned int refCount; /* Used to ensure this structure is not
unsigned int refCount; /* Used to ensure this structure is not
* deleted too early. Keeps track of how many
* pieces of code have a pointer to this
* structure. */
@@ -745,35 +757,38 @@ typedef struct VarInHash {
* in precompiled scripts keep working.
*/
/* Type of value (0 is scalar) */
#define VAR_ARRAY 0x1
#define VAR_LINK 0x2
enum VariableFlags {
/* Type of value (0 is scalar) */
VAR_ARRAY = 0x1,
VAR_LINK = 0x2,
/* Type of storage (0 is compiled local) */
#define VAR_IN_HASHTABLE 0x4
#define VAR_DEAD_HASH 0x8
#define VAR_ARRAY_ELEMENT 0x1000
#define VAR_NAMESPACE_VAR 0x80 /* KEEP OLD VALUE for Itcl */
/* Type of storage (0 is compiled local) */
VAR_IN_HASHTABLE = 0x4,
VAR_DEAD_HASH = 0x8,
VAR_ARRAY_ELEMENT = 0x1000,
VAR_NAMESPACE_VAR = 0x80, /* KEEP OLD VALUE for Itcl */
#define VAR_ALL_HASH \
(VAR_IN_HASHTABLE|VAR_DEAD_HASH|VAR_NAMESPACE_VAR|VAR_ARRAY_ELEMENT)
VAR_ALL_HASH = (
VAR_IN_HASHTABLE | VAR_DEAD_HASH | VAR_NAMESPACE_VAR |
VAR_ARRAY_ELEMENT),
/* Trace and search state. */
/* Trace and search state. */
VAR_TRACED_READ = 0x10, /* TCL_TRACE_READS */
VAR_TRACED_WRITE = 0x20, /* TCL_TRACE_WRITES */
VAR_TRACED_UNSET = 0x40, /* TCL_TRACE_UNSETS */
VAR_TRACED_ARRAY = 0x800, /* TCL_TRACE_ARRAY */
VAR_TRACE_ACTIVE = 0x2000,
VAR_SEARCH_ACTIVE = 0x4000,
VAR_ALL_TRACES = (
VAR_TRACED_READ | VAR_TRACED_WRITE | VAR_TRACED_ARRAY |
VAR_TRACED_UNSET),
#define VAR_TRACED_READ 0x10 /* TCL_TRACE_READS */
#define VAR_TRACED_WRITE 0x20 /* TCL_TRACE_WRITES */
#define VAR_TRACED_UNSET 0x40 /* TCL_TRACE_UNSETS */
#define VAR_TRACED_ARRAY 0x800 /* TCL_TRACE_ARRAY */
#define VAR_TRACE_ACTIVE 0x2000
#define VAR_SEARCH_ACTIVE 0x4000
#define VAR_ALL_TRACES \
(VAR_TRACED_READ|VAR_TRACED_WRITE|VAR_TRACED_ARRAY|VAR_TRACED_UNSET)
/* Special handling on initialisation (only CompiledLocal). */
#define VAR_ARGUMENT 0x100 /* KEEP OLD VALUE! See tclProc.c */
#define VAR_TEMPORARY 0x200 /* KEEP OLD VALUE! See tclProc.c */
#define VAR_IS_ARGS 0x400
#define VAR_RESOLVED 0x8000
/* Special handling on initialisation (only CompiledLocal). */
VAR_ARGUMENT = 0x100, /* KEEP OLD VALUE! See tclProc.c */
VAR_TEMPORARY = 0x200, /* KEEP OLD VALUE! See tclProc.c */
VAR_IS_ARGS = 0x400,
VAR_RESOLVED = 0x8000
};
/*
* Macros to ensure that various flag bits are set properly for variables.
@@ -974,7 +989,7 @@ typedef struct CompiledLocal {
* is marked by a unique tag during
* compilation, and that same tag is used to
* find the variable at runtime. */
char name[TCLFLEXARRAY]; /* Name of the local variable starts here. If
char name[TCLFLEXARRAY]; /* Name of the local variable starts here. If
* the name is NULL, this will just be '\0'.
* The actual size of this field will be large
* enough to hold the name. MUST BE THE LAST
@@ -1032,7 +1047,7 @@ typedef struct Trace {
int level; /* Only trace commands at nesting level less
* than or equal to this. */
Tcl_CmdObjTraceProc *proc; /* Procedure to call to trace command. */
void *clientData; /* Arbitrary value to pass to proc. */
void *clientData; /* Arbitrary value to pass to proc. */
struct Trace *nextPtr; /* Next in list of traces for this interp. */
int flags; /* Flags governing the trace - see
* Tcl_CreateObjTrace for details. */
@@ -1063,17 +1078,16 @@ typedef struct ActiveInterpTrace {
/*
* Flag values designating types of execution traces. See tclTrace.c for
* related flag values.
*
* TCL_TRACE_ENTER_EXEC - triggers enter/enterstep traces.
* - passed to Tcl_CreateObjTrace to set up
* "enterstep" traces.
* TCL_TRACE_LEAVE_EXEC - triggers leave/leavestep traces.
* - passed to Tcl_CreateObjTrace to set up
* "leavestep" traces.
*/
#define TCL_TRACE_ENTER_EXEC 1
#define TCL_TRACE_LEAVE_EXEC 2
enum ExecutionTraceTypes {
TCL_TRACE_ENTER_EXEC = 1, /* Triggers enter/enterstep traces. Passed to
* Tcl_CreateObjTrace to set up "enterstep"
* traces. */
TCL_TRACE_LEAVE_EXEC = 2 /* Triggers leave/leavestep traces. Passed to
* Tcl_CreateObjTrace to set up "leavestep"
* traces. */
};
/*
* The structure below defines an entry in the assocData hash table which is
@@ -1176,20 +1190,24 @@ typedef struct CallFrame {
/* NULL if no tailcall is scheduled */
} CallFrame;
#define FRAME_IS_PROC 0x1
#define FRAME_IS_LAMBDA 0x2
#define FRAME_IS_METHOD 0x4 /* The frame is a method body, and the frame's
enum CallFrameFlags {
/*FRAME_IS_NAMESPACE = 0,*/ /* The frame is a namespace. Not used except
* by implication. */
FRAME_IS_PROC = 0x1, /* The frame is a standard procedure. */
FRAME_IS_LAMBDA = 0x2, /* The frame is a lambda term */
FRAME_IS_METHOD = 0x4, /* The frame is a method body, and the frame's
* clientData field contains a CallContext
* reference. Part of TIP#257. */
#define FRAME_IS_OO_DEFINE 0x8 /* The frame is part of the inside workings of
FRAME_IS_OO_DEFINE = 0x8, /* The frame is part of the inside workings of
* the [oo::define] command; the clientData
* field contains an Object reference that has
* been confirmed to refer to a class. Part of
* TIP#257. */
#define FRAME_IS_PRIVATE_DEFINE 0x10
FRAME_IS_PRIVATE_DEFINE = 0x10
/* Marks this frame as being used for private
* declarations with [oo::define]. Usually
* OR'd with FRAME_IS_OO_DEFINE. TIP#500. */
};
/*
* TIP #280
@@ -1312,7 +1330,7 @@ typedef struct CFWordBC {
typedef struct ContLineLoc {
int num; /* Number of entries in loc, not counting the
* final -1 marker entry. */
int loc[TCLFLEXARRAY];/* Table of locations, as character offsets.
int loc[TCLFLEXARRAY]; /* Table of locations, as character offsets.
* The table is allocated as part of the
* structure, extending behind the nominal end
* of the structure. An entry containing the
@@ -1336,13 +1354,15 @@ typedef struct ContLineLoc {
* types, per the context of the byte code in execution.
*/
#define TCL_LOCATION_EVAL (0) /* Location in a dynamic eval script. */
#define TCL_LOCATION_BC (2) /* Location in byte code. */
#define TCL_LOCATION_PREBC (3) /* Location in precompiled byte code, no
* location. */
#define TCL_LOCATION_SOURCE (4) /* Location in a file. */
#define TCL_LOCATION_PROC (5) /* Location in a dynamic proc. */
#define TCL_LOCATION_LAST (6) /* Number of values in the enum. */
enum CmdFrameTypes {
TCL_LOCATION_EVAL = 0, /* Location in a dynamic eval script. */
TCL_LOCATION_BC = 2, /* Location in bytecode. */
TCL_LOCATION_PREBC = 3, /* Location in precompiled bytecode, no
* location. */
TCL_LOCATION_SOURCE = 4, /* Location in a file. */
TCL_LOCATION_PROC = 5, /* Location in a dynamic proc. */
TCL_LOCATION_LAST = 6 /* Number of values in the enum. */
};
/*
* Structure passed to describe procedure-like "procedures" that are not
@@ -1353,10 +1373,10 @@ typedef struct ContLineLoc {
typedef Tcl_Obj * (GetFrameInfoValueProc)(void *clientData);
typedef struct {
const char *name; /* Name of this field. */
GetFrameInfoValueProc *proc; /* Function to generate a Tcl_Obj* from the
GetFrameInfoValueProc *proc;/* Function to generate a Tcl_Obj* from the
* clientData, or just use the clientData
* directly (after casting) if NULL. */
void *clientData; /* Context for above function, or Tcl_Obj* if
void *clientData; /* Context for above function, or Tcl_Obj* if
* proc field is NULL. */
} ExtraFrameInfoField;
typedef struct {
@@ -1383,8 +1403,10 @@ typedef void **TclHandle;
*----------------------------------------------------------------
*/
#define TCL_REG_BOSONLY 002000 /* Prepend \A to pattern so it only matches at
enum TclRegexpFlags {
TCL_REG_BOSONLY = 002000 /* Prepend \A to pattern so it only matches at
* the beginning of the string. */
};
/*
* These are a thin layer over TclpThreadKeyDataGet and TclpThreadKeyDataSet
@@ -1691,11 +1713,11 @@ typedef struct Command {
Tcl_ObjCmdProc *objProc; /* Object-based command procedure. */
void *objClientData; /* Arbitrary value passed to object proc. */
Tcl_CmdProc *proc; /* String-based command procedure. */
void *clientData; /* Arbitrary value passed to string proc. */
void *clientData; /* Arbitrary value passed to string proc. */
Tcl_CmdDeleteProc *deleteProc;
/* Procedure invoked when deleting command to,
* e.g., free all client data. */
void *deleteData; /* Arbitrary value passed to deleteProc. */
void *deleteData; /* Arbitrary value passed to deleteProc. */
int flags; /* Miscellaneous bits of information about
* command. See below for definitions. */
ImportRef *importRefPtr; /* List of each imported Command created in
@@ -1711,37 +1733,32 @@ typedef struct Command {
} Command;
/*
* Flag bits for commands.
*
* CMD_DYING - If 1 the command is in the process of
* being deleted (its deleteProc is currently
* executing). Other attempts to delete the
* command should be ignored.
* CMD_TRACE_ACTIVE - If 1 the trace processing is currently
* underway for a rename/delete change. See the
* two flags below for which is currently being
* processed.
* CMD_HAS_EXEC_TRACES - If 1 means that this command has at least one
* execution trace (as opposed to simple
* delete/rename traces) in its tracePtr list.
* CMD_COMPILES_EXPANDED - If 1 this command has a compiler that
* can handle expansion (provided it is not the
* first word).
* TCL_TRACE_RENAME - A rename trace is in progress. Further
* Flag bits for commands. Also:
* TCL_TRACE_RENAME - A rename trace is in progress. Further
* recursive renames will not be traced.
* TCL_TRACE_DELETE - A delete trace is in progress. Further
* TCL_TRACE_DELETE - A delete trace is in progress. Further
* recursive deletes will not be traced.
* (these last two flags are defined in tcl.h)
* (these two flags are defined in tcl.h)
*/
#define CMD_DYING 0x01
#define CMD_TRACE_ACTIVE 0x02
#define CMD_HAS_EXEC_TRACES 0x04
#define CMD_COMPILES_EXPANDED 0x08
#define CMD_REDEF_IN_PROGRESS 0x10
#define CMD_VIA_RESOLVER 0x20
#define CMD_DEAD 0x40
enum CommandFlags {
CMD_DYING = 0x01, /* The command is in the process of being
* deleted (its deleteProc is currently
* executing). Other attempts to delete the
* command should be ignored. */
CMD_TRACE_ACTIVE = 0x02, /* The trace processing is currently underway
* for a rename/delete change. See the two
* flags (TCL_TRACE_RENAME, TCL_TRACE_DELETE)
* for which is currently being processed. */
CMD_HAS_EXEC_TRACES = 0x04,
CMD_COMPILES_EXPANDED = 0x08,
/* This command has a compiler that can handle
* expansion (provided it is not the first
* word). */
CMD_REDEF_IN_PROGRESS = 0x10,
CMD_VIA_RESOLVER = 0x20,
CMD_DEAD = 0x40
};
/*
*----------------------------------------------------------------
@@ -2267,75 +2284,81 @@ typedef struct Interp {
/*
* EvalFlag bits for Interp structures:
*
* TCL_ALLOW_EXCEPTIONS 1 means it's OK for the script to terminate with a
* code other than TCL_OK or TCL_ERROR; 0 means codes
* other than these should be turned into errors.
*/
#define TCL_ALLOW_EXCEPTIONS 0x04
#define TCL_EVAL_FILE 0x02
#define TCL_EVAL_SOURCE_IN_FRAME 0x10
#define TCL_EVAL_NORESOLVE 0x20
#define TCL_EVAL_DISCARD_RESULT 0x40
enum TclInterpEvalFlags {
TCL_ALLOW_EXCEPTIONS = 0x04,/* It's OK for the script to terminate with a
* code other than TCL_OK or TCL_ERROR; not
* set means codes other than these should be
* turned into errors. */
TCL_EVAL_FILE = 0x02,
TCL_EVAL_SOURCE_IN_FRAME = 0x10,
TCL_EVAL_NORESOLVE = 0x20,
TCL_EVAL_DISCARD_RESULT = 0x40
};
/*
* Flag bits for Interp structures:
*
* DELETED: Non-zero means the interpreter has been deleted:
* don't process any more commands for it, and destroy
* the structure as soon as all nested invocations of
* Tcl_Eval are done.
* ERR_ALREADY_LOGGED: Non-zero means information has already been logged in
* iPtr->errorInfo for the current Tcl_Eval instance, so
* Tcl_Eval needn't log it (used to implement the "error
* message log" command).
* DONT_COMPILE_CMDS_INLINE: Non-zero means that the bytecode compiler should
* not compile any commands into an inline sequence of
* instructions. This is set 1, for example, when command
* traces are requested.
* RAND_SEED_INITIALIZED: Non-zero means that the randSeed value of the interp
* has not be initialized. This is set 1 when we first
* use the rand() or srand() functions.
* SAFE_INTERP: Non zero means that the current interp is a safe
* interp (i.e. it has only the safe commands installed,
* less privilege than a regular interp).
* INTERP_DEBUG_FRAME: Used for switching on various extra interpreter
* debug/info mechanisms (e.g. info frame eval/uplevel
* tracing) which are performance intensive.
* INTERP_TRACE_IN_PROGRESS: Non-zero means that an interp trace is currently
* active; so no further trace callbacks should be
* invoked.
* INTERP_ALTERNATE_WRONG_ARGS: Used for listing second and subsequent forms
* of the wrong-num-args string in Tcl_WrongNumArgs.
* Makes it append instead of replacing and uses
* different intermediate text.
* CANCELED: Non-zero means that the script in progress should be
* canceled as soon as possible. This can be checked by
* extensions (and the core itself) by calling
* Tcl_Canceled and checking if TCL_ERROR is returned.
* This is a one-shot flag that is reset immediately upon
* being detected; however, if the TCL_CANCEL_UNWIND flag
* is set Tcl_Canceled will continue to report that the
* script in progress has been canceled thereby allowing
* the evaluation stack for the interp to be fully
* unwound.
*
* WARNING: For the sake of some extensions that have made use of former
* internal values, do not re-use the flag values 2 (formerly ERR_IN_PROGRESS)
* or 8 (formerly ERROR_CODE_SET).
*/
#define DELETED 1
#define ERR_ALREADY_LOGGED 4
#define INTERP_DEBUG_FRAME 0x10
#define DONT_COMPILE_CMDS_INLINE 0x20
#define RAND_SEED_INITIALIZED 0x40
#define SAFE_INTERP 0x80
#define INTERP_TRACE_IN_PROGRESS 0x200
#define INTERP_ALTERNATE_WRONG_ARGS 0x400
#define ERR_LEGACY_COPY 0x800
#define CANCELED 0x1000
enum TclInterpFlags {
DELETED = 1, /* If set, the interpreter has been deleted:
* don't process any more commands for it, and
* destroy the structure as soon as all nested
* invocations of Tcl_Eval are done. */
ERR_ALREADY_LOGGED = 4, /* If set, information has already been logged
* in iPtr->errorInfo for the current Tcl_Eval
* instance, so Tcl_Eval needn't log it (used
* to implement the "error message log"
* command). */
INTERP_DEBUG_FRAME = 0x10, /* Used for switching on various extra
* interpreter debug/info mechanisms (e.g.
* info frame eval/uplevel tracing) which are
* performance intensive. */
DONT_COMPILE_CMDS_INLINE = 0x20,
/* If set the bytecode compiler should not
* compile any commands into an inline
* sequence of instructions. This is set, for
* example, when command traces are
* requested. */
RAND_SEED_INITIALIZED = 0x40,
/* If set, the randSeed value of the interp
* has been initialized. This is set when we
* first use the rand() or srand()
* functions. */
SAFE_INTERP = 0x80, /* If set, the current interp is a safe interp
* (i.e. it has only the safe commands
* installed, less privilege than a regular
* interp). */
INTERP_TRACE_IN_PROGRESS = 0x200,
/* An interp trace is currently active; so no
* further trace callbacks should be
* invoked. */
INTERP_ALTERNATE_WRONG_ARGS = 0x400,
/* Used for listing second and subsequent
* forms of the wrong-num-args string in
* Tcl_WrongNumArgs. Makes it append instead
* of replacing and uses different
* intermediate text. Used by a few commands
* (notably [read]). */
ERR_LEGACY_COPY = 0x800,
CANCELED = 0x1000 /* If set, the script in progress should be
* canceled as soon as possible. This can be
* checked by extensions (and the core itself)
* by calling Tcl_Canceled and checking if
* TCL_ERROR is returned. This is a one-shot
* flag that is reset immediately upon being
* detected; however, if the TCL_CANCEL_UNWIND
* flag is set Tcl_Canceled will continue to
* report that the script in progress has been
* canceled thereby allowing the evaluation
* stack for the interp to be fully
* unwound. */
};
/*
* Maximum number of levels of nesting permitted in Tcl commands (used to
@@ -2413,22 +2436,21 @@ typedef enum TclEolTranslation {
/*
* Flags for TclInvoke:
*
* TCL_INVOKE_HIDDEN Invoke a hidden command; if not set, invokes
* an exposed command.
* TCL_INVOKE_NO_UNKNOWN If set, "unknown" is not invoked if the
* command to be invoked is not found. Only has
* an effect if invoking an exposed command,
* i.e. if TCL_INVOKE_HIDDEN is not also set.
* TCL_INVOKE_NO_TRACEBACK Does not record traceback information if the
* invoked command returns an error. Used if the
* caller plans on recording its own traceback
* information.
*/
#define TCL_INVOKE_HIDDEN (1<<0)
#define TCL_INVOKE_NO_UNKNOWN (1<<1)
#define TCL_INVOKE_NO_TRACEBACK (1<<2)
enum TclInvokeFlags {
TCL_INVOKE_HIDDEN = 1, /* Invoke a hidden command; if not set,
* invokes an exposed command. */
TCL_INVOKE_NO_UNKNOWN = 2, /* If set, "unknown" is not invoked if the
* command to be invoked is not found. Only
* has an effect if invoking an exposed
* command, i.e. if TCL_INVOKE_HIDDEN is not
* also set. */
TCL_INVOKE_NO_TRACEBACK = 4 /* Does not record traceback information if
* the invoked command returns an error. Used
* if the caller plans on recording its own
* traceback information. */
};
/*
* The structure used as the internal representation of Tcl list objects. This
@@ -2490,8 +2512,10 @@ typedef struct List {
* TclNRLmapCmd and their compilations.
*/
#define TCL_EACH_KEEP_NONE 0 /* Discard iteration result like [foreach] */
#define TCL_EACH_COLLECT 1 /* Collect iteration result like [lmap] */
enum ForeachFlags {
TCL_EACH_KEEP_NONE = 0, /* Discard iteration result like [foreach] */
TCL_EACH_COLLECT = 1 /* Collect iteration result like [lmap] */
};
/*
* Macros providing a faster path to booleans and integers:
@@ -2550,27 +2574,24 @@ typedef struct List {
/*
* Flag values for TclTraceDictPath().
*
* DICT_PATH_READ indicates that all entries on the path must exist but no
* updates will be needed.
*
* DICT_PATH_UPDATE indicates that we are going to be doing an update at the
* tip of the path, so duplication of shared objects should be done along the
* way.
*
* DICT_PATH_EXISTS indicates that we are performing an existence test and a
* lookup failure should therefore not be an error. If (and only if) this flag
* is set, TclTraceDictPath() will return the special value
* DICT_PATH_NON_EXISTENT if the path is not traceable.
*
* DICT_PATH_CREATE (which also requires the DICT_PATH_UPDATE bit to be set)
* indicates that we are to create non-existent dictionaries on the path.
*/
#define DICT_PATH_READ 0
#define DICT_PATH_UPDATE 1
#define DICT_PATH_EXISTS 2
#define DICT_PATH_CREATE 5
enum DictPathFlags {
DICT_PATH_READ = 0, /* All entries on the path must exist but no
* updates will be needed. */
DICT_PATH_UPDATE = 1, /* We are going to be doing an update at the
* tip of the path, so duplication of shared
* objects should be done along the way. */
DICT_PATH_EXISTS = 2, /* We are performing an existence test and a
* lookup failure should therefore not be an
* error. If (and only if) this flag is set,
* TclTraceDictPath() will return the special
* value DICT_PATH_NON_EXISTENT if the path is
* not traceable. */
DICT_PATH_CREATE = 5 /* We are to create non-existent dictionaries
* on the path. (Also requires the
* DICT_PATH_UPDATE bit to be set.) */
};
#define DICT_PATH_NON_EXISTENT ((Tcl_Obj *) (void *) 1)
@@ -2623,10 +2644,12 @@ typedef struct TclFile_ *TclFile;
* combination of the following values:
*/
#define TCL_GLOBMODE_NO_COMPLAIN 1
#define TCL_GLOBMODE_JOIN 2
#define TCL_GLOBMODE_DIR 4
#define TCL_GLOBMODE_TAILS 8
enum GlobModeFlags {
TCL_GLOBMODE_NO_COMPLAIN = 1,
TCL_GLOBMODE_JOIN = 2,
TCL_GLOBMODE_DIR = 4,
TCL_GLOBMODE_TAILS = 8
};
typedef enum Tcl_PathPart {
TCL_PATH_DIRNAME,
@@ -2695,24 +2718,22 @@ typedef struct ProcessGlobalValue {
*----------------------------------------------------------------------
*/
#define TCL_PARSE_DECIMAL_ONLY 1
/* Leading zero doesn't denote octal or
enum TclParseNumberFlags {
TCL_PARSE_DECIMAL_ONLY = 1, /* Leading zero doesn't denote octal or
* hex. */
#define TCL_PARSE_OCTAL_ONLY 2
/* Parse octal even without prefix. */
#define TCL_PARSE_HEXADECIMAL_ONLY 4
TCL_PARSE_OCTAL_ONLY = 2, /* Parse octal even without prefix. */
TCL_PARSE_HEXADECIMAL_ONLY = 4,
/* Parse hexadecimal even without prefix. */
#define TCL_PARSE_INTEGER_ONLY 8
/* Disable floating point parsing. */
#define TCL_PARSE_SCAN_PREFIXES 16
TCL_PARSE_INTEGER_ONLY = 8, /* Disable floating point parsing. */
TCL_PARSE_SCAN_PREFIXES = 16,
/* Use [scan] rules dealing with 0?
* prefixes. */
#define TCL_PARSE_NO_WHITESPACE 32
TCL_PARSE_NO_WHITESPACE = 32,
/* Reject leading/trailing whitespace. */
#define TCL_PARSE_BINARY_ONLY 64
/* Parse binary even without prefix. */
#define TCL_PARSE_NO_UNDERSCORE 128
TCL_PARSE_BINARY_ONLY = 64, /* Parse binary even without prefix. */
TCL_PARSE_NO_UNDERSCORE = 128
/* Reject underscore digit separator */
};
/*
*----------------------------------------------------------------------
@@ -2720,14 +2741,16 @@ typedef struct ProcessGlobalValue {
*----------------------------------------------------------------------
*/
#define TCL_NUMBER_INT 2
enum TclNumberTypes {
TCL_NUMBER_INT = 2,
#if (TCL_MAJOR_VERSION < 9) && !defined(TCL_NO_DEPRECATED)
# define TCL_NUMBER_LONG 1 /* deprecated, not used any more */
# define TCL_NUMBER_WIDE TCL_NUMBER_INT /* deprecated */
TCL_NUMBER_LONG = 1, /* deprecated, not used any more */
TCL_NUMBER_WIDE = TCL_NUMBER_INT, /* deprecated */
#endif
#define TCL_NUMBER_BIG 3
#define TCL_NUMBER_DOUBLE 4
#define TCL_NUMBER_NAN 5
TCL_NUMBER_BIG = 3,
TCL_NUMBER_DOUBLE = 4,
TCL_NUMBER_NAN = 5
};
/*
*----------------------------------------------------------------
@@ -2801,7 +2824,9 @@ MODULE_SCOPE size_t tclObjsShared[TCL_MAX_SHARED_OBJ_STATS];
MODULE_SCOPE char tclEmptyString;
enum CheckEmptyStringResult {
TCL_EMPTYSTRING_UNKNOWN = -1, TCL_EMPTYSTRING_NO, TCL_EMPTYSTRING_YES
TCL_EMPTYSTRING_UNKNOWN = -1,
TCL_EMPTYSTRING_NO,
TCL_EMPTYSTRING_YES
};
/*
@@ -2870,7 +2895,7 @@ typedef struct ForIterData {
typedef void* TclFindSymbolProc(Tcl_Interp* interp, Tcl_LoadHandle loadHandle,
const char* symbol);
struct Tcl_LoadHandle_ {
void *clientData; /* Client data is the load handle in the
void *clientData; /* Client data is the load handle in the
* native filesystem if a module was loaded
* there, or an opaque pointer to a structure
* for further bookkeeping on load-from-VFS
@@ -2884,19 +2909,16 @@ struct Tcl_LoadHandle_ {
/* Flags for conversion of doubles to digit strings */
#define TCL_DD_E_FORMAT 0x2
/* Use a fixed-length string of digits,
enum DoubleFormatFlags {
TCL_DD_E_FORMAT = 0x2, /* Use a fixed-length string of digits,
* suitable for E format*/
#define TCL_DD_F_FORMAT 0x3
/* Use a fixed number of digits after the
TCL_DD_F_FORMAT = 0x3, /* Use a fixed number of digits after the
* decimal point, suitable for F format */
#define TCL_DD_SHORTEST 0x4
/* Use the shortest possible string */
#define TCL_DD_NO_QUICK 0x8
/* Debug flag: forbid quick FP conversion */
#define TCL_DD_CONVERSION_TYPE_MASK 0x3
TCL_DD_SHORTEST = 0x4, /* Use the shortest possible string */
TCL_DD_NO_QUICK = 0x8, /* Debug flag: forbid quick FP conversion */
TCL_DD_CONVERSION_TYPE_MASK = 0x3
/* Mask to isolate the conversion type */
};
/*
*----------------------------------------------------------------
+10 -11
View File
@@ -196,18 +196,18 @@ struct LimitHandler {
/*
* Values for the LimitHandler flags field.
* LIMIT_HANDLER_ACTIVE - Whether the handler is currently being
* processed; handlers are never to be entered reentrantly.
* LIMIT_HANDLER_DELETED - Whether the handler has been deleted. This
* should not normally be observed because when a handler is
* deleted it is also spliced out of the list of handlers, but
* even so we will be careful.
*/
#define LIMIT_HANDLER_ACTIVE 0x01
#define LIMIT_HANDLER_DELETED 0x02
enum LimitHandlerFlags {
LIMIT_HANDLER_ACTIVE = 0x01,/* Whether the handler is currently being
* processed; handlers are never to be entered
* reentrantly. */
LIMIT_HANDLER_DELETED = 0x02/* Whether the handler has been deleted. This
* should not normally be observed because
* when a handler is deleted it is also
* spliced out of the list of handlers, but
* even so we will be careful. */
};
/*
* Prototypes for local static functions:
@@ -276,7 +276,6 @@ static void TimeLimitCallback(ClientData clientData);
static Tcl_NRPostProc NRPostInvokeHidden;
static Tcl_ObjCmdProc NRInterpCmd;
static Tcl_ObjCmdProc NRChildCmd;
/*
*----------------------------------------------------------------------
+16 -18
View File
@@ -75,21 +75,19 @@ typedef struct Link {
/*
* Definitions for flag bits:
* LINK_READ_ONLY - 1 means errors should be generated if Tcl
* script attempts to write variable.
* LINK_BEING_UPDATED - 1 means that a call to Tcl_UpdateLinkedVar is
* in progress for this variable, so trace
* callbacks on the variable should be ignored.
* LINK_ALLOC_ADDR - 1 means linkPtr->addr was allocated on the
* heap.
* LINK_ALLOC_LAST - 1 means linkPtr->valueLast.p was allocated on
* the heap.
*/
#define LINK_READ_ONLY 1
#define LINK_BEING_UPDATED 2
#define LINK_ALLOC_ADDR 4
#define LINK_ALLOC_LAST 8
enum LinkFlags {
LINK_READ_ONLY = 1, /* Errors should be generated if Tcl script
* attempts to write variable. */
LINK_BEING_UPDATED = 2, /* A call to Tcl_UpdateLinkedVar is in
* progress for this variable, so trace
* callbacks on the variable should be
* ignored. */
LINK_ALLOC_ADDR = 4, /* linkPtr->addr was allocated on the heap. */
LINK_ALLOC_LAST = 8 /* linkPtr->valueLast.p was allocated on the
* heap. */
};
/*
* Forward references to functions defined later in this file:
@@ -110,11 +108,11 @@ static int SetInvalidRealFromAny(Tcl_Interp *interp,
*/
static Tcl_ObjType invalidRealType = {
"invalidReal", /* name */
NULL, /* freeIntRepProc */
NULL, /* dupIntRepProc */
NULL, /* updateStringProc */
NULL /* setFromAnyProc */
"invalidReal", /* name */
NULL, /* freeIntRepProc */
NULL, /* dupIntRepProc */
NULL, /* updateStringProc */
NULL /* setFromAnyProc */
};
/*
+5 -3
View File
@@ -105,9 +105,11 @@ typedef struct {
* Tcl_NewInstanceMethod.
*/
#define TCL_OO_METHOD_PUBLIC 1
#define TCL_OO_METHOD_UNEXPORTED 0
#define TCL_OO_METHOD_PRIVATE 0x20
enum TclOOVisibilityConstants {
TCL_OO_METHOD_PUBLIC = 1,
TCL_OO_METHOD_UNEXPORTED = 0,
TCL_OO_METHOD_PRIVATE = 0x20
};
/*
* The type of some object (or class) metadata. This describes how to delete
+20 -16
View File
@@ -51,13 +51,15 @@ typedef struct {
* Extra flags used for call chain management.
*/
#define DEFINITE_PROTECTED 0x100000
#define DEFINITE_PUBLIC 0x200000
#define KNOWN_STATE (DEFINITE_PROTECTED | DEFINITE_PUBLIC)
#define SPECIAL (CONSTRUCTOR | DESTRUCTOR | FORCE_UNKNOWN)
#define BUILDING_MIXINS 0x400000
#define TRAVERSED_MIXIN 0x800000
#define OBJECT_MIXIN 0x1000000
enum CallChainFlags {
DEFINITE_PROTECTED = 0x100000,
DEFINITE_PUBLIC = 0x200000,
BUILDING_MIXINS = 0x400000,
TRAVERSED_MIXIN = 0x800000,
OBJECT_MIXIN = 0x1000000,
KNOWN_STATE = (DEFINITE_PROTECTED | DEFINITE_PUBLIC),
SPECIAL = (CONSTRUCTOR | DESTRUCTOR | FORCE_UNKNOWN)
};
#define MIXIN_CONSISTENT(flags) \
(((flags) & OBJECT_MIXIN) || \
!((flags) & BUILDING_MIXINS) == !((flags) & TRAVERSED_MIXIN))
@@ -152,7 +154,6 @@ static const Tcl_ObjType methodNameType = {
NULL,
NULL
};
/*
* ----------------------------------------------------------------------
@@ -422,6 +423,14 @@ FinalizeMethodRefs(
* ----------------------------------------------------------------------
*/
/*
* Name the bits used in the names table values.
*/
enum NameTableFlags {
IN_LIST = 1,
NO_IMPLEMENTATION = 2
};
int
TclOOGetSortedMethodList(
Object *oPtr, /* The object to get the method names for. */
@@ -453,12 +462,6 @@ TclOOGetSortedMethodList(
Tcl_InitObjHashTable(&names);
Tcl_InitHashTable(&examinedClasses, TCL_ONE_WORD_KEYS);
/*
* Name the bits used in the names table values.
*/
#define IN_LIST 1
#define NO_IMPLEMENTATION 2
/*
* Process method names due to the object.
*/
@@ -2027,8 +2030,9 @@ AddSimpleClassDefineNamespaces(
static inline void
AddDefinitionNamespaceToChain(
Class *const definerCls, /* What class defines this entry. */
Tcl_Obj *const namespaceName, /* The name for this entry (or NULL, a
Class *const definerCls, /* What class defines this entry. */
Tcl_Obj *const namespaceName,
/* The name for this entry (or NULL, a
* no-op). */
DefineChain *const definePtr,
/* The define chain to add the method
+28 -21
View File
@@ -112,7 +112,9 @@ typedef struct ProcedureMethod {
* methods.
*/
#define USE_DECLARER_NS 0x80
enum ProcedureMethodFlags {
USE_DECLARER_NS = 0x80,
};
/*
* Forwarded methods have the following extra information.
@@ -213,36 +215,38 @@ typedef struct Object {
* command. */
} Object;
#define OBJECT_DESTRUCTING 1 /* Indicates that an object is being or has
* been destroyed */
#define DESTRUCTOR_CALLED 2 /* Indicates that evaluation of destructor script for the
object has began */
#define OO_UNUSED_4 4 /* No longer used. */
#define ROOT_OBJECT 0x1000 /* Flag to say that this object is the root of
enum ObjectFlags {
OBJECT_DESTRUCTING = 1, /* Indicates that an object is being or has
* been destroyed */
DESTRUCTOR_CALLED = 2, /* Indicates that evaluation of destructor
* script for the object has began */
OO_UNUSED_4 = 4, /* No longer used. */
ROOT_OBJECT = 0x1000, /* Flag to say that this object is the root of
* the class hierarchy and should be treated
* specially during teardown. */
#define FILTER_HANDLING 0x2000 /* Flag set when the object is processing a
FILTER_HANDLING = 0x2000, /* Flag set when the object is processing a
* filter; when set, filters are *not*
* processed on the object, preventing nasty
* recursive filtering problems. */
#define USE_CLASS_CACHE 0x4000 /* Flag set to say that the object is a pure
USE_CLASS_CACHE = 0x4000, /* Flag set to say that the object is a pure
* instance of the class, and has had nothing
* added that changes the dispatch chain (i.e.
* no methods, mixins, or filters. */
#define ROOT_CLASS 0x8000 /* Flag to say that this object is the root
ROOT_CLASS = 0x8000, /* Flag to say that this object is the root
* class of classes, and should be treated
* specially during teardown (and in a few
* other spots). */
#define FORCE_UNKNOWN 0x10000 /* States that we are *really* looking up the
FORCE_UNKNOWN = 0x10000, /* States that we are *really* looking up the
* unknown method handler at that point. */
#define HAS_PRIVATE_METHODS 0x20000
HAS_PRIVATE_METHODS = 0x20000,
/* Object/class has (or had) private methods,
* and so shouldn't be cached so
* aggressively. */
#define DONT_DELETE 0x40000 /* Inhibit deletion of this object. Used
DONT_DELETE = 0x40000 /* Inhibit deletion of this object. Used
* during fundamental object type mutation to
* make sure that the object actually survives
* to the end of the operation. */
};
/*
* And the definition of a class. Note that every class also has an associated
@@ -418,17 +422,18 @@ typedef struct CallContext {
* Bits for the 'flags' field of the call chain.
*/
#define PUBLIC_METHOD 0x01 /* This is a public (exported) method. */
#define PRIVATE_METHOD 0x02 /* This is a private (class's direct instances
enum TclCallChainFlags {
PUBLIC_METHOD = 0x01, /* This is a public (exported) method. */
PRIVATE_METHOD = 0x02, /* This is a private (class's direct instances
* only) method. Supports itcl. */
#define OO_UNKNOWN_METHOD 0x04 /* This is an unknown method. */
#define CONSTRUCTOR 0x08 /* This is a constructor. */
#define DESTRUCTOR 0x10 /* This is a destructor. */
#define TRUE_PRIVATE_METHOD 0x20
/* This is a private method only accessible
OO_UNKNOWN_METHOD = 0x04, /* This is an unknown method. */
CONSTRUCTOR = 0x08, /* This is a constructor. */
DESTRUCTOR = 0x10, /* This is a destructor. */
TRUE_PRIVATE_METHOD = 0x20, /* This is a private method only accessible
* from other methods defined on this class
* or instance. [TIP #500] */
#define SCOPE_FLAGS (PUBLIC_METHOD | PRIVATE_METHOD | TRUE_PRIVATE_METHOD)
SCOPE_FLAGS = (PUBLIC_METHOD | PRIVATE_METHOD | TRUE_PRIVATE_METHOD)
};
/*
* Structure containing definition information about basic class methods.
@@ -666,7 +671,9 @@ MODULE_SCOPE void TclOOSetupVariableResolver(Tcl_Namespace *nsPtr);
* but all arguments are used multiple times and so must have no side effects.
*/
#ifdef DUPLICATE
#undef DUPLICATE /* prevent possible conflict with definition in WINAPI nb30.h */
#endif /* DUPLICATE */
#define DUPLICATE(target,source,type) \
do { \
size_t len = sizeof(type) * ((target).num=(source).num);\
+29 -11
View File
@@ -1,17 +1,35 @@
/*
* Minimal set of shared macro definitions and declarations so that multiple
* source files can make use of the parsing table in tclParse.c
* tclParse.h --
*
* This file contains the minimal set of shared macro definitions and
* declarations so that multiple source files can make use of the parsing
* table in tclParse.c.
*
* Copyright (c) 2012 by Don Porter
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#define TYPE_NORMAL 0
#define TYPE_SPACE 0x1
#define TYPE_COMMAND_END 0x2
#define TYPE_SUBS 0x4
#define TYPE_QUOTE 0x8
#define TYPE_CLOSE_PAREN 0x10
#define TYPE_CLOSE_BRACK 0x20
#define TYPE_BRACE 0x40
enum ParseTypes {
TYPE_NORMAL = 0,
TYPE_SPACE = 0x1,
TYPE_COMMAND_END = 0x2,
TYPE_SUBS = 0x4,
TYPE_QUOTE = 0x8,
TYPE_CLOSE_PAREN = 0x10,
TYPE_CLOSE_BRACK = 0x20,
TYPE_BRACE = 0x40
};
#define CHAR_TYPE(c) tclCharTypeTable[(unsigned char)(c)]
#define CHAR_TYPE(c) tclCharTypeTable[(unsigned char)(c)]
MODULE_SCOPE const char tclCharTypeTable[];
/*
* Local Variables:
* mode: c
* c-basic-offset: 4
* fill-column: 78
* End:
*/
+14 -10
View File
@@ -77,23 +77,27 @@ typedef struct FsPath {
* Flag values for FsPath->flags.
*/
#define TCLPATH_APPENDED 1
#define TCLPATH_NEEDNORM 4
enum FsPathFlags {
TCLPATH_APPENDED = 1,
TCLPATH_NEEDNORM = 4
};
/*
* Define some macros to give us convenient access to path-object specific
* fields.
*/
#define PATHOBJ(pathPtr) ((FsPath *) (TclFetchIntRep((pathPtr), &fsPathType)->twoPtrValue.ptr1))
#define PATHOBJ(pathPtr) \
((FsPath *) (TclFetchIntRep((pathPtr), &fsPathType)->twoPtrValue.ptr1))
#define SETPATHOBJ(pathPtr,fsPathPtr) \
do { \
Tcl_ObjIntRep ir; \
ir.twoPtrValue.ptr1 = (void *) (fsPathPtr); \
ir.twoPtrValue.ptr2 = NULL; \
Tcl_StoreIntRep((pathPtr), &fsPathType, &ir); \
} while (0)
#define PATHFLAGS(pathPtr) (PATHOBJ(pathPtr)->flags)
do { \
Tcl_ObjIntRep ir; \
ir.twoPtrValue.ptr1 = (void *) (fsPathPtr); \
ir.twoPtrValue.ptr2 = NULL; \
Tcl_StoreIntRep((pathPtr), &fsPathType, &ir); \
} while (0)
#define PATHFLAGS(pathPtr) \
(PATHOBJ(pathPtr)->flags)
/*
*---------------------------------------------------------------------------
+8 -7
View File
@@ -16,13 +16,14 @@
* Flag values used by Tcl_ScanObjCmd.
*/
#define SCAN_NOSKIP 0x1 /* Don't skip blanks. */
#define SCAN_SUPPRESS 0x2 /* Suppress assignment. */
#define SCAN_UNSIGNED 0x4 /* Read an unsigned value. */
#define SCAN_WIDTH 0x8 /* A width value was supplied. */
#define SCAN_LONGER 0x400 /* Asked for a wide value. */
#define SCAN_BIG 0x800 /* Asked for a bignum value. */
enum ScanFlags {
SCAN_NOSKIP = 0x1, /* Don't skip blanks. */
SCAN_SUPPRESS = 0x2, /* Suppress assignment. */
SCAN_UNSIGNED = 0x4, /* Read an unsigned value. */
SCAN_WIDTH = 0x8, /* A width value was supplied. */
SCAN_LONGER = 0x400, /* Asked for a wide value. */
SCAN_BIG = 0x800 /* Asked for a bignum value. */
};
/*
* The following structure contains the information associated with a
+17 -16
View File
@@ -68,25 +68,26 @@ typedef struct {
* TCL_TRACE_ENTER_DURING_EXEC == 4 * TCL_TRACE_ENTER_EXEC and that
* TCL_TRACE_LEAVE_DURING_EXEC == 4 * TCL_TRACE_LEAVE_EXEC.
*
* TCL_TRACE_ENTER_DURING_EXEC - Trace each command inside the command
* currently being traced, before execution.
* TCL_TRACE_LEAVE_DURING_EXEC - Trace each command inside the command
* currently being traced, after execution.
* TCL_TRACE_ANY_EXEC - OR'd combination of all EXEC flags.
* TCL_TRACE_EXEC_IN_PROGRESS - The callback function on this trace is
* currently executing. Therefore we don't let
* further traces execute.
* TCL_TRACE_EXEC_DIRECT - This execution trace is triggered directly
* by the command being traced, not because of
* an internal trace.
* The flag 'TCL_TRACE_DESTROYED' may also be used in command execution traces.
*/
#define TCL_TRACE_ENTER_DURING_EXEC 4
#define TCL_TRACE_LEAVE_DURING_EXEC 8
#define TCL_TRACE_ANY_EXEC 15
#define TCL_TRACE_EXEC_IN_PROGRESS 0x10
#define TCL_TRACE_EXEC_DIRECT 0x20
enum TraceExecutionFlags {
TCL_TRACE_ENTER_DURING_EXEC = 4,
/* Trace each command inside the command
* currently being traced, before
* execution. */
TCL_TRACE_LEAVE_DURING_EXEC = 8,
/* Trace each command inside the command
* currently being traced, after execution. */
TCL_TRACE_ANY_EXEC = 15, /* OR'd combination of all EXEC flags. */
TCL_TRACE_EXEC_IN_PROGRESS = 0x10,
/* The callback function on this trace is
* currently executing. Therefore we don't let
* further traces execute. */
TCL_TRACE_EXEC_DIRECT = 0x20/* This execution trace is triggered directly
* by the command being traced, not because of
* an internal trace. */
};
/*
* Forward declarations for functions defined in this file:
+7 -5
View File
@@ -88,11 +88,13 @@ static ProcessGlobalValue executableName = {
*/
#define COMPAT 1
#define CONVERT_NONE 0
#define CONVERT_BRACE 2
#define CONVERT_ESCAPE 4
#define CONVERT_MASK (CONVERT_BRACE | CONVERT_ESCAPE)
#define CONVERT_ANY 16
enum FormatListFlags {
CONVERT_NONE = 0,
CONVERT_BRACE = 2,
CONVERT_ESCAPE = 4,
CONVERT_MASK = (CONVERT_BRACE | CONVERT_ESCAPE),
CONVERT_ANY = 16
};
/*
* The following key is used by Tcl_PrintDouble and TclPrecTraceProc to
+12 -14
View File
@@ -130,21 +130,19 @@ typedef struct {
} ZlibChannelData;
/*
* Value bits for the flags field. Definitions are:
* ASYNC - Whether this is an asynchronous channel.
* IN_HEADER - Whether the inHeader field has been registered with
* the input compressor.
* OUT_HEADER - Whether the outputHeader field has been registered
* with the output decompressor.
* STREAM_DECOMPRESS - Signal decompress pending data.
* STREAM_DONE - Flag to signal stream end up to transform input.
* Value bits for the flags field:
*/
#define ASYNC 0x01
#define IN_HEADER 0x02
#define OUT_HEADER 0x04
#define STREAM_DECOMPRESS 0x08
#define STREAM_DONE 0x10
enum ZlibChannelFlags {
ASYNC = 0x01, /* Whether this is an asynchronous channel. */
IN_HEADER = 0x02, /* Whether the inHeader field has been
* registered with the input compressor. */
OUT_HEADER = 0x04, /* Whether the outputHeader field has been
* registered with the output decompressor. */
STREAM_DECOMPRESS = 0x08, /* Signal decompress pending data. */
STREAM_DONE = 0x10 /* Flag to signal stream end up to transform
* input. */
};
/*
* Size of buffers allocated by default, and the range it can be set to. The
@@ -214,7 +212,7 @@ static const Tcl_ChannelType zlibChannelType = {
ZlibTransformGetOption,
ZlibTransformWatch,
ZlibTransformGetHandle,
ZlibTransformClose, /* close2Proc */
ZlibTransformClose, /* close2Proc */
ZlibTransformBlockMode,
NULL, /* flushProc */
ZlibTransformEventHandler,
+11 -9
View File
@@ -32,9 +32,11 @@ extern int copyfile(const char *from, const char *to,
#else /* HAVE_COPYFILE_H */
int copyfile(const char *from, const char *to,
void *state, uint32_t flags);
#define COPYFILE_ACL (1<<0)
#define COPYFILE_XATTR (1<<2)
#define COPYFILE_NOFOLLOW_SRC (1<<18)
enum copyfileFlags {
COPYFILE_ACL = (1<<0),
COPYFILE_XATTR = (1<<2),
COPYFILE_NOFOLLOW_SRC = (1<<18)
};
#if defined(HAVE_WEAK_IMPORT) && (MAC_OS_X_VERSION_MIN_REQUIRED < 1040)
/* Support for weakly importing copyfile. */
#define WEAK_IMPORT_COPYFILE
@@ -84,11 +86,11 @@ static int SetOSTypeFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr);
static void UpdateStringOfOSType(Tcl_Obj *objPtr);
static const Tcl_ObjType tclOSTypeType = {
"osType", /* name */
NULL, /* freeIntRepProc */
NULL, /* dupIntRepProc */
UpdateStringOfOSType, /* updateStringProc */
SetOSTypeFromAny /* setFromAnyProc */
"osType", /* name */
NULL, /* freeIntRepProc */
NULL, /* dupIntRepProc */
UpdateStringOfOSType, /* updateStringProc */
SetOSTypeFromAny /* setFromAnyProc */
};
enum {
@@ -689,7 +691,7 @@ SetOSTypeFromAny(
static void
UpdateStringOfOSType(
Tcl_Obj *objPtr) /* OSType object whose string rep to
Tcl_Obj *objPtr) /* OSType object whose string rep to
* update. */
{
const int size = TCL_UTF_MAX * 4;
+9 -9
View File
@@ -173,17 +173,17 @@ static pthread_cond_t notifierCV = PTHREAD_COND_INITIALIZER;
/*
* The pollState bits:
*
* POLL_WANT is set by each thread before it waits on its condition variable.
* It is checked by the notifier before it does select.
*
* POLL_DONE is set by the notifier if it goes into select after seeing
* POLL_WANT. The idea is to ensure it tries a select with the same bits
* the initial thread had set.
*/
#define POLL_WANT 0x1
#define POLL_DONE 0x2
enum PollStateFlags {
POLL_WANT = 0x1, /* Set by each thread before it waits on its
* condition variable. It is checked by the
* notifier before it does select(). */
POLL_DONE = 0x2 /* Set by the notifier if it goes into
* select() after seeing POLL_WANT. The idea
* is to ensure it tries a select() with the
* same bits the initial thread had set. */
};
/*
* This is the thread ID of the notifier thread that does select.
+5 -3
View File
@@ -57,9 +57,11 @@
* TraverseUnixTree() calls the traverseProc()
*/
#define DOTREE_PRED 1 /* pre-order directory */
#define DOTREE_POSTD 2 /* post-order directory */
#define DOTREE_F 3 /* regular file */
enum DoTreeOps {
DOTREE_PRED = 1, /* pre-order directory */
DOTREE_POSTD = 2, /* post-order directory */
DOTREE_F = 3, /* regular file */
};
/*
* Fallback temporary file location the temporary file generation code. Can be
+14 -11
View File
@@ -87,22 +87,25 @@ struct TcpState {
* structure.
*/
#define TCP_NONBLOCKING (1<<0) /* Socket with non-blocking I/O */
#define TCP_ASYNC_CONNECT (1<<1) /* Async connect in progress. */
#define TCP_ASYNC_PENDING (1<<4) /* TcpConnect was called to
* process an async connect. This
* flag indicates that reentry is
* still pending */
#define TCP_ASYNC_FAILED (1<<5) /* An async connect finally failed */
enum TcpStateFlags {
TCP_NONBLOCKING = (1<<0), /* Socket with non-blocking I/O */
TCP_ASYNC_CONNECT = (1<<1), /* Async connect in progress. */
TCP_ASYNC_PENDING = (1<<4), /* TcpConnect was called to process an async
* connect. This flag indicates that reentry
* is still pending */
TCP_ASYNC_FAILED = (1<<5) /* An async connect finally failed */
};
/*
* These bits may be ORed together into the "testFlags" field of a TcpState
* structure.
*/
#define TCP_ASYNC_TEST_MODE (1<<0) /* Async testing activated. Do not
* automatically continue connection
* process. */
enum TcpStateTestFlags {
TCP_ASYNC_TEST_MODE = (1<<0)/* Async testing activated. Do not
* automatically continue connection
* process. */
};
/*
* The following defines the maximum length of the listen queue. This is the
@@ -1075,7 +1078,7 @@ WrapNotify(
static void
TcpWatchProc(
void *instanceData, /* The socket state. */
void *instanceData, /* The socket state. */
int mask) /* Events of interest; an OR-ed combination of
* TCL_READABLE, TCL_WRITABLE and
* TCL_EXCEPTION. */
+9 -5
View File
@@ -17,12 +17,16 @@
* State flags used in the info structures below.
*/
#define FILE_PENDING (1<<0) /* Message is pending in the queue. */
#define FILE_ASYNC (1<<1) /* Channel is non-blocking. */
#define FILE_APPEND (1<<2) /* File is in append mode. */
enum FileStateFlags {
FILE_PENDING = (1<<0), /* Message is pending in the queue. */
FILE_ASYNC = (1<<1), /* Channel is non-blocking. */
FILE_APPEND = (1<<2) /* File is in append mode. */
};
#define FILE_TYPE_SERIAL (FILE_TYPE_PIPE+1)
#define FILE_TYPE_CONSOLE (FILE_TYPE_PIPE+2)
enum SpecialFileTypes {
FILE_TYPE_SERIAL = (FILE_TYPE_PIPE+1),
FILE_TYPE_CONSOLE = (FILE_TYPE_PIPE+2)
};
/*
* The following structure contains per-instance data for a file based
+25 -20
View File
@@ -31,18 +31,22 @@ TCL_DECLARE_MUTEX(consoleMutex)
* Bit masks used in the flags field of the ConsoleInfo structure below.
*/
#define CONSOLE_PENDING (1<<0) /* Message is pending in the queue. */
#define CONSOLE_ASYNC (1<<1) /* Channel is non-blocking. */
#define CONSOLE_READ_OPS (1<<4) /* Channel supports read-related ops. */
#define CONSOLE_RESET (1<<5) /* Console mode needs to be reset. */
enum ConsoleInfoFlags {
CONSOLE_PENDING = (1<<0), /* Message is pending in the queue. */
CONSOLE_ASYNC = (1<<1), /* Channel is non-blocking. */
CONSOLE_READ_OPS = (1<<4), /* Channel supports read-related ops. */
CONSOLE_RESET = (1<<5) /* Console mode needs to be reset. */
};
/*
* Bit masks used in the sharedFlags field of the ConsoleInfo structure below.
*/
#define CONSOLE_EOF (1<<2) /* Console has reached EOF. */
#define CONSOLE_BUFFERED (1<<3) /* Data was read into a buffer by the reader
* thread. */
enum ConsoleInfoSharedFlags {
CONSOLE_EOF = (1<<2), /* Console has reached EOF. */
CONSOLE_BUFFERED = (1<<3) /* Data was read into a buffer by the reader
* thread. */
};
#define CONSOLE_BUFFER_SIZE (8*1024)
@@ -219,19 +223,19 @@ ReadConsoleBytes(
BOOL result;
/*
* If user types a Ctrl-Break or Ctrl-C, ReadConsole will return
* success with ntchars == 0 and GetLastError() will be
* ERROR_OPERATION_ABORTED. We do not want to treat this case
* as EOF so we will loop around again. If no Ctrl signal handlers
* have been established, the default signal OS handler in a separate
* thread will terminate the program. If a Ctrl signal handler
* has been established (through an extension for example), it
* will run and take whatever action it deems appropriate.
* If user types a Ctrl-Break or Ctrl-C, ReadConsole will return success
* with ntchars == 0 and GetLastError() will be ERROR_OPERATION_ABORTED.
* We do not want to treat this case as EOF so we will loop around again.
* If no Ctrl signal handlers have been established, the default signal OS
* handler in a separate thread will terminate the program. If a Ctrl
* signal handler has been established (through an extension for example),
* it will run and take whatever action it deems appropriate.
*/
do {
result = ReadConsoleW(hConsole, lpBuffer, nbytes / sizeof(WCHAR), &ntchars,
NULL);
} while (result && ntchars == 0 && GetLastError() == ERROR_OPERATION_ABORTED);
result = ReadConsoleW(hConsole, lpBuffer, nbytes / sizeof(WCHAR),
&ntchars, NULL);
} while (result && ntchars == 0 &&
GetLastError() == ERROR_OPERATION_ABORTED);
if (nbytesread != NULL) {
*nbytesread = ntchars * sizeof(WCHAR);
}
@@ -755,8 +759,9 @@ ConsoleOutputProc(
*errorCode = 0;
/* avoid blocking if pipe-thread exited */
timeout = (infoPtr->flags & CONSOLE_ASYNC) || !TclPipeThreadIsAlive(&threadInfo->TI)
|| TclInExit() || TclInThreadExit() ? 0 : INFINITE;
timeout = ((infoPtr->flags & CONSOLE_ASYNC) ||
!TclPipeThreadIsAlive(&threadInfo->TI) || TclInExit() ||
TclInThreadExit()) ? 0 : INFINITE;
if (WaitForSingleObject(threadInfo->readyEvent, timeout) == WAIT_TIMEOUT) {
/*
* The writer thread is blocked waiting for a write to complete and
+5 -3
View File
@@ -84,9 +84,11 @@ static int ddeIsServer = 0;
#define TCL_DDE_SERVICE_NAME L"TclEval"
#define TCL_DDE_EXECUTE_RESULT L"$TCLEVAL$EXECUTE$RESULT"
#define DDE_FLAG_ASYNC 1
#define DDE_FLAG_BINARY 2
#define DDE_FLAG_FORCE 4
enum TclDdeFlags {
DDE_FLAG_ASYNC = 1,
DDE_FLAG_BINARY = 2,
DDE_FLAG_FORCE = 4
};
TCL_DECLARE_MUTEX(ddeMutex)
+6 -4
View File
@@ -17,10 +17,12 @@
* TraverseWinTree() calls the traverseProc()
*/
#define DOTREE_PRED 1 /* pre-order directory */
#define DOTREE_POSTD 2 /* post-order directory */
#define DOTREE_F 3 /* regular file */
#define DOTREE_LINK 4 /* symbolic link */
enum DotreeTypes {
DOTREE_PRED = 1, /* pre-order directory */
DOTREE_POSTD = 2, /* post-order directory */
DOTREE_F = 3, /* regular file */
DOTREE_LINK = 4 /* symbolic link */
};
/*
* Callbacks for file attributes code.
+18 -14
View File
@@ -32,10 +32,12 @@ TCL_DECLARE_MUTEX(pipeMutex)
* under windows. There is special case code for the various types.
*/
#define APPL_NONE 0
#define APPL_DOS 1
#define APPL_WIN3X 2
#define APPL_WIN32 3
enum ApplicationTypes {
APPL_NONE = 0,
APPL_DOS = 1,
APPL_WIN3X = 2,
APPL_WIN32 = 3
};
/*
* The following constants and structures are used to encapsulate the state of
@@ -67,19 +69,21 @@ typedef struct ProcInfo {
static ProcInfo *procList;
/*
* Bit masks used in the flags field of the PipeInfo structure below.
*/
enum PipeInfoFlags {
/*
* Bit masks used in the flags field of the PipeInfo structure below.
*/
#define PIPE_PENDING (1<<0) /* Message is pending in the queue. */
#define PIPE_ASYNC (1<<1) /* Channel is non-blocking. */
PIPE_PENDING = (1<<0), /* Message is pending in the queue. */
PIPE_ASYNC = (1<<1), /* Channel is non-blocking. */
/*
* Bit masks used in the sharedFlags field of the PipeInfo structure below.
*/
/*
* Bit masks used in the sharedFlags field of the PipeInfo structure below.
*/
#define PIPE_EOF (1<<2) /* Pipe has reached EOF. */
#define PIPE_EXTRABYTE (1<<3) /* The reader thread has consumed one byte. */
PIPE_EOF = (1<<2), /* Pipe has reached EOF. */
PIPE_EXTRABYTE = (1<<3) /* The reader thread has consumed one byte. */
};
/*
* TODO: It appears the whole EXTRABYTE machinery is in place to support
+22 -17
View File
@@ -29,28 +29,33 @@ static int initialized = 0;
TCL_DECLARE_MUTEX(serialMutex)
/*
* Bit masks used in the flags field of the SerialInfo structure below.
*/
enum SerialInfoFlags {
/*
* Bit masks used in the flags field of the SerialInfo structure below.
*/
#define SERIAL_PENDING (1<<0) /* Message is pending in the queue. */
#define SERIAL_ASYNC (1<<1) /* Channel is non-blocking. */
SERIAL_PENDING = (1<<0), /* Message is pending in the queue. */
SERIAL_ASYNC = (1<<1), /* Channel is non-blocking. */
/*
* Bit masks used in the sharedFlags field of the SerialInfo structure below.
*/
/*
* Bit masks used in the sharedFlags field of the SerialInfo structure
* below.
*/
#define SERIAL_EOF (1<<2) /* Serial has reached EOF. */
#define SERIAL_ERROR (1<<4)
SERIAL_EOF = (1<<2), /* Serial has reached EOF. */
SERIAL_ERROR = (1<<4),
/*
* Bit masks used for noting whether to drain or discard output on close. They
* are disjoint from each other; at most one may be set at a time.
*/
/*
* Bit masks used for noting whether to drain or discard output on
* close. They are disjoint from each other; at most one may be set at a
* time.
*/
#define SERIAL_CLOSE_DRAIN (1<<6) /* Drain all output on close. */
#define SERIAL_CLOSE_DISCARD (1<<7) /* Discard all output on close. */
#define SERIAL_CLOSE_MASK (3<<6) /* Both two bits above. */
SERIAL_CLOSE_DRAIN = (1<<6),/* Drain all output on close. */
SERIAL_CLOSE_DISCARD = (1<<7),
/* Discard all output on close. */
SERIAL_CLOSE_MASK = (3<<6) /* Both two bits above. */
};
/*
* Default time to block between checking status on the serial port.
+33 -29
View File
@@ -174,26 +174,27 @@ struct TcpState {
* structure.
*/
#define TCP_NONBLOCKING (1<<0) /* Socket with non-blocking I/O */
#define TCP_ASYNC_CONNECT (1<<1) /* Async connect in progress. */
#define SOCKET_EOF (1<<2) /* A zero read happened on the
* socket. */
#define SOCKET_PENDING (1<<3) /* A message has been sent for this
* socket */
#define TCP_ASYNC_PENDING (1<<4) /* TcpConnect was called to
* process an async connect. This
* flag indicates that reentry is
* still pending */
#define TCP_ASYNC_FAILED (1<<5) /* An async connect finally failed */
enum TcpStateFlags {
TCP_NONBLOCKING = (1<<0), /* Socket with non-blocking I/O */
TCP_ASYNC_CONNECT = (1<<1), /* Async connect in progress. */
SOCKET_EOF = (1<<2), /* A zero read happened on the socket. */
SOCKET_PENDING = (1<<3), /* A message has been sent for this socket */
TCP_ASYNC_PENDING = (1<<4), /* TcpConnect was called to process an async
* connect. This flag indicates that reentry
* is still pending. */
TCP_ASYNC_FAILED = (1<<5) /* An async connect finally failed */
};
/*
* These bits may be ORed together into the "testFlags" field of a TcpState
* structure.
*/
#define TCP_ASYNC_TEST_MODE (1<<0) /* Async testing activated. Do not
* automatically continue connection
* process */
enum TcpStateTestFlags {
TCP_ASYNC_TEST_MODE = (1<<0)/* Async testing activated. Do not
* automatically continue connection
* process */
};
/*
* The following structure is what is added to the Tcl event queue when a
@@ -241,8 +242,7 @@ static WNDCLASSW windowClass;
* Static routines for this file:
*/
static int TcpConnect(Tcl_Interp *interp,
TcpState *state);
static int TcpConnect(Tcl_Interp *interp, TcpState *state);
static void InitSockets(void);
static TcpState * NewSocketInfo(SOCKET socket);
static void SocketExitHandler(ClientData clientData);
@@ -317,6 +317,11 @@ static ProcessGlobalValue hostName =
SendMessageW((tsdPtr)->hwnd, SOCKET_SELECT, \
(WPARAM) (message), (LPARAM) (payload))
/*
* The name of a variable that may be changed to suppress reverse DNS lookups.
*/
#define SUPPRESS_RDNS_VAR "::tcl::unsupported::noReverseDNS"
/*
* Address print debug functions
@@ -372,7 +377,8 @@ InitializeHostName(
Tcl_DString ds;
Tcl_DStringInit(&ds);
if (GetComputerNameExW(ComputerNamePhysicalDnsFullyQualified, wbuf, &length) != 0) {
if (GetComputerNameExW(ComputerNamePhysicalDnsFullyQualified, wbuf,
&length) != 0) {
/*
* Convert string from native to UTF then change to lowercase.
*/
@@ -1153,11 +1159,13 @@ TcpClose2Proc(
* TCL_WRITABLE so this should never be called for a server socket.
*/
if ((flags & TCL_CLOSE_READ) && (shutdown(statePtr->sockets->fd, SD_RECEIVE) == SOCKET_ERROR)) {
if ((flags & TCL_CLOSE_READ) &&
(shutdown(statePtr->sockets->fd, SD_RECEIVE) == SOCKET_ERROR)) {
Tcl_WinConvertError((DWORD) WSAGetLastError());
readError = Tcl_GetErrno();
}
if ((flags & TCL_CLOSE_WRITE) && (shutdown(statePtr->sockets->fd, SD_SEND) == SOCKET_ERROR)) {
if ((flags & TCL_CLOSE_WRITE) &&
(shutdown(statePtr->sockets->fd, SD_SEND) == SOCKET_ERROR)) {
Tcl_WinConvertError((DWORD) WSAGetLastError());
writeError = Tcl_GetErrno();
}
@@ -1300,7 +1308,6 @@ TcpGetOptionProc(
SOCKET sock;
size_t len = 0;
int reverseDNS = 0;
#define SUPPRESS_RDNS_VAR "::tcl::unsupported::noReverseDNS"
/*
* Check that WinSock is initialized; do not call it if not, to prevent
@@ -1383,8 +1390,7 @@ TcpGetOptionProc(
if (err) {
Tcl_WinConvertError(err);
Tcl_DStringAppend(dsPtr, Tcl_ErrnoMsg(Tcl_GetErrno()),
-1);
Tcl_DStringAppend(dsPtr, Tcl_ErrnoMsg(Tcl_GetErrno()), -1);
}
}
}
@@ -2444,9 +2450,9 @@ TcpAccept(
if (statePtr->acceptProc != NULL) {
getnameinfo(&(addr.sa), len, host, sizeof(host), port, sizeof(port),
NI_NUMERICHOST|NI_NUMERICSERV);
NI_NUMERICHOST | NI_NUMERICSERV);
statePtr->acceptProc(statePtr->acceptProcData, newInfoPtr->channel,
host, atoi(port));
host, atoi(port));
}
}
@@ -3011,8 +3017,7 @@ AddSocketInfoFd(
fds->statePtr = statePtr;
fds->next = NULL;
}
/*
*----------------------------------------------------------------------
*
@@ -3067,10 +3072,9 @@ NewSocketInfo(SOCKET socket)
static int
WaitForSocketEvent(
TcpState *statePtr, /* Information about this socket. */
TcpState *statePtr, /* Information about this socket. */
int events, /* Events to look for. May be one of
* FD_READ or FD_WRITE.
*/
* FD_READ or FD_WRITE. */
int *errorCodePtr) /* Where to store errors? */
{
int result = 1;
+19 -23
View File
@@ -79,10 +79,10 @@ static CRITICAL_SECTION joinLock;
#if TCL_THREADS
typedef struct ThreadSpecificData {
HANDLE condEvent; /* Per-thread condition event */
HANDLE condEvent; /* Per-thread condition event */
struct ThreadSpecificData *nextPtr; /* Queue pointers */
struct ThreadSpecificData *prevPtr;
int flags; /* See flags below */
int flags; /* See flags below */
} ThreadSpecificData;
static Tcl_ThreadDataKey dataKey;
@@ -90,15 +90,14 @@ static Tcl_ThreadDataKey dataKey;
/*
* State bits for the thread.
* WIN_THREAD_UNINIT Uninitialized. Must be zero because of the way
* ThreadSpecificData is created.
* WIN_THREAD_RUNNING Running, not waiting.
* WIN_THREAD_BLOCKED Waiting, or trying to wait.
*/
#define WIN_THREAD_UNINIT 0x0
#define WIN_THREAD_RUNNING 0x1
#define WIN_THREAD_BLOCKED 0x2
enum ThreadStateBits {
WIN_THREAD_UNINIT = 0x0, /* Uninitialized. Must be zero because of the
* way ThreadSpecificData is created. */
WIN_THREAD_RUNNING = 0x1, /* Running, not waiting. */
WIN_THREAD_BLOCKED = 0x2 /* Waiting, or trying to wait. */
};
/*
* The per condition queue pointers and the Mutex used to serialize access to
@@ -108,8 +107,8 @@ static Tcl_ThreadDataKey dataKey;
typedef struct {
CRITICAL_SECTION condLock; /* Lock to serialize queuing on the
* condition. */
struct ThreadSpecificData *firstPtr; /* Queue pointers */
struct ThreadSpecificData *lastPtr;
ThreadSpecificData *firstPtr; /* Queue pointers */
ThreadSpecificData *lastPtr;
} WinCondition;
/*
@@ -131,9 +130,10 @@ typedef struct {
*/
typedef struct {
LPTHREAD_START_ROUTINE lpStartAddress; /* Original startup routine */
LPVOID lpParameter; /* Original startup data */
unsigned int fpControl; /* Floating point control word from the
LPTHREAD_START_ROUTINE lpStartAddress;
/* Original startup routine */
LPVOID lpParameter; /* Original startup data */
unsigned int fpControl; /* Floating point control word from the
* main thread */
} WinThread;
@@ -208,7 +208,7 @@ TclpThreadCreate(
int flags) /* Flags controlling behaviour of the new
* thread. */
{
WinThread *winThreadPtr; /* Per-thread startup info */
WinThread *winThreadPtr; /* Per-thread startup info */
HANDLE tHandle;
winThreadPtr = (WinThread *)ckalloc(sizeof(WinThread));
@@ -218,9 +218,9 @@ TclpThreadCreate(
EnterCriticalSection(&joinLock);
*idPtr = 0; /* must initialize as Tcl_Thread is a pointer and
* on WIN64 sizeof void* != sizeof unsigned
*/
*idPtr = 0; /* must initialize as Tcl_Thread is a pointer
* and on WIN64 sizeof(void*) !=
* sizeof(unsigned) */
#if defined(_MSC_VER) || defined(__MSVCRT__)
tHandle = (HANDLE) _beginthreadex(NULL, (unsigned) stackSize,
@@ -660,7 +660,7 @@ void
Tcl_ConditionWait(
Tcl_Condition *condPtr, /* Really (WinCondition **) */
Tcl_Mutex *mutexPtr, /* Really (CRITICAL_SECTION **) */
const Tcl_Time *timePtr) /* Timeout on waiting period */
const Tcl_Time *timePtr) /* Timeout on waiting period */
{
WinCondition *winCondPtr; /* Per-condition queue head */
CRITICAL_SECTION *csPtr; /* Caller's Mutex, after casting */
@@ -927,9 +927,6 @@ TclpFinalizeCondition(
}
}
/*
* Additions by AOL for specialized thread memory allocator.
*/
@@ -1031,7 +1028,6 @@ TclpFreeAllocCache(
}
#endif /* USE_THREAD_ALLOC */
void *
TclpThreadCreateKey(void)
{