Index: TODO =================================================================== diff -u -r3a867351bc680631bdf05f73b886763ac109a7f8 -re29434ffef30bea10b7422f1f295787d41377839 --- TODO (.../TODO) (revision 3a867351bc680631bdf05f73b886763ac109a7f8) +++ TODO (.../TODO) (revision e29434ffef30bea10b7422f1f295787d41377839) @@ -2800,6 +2800,9 @@ - reduce verbosity - nx.tcl: improve code documentation +-nsf.c: added c-implementation of "/object/ info slots" to + share implementation details and reduce scattering + TODO: - missing in c-based "info slots": Index: generic/gentclAPI.decls =================================================================== diff -u -r5c255e27038ce407b8bdf4706a9942c10da1a940 -re29434ffef30bea10b7422f1f295787d41377839 --- generic/gentclAPI.decls (.../gentclAPI.decls) (revision 5c255e27038ce407b8bdf4706a9942c10da1a940) +++ generic/gentclAPI.decls (.../gentclAPI.decls) (revision e29434ffef30bea10b7422f1f295787d41377839) @@ -350,6 +350,10 @@ {-argName "-intrinsic"} {-argName "pattern" -required 0} } +objectInfoMethod slots NsfObjInfoSlotsMethod { + {-argName "-type" -required 0 -nrargs 1 -type class} + {-argName "pattern" -required 0} +} objectInfoMethod vars NsfObjInfoVarsMethod { {-argName "pattern" -required 0} } Index: generic/nsf.c =================================================================== diff -u -r16d627336b40d4eafd46400984337bf3e514605e -re29434ffef30bea10b7422f1f295787d41377839 --- generic/nsf.c (.../nsf.c) (revision 16d627336b40d4eafd46400984337bf3e514605e) +++ generic/nsf.c (.../nsf.c) (revision e29434ffef30bea10b7422f1f295787d41377839) @@ -10692,14 +10692,16 @@ hPtr = Tcl_FirstHashEntry(cmdTablePtr, &hSrch); for (; hPtr; hPtr = Tcl_NextHashEntry(&hSrch)) { char *key = Tcl_GetHashKey(cmdTablePtr, hPtr); - - /* - * Check, if we have and entry with this key already processed. We - * never want to report shadowed entries. - */ - Tcl_CreateHashEntry(slotTablePtr, key, &new); - if (!new) continue; + if (slotTablePtr) { + /* + * Check, if we have and entry with this key already processed. We + * never want to report shadowed entries. + */ + Tcl_CreateHashEntry(slotTablePtr, key, &new); + if (!new) continue; + } + /* * Obtain the childObject */ @@ -19363,6 +19365,25 @@ } /* +objectInfoMethod slots NsfObjInfoSlotsMethod { + {-argName "-type" -required 0 -nrargs 1 -type class} + {-argName "pattern" -required 0} +} +*/ +static int +NsfObjInfoSlotsMethod(Tcl_Interp *interp, NsfObject *object, + NsfClass *type, CONST char *pattern) { + Tcl_Obj *listObj = Tcl_NewListObj(0, NULL); + + AddSlotObjects(interp, object, "::per-object-slot", NULL, + SourceAllIdx, type, pattern, listObj); + + Tcl_SetObjResult(interp, listObj); + return TCL_OK; +} + + +/* objectInfoMethod vars NsfObjInfoVarsMethod { {-argName "pattern" -required 0} } Index: generic/tclAPI.h =================================================================== diff -u -r5c255e27038ce407b8bdf4706a9942c10da1a940 -re29434ffef30bea10b7422f1f295787d41377839 --- generic/tclAPI.h (.../tclAPI.h) (revision 5c255e27038ce407b8bdf4706a9942c10da1a940) +++ generic/tclAPI.h (.../tclAPI.h) (revision e29434ffef30bea10b7422f1f295787d41377839) @@ -285,6 +285,7 @@ static int NsfObjInfoMixinguardMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); static int NsfObjInfoParentMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); static int NsfObjInfoPrecedenceMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); +static int NsfObjInfoSlotsMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); static int NsfObjInfoVarsMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); static int NsfCAllocMethod(Tcl_Interp *interp, NsfClass *cl, Tcl_Obj *objectName); @@ -376,6 +377,7 @@ static int NsfObjInfoMixinguardMethod(Tcl_Interp *interp, NsfObject *obj, CONST char *mixin); static int NsfObjInfoParentMethod(Tcl_Interp *interp, NsfObject *obj); static int NsfObjInfoPrecedenceMethod(Tcl_Interp *interp, NsfObject *obj, int withIntrinsic, CONST char *pattern); +static int NsfObjInfoSlotsMethod(Tcl_Interp *interp, NsfObject *obj, NsfClass *withType, CONST char *pattern); static int NsfObjInfoVarsMethod(Tcl_Interp *interp, NsfObject *obj, CONST char *pattern); enum { @@ -468,6 +470,7 @@ NsfObjInfoMixinguardMethodIdx, NsfObjInfoParentMethodIdx, NsfObjInfoPrecedenceMethodIdx, + NsfObjInfoSlotsMethodIdx, NsfObjInfoVarsMethodIdx } NsfMethods; @@ -2211,6 +2214,26 @@ } static int +NsfObjInfoSlotsMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { + ParseContext pc; + NsfObject *obj = (NsfObject *)clientData; + if (!obj) return NsfDispatchClientDataError(interp, clientData, "object", "slots"); + if (ArgumentParse(interp, objc, objv, obj, objv[0], + method_definitions[NsfObjInfoSlotsMethodIdx].paramDefs, + method_definitions[NsfObjInfoSlotsMethodIdx].nrParameters, 1, + &pc) != TCL_OK) { + return TCL_ERROR; + } else { + NsfClass *withType = (NsfClass *)pc.clientData[0]; + CONST char *pattern = (CONST char *)pc.clientData[1]; + + assert(pc.status == 0); + return NsfObjInfoSlotsMethod(interp, obj, withType, pattern); + + } +} + +static int NsfObjInfoVarsMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { ParseContext pc; NsfObject *obj = (NsfObject *)clientData; @@ -2602,6 +2625,10 @@ {"-intrinsic", 0, 0, Nsf_ConvertToString, NULL,NULL,NULL,NULL,NULL,NULL,NULL}, {"pattern", 0, 0, Nsf_ConvertToString, NULL,NULL,NULL,NULL,NULL,NULL,NULL}} }, +{"::nsf::methods::object::info::slots", NsfObjInfoSlotsMethodStub, 2, { + {"-type", 0, 1, Nsf_ConvertToClass, NULL,NULL,NULL,NULL,NULL,NULL,NULL}, + {"pattern", 0, 0, Nsf_ConvertToString, NULL,NULL,NULL,NULL,NULL,NULL,NULL}} +}, {"::nsf::methods::object::info::vars", NsfObjInfoVarsMethodStub, 1, { {"pattern", 0, 0, Nsf_ConvertToString, NULL,NULL,NULL,NULL,NULL,NULL,NULL}} },{NULL} Index: library/nx/nx.tcl =================================================================== diff -u -r3a867351bc680631bdf05f73b886763ac109a7f8 -re29434ffef30bea10b7422f1f295787d41377839 --- library/nx/nx.tcl (.../nx.tcl) (revision 3a867351bc680631bdf05f73b886763ac109a7f8) +++ library/nx/nx.tcl (.../nx.tcl) (revision e29434ffef30bea10b7422f1f295787d41377839) @@ -579,16 +579,9 @@ :alias "info parent" ::nsf::methods::object::info::parent :alias "info precedence" ::nsf::methods::object::info::precedence :method "info slots" {{-type ::nx::Slot} pattern:optional} { - set slotContainer [::nsf::self]::per-object-slot - if {[::nsf::object::exists $slotContainer]} { - set cmd [list ::nsf::methods::object::info::children -type $type] - if {[info exists pattern]} {lappend cmd $pattern} - set result [list] - foreach slot [$slotContainer {*}$cmd] { - if {[$slot per-object]} { lappend result $slot } - } - return $result - } + set cmd [list ::nsf::methods::object::info::slots -type $type] + if {[info exists pattern]} {lappend cmd $pattern} + return [::nsf::my {*}$cmd] } :alias "info vars" ::nsf::methods::object::info::vars }