Index: Makefile.in =================================================================== diff -u -rb9444659be7050e31855b0dfc3789087ee62a274 -r211c77c1a94a47be185a8bfb12c89512937b1901 --- Makefile.in (.../Makefile.in) (revision b9444659be7050e31855b0dfc3789087ee62a274) +++ Makefile.in (.../Makefile.in) (revision 211c77c1a94a47be185a8bfb12c89512937b1901) @@ -398,7 +398,7 @@ test-core: $(TCLSH_PROG) $(TCLSH) $(src_test_dir_native)/object-system.test -libdir $(PLATFORM_DIR) $(TESTFLAGS) $(TCLSH) $(src_test_dir_native)/destroy.test -libdir $(PLATFORM_DIR) $(TESTFLAGS) - $(TCLSH) $(src_test_dir_native)/method-modifiers.test -libdir $(PLATFORM_DIR) $(TESTFLAGS) + $(TCLSH) $(src_test_dir_native)/methods.test -libdir $(PLATFORM_DIR) $(TESTFLAGS) $(TCLSH) $(src_test_dir_native)/var-access.test -libdir $(PLATFORM_DIR) $(TESTFLAGS) $(TCLSH) $(src_test_dir_native)/varresolution.test -libdir $(PLATFORM_DIR) $(TESTFLAGS) $(TCLSH) $(src_test_dir_native)/info-method.test -libdir $(PLATFORM_DIR) $(TESTFLAGS) Index: TODO =================================================================== diff -u -r8f4ba2af8b01697a3aab727a2794cb3b456d6632 -r211c77c1a94a47be185a8bfb12c89512937b1901 --- TODO (.../TODO) (revision 8f4ba2af8b01697a3aab727a2794cb3b456d6632) +++ TODO (.../TODO) (revision 211c77c1a94a47be185a8bfb12c89512937b1901) @@ -2615,6 +2615,13 @@ * replaced "arg" by "type" in spec for mongo attributes to make spec less stange +- nsf.c: made potentially unknown clientData more safe (error message, + when something is passed via clientData to a method expecting + an object/class as clientData). +- renamed NsfNoDispatchObjectError() to NsfDispatchClientDataError(), + extended interface +- Makefile.in: fixed name methods.test + TODO: - the scripted init block is called before init. If the default @@ -2642,10 +2649,6 @@ This is not sufficient, if we would like to test in this script, whether the first arg is e.g. a class. -- make potentially unknown clientData more safe (error message, - when something is passed via clientData to a method expecting - an object/class as clientData). Code is in gentclAPI.h - - document value added replacements of Tcl functions - object parameter type forward: Index: generic/gentclAPI.tcl =================================================================== diff -u -r65abda7763aa24fe8a33728195cc3043d06ee660 -r211c77c1a94a47be185a8bfb12c89512937b1901 --- generic/gentclAPI.tcl (.../gentclAPI.tcl) (revision 65abda7763aa24fe8a33728195cc3043d06ee660) +++ generic/gentclAPI.tcl (.../gentclAPI.tcl) (revision 211c77c1a94a47be185a8bfb12c89512937b1901) @@ -85,7 +85,7 @@ } } -proc gencall {fn parameterDefinitions clientData cDefsVar ifDefVar arglistVar preVar postVar introVar} { +proc gencall {methodName fn parameterDefinitions clientData cDefsVar ifDefVar arglistVar preVar postVar introVar} { upvar $cDefsVar cDefs $ifDefVar ifDef $arglistVar arglist $preVar pre $postVar post \ $introVar intro set c [list] @@ -99,14 +99,14 @@ set if [list "NsfClass *cl"] append intro \ " NsfClass *cl = NsfObjectToClass(clientData);" \n \ - { if (!cl) return NsfObjErrType(interp, NULL, clientData ? ((NsfObject*)clientData)->cmdName : NsfGlobalObjs[NSF_EMPTY], "Class", NULL);} + " if (!cl) return NsfDispatchClientDataError(interp, clientData, \"class\", \"$methodName\");" } object { set a [list obj] set if [list "NsfObject *obj"] append intro \ " NsfObject *obj = (NsfObject *)clientData;" \n \ - { if (!obj) return NsfObjErrType(interp, NULL, clientData ? ((NsfObject*)clientData)->cmdName : NsfGlobalObjs[NSF_EMPTY], "Object", NULL);} + " if (!obj) return NsfDispatchClientDataError(interp, clientData, \"object\", \"$methodName\");" } "" { append intro " (void)clientData;\n" @@ -264,7 +264,7 @@ set stubDecl "static int $d(stub)$::objCmdProc\n" set ifd "{\"$d(ns)::$d(methodName)\", $d(stub), $nrArgs, {\n [genifd $d(parameterDefinitions)]}\n}" - gencall $d(stub) $d(parameterDefinitions) $d(clientData) cDefs ifDef arglist pre post intro + gencall $d(methodName) $d(stub) $d(parameterDefinitions) $d(clientData) cDefs ifDef arglist pre post intro append decls "static int [implArgList $d(implementation) {Tcl_Interp *} $ifDef];\n" if {$post ne ""} { append cDefs "\n int returnCode;" Index: generic/nsf.c =================================================================== diff -u -rb01ae78fb55550ee1ce97f2c8c69a07535190411 -r211c77c1a94a47be185a8bfb12c89512937b1901 --- generic/nsf.c (.../nsf.c) (revision b01ae78fb55550ee1ce97f2c8c69a07535190411) +++ generic/nsf.c (.../nsf.c) (revision 211c77c1a94a47be185a8bfb12c89512937b1901) @@ -12147,7 +12147,7 @@ NsfObject *object = cd->object; if (objc > 2) return NsfObjWrongArgs(interp, "wrong # args", object->cmdName, objv[0], "?value?"); - if (!object) return NsfNoDispatchObjectError(interp, ObjStr(objv[0])); + if (!object) return NsfDispatchClientDataError(interp, clientData, "object", ObjStr(objv[0])); if (cd->paramsPtr && objc == 2) { Tcl_Obj *outObjPtr; @@ -12432,7 +12432,7 @@ int result, inputArg = 1; if (!tcd || !tcd->object) { - return NsfNoDispatchObjectError(interp, "forwarder"); + return NsfDispatchClientDataError(interp, tcd, "object", "forwarder"); } if (tcd->passthrough) { /* two short cuts for simple cases */ @@ -12600,7 +12600,8 @@ assert(tcd->object == GetSelfObj(interp)); if (self == NULL) { - return NsfNoDispatchObjectError(interp, Tcl_GetCommandName(interp, tcd->aliasCmd)); + return NsfDispatchClientDataError(interp, self, "object", + Tcl_GetCommandName(interp, tcd->aliasCmd)); } if (Tcl_Command_cmdEpoch(tcd->aliasedCmd)) { Index: generic/nsf.h =================================================================== diff -u -rb01ae78fb55550ee1ce97f2c8c69a07535190411 -r211c77c1a94a47be185a8bfb12c89512937b1901 --- generic/nsf.h (.../nsf.h) (revision b01ae78fb55550ee1ce97f2c8c69a07535190411) +++ generic/nsf.h (.../nsf.h) (revision 211c77c1a94a47be185a8bfb12c89512937b1901) @@ -257,7 +257,8 @@ Tcl_Obj *cmdNameObj, Tcl_Obj *methodObj); extern int -NsfNoDispatchObjectError(Tcl_Interp *interp, CONST char *methodName); +NsfDispatchClientDataError(Tcl_Interp *interp, ClientData clientData, + CONST char *what, CONST char *methodName); #define NSF_LOG_NOTICE 2 #define NSF_LOG_WARN 1 Index: generic/nsfError.c =================================================================== diff -u -rb01ae78fb55550ee1ce97f2c8c69a07535190411 -r211c77c1a94a47be185a8bfb12c89512937b1901 --- generic/nsfError.c (.../nsfError.c) (revision b01ae78fb55550ee1ce97f2c8c69a07535190411) +++ generic/nsfError.c (.../nsfError.c) (revision 211c77c1a94a47be185a8bfb12c89512937b1901) @@ -203,10 +203,10 @@ *---------------------------------------------------------------------- */ int -NsfNoDispatchObjectError(Tcl_Interp *interp, CONST char *methodName) { - return NsfPrintError(interp, "Method %s not dispatched on object; " - "don't call aliased methods via namespace paths!", - methodName); +NsfDispatchClientDataError(Tcl_Interp *interp, ClientData clientData, CONST char *what, CONST char *methodName) { + return NsfPrintError(interp, "Method %s not dispatched on valid %s%s", + methodName, what, + clientData ? "" : " ; don't call aliased methods via namespace paths!"); } extern int Index: generic/tclAPI.h =================================================================== diff -u -rb01ae78fb55550ee1ce97f2c8c69a07535190411 -r211c77c1a94a47be185a8bfb12c89512937b1901 --- generic/tclAPI.h (.../tclAPI.h) (revision b01ae78fb55550ee1ce97f2c8c69a07535190411) +++ generic/tclAPI.h (.../tclAPI.h) (revision 211c77c1a94a47be185a8bfb12c89512937b1901) @@ -452,7 +452,7 @@ static int NsfCAllocMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { NsfClass *cl = NsfObjectToClass(clientData); - if (!cl) return NsfObjErrType(interp, NULL, clientData ? ((NsfObject*)clientData)->cmdName : NsfGlobalObjs[NSF_EMPTY], "Class", NULL); + if (!cl) return NsfDispatchClientDataError(interp, clientData, "class", "alloc"); if (objc != 2) { @@ -469,7 +469,7 @@ NsfCCreateMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { ParseContext pc; NsfClass *cl = NsfObjectToClass(clientData); - if (!cl) return NsfObjErrType(interp, NULL, clientData ? ((NsfObject*)clientData)->cmdName : NsfGlobalObjs[NSF_EMPTY], "Class", NULL); + if (!cl) return NsfDispatchClientDataError(interp, clientData, "class", "create"); if (ArgumentParse(interp, objc, objv, (NsfObject *) cl, objv[0], method_definitions[NsfCCreateMethodIdx].paramDefs, method_definitions[NsfCCreateMethodIdx].nrParameters, 1, @@ -487,7 +487,7 @@ static int NsfCDeallocMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { NsfClass *cl = NsfObjectToClass(clientData); - if (!cl) return NsfObjErrType(interp, NULL, clientData ? ((NsfObject*)clientData)->cmdName : NsfGlobalObjs[NSF_EMPTY], "Class", NULL); + if (!cl) return NsfDispatchClientDataError(interp, clientData, "class", "dealloc"); if (objc != 2) { @@ -504,7 +504,7 @@ NsfCFilterGuardMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { ParseContext pc; NsfClass *cl = NsfObjectToClass(clientData); - if (!cl) return NsfObjErrType(interp, NULL, clientData ? ((NsfObject*)clientData)->cmdName : NsfGlobalObjs[NSF_EMPTY], "Class", NULL); + if (!cl) return NsfDispatchClientDataError(interp, clientData, "class", "filterguard"); if (ArgumentParse(interp, objc, objv, (NsfObject *) cl, objv[0], method_definitions[NsfCFilterGuardMethodIdx].paramDefs, method_definitions[NsfCFilterGuardMethodIdx].nrParameters, 1, @@ -524,7 +524,7 @@ NsfCMixinGuardMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { ParseContext pc; NsfClass *cl = NsfObjectToClass(clientData); - if (!cl) return NsfObjErrType(interp, NULL, clientData ? ((NsfObject*)clientData)->cmdName : NsfGlobalObjs[NSF_EMPTY], "Class", NULL); + if (!cl) return NsfDispatchClientDataError(interp, clientData, "class", "mixinguard"); if (ArgumentParse(interp, objc, objv, (NsfObject *) cl, objv[0], method_definitions[NsfCMixinGuardMethodIdx].paramDefs, method_definitions[NsfCMixinGuardMethodIdx].nrParameters, 1, @@ -544,7 +544,7 @@ NsfCNewMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { ParseContext pc; NsfClass *cl = NsfObjectToClass(clientData); - if (!cl) return NsfObjErrType(interp, NULL, clientData ? ((NsfObject*)clientData)->cmdName : NsfGlobalObjs[NSF_EMPTY], "Class", NULL); + if (!cl) return NsfDispatchClientDataError(interp, clientData, "class", "new"); if (ArgumentParse(interp, objc, objv, (NsfObject *) cl, objv[0], method_definitions[NsfCNewMethodIdx].paramDefs, method_definitions[NsfCNewMethodIdx].nrParameters, 1, @@ -563,7 +563,7 @@ NsfCRecreateMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { ParseContext pc; NsfClass *cl = NsfObjectToClass(clientData); - if (!cl) return NsfObjErrType(interp, NULL, clientData ? ((NsfObject*)clientData)->cmdName : NsfGlobalObjs[NSF_EMPTY], "Class", NULL); + if (!cl) return NsfDispatchClientDataError(interp, clientData, "class", "recreate"); if (ArgumentParse(interp, objc, objv, (NsfObject *) cl, objv[0], method_definitions[NsfCRecreateMethodIdx].paramDefs, method_definitions[NsfCRecreateMethodIdx].nrParameters, 1, @@ -581,7 +581,7 @@ static int NsfCSuperclassMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { NsfClass *cl = NsfObjectToClass(clientData); - if (!cl) return NsfObjErrType(interp, NULL, clientData ? ((NsfObject*)clientData)->cmdName : NsfGlobalObjs[NSF_EMPTY], "Class", NULL); + if (!cl) return NsfDispatchClientDataError(interp, clientData, "class", "superclass"); if (objc < 1 || objc > 2) { @@ -598,7 +598,7 @@ NsfClassInfoFilterguardMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { ParseContext pc; NsfClass *cl = NsfObjectToClass(clientData); - if (!cl) return NsfObjErrType(interp, NULL, clientData ? ((NsfObject*)clientData)->cmdName : NsfGlobalObjs[NSF_EMPTY], "Class", NULL); + if (!cl) return NsfDispatchClientDataError(interp, clientData, "class", "filterguard"); if (ArgumentParse(interp, objc, objv, (NsfObject *) cl, objv[0], method_definitions[NsfClassInfoFilterguardMethodIdx].paramDefs, method_definitions[NsfClassInfoFilterguardMethodIdx].nrParameters, 1, @@ -617,7 +617,7 @@ NsfClassInfoFiltermethodsMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { ParseContext pc; NsfClass *cl = NsfObjectToClass(clientData); - if (!cl) return NsfObjErrType(interp, NULL, clientData ? ((NsfObject*)clientData)->cmdName : NsfGlobalObjs[NSF_EMPTY], "Class", NULL); + if (!cl) return NsfDispatchClientDataError(interp, clientData, "class", "filtermethods"); if (ArgumentParse(interp, objc, objv, (NsfObject *) cl, objv[0], method_definitions[NsfClassInfoFiltermethodsMethodIdx].paramDefs, method_definitions[NsfClassInfoFiltermethodsMethodIdx].nrParameters, 1, @@ -637,7 +637,7 @@ NsfClassInfoForwardMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { ParseContext pc; NsfClass *cl = NsfObjectToClass(clientData); - if (!cl) return NsfObjErrType(interp, NULL, clientData ? ((NsfObject*)clientData)->cmdName : NsfGlobalObjs[NSF_EMPTY], "Class", NULL); + if (!cl) return NsfDispatchClientDataError(interp, clientData, "class", "forward"); if (ArgumentParse(interp, objc, objv, (NsfObject *) cl, objv[0], method_definitions[NsfClassInfoForwardMethodIdx].paramDefs, method_definitions[NsfClassInfoForwardMethodIdx].nrParameters, 1, @@ -657,7 +657,7 @@ NsfClassInfoHeritageMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { ParseContext pc; NsfClass *cl = NsfObjectToClass(clientData); - if (!cl) return NsfObjErrType(interp, NULL, clientData ? ((NsfObject*)clientData)->cmdName : NsfGlobalObjs[NSF_EMPTY], "Class", NULL); + if (!cl) return NsfDispatchClientDataError(interp, clientData, "class", "heritage"); if (ArgumentParse(interp, objc, objv, (NsfObject *) cl, objv[0], method_definitions[NsfClassInfoHeritageMethodIdx].paramDefs, method_definitions[NsfClassInfoHeritageMethodIdx].nrParameters, 1, @@ -676,7 +676,7 @@ NsfClassInfoInstancesMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { ParseContext pc; NsfClass *cl = NsfObjectToClass(clientData); - if (!cl) return NsfObjErrType(interp, NULL, clientData ? ((NsfObject*)clientData)->cmdName : NsfGlobalObjs[NSF_EMPTY], "Class", NULL); + if (!cl) return NsfDispatchClientDataError(interp, clientData, "class", "instances"); if (ArgumentParse(interp, objc, objv, (NsfObject *) cl, objv[0], method_definitions[NsfClassInfoInstancesMethodIdx].paramDefs, method_definitions[NsfClassInfoInstancesMethodIdx].nrParameters, 1, @@ -710,7 +710,7 @@ NsfClassInfoMethodMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { ParseContext pc; NsfClass *cl = NsfObjectToClass(clientData); - if (!cl) return NsfObjErrType(interp, NULL, clientData ? ((NsfObject*)clientData)->cmdName : NsfGlobalObjs[NSF_EMPTY], "Class", NULL); + if (!cl) return NsfDispatchClientDataError(interp, clientData, "class", "method"); if (ArgumentParse(interp, objc, objv, (NsfObject *) cl, objv[0], method_definitions[NsfClassInfoMethodMethodIdx].paramDefs, method_definitions[NsfClassInfoMethodMethodIdx].nrParameters, 1, @@ -730,7 +730,7 @@ NsfClassInfoMethodsMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { ParseContext pc; NsfClass *cl = NsfObjectToClass(clientData); - if (!cl) return NsfObjErrType(interp, NULL, clientData ? ((NsfObject*)clientData)->cmdName : NsfGlobalObjs[NSF_EMPTY], "Class", NULL); + if (!cl) return NsfDispatchClientDataError(interp, clientData, "class", "methods"); if (ArgumentParse(interp, objc, objv, (NsfObject *) cl, objv[0], method_definitions[NsfClassInfoMethodsMethodIdx].paramDefs, method_definitions[NsfClassInfoMethodsMethodIdx].nrParameters, 1, @@ -754,7 +754,7 @@ NsfClassInfoMixinOfMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { ParseContext pc; NsfClass *cl = NsfObjectToClass(clientData); - if (!cl) return NsfObjErrType(interp, NULL, clientData ? ((NsfObject*)clientData)->cmdName : NsfGlobalObjs[NSF_EMPTY], "Class", NULL); + if (!cl) return NsfDispatchClientDataError(interp, clientData, "class", "mixinof"); if (ArgumentParse(interp, objc, objv, (NsfObject *) cl, objv[0], method_definitions[NsfClassInfoMixinOfMethodIdx].paramDefs, method_definitions[NsfClassInfoMixinOfMethodIdx].nrParameters, 1, @@ -789,7 +789,7 @@ NsfClassInfoMixinclassesMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { ParseContext pc; NsfClass *cl = NsfObjectToClass(clientData); - if (!cl) return NsfObjErrType(interp, NULL, clientData ? ((NsfObject*)clientData)->cmdName : NsfGlobalObjs[NSF_EMPTY], "Class", NULL); + if (!cl) return NsfDispatchClientDataError(interp, clientData, "class", "mixinclasses"); if (ArgumentParse(interp, objc, objv, (NsfObject *) cl, objv[0], method_definitions[NsfClassInfoMixinclassesMethodIdx].paramDefs, method_definitions[NsfClassInfoMixinclassesMethodIdx].nrParameters, 1, @@ -824,7 +824,7 @@ NsfClassInfoMixinguardMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { ParseContext pc; NsfClass *cl = NsfObjectToClass(clientData); - if (!cl) return NsfObjErrType(interp, NULL, clientData ? ((NsfObject*)clientData)->cmdName : NsfGlobalObjs[NSF_EMPTY], "Class", NULL); + if (!cl) return NsfDispatchClientDataError(interp, clientData, "class", "mixinguard"); if (ArgumentParse(interp, objc, objv, (NsfObject *) cl, objv[0], method_definitions[NsfClassInfoMixinguardMethodIdx].paramDefs, method_definitions[NsfClassInfoMixinguardMethodIdx].nrParameters, 1, @@ -843,7 +843,7 @@ NsfClassInfoSubclassMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { ParseContext pc; NsfClass *cl = NsfObjectToClass(clientData); - if (!cl) return NsfObjErrType(interp, NULL, clientData ? ((NsfObject*)clientData)->cmdName : NsfGlobalObjs[NSF_EMPTY], "Class", NULL); + if (!cl) return NsfDispatchClientDataError(interp, clientData, "class", "subclass"); if (ArgumentParse(interp, objc, objv, (NsfObject *) cl, objv[0], method_definitions[NsfClassInfoSubclassMethodIdx].paramDefs, method_definitions[NsfClassInfoSubclassMethodIdx].nrParameters, 1, @@ -877,7 +877,7 @@ NsfClassInfoSuperclassMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { ParseContext pc; NsfClass *cl = NsfObjectToClass(clientData); - if (!cl) return NsfObjErrType(interp, NULL, clientData ? ((NsfObject*)clientData)->cmdName : NsfGlobalObjs[NSF_EMPTY], "Class", NULL); + if (!cl) return NsfDispatchClientDataError(interp, clientData, "class", "superclass"); if (ArgumentParse(interp, objc, objv, (NsfObject *) cl, objv[0], method_definitions[NsfClassInfoSuperclassMethodIdx].paramDefs, method_definitions[NsfClassInfoSuperclassMethodIdx].nrParameters, 1, @@ -1516,7 +1516,7 @@ NsfOAutonameMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { ParseContext pc; NsfObject *obj = (NsfObject *)clientData; - if (!obj) return NsfObjErrType(interp, NULL, clientData ? ((NsfObject*)clientData)->cmdName : NsfGlobalObjs[NSF_EMPTY], "Object", NULL); + if (!obj) return NsfDispatchClientDataError(interp, clientData, "object", "autoname"); if (ArgumentParse(interp, objc, objv, obj, objv[0], method_definitions[NsfOAutonameMethodIdx].paramDefs, method_definitions[NsfOAutonameMethodIdx].nrParameters, 1, @@ -1536,7 +1536,7 @@ static int NsfOClassMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { NsfObject *obj = (NsfObject *)clientData; - if (!obj) return NsfObjErrType(interp, NULL, clientData ? ((NsfObject*)clientData)->cmdName : NsfGlobalObjs[NSF_EMPTY], "Object", NULL); + if (!obj) return NsfDispatchClientDataError(interp, clientData, "object", "class"); if (objc < 1 || objc > 2) { @@ -1552,7 +1552,7 @@ static int NsfOCleanupMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { NsfObject *obj = (NsfObject *)clientData; - if (!obj) return NsfObjErrType(interp, NULL, clientData ? ((NsfObject*)clientData)->cmdName : NsfGlobalObjs[NSF_EMPTY], "Object", NULL); + if (!obj) return NsfDispatchClientDataError(interp, clientData, "object", "cleanup"); if (objc != 1) { @@ -1568,7 +1568,7 @@ static int NsfOConfigureMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { NsfObject *obj = (NsfObject *)clientData; - if (!obj) return NsfObjErrType(interp, NULL, clientData ? ((NsfObject*)clientData)->cmdName : NsfGlobalObjs[NSF_EMPTY], "Object", NULL); + if (!obj) return NsfDispatchClientDataError(interp, clientData, "object", "configure"); return NsfOConfigureMethod(interp, obj, objc, objv); @@ -1578,7 +1578,7 @@ static int NsfODestroyMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { NsfObject *obj = (NsfObject *)clientData; - if (!obj) return NsfObjErrType(interp, NULL, clientData ? ((NsfObject*)clientData)->cmdName : NsfGlobalObjs[NSF_EMPTY], "Object", NULL); + if (!obj) return NsfDispatchClientDataError(interp, clientData, "object", "destroy"); if (objc != 1) { @@ -1595,7 +1595,7 @@ NsfOExistsMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { ParseContext pc; NsfObject *obj = (NsfObject *)clientData; - if (!obj) return NsfObjErrType(interp, NULL, clientData ? ((NsfObject*)clientData)->cmdName : NsfGlobalObjs[NSF_EMPTY], "Object", NULL); + if (!obj) return NsfDispatchClientDataError(interp, clientData, "object", "exists"); if (ArgumentParse(interp, objc, objv, obj, objv[0], method_definitions[NsfOExistsMethodIdx].paramDefs, method_definitions[NsfOExistsMethodIdx].nrParameters, 1, @@ -1614,7 +1614,7 @@ NsfOFilterGuardMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { ParseContext pc; NsfObject *obj = (NsfObject *)clientData; - if (!obj) return NsfObjErrType(interp, NULL, clientData ? ((NsfObject*)clientData)->cmdName : NsfGlobalObjs[NSF_EMPTY], "Object", NULL); + if (!obj) return NsfDispatchClientDataError(interp, clientData, "object", "filterguard"); if (ArgumentParse(interp, objc, objv, obj, objv[0], method_definitions[NsfOFilterGuardMethodIdx].paramDefs, method_definitions[NsfOFilterGuardMethodIdx].nrParameters, 1, @@ -1633,7 +1633,7 @@ static int NsfOInstvarMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { NsfObject *obj = (NsfObject *)clientData; - if (!obj) return NsfObjErrType(interp, NULL, clientData ? ((NsfObject*)clientData)->cmdName : NsfGlobalObjs[NSF_EMPTY], "Object", NULL); + if (!obj) return NsfDispatchClientDataError(interp, clientData, "object", "instvar"); return NsfOInstvarMethod(interp, obj, objc, objv); @@ -1644,7 +1644,7 @@ NsfOMixinGuardMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { ParseContext pc; NsfObject *obj = (NsfObject *)clientData; - if (!obj) return NsfObjErrType(interp, NULL, clientData ? ((NsfObject*)clientData)->cmdName : NsfGlobalObjs[NSF_EMPTY], "Object", NULL); + if (!obj) return NsfDispatchClientDataError(interp, clientData, "object", "mixinguard"); if (ArgumentParse(interp, objc, objv, obj, objv[0], method_definitions[NsfOMixinGuardMethodIdx].paramDefs, method_definitions[NsfOMixinGuardMethodIdx].nrParameters, 1, @@ -1663,7 +1663,7 @@ static int NsfONoinitMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { NsfObject *obj = (NsfObject *)clientData; - if (!obj) return NsfObjErrType(interp, NULL, clientData ? ((NsfObject*)clientData)->cmdName : NsfGlobalObjs[NSF_EMPTY], "Object", NULL); + if (!obj) return NsfDispatchClientDataError(interp, clientData, "object", "noinit"); if (objc != 1) { @@ -1679,7 +1679,7 @@ static int NsfORequireNamespaceMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { NsfObject *obj = (NsfObject *)clientData; - if (!obj) return NsfObjErrType(interp, NULL, clientData ? ((NsfObject*)clientData)->cmdName : NsfGlobalObjs[NSF_EMPTY], "Object", NULL); + if (!obj) return NsfDispatchClientDataError(interp, clientData, "object", "requirenamespace"); if (objc != 1) { @@ -1695,7 +1695,7 @@ static int NsfOResidualargsMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { NsfObject *obj = (NsfObject *)clientData; - if (!obj) return NsfObjErrType(interp, NULL, clientData ? ((NsfObject*)clientData)->cmdName : NsfGlobalObjs[NSF_EMPTY], "Object", NULL); + if (!obj) return NsfDispatchClientDataError(interp, clientData, "object", "residualargs"); return NsfOResidualargsMethod(interp, obj, objc, objv); @@ -1705,7 +1705,7 @@ static int NsfOUplevelMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { NsfObject *obj = (NsfObject *)clientData; - if (!obj) return NsfObjErrType(interp, NULL, clientData ? ((NsfObject*)clientData)->cmdName : NsfGlobalObjs[NSF_EMPTY], "Object", NULL); + if (!obj) return NsfDispatchClientDataError(interp, clientData, "object", "uplevel"); return NsfOUplevelMethod(interp, obj, objc, objv); @@ -1715,7 +1715,7 @@ static int NsfOUpvarMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { NsfObject *obj = (NsfObject *)clientData; - if (!obj) return NsfObjErrType(interp, NULL, clientData ? ((NsfObject*)clientData)->cmdName : NsfGlobalObjs[NSF_EMPTY], "Object", NULL); + if (!obj) return NsfDispatchClientDataError(interp, clientData, "object", "upvar"); return NsfOUpvarMethod(interp, obj, objc, objv); @@ -1725,7 +1725,7 @@ static int NsfOVolatileMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { NsfObject *obj = (NsfObject *)clientData; - if (!obj) return NsfObjErrType(interp, NULL, clientData ? ((NsfObject*)clientData)->cmdName : NsfGlobalObjs[NSF_EMPTY], "Object", NULL); + if (!obj) return NsfDispatchClientDataError(interp, clientData, "object", "volatile"); if (objc != 1) { @@ -1742,7 +1742,7 @@ NsfObjInfoChildrenMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { ParseContext pc; NsfObject *obj = (NsfObject *)clientData; - if (!obj) return NsfObjErrType(interp, NULL, clientData ? ((NsfObject*)clientData)->cmdName : NsfGlobalObjs[NSF_EMPTY], "Object", NULL); + if (!obj) return NsfDispatchClientDataError(interp, clientData, "object", "children"); if (ArgumentParse(interp, objc, objv, obj, objv[0], method_definitions[NsfObjInfoChildrenMethodIdx].paramDefs, method_definitions[NsfObjInfoChildrenMethodIdx].nrParameters, 1, @@ -1761,7 +1761,7 @@ static int NsfObjInfoClassMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { NsfObject *obj = (NsfObject *)clientData; - if (!obj) return NsfObjErrType(interp, NULL, clientData ? ((NsfObject*)clientData)->cmdName : NsfGlobalObjs[NSF_EMPTY], "Object", NULL); + if (!obj) return NsfDispatchClientDataError(interp, clientData, "object", "class"); if (objc != 1) { @@ -1778,7 +1778,7 @@ NsfObjInfoFilterguardMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { ParseContext pc; NsfObject *obj = (NsfObject *)clientData; - if (!obj) return NsfObjErrType(interp, NULL, clientData ? ((NsfObject*)clientData)->cmdName : NsfGlobalObjs[NSF_EMPTY], "Object", NULL); + if (!obj) return NsfDispatchClientDataError(interp, clientData, "object", "filterguard"); if (ArgumentParse(interp, objc, objv, obj, objv[0], method_definitions[NsfObjInfoFilterguardMethodIdx].paramDefs, method_definitions[NsfObjInfoFilterguardMethodIdx].nrParameters, 1, @@ -1797,7 +1797,7 @@ NsfObjInfoFiltermethodsMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { ParseContext pc; NsfObject *obj = (NsfObject *)clientData; - if (!obj) return NsfObjErrType(interp, NULL, clientData ? ((NsfObject*)clientData)->cmdName : NsfGlobalObjs[NSF_EMPTY], "Object", NULL); + if (!obj) return NsfDispatchClientDataError(interp, clientData, "object", "filtermethods"); if (ArgumentParse(interp, objc, objv, obj, objv[0], method_definitions[NsfObjInfoFiltermethodsMethodIdx].paramDefs, method_definitions[NsfObjInfoFiltermethodsMethodIdx].nrParameters, 1, @@ -1818,7 +1818,7 @@ NsfObjInfoForwardMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { ParseContext pc; NsfObject *obj = (NsfObject *)clientData; - if (!obj) return NsfObjErrType(interp, NULL, clientData ? ((NsfObject*)clientData)->cmdName : NsfGlobalObjs[NSF_EMPTY], "Object", NULL); + if (!obj) return NsfDispatchClientDataError(interp, clientData, "object", "forward"); if (ArgumentParse(interp, objc, objv, obj, objv[0], method_definitions[NsfObjInfoForwardMethodIdx].paramDefs, method_definitions[NsfObjInfoForwardMethodIdx].nrParameters, 1, @@ -1838,7 +1838,7 @@ NsfObjInfoHasMixinMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { ParseContext pc; NsfObject *obj = (NsfObject *)clientData; - if (!obj) return NsfObjErrType(interp, NULL, clientData ? ((NsfObject*)clientData)->cmdName : NsfGlobalObjs[NSF_EMPTY], "Object", NULL); + if (!obj) return NsfDispatchClientDataError(interp, clientData, "object", "hasmixin"); if (ArgumentParse(interp, objc, objv, obj, objv[0], method_definitions[NsfObjInfoHasMixinMethodIdx].paramDefs, method_definitions[NsfObjInfoHasMixinMethodIdx].nrParameters, 1, @@ -1857,7 +1857,7 @@ NsfObjInfoHasTypeMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { ParseContext pc; NsfObject *obj = (NsfObject *)clientData; - if (!obj) return NsfObjErrType(interp, NULL, clientData ? ((NsfObject*)clientData)->cmdName : NsfGlobalObjs[NSF_EMPTY], "Object", NULL); + if (!obj) return NsfDispatchClientDataError(interp, clientData, "object", "hastype"); if (ArgumentParse(interp, objc, objv, obj, objv[0], method_definitions[NsfObjInfoHasTypeMethodIdx].paramDefs, method_definitions[NsfObjInfoHasTypeMethodIdx].nrParameters, 1, @@ -1875,7 +1875,7 @@ static int NsfObjInfoHasnamespaceMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { NsfObject *obj = (NsfObject *)clientData; - if (!obj) return NsfObjErrType(interp, NULL, clientData ? ((NsfObject*)clientData)->cmdName : NsfGlobalObjs[NSF_EMPTY], "Object", NULL); + if (!obj) return NsfDispatchClientDataError(interp, clientData, "object", "hasnamespace"); if (objc != 1) { @@ -1892,7 +1892,7 @@ NsfObjInfoIsMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { ParseContext pc; NsfObject *obj = (NsfObject *)clientData; - if (!obj) return NsfObjErrType(interp, NULL, clientData ? ((NsfObject*)clientData)->cmdName : NsfGlobalObjs[NSF_EMPTY], "Object", NULL); + if (!obj) return NsfDispatchClientDataError(interp, clientData, "object", "is"); if (ArgumentParse(interp, objc, objv, obj, objv[0], method_definitions[NsfObjInfoIsMethodIdx].paramDefs, method_definitions[NsfObjInfoIsMethodIdx].nrParameters, 1, @@ -1911,7 +1911,7 @@ NsfObjInfoLookupFilterMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { ParseContext pc; NsfObject *obj = (NsfObject *)clientData; - if (!obj) return NsfObjErrType(interp, NULL, clientData ? ((NsfObject*)clientData)->cmdName : NsfGlobalObjs[NSF_EMPTY], "Object", NULL); + if (!obj) return NsfDispatchClientDataError(interp, clientData, "object", "lookupfilter"); if (ArgumentParse(interp, objc, objv, obj, objv[0], method_definitions[NsfObjInfoLookupFilterMethodIdx].paramDefs, method_definitions[NsfObjInfoLookupFilterMethodIdx].nrParameters, 1, @@ -1929,7 +1929,7 @@ static int NsfObjInfoLookupMethodMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { NsfObject *obj = (NsfObject *)clientData; - if (!obj) return NsfObjErrType(interp, NULL, clientData ? ((NsfObject*)clientData)->cmdName : NsfGlobalObjs[NSF_EMPTY], "Object", NULL); + if (!obj) return NsfDispatchClientDataError(interp, clientData, "object", "lookupmethod"); if (objc != 2) { @@ -1946,7 +1946,7 @@ NsfObjInfoLookupMethodsMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { ParseContext pc; NsfObject *obj = (NsfObject *)clientData; - if (!obj) return NsfObjErrType(interp, NULL, clientData ? ((NsfObject*)clientData)->cmdName : NsfGlobalObjs[NSF_EMPTY], "Object", NULL); + if (!obj) return NsfDispatchClientDataError(interp, clientData, "object", "lookupmethods"); if (ArgumentParse(interp, objc, objv, obj, objv[0], method_definitions[NsfObjInfoLookupMethodsMethodIdx].paramDefs, method_definitions[NsfObjInfoLookupMethodsMethodIdx].nrParameters, 1, @@ -1971,7 +1971,7 @@ NsfObjInfoLookupSlotsMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { ParseContext pc; NsfObject *obj = (NsfObject *)clientData; - if (!obj) return NsfObjErrType(interp, NULL, clientData ? ((NsfObject*)clientData)->cmdName : NsfGlobalObjs[NSF_EMPTY], "Object", NULL); + if (!obj) return NsfDispatchClientDataError(interp, clientData, "object", "lookupslots"); if (ArgumentParse(interp, objc, objv, obj, objv[0], method_definitions[NsfObjInfoLookupSlotsMethodIdx].paramDefs, method_definitions[NsfObjInfoLookupSlotsMethodIdx].nrParameters, 1, @@ -1990,7 +1990,7 @@ NsfObjInfoMethodMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { ParseContext pc; NsfObject *obj = (NsfObject *)clientData; - if (!obj) return NsfObjErrType(interp, NULL, clientData ? ((NsfObject*)clientData)->cmdName : NsfGlobalObjs[NSF_EMPTY], "Object", NULL); + if (!obj) return NsfDispatchClientDataError(interp, clientData, "object", "method"); if (ArgumentParse(interp, objc, objv, obj, objv[0], method_definitions[NsfObjInfoMethodMethodIdx].paramDefs, method_definitions[NsfObjInfoMethodMethodIdx].nrParameters, 1, @@ -2010,7 +2010,7 @@ NsfObjInfoMethodsMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { ParseContext pc; NsfObject *obj = (NsfObject *)clientData; - if (!obj) return NsfObjErrType(interp, NULL, clientData ? ((NsfObject*)clientData)->cmdName : NsfGlobalObjs[NSF_EMPTY], "Object", NULL); + if (!obj) return NsfDispatchClientDataError(interp, clientData, "object", "methods"); if (ArgumentParse(interp, objc, objv, obj, objv[0], method_definitions[NsfObjInfoMethodsMethodIdx].paramDefs, method_definitions[NsfObjInfoMethodsMethodIdx].nrParameters, 1, @@ -2034,7 +2034,7 @@ NsfObjInfoMixinclassesMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { ParseContext pc; NsfObject *obj = (NsfObject *)clientData; - if (!obj) return NsfObjErrType(interp, NULL, clientData ? ((NsfObject*)clientData)->cmdName : NsfGlobalObjs[NSF_EMPTY], "Object", NULL); + if (!obj) return NsfDispatchClientDataError(interp, clientData, "object", "mixinclasses"); if (ArgumentParse(interp, objc, objv, obj, objv[0], method_definitions[NsfObjInfoMixinclassesMethodIdx].paramDefs, method_definitions[NsfObjInfoMixinclassesMethodIdx].nrParameters, 1, @@ -2069,7 +2069,7 @@ NsfObjInfoMixinguardMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { ParseContext pc; NsfObject *obj = (NsfObject *)clientData; - if (!obj) return NsfObjErrType(interp, NULL, clientData ? ((NsfObject*)clientData)->cmdName : NsfGlobalObjs[NSF_EMPTY], "Object", NULL); + if (!obj) return NsfDispatchClientDataError(interp, clientData, "object", "mixinguard"); if (ArgumentParse(interp, objc, objv, obj, objv[0], method_definitions[NsfObjInfoMixinguardMethodIdx].paramDefs, method_definitions[NsfObjInfoMixinguardMethodIdx].nrParameters, 1, @@ -2087,7 +2087,7 @@ static int NsfObjInfoParentMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { NsfObject *obj = (NsfObject *)clientData; - if (!obj) return NsfObjErrType(interp, NULL, clientData ? ((NsfObject*)clientData)->cmdName : NsfGlobalObjs[NSF_EMPTY], "Object", NULL); + if (!obj) return NsfDispatchClientDataError(interp, clientData, "object", "parent"); if (objc != 1) { @@ -2104,7 +2104,7 @@ NsfObjInfoPrecedenceMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { ParseContext pc; NsfObject *obj = (NsfObject *)clientData; - if (!obj) return NsfObjErrType(interp, NULL, clientData ? ((NsfObject*)clientData)->cmdName : NsfGlobalObjs[NSF_EMPTY], "Object", NULL); + if (!obj) return NsfDispatchClientDataError(interp, clientData, "object", "precedence"); if (ArgumentParse(interp, objc, objv, obj, objv[0], method_definitions[NsfObjInfoPrecedenceMethodIdx].paramDefs, method_definitions[NsfObjInfoPrecedenceMethodIdx].nrParameters, 1, @@ -2124,7 +2124,7 @@ NsfObjInfoVarsMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { ParseContext pc; NsfObject *obj = (NsfObject *)clientData; - if (!obj) return NsfObjErrType(interp, NULL, clientData ? ((NsfObject*)clientData)->cmdName : NsfGlobalObjs[NSF_EMPTY], "Object", NULL); + if (!obj) return NsfDispatchClientDataError(interp, clientData, "object", "vars"); if (ArgumentParse(interp, objc, objv, obj, objv[0], method_definitions[NsfObjInfoVarsMethodIdx].paramDefs, method_definitions[NsfObjInfoVarsMethodIdx].nrParameters, 1, Index: tests/method-require.test =================================================================== diff -u -rb3018d3be0f1524a3f1709edc0e2ddb5d8bc4c0b -r211c77c1a94a47be185a8bfb12c89512937b1901 --- tests/method-require.test (.../method-require.test) (revision b3018d3be0f1524a3f1709edc0e2ddb5d8bc4c0b) +++ tests/method-require.test (.../method-require.test) (revision 211c77c1a94a47be185a8bfb12c89512937b1901) @@ -86,6 +86,6 @@ nx::Object create o ::nsf::method::require o alloc - ? {o alloc x} {expected Class but got "::o"} + ? {o alloc x} {Method alloc not dispatched on valid class} } \ No newline at end of file Index: tests/methods.test =================================================================== diff -u -rd40717ac3710f2123cb9359e3d0442ad4ff3da73 -r211c77c1a94a47be185a8bfb12c89512937b1901 --- tests/methods.test (.../methods.test) (revision d40717ac3710f2123cb9359e3d0442ad4ff3da73) +++ tests/methods.test (.../methods.test) (revision 211c77c1a94a47be185a8bfb12c89512937b1901) @@ -417,7 +417,7 @@ } # dispatch methods without current object - ? ::o::a "Method ::o::a not dispatched on object; don't call aliased methods via namespace paths!" + ? ::o::a "Method ::o::a not dispatched on valid object" ? ::o::b "::o2" ? ::o::foo "No current object" } \ No newline at end of file