Index: TODO =================================================================== diff -u -r52a0f3588723b74acd74a83be339c80b5b4a6701 -r30e21998853894414b65f668572dcf554635ead6 --- TODO (.../TODO) (revision 52a0f3588723b74acd74a83be339c80b5b4a6701) +++ TODO (.../TODO) (revision 30e21998853894414b65f668572dcf554635ead6) @@ -2963,6 +2963,8 @@ * bring cmd definitions for nsf::object in right order - extended regression test +- genAPI.decls and nsf.c: bring cmds in same order +- nsf.c: align naming conventions TODO: - do we have to adjust the documentation in xotcl2 for object initialization? Index: generic/gentclAPI.decls =================================================================== diff -u -r52a0f3588723b74acd74a83be339c80b5b4a6701 -r30e21998853894414b65f668572dcf554635ead6 --- generic/gentclAPI.decls (.../gentclAPI.decls) (revision 52a0f3588723b74acd74a83be339c80b5b4a6701) +++ generic/gentclAPI.decls (.../gentclAPI.decls) (revision 30e21998853894414b65f668572dcf554635ead6) @@ -55,6 +55,9 @@ {-argName "value" -required 1 -type tclobj} } +# +# method cmds +# cmd "method::alias" NsfMethodAliasCmd { {-argName "object" -required 1 -type object} {-argName "-per-object" -required 0 -nrargs 0} @@ -67,11 +70,6 @@ {-argName "assertionsubcmd" -required 1 -type "check|object-invar|class-invar"} {-argName "arg" -required 0 -type tclobj} } -cmd "method::delete" NsfMethodDeleteCmd { - {-argName "object" -required 1 -type object} - {-argName "-per-object" -nrargs 0} - {-argName "methodName" -required 1 -type tclobj} -} cmd "method::create" NsfMethodCreateCmd { {-argName "object" -required 1 -type object} {-argName "-inner-namespace" -nrargs 0} @@ -83,6 +81,11 @@ {-argName "-precondition" -type tclobj} {-argName "-postcondition" -type tclobj} } +cmd "method::delete" NsfMethodDeleteCmd { + {-argName "object" -required 1 -type object} + {-argName "-per-object" -nrargs 0} + {-argName "methodName" -required 1 -type tclobj} +} cmd "method::forward" NsfMethodForwardCmd { {-argName "object" -required 1 -type object} {-argName "-per-object" -nrargs 0} @@ -112,6 +115,9 @@ {-argName "parameter" -required 1 -type tclobj} } +# +# object cmds +# cmd "object::exists" NsfObjectExistsCmd { {-argName "value" -required 1 -type tclobj} } @@ -122,12 +128,12 @@ {-argName "objectName" -required 1 -type tclobj} } + cmd my NsfMyCmd { {-argName "-local" -nrargs 0} {-argName "methodName" -required 1 -type tclobj} {-argName "args" -type args} } - cmd next NsfNextCmd { {-argName "arguments" -required 0 -type tclobj} } @@ -158,20 +164,23 @@ cmd self NsfSelfCmd { } -cmd "var::exists" NsfExistsVarCmd { +# +# var cmds +# +cmd "var::exists" NsfVarExistsCmd { {-argName "object" -required 1 -type object} {-argName "varName" -required 1} } -cmd "var::import" NsfImportvarCmd { +cmd "var::import" NsfVarImportCmd { {-argName "object" -required 1 -type object} {-argName "args" -type args} } -cmd "var::set" NsfSetVarCmd { +cmd "var::set" NsfVarSetCmd { {-argName "object" -required 1 -type object} {-argName "varName" -required 1 -type tclobj} {-argName "value" -required 0 -type tclobj} } -cmd "var::unset" NsfUnsetVarCmd { +cmd "var::unset" NsfVarUnsetCmd { {-argName "object" -required 1 -type object} {-argName "varName" -required 1 -type tclobj} } Index: generic/nsf.c =================================================================== diff -u -r52a0f3588723b74acd74a83be339c80b5b4a6701 -r30e21998853894414b65f668572dcf554635ead6 --- generic/nsf.c (.../nsf.c) (revision 52a0f3588723b74acd74a83be339c80b5b4a6701) +++ generic/nsf.c (.../nsf.c) (revision 30e21998853894414b65f668572dcf554635ead6) @@ -12022,52 +12022,6 @@ /* *---------------------------------------------------------------------- - * NsfNextCmd -- - * - * nsf::next calls the next shadowed method. It might get a single - * argument which is used as argument vector for that method. If no - * argument is provided, the argument vector of the last invocation - * is used. - * - * Results: - * Tcl return code - * - * Side effects: - * The invoked method might produce side effects - * - *---------------------------------------------------------------------- - */ -/* -nsfCmd next NsfNextCmd { - {-argName "arguments" -required 0 -type tclobj} -} -*/ -static int -NsfNextCmd(Tcl_Interp *interp, Tcl_Obj *arguments) { - int freeArgumentVector, oc, nobjc, result; - NsfCallStackContent *cscPtr; - CONST char *methodName; - Tcl_Obj **nobjv, **ov; - - if (arguments) { - /* Arguments were provided. */ - int result = Tcl_ListObjGetElements(interp, arguments, &oc, &ov); - if (result != TCL_OK) {return result;} - } else { - /* No arguments were provided. */ - oc = -1; - } - - result = NextGetArguments(interp, oc, ov, &cscPtr, &methodName, - &nobjc, &nobjv, &freeArgumentVector); - if (result == TCL_OK) { - result = NextSearchAndInvoke(interp, methodName, nobjc, nobjv, cscPtr, freeArgumentVector); - } - return result; -} - -/* - *---------------------------------------------------------------------- * NsfNextObjCmd -- * * nsf::xotclnext is for backwards compatibility to the next @@ -16143,8 +16097,9 @@ /*********************************************************************** * Begin generated Next Scripting commands ***********************************************************************/ + /* -nsfCmd __db_show_stack NsfShowStackCmd {} +cmd __db_show_stack NsfShowStackCmd {} */ static int NsfShowStackCmd(Tcl_Interp *interp) { @@ -16153,7 +16108,7 @@ } /* -nsfCmd __db_run_assertions NsfDebugRunAssertionsCmd {} +cmd __db_run_assertions NsfDebugRunAssertionsCmd {} */ static int NsfDebugRunAssertionsCmd(Tcl_Interp *interp) { @@ -16225,7 +16180,7 @@ } /* -nsfCmd __profile_clear_data NsfProfileClearDataStub {} +cmd __profile_clear_data NsfProfileClearDataStub {} */ static int NsfProfileClearDataStub(Tcl_Interp *interp) { @@ -16236,7 +16191,7 @@ } /* -nsfCmd __profile_get_data NsfProfileGetDataStub {} +cmd __profile_get_data NsfProfileGetDataStub {} */ static int NsfProfileGetDataStub(Tcl_Interp *interp) { @@ -16292,7 +16247,7 @@ } /* -nsfCmd configure NsfConfigureCmd { +cmd configure NsfConfigureCmd { {-argName "configureoption" -required 1 -type "debug|dtrace|filter|profile|softrecreate|objectsystems|keepinitcmd|checkresults|checkarguments"} {-argName "value" -required 0 -type tclobj} } @@ -16423,7 +16378,7 @@ /* -nsfCmd createobjectsystem NsfCreateObjectSystemCmd { +cmd createobjectsystem NsfCreateObjectSystemCmd { {-argName "rootClass" -required 1 -type tclobj} {-argName "rootMetaClass" -required 1 -type tclobj} {-argName "systemMethods" -required 0 -type tclobj} @@ -16540,7 +16495,7 @@ } /* -nsfCmd dispatch NsfDispatchCmd { +cmd dispatch NsfDispatchCmd { {-argName "object" -required 1 -type object} {-argName "-frame" -required 0 -nrargs 1 -type "method|object|default" -default "default"} {-argName "command" -required 1 -type tclobj} @@ -16649,7 +16604,7 @@ } /* -nsfCmd colon NsfColonCmd { +cmd colon NsfColonCmd { {-argName "args" -type allargs} } */ @@ -16664,12 +16619,9 @@ } /* -nsfCmd finalize NsfFinalizeObjCmd { +cmd finalize NsfFinalizeObjCmd { } */ -/* - * ::nsf::finalize command - */ static int NsfFinalizeObjCmd(Tcl_Interp *interp) { int result; @@ -16704,7 +16656,7 @@ /* -nsfCmd interp NsfInterpObjCmd { +cmd interp NsfInterpObjCmd { {-argName "name"} {-argName "args" -type allargs} } @@ -16739,7 +16691,7 @@ } /* -nsfCmd invalidateobjectparameter NsfInvalidateObjectParameterCmd { +cmd invalidateobjectparameter NsfInvalidateObjectParameterCmd { {-argName "class" -type class} } */ @@ -16755,7 +16707,7 @@ } /* -nsfCmd is NsfIsCmd { +cmd is NsfIsCmd { {-argName "-complain"} {-argName "constraint" -required 1 -type tclobj} {-argName "value" -required 1 -type tclobj} @@ -16792,55 +16744,7 @@ } /* -cmd "object::exists" NsfObjectExistsCmd { - {-argName "value" -required 1 -type tclobj} -} -*/ -static int -NsfObjectExistsCmd(Tcl_Interp *interp, Tcl_Obj *valueObj) { - NsfObject *object; - - /* - * Pass the object as Tcl_Obj, since we do not want to raise an error in - * case the object does not exist. - */ - Tcl_SetBooleanObj(Tcl_GetObjResult(interp), GetObjectFromObj(interp, valueObj, &object) == TCL_OK); - return TCL_OK; -} - -/* -cmd "object::initialized" NsfObjectInitializedCmd { - {-argName "objectName" -required 1 -type object} -} -*/ -static int -NsfObjectInitializedCmd(Tcl_Interp *interp, NsfObject *object) { - - Tcl_SetObjResult(interp, - NsfGlobalObjs[(object->flags & NSF_INIT_CALLED) ? - NSF_ONE : NSF_ZERO]); - return TCL_OK; -} - -/* -cmd "object::qualify" NsfObjectQualifyCmd { - {-argName "objectName" -required 1 -type tclobj} -} -*/ -static int -NsfObjectQualifyCmd(Tcl_Interp *interp, Tcl_Obj *nameObj) { - CONST char *nameString = ObjStr(nameObj); - - if (isAbsolutePath(nameString)) { - Tcl_SetObjResult(interp, nameObj); - } else { - Tcl_SetObjResult(interp, NameInNamespaceObj(interp, nameString, CallingNameSpace(interp))); - } - return TCL_OK; -} - -/* -nsfCmd method::alias NsfMethodAliasCmd { +cmd method::alias NsfMethodAliasCmd { {-argName "object" -type object} {-argName "-per-object"} {-argName "methodName"} @@ -17009,7 +16913,7 @@ } /* -nsfCmd method::assertion NsfMethodAssertionCmd { +cmd method::assertion NsfMethodAssertionCmd { {-argName "object" -type object} {-argName "assertionsubcmd" -required 1 -type "check|object-invar|class-invar"} {-argName "arg" -required 0 -type tclobj} @@ -17062,7 +16966,7 @@ } /* -nsfCmd method::create NsfMethodCreateCmd { +cmd method::create NsfMethodCreateCmd { {-argName "object" -required 1 -type object} {-argName "-inner-namespace"} {-argName "-per-object"} @@ -17108,7 +17012,7 @@ } /* -nsfCmd method::forward NsfMethodForwardCmd { +cmd method::forward NsfMethodForwardCmd { {-argName "object" -required 1 -type object} {-argName "-per-object"} {-argName "method" -required 1 -type tclobj} @@ -17165,7 +17069,7 @@ } /* -nsfCmd ::method::property NsfMethodPropertyCmd { +cmd ::method::property NsfMethodPropertyCmd { {-argName "object" -required 1 -type object} {-argName "-per-object"} {-argName "methodName" -required 1 -type tclobj} @@ -17333,7 +17237,7 @@ } /* -nsfCmd method::setter NsfMethodSetterCmd { +cmd method::setter NsfMethodSetterCmd { {-argName "object" -required 1 -type object} {-argName "-per-object"} {-argName "parameter" -type tclobj} @@ -17397,8 +17301,62 @@ return result; } + + + + + /* -nsfCmd my NsfMyCmd { +cmd "object::exists" NsfObjectExistsCmd { + {-argName "value" -required 1 -type tclobj} +} +*/ +static int +NsfObjectExistsCmd(Tcl_Interp *interp, Tcl_Obj *valueObj) { + NsfObject *object; + + /* + * Pass the object as Tcl_Obj, since we do not want to raise an error in + * case the object does not exist. + */ + Tcl_SetBooleanObj(Tcl_GetObjResult(interp), GetObjectFromObj(interp, valueObj, &object) == TCL_OK); + return TCL_OK; +} + +/* +cmd "object::initialized" NsfObjectInitializedCmd { + {-argName "objectName" -required 1 -type object} +} +*/ +static int +NsfObjectInitializedCmd(Tcl_Interp *interp, NsfObject *object) { + + Tcl_SetObjResult(interp, + NsfGlobalObjs[(object->flags & NSF_INIT_CALLED) ? + NSF_ONE : NSF_ZERO]); + return TCL_OK; +} + +/* +cmd "object::qualify" NsfObjectQualifyCmd { + {-argName "objectName" -required 1 -type tclobj} +} +*/ +static int +NsfObjectQualifyCmd(Tcl_Interp *interp, Tcl_Obj *nameObj) { + CONST char *nameString = ObjStr(nameObj); + + if (isAbsolutePath(nameString)) { + Tcl_SetObjResult(interp, nameObj); + } else { + Tcl_SetObjResult(interp, NameInNamespaceObj(interp, nameString, CallingNameSpace(interp))); + } + return TCL_OK; +} + + +/* +cmd my NsfMyCmd { {-argName "-local"} {-argName "method" -required 1 -type tclobj} {-argName "args" -type args} @@ -17443,8 +17401,55 @@ return result; } + /* -nsfCmd namespace_copycmds NsfNSCopyCmdsCmd { + *---------------------------------------------------------------------- + * NsfNextCmd -- + * + * nsf::next calls the next shadowed method. It might get a single + * argument which is used as argument vector for that method. If no + * argument is provided, the argument vector of the last invocation + * is used. + * + * Results: + * Tcl return code + * + * Side effects: + * The invoked method might produce side effects + * + *---------------------------------------------------------------------- + */ +/* +cmd next NsfNextCmd { + {-argName "arguments" -required 0 -type tclobj} +} +*/ +static int +NsfNextCmd(Tcl_Interp *interp, Tcl_Obj *arguments) { + int freeArgumentVector, oc, nobjc, result; + NsfCallStackContent *cscPtr; + CONST char *methodName; + Tcl_Obj **nobjv, **ov; + + if (arguments) { + /* Arguments were provided. */ + int result = Tcl_ListObjGetElements(interp, arguments, &oc, &ov); + if (result != TCL_OK) {return result;} + } else { + /* No arguments were provided. */ + oc = -1; + } + + result = NextGetArguments(interp, oc, ov, &cscPtr, &methodName, + &nobjc, &nobjv, &freeArgumentVector); + if (result == TCL_OK) { + result = NextSearchAndInvoke(interp, methodName, nobjc, nobjv, cscPtr, freeArgumentVector); + } + return result; +} + +/* +cmd nscopycmds NsfNSCopyCmdsCmd { {-argName "fromNs" -required 1 -type tclobj} {-argName "toNs" -required 1 -type tclobj} } @@ -17651,7 +17656,7 @@ } /* -nsfCmd namespace_copyvars NsfNSCopyVars { +cmd nscopyvars NsfNSCopyVars { {-argName "fromNs" -required 1 -type tclobj} {-argName "toNs" -required 1 -type tclobj} } @@ -17764,7 +17769,7 @@ } /* -nsfCmd proc NsfProcCmd { +cmd proc NsfProcCmd { {-argName "-ad" -required 0} {-argName "procName" -required 1 -type tclobj} {-argName "arguments" -required 1 -type tclobj} @@ -17811,7 +17816,7 @@ } /* -nsfCmd relation NsfRelationCmd { +cmd relation NsfRelationCmd { {-argName "object" -type object} {-argName "relationtype" -required 1 -type "object-mixin|class-mixin|object-filter|class-filter|class|superclass|rootclass"} {-argName "value" -required 0 -type tclobj} @@ -18066,7 +18071,7 @@ } /* -nsfCmd current NsfCurrentCmd { +cmd current NsfCurrentCmd { {-argName "currentoption" -required 0 -type "proc|method|methodpath|object|class|activelevel|args|activemixin|calledproc|calledmethod|calledclass|callingproc|callingmethod|callingclass|callinglevel|callingobject|filterreg|isnextcall|next"} } */ @@ -18212,7 +18217,7 @@ } /* -nsfCmd self NsfSelfCmd { +cmd self NsfSelfCmd { } */ static int @@ -18228,13 +18233,13 @@ } /* -nsfCmd var::exists NsfExistsVarCmd { +cmd var::exists NsfVarExistsCmd { {-argName "object" -required 1 -type object} {-argName "varname" -required 1} } */ static int -NsfExistsVarCmd(Tcl_Interp *interp, NsfObject *object, CONST char *varName) { +NsfVarExistsCmd(Tcl_Interp *interp, NsfObject *object, CONST char *varName) { if (CheckVarName(interp, varName) != TCL_OK) { return TCL_ERROR; @@ -18245,13 +18250,13 @@ } /* -nsfCmd var::import NsfImportvarCmd { +cmd var::import NsfVarImportCmd { {-argName "object" -type object} {-argName "args" -type args} } */ static int -NsfImportvar(Tcl_Interp *interp, NsfObject *object, const char *cmdName, int objc, Tcl_Obj *CONST objv[]) { +NsfVarImport(Tcl_Interp *interp, NsfObject *object, const char *cmdName, int objc, Tcl_Obj *CONST objv[]) { int i, result = TCL_OK; for (i=0; i