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); }