Index: TODO =================================================================== diff -u -r8046b1da6bc0689f73d4dbdc3f8d1e03fd23acaf -rac96e6ce975fe5864b64dee9d66bc701a31e113b --- TODO (.../TODO) (revision 8046b1da6bc0689f73d4dbdc3f8d1e03fd23acaf) +++ TODO (.../TODO) (revision ac96e6ce975fe5864b64dee9d66bc701a31e113b) @@ -3427,6 +3427,11 @@ - renamed "nsf::method::dispatch" to "nsf::directdispatch" - renamed "nsf::object::dispatch" to "nsf::dispatch" +- nsf.c: + * added permissable value "private" to flag "-callprotection" for + "info lookup method" and "info methods". + * extended regression test + TODO: - private: * document private in migration guide tutorial Index: generic/nsf.c =================================================================== diff -u -r3c3b37a34bbdbf3b0b5e2300bb577bc9b6fd40cc -rac96e6ce975fe5864b64dee9d66bc701a31e113b --- generic/nsf.c (.../nsf.c) (revision 3c3b37a34bbdbf3b0b5e2300bb577bc9b6fd40cc) +++ generic/nsf.c (.../nsf.c) (revision ac96e6ce975fe5864b64dee9d66bc701a31e113b) @@ -16676,7 +16676,7 @@ * ProtectionMatches -- * * Check, whether the provided method (specified as a cmd) matches with the - * required call-protection (typically all|protected|public). + * required call-protection (typically all|public|protected|private). * * Results: * Returns true or false @@ -16689,14 +16689,21 @@ static int ProtectionMatches(int withCallprotection, Tcl_Command cmd) { - int result, isProtected = Tcl_Command_flags(cmd) & NSF_CMD_CALL_PROTECTED_METHOD; + int result, isProtected, isPrivate, cmdFlags; + + assert(cmd); + cmdFlags = Tcl_Command_flags(cmd); + isProtected = (cmdFlags & NSF_CMD_CALL_PROTECTED_METHOD) != 0; + isPrivate = (cmdFlags & NSF_CMD_CALL_PRIVATE_METHOD) != 0; + if (withCallprotection == CallprotectionNULL) { withCallprotection = CallprotectionPublicIdx; } switch (withCallprotection) { case CallprotectionAllIdx: result = 1; break; case CallprotectionPublicIdx: result = (isProtected == 0); break; - case CallprotectionProtectedIdx: result = (isProtected != 0); break; + case CallprotectionProtectedIdx: result = isProtected && !isPrivate; break; + case CallprotectionPrivateIdx: result = isPrivate; break; default: result = 1; } return result; @@ -21375,7 +21382,7 @@ /* objectInfoMethod lookupmethods NsfObjInfoLookupMethodsMethod { - {-argName "-callprotection" -nrargs 1 -type "all|protected|public" -default all} + {-argName "-callprotection" -nrargs 1 -type "all|public|protected|private" -default all} {-argName "-incontext"} {-argName "-methodtype" -nrargs 1 -type "all|scripted|builtin|alias|forwarder|object|setter"} {-argName "-nomixins"} @@ -21540,7 +21547,7 @@ /* objectInfoMethod methods NsfObjInfoMethodsMethod { - {-argName "-callprotection" -nrargs 1 -type "all|protected|public" -default public} + {-argName "-callprotection" -type "all|public|protected|private" -default all} {-argName "-methodtype" -nrargs 1 -type "all|scripted|builtin|alias|forwarder|object|setter"} {-argName "-path"} {-argName "pattern"} @@ -21837,7 +21844,7 @@ /* classInfoMethod methods NsfClassInfoMethodsMethod { - {-argName "-callprotection" -nrargs 1 -type "all|protected|public" -default public} + {-argName "-callprotection" -type "all|public|protected|private" -default all} {-argName "-methodtype" -nrargs 1 -type "all|scripted|builtin|alias|forwarder|object|setter"} {-argName "-path"} {-argName "pattern"} Index: generic/nsfAPI.decls =================================================================== diff -u -r8046b1da6bc0689f73d4dbdc3f8d1e03fd23acaf -rac96e6ce975fe5864b64dee9d66bc701a31e113b --- generic/nsfAPI.decls (.../nsfAPI.decls) (revision 8046b1da6bc0689f73d4dbdc3f8d1e03fd23acaf) +++ generic/nsfAPI.decls (.../nsfAPI.decls) (revision ac96e6ce975fe5864b64dee9d66bc701a31e113b) @@ -345,7 +345,7 @@ {-argName "name" -required 1 -type tclobj} } objectInfoMethod lookupmethods NsfObjInfoLookupMethodsMethod { - {-argName "-callprotection" -type "all|protected|public" -default all} + {-argName "-callprotection" -type "all|public|protected|private" -default all} {-argName "-incontext" -nrargs 0} {-argName "-methodtype" -type "all|scripted|builtin|alias|forwarder|object|setter"} {-argName "-nomixins" -nrargs 0} @@ -363,7 +363,7 @@ {-argName "name" -required 1 -type tclobj} } objectInfoMethod methods NsfObjInfoMethodsMethod { - {-argName "-callprotection" -type "all|protected|public" -default public} + {-argName "-callprotection" -type "all|public|protected|private" -default all} {-argName "-methodtype" -type "all|scripted|builtin|alias|forwarder|object|setter|nsfproc"} {-argName "-path" -nrargs 0} {-argName "pattern" -required 0} @@ -418,7 +418,7 @@ {-argName "name" -required 1 -type tclobj} } classInfoMethod methods NsfClassInfoMethodsMethod { - {-argName "-callprotection" -type "all|protected|public" -default public} + {-argName "-callprotection" -type "all|public|protected|private" -default all} {-argName "-methodtype" -type "all|scripted|builtin|alias|forwarder|object|setter|nsfproc"} {-argName "-path" -nrargs 0} {-argName "pattern"} Index: generic/nsfAPI.h =================================================================== diff -u -r8046b1da6bc0689f73d4dbdc3f8d1e03fd23acaf -rac96e6ce975fe5864b64dee9d66bc701a31e113b --- generic/nsfAPI.h (.../nsfAPI.h) (revision 8046b1da6bc0689f73d4dbdc3f8d1e03fd23acaf) +++ generic/nsfAPI.h (.../nsfAPI.h) (revision ac96e6ce975fe5864b64dee9d66bc701a31e113b) @@ -12,12 +12,12 @@ return result; } -enum CallprotectionIdx {CallprotectionNULL, CallprotectionAllIdx, CallprotectionProtectedIdx, CallprotectionPublicIdx}; +enum CallprotectionIdx {CallprotectionNULL, CallprotectionAllIdx, CallprotectionPublicIdx, CallprotectionProtectedIdx, CallprotectionPrivateIdx}; static int ConvertToCallprotection(Tcl_Interp *interp, Tcl_Obj *objPtr, Nsf_Param CONST *pPtr, ClientData *clientData, Tcl_Obj **outObjPtr) { int index, result; - static CONST char *opts[] = {"all", "protected", "public", NULL}; + static CONST char *opts[] = {"all", "public", "protected", "private", NULL}; (void)pPtr; result = Tcl_GetIndexFromObj(interp, objPtr, opts, "-callprotection", 0, &index); *clientData = (ClientData) INT2PTR(index + 1); @@ -186,7 +186,7 @@ {ConvertToScope, "all|class|object"}, {ConvertToInfoobjectparametersubcmd, "list|name|parameter|parametersyntax"}, {ConvertToInfomethodsubcmd, "args|body|definition|exists|handle|origin|parameter|parametersyntax|type|precondition|postcondition|submethods"}, - {ConvertToCallprotection, "all|protected|public"}, + {ConvertToCallprotection, "all|public|protected|private"}, {ConvertToMethodtype, "all|scripted|builtin|alias|forwarder|object|setter|nsfproc"}, {ConvertToFrame, "method|object|default"}, {ConvertToCurrentoption, "proc|method|methodpath|object|class|activelevel|args|activemixin|calledproc|calledmethod|calledclass|callingproc|callingmethod|callingclass|callinglevel|callingobject|filterreg|isnextcall|nextmethod"}, Index: tests/info-method.test =================================================================== diff -u -r29ed0c8902296dbea451c12d031cc06b6126dd5b -rac96e6ce975fe5864b64dee9d66bc701a31e113b --- tests/info-method.test (.../info-method.test) (revision 29ed0c8902296dbea451c12d031cc06b6126dd5b) +++ tests/info-method.test (.../info-method.test) (revision ac96e6ce975fe5864b64dee9d66bc701a31e113b) @@ -483,7 +483,7 @@ ? {nx::Object info method parameter "info lookup methods"} \ "-callprotection -incontext:switch -methodtype -nomixins:switch -path:switch -source pattern:optional" ? {nx::Object info method parametersyntax "info lookup methods"} \ - "?-callprotection all|protected|public? ?-incontext? ?-methodtype all|scripted|builtin|alias|forwarder|object|setter|nsfproc? ?-nomixins? ?-path? ?-source all|application|baseclasses? ?pattern?" + "?-callprotection all|public|protected|private? ?-incontext? ?-methodtype all|scripted|builtin|alias|forwarder|object|setter|nsfproc? ?-nomixins? ?-path? ?-source all|application|baseclasses? ?pattern?" ? {o info method parameter "foo b"} "x:int y:upper" Index: tests/protected.test =================================================================== diff -u -r2493736d00766ffa6a8eb5b536c616e4e8da34e9 -rac96e6ce975fe5864b64dee9d66bc701a31e113b --- tests/protected.test (.../protected.test) (revision 2493736d00766ffa6a8eb5b536c616e4e8da34e9) +++ tests/protected.test (.../protected.test) (revision ac96e6ce975fe5864b64dee9d66bc701a31e113b) @@ -330,6 +330,13 @@ :create d1 } + # check introspection and "-callprotection" filter + ? {lsort [C info methods]} "p2 p4" + ? {lsort [C info methods -callprotection all]} "p1 p2 p3 p4" + ? {lsort [C info methods -callprotection public]} "p2 p4" + ? {lsort [C info methods -callprotection protected]} "" + ? {lsort [C info methods -callprotection private]} "p1 p3" + # called shadowed # C.p1 private B.p1 private # C.p2 public B.p2 private