Index: generic/gentclAPI.decls =================================================================== diff -u -rbf592f968ae84740d9ef7c40cddbcbf9f5a68283 -rb01ae78fb55550ee1ce97f2c8c69a07535190411 --- generic/gentclAPI.decls (.../gentclAPI.decls) (revision bf592f968ae84740d9ef7c40cddbcbf9f5a68283) +++ generic/gentclAPI.decls (.../gentclAPI.decls) (revision b01ae78fb55550ee1ce97f2c8c69a07535190411) @@ -157,6 +157,10 @@ {-argName "varName" -required 1 -type tclobj} {-argName "value" -required 0 -type tclobj} } +cmd "var::unset" NsfUnsetVarCmd { + {-argName "object" -required 1 -type object} + {-argName "varName" -required 1 -type tclobj} +} # # object methods Index: generic/nsf.c =================================================================== diff -u -rd40717ac3710f2123cb9359e3d0442ad4ff3da73 -rb01ae78fb55550ee1ce97f2c8c69a07535190411 --- generic/nsf.c (.../nsf.c) (revision d40717ac3710f2123cb9359e3d0442ad4ff3da73) +++ generic/nsf.c (.../nsf.c) (revision b01ae78fb55550ee1ce97f2c8c69a07535190411) @@ -12112,7 +12112,36 @@ return TCL_ERROR; } +/* + *---------------------------------------------------------------------- + * UnsetInstVar -- + * + * Unset an instance variable of the specified object. + * + * Results: + * Tcl result code. + * + * Side effects: + * Variable unset. + * + *---------------------------------------------------------------------- + */ static int +UnsetInstVar(Tcl_Interp *interp, NsfObject *object, CONST char* name) { + CallFrame frame, *framePtr = &frame; + int flags, result; + + assert(object); + flags = (object->nsPtr) ? TCL_LEAVE_ERR_MSG|TCL_NAMESPACE_ONLY : TCL_LEAVE_ERR_MSG; + + Nsf_PushFrameObj(interp, object, framePtr); + result = Tcl_UnsetVar2(interp, name, NULL, flags); + Nsf_PopFrameObj(interp, framePtr); + + return result; +} + +static int NsfSetterMethod(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { SetterCmdClientData *cd = (SetterCmdClientData*)clientData; NsfObject *object = cd->object; @@ -16576,6 +16605,23 @@ } /* +nsfCmd var::unset NsfUnsetVarCmd { + {-argName "object" -required 1 -type object} + {-argName "varname" -required 1 -type tclobj} +} +*/ +static int +NsfUnsetVarCmd(Tcl_Interp *interp, NsfObject *object, Tcl_Obj *varNameObj) { + char *varName = ObjStr(varNameObj); + + if (CheckVarName(interp, varName) != TCL_OK) { + return TCL_ERROR; + } + + return UnsetInstVar(interp, object, varName); +} + +/* nsfCmd method::setter NsfSetterCmd { {-argName "object" -required 1 -type object} {-argName "-per-object"} Index: generic/nsf.h =================================================================== diff -u -rd40717ac3710f2123cb9359e3d0442ad4ff3da73 -rb01ae78fb55550ee1ce97f2c8c69a07535190411 --- generic/nsf.h (.../nsf.h) (revision d40717ac3710f2123cb9359e3d0442ad4ff3da73) +++ generic/nsf.h (.../nsf.h) (revision b01ae78fb55550ee1ce97f2c8c69a07535190411) @@ -257,7 +257,7 @@ Tcl_Obj *cmdNameObj, Tcl_Obj *methodObj); extern int -NsfNoDispatchObjectError(Tcl_Interp *interp, char *methodName); +NsfNoDispatchObjectError(Tcl_Interp *interp, CONST char *methodName); #define NSF_LOG_NOTICE 2 #define NSF_LOG_WARN 1 Index: generic/nsfError.c =================================================================== diff -u -rd40717ac3710f2123cb9359e3d0442ad4ff3da73 -rb01ae78fb55550ee1ce97f2c8c69a07535190411 --- generic/nsfError.c (.../nsfError.c) (revision d40717ac3710f2123cb9359e3d0442ad4ff3da73) +++ generic/nsfError.c (.../nsfError.c) (revision b01ae78fb55550ee1ce97f2c8c69a07535190411) @@ -203,7 +203,7 @@ *---------------------------------------------------------------------- */ int -NsfNoDispatchObjectError(Tcl_Interp *interp, char *methodName) { +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); Index: generic/tclAPI.h =================================================================== diff -u -r65abda7763aa24fe8a33728195cc3043d06ee660 -rb01ae78fb55550ee1ce97f2c8c69a07535190411 --- generic/tclAPI.h (.../tclAPI.h) (revision 65abda7763aa24fe8a33728195cc3043d06ee660) +++ generic/tclAPI.h (.../tclAPI.h) (revision b01ae78fb55550ee1ce97f2c8c69a07535190411) @@ -233,6 +233,7 @@ static int NsfSetVarCmdStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); static int NsfSetterCmdStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); static int NsfShowStackCmdStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); +static int NsfUnsetVarCmdStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); static int NsfOAutonameMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); static int NsfOClassMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); static int NsfOCleanupMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); @@ -320,6 +321,7 @@ static int NsfSetVarCmd(Tcl_Interp *interp, NsfObject *object, Tcl_Obj *varName, Tcl_Obj *value); static int NsfSetterCmd(Tcl_Interp *interp, NsfObject *object, int withPer_object, Tcl_Obj *parameter); static int NsfShowStackCmd(Tcl_Interp *interp); +static int NsfUnsetVarCmd(Tcl_Interp *interp, NsfObject *object, Tcl_Obj *varName); static int NsfOAutonameMethod(Tcl_Interp *interp, NsfObject *obj, int withInstance, int withReset, Tcl_Obj *name); static int NsfOClassMethod(Tcl_Interp *interp, NsfObject *obj, Tcl_Obj *class); static int NsfOCleanupMethod(Tcl_Interp *interp, NsfObject *obj); @@ -408,6 +410,7 @@ NsfSetVarCmdIdx, NsfSetterCmdIdx, NsfShowStackCmdIdx, + NsfUnsetVarCmdIdx, NsfOAutonameMethodIdx, NsfOClassMethodIdx, NsfOCleanupMethodIdx, @@ -1490,6 +1493,26 @@ } static int +NsfUnsetVarCmdStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { + ParseContext pc; + (void)clientData; + + if (ArgumentParse(interp, objc, objv, NULL, objv[0], + method_definitions[NsfUnsetVarCmdIdx].paramDefs, + method_definitions[NsfUnsetVarCmdIdx].nrParameters, 1, + &pc) != TCL_OK) { + return TCL_ERROR; + } else { + NsfObject *object = (NsfObject *)pc.clientData[0]; + Tcl_Obj *varName = (Tcl_Obj *)pc.clientData[1]; + + assert(pc.status == 0); + return NsfUnsetVarCmd(interp, object, varName); + + } +} + +static int NsfOAutonameMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { ParseContext pc; NsfObject *obj = (NsfObject *)clientData; @@ -2341,6 +2364,10 @@ {"::nsf::__db_show_stack", NsfShowStackCmdStub, 0, { {NULL, 0, 0, NULL, NULL,NULL,NULL,NULL,NULL,NULL,NULL}} }, +{"::nsf::var::unset", NsfUnsetVarCmdStub, 2, { + {"object", NSF_ARG_REQUIRED, 0, Nsf_ConvertToObject, NULL,NULL,NULL,NULL,NULL,NULL,NULL}, + {"varName", NSF_ARG_REQUIRED, 0, Nsf_ConvertToTclobj, NULL,NULL,NULL,NULL,NULL,NULL,NULL}} +}, {"::nsf::methods::object::autoname", NsfOAutonameMethodStub, 3, { {"-instance", 0, 0, Nsf_ConvertToString, NULL,NULL,NULL,NULL,NULL,NULL,NULL}, {"-reset", 0, 0, Nsf_ConvertToString, NULL,NULL,NULL,NULL,NULL,NULL,NULL},