Index: TODO =================================================================== diff -u -rc6057c18970d5bc19fe0f1f760ef0d29898ecfdd -rdcee5f2f7bac79f3fb2b966d68360cdfcef8002a --- TODO (.../TODO) (revision c6057c18970d5bc19fe0f1f760ef0d29898ecfdd) +++ TODO (.../TODO) (revision dcee5f2f7bac79f3fb2b966d68360cdfcef8002a) @@ -3044,6 +3044,8 @@ renamed "nsf::createobjectsystem" => "nsf::objectsystem::create" renamed "nsf::unknown" => "nsf::object::unknown" renamed "nsf::dispatch" => "nsf::object::dispatch" +- generalized "nsf::object::initialized" to + nsf::object::property objectName initialized|class|rootmetaclass|rootclass|slotcontainer TODO: @@ -3055,6 +3057,8 @@ createBootstrapAttributeSlots ::nx::Attribute {accessor true} -> false + + - Revise callstack introspection/intercession, i.e., [current activelevel] vs. [current callinglevel] vs. uplevel()/upvar(): Index: generic/nsf.c =================================================================== diff -u -rc6057c18970d5bc19fe0f1f760ef0d29898ecfdd -rdcee5f2f7bac79f3fb2b966d68360cdfcef8002a --- generic/nsf.c (.../nsf.c) (revision c6057c18970d5bc19fe0f1f760ef0d29898ecfdd) +++ generic/nsf.c (.../nsf.c) (revision dcee5f2f7bac79f3fb2b966d68360cdfcef8002a) @@ -3086,7 +3086,7 @@ * tclProc.c:InitResolvedLocals()). It registers two handlers for a * given, colon-prefixed variable found in the script: the actual * variable fetcher and a variable cleanup handler. The variable - * fetcher is executed whenever a Tcl call frame is intialised and + * fetcher is executed whenever a Tcl call frame is intialized and * the array of compiled locals is constructed (see also * InitResolvedLocals()). * @@ -17256,15 +17256,25 @@ } /* -cmd "object::initialized" NsfObjectInitializedCmd { +cmd "object::property" NsfObjectPropertyCmd { {-argName "objectName" -required 1 -type object} + {-argName "objectproperty" -type "initialized|class|rootmetaclass|rootclass|slotcontainer" -required 1} } */ static int -NsfObjectInitializedCmd(Tcl_Interp *interp, NsfObject *object) { +NsfObjectPropertyCmd(Tcl_Interp *interp, NsfObject *object, int objectproperty) { + int flags = 0;; + + switch (objectproperty) { + case ObjectpropertyInitializedIdx: flags = NSF_INIT_CALLED; break; + case ObjectpropertyClassIdx: flags = NSF_IS_CLASS; break; + case ObjectpropertyRootmetaclassIdx: flags = NSF_IS_ROOT_META_CLASS; break; + case ObjectpropertyRootclassIdx: flags = NSF_IS_ROOT_CLASS; break; + case ObjectpropertySlotcontainerIdx: flags = NSF_IS_SLOT_CONTAINER; break; + } - Tcl_SetObjResult(interp, - NsfGlobalObjs[(object->flags & NSF_INIT_CALLED) ? + Tcl_SetObjResult(interp, + NsfGlobalObjs[(object->flags & flags) ? NSF_ONE : NSF_ZERO]); return TCL_OK; } Index: generic/nsfAPI.decls =================================================================== diff -u -rc6057c18970d5bc19fe0f1f760ef0d29898ecfdd -rdcee5f2f7bac79f3fb2b966d68360cdfcef8002a --- generic/nsfAPI.decls (.../nsfAPI.decls) (revision c6057c18970d5bc19fe0f1f760ef0d29898ecfdd) +++ generic/nsfAPI.decls (.../nsfAPI.decls) (revision dcee5f2f7bac79f3fb2b966d68360cdfcef8002a) @@ -116,8 +116,9 @@ cmd "object::exists" NsfObjectExistsCmd { {-argName "value" -required 1 -type tclobj} } -cmd "object::initialized" NsfObjectInitializedCmd { +cmd "object::property" NsfObjectPropertyCmd { {-argName "objectName" -required 1 -type object} + {-argName "objectproperty" -type "initialized|class|rootmetaclass|rootclass|slotcontainer" -required 1} } cmd "object::qualify" NsfObjectQualifyCmd { {-argName "objectName" -required 1 -type tclobj} Index: generic/nsfAPI.h =================================================================== diff -u -rc6057c18970d5bc19fe0f1f760ef0d29898ecfdd -rdcee5f2f7bac79f3fb2b966d68360cdfcef8002a --- generic/nsfAPI.h (.../nsfAPI.h) (revision c6057c18970d5bc19fe0f1f760ef0d29898ecfdd) +++ generic/nsfAPI.h (.../nsfAPI.h) (revision dcee5f2f7bac79f3fb2b966d68360cdfcef8002a) @@ -142,6 +142,19 @@ return result; } +enum ObjectpropertyIdx {ObjectpropertyNULL, ObjectpropertyInitializedIdx, ObjectpropertyClassIdx, ObjectpropertyRootmetaclassIdx, ObjectpropertyRootclassIdx, ObjectpropertySlotcontainerIdx}; + +static int ConvertToObjectproperty(Tcl_Interp *interp, Tcl_Obj *objPtr, Nsf_Param CONST *pPtr, + ClientData *clientData, Tcl_Obj **outObjPtr) { + int index, result; + static CONST char *opts[] = {"initialized", "class", "rootmetaclass", "rootclass", "slotcontainer", NULL}; + (void)pPtr; + result = Tcl_GetIndexFromObj(interp, objPtr, opts, "objectproperty", 0, &index); + *clientData = (ClientData) INT2PTR(index + 1); + *outObjPtr = objPtr; + return result; +} + enum RelationtypeIdx {RelationtypeNULL, RelationtypeObject_mixinIdx, RelationtypeClass_mixinIdx, RelationtypeObject_filterIdx, RelationtypeClass_filterIdx, RelationtypeClassIdx, RelationtypeSuperclassIdx, RelationtypeRootclassIdx}; static int ConvertToRelationtype(Tcl_Interp *interp, Tcl_Obj *objPtr, Nsf_Param CONST *pPtr, @@ -182,6 +195,7 @@ {ConvertToRelationtype, "object-mixin|class-mixin|object-filter|class-filter|class|superclass|rootclass"}, {ConvertToSource, "all|application|baseclasses"}, {ConvertToConfigureoption, "debug|dtrace|filter|profile|softrecreate|objectsystems|keepinitcmd|checkresults|checkarguments"}, + {ConvertToObjectproperty, "initialized|class|rootmetaclass|rootclass|slotcontainer"}, {ConvertToAssertionsubcmd, "check|object-invar|class-invar"}, {NULL, NULL} }; @@ -240,7 +254,7 @@ static int NsfNextCmdStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); static int NsfObjectDispatchCmdStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); static int NsfObjectExistsCmdStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); -static int NsfObjectInitializedCmdStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); +static int NsfObjectPropertyCmdStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); static int NsfObjectQualifyCmdStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); static int NsfObjectSystemCreateCmdStub(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 []); @@ -335,7 +349,7 @@ static int NsfNextCmd(Tcl_Interp *interp, Tcl_Obj *arguments); static int NsfObjectDispatchCmd(Tcl_Interp *interp, NsfObject *object, int withFrame, Tcl_Obj *command, int nobjc, Tcl_Obj *CONST nobjv[]); static int NsfObjectExistsCmd(Tcl_Interp *interp, Tcl_Obj *value); -static int NsfObjectInitializedCmd(Tcl_Interp *interp, NsfObject *objectName); +static int NsfObjectPropertyCmd(Tcl_Interp *interp, NsfObject *objectName, int objectproperty); static int NsfObjectQualifyCmd(Tcl_Interp *interp, Tcl_Obj *objectName); static int NsfObjectSystemCreateCmd(Tcl_Interp *interp, Tcl_Obj *rootClass, Tcl_Obj *rootMetaClass, Tcl_Obj *systemMethods); static int NsfProcCmd(Tcl_Interp *interp, int withAd, Tcl_Obj *procName, Tcl_Obj *arguments, Tcl_Obj *body); @@ -431,7 +445,7 @@ NsfNextCmdIdx, NsfObjectDispatchCmdIdx, NsfObjectExistsCmdIdx, - NsfObjectInitializedCmdIdx, + NsfObjectPropertyCmdIdx, NsfObjectQualifyCmdIdx, NsfObjectSystemCreateCmdIdx, NsfProcCmdIdx, @@ -1403,20 +1417,21 @@ } static int -NsfObjectInitializedCmdStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { +NsfObjectPropertyCmdStub(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[NsfObjectInitializedCmdIdx].paramDefs, - method_definitions[NsfObjectInitializedCmdIdx].nrParameters, 1, + method_definitions[NsfObjectPropertyCmdIdx].paramDefs, + method_definitions[NsfObjectPropertyCmdIdx].nrParameters, 1, &pc) != TCL_OK) { return TCL_ERROR; } else { NsfObject *objectName = (NsfObject *)pc.clientData[0]; + int objectproperty = (int )PTR2INT(pc.clientData[1]); assert(pc.status == 0); - return NsfObjectInitializedCmd(interp, objectName); + return NsfObjectPropertyCmd(interp, objectName, objectproperty); } } @@ -2508,8 +2523,9 @@ {"::nsf::object::exists", NsfObjectExistsCmdStub, 1, { {"value", NSF_ARG_REQUIRED, 1, Nsf_ConvertToTclobj, NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}} }, -{"::nsf::object::initialized", NsfObjectInitializedCmdStub, 1, { - {"objectName", NSF_ARG_REQUIRED, 1, Nsf_ConvertToObject, NULL,NULL,"object",NULL,NULL,NULL,NULL,NULL}} +{"::nsf::object::property", NsfObjectPropertyCmdStub, 2, { + {"objectName", NSF_ARG_REQUIRED, 1, Nsf_ConvertToObject, NULL,NULL,"object",NULL,NULL,NULL,NULL,NULL}, + {"objectproperty", NSF_ARG_REQUIRED|NSF_ARG_IS_ENUMERATION, 1, ConvertToObjectproperty, NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}} }, {"::nsf::object::qualify", NsfObjectQualifyCmdStub, 1, { {"objectName", NSF_ARG_REQUIRED, 1, Nsf_ConvertToTclobj, NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}} Index: tests/object-system.test =================================================================== diff -u -rc6057c18970d5bc19fe0f1f760ef0d29898ecfdd -rdcee5f2f7bac79f3fb2b966d68360cdfcef8002a --- tests/object-system.test (.../object-system.test) (revision c6057c18970d5bc19fe0f1f760ef0d29898ecfdd) +++ tests/object-system.test (.../object-system.test) (revision dcee5f2f7bac79f3fb2b966d68360cdfcef8002a) @@ -22,7 +22,7 @@ ? {::nsf::configure objectsystem} "{::nx::Object ::nx::Class {-class.alloc alloc -class.create create -class.dealloc dealloc -class.objectparameter objectparameter -class.recreate recreate -object.configure configure -object.defaultmethod defaultmethod -object.destroy destroy -object.init init -object.move move -object.unknown unknown}}" ? {::nsf::object::exists Object} 1 -? {::nsf::object::initialized Object} 1 +? {::nsf::object::property Object initialized} 1 ? {::nsf::is class Object} 1 ? {::nsf::is metaclass Object} 0 ? {Object info superclass} "" @@ -45,9 +45,9 @@ Object create o2 { ? {::nsf::object::exists ::o2} 1 - ? {::nsf::object::initialized ::o2} 0 + ? {::nsf::object::property ::o2 initialized} 0 } -? {::nsf::object::initialized ::o2} 1 +? {::nsf::object::property ::o2 initialized} 1 Class create C0 ? {::nsf::is class C0} 1