Index: TODO =================================================================== diff -u -r8db56ce1f1dff5e22768c59df1b9039e961c6267 -rdd7a26337aa9aec3e0a06d2137ee7e708a8e1a9a --- TODO (.../TODO) (revision 8db56ce1f1dff5e22768c59df1b9039e961c6267) +++ TODO (.../TODO) (revision dd7a26337aa9aec3e0a06d2137ee7e708a8e1a9a) @@ -2128,7 +2128,23 @@ C-defined cmds, when a nonpos-arg gets no arguments - updated regression test +- added experimental ::nsf::proc for realization of procs with next + scripting argument passing. These nsf::procs improve the + orthogonality of the code (using e.g. nonpos args and value checker + for procs) and allows the same introspection interface (info method + parameter|parametersyntax, ...) + TODO: + +- nsf::proc + * scripted method like implementation + * toplevel introspection + * support for serialization in aolserver + * regression tests + * uplevel etc. semantics + * reduce verbosity + * memleak testing + - "info method definition" for attributes? - check performance implications of value conflict checker Index: generic/gentclAPI.decls =================================================================== diff -u -rbc9126dba8c73fbe5964faa34e8f11c23184b93e -rdd7a26337aa9aec3e0a06d2137ee7e708a8e1a9a --- generic/gentclAPI.decls (.../gentclAPI.decls) (revision bc9126dba8c73fbe5964faa34e8f11c23184b93e) +++ generic/gentclAPI.decls (.../gentclAPI.decls) (revision dd7a26337aa9aec3e0a06d2137ee7e708a8e1a9a) @@ -96,11 +96,18 @@ {-argName "-per-object"} {-argName "-public"} {-argName "methodName" -required 1 -type tclobj} - {-argName "args" -required 1 -type tclobj} + {-argName "arguments" -required 1 -type tclobj} {-argName "body" -required 1 -type tclobj} {-argName "-precondition" -nrargs 1 -type tclobj} {-argName "-postcondition" -nrargs 1 -type tclobj} } + +nsfCmd proc NsfProcCmd { + {-argName "methodName" -required 1 -type tclobj} + {-argName "arguments" -required 1 -type tclobj} + {-argName "body" -required 1 -type tclobj} +} + nsfCmd methodproperty NsfMethodPropertyCmd { {-argName "object" -required 1 -type object} {-argName "-per-object"} Index: generic/nsf.c =================================================================== diff -u -r89c35cdde49d7be07d3b34a072e7c05357a9ee08 -rdd7a26337aa9aec3e0a06d2137ee7e708a8e1a9a --- generic/nsf.c (.../nsf.c) (revision 89c35cdde49d7be07d3b34a072e7c05357a9ee08) +++ generic/nsf.c (.../nsf.c) (revision dd7a26337aa9aec3e0a06d2137ee7e708a8e1a9a) @@ -8249,8 +8249,9 @@ INCR_REF_COUNT(resultBody); - if (paramDefs && paramPtr->possibleUnknowns > 0) + if (paramDefs && paramPtr->possibleUnknowns > 0) { Tcl_AppendStringsToObj(resultBody, "::nsf::__unset_unknown_args\n", (char *) NULL); + } Tcl_AppendStringsToObj(resultBody, ObjStr(body), (char *) NULL); return resultBody; @@ -9031,14 +9032,14 @@ INCR_REF_COUNT(ov[2]); /*fprintf(stderr, "final arglist = <%s>\n", ObjStr(argList)); */ ov[3] = AddPrefixToBody(body, 1, &parsedParam); - } else { /* no nonpos arguments */ + } else { /* no parameter handling needed */ ov[2] = args; ov[3] = AddPrefixToBody(body, 0, &parsedParam); } Tcl_PushCallFrame(interp, (Tcl_CallFrame *)framePtr, nsPtr, 0); /* create the method in the provided namespace */ - result = Tcl_ProcObjCmd(0, interp, 4, ov) != TCL_OK; + result = Tcl_ProcObjCmd(0, interp, 4, ov); if (result == TCL_OK) { /* retrieve the defined proc */ Proc *procPtr = FindProcMethod(nsPtr, methodName); @@ -9144,7 +9145,200 @@ return result; } +/************************************************************************** + * Begin Definition of Parameter procs (Tcl Procs with Parameter handling) + **************************************************************************/ +/// xxxx +typedef struct NsfProcClientData { + Tcl_Obj *procName; + NsfParamDefs *paramDefs; +} NsfProcClientData; + +/* + *---------------------------------------------------------------------- + * NsfProcStubDeleteProc -- + * + * Tcl_CmdDeleteProc for NsfProcStubs. Is called, whenever a + * NsfProcStub is deleted and frees the associated client data. + * + * Results: + * None. + * + * Side effects: + * Frees clientdata + * + *---------------------------------------------------------------------- + */ +static void +NsfProcStubDeleteProc(ClientData clientData) { + NsfProcClientData *tcd = clientData; + + /*fprintf(stderr, "NsfProcStubDeleteProc received %p\n", clientData); + fprintf(stderr, "... procName %s paramDefs %p\n", ObjStr(tcd->procName), tcd->paramDefs);*/ + + DECR_REF_COUNT(tcd->procName); + /* ParamDefsFree(tcd->paramDefs); */ /* seems not neccessary */ + FREE(NsfProcClientData, tcd); +} + +/* + *---------------------------------------------------------------------- + * NsfProcStub -- + * + * Tcl_ObjCmdProc implementing Proc Stubs. This function processes + * the argument list in accordance with the parameter definitions + * and calls in case of success the shadowed proc. + * + * Results: + * Tcl return code. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ static int +NsfProcStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { + NsfProcClientData *tcd = clientData; + int result; + + assert(tcd); + fprintf(stderr, "NsfProcStub %s is called, tcd %p\n", ObjStr(objv[0]), tcd); + + if (tcd->paramDefs && tcd->paramDefs->paramsPtr) { + ParseContext *pcPtr = (ParseContext *) NsfTclStackAlloc(interp, sizeof(ParseContext), "parse context"); + ALLOC_ON_STACK(Tcl_Obj*, objc, tov); + + /* + * We have to substitute the the first element of objv with the + * name of the function to be called. Since objv is immutable, we + * have to copy the full argument vector and replace the element + * on position [0] + */ + memcpy(tov+1, objv+1, sizeof(Tcl_Obj *)*(objc-1)); + tov[0] = tcd->procName; + + /* If the argument passing is ok, the shadowed proc is called */ + result = ProcessMethodArguments(pcPtr, interp, NULL, 1, + tcd->paramDefs, ObjStr(objv[0]), + objc, tov); + + if (result == TCL_OK) { + /* + * For the time being, we call the shadowed proc defined with a + * mutated name. It should be possible to compile and call the + * proc body directly, similar as for scripted methods. + * + * TODO: check implications with NRE and Tcl 8.6, maybe a + * finalize function is needed as well. + */ + fprintf(stderr, "NsfProcStub: call proc arguments oc %d [0] '%s' \n", + pcPtr->objc, ObjStr(pcPtr->full_objv[0])); + result = Tcl_EvalObjv(interp, pcPtr->objc, pcPtr->full_objv, 0); + + + } else { + fprintf(stderr, "NsfProcStub: incorrect arguments\n"); + } + + ParseContextRelease(pcPtr); + NsfTclStackFree(interp, pcPtr, "release parse context"); + FREE_ON_STACK(Tcl_Obj *, ov); + } else { + fprintf(stderr, "no parameters\n"); + assert(0); /* should never happen */ + result = TCL_ERROR; + } + return result; +} + +/* + *---------------------------------------------------------------------- + * NsfAddParameterProc -- + * + * Add a command for implementing a Tcl proc with next scripting + * parameter handling. + * + * For the time being, this function adds two things, (a) a Tcl cmd + * functioning as a stub for the argument processing (in accordance + * with the parameter definitions) and (b) the shadowed Tcl proc + * with a mutated name. The latter might not be necessary, when we + * handle this in a style like for scriped methods. + * + * TODO: the current 1 cmd + 1 proc implemtnation is not robust + * against renaming and partial deletions (deletion of the + * stub). The sketched variant should be better and should be + * exampined first in detail. + * + * Results: + * Tcl return code. + * + * Side effects: + * Adding 1 Tcl and and 1 Tcl proc + * + *---------------------------------------------------------------------- + */ +static int +NsfAddParameterProc(Tcl_Interp *interp, NsfParsedParam *parsedParamPtr, + CONST char *methodName, Tcl_Obj *body) { + Tcl_Obj *procNameObj = Tcl_NewStringObj(methodName, -1); + NsfParamDefs *paramDefs = parsedParamPtr->paramDefs; + NsfProcClientData *tcd = NEW(NsfProcClientData); + Tcl_Obj *argList = Tcl_NewListObj(0, NULL); + NsfParam *pPtr; + Tcl_Obj *ov[4]; + int result; + + /* The name of the shadowed Tcl proc is the original name, with a special suffix */ + Tcl_AppendToObj(procNameObj, "__#", 3); + tcd->procName = procNameObj; /* well be freed, when NsfProcStub is deleted */ + tcd->paramDefs = paramDefs; + + fprintf(stderr, "NsfAddParameterProc %s tcd %p paramdefs %p\n", methodName, tcd, tcd->paramDefs); + + for (pPtr = paramDefs->paramsPtr; pPtr->name; pPtr++) { + if (*pPtr->name == '-') { + Tcl_ListObjAppendElement(interp, argList, Tcl_NewStringObj(pPtr->name+1, -1)); + } else { + Tcl_ListObjAppendElement(interp, argList, Tcl_NewStringObj(pPtr->name, -1)); + } + } + ov[0] = NULL; + ov[1] = procNameObj; + ov[2] = argList; + ov[3] = AddPrefixToBody(body, 1, parsedParamPtr); + + INCR_REF_COUNT(ov[1]); + INCR_REF_COUNT(ov[2]); + + fprintf(stderr, "NsfAddParameterProc define proc %s arglist '%s'\n", ObjStr(ov[1]), ObjStr(ov[2])); + result = Tcl_ProcObjCmd(0, interp, 4, ov); + + if (result == TCL_OK) { + Tcl_Command cmd = Tcl_CreateObjCommand(interp, methodName, NsfProcStub, + tcd, NsfProcStubDeleteProc); + if (cmd) { + fprintf(stderr, "NsfAddParameterProc define cmd %s::%s %p\n", + ((Command *)cmd)->nsPtr->fullName, + Tcl_GetCommandName(interp, cmd), cmd); + ParamDefsStore(interp, cmd, paramDefs); + } else { + /* free tcd and its content */ + NsfProcStubDeleteProc(tcd); + } + } + + DECR_REF_COUNT(ov[2]); + DECR_REF_COUNT(ov[3]); + + return result; +} +/************************************************************************** + * End Definition of Parameter procs (Tcl Procs with Parameter handling) + **************************************************************************/ + + +static int GetMatchObject(Tcl_Interp *interp, Tcl_Obj *patternObj, Tcl_Obj *origObj, NsfObject **matchObject, CONST char **pattern) { if (patternObj) { @@ -12522,6 +12716,7 @@ return listObj; } +// TODO enum style /* *---------------------------------------------------------------------- @@ -12543,135 +12738,140 @@ static int ListCmdParams(Tcl_Interp *interp, Tcl_Command cmd, CONST char *methodName, int withVarnames) { - Proc *procPtr = GetTclProcFromCommand(cmd); + NsfParamDefs *paramDefs; + Tcl_Obj *list; + Proc *procPtr; assert(methodName); + assert(cmd); - if (procPtr) { - NsfParamDefs *paramDefs = procPtr ? ParamDefsGet((Tcl_Command)procPtr->cmdPtr) : NULL; - Tcl_Obj *list; + paramDefs = ParamDefsGet(cmd); - if (paramDefs && paramDefs->paramsPtr) { - /* - * Obtain parameter info from paramDefs - */ - list = ListParamDefs(interp, paramDefs->paramsPtr, withVarnames); + if (paramDefs && paramDefs->paramsPtr) { + /* + * Obtain parameter info from paramDefs + */ + list = ListParamDefs(interp, paramDefs->paramsPtr, withVarnames); + Tcl_SetObjResult(interp, list); + return TCL_OK; + } - } else { - /* - * Obtain parameter info from compiled locals - */ - CompiledLocal *args = procPtr->firstLocalPtr; - - list = Tcl_NewListObj(0, NULL); - for ( ; args; args = args->nextPtr) { - Tcl_Obj *innerlist; - - if (!TclIsCompiledLocalArgument(args)) { - continue; - } - - if (withVarnames == 2 && strcmp(args->name, "args") == 0) { - if (args != procPtr->firstLocalPtr) { - Tcl_AppendToObj(list, " ", 1); - } - Tcl_AppendToObj(list, "?arg ...?", 9); - } else { - innerlist = Tcl_NewListObj(0, NULL); - Tcl_ListObjAppendElement(interp, innerlist, Tcl_NewStringObj(args->name, -1)); - if (!withVarnames && args->defValuePtr) { - Tcl_ListObjAppendElement(interp, innerlist, args->defValuePtr); - } - Tcl_ListObjAppendElement(interp, list, innerlist); - } + procPtr = GetTclProcFromCommand(cmd); + if (procPtr) { + /* + * Obtain parameter info from compiled locals + */ + CompiledLocal *args = procPtr->firstLocalPtr; + + list = Tcl_NewListObj(0, NULL); + for ( ; args; args = args->nextPtr) { + Tcl_Obj *innerlist; + + if (!TclIsCompiledLocalArgument(args)) { + continue; } + + if (withVarnames == 2 && strcmp(args->name, "args") == 0) { + if (args != procPtr->firstLocalPtr) { + Tcl_AppendToObj(list, " ", 1); + } + Tcl_AppendToObj(list, "?arg ...?", 9); + } else { + innerlist = Tcl_NewListObj(0, NULL); + Tcl_ListObjAppendElement(interp, innerlist, Tcl_NewStringObj(args->name, -1)); + if (!withVarnames && args->defValuePtr) { + Tcl_ListObjAppendElement(interp, innerlist, args->defValuePtr); + } + Tcl_ListObjAppendElement(interp, list, innerlist); + } } Tcl_SetObjResult(interp, list); return TCL_OK; + } - } else if (cmd) { + { /* * If a command is found for the object|class, check whether we * find the parameter definitions for the C-defined method. */ methodDefinition *mdPtr = &method_definitions[0]; - + for (; mdPtr->methodName; mdPtr ++) { - + /*fprintf(stderr, "... comparing %p with %p => %s\n", ((Command *)cmd)->objProc, mdPtr->proc, mdPtr->methodName);*/ - + if (((Command *)cmd)->objProc == mdPtr->proc) { - NsfParamDefs paramDefs = {mdPtr->paramDefs, mdPtr->nrParameters}; + NsfParamDefs paramDefs = {mdPtr->paramDefs, mdPtr->nrParameters}; Tcl_Obj *list = ListParamDefs(interp, paramDefs.paramsPtr, withVarnames); - - Tcl_SetObjResult(interp, list); - return TCL_OK; - } - } - - if (((Command *)cmd)->objProc == NsfSetterMethod) { - SetterCmdClientData *cd = (SetterCmdClientData *)Tcl_Command_objClientData(cmd); - if (cd->paramsPtr) { - Tcl_Obj *list; - NsfParamDefs paramDefs; - paramDefs.paramsPtr = cd->paramsPtr; - paramDefs.nrParams = 1; - paramDefs.slotObj = NULL; - list = ListParamDefs(interp, paramDefs.paramsPtr, withVarnames); - Tcl_SetObjResult(interp, list); - return TCL_OK; - } else { - Tcl_SetObjResult(interp, Tcl_NewStringObj(methodName, -1)); - return TCL_OK; - } - } - - /* - * In case, we failed so far to obtain a result, try to use the - * object-system implementors definitions in the gobal array - * ::nsf::parametersyntax. Note that we can only obtain the - * parametersyntax this way. - */ - if (withVarnames == 2) { - Command *cmdPtr = (Command *)cmd; - Tcl_DString ds, *dsPtr = &ds; - Tcl_Obj *parameterSyntaxObj; - - Tcl_DStringInit(dsPtr); - if (strcmp("::", cmdPtr->nsPtr->fullName) != 0) { - Tcl_DStringAppend(dsPtr, cmdPtr->nsPtr->fullName, -1); - } - Tcl_DStringAppend(dsPtr, "::", 2); - Tcl_DStringAppend(dsPtr, methodName, -1); - - /*fprintf(stderr,"Looking up ::nsf::parametersyntax(%s) ...\n",Tcl_DStringValue(dsPtr));*/ - parameterSyntaxObj = Tcl_GetVar2Ex(interp, "::nsf::parametersyntax", - Tcl_DStringValue(dsPtr), TCL_GLOBAL_ONLY); - - /*fprintf(stderr, "No parametersyntax so far methodname %s cmd name %s ns %s\n", - methodName, Tcl_GetCommandName(interp,cmd), Tcl_DStringValue(dsPtr));*/ - - Tcl_DStringFree(dsPtr); - if (parameterSyntaxObj) { - Tcl_SetObjResult(interp, parameterSyntaxObj); + + Tcl_SetObjResult(interp, list); return TCL_OK; } } - - if (((Command *)cmd)->objProc == NsfForwardMethod) { - return NsfPrintError(interp, "info params: could not obtain parameter definition for forwarder '%s'", - methodName); - } else if (((Command *)cmd)->objProc != NsfObjDispatch) { - return NsfPrintError(interp, "info params: could not obtain parameter definition for method '%s'", - methodName); + } + + if (((Command *)cmd)->objProc == NsfSetterMethod) { + SetterCmdClientData *cd = (SetterCmdClientData *)Tcl_Command_objClientData(cmd); + if (cd->paramsPtr) { + Tcl_Obj *list; + NsfParamDefs paramDefs; + paramDefs.paramsPtr = cd->paramsPtr; + paramDefs.nrParams = 1; + paramDefs.slotObj = NULL; + list = ListParamDefs(interp, paramDefs.paramsPtr, withVarnames); + Tcl_SetObjResult(interp, list); + return TCL_OK; } else { - /* procPtr == NsfObjDispatch, be quiet */ + Tcl_SetObjResult(interp, Tcl_NewStringObj(methodName, -1)); return TCL_OK; } } + /* + * In case, we failed so far to obtain a result, try to use the + * object-system implementors definitions in the gobal array + * ::nsf::parametersyntax. Note that we can only obtain the + * parametersyntax this way. + */ + if (withVarnames == 2) { + Command *cmdPtr = (Command *)cmd; + Tcl_DString ds, *dsPtr = &ds; + Tcl_Obj *parameterSyntaxObj; + + Tcl_DStringInit(dsPtr); + if (strcmp("::", cmdPtr->nsPtr->fullName) != 0) { + Tcl_DStringAppend(dsPtr, cmdPtr->nsPtr->fullName, -1); + } + Tcl_DStringAppend(dsPtr, "::", 2); + Tcl_DStringAppend(dsPtr, methodName, -1); + + /*fprintf(stderr,"Looking up ::nsf::parametersyntax(%s) ...\n",Tcl_DStringValue(dsPtr));*/ + parameterSyntaxObj = Tcl_GetVar2Ex(interp, "::nsf::parametersyntax", + Tcl_DStringValue(dsPtr), TCL_GLOBAL_ONLY); + + /*fprintf(stderr, "No parametersyntax so far methodname %s cmd name %s ns %s\n", + methodName, Tcl_GetCommandName(interp,cmd), Tcl_DStringValue(dsPtr));*/ + + Tcl_DStringFree(dsPtr); + if (parameterSyntaxObj) { + Tcl_SetObjResult(interp, parameterSyntaxObj); + return TCL_OK; + } + } + + if (((Command *)cmd)->objProc == NsfForwardMethod) { + return NsfPrintError(interp, "info params: could not obtain parameter definition for forwarder '%s'", + methodName); + } else if (((Command *)cmd)->objProc != NsfObjDispatch) { + return NsfPrintError(interp, "info params: could not obtain parameter definition for method '%s'", + methodName); + } else { + /* procPtr == NsfObjDispatch, be quiet */ + return TCL_OK; + } + { Tcl_Obj *methodObj = Tcl_NewStringObj(methodName, -1); INCR_REF_COUNT(methodObj); @@ -14296,7 +14496,7 @@ {-argName "-per-object"} {-argName "-public"} {-argName "name" -required 1 -type tclobj} - {-argName "args" -required 1 -type tclobj} + {-argName "arguments" -required 1 -type tclobj} {-argName "body" -required 1 -type tclobj} {-argName "-precondition" -nrargs 1 -type tclobj} {-argName "-postcondition" -nrargs 1 -type tclobj} @@ -14305,7 +14505,7 @@ static int NsfMethodCmd(Tcl_Interp *interp, NsfObject *object, int withInner_namespace, int withPer_object, int withPublic, - Tcl_Obj *nameObj, Tcl_Obj *args, Tcl_Obj *body, + Tcl_Obj *nameObj, Tcl_Obj *arguments, Tcl_Obj *body, Tcl_Obj *withPrecondition, Tcl_Obj *withPostcondition) { NsfClass *cl = (withPer_object || ! NsfObjectIsClass(object)) ? @@ -14314,7 +14514,7 @@ if (cl == 0) { RequireObjNamespace(interp, object); } - return MakeMethod(interp, object, cl, nameObj, args, body, + return MakeMethod(interp, object, cl, nameObj, arguments, body, withPrecondition, withPostcondition, withPublic, withInner_namespace); } @@ -14827,6 +15027,51 @@ } /* +nsfCmd proc NsfProcCmd { + {-argName "methodName" -required 1 -type tclobj} + {-argName "arguments" -required 1 -type tclobj} + {-argName "body" -required 1 -type tclobj} +} +*/ +static int +NsfProcCmd(Tcl_Interp *interp, Tcl_Obj *nameObj, Tcl_Obj *arguments, Tcl_Obj *body) { + NsfParsedParam parsedParam; + int result; + + /* + * Parse argument list "arguments" to determine if we should provide + * nsf parameter handling. + */ + result = ParamDefsParse(interp, nameObj, arguments, NSF_DISALLOWED_ARG_METHOD_PARAMETER, &parsedParam); + if (result != TCL_OK) { + return result; + } + + if (parsedParam.paramDefs) { + /* + * We need parameter handling. In such cases, a thin C-based layer + * is added which handles the parameter passing and calls the proc + * later. + */ + result = NsfAddParameterProc(interp, &parsedParam, ObjStr(nameObj), body); + + } else { + /* + * No parameter handling needed. A plain Tcl proc is added. + */ + Tcl_Obj *ov[4]; + + ov[0] = NULL; + ov[1] = nameObj; + ov[2] = arguments; + ov[3] = body; + result = Tcl_ProcObjCmd(0, interp, 4, ov); + } + + return result; +} + +/* nsfCmd __qualify NsfQualifyObjCmd { {-argName "name" -required 1 -type tclobj} } Index: generic/nsf.tcl =================================================================== diff -u -r3b2edfa776291682e0d251322997aad328b885df -rdd7a26337aa9aec3e0a06d2137ee7e708a8e1a9a --- generic/nsf.tcl (.../nsf.tcl) (revision 3b2edfa776291682e0d251322997aad328b885df) +++ generic/nsf.tcl (.../nsf.tcl) (revision dd7a26337aa9aec3e0a06d2137ee7e708a8e1a9a) @@ -46,19 +46,12 @@ # argument). # - set ::nsf::parametersyntax(::nsf::mixin) "object ?-per-object? classes" - - proc ::nsf::mixin {object args} { - if {[lindex $args 0] eq "-per-object"} { - set rel "object-mixin" - set args [lrange $args 1 end] - } else { - set rel "class-mixin" - } - if {[lindex $args 0] ne ""} { + ::nsf::proc ::nsf::mixin {object -per-object:switch classes} { + set rel [expr {${per-object} ? "object-mixin" : "class-mixin"}] + if {[lindex $classes 0] ne ""} { set oldSetting [::nsf::relation $object $rel] # use uplevel to avoid namespace surprises - uplevel [list ::nsf::relation $object $rel [linsert $oldSetting 0 $args]] + uplevel [list ::nsf::relation $object $rel [linsert $oldSetting 0 $classes]] } else { uplevel [list ::nsf::relation $object $rel ""] } Index: generic/nsfDecls.h =================================================================== diff -u -r87c6a11296ada89c007cc2ed33df6887ac53c740 -rdd7a26337aa9aec3e0a06d2137ee7e708a8e1a9a --- generic/nsfDecls.h (.../nsfDecls.h) (revision 87c6a11296ada89c007cc2ed33df6887ac53c740) +++ generic/nsfDecls.h (.../nsfDecls.h) (revision dd7a26337aa9aec3e0a06d2137ee7e708a8e1a9a) @@ -28,172 +28,177 @@ #ifndef Nsf_Init_TCL_DECLARED #define Nsf_Init_TCL_DECLARED /* 0 */ -EXTERN int Nsf_Init(Tcl_Interp *interp); +EXTERN int Nsf_Init (Tcl_Interp * interp); #endif /* Slot 1 is reserved */ #ifndef NsfIsClass_TCL_DECLARED #define NsfIsClass_TCL_DECLARED /* 2 */ -EXTERN struct Nsf_Class * NsfIsClass(Tcl_Interp *interp, ClientData cd); +EXTERN struct Nsf_Class * NsfIsClass (Tcl_Interp * interp, ClientData cd); #endif #ifndef NsfGetObject_TCL_DECLARED #define NsfGetObject_TCL_DECLARED /* 3 */ -EXTERN struct Nsf_Object * NsfGetObject(Tcl_Interp *interp, CONST char *name); +EXTERN struct Nsf_Object * NsfGetObject (Tcl_Interp * interp, + CONST char * name); #endif #ifndef NsfGetClass_TCL_DECLARED #define NsfGetClass_TCL_DECLARED /* 4 */ -EXTERN struct Nsf_Class * NsfGetClass(Tcl_Interp *interp, CONST char *name); +EXTERN struct Nsf_Class * NsfGetClass (Tcl_Interp * interp, + CONST char * name); #endif #ifndef NsfCreateObject_TCL_DECLARED #define NsfCreateObject_TCL_DECLARED /* 5 */ -EXTERN int NsfCreateObject(Tcl_Interp *interp, Tcl_Obj *name, - struct Nsf_Class *cl); +EXTERN int NsfCreateObject (Tcl_Interp * interp, Tcl_Obj * name, + struct Nsf_Class * cl); #endif #ifndef NsfDeleteObject_TCL_DECLARED #define NsfDeleteObject_TCL_DECLARED /* 6 */ -EXTERN int NsfDeleteObject(Tcl_Interp *interp, - struct Nsf_Object *obj); +EXTERN int NsfDeleteObject (Tcl_Interp * interp, + struct Nsf_Object * obj); #endif #ifndef NsfRemoveObjectMethod_TCL_DECLARED #define NsfRemoveObjectMethod_TCL_DECLARED /* 7 */ -EXTERN int NsfRemoveObjectMethod(Tcl_Interp *interp, - struct Nsf_Object *obj, CONST char *nm); +EXTERN int NsfRemoveObjectMethod (Tcl_Interp * interp, + struct Nsf_Object * obj, CONST char * nm); #endif #ifndef NsfRemoveClassMethod_TCL_DECLARED #define NsfRemoveClassMethod_TCL_DECLARED /* 8 */ -EXTERN int NsfRemoveClassMethod(Tcl_Interp *interp, - struct Nsf_Class *cl, CONST char *nm); +EXTERN int NsfRemoveClassMethod (Tcl_Interp * interp, + struct Nsf_Class * cl, CONST char * nm); #endif #ifndef NsfOSetInstVar_TCL_DECLARED #define NsfOSetInstVar_TCL_DECLARED /* 9 */ -EXTERN Tcl_Obj * NsfOSetInstVar(struct Nsf_Object *obj, - Tcl_Interp *interp, Tcl_Obj *name, - Tcl_Obj *value, int flgs); +EXTERN Tcl_Obj * NsfOSetInstVar (struct Nsf_Object * obj, + Tcl_Interp * interp, Tcl_Obj * name, + Tcl_Obj * value, int flgs); #endif #ifndef NsfOGetInstVar_TCL_DECLARED #define NsfOGetInstVar_TCL_DECLARED /* 10 */ -EXTERN Tcl_Obj * NsfOGetInstVar(struct Nsf_Object *obj, - Tcl_Interp *interp, Tcl_Obj *name, int flgs); +EXTERN Tcl_Obj * NsfOGetInstVar (struct Nsf_Object * obj, + Tcl_Interp * interp, Tcl_Obj * name, + int flgs); #endif #ifndef Nsf_ObjSetVar2_TCL_DECLARED #define Nsf_ObjSetVar2_TCL_DECLARED /* 11 */ -EXTERN Tcl_Obj * Nsf_ObjSetVar2(struct Nsf_Object *obj, - Tcl_Interp *interp, Tcl_Obj *name1, - Tcl_Obj *name2, Tcl_Obj *value, int flgs); +EXTERN Tcl_Obj * Nsf_ObjSetVar2 (struct Nsf_Object * obj, + Tcl_Interp * interp, Tcl_Obj * name1, + Tcl_Obj * name2, Tcl_Obj * value, int flgs); #endif #ifndef Nsf_ObjGetVar2_TCL_DECLARED #define Nsf_ObjGetVar2_TCL_DECLARED /* 12 */ -EXTERN Tcl_Obj * Nsf_ObjGetVar2(struct Nsf_Object *obj, - Tcl_Interp *interp, Tcl_Obj *name1, - Tcl_Obj *name2, int flgs); +EXTERN Tcl_Obj * Nsf_ObjGetVar2 (struct Nsf_Object * obj, + Tcl_Interp * interp, Tcl_Obj * name1, + Tcl_Obj * name2, int flgs); #endif #ifndef NsfUnsetInstVar2_TCL_DECLARED #define NsfUnsetInstVar2_TCL_DECLARED /* 13 */ -EXTERN int NsfUnsetInstVar2(struct Nsf_Object *obj, - Tcl_Interp *interp, CONST char *name1, - CONST char *name2, int flgs); +EXTERN int NsfUnsetInstVar2 (struct Nsf_Object * obj, + Tcl_Interp * interp, CONST char * name1, + CONST char * name2, int flgs); #endif #ifndef NsfDStringPrintf_TCL_DECLARED #define NsfDStringPrintf_TCL_DECLARED /* 14 */ -EXTERN void NsfDStringPrintf(Tcl_DString *dsPtr, CONST char *fmt, - va_list apSrc); +EXTERN void NsfDStringPrintf (Tcl_DString * dsPtr, + CONST char * fmt, va_list apSrc); #endif #ifndef NsfPrintError_TCL_DECLARED #define NsfPrintError_TCL_DECLARED /* 15 */ -EXTERN int NsfPrintError(Tcl_Interp *interp, CONST char *fmt, ...); +EXTERN int NsfPrintError (Tcl_Interp * interp, CONST char * fmt, ...); #endif #ifndef NsfErrInProc_TCL_DECLARED #define NsfErrInProc_TCL_DECLARED /* 16 */ -EXTERN int NsfErrInProc(Tcl_Interp *interp, Tcl_Obj *objName, - Tcl_Obj *clName, CONST char *procName); +EXTERN int NsfErrInProc (Tcl_Interp * interp, Tcl_Obj * objName, + Tcl_Obj * clName, CONST char * procName); #endif #ifndef NsfObjErrType_TCL_DECLARED #define NsfObjErrType_TCL_DECLARED /* 17 */ -EXTERN int NsfObjErrType(Tcl_Interp *interp, - CONST char *context, Tcl_Obj *value, - CONST char *type, Nsf_Param CONST *pPtr); +EXTERN int NsfObjErrType (Tcl_Interp * interp, + CONST char * context, Tcl_Obj * value, + CONST char * type, Nsf_Param CONST * pPtr); #endif #ifndef NsfStackDump_TCL_DECLARED #define NsfStackDump_TCL_DECLARED /* 18 */ -EXTERN void NsfStackDump(Tcl_Interp *interp); +EXTERN void NsfStackDump (Tcl_Interp * interp); #endif #ifndef NsfSetObjClientData_TCL_DECLARED #define NsfSetObjClientData_TCL_DECLARED /* 19 */ -EXTERN void NsfSetObjClientData(Nsf_Object *obj, ClientData data); +EXTERN void NsfSetObjClientData (Nsf_Object * obj, + ClientData data); #endif #ifndef NsfGetObjClientData_TCL_DECLARED #define NsfGetObjClientData_TCL_DECLARED /* 20 */ -EXTERN ClientData NsfGetObjClientData(Nsf_Object *obj); +EXTERN ClientData NsfGetObjClientData (Nsf_Object * obj); #endif #ifndef NsfSetClassClientData_TCL_DECLARED #define NsfSetClassClientData_TCL_DECLARED /* 21 */ -EXTERN void NsfSetClassClientData(Nsf_Class *cl, ClientData data); +EXTERN void NsfSetClassClientData (Nsf_Class * cl, + ClientData data); #endif #ifndef NsfGetClassClientData_TCL_DECLARED #define NsfGetClassClientData_TCL_DECLARED /* 22 */ -EXTERN ClientData NsfGetClassClientData(Nsf_Class *cl); +EXTERN ClientData NsfGetClassClientData (Nsf_Class * cl); #endif #ifndef NsfRequireObjNamespace_TCL_DECLARED #define NsfRequireObjNamespace_TCL_DECLARED /* 23 */ -EXTERN void NsfRequireObjNamespace(Tcl_Interp *interp, - Nsf_Object *obj); +EXTERN void NsfRequireObjNamespace (Tcl_Interp * interp, + Nsf_Object * obj); #endif #ifndef NsfNextObjCmd_TCL_DECLARED #define NsfNextObjCmd_TCL_DECLARED /* 24 */ -EXTERN int NsfNextObjCmd(ClientData cd, Tcl_Interp *interp, +EXTERN int NsfNextObjCmd (ClientData cd, Tcl_Interp * interp, int objc, Tcl_Obj *CONST objv[]); #endif #ifndef NsfCallMethodWithArgs_TCL_DECLARED #define NsfCallMethodWithArgs_TCL_DECLARED /* 25 */ -EXTERN int NsfCallMethodWithArgs(ClientData cd, - Tcl_Interp *interp, Tcl_Obj *method, - Tcl_Obj *arg, int objc, +EXTERN int NsfCallMethodWithArgs (ClientData cd, + Tcl_Interp * interp, Tcl_Obj * method, + Tcl_Obj * arg, int objc, Tcl_Obj *CONST objv[], int flags); #endif #ifndef NsfAddObjectMethod_TCL_DECLARED #define NsfAddObjectMethod_TCL_DECLARED /* 26 */ -EXTERN int NsfAddObjectMethod(Tcl_Interp *interp, - struct Nsf_Object *obj, CONST char *nm, - Tcl_ObjCmdProc *proc, ClientData cd, - Tcl_CmdDeleteProc *dp, int flags); +EXTERN int NsfAddObjectMethod (Tcl_Interp * interp, + struct Nsf_Object * obj, CONST char * nm, + Tcl_ObjCmdProc * proc, ClientData cd, + Tcl_CmdDeleteProc * dp, int flags); #endif #ifndef NsfAddClassMethod_TCL_DECLARED #define NsfAddClassMethod_TCL_DECLARED /* 27 */ -EXTERN int NsfAddClassMethod(Tcl_Interp *interp, - struct Nsf_Class *cl, CONST char *nm, - Tcl_ObjCmdProc *proc, ClientData cd, - Tcl_CmdDeleteProc *dp, int flags); +EXTERN int NsfAddClassMethod (Tcl_Interp * interp, + struct Nsf_Class * cl, CONST char * nm, + Tcl_ObjCmdProc * proc, ClientData cd, + Tcl_CmdDeleteProc * dp, int flags); #endif #ifndef NsfCreate_TCL_DECLARED #define NsfCreate_TCL_DECLARED /* 28 */ -EXTERN int NsfCreate(Tcl_Interp *in, Nsf_Class *class, - Tcl_Obj *name, ClientData data, int objc, +EXTERN int NsfCreate (Tcl_Interp * in, Nsf_Class * class, + Tcl_Obj * name, ClientData data, int objc, Tcl_Obj *CONST objv[]); #endif @@ -205,35 +210,35 @@ int magic; struct NsfStubHooks *hooks; - int (*nsf_Init) (Tcl_Interp *interp); /* 0 */ + int (*nsf_Init) (Tcl_Interp * interp); /* 0 */ void *reserved1; - struct Nsf_Class * (*nsfIsClass) (Tcl_Interp *interp, ClientData cd); /* 2 */ - struct Nsf_Object * (*nsfGetObject) (Tcl_Interp *interp, CONST char *name); /* 3 */ - struct Nsf_Class * (*nsfGetClass) (Tcl_Interp *interp, CONST char *name); /* 4 */ - int (*nsfCreateObject) (Tcl_Interp *interp, Tcl_Obj *name, struct Nsf_Class *cl); /* 5 */ - int (*nsfDeleteObject) (Tcl_Interp *interp, struct Nsf_Object *obj); /* 6 */ - int (*nsfRemoveObjectMethod) (Tcl_Interp *interp, struct Nsf_Object *obj, CONST char *nm); /* 7 */ - int (*nsfRemoveClassMethod) (Tcl_Interp *interp, struct Nsf_Class *cl, CONST char *nm); /* 8 */ - Tcl_Obj * (*nsfOSetInstVar) (struct Nsf_Object *obj, Tcl_Interp *interp, Tcl_Obj *name, Tcl_Obj *value, int flgs); /* 9 */ - Tcl_Obj * (*nsfOGetInstVar) (struct Nsf_Object *obj, Tcl_Interp *interp, Tcl_Obj *name, int flgs); /* 10 */ - Tcl_Obj * (*nsf_ObjSetVar2) (struct Nsf_Object *obj, Tcl_Interp *interp, Tcl_Obj *name1, Tcl_Obj *name2, Tcl_Obj *value, int flgs); /* 11 */ - Tcl_Obj * (*nsf_ObjGetVar2) (struct Nsf_Object *obj, Tcl_Interp *interp, Tcl_Obj *name1, Tcl_Obj *name2, int flgs); /* 12 */ - int (*nsfUnsetInstVar2) (struct Nsf_Object *obj, Tcl_Interp *interp, CONST char *name1, CONST char *name2, int flgs); /* 13 */ - void (*nsfDStringPrintf) (Tcl_DString *dsPtr, CONST char *fmt, va_list apSrc); /* 14 */ - int (*nsfPrintError) (Tcl_Interp *interp, CONST char *fmt, ...); /* 15 */ - int (*nsfErrInProc) (Tcl_Interp *interp, Tcl_Obj *objName, Tcl_Obj *clName, CONST char *procName); /* 16 */ - int (*nsfObjErrType) (Tcl_Interp *interp, CONST char *context, Tcl_Obj *value, CONST char *type, Nsf_Param CONST *pPtr); /* 17 */ - void (*nsfStackDump) (Tcl_Interp *interp); /* 18 */ - void (*nsfSetObjClientData) (Nsf_Object *obj, ClientData data); /* 19 */ - ClientData (*nsfGetObjClientData) (Nsf_Object *obj); /* 20 */ - void (*nsfSetClassClientData) (Nsf_Class *cl, ClientData data); /* 21 */ - ClientData (*nsfGetClassClientData) (Nsf_Class *cl); /* 22 */ - void (*nsfRequireObjNamespace) (Tcl_Interp *interp, Nsf_Object *obj); /* 23 */ - int (*nsfNextObjCmd) (ClientData cd, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]); /* 24 */ - int (*nsfCallMethodWithArgs) (ClientData cd, Tcl_Interp *interp, Tcl_Obj *method, Tcl_Obj *arg, int objc, Tcl_Obj *CONST objv[], int flags); /* 25 */ - int (*nsfAddObjectMethod) (Tcl_Interp *interp, struct Nsf_Object *obj, CONST char *nm, Tcl_ObjCmdProc *proc, ClientData cd, Tcl_CmdDeleteProc *dp, int flags); /* 26 */ - int (*nsfAddClassMethod) (Tcl_Interp *interp, struct Nsf_Class *cl, CONST char *nm, Tcl_ObjCmdProc *proc, ClientData cd, Tcl_CmdDeleteProc *dp, int flags); /* 27 */ - int (*nsfCreate) (Tcl_Interp *in, Nsf_Class *class, Tcl_Obj *name, ClientData data, int objc, Tcl_Obj *CONST objv[]); /* 28 */ + struct Nsf_Class * (*nsfIsClass) (Tcl_Interp * interp, ClientData cd); /* 2 */ + struct Nsf_Object * (*nsfGetObject) (Tcl_Interp * interp, CONST char * name); /* 3 */ + struct Nsf_Class * (*nsfGetClass) (Tcl_Interp * interp, CONST char * name); /* 4 */ + int (*nsfCreateObject) (Tcl_Interp * interp, Tcl_Obj * name, struct Nsf_Class * cl); /* 5 */ + int (*nsfDeleteObject) (Tcl_Interp * interp, struct Nsf_Object * obj); /* 6 */ + int (*nsfRemoveObjectMethod) (Tcl_Interp * interp, struct Nsf_Object * obj, CONST char * nm); /* 7 */ + int (*nsfRemoveClassMethod) (Tcl_Interp * interp, struct Nsf_Class * cl, CONST char * nm); /* 8 */ + Tcl_Obj * (*nsfOSetInstVar) (struct Nsf_Object * obj, Tcl_Interp * interp, Tcl_Obj * name, Tcl_Obj * value, int flgs); /* 9 */ + Tcl_Obj * (*nsfOGetInstVar) (struct Nsf_Object * obj, Tcl_Interp * interp, Tcl_Obj * name, int flgs); /* 10 */ + Tcl_Obj * (*nsf_ObjSetVar2) (struct Nsf_Object * obj, Tcl_Interp * interp, Tcl_Obj * name1, Tcl_Obj * name2, Tcl_Obj * value, int flgs); /* 11 */ + Tcl_Obj * (*nsf_ObjGetVar2) (struct Nsf_Object * obj, Tcl_Interp * interp, Tcl_Obj * name1, Tcl_Obj * name2, int flgs); /* 12 */ + int (*nsfUnsetInstVar2) (struct Nsf_Object * obj, Tcl_Interp * interp, CONST char * name1, CONST char * name2, int flgs); /* 13 */ + void (*nsfDStringPrintf) (Tcl_DString * dsPtr, CONST char * fmt, va_list apSrc); /* 14 */ + int (*nsfPrintError) (Tcl_Interp * interp, CONST char * fmt, ...); /* 15 */ + int (*nsfErrInProc) (Tcl_Interp * interp, Tcl_Obj * objName, Tcl_Obj * clName, CONST char * procName); /* 16 */ + int (*nsfObjErrType) (Tcl_Interp * interp, CONST char * context, Tcl_Obj * value, CONST char * type, Nsf_Param CONST * pPtr); /* 17 */ + void (*nsfStackDump) (Tcl_Interp * interp); /* 18 */ + void (*nsfSetObjClientData) (Nsf_Object * obj, ClientData data); /* 19 */ + ClientData (*nsfGetObjClientData) (Nsf_Object * obj); /* 20 */ + void (*nsfSetClassClientData) (Nsf_Class * cl, ClientData data); /* 21 */ + ClientData (*nsfGetClassClientData) (Nsf_Class * cl); /* 22 */ + void (*nsfRequireObjNamespace) (Tcl_Interp * interp, Nsf_Object * obj); /* 23 */ + int (*nsfNextObjCmd) (ClientData cd, Tcl_Interp * interp, int objc, Tcl_Obj *CONST objv[]); /* 24 */ + int (*nsfCallMethodWithArgs) (ClientData cd, Tcl_Interp * interp, Tcl_Obj * method, Tcl_Obj * arg, int objc, Tcl_Obj *CONST objv[], int flags); /* 25 */ + int (*nsfAddObjectMethod) (Tcl_Interp * interp, struct Nsf_Object * obj, CONST char * nm, Tcl_ObjCmdProc * proc, ClientData cd, Tcl_CmdDeleteProc * dp, int flags); /* 26 */ + int (*nsfAddClassMethod) (Tcl_Interp * interp, struct Nsf_Class * cl, CONST char * nm, Tcl_ObjCmdProc * proc, ClientData cd, Tcl_CmdDeleteProc * dp, int flags); /* 27 */ + int (*nsfCreate) (Tcl_Interp * in, Nsf_Class * class, Tcl_Obj * name, ClientData data, int objc, Tcl_Obj *CONST objv[]); /* 28 */ } NsfStubs; #ifdef __cplusplus Index: generic/predefined.h =================================================================== diff -u -r3b2edfa776291682e0d251322997aad328b885df -rdd7a26337aa9aec3e0a06d2137ee7e708a8e1a9a --- generic/predefined.h (.../predefined.h) (revision 3b2edfa776291682e0d251322997aad328b885df) +++ generic/predefined.h (.../predefined.h) (revision dd7a26337aa9aec3e0a06d2137ee7e708a8e1a9a) @@ -15,15 +15,11 @@ "eval [linsert $cmd 1 $object]} else {\n" "eval [linsert $(definition) 1 $object]}} else {\n" "error \"cannot require method $name for $object, method unknown\"}}\n" -"set ::nsf::parametersyntax(::nsf::mixin) \"object ?-per-object? classes\"\n" -"proc ::nsf::mixin {object args} {\n" -"if {[lindex $args 0] eq \"-per-object\"} {\n" -"set rel \"object-mixin\"\n" -"set args [lrange $args 1 end]} else {\n" -"set rel \"class-mixin\"}\n" -"if {[lindex $args 0] ne \"\"} {\n" +"::nsf::proc ::nsf::mixin {object -per-object:switch classes} {\n" +"set rel [expr {${per-object} ? \"object-mixin\" : \"class-mixin\"}]\n" +"if {[lindex $classes 0] ne \"\"} {\n" "set oldSetting [::nsf::relation $object $rel]\n" -"uplevel [list ::nsf::relation $object $rel [linsert $oldSetting 0 $args]]} else {\n" +"uplevel [list ::nsf::relation $object $rel [linsert $oldSetting 0 $classes]]} else {\n" "uplevel [list ::nsf::relation $object $rel \"\"]}}\n" "::nsf::provide_method autoname {::nsf::alias autoname ::nsf::methods::object::autoname}\n" "::nsf::provide_method exists {::nsf::alias exists ::nsf::methods::object::exists}\n" Index: generic/tclAPI.h =================================================================== diff -u -rbc9126dba8c73fbe5964faa34e8f11c23184b93e -rdd7a26337aa9aec3e0a06d2137ee7e708a8e1a9a --- generic/tclAPI.h (.../tclAPI.h) (revision bc9126dba8c73fbe5964faa34e8f11c23184b93e) +++ generic/tclAPI.h (.../tclAPI.h) (revision dd7a26337aa9aec3e0a06d2137ee7e708a8e1a9a) @@ -228,6 +228,7 @@ static int NsfNSCopyCmdsCmdStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); static int NsfNSCopyVarsCmdStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); static int NsfNextCmdStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); +static int NsfProcCmdStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); static int NsfQualifyObjCmdStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); static int NsfRelationCmdStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); static int NsfSelfCmdStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); @@ -305,12 +306,13 @@ static int NsfInvalidateObjectParameterCmd(Tcl_Interp *interp, NsfClass *class); static int NsfIsCmd(Tcl_Interp *interp, int withComplain, Tcl_Obj *constraint, Tcl_Obj *value); static int NsfIsObjectCmd(Tcl_Interp *interp, Tcl_Obj *value); -static int NsfMethodCmd(Tcl_Interp *interp, NsfObject *object, int withInner_namespace, int withPer_object, int withPublic, Tcl_Obj *methodName, Tcl_Obj *args, Tcl_Obj *body, Tcl_Obj *withPrecondition, Tcl_Obj *withPostcondition); +static int NsfMethodCmd(Tcl_Interp *interp, NsfObject *object, int withInner_namespace, int withPer_object, int withPublic, Tcl_Obj *methodName, Tcl_Obj *arguments, Tcl_Obj *body, Tcl_Obj *withPrecondition, Tcl_Obj *withPostcondition); static int NsfMethodPropertyCmd(Tcl_Interp *interp, NsfObject *object, int withPer_object, Tcl_Obj *methodName, int methodproperty, Tcl_Obj *value); static int NsfMyCmd(Tcl_Interp *interp, int withLocal, Tcl_Obj *methodName, int nobjc, Tcl_Obj *CONST nobjv[]); static int NsfNSCopyCmdsCmd(Tcl_Interp *interp, Tcl_Obj *fromNs, Tcl_Obj *toNs); static int NsfNSCopyVarsCmd(Tcl_Interp *interp, Tcl_Obj *fromNs, Tcl_Obj *toNs); static int NsfNextCmd(Tcl_Interp *interp, Tcl_Obj *arguments); +static int NsfProcCmd(Tcl_Interp *interp, Tcl_Obj *methodName, Tcl_Obj *arguments, Tcl_Obj *body); static int NsfQualifyObjCmd(Tcl_Interp *interp, Tcl_Obj *objectName); static int NsfRelationCmd(Tcl_Interp *interp, NsfObject *object, int relationtype, Tcl_Obj *value); static int NsfSelfCmd(Tcl_Interp *interp); @@ -395,6 +397,7 @@ NsfNSCopyCmdsCmdIdx, NsfNSCopyVarsCmdIdx, NsfNextCmdIdx, + NsfProcCmdIdx, NsfQualifyObjCmdIdx, NsfRelationCmdIdx, NsfSelfCmdIdx, @@ -1175,13 +1178,13 @@ int withPer_object = (int )PTR2INT(pc.clientData[2]); int withPublic = (int )PTR2INT(pc.clientData[3]); Tcl_Obj *methodName = (Tcl_Obj *)pc.clientData[4]; - Tcl_Obj *args = (Tcl_Obj *)pc.clientData[5]; + Tcl_Obj *arguments = (Tcl_Obj *)pc.clientData[5]; Tcl_Obj *body = (Tcl_Obj *)pc.clientData[6]; Tcl_Obj *withPrecondition = (Tcl_Obj *)pc.clientData[7]; Tcl_Obj *withPostcondition = (Tcl_Obj *)pc.clientData[8]; assert(pc.status == 0); - return NsfMethodCmd(interp, object, withInner_namespace, withPer_object, withPublic, methodName, args, body, withPrecondition, withPostcondition); + return NsfMethodCmd(interp, object, withInner_namespace, withPer_object, withPublic, methodName, arguments, body, withPrecondition, withPostcondition); } } @@ -1281,6 +1284,26 @@ } static int +NsfProcCmdStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { + ParseContext pc; + + if (ArgumentParse(interp, objc, objv, NULL, objv[0], + method_definitions[NsfProcCmdIdx].paramDefs, + method_definitions[NsfProcCmdIdx].nrParameters, 1, + &pc) != TCL_OK) { + return TCL_ERROR; + } else { + Tcl_Obj *methodName = (Tcl_Obj *)pc.clientData[0]; + Tcl_Obj *arguments = (Tcl_Obj *)pc.clientData[1]; + Tcl_Obj *body = (Tcl_Obj *)pc.clientData[2]; + + assert(pc.status == 0); + return NsfProcCmd(interp, methodName, arguments, body); + + } +} + +static int NsfQualifyObjCmdStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { @@ -2174,7 +2197,7 @@ {"-per-object", 0, 0, ConvertToString}, {"-public", 0, 0, ConvertToString}, {"methodName", NSF_ARG_REQUIRED, 0, ConvertToTclobj}, - {"args", NSF_ARG_REQUIRED, 0, ConvertToTclobj}, + {"arguments", NSF_ARG_REQUIRED, 0, ConvertToTclobj}, {"body", NSF_ARG_REQUIRED, 0, ConvertToTclobj}, {"-precondition", 0, 1, ConvertToTclobj}, {"-postcondition", 0, 1, ConvertToTclobj}} @@ -2202,6 +2225,11 @@ {"::nsf::next", NsfNextCmdStub, 1, { {"arguments", 0, 0, ConvertToTclobj}} }, +{"::nsf::proc", NsfProcCmdStub, 3, { + {"methodName", NSF_ARG_REQUIRED, 0, ConvertToTclobj}, + {"arguments", NSF_ARG_REQUIRED, 0, ConvertToTclobj}, + {"body", NSF_ARG_REQUIRED, 0, ConvertToTclobj}} +}, {"::nsf::qualify", NsfQualifyObjCmdStub, 1, { {"objectName", NSF_ARG_REQUIRED, 0, ConvertToTclobj}} },