aboutsummaryrefslogtreecommitdiff
path: root/jim.h
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2011-06-16 10:27:27 +1000
committerSteve Bennett <steveb@workware.net.au>2011-07-08 05:41:58 +1000
commit4a5e4965e2c208375a77d40b831a07897f80ee50 (patch)
tree8d9ea6efb78a2a884ac347b59b3d48740eda0349 /jim.h
parente3639458879e363cf012a1f7a00fdfab92f0f7ce (diff)
downloadjimtcl-4a5e4965e2c208375a77d40b831a07897f80ee50.zip
jimtcl-4a5e4965e2c208375a77d40b831a07897f80ee50.tar.gz
jimtcl-4a5e4965e2c208375a77d40b831a07897f80ee50.tar.bz2
Better proc optional arg handling
Allows args and optional parameters in any location, in addition to being smaller and faster. Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'jim.h')
-rw-r--r--jim.h20
1 files changed, 13 insertions, 7 deletions
diff --git a/jim.h b/jim.h
index 9f1520b..224f50e 100644
--- a/jim.h
+++ b/jim.h
@@ -466,6 +466,8 @@ typedef int (*Jim_CmdProc)(struct Jim_Interp *interp, int argc,
Jim_Obj *const *argv);
typedef void (*Jim_DelCmdProc)(struct Jim_Interp *interp, void *privData);
+
+
/* A command is implemented in C if funcPtr is != NULL, otherwise
* it's a Tcl procedure with the arglist and body represented by the
* two objects referenced by arglistObjPtr and bodyoObjPtr. */
@@ -483,13 +485,17 @@ typedef struct Jim_Cmd {
/* 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' */
- int upcall; /* True if proc is currently in upcall */
+ Jim_HashTable *staticVars; /* Static vars hash table. NULL if no statics. */
+ struct Jim_Cmd *prevCmd; /* Previous command defn if proc created 'local' */
+ int argListLen; /* Length of argListObjPtr */
+ int reqArity; /* Number of required parameters */
+ int optArity; /* Number of optional parameters */
+ int argsPos; /* Position of 'args', if specified, or -1 */
+ int upcall; /* True if proc is currently in upcall */
+ struct Jim_ProcArg {
+ Jim_Obj *nameObjPtr; /* Name of this arg */
+ Jim_Obj *defaultObjPtr; /* Default value, (or rename for $args) */
+ } *arglist;
} proc;
} u;
} Jim_Cmd;