aboutsummaryrefslogtreecommitdiff
path: root/jim.h
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2011-04-12 09:45:51 +1000
committerSteve Bennett <steveb@workware.net.au>2011-06-01 12:05:19 +1000
commit229239b9443c366f90ca251ede04bfa04ae16cc2 (patch)
tree6df75c043afaa8fd1568c7c2ff7912c5b5b84999 /jim.h
parent14eeca4e8c1a62e68be012cacbad112c927df34b (diff)
downloadjimtcl-229239b9443c366f90ca251ede04bfa04ae16cc2.zip
jimtcl-229239b9443c366f90ca251ede04bfa04ae16cc2.tar.gz
jimtcl-229239b9443c366f90ca251ede04bfa04ae16cc2.tar.bz2
Use a union for Jim_Cmd fields
There is no overlap between proc command fields and native command fields, so overlap them with a union. Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'jim.h')
-rw-r--r--jim.h33
1 files changed, 21 insertions, 12 deletions
diff --git a/jim.h b/jim.h
index 77b96ca..e968c89 100644
--- a/jim.h
+++ b/jim.h
@@ -465,7 +465,7 @@ typedef struct Jim_Var {
Jim_Obj *objPtr;
struct Jim_CallFrame *linkFramePtr;
} Jim_Var;
-
+
/* The cmd structure. */
typedef int (*Jim_CmdProc)(struct Jim_Interp *interp, int argc,
Jim_Obj *const *argv);
@@ -476,17 +476,26 @@ typedef void (*Jim_DelCmdProc)(struct Jim_Interp *interp, void *privData);
* two objects referenced by arglistObjPtr and bodyoObjPtr. */
typedef struct Jim_Cmd {
int inUse; /* Reference count */
- Jim_CmdProc cmdProc; /* Not-NULL for a C command. */
- void *privData; /* Only used for C commands. */
- struct Jim_Cmd *prevCmd; /* If any, and this command created "local" */
- Jim_DelCmdProc delProc; /* Called when the command is deleted if != NULL */
- Jim_Obj *argListObjPtr;
- Jim_Obj *bodyObjPtr;
- Jim_HashTable *staticVars; /* Static vars hash table. NULL if no statics. */
- int leftArity; /* Required args assigned from the left */
- int optionalArgs; /* Number of optional args (default values) */
- int rightArity; /* Required args assigned from the right */
- int args; /* True if 'args' specified */
+ int isproc; /* Is this a procedure? */
+ union {
+ struct {
+ /* native (C) command */
+ Jim_CmdProc cmdProc; /* The command implementation */
+ Jim_DelCmdProc delProc; /* Called when the command is deleted if != NULL */
+ void *privData; /* command-private data available via Jim_CmdPrivData() */
+ } native;
+ struct {
+ /* Tcl procedure */
+ Jim_Obj *argListObjPtr;
+ Jim_Obj *bodyObjPtr;
+ Jim_HashTable *staticVars; /* Static vars hash table. NULL if no statics. */
+ int leftArity; /* Required args assigned from the left */
+ int optionalArgs; /* Number of optional args (default values) */
+ int rightArity; /* Required args assigned from the right */
+ int args; /* True if 'args' specified */
+ struct Jim_Cmd *prevCmd; /* Previous command defn if proc created 'local' */
+ } proc;
+ } u;
} Jim_Cmd;
/* Pseudo Random Number Generator State structure */