Index: ChangeLog =================================================================== diff -u -rc990d14157d8434cd5b1ee5f45aa43f82cb911b5 -r200940690a99e5cd234e83fe6acc234477bf879c --- ChangeLog (.../ChangeLog) (revision c990d14157d8434cd5b1ee5f45aa43f82cb911b5) +++ ChangeLog (.../ChangeLog) (revision 200940690a99e5cd234e83fe6acc234477bf879c) @@ -62,6 +62,11 @@ Meta C -superclass O -parameter {a {b -default ""} {c -default 1}} C c1 ;# c1 has no no default value for "a", before it had ====== +2009-06-30 + - all object methods generated + - compiles, but must be debugged + - from 15356 generic/xotcl.c => 13884 + 2009-06-29 - !!! removed obsolete features * ability to specify nonpos args and pos args as different arguments Index: generic/gentclAPI.tcl =================================================================== diff -u -r9f046615c4f92e3d10286103e1ee67c8b6882f14 -r200940690a99e5cd234e83fe6acc234477bf879c --- generic/gentclAPI.tcl (.../gentclAPI.tcl) (revision 9f046615c4f92e3d10286103e1ee67c8b6882f14) +++ generic/gentclAPI.tcl (.../gentclAPI.tcl) (revision 200940690a99e5cd234e83fe6acc234477bf879c) @@ -23,9 +23,31 @@ upvar $cDefsVar cDefs $ifDefVar ifDef $arglistVar arglist $preVar pre $postVar post \ $introVar intro set c [list] - set a [list] set i 0 set pre ""; set post "" + set intro " parseContext pc;\n" + + switch $clientData { + class { + set a [list cl] + set if [list "XOTclClass *cl"] + append intro \ + " XOTclClass *cl = XOTclObjectToClass(clientData);" \n \ + { if (!cl) return XOTclObjErrType(interp, objv[0], "Class");} + } + object { + set a [list obj] + set if [list "XOTclObject *obj"] + append intro \ + " XOTclObject *obj = (XOTclObject *)clientData;" \n \ + { if (!obj) return XOTclObjErrType(interp, objv[0], "Object");} + } + "" { + set a [list] + set if [list] + array set cd {arglist "" ifDefs ""} + } + } foreach argDefinition $argDefinitions { array set "" $argDefinition set ifSet 0 @@ -90,21 +112,9 @@ lappend a $calledArg incr i } - set intro " parseContext pc;\n" - switch $clientData { - class { - array set cd {arglist "cl, " ifDefs "XOTclClass *cl, "} - append intro \ - " XOTclClass *cl = XOTclObjectToClass(clientData);" \n \ - { if (!cl) return XOTclObjErrType(interp, objv[0], "Class");} - } - "" { - array set cd {arglist "" ifDefs ""} - } - } - set ifDef $cd(ifDefs)[join $if ", "] - set cDefs [join $c "\n "] - set arglist $cd(arglist)[join $a ", "] + set ifDef [join $if ", "] + set cDefs [join $c "\n "] + set arglist [join $a ", "] } @@ -202,8 +212,119 @@ proc classMethod {methodName implementation argDefinitions} { methodDefinition $methodName classMethod $implementation $argDefinitions } +proc objectMethod {methodName implementation argDefinitions} { + methodDefinition $methodName objectMethod $implementation $argDefinitions +} +# +# object methods +# +objectMethod autoname XOTclOAutonameMethod { + {-argName "-instance"} + {-argName "-reset"} + {-argName "name" -required 1 -type tclobj} +} +objectMethod check XOTclOCheckMethod { + {-argName "flag" -required 1 -type tclobj} +} +objectMethod cleanup XOTclOCleanupMethod { +} +objectMethod configure XOTclOConfigureMethod { + {-argName "args" -type allargs} +} +objectMethod destroy XOTclODestroyMethod { +} +objectMethod exists XOTclOExistsMethod { + {-argName "var" -required 1} +} +objectMethod filterguard XOTclOFilterGuardMethod { + {-argName "filter" -required 1} + {-argName "guard" -required 1 -type tclobj} +} +objectMethod filtersearch XOTclOFilterSearchMethod { + {-argName "filter" -required 1} +} +objectMethod instvar XOTclOInstVarMethod { + {-argName "args" -type allargs} +} +objectMethod invar XOTclOInvariantsMethod { + {-argName "invariantlist" -required 1 -type tclobj} +} +objectMethod isclass XOTclOIsClassMethod { + {-argName "class" -type tclobj} +} +objectMethod ismetaclass XOTclOIsMetaClassMethod { + {-argName "metaclass" -type tclobj} +} +objectMethod ismixin XOTclOIsMixinMethod { + {-argName "class" -required 1 -type tclobj} +} +objectMethod isobject XOTclOIsObjectMethod { + {-argName "object" -required 1 -type tclobj} +} +objectMethod istype XOTclOIsTypeMethod { + {-argName "class" -required 1 -type tclobj} +} +objectMethod mixinguard XOTclOMixinGuardMethod { + {-argName "mixin" -required 1} + {-argName "guard" -required 1 -type tclobj} +} +objectMethod __next XOTclONextMethod { + {-argName "args" -type allargs} +} +objectMethod noinit XOTclONoinitMethod { +} +objectMethod parametercmd XOTclOParametercmdMethod { + {-argName "name" -required 1} +} +objectMethod proc XOTclOProcMethod { + {-argName "name" -required 1 -type tclobj} + {-argName "args" -required 1 -type tclobj} + {-argName "body" -required 1 -type tclobj} + {-argName "precondition" -type tclobj} + {-argName "postcondition" -type tclobj} +} +objectMethod procsearch XOTclOProcSearchMethod { + {-argName "name" -required 1} +} + +objectMethod requireNamespace XOTclORequireNamespaceMethod { +} +# "set" needed? +objectMethod set XOTclOSetMethod { + {-argName "var" -required 1 -type tclobj} + {-argName "value" -type tclobj} +} +objectMethod setvalues XOTclOSetvaluesMethod { + {-argName "args" -type allargs} +} +objectMethod forward XOTclOForwardMethod { + {-argName "method" -required 1 -type tclobj} + {-argName "-default" -nrargs 1 -type tclobj} + {-argName "-earlybinding"} + {-argName "-methodprefix" -nrargs 1 -type tclobj} + {-argName "-objscope"} + {-argName "-onerror" -nrargs 1 -type tclobj} + {-argName "-verbose"} + {-argName "target" -type tclobj} + {-argName "args" -type args} +} +objectMethod uplevel XOTclOUplevelMethod { + {-argName "args" -type allargs} +} +objectMethod upvar XOTclOUpvarMethod { + {-argName "args" -type allargs} +} +objectMethod volatile XOTclOVolatileMethod { +} +objectMethod vwait XOTclOVwaitMethod { + {-argName "varname" -required 1} +} + + + + # # class methods # @@ -212,7 +333,7 @@ } classMethod create XOTclCCreateMethod { {-argName "name" -required 1} - {-argName "args" -required 1 -type allargs} + {-argName "args" -type allargs} } classMethod dealloc XOTclCDeallocMethod { {-argName "object" -required 1 -type tclobj} @@ -232,7 +353,7 @@ {-argName "mixin" -required 1} {-argName "guard" -required 1 -type tclobj} } -classMethod instparametercmd XOTclCInstParameterCmdMethod { +classMethod instparametercmd XOTclCInstParametercmdMethod { {-argName "name" -required 1} } classMethod instproc XOTclCInstProcMethod { @@ -263,11 +384,11 @@ # todo -protected for XOTclCInstForwardMethod classMethod recreate XOTclCRecreateMethod { {-argName "name" -required 1 -type tclobj} - {-argName "args" -required 1 -type allargs} + {-argName "args" -type allargs} } classMethod unknown XOTclCUnknownMethod { {-argName "name" -required 1} - {-argName "args" -required 1 -type allargs} + {-argName "args" -type allargs} } # @@ -326,7 +447,7 @@ infoObjectMethod forward XOTclObjInfoForwardMethod { {-argName "object" -required 1 -type object} {-argName "-definition"} - {-argName "methodName" -required 1} + {-argName "pattern"} } infoObjectMethod hasnamespace XOTclObjInfoHasnamespaceMethod { {-argName "object" -required 1 -type object} @@ -440,7 +561,7 @@ infoClassMethod instforward XOTclClassInfoInstforwardMethod { {-argName "class" -required 1 -type class} {-argName "-definition"} - {-argName "methodName" -required 1} + {-argName "pattern"} } infoClassMethod instinvar XOTclClassInfoInstinvarMethod { @@ -517,4 +638,5 @@ } -genifds \ No newline at end of file +genifds +puts stderr "[array size ::definitions] parsing stubs generated" Index: generic/tclAPI.h =================================================================== diff -u -rc990d14157d8434cd5b1ee5f45aa43f82cb911b5 -r200940690a99e5cd234e83fe6acc234477bf879c --- generic/tclAPI.h (.../tclAPI.h) (revision c990d14157d8434cd5b1ee5f45aa43f82cb911b5) +++ generic/tclAPI.h (.../tclAPI.h) (revision 200940690a99e5cd234e83fe6acc234477bf879c) @@ -19,7 +19,7 @@ static int XOTclCInstFilterGuardMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); static int XOTclCInstForwardMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); static int XOTclCInstMixinGuardMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); -static int XOTclCInstParameterCmdMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); +static int XOTclCInstParametercmdMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); static int XOTclCInstProcMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); static int XOTclCInstProcMethodCStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); static int XOTclCInvariantsMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); @@ -73,6 +73,35 @@ static int XOTclObjInfoProcsMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); static int XOTclObjInfoSlotObjectsMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); static int XOTclObjInfoVarsMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); +static int XOTclOAutonameMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); +static int XOTclOCheckMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); +static int XOTclOCleanupMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); +static int XOTclOConfigureMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); +static int XOTclODestroyMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); +static int XOTclOExistsMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); +static int XOTclOFilterGuardMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); +static int XOTclOFilterSearchMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); +static int XOTclOForwardMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); +static int XOTclOInstVarMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); +static int XOTclOInvariantsMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); +static int XOTclOIsClassMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); +static int XOTclOIsMetaClassMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); +static int XOTclOIsMixinMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); +static int XOTclOIsObjectMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); +static int XOTclOIsTypeMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); +static int XOTclOMixinGuardMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); +static int XOTclONextMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); +static int XOTclONoinitMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); +static int XOTclOParametercmdMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); +static int XOTclOProcMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); +static int XOTclOProcSearchMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); +static int XOTclORequireNamespaceMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); +static int XOTclOSetMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); +static int XOTclOSetvaluesMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); +static int XOTclOUplevelMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); +static int XOTclOUpvarMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); +static int XOTclOVolatileMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); +static int XOTclOVwaitMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); static int XOTclCheckBooleanArgs(Tcl_Interp *interp, char *name, Tcl_Obj *value); static int XOTclCheckRequiredArgs(Tcl_Interp *interp, char *name, Tcl_Obj *value); @@ -82,7 +111,7 @@ static int XOTclCInstFilterGuardMethod(Tcl_Interp *interp, XOTclClass *cl, char *filter, Tcl_Obj *guard); static int XOTclCInstForwardMethod(Tcl_Interp *interp, XOTclClass *cl, Tcl_Obj *method, Tcl_Obj *withDefault, int withEarlybinding, Tcl_Obj *withMethodprefix, int withObjscope, Tcl_Obj *withOnerror, int withVerbose, Tcl_Obj *target, int nobjc, Tcl_Obj *CONST nobjv[]); static int XOTclCInstMixinGuardMethod(Tcl_Interp *interp, XOTclClass *cl, char *mixin, Tcl_Obj *guard); -static int XOTclCInstParameterCmdMethod(Tcl_Interp *interp, XOTclClass *cl, char *name); +static int XOTclCInstParametercmdMethod(Tcl_Interp *interp, XOTclClass *cl, char *name); static int XOTclCInstProcMethod(Tcl_Interp *interp, XOTclClass *cl, Tcl_Obj *name, Tcl_Obj *args, Tcl_Obj *body, Tcl_Obj *precondition, Tcl_Obj *postcondition); static int XOTclCInstProcMethodC(Tcl_Interp *interp, XOTclClass *cl, Tcl_Obj *name, Tcl_Obj *args, Tcl_Obj *body, Tcl_Obj *precondition, Tcl_Obj *postcondition); static int XOTclCInvariantsMethod(Tcl_Interp *interp, XOTclClass *cl, Tcl_Obj *invariantlist); @@ -97,7 +126,7 @@ static int XOTclClassInfoInstdefaultMethod(Tcl_Interp *interp, XOTclClass *class, char *methodName, char *arg, Tcl_Obj *var); static int XOTclClassInfoInstfilterMethod(Tcl_Interp *interp, XOTclClass *class, int withGuards, char *pattern); static int XOTclClassInfoInstfilterguardMethod(Tcl_Interp *interp, XOTclClass *class, char *filter); -static int XOTclClassInfoInstforwardMethod(Tcl_Interp *interp, XOTclClass *class, int withDefinition, char *methodName); +static int XOTclClassInfoInstforwardMethod(Tcl_Interp *interp, XOTclClass *class, int withDefinition, char *pattern); static int XOTclClassInfoInstinvarMethod(Tcl_Interp *interp, XOTclClass *class); static int XOTclClassInfoInstmixinMethod(Tcl_Interp *interp, XOTclClass *class, int withClosure, int withGuards, char *patternString, XOTclObject *patternObj); static int XOTclClassInfoInstmixinguardMethod(Tcl_Interp *interp, XOTclClass *class, char *mixin); @@ -121,7 +150,7 @@ static int XOTclObjInfoDefaultMethod(Tcl_Interp *interp, XOTclObject *object, char *methodName, char *arg, Tcl_Obj *var); static int XOTclObjInfoFilterMethod(Tcl_Interp *interp, XOTclObject *object, int withOrder, int withGuards, char *pattern); static int XOTclObjInfoFilterguardMethod(Tcl_Interp *interp, XOTclObject *object, char *filter); -static int XOTclObjInfoForwardMethod(Tcl_Interp *interp, XOTclObject *object, int withDefinition, char *methodName); +static int XOTclObjInfoForwardMethod(Tcl_Interp *interp, XOTclObject *object, int withDefinition, char *pattern); static int XOTclObjInfoHasnamespaceMethod(Tcl_Interp *interp, XOTclObject *object); static int XOTclObjInfoInvarMethod(Tcl_Interp *interp, XOTclObject *object); static int XOTclObjInfoMethodsMethod(Tcl_Interp *interp, XOTclObject *object, int withNoprocs, int withNocmds, int withNomixins, int withIncontext, char *pattern); @@ -136,6 +165,35 @@ static int XOTclObjInfoProcsMethod(Tcl_Interp *interp, XOTclObject *object, char *pattern); static int XOTclObjInfoSlotObjectsMethod(Tcl_Interp *interp, XOTclObject *object, char *pattern); static int XOTclObjInfoVarsMethod(Tcl_Interp *interp, XOTclObject *object, char *pattern); +static int XOTclOAutonameMethod(Tcl_Interp *interp, XOTclObject *obj, int withInstance, int withReset, Tcl_Obj *name); +static int XOTclOCheckMethod(Tcl_Interp *interp, XOTclObject *obj, Tcl_Obj *flag); +static int XOTclOCleanupMethod(Tcl_Interp *interp, XOTclObject *obj); +static int XOTclOConfigureMethod(Tcl_Interp *interp, XOTclObject *obj, int objc, Tcl_Obj *CONST objv[]); +static int XOTclODestroyMethod(Tcl_Interp *interp, XOTclObject *obj); +static int XOTclOExistsMethod(Tcl_Interp *interp, XOTclObject *obj, char *var); +static int XOTclOFilterGuardMethod(Tcl_Interp *interp, XOTclObject *obj, char *filter, Tcl_Obj *guard); +static int XOTclOFilterSearchMethod(Tcl_Interp *interp, XOTclObject *obj, char *filter); +static int XOTclOForwardMethod(Tcl_Interp *interp, XOTclObject *obj, Tcl_Obj *method, Tcl_Obj *withDefault, int withEarlybinding, Tcl_Obj *withMethodprefix, int withObjscope, Tcl_Obj *withOnerror, int withVerbose, Tcl_Obj *target, int nobjc, Tcl_Obj *CONST nobjv[]); +static int XOTclOInstVarMethod(Tcl_Interp *interp, XOTclObject *obj, int objc, Tcl_Obj *CONST objv[]); +static int XOTclOInvariantsMethod(Tcl_Interp *interp, XOTclObject *obj, Tcl_Obj *invariantlist); +static int XOTclOIsClassMethod(Tcl_Interp *interp, XOTclObject *obj, Tcl_Obj *class); +static int XOTclOIsMetaClassMethod(Tcl_Interp *interp, XOTclObject *obj, Tcl_Obj *metaclass); +static int XOTclOIsMixinMethod(Tcl_Interp *interp, XOTclObject *obj, Tcl_Obj *class); +static int XOTclOIsObjectMethod(Tcl_Interp *interp, XOTclObject *obj, Tcl_Obj *object); +static int XOTclOIsTypeMethod(Tcl_Interp *interp, XOTclObject *obj, Tcl_Obj *class); +static int XOTclOMixinGuardMethod(Tcl_Interp *interp, XOTclObject *obj, char *mixin, Tcl_Obj *guard); +static int XOTclONextMethod(Tcl_Interp *interp, XOTclObject *obj, int objc, Tcl_Obj *CONST objv[]); +static int XOTclONoinitMethod(Tcl_Interp *interp, XOTclObject *obj); +static int XOTclOParametercmdMethod(Tcl_Interp *interp, XOTclObject *obj, char *name); +static int XOTclOProcMethod(Tcl_Interp *interp, XOTclObject *obj, Tcl_Obj *name, Tcl_Obj *args, Tcl_Obj *body, Tcl_Obj *precondition, Tcl_Obj *postcondition); +static int XOTclOProcSearchMethod(Tcl_Interp *interp, XOTclObject *obj, char *name); +static int XOTclORequireNamespaceMethod(Tcl_Interp *interp, XOTclObject *obj); +static int XOTclOSetMethod(Tcl_Interp *interp, XOTclObject *obj, Tcl_Obj *var, Tcl_Obj *value); +static int XOTclOSetvaluesMethod(Tcl_Interp *interp, XOTclObject *obj, int objc, Tcl_Obj *CONST objv[]); +static int XOTclOUplevelMethod(Tcl_Interp *interp, XOTclObject *obj, int objc, Tcl_Obj *CONST objv[]); +static int XOTclOUpvarMethod(Tcl_Interp *interp, XOTclObject *obj, int objc, Tcl_Obj *CONST objv[]); +static int XOTclOVolatileMethod(Tcl_Interp *interp, XOTclObject *obj); +static int XOTclOVwaitMethod(Tcl_Interp *interp, XOTclObject *obj, char *varname); enum { XOTclCheckBooleanArgsIdx, @@ -146,7 +204,7 @@ XOTclCInstFilterGuardMethodIdx, XOTclCInstForwardMethodIdx, XOTclCInstMixinGuardMethodIdx, - XOTclCInstParameterCmdMethodIdx, + XOTclCInstParametercmdMethodIdx, XOTclCInstProcMethodIdx, XOTclCInstProcMethodCIdx, XOTclCInvariantsMethodIdx, @@ -199,7 +257,36 @@ XOTclObjInfoPrecedenceMethodIdx, XOTclObjInfoProcsMethodIdx, XOTclObjInfoSlotObjectsMethodIdx, - XOTclObjInfoVarsMethodIdx + XOTclObjInfoVarsMethodIdx, + XOTclOAutonameMethodIdx, + XOTclOCheckMethodIdx, + XOTclOCleanupMethodIdx, + XOTclOConfigureMethodIdx, + XOTclODestroyMethodIdx, + XOTclOExistsMethodIdx, + XOTclOFilterGuardMethodIdx, + XOTclOFilterSearchMethodIdx, + XOTclOForwardMethodIdx, + XOTclOInstVarMethodIdx, + XOTclOInvariantsMethodIdx, + XOTclOIsClassMethodIdx, + XOTclOIsMetaClassMethodIdx, + XOTclOIsMixinMethodIdx, + XOTclOIsObjectMethodIdx, + XOTclOIsTypeMethodIdx, + XOTclOMixinGuardMethodIdx, + XOTclONextMethodIdx, + XOTclONoinitMethodIdx, + XOTclOParametercmdMethodIdx, + XOTclOProcMethodIdx, + XOTclOProcSearchMethodIdx, + XOTclORequireNamespaceMethodIdx, + XOTclOSetMethodIdx, + XOTclOSetvaluesMethodIdx, + XOTclOUplevelMethodIdx, + XOTclOUpvarMethodIdx, + XOTclOVolatileMethodIdx, + XOTclOVwaitMethodIdx } XOTclMethods; @@ -333,16 +420,16 @@ } static int -XOTclCInstParameterCmdMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { +XOTclCInstParametercmdMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { parseContext pc; XOTclClass *cl = XOTclObjectToClass(clientData); if (!cl) return XOTclObjErrType(interp, objv[0], "Class"); - if (parse2(interp, objc, objv, XOTclCInstParameterCmdMethodIdx, &pc) != TCL_OK) { + if (parse2(interp, objc, objv, XOTclCInstParametercmdMethodIdx, &pc) != TCL_OK) { return TCL_ERROR; } else { char * name = (char *)pc.clientData[0]; - return XOTclCInstParameterCmdMethod(interp, cl, name); + return XOTclCInstParametercmdMethod(interp, cl, name); } } @@ -584,9 +671,9 @@ } else { XOTclClass * class = (XOTclClass *)pc.clientData[0]; int withDefinition = (int )pc.clientData[1]; - char * methodName = (char *)pc.clientData[2]; + char * pattern = (char *)pc.clientData[2]; - return XOTclClassInfoInstforwardMethod(interp, class, withDefinition, methodName); + return XOTclClassInfoInstforwardMethod(interp, class, withDefinition, pattern); } } @@ -974,9 +1061,9 @@ } else { XOTclObject * object = (XOTclObject *)pc.clientData[0]; int withDefinition = (int )pc.clientData[1]; - char * methodName = (char *)pc.clientData[2]; + char * pattern = (char *)pc.clientData[2]; - return XOTclObjInfoForwardMethod(interp, object, withDefinition, methodName); + return XOTclObjInfoForwardMethod(interp, object, withDefinition, pattern); } } @@ -1201,6 +1288,457 @@ } } +static int +XOTclOAutonameMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { + parseContext pc; + XOTclObject *obj = (XOTclObject *)clientData; + if (!obj) return XOTclObjErrType(interp, objv[0], "Object"); + if (parse2(interp, objc, objv, XOTclOAutonameMethodIdx, &pc) != TCL_OK) { + return TCL_ERROR; + } else { + int withInstance = (int )pc.clientData[0]; + int withReset = (int )pc.clientData[1]; + Tcl_Obj * name = (Tcl_Obj *)pc.clientData[2]; + + return XOTclOAutonameMethod(interp, obj, withInstance, withReset, name); + + } +} + +static int +XOTclOCheckMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { + parseContext pc; + XOTclObject *obj = (XOTclObject *)clientData; + if (!obj) return XOTclObjErrType(interp, objv[0], "Object"); + if (parse2(interp, objc, objv, XOTclOCheckMethodIdx, &pc) != TCL_OK) { + return TCL_ERROR; + } else { + Tcl_Obj * flag = (Tcl_Obj *)pc.clientData[0]; + + return XOTclOCheckMethod(interp, obj, flag); + + } +} + +static int +XOTclOCleanupMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { + parseContext pc; + XOTclObject *obj = (XOTclObject *)clientData; + if (!obj) return XOTclObjErrType(interp, objv[0], "Object"); + if (parse2(interp, objc, objv, XOTclOCleanupMethodIdx, &pc) != TCL_OK) { + return TCL_ERROR; + } else { + + + return XOTclOCleanupMethod(interp, obj); + + } +} + +static int +XOTclOConfigureMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { + parseContext pc; + XOTclObject *obj = (XOTclObject *)clientData; + if (!obj) return XOTclObjErrType(interp, objv[0], "Object"); + if (parse2(interp, objc, objv, XOTclOConfigureMethodIdx, &pc) != TCL_OK) { + return TCL_ERROR; + } else { + + + return XOTclOConfigureMethod(interp, obj, objc, objv); + + } +} + +static int +XOTclODestroyMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { + parseContext pc; + XOTclObject *obj = (XOTclObject *)clientData; + if (!obj) return XOTclObjErrType(interp, objv[0], "Object"); + if (parse2(interp, objc, objv, XOTclODestroyMethodIdx, &pc) != TCL_OK) { + return TCL_ERROR; + } else { + + + return XOTclODestroyMethod(interp, obj); + + } +} + +static int +XOTclOExistsMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { + parseContext pc; + XOTclObject *obj = (XOTclObject *)clientData; + if (!obj) return XOTclObjErrType(interp, objv[0], "Object"); + if (parse2(interp, objc, objv, XOTclOExistsMethodIdx, &pc) != TCL_OK) { + return TCL_ERROR; + } else { + char * var = (char *)pc.clientData[0]; + + return XOTclOExistsMethod(interp, obj, var); + + } +} + +static int +XOTclOFilterGuardMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { + parseContext pc; + XOTclObject *obj = (XOTclObject *)clientData; + if (!obj) return XOTclObjErrType(interp, objv[0], "Object"); + if (parse2(interp, objc, objv, XOTclOFilterGuardMethodIdx, &pc) != TCL_OK) { + return TCL_ERROR; + } else { + char * filter = (char *)pc.clientData[0]; + Tcl_Obj * guard = (Tcl_Obj *)pc.clientData[1]; + + return XOTclOFilterGuardMethod(interp, obj, filter, guard); + + } +} + +static int +XOTclOFilterSearchMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { + parseContext pc; + XOTclObject *obj = (XOTclObject *)clientData; + if (!obj) return XOTclObjErrType(interp, objv[0], "Object"); + if (parse2(interp, objc, objv, XOTclOFilterSearchMethodIdx, &pc) != TCL_OK) { + return TCL_ERROR; + } else { + char * filter = (char *)pc.clientData[0]; + + return XOTclOFilterSearchMethod(interp, obj, filter); + + } +} + +static int +XOTclOForwardMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { + parseContext pc; + XOTclObject *obj = (XOTclObject *)clientData; + if (!obj) return XOTclObjErrType(interp, objv[0], "Object"); + if (parse2(interp, objc, objv, XOTclOForwardMethodIdx, &pc) != TCL_OK) { + return TCL_ERROR; + } else { + Tcl_Obj * method = (Tcl_Obj *)pc.clientData[0]; + Tcl_Obj * withDefault = (Tcl_Obj *)pc.clientData[1]; + int withEarlybinding = (int )pc.clientData[2]; + Tcl_Obj * withMethodprefix = (Tcl_Obj *)pc.clientData[3]; + int withObjscope = (int )pc.clientData[4]; + Tcl_Obj * withOnerror = (Tcl_Obj *)pc.clientData[5]; + int withVerbose = (int )pc.clientData[6]; + Tcl_Obj * target = (Tcl_Obj *)pc.clientData[7]; + + return XOTclOForwardMethod(interp, obj, method, withDefault, withEarlybinding, withMethodprefix, withObjscope, withOnerror, withVerbose, target, objc-pc.lastobjc, objv+pc.lastobjc); + + } +} + +static int +XOTclOInstVarMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { + parseContext pc; + XOTclObject *obj = (XOTclObject *)clientData; + if (!obj) return XOTclObjErrType(interp, objv[0], "Object"); + if (parse2(interp, objc, objv, XOTclOInstVarMethodIdx, &pc) != TCL_OK) { + return TCL_ERROR; + } else { + + + return XOTclOInstVarMethod(interp, obj, objc, objv); + + } +} + +static int +XOTclOInvariantsMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { + parseContext pc; + XOTclObject *obj = (XOTclObject *)clientData; + if (!obj) return XOTclObjErrType(interp, objv[0], "Object"); + if (parse2(interp, objc, objv, XOTclOInvariantsMethodIdx, &pc) != TCL_OK) { + return TCL_ERROR; + } else { + Tcl_Obj * invariantlist = (Tcl_Obj *)pc.clientData[0]; + + return XOTclOInvariantsMethod(interp, obj, invariantlist); + + } +} + +static int +XOTclOIsClassMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { + parseContext pc; + XOTclObject *obj = (XOTclObject *)clientData; + if (!obj) return XOTclObjErrType(interp, objv[0], "Object"); + if (parse2(interp, objc, objv, XOTclOIsClassMethodIdx, &pc) != TCL_OK) { + return TCL_ERROR; + } else { + Tcl_Obj * class = (Tcl_Obj *)pc.clientData[0]; + + return XOTclOIsClassMethod(interp, obj, class); + + } +} + +static int +XOTclOIsMetaClassMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { + parseContext pc; + XOTclObject *obj = (XOTclObject *)clientData; + if (!obj) return XOTclObjErrType(interp, objv[0], "Object"); + if (parse2(interp, objc, objv, XOTclOIsMetaClassMethodIdx, &pc) != TCL_OK) { + return TCL_ERROR; + } else { + Tcl_Obj * metaclass = (Tcl_Obj *)pc.clientData[0]; + + return XOTclOIsMetaClassMethod(interp, obj, metaclass); + + } +} + +static int +XOTclOIsMixinMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { + parseContext pc; + XOTclObject *obj = (XOTclObject *)clientData; + if (!obj) return XOTclObjErrType(interp, objv[0], "Object"); + if (parse2(interp, objc, objv, XOTclOIsMixinMethodIdx, &pc) != TCL_OK) { + return TCL_ERROR; + } else { + Tcl_Obj * class = (Tcl_Obj *)pc.clientData[0]; + + return XOTclOIsMixinMethod(interp, obj, class); + + } +} + +static int +XOTclOIsObjectMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { + parseContext pc; + XOTclObject *obj = (XOTclObject *)clientData; + if (!obj) return XOTclObjErrType(interp, objv[0], "Object"); + if (parse2(interp, objc, objv, XOTclOIsObjectMethodIdx, &pc) != TCL_OK) { + return TCL_ERROR; + } else { + Tcl_Obj * object = (Tcl_Obj *)pc.clientData[0]; + + return XOTclOIsObjectMethod(interp, obj, object); + + } +} + +static int +XOTclOIsTypeMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { + parseContext pc; + XOTclObject *obj = (XOTclObject *)clientData; + if (!obj) return XOTclObjErrType(interp, objv[0], "Object"); + if (parse2(interp, objc, objv, XOTclOIsTypeMethodIdx, &pc) != TCL_OK) { + return TCL_ERROR; + } else { + Tcl_Obj * class = (Tcl_Obj *)pc.clientData[0]; + + return XOTclOIsTypeMethod(interp, obj, class); + + } +} + +static int +XOTclOMixinGuardMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { + parseContext pc; + XOTclObject *obj = (XOTclObject *)clientData; + if (!obj) return XOTclObjErrType(interp, objv[0], "Object"); + if (parse2(interp, objc, objv, XOTclOMixinGuardMethodIdx, &pc) != TCL_OK) { + return TCL_ERROR; + } else { + char * mixin = (char *)pc.clientData[0]; + Tcl_Obj * guard = (Tcl_Obj *)pc.clientData[1]; + + return XOTclOMixinGuardMethod(interp, obj, mixin, guard); + + } +} + +static int +XOTclONextMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { + parseContext pc; + XOTclObject *obj = (XOTclObject *)clientData; + if (!obj) return XOTclObjErrType(interp, objv[0], "Object"); + if (parse2(interp, objc, objv, XOTclONextMethodIdx, &pc) != TCL_OK) { + return TCL_ERROR; + } else { + + + return XOTclONextMethod(interp, obj, objc, objv); + + } +} + +static int +XOTclONoinitMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { + parseContext pc; + XOTclObject *obj = (XOTclObject *)clientData; + if (!obj) return XOTclObjErrType(interp, objv[0], "Object"); + if (parse2(interp, objc, objv, XOTclONoinitMethodIdx, &pc) != TCL_OK) { + return TCL_ERROR; + } else { + + + return XOTclONoinitMethod(interp, obj); + + } +} + +static int +XOTclOParametercmdMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { + parseContext pc; + XOTclObject *obj = (XOTclObject *)clientData; + if (!obj) return XOTclObjErrType(interp, objv[0], "Object"); + if (parse2(interp, objc, objv, XOTclOParametercmdMethodIdx, &pc) != TCL_OK) { + return TCL_ERROR; + } else { + char * name = (char *)pc.clientData[0]; + + return XOTclOParametercmdMethod(interp, obj, name); + + } +} + +static int +XOTclOProcMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { + parseContext pc; + XOTclObject *obj = (XOTclObject *)clientData; + if (!obj) return XOTclObjErrType(interp, objv[0], "Object"); + if (parse2(interp, objc, objv, XOTclOProcMethodIdx, &pc) != TCL_OK) { + return TCL_ERROR; + } else { + Tcl_Obj * name = (Tcl_Obj *)pc.clientData[0]; + Tcl_Obj * args = (Tcl_Obj *)pc.clientData[1]; + Tcl_Obj * body = (Tcl_Obj *)pc.clientData[2]; + Tcl_Obj * precondition = (Tcl_Obj *)pc.clientData[3]; + Tcl_Obj * postcondition = (Tcl_Obj *)pc.clientData[4]; + + return XOTclOProcMethod(interp, obj, name, args, body, precondition, postcondition); + + } +} + +static int +XOTclOProcSearchMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { + parseContext pc; + XOTclObject *obj = (XOTclObject *)clientData; + if (!obj) return XOTclObjErrType(interp, objv[0], "Object"); + if (parse2(interp, objc, objv, XOTclOProcSearchMethodIdx, &pc) != TCL_OK) { + return TCL_ERROR; + } else { + char * name = (char *)pc.clientData[0]; + + return XOTclOProcSearchMethod(interp, obj, name); + + } +} + +static int +XOTclORequireNamespaceMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { + parseContext pc; + XOTclObject *obj = (XOTclObject *)clientData; + if (!obj) return XOTclObjErrType(interp, objv[0], "Object"); + if (parse2(interp, objc, objv, XOTclORequireNamespaceMethodIdx, &pc) != TCL_OK) { + return TCL_ERROR; + } else { + + + return XOTclORequireNamespaceMethod(interp, obj); + + } +} + +static int +XOTclOSetMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { + parseContext pc; + XOTclObject *obj = (XOTclObject *)clientData; + if (!obj) return XOTclObjErrType(interp, objv[0], "Object"); + if (parse2(interp, objc, objv, XOTclOSetMethodIdx, &pc) != TCL_OK) { + return TCL_ERROR; + } else { + Tcl_Obj * var = (Tcl_Obj *)pc.clientData[0]; + Tcl_Obj * value = (Tcl_Obj *)pc.clientData[1]; + + return XOTclOSetMethod(interp, obj, var, value); + + } +} + +static int +XOTclOSetvaluesMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { + parseContext pc; + XOTclObject *obj = (XOTclObject *)clientData; + if (!obj) return XOTclObjErrType(interp, objv[0], "Object"); + if (parse2(interp, objc, objv, XOTclOSetvaluesMethodIdx, &pc) != TCL_OK) { + return TCL_ERROR; + } else { + + + return XOTclOSetvaluesMethod(interp, obj, objc, objv); + + } +} + +static int +XOTclOUplevelMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { + parseContext pc; + XOTclObject *obj = (XOTclObject *)clientData; + if (!obj) return XOTclObjErrType(interp, objv[0], "Object"); + if (parse2(interp, objc, objv, XOTclOUplevelMethodIdx, &pc) != TCL_OK) { + return TCL_ERROR; + } else { + + + return XOTclOUplevelMethod(interp, obj, objc, objv); + + } +} + +static int +XOTclOUpvarMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { + parseContext pc; + XOTclObject *obj = (XOTclObject *)clientData; + if (!obj) return XOTclObjErrType(interp, objv[0], "Object"); + if (parse2(interp, objc, objv, XOTclOUpvarMethodIdx, &pc) != TCL_OK) { + return TCL_ERROR; + } else { + + + return XOTclOUpvarMethod(interp, obj, objc, objv); + + } +} + +static int +XOTclOVolatileMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { + parseContext pc; + XOTclObject *obj = (XOTclObject *)clientData; + if (!obj) return XOTclObjErrType(interp, objv[0], "Object"); + if (parse2(interp, objc, objv, XOTclOVolatileMethodIdx, &pc) != TCL_OK) { + return TCL_ERROR; + } else { + + + return XOTclOVolatileMethod(interp, obj); + + } +} + +static int +XOTclOVwaitMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { + parseContext pc; + XOTclObject *obj = (XOTclObject *)clientData; + if (!obj) return XOTclObjErrType(interp, objv[0], "Object"); + if (parse2(interp, objc, objv, XOTclOVwaitMethodIdx, &pc) != TCL_OK) { + return TCL_ERROR; + } else { + char * varname = (char *)pc.clientData[0]; + + return XOTclOVwaitMethod(interp, obj, varname); + + } +} + static methodDefinition2 methodDefinitons[] = { {"type=boolean", XOTclCheckBooleanArgsStub, { {"name", 1, 0, NULL}, @@ -1215,7 +1753,7 @@ }, {"create", XOTclCCreateMethodStub, { {"name", 1, 0, NULL}, - {"args", 1, 0, "allargs"}} + {"args", 0, 0, "allargs"}} }, {"dealloc", XOTclCDeallocMethodStub, { {"object", 1, 0, "tclobj"}} @@ -1239,7 +1777,7 @@ {"mixin", 1, 0, NULL}, {"guard", 1, 0, "tclobj"}} }, -{"instparametercmd", XOTclCInstParameterCmdMethodStub, { +{"instparametercmd", XOTclCInstParametercmdMethodStub, { {"name", 1, 0, NULL}} }, {"instproc", XOTclCInstProcMethodStub, { @@ -1265,11 +1803,11 @@ }, {"recreate", XOTclCRecreateMethodStub, { {"name", 1, 0, "tclobj"}, - {"args", 1, 0, "allargs"}} + {"args", 0, 0, "allargs"}} }, {"unknown", XOTclCUnknownMethodStub, { {"name", 1, 0, NULL}, - {"args", 1, 0, "allargs"}} + {"args", 0, 0, "allargs"}} }, {"instances", XOTclClassInfoHeritageMethodStub, { {"class", 1, 0, "class"}, @@ -1310,7 +1848,7 @@ {"instforward", XOTclClassInfoInstforwardMethodStub, { {"class", 1, 0, "class"}, {"-definition", 0, 0, NULL}, - {"methodName", 1, 0, NULL}} + {"pattern", 0, 0, NULL}} }, {"instinvar", XOTclClassInfoInstinvarMethodStub, { {"class", 1, 0, "class"}} @@ -1412,7 +1950,7 @@ {"forward", XOTclObjInfoForwardMethodStub, { {"object", 1, 0, "object"}, {"-definition", 0, 0, NULL}, - {"methodName", 1, 0, NULL}} + {"pattern", 0, 0, NULL}} }, {"hasnamespace", XOTclObjInfoHasnamespaceMethodStub, { {"object", 1, 0, "object"}} @@ -1473,6 +2011,110 @@ {"vars", XOTclObjInfoVarsMethodStub, { {"object", 1, 0, "object"}, {"pattern", 0, 0, NULL}} +}, +{"autoname", XOTclOAutonameMethodStub, { + {"-instance", 0, 0, NULL}, + {"-reset", 0, 0, NULL}, + {"name", 1, 0, "tclobj"}} +}, +{"check", XOTclOCheckMethodStub, { + {"flag", 1, 0, "tclobj"}} +}, +{"cleanup", XOTclOCleanupMethodStub, { + } +}, +{"configure", XOTclOConfigureMethodStub, { + {"args", 0, 0, "allargs"}} +}, +{"destroy", XOTclODestroyMethodStub, { + } +}, +{"exists", XOTclOExistsMethodStub, { + {"var", 1, 0, NULL}} +}, +{"filterguard", XOTclOFilterGuardMethodStub, { + {"filter", 1, 0, NULL}, + {"guard", 1, 0, "tclobj"}} +}, +{"filtersearch", XOTclOFilterSearchMethodStub, { + {"filter", 1, 0, NULL}} +}, +{"forward", XOTclOForwardMethodStub, { + {"method", 1, 0, "tclobj"}, + {"-default", 0, 1, "tclobj"}, + {"-earlybinding", 0, 0, NULL}, + {"-methodprefix", 0, 1, "tclobj"}, + {"-objscope", 0, 0, NULL}, + {"-onerror", 0, 1, "tclobj"}, + {"-verbose", 0, 0, NULL}, + {"target", 0, 0, "tclobj"}, + {"args", 0, 0, "args"}} +}, +{"instvar", XOTclOInstVarMethodStub, { + {"args", 0, 0, "allargs"}} +}, +{"invar", XOTclOInvariantsMethodStub, { + {"invariantlist", 1, 0, "tclobj"}} +}, +{"isclass", XOTclOIsClassMethodStub, { + {"class", 0, 0, "tclobj"}} +}, +{"ismetaclass", XOTclOIsMetaClassMethodStub, { + {"metaclass", 0, 0, "tclobj"}} +}, +{"ismixin", XOTclOIsMixinMethodStub, { + {"class", 1, 0, "tclobj"}} +}, +{"isobject", XOTclOIsObjectMethodStub, { + {"object", 1, 0, "tclobj"}} +}, +{"istype", XOTclOIsTypeMethodStub, { + {"class", 1, 0, "tclobj"}} +}, +{"mixinguard", XOTclOMixinGuardMethodStub, { + {"mixin", 1, 0, NULL}, + {"guard", 1, 0, "tclobj"}} +}, +{"__next", XOTclONextMethodStub, { + {"args", 0, 0, "allargs"}} +}, +{"noinit", XOTclONoinitMethodStub, { + } +}, +{"parametercmd", XOTclOParametercmdMethodStub, { + {"name", 1, 0, NULL}} +}, +{"proc", XOTclOProcMethodStub, { + {"name", 1, 0, "tclobj"}, + {"args", 1, 0, "tclobj"}, + {"body", 1, 0, "tclobj"}, + {"precondition", 0, 0, "tclobj"}, + {"postcondition", 0, 0, "tclobj"}} +}, +{"procsearch", XOTclOProcSearchMethodStub, { + {"name", 1, 0, NULL}} +}, +{"requireNamespace", XOTclORequireNamespaceMethodStub, { + } +}, +{"set", XOTclOSetMethodStub, { + {"var", 1, 0, "tclobj"}, + {"value", 0, 0, "tclobj"}} +}, +{"setvalues", XOTclOSetvaluesMethodStub, { + {"args", 0, 0, "allargs"}} +}, +{"uplevel", XOTclOUplevelMethodStub, { + {"args", 0, 0, "allargs"}} +}, +{"upvar", XOTclOUpvarMethodStub, { + {"args", 0, 0, "allargs"}} +}, +{"volatile", XOTclOVolatileMethodStub, { + } +}, +{"vwait", XOTclOVwaitMethodStub, { + {"varname", 1, 0, NULL}} } }; Index: generic/xotcl.c =================================================================== diff -u -r9f046615c4f92e3d10286103e1ee67c8b6882f14 -r200940690a99e5cd234e83fe6acc234477bf879c --- generic/xotcl.c (.../xotcl.c) (revision 9f046615c4f92e3d10286103e1ee67c8b6882f14) +++ generic/xotcl.c (.../xotcl.c) (revision 200940690a99e5cd234e83fe6acc234477bf879c) @@ -5191,6 +5191,8 @@ (overflow ? "..." : ""), interp->errorLine)); } + + static int PushProcCallFrame( ClientData clientData, /* Record describing procedure to be * interpreted. */ @@ -6106,7 +6108,148 @@ } +static int +MakeProc2(Tcl_Namespace *ns, XOTclAssertionStore *aStore, Tcl_HashTable **nonposArgsTable, + Tcl_Interp *interp, + Tcl_Obj *name, Tcl_Obj *args, Tcl_Obj *body, Tcl_Obj *precondition, Tcl_Obj *postcondition, + XOTclObject *obj, int clsns) { + int result, haveNonposArgs = 0, argsc, i; + TclCallFrame frame, *framePtr = &frame; + Tcl_Obj *ov[4], **argsv; + Tcl_HashEntry *hPtr = NULL; + char *procName = ObjStr(name); + if (*nonposArgsTable && (hPtr = XOTcl_FindHashEntry(*nonposArgsTable, procName))) { + NonposArgsDeleteHashEntry(hPtr); + } + + ov[0] = NULL; /*objv[0];*/ + ov[1] = name; + + /* see, if we have nonposArgs in the ordinary argument list */ + result = Tcl_ListObjGetElements(interp, args, &argsc, &argsv); + if (result != TCL_OK) { + return XOTclVarErrMsg(interp, "cannot break args into list: ", + ObjStr(args), (char *) NULL); + } + for (i=0; i 0) { + arg = ObjStr(npav[0]); + /* fprintf(stderr, "*** argparse1 arg='%s' rc=%d\n", arg, rc);*/ + if (*arg == '-') { + haveNonposArgs = 1; + continue; + } + } + break; + } + if (haveNonposArgs) { + int nrOrdinaryArgs = argsc - i; + Tcl_Obj *ordinaryArgs = Tcl_NewListObj(nrOrdinaryArgs, &argsv[i]); + Tcl_Obj *nonposArgs = Tcl_NewListObj(i, &argsv[0]); + INCR_REF_COUNT(ordinaryArgs); + INCR_REF_COUNT(nonposArgs); + result = parseNonposArgs(interp, procName, nonposArgs, ordinaryArgs, + nonposArgsTable, &haveNonposArgs); + DECR_REF_COUNT(ordinaryArgs); + DECR_REF_COUNT(nonposArgs); + if (result != TCL_OK) + return result; + } + + if (haveNonposArgs) { + ov[2] = XOTclGlobalObjects[XOTE_ARGS]; + ov[3] = addPrefixToBody(body, 1); + } else { /* no nonpos arguments */ + ov[2] = args; + ov[3] = addPrefixToBody(body, 0); + } + + Tcl_PushCallFrame(interp,(Tcl_CallFrame *)framePtr, ns, 0); + + result = Tcl_ProcObjCmd(0, interp, 4, ov) != TCL_OK; +#if defined(NAMESPACEINSTPROCS) + { + Proc *procPtr = TclFindProc((Interp *)interp, procName); + /*fprintf(stderr,"proc=%p cmd=%p ns='%s' objns=%s\n", procPtr, procPtr->cmdPtr, + procPtr->cmdPtr->nsPtr->fullName, cmd->nsPtr->fullName);*/ + /*** patch the command ****/ + if (procPtr) { + if (clsns) { + /* set the namespace of the method as inside of the class */ + if (!obj->nsPtr) { + makeObjNamespace(interp, obj); + } + /*fprintf(stderr,"obj %s\n", objectName(obj)); + fprintf(stderr,"ns %p obj->ns %p\n", ns, obj->nsPtr); + fprintf(stderr,"ns %s obj->ns %s\n", ns->fullName, obj->nsPtr->fullName);*/ + procPtr->cmdPtr->nsPtr = (Namespace*) obj->nsPtr; + } else { + /* set the namespace of the method to the same namespace the class has */ + procPtr->cmdPtr->nsPtr = ((Command *)obj->id)->nsPtr; + } + } + } +#endif + + Tcl_PopCallFrame(interp); + + if (precondition || postcondition) { + AssertionAddProc(interp, ObjStr(name), aStore, precondition, postcondition); + } + + DECR_REF_COUNT(ov[3]); + + return result; +} + +static int makeMethod2(Tcl_Interp *interp, XOTclClass *cl, Tcl_Obj *name, Tcl_Obj *args, Tcl_Obj *body, + Tcl_Obj *precondition, Tcl_Obj *postcondition, int clsns) { + XOTclClassOpt *opt = cl->opt; + int result = TCL_OK; + char *argStr = ObjStr(args), *bdyStr = ObjStr(body), *nameStr = ObjStr(name); + + if ((cl->object.flags & XOTCL_IS_ROOT_CLASS && isDestroyString(nameStr)) || + (cl->object.flags & XOTCL_IS_ROOT_META_CLASS && isDeallocString(nameStr)) || + (cl->object.flags & XOTCL_IS_ROOT_META_CLASS && isAllocString(nameStr)) || + (cl->object.flags & XOTCL_IS_ROOT_META_CLASS && isCreateString(nameStr))) + return XOTclVarErrMsg(interp, className(cl), " method '", nameStr, "' of ", + className(cl), " can not be overwritten. Derive a ", + "sub-class", (char *) NULL); + if (precondition && !postcondition) { + return XOTclVarErrMsg(interp, className(cl), " method '", nameStr, + "'; when specifying a precondition (", ObjStr(precondition), + ") a postcondition must be specified as well", + (char *) NULL); + } + + /* if both, args and body are empty strings, we delete the method */ + if (*argStr == 0 && *bdyStr == 0) { + result = XOTclRemoveIMethod(interp, (XOTcl_Class *)cl, nameStr); + } else { + XOTclAssertionStore *aStore = NULL; + if (precondition || postcondition) { + opt = XOTclRequireClassOpt(cl); + if (!opt->assertions) + opt->assertions = AssertionCreateStore(); + aStore = opt->assertions; + } + result = MakeProc2(cl->nsPtr, aStore, &(cl->nonposArgsTable), + interp, name, args, body, precondition, postcondition, + &cl->object, clsns); + } + + /* could be a filter or filter inheritance ... update filter orders */ + FilterInvalidateObjOrders(interp, cl); + + return result; +} + static int MakeProc(Tcl_Namespace *ns, XOTclAssertionStore *aStore, Tcl_HashTable **nonposArgsTable, @@ -6189,7 +6332,6 @@ ov[2] = objv[2]; ov[3] = addPrefixToBody(objv[3], 0); } - } Tcl_PushCallFrame(interp,(Tcl_CallFrame *)framePtr, ns, 0); @@ -6409,6 +6551,9 @@ int rc; if (definition) { Tcl_HashEntry *hPtr = table && pattern ? XOTcl_FindHashEntry(table, pattern) : 0; + /* notice: we don't use pattern for wildcard matching here; + pattern can only contain wildcards when used without + "-definition" */ if (hPtr) { Tcl_Command cmd = (Tcl_Command)Tcl_GetHashValue(hPtr); ClientData clientData = cmd? Tcl_Command_objClientData(cmd) : NULL; @@ -7144,25 +7289,6 @@ return TCL_OK; } -/* method for calling e.g. $obj __next */ -static int -XOTclONextMethod(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { - XOTclObject *obj = (XOTclObject*)clientData; - XOTclCallStack *cs = &RUNTIME_STATE(interp)->cs; - XOTclCallStackContent *csc = CallStackGetTopFrame(interp); - char *methodName; - - for (; csc >= cs->content; csc--) { - if (csc->self == obj) break; - } - if (csccontent) - return XOTclVarErrMsg(interp, "__next: can't find object", - objectName(obj), (char *) NULL); - methodName = (char *)Tcl_GetCommandName(interp, csc->cmdPtr); - /*fprintf(stderr,"******* next for proc %s\n", methodName);*/ - return XOTclNextMethod(obj, interp, csc->cl, methodName, objc-1, &objv[1], 0); -} - /* * "self" object command */ @@ -8458,94 +8584,8 @@ } #endif -/* - * object method implementations - */ -static int -XOTclODestroyMethod(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { - XOTclObject *obj = (XOTclObject*)clientData; - if (!obj) return XOTclObjErrType(interp, objv[0], "Object"); - if (objc < 1) return XOTclObjErrArgCnt(interp, obj->cmdName, objv[0], NULL); - - PRINTOBJ("XOTclODestroyMethod", obj); - - /* - * call dealloc for [self] - */ - return XOTclCallMethodWithArgs((ClientData)obj->cl, interp, - XOTclGlobalObjects[XOTE_DEALLOC], obj->cmdName, - objc, objv+1, 0); -} - -static int -XOTclOCleanupMethod(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { - XOTclObject *obj = (XOTclObject*)clientData; - XOTclClass *cl = XOTclObjectToClass(obj); - char *fn; - int softrecreate; - Tcl_Obj *savedNameObj; - -#if defined(OBJDELETION_TRACE) - fprintf(stderr,"+++ XOTclOCleanupMethod\n"); -#endif - - if (!obj) return XOTclObjErrType(interp, objv[0], "Object"); - if (objc < 1) return XOTclObjErrArgCnt(interp, obj->cmdName, objv[0], NULL); - - PRINTOBJ("XOTclOCleanupMethod", obj); - - fn = objectName(obj); - savedNameObj = obj->cmdName; - INCR_REF_COUNT(savedNameObj); - - /* save and pass around softrecreate*/ - softrecreate = obj->flags & XOTCL_RECREATE && RUNTIME_STATE(interp)->doSoftrecreate; - - CleanupDestroyObject(interp, obj, softrecreate); - CleanupInitObject(interp, obj, obj->cl, obj->nsPtr, softrecreate); - - if (cl) { - CleanupDestroyClass(interp, cl, softrecreate, 1); - CleanupInitClass(interp, cl, cl->nsPtr, softrecreate, 1); - } - - DECR_REF_COUNT(savedNameObj); - - return TCL_OK; -} - -static int -XOTclOIsClassMethod(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { - Tcl_Obj *className; - XOTclObject *obj = (XOTclObject*)clientData, *o; - if (!obj) return XOTclObjErrType(interp, objv[0], "Object"); - if (objc < 1 || objc > 2) return XOTclObjErrArgCnt(interp, obj->cmdName, objv[0], - "?className?"); - className = (objc == 2) ? objv[1] : obj->cmdName; - - Tcl_SetIntObj(Tcl_GetObjResult(interp), - (XOTclObjConvertObject(interp, className, &o) == TCL_OK - && XOTclObjectIsClass(o) )); - return TCL_OK; -} - -static int -XOTclOIsObjectMethod(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { - XOTclObject *obj = (XOTclObject*)clientData, *o; - - if (!obj) return XOTclObjErrType(interp, objv[0], "Object"); - if (objc != 2) return XOTclObjErrArgCnt(interp, obj->cmdName, objv[0], ""); - - if (XOTclObjConvertObject(interp, objv[1], &o) == TCL_OK) { - Tcl_SetIntObj(Tcl_GetObjResult(interp), 1); - } else { - Tcl_SetIntObj(Tcl_GetObjResult(interp), 0); - } - return TCL_OK; -} - static int hasMetaProperty(Tcl_Interp *interp, XOTclClass *cl) { return cl->object.flags & XOTCL_IS_ROOT_META_CLASS; @@ -8597,27 +8637,8 @@ return hasMCM; } -static int -XOTclOIsMetaClassMethod(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { - XOTclObject *obj = (XOTclObject*)clientData, *o; - Tcl_Obj *className; - if (!obj) return XOTclObjErrType(interp, objv[0], "Object"); - if (objc < 1 || objc > 2) return XOTclObjErrArgCnt(interp, obj->cmdName, objv[0], - "?metaClassName?"); - - className = (objc == 2) ? objv[1] : obj->cmdName; - if (XOTclObjConvertObject(interp, className, &o) == TCL_OK - && XOTclObjectIsClass(o) - && IsMetaClass(interp, (XOTclClass*)o, 1)) { - Tcl_SetIntObj(Tcl_GetObjResult(interp), 1); - } else { - Tcl_SetIntObj(Tcl_GetObjResult(interp), 0); - } - return TCL_OK; -} - static int isSubType(XOTclClass *subcl, XOTclClass *cl) { XOTclClasses *t; @@ -8636,25 +8657,7 @@ return success; } -static int -XOTclOIsTypeMethod(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { - XOTclObject *obj = (XOTclObject*)clientData; - XOTclClass *cl; - int success = 0; - if (!obj) return XOTclObjErrType(interp, objv[0], "Object"); - if (objc != 2) return XOTclObjErrArgCnt(interp, obj->cmdName, objv[0], ""); - if (obj->cl && GetXOTclClassFromObj(interp, objv[1], &cl, obj->cl) == TCL_OK) { - success = isSubType(obj->cl, cl); - } - Tcl_ResetResult(interp); - Tcl_SetIntObj(Tcl_GetObjResult(interp), success); - return TCL_OK; -} - - - - static int XOTclIsCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { XOTclObject *obj = NULL; @@ -8731,93 +8734,7 @@ return 0; } -static int -XOTclOIsMixinMethod(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { - XOTclObject *obj = (XOTclObject*)clientData; - XOTclClass *cl; - int success = 0; - if (!obj) return XOTclObjErrType(interp, objv[0], "Object"); - if (objc != 2) return XOTclObjErrArgCnt(interp, obj->cmdName, objv[0], ""); - - if (GetXOTclClassFromObj(interp, objv[1],&cl, obj->cl) == TCL_OK) { - success = hasMixin(interp, obj, cl); - } - Tcl_ResetResult(interp); - Tcl_SetIntObj(Tcl_GetObjResult(interp), success); - return TCL_OK; -} - -static int -XOTclOExistsMethod(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { - XOTclObject *obj = (XOTclObject*)clientData; - - if (!obj) return XOTclObjErrType(interp, objv[0], "Object"); - if (objc != 2) return XOTclObjErrArgCnt(interp, obj->cmdName, objv[0], "var"); - - Tcl_SetIntObj(Tcl_GetObjResult(interp), - varExists(interp, obj, ObjStr(objv[1]), NULL, 1, 1)); - return TCL_OK; -} - -static int -XOTclOProcMethod(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj * CONST objv[]) { - XOTclObject *obj = (XOTclObject*)clientData; - char *argStr, *bdyStr, *name; - XOTclObjectOpt *opt; - int incr = 0, result = TCL_OK; - - if (!obj) return XOTclObjErrType(interp, objv[0], "Object"); - if (objc < 4 || objc > 7) - return XOTclObjErrArgCnt(interp, obj->cmdName, objv[0], - "name ?non-positional-args? args body ?preAssertion postAssertion?"); - - if (objc == 5 || objc == 7) { - incr = 1; - } - - argStr = ObjStr(objv[2 + incr]); - bdyStr = ObjStr(objv[3 + incr]); - name = ObjStr(objv[1 + incr]); - - if (*argStr == 0 && *bdyStr == 0) { - opt = obj->opt; - if (opt) - AssertionRemoveProc(opt->assertions, name); - if (obj->nsPtr) - NSDeleteCmd(interp, obj->nsPtr, name); - } else { - XOTclAssertionStore *aStore = NULL; - if (objc > 5) { - opt = XOTclRequireObjectOpt(obj); - if (!opt->assertions) - opt->assertions = AssertionCreateStore(); - aStore = opt->assertions; - } - requireObjNamespace(interp, obj); - result = MakeProc(obj->nsPtr, aStore, &(obj->nonposArgsTable), - interp, objc, (Tcl_Obj **) objv, obj, 0); - } - - /* could be a filter => recompute filter order */ - FilterComputeDefined(interp, obj); - - return result; -} - -static int -XOTclONoinitMethod(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj * CONST objv[]) { - XOTclObject *obj = (XOTclObject*)clientData; - - if (!obj) return XOTclObjErrType(interp, objv[0], "Object"); - if (objc != 1) return XOTclObjErrArgCnt(interp, obj->cmdName, objv[0], NULL); - - obj->flags |= XOTCL_INIT_CALLED; - - return TCL_OK; -} - - extern int XOTclCreateObject(Tcl_Interp *interp, Tcl_Obj *name, XOTcl_Class *class) { XOTclClass *cl = (XOTclClass*) class; @@ -9060,8 +8977,7 @@ return TCL_OK; } -static int -XOTclOInstVarMethod(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]); +static int XOTclOInstVarMethod(Tcl_Interp *interp, XOTclObject *obj, int objc, Tcl_Obj *CONST objv[]); extern int XOTclInstVar(XOTcl_Object *obji, Tcl_Interp *interp, char *name, char *destName) { @@ -9080,7 +8996,7 @@ Tcl_ListObjAppendElement(interp, objv[1], alias); } - result = XOTclOInstVarMethod((ClientData) obj, interp, 2, objv); + result = XOTclOInstVarMethod(interp, obj, 2, objv); if (destName) { DECR_REF_COUNT(alias); @@ -9094,6 +9010,9 @@ XOTclRemovePMethod(Tcl_Interp *interp, XOTcl_Object *obji, char *name) { XOTclObject *obj = (XOTclObject*) obji; + if (obj->opt) + AssertionRemoveProc(obj->opt->assertions, name); + if (obj->nsPtr) { int rc = NSDeleteCmd(interp, obj->nsPtr, name); if (rc < 0) @@ -9168,15 +9087,6 @@ } static int -XOTclOSetMethod(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { - XOTclObject *obj = (XOTclObject*)clientData; - - if (!obj) return XOTclObjErrType(interp, objv[0], "Object"); - if (objc > 3 || objc < 2) return XOTclObjErrArgCnt(interp, obj->cmdName, objv[0], "var ?value?"); - return setInstVar(interp, obj, objv[1], objc == 3 ? objv[2] : NULL); -} - -static int XOTclSetterMethod(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { XOTclObject *obj = (XOTclObject*)clientData; @@ -9186,119 +9096,8 @@ } -static int -XOTclOUpvarMethod(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj * CONST objv[]) { - XOTclObject *obj = (XOTclObject*)clientData; - Tcl_Obj *frameInfoObj = NULL; - int i, result = TCL_ERROR; - char *frameInfo; - callFrameContext ctx = {0}; - if (!obj) return XOTclObjErrType(interp, objv[0], "Object"); - if (objc < 2) return XOTclObjErrArgCnt(interp, obj->cmdName, objv[0], - "?level? otherVar localVar ?otherVar localVar ...?"); - - if (objc % 2 == 0) { - frameInfo = ObjStr(objv[1]); - i = 2; - } else { - frameInfoObj = computeLevelObj(interp, CALLING_LEVEL); - INCR_REF_COUNT(frameInfoObj); - frameInfo = ObjStr(frameInfoObj); - i = 1; - } - - if (obj && (obj->filterStack || obj->mixinStack)) { - CallStackUseActiveFrames(interp, &ctx); - } - - for ( ; i < objc; i += 2) { - result = Tcl_UpVar2(interp, frameInfo, ObjStr(objv[i]), NULL, - ObjStr(objv[i+1]), 0 /*flags*/); - if (result != TCL_OK) - break; - } - - if (frameInfoObj) { - DECR_REF_COUNT(frameInfoObj); - } - CallStackRestoreSavedFrames(interp, &ctx); - return result; -} - static int -XOTclOUplevelMethod(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj * CONST objv[]) { - XOTclObject *obj = (XOTclObject *)clientData; - int i, result = TCL_ERROR; - char *frameInfo = NULL; - Tcl_CallFrame *framePtr = NULL, *savedVarFramePtr; - - if (!obj) return XOTclObjErrType(interp, objv[0], "Object"); - if (objc < 2) { - uplevelSyntax: - return XOTclObjErrArgCnt(interp, obj->cmdName, objv[0], "?level? command ?arg ...?"); - } - /* - * Find the level to use for executing the command. - */ - if (objc>2) { - CallFrame *cf; - frameInfo = ObjStr(objv[1]); - result = TclGetFrame(interp, frameInfo, &cf); - if (result == -1) { - return TCL_ERROR; - } - framePtr = (Tcl_CallFrame *)cf; - i = result+1; - } else { - i = 1; - } - - objc -= i; - objv += i; - if (objc == 0) { - goto uplevelSyntax; - } - - if (!framePtr) { - XOTclCallStackContent *csc = XOTclCallStackFindLastInvocation(interp, 1); - if (csc) - framePtr = csc->currentFramePtr; - } - - savedVarFramePtr = (Tcl_CallFrame *)Tcl_Interp_varFramePtr(interp); - Tcl_Interp_varFramePtr(interp) = (CallFrame *)framePtr; - - /* - * Execute the residual arguments as a command. - */ - - if (objc == 1) { - result = Tcl_EvalObjEx(interp, objv[0], TCL_EVAL_DIRECT); - } else { - /* - * More than one argument: concatenate them together with spaces - * between, then evaluate the result. Tcl_EvalObjEx will delete - * the object when it decrements its refcount after eval'ing it. - */ - Tcl_Obj *objPtr = Tcl_ConcatObj(objc, objv); - result = Tcl_EvalObjEx(interp, objPtr, TCL_EVAL_DIRECT); - } - if (result == TCL_ERROR) { - char msg[32 + TCL_INTEGER_SPACE]; - sprintf(msg, "\n (\"uplevel\" body line %d)", interp->errorLine); - Tcl_AddObjErrorInfo(interp, msg, -1); - } - - /* - * Restore the variable frame, and return. - */ - - Tcl_Interp_varFramePtr(interp) = (CallFrame *)savedVarFramePtr; - return result; -} - -static int forwardArg(Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[], Tcl_Obj *o, forwardCmdClientData *tcd, Tcl_Obj **out, Tcl_Obj **freeList, int *inputarg, int *mapvalue) { @@ -9608,52 +9407,7 @@ -static int -XOTclOInstVarMethod(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { - XOTclObject *obj = (XOTclObject*)clientData; - Tcl_Obj **ov; - int i, oc, result = TCL_OK; - callFrameContext ctx = {0}; - if (!obj) return XOTclObjErrType(interp, objv[0], "Object"); - if (objc < 2) return XOTclObjErrArgCnt(interp, obj->cmdName, objv[0], "?vars?"); - - if (obj && (obj->filterStack || obj->mixinStack) ) { - CallStackUseActiveFrames(interp, &ctx); - } - if (!Tcl_Interp_varFramePtr(interp)) { - CallStackRestoreSavedFrames(interp, &ctx); - return XOTclVarErrMsg(interp, "instvar used on ", objectName(obj), - ", but callstack is not in procedure scope", - (char *) NULL); - } - - for (i=1; icmdName, objv[0], "varname"); - - nameString = ObjStr(objv[1]); - - /* - * Make sure the var table exists and the varname is in there - */ - if (NSRequireVariableOnObj(interp, obj, nameString, flgs) == 0) - return XOTclVarErrMsg(interp, "Can't lookup (and create) variable ", - nameString, " on ", objectName(obj), - (char *) NULL); - - XOTcl_PushFrame(interp, obj); - /* - * much of this is copied from Tcl, since we must avoid - * access with flag TCL_GLOBAL_ONLY ... doesn't work on - * obj->varTable vars - */ - if (Tcl_TraceVar(interp, nameString, flgs, (Tcl_VarTraceProc *)VwaitVarProc, - (ClientData) &done) != TCL_OK) { - return TCL_ERROR; - } - done = 0; - foundEvent = 1; - while (!done && foundEvent) { - foundEvent = Tcl_DoOneEvent(TCL_ALL_EVENTS); - } - Tcl_UntraceVar(interp, nameString, flgs, (Tcl_VarTraceProc *)VwaitVarProc, - (ClientData) &done); - XOTcl_PopFrame(interp, obj); - /* - * Clear out the interpreter's result, since it may have been set - * by event handlers. - */ - Tcl_ResetResult(interp); - - if (!foundEvent) { - return XOTclVarErrMsg(interp, "can't wait for variable '", nameString, - "': would wait forever", (char *) NULL); - } - return TCL_OK; -} - static int -XOTclOInvariantsMethod(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { - XOTclObject *obj = (XOTclObject*)clientData; - XOTclObjectOpt *opt; - - if (!obj) return XOTclObjErrType(interp, objv[0], "Object"); - if (objc != 2) - return XOTclObjErrArgCnt(interp, obj->cmdName, objv[0], ""); - - opt = XOTclRequireObjectOpt(obj); - - if (opt->assertions) - TclObjListFreeList(opt->assertions->invariants); - else - opt->assertions = AssertionCreateStore(); - - opt->assertions->invariants = AssertionNewList(interp, objv[1]); - return TCL_OK; -} - -static int -XOTclOAutonameMethod(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { - XOTclObject *obj = (XOTclObject*)clientData; - int instanceOpt = 0, resetOpt = 0; - Tcl_Obj *autoname; - - if (!obj) return XOTclObjErrType(interp, objv[0], "Object"); - if (objc == 3) { - instanceOpt = (strcmp(ObjStr(objv[1]), "-instance") == 0); - resetOpt = (strcmp(ObjStr(objv[1]), "-reset") == 0); - } - if ((objc < 2 || objc > 3) || (objc == 3 && !instanceOpt && !resetOpt)) - return XOTclObjErrArgCnt(interp, obj->cmdName, objv[0], "[-instance | -reset] name"); - - autoname = AutonameIncr(interp, objv[objc-1], obj, instanceOpt, resetOpt); - if (autoname) { - Tcl_SetObjResult(interp, autoname); - DECR_REF_COUNT(autoname); - } - else - return XOTclVarErrMsg(interp, - "Autoname failed. Probably format string (with %) was not well-formed", - (char *) NULL); - - return TCL_OK; -} - -static int -XOTclOCheckMethod(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { - XOTclObject *obj = (XOTclObject*)clientData; - int ocArgs; Tcl_Obj **ovArgs; - int i; - XOTclObjectOpt *opt; - - /*fprintf(stderr,"checkmethod\n");*/ - if (!obj) return XOTclObjErrType(interp, objv[0], "Object"); - if (objc != 2) - return XOTclObjErrArgCnt(interp, obj->cmdName, objv[0], - "?all? ?pre? ?post? ?invar? ?instinvar?"); - - opt = XOTclRequireObjectOpt(obj); - opt->checkoptions = CHECK_NONE; - - if (Tcl_ListObjGetElements(interp, objv[1], &ocArgs, &ovArgs) == TCL_OK - && ocArgs > 0) { - for (i = 0; i < ocArgs; i++) { - char *option = ObjStr(ovArgs[i]); - if (option) { - switch (*option) { - case 'i': - if (strcmp(option, "instinvar") == 0) { - opt->checkoptions |= CHECK_CLINVAR; - } else if (strcmp(option, "invar") == 0) { - opt->checkoptions |= CHECK_OBJINVAR; - } - break; - case 'p': - if (strcmp(option, "pre") == 0) { - opt->checkoptions |= CHECK_PRE; - } else if (strcmp(option, "post") == 0) { - opt->checkoptions |= CHECK_POST; - } - break; - case 'a': - if (strcmp(option, "all") == 0) { - opt->checkoptions |= CHECK_ALL; - } - break; - } - } - } - } - if (opt->checkoptions == CHECK_NONE && ocArgs>0) { - return XOTclVarErrMsg(interp, "Unknown check option in command '", - objectName(obj), " ", ObjStr(objv[0]), - " ", ObjStr(objv[1]), - "', valid: all pre post invar instinvar", - (char *) NULL); - } - - Tcl_ResetResult(interp); - return TCL_OK; -} - -static int -XOTclConfigureCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { - int bool, opt, result = TCL_OK; - static CONST char *opts[] = { - "filter", "softrecreate", - NULL - }; - enum subCmdIdx { - filterIdx, softrecreateIdx, - }; - - if (objc < 2 || objc>3) - return XOTclObjErrArgCnt(interp, objv[0], NULL, - "filter|softrecreate ?on|off?"); - - if (Tcl_GetIndexFromObj(interp, objv[1], opts, "option", 0, &opt) != TCL_OK) { - return TCL_ERROR; - } - - if (objc == 3) { - result = Tcl_GetBooleanFromObj(interp, objv[2], &bool); - } - if (result == TCL_OK) { - switch (opt) { - case filterIdx: - Tcl_SetBooleanObj(Tcl_GetObjResult(interp), - (RUNTIME_STATE(interp)->doFilters)); - if (objc == 3) - RUNTIME_STATE(interp)->doFilters = bool; - break; - - case softrecreateIdx: - Tcl_SetBooleanObj(Tcl_GetObjResult(interp), - (RUNTIME_STATE(interp)->doSoftrecreate)); - if (objc == 3) - RUNTIME_STATE(interp)->doSoftrecreate = bool; - break; - } - } - return result; -} - -static int XOTclObjscopedMethod(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { aliasCmdClientData *tcd = (aliasCmdClientData *)clientData; XOTclObject *obj = tcd->obj; @@ -10192,8 +9748,49 @@ return TCL_OK; } +static int +XOTclConfigureCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { + int bool, opt, result = TCL_OK; + static CONST char *opts[] = { + "filter", "softrecreate", + NULL + }; + enum subCmdIdx { + filterIdx, softrecreateIdx, + }; + if (objc < 2 || objc>3) + return XOTclObjErrArgCnt(interp, objv[0], NULL, + "filter|softrecreate ?on|off?"); + if (Tcl_GetIndexFromObj(interp, objv[1], opts, "option", 0, &opt) != TCL_OK) { + return TCL_ERROR; + } + + if (objc == 3) { + result = Tcl_GetBooleanFromObj(interp, objv[2], &bool); + } + if (result == TCL_OK) { + switch (opt) { + case filterIdx: + Tcl_SetBooleanObj(Tcl_GetObjResult(interp), + (RUNTIME_STATE(interp)->doFilters)); + if (objc == 3) + RUNTIME_STATE(interp)->doFilters = bool; + break; + + case softrecreateIdx: + Tcl_SetBooleanObj(Tcl_GetObjResult(interp), + (RUNTIME_STATE(interp)->doSoftrecreate)); + if (objc == 3) + RUNTIME_STATE(interp)->doSoftrecreate = bool; + break; + } + } + return result; +} + + static int XOTclSetInstvarCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { XOTclObject *obj = NULL; @@ -10440,167 +10037,6 @@ } -static int -XOTclOMixinGuardMethod(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { - XOTclObject *obj = (XOTclObject*)clientData; - XOTclCmdList *h; - XOTclObjectOpt *opt; - - if (!obj) return XOTclObjErrType(interp, objv[0], "Object"); - if (objc != 3) - return XOTclObjErrArgCnt(interp, obj->cmdName, objv[0], "mixin guards"); - - opt = obj->opt; - if (opt && opt->mixins) { - XOTclClass *mixinCl = XOTclpGetClass(interp, ObjStr(objv[1])); - Tcl_Command mixinCmd = NULL; - if (mixinCl) { - mixinCmd = Tcl_GetCommandFromObj(interp, mixinCl->object.cmdName); - } - if (mixinCmd) { - h = CmdListFindCmdInList(mixinCmd, opt->mixins); - if (h) { - if (h->clientData) - GuardDel((XOTclCmdList*) h); - GuardAdd(interp, h, objv[2]); - obj->flags &= ~XOTCL_MIXIN_ORDER_VALID; - return TCL_OK; - } - } - } - - return XOTclVarErrMsg(interp, "Mixinguard: can't find mixin ", - ObjStr(objv[1]), " on ", objectName(obj), - (char *) NULL); -} - - -static int -XOTclOFilterGuardMethod(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { - XOTclObject *obj = (XOTclObject*)clientData; - XOTclCmdList *h; - XOTclObjectOpt *opt; - - if (!obj) return XOTclObjErrType(interp, objv[0], "Object"); - if (objc != 3) - return XOTclObjErrArgCnt(interp, obj->cmdName, objv[0], "filtername filterGuards"); - - opt = obj->opt; - if (opt && opt->filters) { - h = CmdListFindNameInList(interp, ObjStr(objv[1]), opt->filters); - if (h) { - if (h->clientData) - GuardDel((XOTclCmdList*) h); - GuardAdd(interp, h, objv[2]); - obj->flags &= ~XOTCL_FILTER_ORDER_VALID; - return TCL_OK; - } - } - - return XOTclVarErrMsg(interp, "Filterguard: can't find filter ", - ObjStr(objv[1]), " on ", objectName(obj), - (char *) NULL); -} - -/* - * Searches for filter on [self] and returns fully qualified name - * if it is not found it returns an empty string - */ -static int -XOTclOFilterSearchMethod(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { - XOTclObject *obj = (XOTclObject*)clientData; - char *methodName; - XOTclCmdList *cmdList; - XOTclClass *fcl; - XOTclObject *fobj; - - if (!obj) return XOTclObjErrType(interp, objv[0], "Object"); - if (objc < 2) return XOTclObjErrArgCnt(interp, obj->cmdName, objv[0], "name"); - Tcl_ResetResult(interp); - - if (!(obj->flags & XOTCL_FILTER_ORDER_VALID)) - FilterComputeDefined(interp, obj); - if (!(obj->flags & XOTCL_FILTER_ORDER_DEFINED)) - return TCL_OK; - - methodName = ObjStr(objv[1]); - - for (cmdList = obj->filterOrder; cmdList; cmdList = cmdList->nextPtr) { - CONST84 char *filterName = Tcl_GetCommandName(interp, cmdList->cmdPtr); - if (filterName[0] == methodName[0] && !strcmp(filterName, methodName)) - break; - } - - if (!cmdList) - return TCL_OK; - - fcl = cmdList->clorobj; - if (fcl && XOTclObjectIsClass(&fcl->object)) { - fobj = NULL; - } else { - fobj = (XOTclObject*)fcl; - fcl = NULL; - } - - Tcl_SetObjResult(interp, - getFullProcQualifier(interp, methodName, fobj, fcl, - cmdList->cmdPtr)); - return TCL_OK; -} - -static int -XOTclOProcSearchMethod(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { - XOTclObject *obj = (XOTclObject*)clientData; - XOTclClass *pcl = NULL; - Tcl_Command cmd = NULL; - char *simpleName, *methodName; - - if (!obj) return XOTclObjErrType(interp, objv[0], "Object"); - if (objc < 2) return XOTclObjErrArgCnt(interp, obj->cmdName, objv[0], "name"); - - Tcl_ResetResult(interp); - - methodName = ObjStr(objv[1]); - - if (!(obj->flags & XOTCL_MIXIN_ORDER_VALID)) - MixinComputeDefined(interp, obj); - - if (obj->flags & XOTCL_MIXIN_ORDER_DEFINED_AND_VALID) { - XOTclCmdList *mixinList; - for (mixinList = obj->mixinOrder; mixinList; mixinList = mixinList->nextPtr) { - XOTclClass *mcl = XOTclpGetClass(interp, (char *)Tcl_GetCommandName(interp, mixinList->cmdPtr)); - if (mcl && (pcl = SearchCMethod(mcl, methodName, &cmd))) { - break; - } - } - } - - if (!cmd && obj->nsPtr) { - cmd = FindMethod(methodName, obj->nsPtr); - } - - if (!cmd && obj->cl) - pcl = SearchCMethod(obj->cl, methodName, &cmd); - - if (cmd) { - XOTclObject *pobj = pcl ? NULL : obj; - simpleName = (char *)Tcl_GetCommandName(interp, cmd); - Tcl_SetObjResult(interp, getFullProcQualifier(interp, simpleName, pobj, pcl, cmd)); - } - return TCL_OK; -} - -static int -XOTclORequireNamespaceMethod(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { - XOTclObject *obj = (XOTclObject*)clientData; - - if (!obj) return XOTclObjErrType(interp, objv[0], "Object"); - if (objc != 1) return XOTclObjErrArgCnt(interp, obj->cmdName, objv[0], NULL); - - requireObjNamespace(interp, obj); - return TCL_OK; -} - typedef enum {NO_DASH, SKALAR_DASH, LIST_DASH} dashArgType; static dashArgType @@ -10681,122 +10117,13 @@ } -static int -XOTclOSetvaluesMethod(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { - XOTclObject *obj = (XOTclObject*)clientData; - Tcl_Obj **argv, **nextArgv, *resultObj; - int i, argc, nextArgc, normalArgs, result = TCL_OK, isdasharg = NO_DASH; - char *methodName, *nextMethodName; - if (!obj) return XOTclObjErrType(interp, objv[0], "Object"); - if (objc < 1) return XOTclObjErrArgCnt(interp, obj->cmdName, objv[0], "?args?"); - /* find arguments without leading dash */ - for (i=1; i < objc; i++) { - if ((isdasharg = isDashArg(interp, objv[i], &methodName, &argc, &argv))) - break; - } - normalArgs = i-1; - Tcl_ResetResult(interp); - for( ; i < objc; argc=nextArgc, argv=nextArgv, methodName=nextMethodName) { - Tcl_ResetResult(interp); - switch (isdasharg) { - case SKALAR_DASH: /* Argument is a skalar with a leading dash */ - { int j; - for (j = i+1; j < objc; j++, argc++) { - if ((isdasharg = isDashArg(interp, objv[j], &nextMethodName, &nextArgc, &nextArgv))) - break; - } - result = callConfigureMethod(interp, obj, methodName, argc+1, objv+i+1); - if (result != TCL_OK) { - return result; - } - i += argc; - break; - } - case LIST_DASH: /* Argument is a list with a leading dash, grouping determined by list */ - { i++; - if (inextPtr) { - result = setDefaultValue(interp, obj, so->obj); - if (result != TCL_OK) { - goto configure_exit; - } - } - - /* - * call configure methods (starting with '-') - */ - result = callMethod((ClientData) obj, interp, - XOTclGlobalObjects[XOTE_SETVALUES], objc+1, objv+1, 0); - /* fprintf(stderr, "setvalues returned %d\n",result);*/ - if (result != TCL_OK) { - goto configure_exit; - } - - /* - * Check, if we got the required values - */ - for (so = slotObjects; so; so = so->nextPtr) { - result = checkRequiredValue(interp, obj, so->obj); - if (result != TCL_OK) { - goto configure_exit; - } - } - - configure_exit: - /*XOTcl_PopFrame(interp, obj);*/ - - if (slotObjects) - XOTclObjectListFree(slotObjects); - return result; -} - - - /* * class method implementations */ - - static Tcl_Namespace * callingNameSpace(Tcl_Interp *interp) { Tcl_Namespace *ns = NULL; @@ -11047,9 +10374,11 @@ memset(pc, 0, sizeof(parseContext)); - /*fprintf(stderr, "BEGIN "); +#if defined(PARSE_TRACE) + fprintf(stderr, "BEGIN (%d) [0]%s ",objc,ObjStr(objv[0])); for (o=1; oname && oname,o);*/ @@ -11102,10 +10431,7 @@ o += flagCount; } else { - if (aPtr->required) - nrReq++; - else - nrOpt++; + if (aPtr->required) nrReq++; else nrOpt++; /*fprintf(stderr,"... arg %s req %d type %s try to set on %d: '%s'\n", aPtr->name,aPtr->required,aPtr->type,i, ObjStr(objv[o]));*/ @@ -11123,21 +10449,29 @@ args = objc - flagCount - 1; pc->lastobjc = aPtr->name ? o : o-1; - /* is the last argument a varargs */ - while (aPtr->name) aPtr++; - aPtr--; + /* process to end of interface;*/ + while (aPtr->name) { + if (aPtr->required) nrReq++; else nrOpt++; + aPtr++; + } + /* is last argument a vararg? */ + aPtr--; if (!varArgs && aPtr->type && (strcmp(aPtr->type,"args") == 0 || strcmp(aPtr->type,"allargs") == 0)) { varArgs = 1; /*fprintf(stderr, "last arg is varargs\n");*/ } - - /*fprintf(stderr, "less nrreq %d last arg %s type %s\n", args < nrReq, aPtr->name, aPtr->type); + /* fprintf(stderr, "less nrreq %d last arg %s type %s\n", args < nrReq, aPtr->name, aPtr->type); fprintf(stderr, "objc = %d, args = %d, nrReq %d, nrReq + nrOpt = %d, varArgs %d i %d %s\n", objc,args,nrReq,nrReq + nrOpt, varArgs, i,aPtr->name);*/ +#if defined(PARSE_TRACE) + fprintf(stderr, "END lastobjc %d, varargs %d, not enough args (%d<%d) = %d\n", + pc->lastobjc,varArgs, args,nrReq,args < nrReq); +#endif + if (args < nrReq || (!varArgs && args > nrReq + nrOpt)) { Tcl_Obj *msg = Tcl_NewStringObj("", 0); for (aPtr=ifdPtr[0]; aPtr->name; aPtr++) { @@ -11155,7 +10489,6 @@ return XOTclObjErrArgCntObj(interp, objv[0], NULL, msg); } - /*fprintf(stderr, "END args=%d\n",pc->lastobjc);*/ return TCL_OK; } @@ -11177,7 +10510,913 @@ return 0; } + +static void forwardCmdDeleteProc(ClientData clientData); /* TODO REMOVE ME LATER */ + +static int +forwardProcessOptions2(Tcl_Interp *interp, Tcl_Obj *name, + Tcl_Obj *withDefault, int withEarlybinding, Tcl_Obj *withMethodprefix, + int withObjscope, Tcl_Obj *withOnerror, int withVerbose, + Tcl_Obj *target, int objc, Tcl_Obj * CONST objv[], + forwardCmdClientData **tcdp) { + forwardCmdClientData *tcd; + int i, rc = 0; + + tcd = NEW(forwardCmdClientData); + memset(tcd, 0, sizeof(forwardCmdClientData)); + + if (withDefault) { + tcd->subcommands = withDefault; + rc = Tcl_ListObjLength(interp, withDefault, &tcd->nr_subcommands); + INCR_REF_COUNT(tcd->subcommands); + } + if (withMethodprefix) { + tcd->prefix = withMethodprefix; + INCR_REF_COUNT(tcd->prefix); + } + if (withOnerror) { + tcd->onerror = withOnerror; + INCR_REF_COUNT(tcd->onerror); + } + tcd->objscope = withObjscope; + tcd->verbose = withVerbose; + tcd->needobjmap = 0; + tcd->cmdName = target; + /*fprintf(stderr, "...forwardprocess objc %d\n",objc);*/ + + for (i=0; ineedobjmap |= (*element == '%' && *(element+1) == '@'); + /* TODO simplify: cmdName not needed here */ + if (tcd->cmdName == NULL) { + tcd->cmdName = objv[i]; + } else if (tcd->args == NULL) { + tcd->args = Tcl_NewListObj(1, &objv[i]); + tcd->nr_args++; + INCR_REF_COUNT(tcd->args); + } else { + Tcl_ListObjAppendElement(interp, tcd->args, objv[i]); + tcd->nr_args++; + } + } + + if (!tcd->cmdName) { + tcd->cmdName = name; + } + + /*fprintf(stderr, "cmdName = %s, args = %s, # = %d\n", + ObjStr(tcd->cmdName), tcd->args?ObjStr(tcd->args):"NULL", tcd->nr_args);*/ + + if (tcd->objscope) { + /* when we evaluating objscope, and define ... + o forward append -objscope append + a call to + o append ... + would lead to a recursive call; so we add the appropriate namespace + */ + char *nameString = ObjStr(tcd->cmdName); + if (!isAbsolutePath(nameString)) { + tcd->cmdName = NameInNamespaceObj(interp, nameString, callingNameSpace(interp)); + /*fprintf(stderr,"name %s not absolute, therefore qualifying %s\n", name, + ObjStr(tcd->cmdName));*/ + } + } + INCR_REF_COUNT(tcd->cmdName); + + if (withEarlybinding) { + Tcl_Command cmd = Tcl_GetCommandFromObj(interp, tcd->cmdName); + if (cmd == NULL) + return XOTclVarErrMsg(interp, "cannot lookup command '", ObjStr(tcd->cmdName), "'", (char *) NULL); + + tcd->objProc = Tcl_Command_objProc(cmd); + if (tcd->objProc == XOTclObjDispatch /* don't do direct invoke on xotcl objects */ + || tcd->objProc == TclObjInterpProc /* don't do direct invoke on tcl procs */ + ) { + /* silently ignore earlybinding flag */ + tcd->objProc = NULL; + } else { + tcd->clientData = Tcl_Command_objClientData(cmd); + } + } + + tcd->passthrough = !tcd->args && *(ObjStr(tcd->cmdName)) != '%' && tcd->objProc; + + /*fprintf(stderr, "forward args = %p, name = '%s'\n", tcd->args, ObjStr(tcd->cmdName));*/ + if (rc == TCL_OK) { + *tcdp = tcd; + } else { + forwardCmdDeleteProc((ClientData)tcd); + } + return rc; +} + + +static int +forwardProcessOptions(Tcl_Interp *interp, int objc, Tcl_Obj * CONST objv[], + forwardCmdClientData **tcdp) { + forwardCmdClientData *tcd; + int i, rc = 0, earlybinding = 0; + + tcd = NEW(forwardCmdClientData); + memset(tcd, 0, sizeof(forwardCmdClientData)); + + for (i=2; isubcommands = objv[i+1]; + rc = Tcl_ListObjLength(interp, objv[i+1],&tcd->nr_subcommands); + if (rc != TCL_OK) break; + INCR_REF_COUNT(tcd->subcommands); + i++; + } else if (!strcmp(ObjStr(objv[i]),"-methodprefix")) { + if (objc <= i+1) {rc = TCL_ERROR; break;} + tcd->prefix = objv[i+1]; + INCR_REF_COUNT(tcd->prefix); + i++; + } else if (!strcmp(ObjStr(objv[i]),"-onerror")) { + if (objc <= i+1) {rc = TCL_ERROR; break;} + tcd->onerror = objv[i+1]; + INCR_REF_COUNT(tcd->onerror); + i++; + } else if (!strcmp(ObjStr(objv[i]),"-objscope")) { + tcd->objscope = 1; + } else if (!strcmp(ObjStr(objv[i]),"-earlybinding")) { + earlybinding = 1; + } else if (!strcmp(ObjStr(objv[i]),"-verbose")) { + tcd->verbose = 1; + } else { + /* todo protected */ + break; + } + } + + tcd->needobjmap = 0; + for (; ineedobjmap |= (*element == '%' && *(element+1) == '@'); + + if (tcd->cmdName == NULL) { + tcd->cmdName = objv[i]; + } else if (tcd->args == NULL) { + tcd->args = Tcl_NewListObj(1, &objv[i]); + tcd->nr_args++; + INCR_REF_COUNT(tcd->args); + } else { + Tcl_ListObjAppendElement(interp, tcd->args, objv[i]); + tcd->nr_args++; + } + } + + if (!tcd->cmdName) { + tcd->cmdName = objv[1]; + } + + if (tcd->objscope) { + /* when we evaluating objscope, and define ... + o forward append -objscope append + a call to + o append ... + would lead to a recursive call; so we add the appropriate namespace + */ + char *name = ObjStr(tcd->cmdName); + if (!isAbsolutePath(name)) { + tcd->cmdName = NameInNamespaceObj(interp, name, callingNameSpace(interp)); + /*fprintf(stderr,"name %s not absolute, therefore qualifying %s\n", name, + ObjStr(tcd->cmdName));*/ + } + } + INCR_REF_COUNT(tcd->cmdName); + + if (earlybinding) { + Tcl_Command cmd = Tcl_GetCommandFromObj(interp, tcd->cmdName); + if (cmd == NULL) + return XOTclVarErrMsg(interp, "cannot lookup command '", ObjStr(tcd->cmdName), "'", (char *) NULL); + + tcd->objProc = Tcl_Command_objProc(cmd); + if (tcd->objProc == XOTclObjDispatch /* don't do direct invoke on xotcl objects */ + || tcd->objProc == TclObjInterpProc /* don't do direct invoke on tcl procs */ + ) { + /* silently ignore earlybinding flag */ + tcd->objProc = NULL; + } else { + tcd->clientData = Tcl_Command_objClientData(cmd); + } + } + + tcd->passthrough = !tcd->args && *(ObjStr(tcd->cmdName)) != '%' && tcd->objProc; + + /*fprintf(stderr, "forward args = %p, name = '%s'\n", tcd->args, ObjStr(tcd->cmdName));*/ + if (rc == TCL_OK) { + *tcdp = tcd; + } else { + forwardCmdDeleteProc((ClientData)tcd); + } + return rc; +} + + /*************************** + * Begin Object Methods + ***************************/ +static int XOTclOAutonameMethod(Tcl_Interp *interp, XOTclObject *obj, int withInstance, int withReset, + Tcl_Obj *name) { + Tcl_Obj *autoname = AutonameIncr(interp, name, obj, withInstance, withReset); + if (autoname) { + Tcl_SetObjResult(interp, autoname); + DECR_REF_COUNT(autoname); + } + else + return XOTclVarErrMsg(interp, + "Autoname failed. Probably format string (with %) was not well-formed", + (char *) NULL); + + return TCL_OK; +} + +static int XOTclOCheckMethod(Tcl_Interp *interp, XOTclObject *obj, Tcl_Obj *flag) { + XOTclObjectOpt *opt = XOTclRequireObjectOpt(obj); + int ocArgs, i; + Tcl_Obj **ovArgs; + opt->checkoptions = CHECK_NONE; + + if (Tcl_ListObjGetElements(interp, flag, &ocArgs, &ovArgs) == TCL_OK + && ocArgs > 0) { + for (i = 0; i < ocArgs; i++) { + char *option = ObjStr(ovArgs[i]); + if (option) { + switch (*option) { + case 'i': + if (strcmp(option, "instinvar") == 0) { + opt->checkoptions |= CHECK_CLINVAR; + } else if (strcmp(option, "invar") == 0) { + opt->checkoptions |= CHECK_OBJINVAR; + } + break; + case 'p': + if (strcmp(option, "pre") == 0) { + opt->checkoptions |= CHECK_PRE; + } else if (strcmp(option, "post") == 0) { + opt->checkoptions |= CHECK_POST; + } + break; + case 'a': + if (strcmp(option, "all") == 0) { + opt->checkoptions |= CHECK_ALL; + } + break; + } + } + } + } + if (opt->checkoptions == CHECK_NONE && ocArgs>0) { + return XOTclVarErrMsg(interp, "Unknown check option in command '", + objectName(obj), " check ", ObjStr(flag), + "', valid: all pre post invar instinvar", + (char *) NULL); + } + + Tcl_ResetResult(interp); + return TCL_OK; +} + +static int XOTclOCleanupMethod(Tcl_Interp *interp, XOTclObject *obj) { + XOTclClass *cl = XOTclObjectToClass(obj); + char *fn; + int softrecreate; + Tcl_Obj *savedNameObj; + +#if defined(OBJDELETION_TRACE) + fprintf(stderr,"+++ XOTclOCleanupMethod\n"); +#endif + PRINTOBJ("XOTclOCleanupMethod", obj); + + fn = objectName(obj); + savedNameObj = obj->cmdName; + INCR_REF_COUNT(savedNameObj); + + /* save and pass around softrecreate*/ + softrecreate = obj->flags & XOTCL_RECREATE && RUNTIME_STATE(interp)->doSoftrecreate; + + CleanupDestroyObject(interp, obj, softrecreate); + CleanupInitObject(interp, obj, obj->cl, obj->nsPtr, softrecreate); + + if (cl) { + CleanupDestroyClass(interp, cl, softrecreate, 1); + CleanupInitClass(interp, cl, cl->nsPtr, softrecreate, 1); + } + + DECR_REF_COUNT(savedNameObj); + return TCL_OK; +} + +static int XOTclOConfigureMethod(Tcl_Interp *interp, XOTclObject *obj, int objc, Tcl_Obj *CONST objv[]) { + XOTclObjects *slotObjects, *so; + int result; + /* would be nice to do it here instead of setValue + XOTcl_FrameDecls; + + XOTcl_PushFrame(interp, obj); make instvars of obj accessible */ + + /* + * Search for default values on slots + */ + slotObjects = computeSlotObjects(interp, obj, NULL); + for (so = slotObjects; so; so = so->nextPtr) { + result = setDefaultValue(interp, obj, so->obj); + if (result != TCL_OK) { + goto configure_exit; + } + } + + /* + * call configure methods (starting with '-') + */ + /*{ int i; + fprintf(stderr, "call setvalues %d: ",objc+1); + for (i=0; inextPtr) { + result = checkRequiredValue(interp, obj, so->obj); + if (result != TCL_OK) { + goto configure_exit; + } + } + + configure_exit: + /*XOTcl_PopFrame(interp, obj);*/ + + if (slotObjects) + XOTclObjectListFree(slotObjects); + return result; +} + +static int XOTclODestroyMethod(Tcl_Interp *interp, XOTclObject *obj) { + PRINTOBJ("XOTclODestroyMethod", obj); + return XOTclCallMethodWithArgs((ClientData)obj->cl, interp, + XOTclGlobalObjects[XOTE_DEALLOC], obj->cmdName, + 1, NULL, 0); +} + +static int XOTclOExistsMethod(Tcl_Interp *interp, XOTclObject *obj, char *var) { + Tcl_SetIntObj(Tcl_GetObjResult(interp), varExists(interp, obj, var, NULL, 1, 1)); + return TCL_OK; +} + +static int XOTclOFilterGuardMethod(Tcl_Interp *interp, XOTclObject *obj, char *filter, Tcl_Obj *guard) { + XOTclObjectOpt *opt = obj->opt; + + if (opt && opt->filters) { + XOTclCmdList *h = CmdListFindNameInList(interp, filter, opt->filters); + if (h) { + if (h->clientData) + GuardDel((XOTclCmdList*) h); + GuardAdd(interp, h, guard); + obj->flags &= ~XOTCL_FILTER_ORDER_VALID; + return TCL_OK; + } + } + + return XOTclVarErrMsg(interp, "Filterguard: can't find filter ", + filter, " on ", objectName(obj), (char *) NULL); +} + +/* + * Searches for filter on [self] and returns fully qualified name + * if it is not found it returns an empty string + */ +static int XOTclOFilterSearchMethod(Tcl_Interp *interp, XOTclObject *obj, char *filter) { + XOTclCmdList *cmdList; + XOTclClass *fcl; + XOTclObject *fobj; + + Tcl_ResetResult(interp); + + if (!(obj->flags & XOTCL_FILTER_ORDER_VALID)) + FilterComputeDefined(interp, obj); + if (!(obj->flags & XOTCL_FILTER_ORDER_DEFINED)) + return TCL_OK; + + for (cmdList = obj->filterOrder; cmdList; cmdList = cmdList->nextPtr) { + CONST84 char *filterName = Tcl_GetCommandName(interp, cmdList->cmdPtr); + if (filterName[0] == filter[0] && !strcmp(filterName, filter)) + break; + } + + if (!cmdList) + return TCL_OK; + + fcl = cmdList->clorobj; + if (fcl && XOTclObjectIsClass(&fcl->object)) { + fobj = NULL; + } else { + fobj = (XOTclObject*)fcl; + fcl = NULL; + } + + Tcl_SetObjResult(interp, getFullProcQualifier(interp, filter, fobj, fcl, + cmdList->cmdPtr)); + return TCL_OK; +} + +static int XOTclOInstVarMethod(Tcl_Interp *interp, XOTclObject *obj, int objc, Tcl_Obj *CONST objv[]) { + Tcl_Obj **ov; + int i, oc, result = TCL_OK; + callFrameContext ctx = {0}; + + if (obj && (obj->filterStack || obj->mixinStack) ) { + CallStackUseActiveFrames(interp, &ctx); + } + if (!Tcl_Interp_varFramePtr(interp)) { + CallStackRestoreSavedFrames(interp, &ctx); + return XOTclVarErrMsg(interp, "instvar used on ", objectName(obj), + ", but callstack is not in procedure scope", + (char *) NULL); + } + + for (i=1; iassertions) + TclObjListFreeList(opt->assertions->invariants); + else + opt->assertions = AssertionCreateStore(); + + opt->assertions->invariants = AssertionNewList(interp, invariantlist); + return TCL_OK; +} + +static int XOTclOIsClassMethod(Tcl_Interp *interp, XOTclObject *obj, Tcl_Obj *class) { + XOTclObject *o; + Tcl_SetIntObj(Tcl_GetObjResult(interp), + (XOTclObjConvertObject(interp, class ? class : obj->cmdName, &o) == TCL_OK + && XOTclObjectIsClass(o) )); + return TCL_OK; +} + +static int XOTclOIsMetaClassMethod(Tcl_Interp *interp, XOTclObject *obj, Tcl_Obj *metaclass) { + XOTclObject *o; + if (XOTclObjConvertObject(interp, metaclass ? metaclass : obj->cmdName, &o) == TCL_OK + && XOTclObjectIsClass(o) + && IsMetaClass(interp, (XOTclClass*)o, 1)) { + Tcl_SetIntObj(Tcl_GetObjResult(interp), 1); + } else { + Tcl_SetIntObj(Tcl_GetObjResult(interp), 0); + } + return TCL_OK; +} + +static int XOTclOIsMixinMethod(Tcl_Interp *interp, XOTclObject *obj, Tcl_Obj *class) { + XOTclClass *cl; + int success = 0; + + if (GetXOTclClassFromObj(interp, class, &cl, obj->cl) == TCL_OK) { + success = hasMixin(interp, obj, cl); + } + Tcl_ResetResult(interp); + Tcl_SetIntObj(Tcl_GetObjResult(interp), success); + return TCL_OK; +} + +static int XOTclOIsObjectMethod(Tcl_Interp *interp, XOTclObject *obj, Tcl_Obj *object) { + XOTclObject *o; + Tcl_SetIntObj(Tcl_GetObjResult(interp), (XOTclObjConvertObject(interp, object, &o) == TCL_OK)); + return TCL_OK; +} + +static int XOTclOIsTypeMethod(Tcl_Interp *interp, XOTclObject *obj, Tcl_Obj *class) { + XOTclClass *cl; + int success = 0; + + if (obj->cl && GetXOTclClassFromObj(interp, class, &cl, obj->cl) == TCL_OK) { + success = isSubType(obj->cl, cl); + } + Tcl_ResetResult(interp); + Tcl_SetIntObj(Tcl_GetObjResult(interp), success); + return TCL_OK; +} + +static int XOTclOMixinGuardMethod(Tcl_Interp *interp, XOTclObject *obj, char *mixin, Tcl_Obj *guard) { + XOTclObjectOpt *opt = obj->opt; + + if (opt && opt->mixins) { + XOTclClass *mixinCl = XOTclpGetClass(interp, mixin); + Tcl_Command mixinCmd = NULL; + if (mixinCl) { + mixinCmd = Tcl_GetCommandFromObj(interp, mixinCl->object.cmdName); + } + if (mixinCmd) { + XOTclCmdList *h = CmdListFindCmdInList(mixinCmd, opt->mixins); + if (h) { + if (h->clientData) + GuardDel((XOTclCmdList*) h); + GuardAdd(interp, h, guard); + obj->flags &= ~XOTCL_MIXIN_ORDER_VALID; + return TCL_OK; + } + } + } + + return XOTclVarErrMsg(interp, "Mixinguard: can't find mixin ", + mixin, " on ", objectName(obj), (char *) NULL); +} + +/* method for calling e.g. $obj __next */ +static int XOTclONextMethod(Tcl_Interp *interp, XOTclObject *obj, int objc, Tcl_Obj *CONST objv[]) { + XOTclCallStack *cs = &RUNTIME_STATE(interp)->cs; + XOTclCallStackContent *csc = CallStackGetTopFrame(interp); + char *methodName; + + for (; csc >= cs->content; csc--) { + if (csc->self == obj) break; + } + if (csccontent) + return XOTclVarErrMsg(interp, "__next: can't find object", + objectName(obj), (char *) NULL); + methodName = (char *)Tcl_GetCommandName(interp, csc->cmdPtr); + return XOTclNextMethod(obj, interp, csc->cl, methodName, objc-1, &objv[1], 0); +} + +static int XOTclONoinitMethod(Tcl_Interp *interp, XOTclObject *obj) { + obj->flags |= XOTCL_INIT_CALLED; + return TCL_OK; +} + +static int XOTclOParametercmdMethod(Tcl_Interp *interp, XOTclObject *obj, char *name) { + XOTclAddObjectMethod(interp, (XOTcl_Object*) obj, name, (Tcl_ObjCmdProc*)XOTclSetterMethod, 0, 0, 0); + return TCL_OK; +} + +static int XOTclOProcMethod(Tcl_Interp *interp, XOTclObject *obj, Tcl_Obj *name, + Tcl_Obj *args, Tcl_Obj *body, + Tcl_Obj *precondition, Tcl_Obj *postcondition) { + char *argStr = ObjStr(args), *bdyStr = ObjStr(body), *nameStr = ObjStr(name); + int result; + + if (precondition && !postcondition) { + return XOTclVarErrMsg(interp, objectName(obj), " method '", nameStr, + "'; when specifying a precondition (", ObjStr(precondition), + ") a postcondition must be specified as well", + (char *) NULL); + } + + /* if both, args and body are empty strings, we delete the method */ + if (*argStr == 0 && *bdyStr == 0) { + result = XOTclRemovePMethod(interp, (XOTcl_Object *)obj, nameStr); + + } else { + XOTclAssertionStore *aStore = NULL; + if (precondition || postcondition) { + XOTclObjectOpt *opt = XOTclRequireObjectOpt(obj); + if (!opt->assertions) + opt->assertions = AssertionCreateStore(); + aStore = opt->assertions; + } + requireObjNamespace(interp, obj); + result = MakeProc2(obj->nsPtr, aStore, &(obj->nonposArgsTable), + interp, name, args, body, precondition, postcondition, + obj, 0); + } + + /* could be a filter => recompute filter order */ + FilterComputeDefined(interp, obj); + return result; +} + +static int XOTclOProcSearchMethod(Tcl_Interp *interp, XOTclObject *obj, char *name) { + XOTclClass *pcl = NULL; + Tcl_Command cmd = NULL; + + Tcl_ResetResult(interp); + + if (!(obj->flags & XOTCL_MIXIN_ORDER_VALID)) + MixinComputeDefined(interp, obj); + + if (obj->flags & XOTCL_MIXIN_ORDER_DEFINED_AND_VALID) { + XOTclCmdList *mixinList; + for (mixinList = obj->mixinOrder; mixinList; mixinList = mixinList->nextPtr) { + XOTclClass *mcl = XOTclpGetClass(interp, (char *)Tcl_GetCommandName(interp, mixinList->cmdPtr)); + if (mcl && (pcl = SearchCMethod(mcl, name, &cmd))) { + break; + } + } + } + + if (!cmd && obj->nsPtr) { + cmd = FindMethod(name, obj->nsPtr); + } + + if (!cmd && obj->cl) + pcl = SearchCMethod(obj->cl, name, &cmd); + + if (cmd) { + XOTclObject *pobj = pcl ? NULL : obj; + char *simpleName = (char *)Tcl_GetCommandName(interp, cmd); + Tcl_SetObjResult(interp, getFullProcQualifier(interp, simpleName, pobj, pcl, cmd)); + } + return TCL_OK; +} + +static int XOTclORequireNamespaceMethod(Tcl_Interp *interp, XOTclObject *obj) { + requireObjNamespace(interp, obj); + return TCL_OK; +} + +static int XOTclOSetMethod(Tcl_Interp *interp, XOTclObject *obj, Tcl_Obj *var, Tcl_Obj *value) { + return setInstVar(interp, obj, var, value); +} + +static int XOTclOSetvaluesMethod(Tcl_Interp *interp, XOTclObject *obj, int objc, Tcl_Obj *CONST objv[]) { + Tcl_Obj **argv, **nextArgv, *resultObj; + int i, argc, nextArgc, normalArgs, result = TCL_OK, isdasharg = NO_DASH; + char *methodName, *nextMethodName; + + /* find arguments without leading dash */ + for (i=1; i < objc; i++) { + if ((isdasharg = isDashArg(interp, objv[i], &methodName, &argc, &argv))) + break; + } + normalArgs = i-1; + Tcl_ResetResult(interp); + + for( ; i < objc; argc=nextArgc, argv=nextArgv, methodName=nextMethodName) { + Tcl_ResetResult(interp); + switch (isdasharg) { + case SKALAR_DASH: /* Argument is a skalar with a leading dash */ + { int j; + for (j = i+1; j < objc; j++, argc++) { + if ((isdasharg = isDashArg(interp, objv[j], &nextMethodName, &nextArgc, &nextArgv))) + break; + } + result = callConfigureMethod(interp, obj, methodName, argc+1, objv+i+1); + if (result != TCL_OK) { + return result; + } + i += argc; + break; + } + case LIST_DASH: /* Argument is a list with a leading dash, grouping determined by list */ + { i++; + if (iobj = obj; + XOTclAddPMethod(interp, (XOTcl_Object *)obj, NSTail(ObjStr(method)), + (Tcl_ObjCmdProc*)XOTclForwardMethod, + (ClientData)tcd, forwardCmdDeleteProc); + } + return rc; +} + +static int XOTclOUplevelMethod(Tcl_Interp *interp, XOTclObject *obj, int objc, Tcl_Obj *CONST objv[]) { + int i, result = TCL_ERROR; + char *frameInfo = NULL; + Tcl_CallFrame *framePtr = NULL, *savedVarFramePtr; + + /* + * Find the level to use for executing the command. + */ + if (objc>2) { + CallFrame *cf; + frameInfo = ObjStr(objv[1]); + result = TclGetFrame(interp, frameInfo, &cf); + if (result == -1) { + return TCL_ERROR; + } + framePtr = (Tcl_CallFrame *)cf; + i = result+1; + } else { + i = 1; + } + + objc -= i; + objv += i; + + if (!framePtr) { + XOTclCallStackContent *csc = XOTclCallStackFindLastInvocation(interp, 1); + if (csc) + framePtr = csc->currentFramePtr; + } + + savedVarFramePtr = (Tcl_CallFrame *)Tcl_Interp_varFramePtr(interp); + Tcl_Interp_varFramePtr(interp) = (CallFrame *)framePtr; + + /* + * Execute the residual arguments as a command. + */ + + if (objc == 1) { + result = Tcl_EvalObjEx(interp, objv[0], TCL_EVAL_DIRECT); + } else { + /* + * More than one argument: concatenate them together with spaces + * between, then evaluate the result. Tcl_EvalObjEx will delete + * the object when it decrements its refcount after eval'ing it. + */ + Tcl_Obj *objPtr = Tcl_ConcatObj(objc, objv); + result = Tcl_EvalObjEx(interp, objPtr, TCL_EVAL_DIRECT); + } + if (result == TCL_ERROR) { + char msg[32 + TCL_INTEGER_SPACE]; + sprintf(msg, "\n (\"uplevel\" body line %d)", interp->errorLine); + Tcl_AddObjErrorInfo(interp, msg, -1); + } + + /* + * Restore the variable frame, and return. + */ + + Tcl_Interp_varFramePtr(interp) = (CallFrame *)savedVarFramePtr; + return result; +} + +static int XOTclOUpvarMethod(Tcl_Interp *interp, XOTclObject *obj, int objc, Tcl_Obj *CONST objv[]) { + Tcl_Obj *frameInfoObj = NULL; + int i, result = TCL_ERROR; + char *frameInfo; + callFrameContext ctx = {0}; + + if (objc % 2 == 0) { + frameInfo = ObjStr(objv[1]); + i = 2; + } else { + frameInfoObj = computeLevelObj(interp, CALLING_LEVEL); + INCR_REF_COUNT(frameInfoObj); + frameInfo = ObjStr(frameInfoObj); + i = 1; + } + + if (obj && (obj->filterStack || obj->mixinStack)) { + CallStackUseActiveFrames(interp, &ctx); + } + + for ( ; i < objc; i += 2) { + result = Tcl_UpVar2(interp, frameInfo, ObjStr(objv[i]), NULL, + ObjStr(objv[i+1]), 0 /*flags*/); + if (result != TCL_OK) + break; + } + + if (frameInfoObj) { + DECR_REF_COUNT(frameInfoObj); + } + CallStackRestoreSavedFrames(interp, &ctx); + return result; +} + +static int XOTclOVolatileMethod(Tcl_Interp *interp, XOTclObject *obj) { + Tcl_Obj *o = obj->cmdName; + int result = TCL_ERROR; + CONST char *fullName = ObjStr(o); + CONST char *vn; + callFrameContext ctx = {0}; + + if (RUNTIME_STATE(interp)->exitHandlerDestroyRound != XOTCL_EXITHANDLER_OFF) { + fprintf(stderr,"### Can't make objects volatile during shutdown\n"); + return XOTclVarErrMsg(interp, "Can't make objects volatile during shutdown\n", NULL); + } + + CallStackUseActiveFrames(interp, &ctx); + vn = NSTail(fullName); + + if (Tcl_SetVar2(interp, vn, NULL, fullName, 0)) { + XOTclObjectOpt *opt = XOTclRequireObjectOpt(obj); + + /*fprintf(stderr,"### setting trace for %s\n", fullName);*/ + result = Tcl_TraceVar(interp, vn, TCL_TRACE_UNSETS, + (Tcl_VarTraceProc*)XOTclUnsetTrace, + (ClientData)o); + opt->volatileVarName = vn; + } + CallStackRestoreSavedFrames(interp, &ctx); + + if (result == TCL_OK) { + INCR_REF_COUNT(o); + } + return result; +} + +static int XOTclOVwaitMethod(Tcl_Interp *interp, XOTclObject *obj, char *varname) { + int done, foundEvent; + int flgs = TCL_TRACE_WRITES|TCL_TRACE_UNSETS; + XOTcl_FrameDecls; + + /* + * Make sure the var table exists and the varname is in there + */ + if (NSRequireVariableOnObj(interp, obj, varname, flgs) == 0) + return XOTclVarErrMsg(interp, "Can't lookup (and create) variable ", + varname, " on ", objectName(obj), (char *) NULL); + + XOTcl_PushFrame(interp, obj); + /* + * much of this is copied from Tcl, since we must avoid + * access with flag TCL_GLOBAL_ONLY ... doesn't work on + * obj->varTable vars + */ + if (Tcl_TraceVar(interp, varname, flgs, (Tcl_VarTraceProc *)VwaitVarProc, + (ClientData) &done) != TCL_OK) { + return TCL_ERROR; + } + done = 0; + foundEvent = 1; + while (!done && foundEvent) { + foundEvent = Tcl_DoOneEvent(TCL_ALL_EVENTS); + } + Tcl_UntraceVar(interp, varname, flgs, (Tcl_VarTraceProc *)VwaitVarProc, + (ClientData) &done); + XOTcl_PopFrame(interp, obj); + /* + * Clear out the interpreter's result, since it may have been set + * by event handlers. + */ + Tcl_ResetResult(interp); + + if (!foundEvent) { + return XOTclVarErrMsg(interp, "can't wait for variable '", varname, + "': would wait forever", (char *) NULL); + } + return TCL_OK; +} + + +/*************************** + * End Object Methods + ***************************/ + + +/*************************** * Begin Class Methods ***************************/ @@ -11254,7 +11493,7 @@ static int XOTclCDeallocMethod(Tcl_Interp *interp, XOTclClass *cl, Tcl_Obj *object) { XOTclObject *delobj; int rc; - + if (XOTclObjConvertObject(interp, object, &delobj) != TCL_OK) return XOTclVarErrMsg(interp, "Can't destroy object ", ObjStr(object), " that does not exist.", @@ -11331,11 +11570,10 @@ } static int XOTclCInstFilterGuardMethod(Tcl_Interp *interp, XOTclClass *cl, char *filter, Tcl_Obj *guard) { - XOTclCmdList *h; XOTclClassOpt *opt = cl->opt; if (opt && opt->instfilters) { - h = CmdListFindNameInList(interp, filter, opt->instfilters); + XOTclCmdList *h = CmdListFindNameInList(interp, filter, opt->instfilters); if (h) { if (h->clientData) GuardDel(h); @@ -11387,7 +11625,7 @@ mixin, " on ", className(cl), (char *) NULL); } -static int XOTclCInstParameterCmdMethod(Tcl_Interp *interp, XOTclClass *cl, char *name) { +static int XOTclCInstParametercmdMethod(Tcl_Interp *interp, XOTclClass *cl, char *name) { XOTclAddInstanceMethod(interp, (XOTcl_Class *)cl, name, (Tcl_ObjCmdProc*)XOTclSetterMethod, 0, 0, 0); return TCL_OK; } @@ -11409,106 +11647,7 @@ return makeMethod2(interp, cl, name, args, body, precondition, postcondition, 1); } -static void forwardCmdDeleteProc(ClientData clientData); /* TODO REMOVE ME LATER */ -static int -forwardProcessOptions2(Tcl_Interp *interp, Tcl_Obj *name, - Tcl_Obj *withDefault, int withEarlybinding, Tcl_Obj *withMethodprefix, - int withObjscope, Tcl_Obj *withOnerror, int withVerbose, - Tcl_Obj *target, int objc, Tcl_Obj * CONST objv[], - forwardCmdClientData **tcdp) { - forwardCmdClientData *tcd; - int i, rc = 0; - - tcd = NEW(forwardCmdClientData); - memset(tcd, 0, sizeof(forwardCmdClientData)); - - if (withDefault) { - tcd->subcommands = withDefault; - rc = Tcl_ListObjLength(interp, withDefault, &tcd->nr_subcommands); - INCR_REF_COUNT(tcd->subcommands); - } - if (withMethodprefix) { - tcd->prefix = withMethodprefix; - INCR_REF_COUNT(tcd->prefix); - } - if (withOnerror) { - tcd->onerror = withOnerror; - INCR_REF_COUNT(tcd->onerror); - } - tcd->objscope = withObjscope; - tcd->verbose = withVerbose; - tcd->needobjmap = 0; - tcd->cmdName = target; - /*fprintf(stderr, "...forwardprocess objc %d\n",objc);*/ - - for (i=0; ineedobjmap |= (*element == '%' && *(element+1) == '@'); - /* TODO simplify: cmdName not needed here */ - if (tcd->cmdName == NULL) { - tcd->cmdName = objv[i]; - } else if (tcd->args == NULL) { - tcd->args = Tcl_NewListObj(1, &objv[i]); - tcd->nr_args++; - INCR_REF_COUNT(tcd->args); - } else { - Tcl_ListObjAppendElement(interp, tcd->args, objv[i]); - tcd->nr_args++; - } - } - - if (!tcd->cmdName) { - tcd->cmdName = name; - } - - /*fprintf(stderr, "cmdName = %s, args = %s, # = %d\n", - ObjStr(tcd->cmdName), tcd->args?ObjStr(tcd->args):"NULL", tcd->nr_args);*/ - - if (tcd->objscope) { - /* when we evaluating objscope, and define ... - o forward append -objscope append - a call to - o append ... - would lead to a recursive call; so we add the appropriate namespace - */ - char *nameString = ObjStr(tcd->cmdName); - if (!isAbsolutePath(nameString)) { - tcd->cmdName = NameInNamespaceObj(interp, nameString, callingNameSpace(interp)); - /*fprintf(stderr,"name %s not absolute, therefore qualifying %s\n", name, - ObjStr(tcd->cmdName));*/ - } - } - INCR_REF_COUNT(tcd->cmdName); - - if (withEarlybinding) { - Tcl_Command cmd = Tcl_GetCommandFromObj(interp, tcd->cmdName); - if (cmd == NULL) - return XOTclVarErrMsg(interp, "cannot lookup command '", ObjStr(tcd->cmdName), "'", (char *) NULL); - - tcd->objProc = Tcl_Command_objProc(cmd); - if (tcd->objProc == XOTclObjDispatch /* don't do direct invoke on xotcl objects */ - || tcd->objProc == TclObjInterpProc /* don't do direct invoke on tcl procs */ - ) { - /* silently ignore earlybinding flag */ - tcd->objProc = NULL; - } else { - tcd->clientData = Tcl_Command_objClientData(cmd); - } - } - - tcd->passthrough = !tcd->args && *(ObjStr(tcd->cmdName)) != '%' && tcd->objProc; - - /*fprintf(stderr, "forward args = %p, name = '%s'\n", tcd->args, ObjStr(tcd->cmdName));*/ - if (rc == TCL_OK) { - *tcdp = tcd; - } else { - forwardCmdDeleteProc((ClientData)tcd); - } - return rc; -} - static int XOTclCInstForwardMethod(Tcl_Interp *interp, XOTclClass *cl, Tcl_Obj *method, Tcl_Obj *withDefault, int withEarlybinding, Tcl_Obj *withMethodprefix, int withObjscope, Tcl_Obj *withOnerror, int withVerbose, @@ -11670,9 +11809,9 @@ return object->opt ? GuardList(interp, object->opt->filters, filter) : TCL_OK; } -static int XOTclObjInfoForwardMethod(Tcl_Interp *interp, XOTclObject *object, int withDefinition, char *methodName) { +static int XOTclObjInfoForwardMethod(Tcl_Interp *interp, XOTclObject *object, int withDefinition, char *pattern) { return object->nsPtr ? - forwardList(interp, Tcl_Namespace_cmdTable(object->nsPtr), methodName, withDefinition) : + forwardList(interp, Tcl_Namespace_cmdTable(object->nsPtr), pattern, withDefinition) : TCL_OK; } @@ -11916,8 +12055,8 @@ } static int XOTclClassInfoInstforwardMethod(Tcl_Interp *interp, XOTclClass *class, - int withDefinition, char *methodName) { - return forwardList(interp, Tcl_Namespace_cmdTable(class->nsPtr), methodName, withDefinition); + int withDefinition, char *pattern) { + return forwardList(interp, Tcl_Namespace_cmdTable(class->nsPtr), pattern, withDefinition); } static int XOTclClassInfoInstinvarMethod(Tcl_Interp *interp, XOTclClass * class) { @@ -12107,20 +12246,6 @@ * End Class Info methods ***************************/ - - - -static int -XOTclCParameterCmdMethod(ClientData clientData, Tcl_Interp *interp, - int objc, Tcl_Obj *CONST objv[]) { - XOTclObject *obj = (XOTclObject*) clientData; - - if (objc < 2) return XOTclObjErrArgCnt(interp, obj->cmdName, objv[0], "name"); - XOTclAddObjectMethod(interp, (XOTcl_Object*) obj, ObjStr(objv[1]), - (Tcl_ObjCmdProc*)XOTclSetterMethod, 0, 0, 0); - return TCL_OK; -} - static void forwardCmdDeleteProc(ClientData clientData) { forwardCmdClientData *tcd = (forwardCmdClientData *)clientData; if (tcd->cmdName) {DECR_REF_COUNT(tcd->cmdName);} @@ -12131,319 +12256,6 @@ FREE(forwardCmdClientData, tcd); } -static int -forwardProcessOptions(Tcl_Interp *interp, int objc, Tcl_Obj * CONST objv[], - forwardCmdClientData **tcdp) { - forwardCmdClientData *tcd; - int i, rc = 0, earlybinding = 0; - - tcd = NEW(forwardCmdClientData); - memset(tcd, 0, sizeof(forwardCmdClientData)); - - for (i=2; isubcommands = objv[i+1]; - rc = Tcl_ListObjLength(interp, objv[i+1],&tcd->nr_subcommands); - if (rc != TCL_OK) break; - INCR_REF_COUNT(tcd->subcommands); - i++; - } else if (!strcmp(ObjStr(objv[i]),"-methodprefix")) { - if (objc <= i+1) {rc = TCL_ERROR; break;} - tcd->prefix = objv[i+1]; - INCR_REF_COUNT(tcd->prefix); - i++; - } else if (!strcmp(ObjStr(objv[i]),"-onerror")) { - if (objc <= i+1) {rc = TCL_ERROR; break;} - tcd->onerror = objv[i+1]; - INCR_REF_COUNT(tcd->onerror); - i++; - } else if (!strcmp(ObjStr(objv[i]),"-objscope")) { - tcd->objscope = 1; - } else if (!strcmp(ObjStr(objv[i]),"-earlybinding")) { - earlybinding = 1; - } else if (!strcmp(ObjStr(objv[i]),"-verbose")) { - tcd->verbose = 1; - } else { - /* todo protected */ - break; - } - } - - tcd->needobjmap = 0; - for (; ineedobjmap |= (*element == '%' && *(element+1) == '@'); - - if (tcd->cmdName == NULL) { - tcd->cmdName = objv[i]; - } else if (tcd->args == NULL) { - tcd->args = Tcl_NewListObj(1, &objv[i]); - tcd->nr_args++; - INCR_REF_COUNT(tcd->args); - } else { - Tcl_ListObjAppendElement(interp, tcd->args, objv[i]); - tcd->nr_args++; - } - } - - if (!tcd->cmdName) { - tcd->cmdName = objv[1]; - } - - if (tcd->objscope) { - /* when we evaluating objscope, and define ... - o forward append -objscope append - a call to - o append ... - would lead to a recursive call; so we add the appropriate namespace - */ - char *name = ObjStr(tcd->cmdName); - if (!isAbsolutePath(name)) { - tcd->cmdName = NameInNamespaceObj(interp, name, callingNameSpace(interp)); - /*fprintf(stderr,"name %s not absolute, therefore qualifying %s\n", name, - ObjStr(tcd->cmdName));*/ - } - } - INCR_REF_COUNT(tcd->cmdName); - - if (earlybinding) { - Tcl_Command cmd = Tcl_GetCommandFromObj(interp, tcd->cmdName); - if (cmd == NULL) - return XOTclVarErrMsg(interp, "cannot lookup command '", ObjStr(tcd->cmdName), "'", (char *) NULL); - - tcd->objProc = Tcl_Command_objProc(cmd); - if (tcd->objProc == XOTclObjDispatch /* don't do direct invoke on xotcl objects */ - || tcd->objProc == TclObjInterpProc /* don't do direct invoke on tcl procs */ - ) { - /* silently ignore earlybinding flag */ - tcd->objProc = NULL; - } else { - tcd->clientData = Tcl_Command_objClientData(cmd); - } - } - - tcd->passthrough = !tcd->args && *(ObjStr(tcd->cmdName)) != '%' && tcd->objProc; - - /*fprintf(stderr, "forward args = %p, name = '%s'\n", tcd->args, ObjStr(tcd->cmdName));*/ - if (rc == TCL_OK) { - *tcdp = tcd; - } else { - forwardCmdDeleteProc((ClientData)tcd); - } - return rc; -} - -static int -XOTclOForwardMethod(ClientData clientData, Tcl_Interp *interp, - int objc, Tcl_Obj * CONST objv[]) { - XOTcl_Object *obj = (XOTcl_Object*) clientData; - forwardCmdClientData *tcd; - int rc; - - if (!obj) return XOTclObjErrType(interp, objv[0], "Object"); - if (objc < 2) goto forward_argc_error; - - rc = forwardProcessOptions(interp, objc, objv, &tcd); - - if (rc == TCL_OK) { - tcd->obj = (XOTclObject*)obj; - XOTclAddPMethod(interp, obj, NSTail(ObjStr(objv[1])), - (Tcl_ObjCmdProc*)XOTclForwardMethod, - (ClientData)tcd, forwardCmdDeleteProc); - return TCL_OK; - } else { - forward_argc_error: - return XOTclObjErrArgCnt(interp, obj->cmdName, objv[0], - "method ?target? ?-default name? ?-objscope? ?-methodprefix string? ?args?"); - } -} - - -static int -XOTclOVolatileMethod(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj * CONST objv[]) { - XOTclObject *obj = (XOTclObject*) clientData; - Tcl_Obj *o = obj->cmdName; - int result = TCL_ERROR; - CONST char *fullName = ObjStr(o); - CONST char *vn; - callFrameContext ctx = {0}; - - if (objc != 1) - return XOTclObjErrArgCnt(interp, obj->cmdName, objv[0], NULL); - - if (RUNTIME_STATE(interp)->exitHandlerDestroyRound != XOTCL_EXITHANDLER_OFF) { - fprintf(stderr,"### Can't make objects volatile during shutdown\n"); - return XOTclVarErrMsg(interp, "Can't make objects volatile during shutdown\n", NULL); - } - - CallStackUseActiveFrames(interp, &ctx); - vn = NSTail(fullName); - - if (Tcl_SetVar2(interp, vn, NULL, fullName, 0)) { - XOTclObjectOpt *opt = XOTclRequireObjectOpt(obj); - - /*fprintf(stderr,"### setting trace for %s\n", fullName);*/ - result = Tcl_TraceVar(interp, vn, TCL_TRACE_UNSETS, - (Tcl_VarTraceProc*)XOTclUnsetTrace, - (ClientData)o); - opt->volatileVarName = vn; - } - CallStackRestoreSavedFrames(interp, &ctx); - - if (result == TCL_OK) { - INCR_REF_COUNT(o); - } - return result; -} - -static int -MakeProc2(Tcl_Namespace *ns, XOTclAssertionStore *aStore, Tcl_HashTable **nonposArgsTable, - Tcl_Interp *interp, - Tcl_Obj *name, Tcl_Obj *args, Tcl_Obj *body, Tcl_Obj *precondition, Tcl_Obj *postcondition, - XOTclObject *obj, int clsns) { - int result, haveNonposArgs = 0, argsc, i; - TclCallFrame frame, *framePtr = &frame; - Tcl_Obj *ov[4], **argsv; - Tcl_HashEntry *hPtr = NULL; - char *procName = ObjStr(name); - - if (*nonposArgsTable && (hPtr = XOTcl_FindHashEntry(*nonposArgsTable, procName))) { - NonposArgsDeleteHashEntry(hPtr); - } - - ov[0] = NULL; /*objv[0];*/ - ov[1] = name; - - /* see, if we have nonposArgs in the ordinary argument list */ - result = Tcl_ListObjGetElements(interp, args, &argsc, &argsv); - if (result != TCL_OK) { - return XOTclVarErrMsg(interp, "cannot break args into list: ", - ObjStr(args), (char *) NULL); - } - for (i=0; i 0) { - arg = ObjStr(npav[0]); - /* fprintf(stderr, "*** argparse1 arg='%s' rc=%d\n", arg, rc);*/ - if (*arg == '-') { - haveNonposArgs = 1; - continue; - } - } - break; - } - if (haveNonposArgs) { - int nrOrdinaryArgs = argsc - i; - Tcl_Obj *ordinaryArgs = Tcl_NewListObj(nrOrdinaryArgs, &argsv[i]); - Tcl_Obj *nonposArgs = Tcl_NewListObj(i, &argsv[0]); - INCR_REF_COUNT(ordinaryArgs); - INCR_REF_COUNT(nonposArgs); - result = parseNonposArgs(interp, procName, nonposArgs, ordinaryArgs, - nonposArgsTable, &haveNonposArgs); - DECR_REF_COUNT(ordinaryArgs); - DECR_REF_COUNT(nonposArgs); - if (result != TCL_OK) - return result; - } - - if (haveNonposArgs) { - ov[2] = XOTclGlobalObjects[XOTE_ARGS]; - ov[3] = addPrefixToBody(body, 1); - } else { /* no nonpos arguments */ - ov[2] = args; - ov[3] = addPrefixToBody(body, 0); - } - - Tcl_PushCallFrame(interp,(Tcl_CallFrame *)framePtr, ns, 0); - - result = Tcl_ProcObjCmd(0, interp, 4, ov) != TCL_OK; -#if defined(NAMESPACEINSTPROCS) - { - Proc *procPtr = TclFindProc((Interp *)interp, procName); - /*fprintf(stderr,"proc=%p cmd=%p ns='%s' objns=%s\n", procPtr, procPtr->cmdPtr, - procPtr->cmdPtr->nsPtr->fullName, cmd->nsPtr->fullName);*/ - /*** patch the command ****/ - if (procPtr) { - if (clsns) { - /* set the namespace of the method as inside of the class */ - if (!obj->nsPtr) { - makeObjNamespace(interp, obj); - } - /*fprintf(stderr,"obj %s\n", objectName(obj)); - fprintf(stderr,"ns %p obj->ns %p\n", ns, obj->nsPtr); - fprintf(stderr,"ns %s obj->ns %s\n", ns->fullName, obj->nsPtr->fullName);*/ - procPtr->cmdPtr->nsPtr = (Namespace*) obj->nsPtr; - } else { - /* set the namespace of the method to the same namespace the class has */ - procPtr->cmdPtr->nsPtr = ((Command *)obj->id)->nsPtr; - } - } - } -#endif - - Tcl_PopCallFrame(interp); - - if (precondition || postcondition) { - AssertionAddProc(interp, ObjStr(name), aStore, precondition, postcondition); - } - - DECR_REF_COUNT(ov[3]); - - return result; -} - -static int makeMethod2(Tcl_Interp *interp, XOTclClass *cl, Tcl_Obj *name, Tcl_Obj *args, Tcl_Obj *body, - Tcl_Obj *precondition, Tcl_Obj *postcondition, int clsns) { - XOTclClassOpt *opt = cl->opt; - int result = TCL_OK; - char *argStr = ObjStr(args), *bdyStr = ObjStr(body), *nameStr = ObjStr(name); - - if ((cl->object.flags & XOTCL_IS_ROOT_CLASS && isDestroyString(nameStr)) || - (cl->object.flags & XOTCL_IS_ROOT_META_CLASS && isDeallocString(nameStr)) || - (cl->object.flags & XOTCL_IS_ROOT_META_CLASS && isAllocString(nameStr)) || - (cl->object.flags & XOTCL_IS_ROOT_META_CLASS && isCreateString(nameStr))) - return XOTclVarErrMsg(interp, className(cl), " method '", nameStr, "' of ", - className(cl), " can not be overwritten. Derive a ", - "sub-class", (char *) NULL); - if (precondition && !postcondition) { - return XOTclVarErrMsg(interp, className(cl), " method '", nameStr, - "'; when specifying a precondition (", ObjStr(precondition), - ") a postcondition must be specified as well", - (char *) NULL); - } - - /* if both, args and body are empty strings, we delete the method */ - if (*argStr == 0 && *bdyStr == 0) { - result = XOTclRemoveIMethod(interp, (XOTcl_Class *)cl, nameStr); - } else { - XOTclAssertionStore *aStore = NULL; - if (precondition || postcondition) { - opt = XOTclRequireClassOpt(cl); - if (!opt->assertions) - opt->assertions = AssertionCreateStore(); - aStore = opt->assertions; - } - result = MakeProc2(cl->nsPtr, aStore, &(cl->nonposArgsTable), - interp, name, args, body, precondition, postcondition, - &cl->object, clsns); - } - - /* could be a filter or filter inheritance ... update filter orders */ - FilterInvalidateObjOrders(interp, cl); - - return result; -} - - - - - /* * New Tcl Commands */ @@ -13827,35 +13639,35 @@ }; methodDefinition definitions1[] = { - {"autoname", XOTclOAutonameMethod}, - {"check", XOTclOCheckMethod}, - {"cleanup", XOTclOCleanupMethod}, - {"configure", XOTclOConfigureMethod}, - {"destroy", XOTclODestroyMethod}, - {"exists", XOTclOExistsMethod}, - {"filterguard", XOTclOFilterGuardMethod}, - {"filtersearch", XOTclOFilterSearchMethod}, - {"instvar", XOTclOInstVarMethod}, - {"invar", XOTclOInvariantsMethod}, - {"isclass", XOTclOIsClassMethod}, - {"ismetaclass", XOTclOIsMetaClassMethod}, - {"isobject", XOTclOIsObjectMethod}, - {"istype", XOTclOIsTypeMethod}, - {"ismixin", XOTclOIsMixinMethod}, - {"mixinguard", XOTclOMixinGuardMethod}, - {"__next", XOTclONextMethod}, - {"noinit", XOTclONoinitMethod}, - {"parametercmd", XOTclCParameterCmdMethod}, - {"proc", XOTclOProcMethod}, - {"procsearch", XOTclOProcSearchMethod}, - {"requireNamespace", XOTclORequireNamespaceMethod}, - {"set", XOTclOSetMethod}, /***??**/ - {"setvalues", XOTclOSetvaluesMethod}, - {"forward", XOTclOForwardMethod}, - {"uplevel", XOTclOUplevelMethod}, - {"upvar", XOTclOUpvarMethod}, - {"volatile", XOTclOVolatileMethod}, - {"vwait", XOTclOVwaitMethod} + {"autoname", XOTclOAutonameMethodStub}, + {"check", XOTclOCheckMethodStub}, + {"cleanup", XOTclOCleanupMethodStub}, + {"configure", XOTclOConfigureMethodStub}, + {"destroy", XOTclODestroyMethodStub}, + {"exists", XOTclOExistsMethodStub}, + {"filterguard", XOTclOFilterGuardMethodStub}, + {"filtersearch", XOTclOFilterSearchMethodStub}, + {"instvar", XOTclOInstVarMethodStub}, + {"invar", XOTclOInvariantsMethodStub}, + {"isclass", XOTclOIsClassMethodStub}, + {"ismetaclass", XOTclOIsMetaClassMethodStub}, + {"ismixin", XOTclOIsMixinMethodStub}, + {"isobject", XOTclOIsObjectMethodStub}, + {"istype", XOTclOIsTypeMethodStub}, + {"mixinguard", XOTclOMixinGuardMethodStub}, + {"__next", XOTclONextMethodStub}, + {"noinit", XOTclONoinitMethodStub}, + {"parametercmd", XOTclOParametercmdMethodStub}, + {"proc", XOTclOProcMethodStub}, + {"procsearch", XOTclOProcSearchMethodStub}, + {"requireNamespace", XOTclORequireNamespaceMethodStub}, + {"set", XOTclOSetMethodStub}, /***??**/ + {"setvalues", XOTclOSetvaluesMethodStub}, + {"forward", XOTclOForwardMethodStub}, + {"uplevel", XOTclOUplevelMethodStub}, + {"upvar", XOTclOUpvarMethodStub}, + {"volatile", XOTclOVolatileMethodStub}, + {"vwait", XOTclOVwaitMethodStub} }; methodDefinition definitions2[] = { @@ -13866,7 +13678,7 @@ {"instfilterguard", XOTclCInstFilterGuardMethodStub}, {"instinvar", XOTclCInvariantsMethodStub}, {"instmixinguard", XOTclCInstMixinGuardMethodStub}, - {"instparametercmd", XOTclCInstParameterCmdMethodStub}, + {"instparametercmd", XOTclCInstParametercmdMethodStub}, {"instproc", XOTclCInstProcMethodStub}, {"classscopedinstproc", XOTclCInstProcMethodCStub}, {"instforward", XOTclCInstForwardMethodStub}, Index: tests/object-system.xotcl =================================================================== diff -u -rf209c50ea8cb651d0dea25206301e45202217797 -r200940690a99e5cd234e83fe6acc234477bf879c --- tests/object-system.xotcl (.../object-system.xotcl) (revision f209c50ea8cb651d0dea25206301e45202217797) +++ tests/object-system.xotcl (.../object-system.xotcl) (revision 200940690a99e5cd234e83fe6acc234477bf879c) @@ -7,7 +7,7 @@ # since even class Test might not work at that time. # proc ? {cmd expected {msg ""}} { - #puts "??? $cmd" + puts "??? $cmd" set r [uplevel $cmd] if {$msg eq ""} {set msg $cmd} if {$r ne $expected} { Index: tests/testx.xotcl =================================================================== diff -u -rc990d14157d8434cd5b1ee5f45aa43f82cb911b5 -r200940690a99e5cd234e83fe6acc234477bf879c --- tests/testx.xotcl (.../testx.xotcl) (revision c990d14157d8434cd5b1ee5f45aa43f82cb911b5) +++ tests/testx.xotcl (.../testx.xotcl) (revision 200940690a99e5cd234e83fe6acc234477bf879c) @@ -1651,14 +1651,15 @@ A create a0 a0 proc f3 {} {puts hu} a0 forward f4 puts hu - a0 parametercmd f6 puts hu + a0 parametercmd f6 ::errorCheck [a0 procsearch f1] "::A instproc f1" procsearch-1 ::errorCheck [a0 procsearch f2] "::A instforward f2" procsearch-2 ::errorCheck [a0 procsearch f3] "::a0 proc f3" procsearch-3 ::errorCheck [a0 procsearch f4] "::a0 forward f4" procsearch-4 ::errorCheck [a0 procsearch f5] "::A instparametercmd f5" procsearch-4 ::errorCheck [a0 procsearch f6] "::a0 parametercmd f6" procsearch-6 ::errorCheck [a0 procsearch set] "::xotcl::Object instcmd set" procsearch-6 + ::errorCheck [catch {a0 parametercmd f6 puts}] 1 "paramtercmd with wrong args returns error" set mixinResult "" i4 moveAgent 5 6 @@ -3137,7 +3138,6 @@ Class ::AAA } - for {set i 1} {$i < 20} {incr i} { # "reference to xotcl object in instvar" Class LexxTreeMounter @@ -3159,6 +3159,7 @@ } next } + set x [LexxTreeMounter new] set x [LexxTreeMounter new] @@ -3184,7 +3185,8 @@ #puts r=$r return $r } - Class O -superclass UnknownClass + Class O -superclass UnknownClass + ::errorCheck $::utest ::UnknownClass "__unknown 1" Object o @@ -3200,7 +3202,6 @@ ::errorCheck [o mixin XX3] ::XX3 "__unknown XX3" } - # this version of unknown creates gobal objects Class proc __unknown {name} { #puts "unkown called with $name" @@ -3243,6 +3244,7 @@ Class C Class D -superclass C Class E -superclass D -parameter {{x 1}} + E instproc t {a b {c 1}} {return ok} E proc p {a b {c 1}} {return ok} E instproc q {} {return [self proc]} @@ -3788,17 +3790,14 @@ o proc x {a b} { return "$a $b" } - o proc x {} {a b} { - return "$a $b" - } - o proc y {-x {-a {1 2 3}}} {a b} { + o proc y {-x {-a {1 2 3}} a b} { return "$args" } - o proc z1 {-x:required {-a {1 2 3}}} {a args} { + o proc z1 {-x:required {-a {1 2 3}} a args} { return "$x -- $args" } - o proc z2 {-x:required {-a {1 }} {-b {1 2}}} {args} {return "$x -- $args -- $a -- $b"} - o proc z3 {-b:boolean} {arg} { + o proc z2 {-x:required {-a {1 }} {-b {1 2}} args} {return "$x -- $args -- $a -- $b"} + o proc z3 {-b:boolean arg} { return "$b $arg" } Object colorchecker @@ -3809,9 +3808,12 @@ lappend ::r "reddish <$var> <$value>" } - o proc z4 {{{-b: required, checkobj colorchecker,color, reddish, - checkobj xotcl::nonposArgs,required} red} - {{-c: required }}} {arg} { + o proc z4 { + {{-b: required, checkobj colorchecker,color, reddish, + checkobj xotcl::nonposArgs,required} red} + {{-c: required }} + arg + } { lappend ::r "$b $arg" return "$b $arg" } @@ -3887,13 +3889,13 @@ Object o - o proc foo {{-a apple}} {{b banana}} { + o proc foo {{-a apple} {b banana}} { return [list [info locals] a: $a b: $b] } - o proc foo2 {{-a apple}} {{b banana} {c apple}} { + o proc foo2 {{-a apple} {b banana} {c apple}} { return [list [info locals] a: $a b: $b c: $c] } - o proc foo3 {{-a apple}} {x y {b banana} {c apple}} { + o proc foo3 {{-a apple} x y {b banana} {c apple}} { return [list [info locals] x: $x y: $y a: $a b: $b c: $c] } @@ -3912,7 +3914,7 @@ "non pos + default values 6" Object o - o proc foo {{-foo 1}} {} { + o proc foo {{-foo 1}} { #puts "foo: $foo" } o foo @@ -3921,7 +3923,7 @@ errorCheck $msg "Non positional arg '-foo': value missing" "Empty non-pos arg" Object oa - oa proc foo {{-a A}} {b} { + oa proc foo {{-a A} b} { #puts "$a $b" } oa foo "B"