Index: TODO =================================================================== diff -u -rafe1427fb16c3833bbbf45bb8496e059a6519d09 -r8ee718fe7e27c3df71bc659f3261710a4aaf5805 --- TODO (.../TODO) (revision afe1427fb16c3833bbbf45bb8496e059a6519d09) +++ TODO (.../TODO) (revision 8ee718fe7e27c3df71bc659f3261710a4aaf5805) @@ -1499,6 +1499,12 @@ - renamed cscPtr->callType to cscPtr->flags, since this is now more appropriate - some more minor cleanup +- changed "info method lookup -application" into + "info method lookup -source application" +- introduced "info method lookup -source application|baseclasses|all" +- updated migration guide +- extended regression test + TODO: - check my for NRE-enabling - major coro cleanup, when working Index: doc/next-migration.html =================================================================== diff -u -r89376e0f64856bb395fdb4407c9646787545a08b -r8ee718fe7e27c3df71bc659f3261710a4aaf5805 --- doc/next-migration.html (.../next-migration.html) (revision 89376e0f64856bb395fdb4407c9646787545a08b) +++ doc/next-migration.html (.../next-migration.html) (revision 8ee718fe7e27c3df71bc659f3261710a4aaf5805) @@ -968,7 +968,7 @@ n.a. # List only application specific methods
- obj info lookup methods -application ... ?pattern?
+ obj info lookup methods -source application ... ?pattern?
# Returns list of method names
@@ -983,7 +983,7 @@ # Options for 'info lookup methods'
#
- # -application
+ # -source ...
# -callprotection ...
# -incontext
# -methodtype ...
@@ -1449,6 +1449,6 @@
- Last modified: Mon Sep 13 16:07:33 CEST 2010 + Last modified: Fri Sep 24 17:34:10 CEST 2010 Index: generic/gentclAPI.decls =================================================================== diff -u -rac57ffc3be1f6ccef6ca5b2d5362cba07960fdc8 -r8ee718fe7e27c3df71bc659f3261710a4aaf5805 --- generic/gentclAPI.decls (.../gentclAPI.decls) (revision ac57ffc3be1f6ccef6ca5b2d5362cba07960fdc8) +++ generic/gentclAPI.decls (.../gentclAPI.decls) (revision 8ee718fe7e27c3df71bc659f3261710a4aaf5805) @@ -257,7 +257,7 @@ objectInfoMethod lookupmethods NsfObjInfoLookupMethodsMethod { {-argName "-methodtype" -nrargs 1 -type "all|scripted|builtin|alias|forwarder|object|setter"} {-argName "-callprotection" -nrargs 1 -type "all|protected|public" -default all} - {-argName "-application"} + {-argName "-source" -nrargs 1 -type "all|application|baseclasses"} {-argName "-nomixins"} {-argName "-incontext"} {-argName "pattern" -required 0} Index: generic/nsf.c =================================================================== diff -u -rafe1427fb16c3833bbbf45bb8496e059a6519d09 -r8ee718fe7e27c3df71bc659f3261710a4aaf5805 --- generic/nsf.c (.../nsf.c) (revision afe1427fb16c3833bbbf45bb8496e059a6519d09) +++ generic/nsf.c (.../nsf.c) (revision 8ee718fe7e27c3df71bc659f3261710a4aaf5805) @@ -11313,6 +11313,26 @@ return result; } +static int MethodSourceMatches(Tcl_Interp *interp, int withSource, NsfClass *cl) { + int isBaseClass; + if (withSource == SourceAllIdx) { + return 1; + } + if (cl == NULL) { + /* If the method is object specific, it can't be from a baseclass + * and must be application specfic. + */ + return (withSource == SourceApplicationIdx); + } + isBaseClass = IsBaseClass(cl); + if (withSource == SourceBaseclassesIdx && isBaseClass) { + return 1; + } else if (withSource == SourceApplicationIdx && !isBaseClass) { + return 1; + } + return 0; +} + static int MethodTypeMatches(Tcl_Interp *interp, int methodType, Tcl_Command cmd, NsfObject *object, CONST char *key, int withPer_object) { @@ -14939,22 +14959,24 @@ return TCL_OK; } + + + /* objectInfoMethod lookupmethods NsfObjInfoLookupMethodsMethod { {-argName "-methodtype" -nrargs 1 -type "all|scripted|builtin|alias|forwarder|object|setter"} {-argName "-callprotection" -nrargs 1 -type "all|protected|public" -default all} - {-argName "-application"} + {-argName "-source" -nrargs 1 -type "all|application|baseclasses"} {-argName "-nomixins"} {-argName "-incontext"} {-argName "pattern" -required 0} } */ static int NsfObjInfoLookupMethodsMethod(Tcl_Interp *interp, NsfObject *object, - int withMethodtype, int withCallprotection, - int withApplication, - int withNomixins, int withIncontext, CONST char *pattern) { - /* todo: own method needed? */ + int withMethodtype, int withCallprotection, + int withSource, int withNomixins, int withIncontext, + CONST char *pattern) { NsfClasses *pl; int withPer_object = 1; Tcl_HashTable *cmdTable, dupsTable, *dups = &dupsTable; @@ -14969,16 +14991,17 @@ if (withCallprotection == CallprotectionNULL) { withCallprotection = CallprotectionPublicIdx; } - - if (withApplication && object->flags & IsBaseClass((NsfClass*)object)) { - return TCL_OK; + if (withSource == SourceNULL) { + withSource = SourceAllIdx; } Tcl_InitHashTable(dups, TCL_STRING_KEYS); if (object->nsPtr) { cmdTable = Tcl_Namespace_cmdTable(object->nsPtr); - ListMethodKeys(interp, cmdTable, pattern, methodType, withCallprotection, - dups, object, withPer_object); + if (MethodSourceMatches(interp, withSource, NULL)) { + ListMethodKeys(interp, cmdTable, pattern, methodType, withCallprotection, + dups, object, withPer_object); + } } if (!withNomixins) { @@ -14991,14 +15014,14 @@ int guardOk = TCL_OK; mixin = NsfGetClassFromCmdPtr(ml->cmdPtr); assert(mixin); - if (withIncontext) { if (!RUNTIME_STATE(interp)->guardCount) { guardOk = GuardCall(object, 0, 0, interp, ml->clientData, NULL); } } if (mixin && guardOk == TCL_OK) { Tcl_HashTable *cmdTable = Tcl_Namespace_cmdTable(mixin->nsPtr); + if (!MethodSourceMatches(interp, withSource, mixin)) continue; ListMethodKeys(interp, cmdTable, pattern, methodType, withCallprotection, dups, object, withPer_object); } @@ -15009,9 +15032,7 @@ /* append method keys from inheritance order */ for (pl = ComputeOrder(object->cl, object->cl->order, Super); pl; pl = pl->nextPtr) { Tcl_HashTable *cmdTable = Tcl_Namespace_cmdTable(pl->cl->nsPtr); - if (withApplication && IsBaseClass(pl->cl)) { - break; - } + if (!MethodSourceMatches(interp, withSource, pl->cl)) continue; ListMethodKeys(interp, cmdTable, pattern, methodType, withCallprotection, dups, object, withPer_object); } Index: generic/tclAPI.h =================================================================== diff -u -rac57ffc3be1f6ccef6ca5b2d5362cba07960fdc8 -r8ee718fe7e27c3df71bc659f3261710a4aaf5805 --- generic/tclAPI.h (.../tclAPI.h) (revision ac57ffc3be1f6ccef6ca5b2d5362cba07960fdc8) +++ generic/tclAPI.h (.../tclAPI.h) (revision 8ee718fe7e27c3df71bc659f3261710a4aaf5805) @@ -109,6 +109,17 @@ } enum ObjectkindIdx {ObjectkindNULL, ObjectkindClassIdx, ObjectkindBaseclassIdx, ObjectkindMetaclassIdx}; +static int ConvertToSource(Tcl_Interp *interp, Tcl_Obj *objPtr, NsfParam CONST *pPtr, + ClientData *clientData, Tcl_Obj **outObjPtr) { + int index, result; + static CONST char *opts[] = {"all", "application", "baseclasses", NULL}; + result = Tcl_GetIndexFromObj(interp, objPtr, opts, "-source", 0, &index); + *clientData = (ClientData) INT2PTR(index + 1); + *outObjPtr = objPtr; + return result; +} +enum SourceIdx {SourceNULL, SourceAllIdx, SourceApplicationIdx, SourceBaseclassesIdx}; + typedef struct { CONST char *methodName; @@ -291,7 +302,7 @@ static int NsfObjInfoIsMethod(Tcl_Interp *interp, NsfObject *obj, int objectkind); static int NsfObjInfoLookupFilterMethod(Tcl_Interp *interp, NsfObject *obj, CONST char *filter); static int NsfObjInfoLookupMethodMethod(Tcl_Interp *interp, NsfObject *obj, CONST char *name); -static int NsfObjInfoLookupMethodsMethod(Tcl_Interp *interp, NsfObject *obj, int withMethodtype, int withCallprotection, int withApplication, int withNomixins, int withIncontext, CONST char *pattern); +static int NsfObjInfoLookupMethodsMethod(Tcl_Interp *interp, NsfObject *obj, int withMethodtype, int withCallprotection, int withSource, int withNomixins, int withIncontext, CONST char *pattern); static int NsfObjInfoLookupSlotsMethod(Tcl_Interp *interp, NsfObject *obj, NsfClass *withType); static int NsfObjInfoMethodMethod(Tcl_Interp *interp, NsfObject *obj, int infomethodsubcmd, Tcl_Obj *name); static int NsfObjInfoMethodsMethod(Tcl_Interp *interp, NsfObject *obj, int withMethodtype, int withCallprotection, int withNomixins, int withIncontext, CONST char *pattern); @@ -1832,13 +1843,13 @@ } else { int withMethodtype = (int )PTR2INT(pc.clientData[0]); int withCallprotection = (int )PTR2INT(pc.clientData[1]); - int withApplication = (int )PTR2INT(pc.clientData[2]); + int withSource = (int )PTR2INT(pc.clientData[2]); int withNomixins = (int )PTR2INT(pc.clientData[3]); int withIncontext = (int )PTR2INT(pc.clientData[4]); CONST char *pattern = (CONST char *)pc.clientData[5]; ParseContextRelease(&pc); - return NsfObjInfoLookupMethodsMethod(interp, obj, withMethodtype, withCallprotection, withApplication, withNomixins, withIncontext, pattern); + return NsfObjInfoLookupMethodsMethod(interp, obj, withMethodtype, withCallprotection, withSource, withNomixins, withIncontext, pattern); } } @@ -2319,7 +2330,7 @@ {"::nsf::cmd::ObjectInfo::lookupmethods", NsfObjInfoLookupMethodsMethodStub, 6, { {"-methodtype", 0, 1, ConvertToMethodtype}, {"-callprotection", 0, 1, ConvertToCallprotection}, - {"-application", 0, 0, ConvertToString}, + {"-source", 0, 1, ConvertToSource}, {"-nomixins", 0, 0, ConvertToString}, {"-incontext", 0, 0, ConvertToString}, {"pattern", 0, 0, ConvertToString}} Index: library/lib/doc-tools.tcl =================================================================== diff -u -rd168a26bce713de8daa5bbe79d740926e961c5bc -r8ee718fe7e27c3df71bc659f3261710a4aaf5805 --- library/lib/doc-tools.tcl (.../doc-tools.tcl) (revision d168a26bce713de8daa5bbe79d740926e961c5bc) +++ library/lib/doc-tools.tcl (.../doc-tools.tcl) (revision 8ee718fe7e27c3df71bc659f3261710a4aaf5805) @@ -508,7 +508,7 @@ :method register {containable:object,type=::nx::doc::Entity} { set tag [[$containable info class] tag] - if {[:info lookup methods -application "@$tag"] ne ""} { + if {[:info lookup methods -source application "@$tag"] ne ""} { :@$tag $containable } } @@ -1971,7 +1971,7 @@ :method parse@tag {line} { set line [split [string trimleft $line]] set tag [lindex $line 0] - if {[:info lookup methods -application $tag] eq ""} { + if {[:info lookup methods -source application $tag] eq ""} { set msg "The tag '$tag' is not supported for the entity type '[namespace tail [:info class]]" ${:block_parser} cancel INVALIDTAG $msg } @@ -2042,7 +2042,7 @@ set args [lassign $line tag name] lassign [:resolve_partof_entity $tag $name] nq_name partof_entity if {$partof_entity ne ""} { - if {[$partof_entity info lookup methods -application $tag] eq ""} { + if {[$partof_entity info lookup methods -source application $tag] eq ""} { ${:block_parser} cancel INVALIDTAG "The tag '$tag' is not supported for the entity type '[namespace tail [$partof_entity info class]]'" # [InvalidTag new -message [subst { @@ -2132,7 +2132,7 @@ # set operand [@$axis new -name $value ] set operand [@$axis id $value] } else { - if {[$operand info lookup methods -application @$axis] eq ""} { + if {[$operand info lookup methods -source application @$axis] eq ""} { ${:block_parser} cancel INVALIDTAG "The tag '$axis' is not supported for the entity type '[namespace tail [$operand info class]]'" } # puts stderr "$operand @$axis id $value" @@ -2149,7 +2149,7 @@ } set operand [@$leaf(axis) new -name $leaf(name) $args] } else { - if {[$operand info lookup methods -application @$leaf(axis)] eq ""} { + if {[$operand info lookup methods -source application @$leaf(axis)] eq ""} { ${:block_parser} cancel INVALIDTAG "The tag '$leaf(axis)' is not supported for the entity type '[namespace tail [$operand info class]]'" } set operand [$operand @$leaf(axis) [list $leaf(name) {*}$args]] Index: library/tcl-cool/tcl-cool.tcl =================================================================== diff -u -ra5e11e1cf74cc5432824aaaf3c45cd436a6e072c -r8ee718fe7e27c3df71bc659f3261710a4aaf5805 --- library/tcl-cool/tcl-cool.tcl (.../tcl-cool.tcl) (revision a5e11e1cf74cc5432824aaaf3c45cd436a6e072c) +++ library/tcl-cool/tcl-cool.tcl (.../tcl-cool.tcl) (revision 8ee718fe7e27c3df71bc659f3261710a4aaf5805) @@ -318,7 +318,8 @@ # >Yippy, I'll get that wicked tweedy!! -puts "\nApplication specific methods of fido: [fido methods -application]" +puts "\nApplication specific methods of fido: [fido methods -source application]" +puts "System specific methods of fido: [fido methods -source baseclasses]" puts "All methods of fido: [fido methods]\n" foreach cmd {{fido wag} {fido rise}} { puts "$cmd [time {eval $cmd} 10000]" } Index: tests/info-method.tcl =================================================================== diff -u -r56b83f4c74bab76211b7a4f6225706f0f54cfa69 -r8ee718fe7e27c3df71bc659f3261710a4aaf5805 --- tests/info-method.tcl (.../info-method.tcl) (revision 56b83f4c74bab76211b7a4f6225706f0f54cfa69) +++ tests/info-method.tcl (.../info-method.tcl) (revision 8ee718fe7e27c3df71bc659f3261710a4aaf5805) @@ -64,11 +64,23 @@ ? {C info method definition a} "::C alias a ::set" ? {C class-object info method definition apo} "::C class-object alias apo ::puts" - ? {::nx::Object info lookup methods -application} "" - ? {::nx::Class info lookup methods -application} "" - ? {lsort [C info lookup methods -application]} "add1 apo fpo mpo spo" - ? {lsort [c1 info lookup methods -application]} "a addOne foo m m-with-assertions s" + ? {::nx::Object info lookup methods -source application} "" + ? {::nx::Class info lookup methods -source application} "" + set object_methods "__default_method_protection alias attribute class configure contains copy destroy eval filter forward info method mixin move protected public require setter volatile vwait" + set class_methods "__default_method_protection alias alloc attribute attributes class class-object configure contains copy create dealloc destroy eval filter forward info method mixin move new protected public require setter superclass volatile vwait" + + ? {lsort [::nx::Object info lookup methods -source baseclasses]} $class_methods + ? {lsort [::nx::Class info lookup methods -source baseclasses]} $class_methods + ? {lsort [::nx::Object info lookup methods -source all]} $class_methods + ? {lsort [::nx::Class info lookup methods -source all]} $class_methods + ? {lsort [::nx::Object info lookup methods]} $class_methods + ? {lsort [::nx::Class info lookup methods]} $class_methods + ? {lsort [C info lookup methods -source application]} "add1 apo fpo mpo spo" + ? {lsort [c1 info lookup methods -source application]} "a addOne foo m m-with-assertions s" + ? {lsort [C info lookup methods -source baseclasses]} $class_methods + ? {lsort [c1 info lookup methods -source baseclasses]} $object_methods + ::nx::configure defaultMethodProtection true # # the subsequent tests assume defaultMethodProtection == true @@ -307,16 +319,14 @@ {::C method {bar baz y} {x:int y:upper} {return y}} ? {nx::Object info method parameter "info lookup methods"} \ - "-methodtype -callprotection -application -nomixins -incontext pattern:optional" + "-methodtype -callprotection -source -nomixins -incontext pattern:optional" ? {o info method parameter "foo b"} "x:int y:upper" ? {nx::Object info method parameter ::nx::Object::slot::__info::lookup::methods} \ - "-methodtype -callprotection -application -nomixins -incontext pattern:optional" + "-methodtype -callprotection -source -nomixins -incontext pattern:optional" ? {o info method parameter "::o::foo::b"} "x:int y:upper" - ? {nx::Object info method handle "info"} "::nsf::classes::nx::Object::info" - ? {nx::Object info method handle "info lookup methods"} \ "::nsf::classes::nx::Object::info lookup methods"