Index: doc/migration1-2.html =================================================================== diff -u -r1ddb61a407f327672ce64aa1c1610e7043c10ec7 -rff41e1a0cb88c3aa7b96ca3b67b27043794991b0 --- doc/migration1-2.html (.../migration1-2.html) (revision 1ddb61a407f327672ce64aa1c1610e7043c10ec7) +++ doc/migration1-2.html (.../migration1-2.html) (revision ff41e1a0cb88c3aa7b96ca3b67b27043794991b0) @@ -8,28 +8,40 @@ background-color : white; color: black; } -code em { - /*font-family: cursive;*/ - color: #888888; +table i { + font-size: 80%; } -code tt { - font-family: helvetica; - font-weight: 900; +table td code i { + font-style: italic; + color: green; } -code i { - font-style: italic; - color: green; -} -tt em { -font-family: cursive; - color: #888888; -} + th {color: #888888;} -td hr {color: #FFFFFF; margin: 10 10 10 10;} +td hr { + color: #FFFFFF; + border-bottom-style: none; + border-left-style: none; + border-right-style: none; + border-top-style: dashed; + border-color: #AAAAAA; + margin: 10 10 10 10; +} /*table {font-size: 80%;}*/ -table {width: 700;} +table { + width: 900; + border-collapse:collapse; +} +table th { + width: 400; + border:1px solid black; +} +table td { + width: 400; + border:1px solid #AAAAAA; +} + @@ -52,7 +64,7 @@

XOTcl 1 Idioms in XOTcl 2

Defining Objects and Classes

- +
@@ -164,82 +176,191 @@
XOTcl 1XOTcl 2
Class ClassName
- - + + - - + - - - - + +
XOTcl 1XOTcl 2
someObject set varname valuesomeObject eval [list set .varname value]obj set varname valueobj eval [list set .varname value]
set newVar [someObject set otherVar]set newVar [someObject eval {set .otherVar}]
+
set newVar [obj set otherVar]set newVar [obj eval {set .otherVar}]
someObject instvar newVar
+
obj instvar newVar
set newVar value
::xotcl::importvar someObject newVar
+
::xotcl::importvar obj newVar
set newVar value
someObject exists varnamesomeObject eval {info exists .varname}obj exists varnameobj eval {info exists .varname}

Object Parameters

Method Parameters

Introspection

+ +

List methods defined by objects

- - - + + + - - + + + + + + + + + + + + + + + + + + + + + +
XOTcl 1XOTcl 2
someObject info methods ?pattern?someObject info callable ?pattern?
obj info commands ?pattern?obj info methods ?pattern?
someObject procsearch methodNamesomeObject info callable -which methodNameobj info parametercmd ?pattern?obj info methods -methodtype setter ?pattern?
obj info procs ?pattern?obj info methods -methodtype scripted ?pattern?
n.a.obj info methods -methodtype alias ?pattern?
n.a.obj info methods -methodtype forwarder ?pattern?
n.a.obj info methods -methodtype object ?pattern?
n.a.obj info methods -callprotection public|protected ...
- +

List methods defined by classes

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
cls info instcommands ?pattern?cls info methods ?pattern?
cls info instparametercmd ?pattern?cls info methods -methodtype setter ?pattern?
cls info instprocs ?pattern?cls info methods -methodtype scripted ?pattern?
n.a.cls info methods -methodtype alias ?pattern?
n.a.cls info methods -methodtype forwarder ?pattern?
n.a.cls info methods -methodtype object ?pattern?
n.a.cls info methods -callprotection public|protected ...
+ +

List class object specific methods

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
cls info commands ?pattern?cls object info methods ?pattern?
cls info parametercmd ?pattern?cls object info methods -methodtype setter ?pattern?
cls info procs ?pattern?cls object info methods -methodtype scripted ?pattern?
n.a.cls object info methods -methodtype alias ?pattern?
n.a.cls object info methods -methodtype forwarder ?pattern?
n.a.cls object info methods -methodtype object ?pattern?
n.a.cls object info methods -callprotection public|protected ...
+ +

List callable methods

+ + + + + + + + + + +
XOTcl 1XOTcl 2
obj info methods ?pattern?obj info callable ?pattern?
n.a.# list only application specific methods
+ obj info callable -application
+ +

List object/class where some method is defined

+ + + + + + + +
XOTcl 1XOTcl 2
obj procsearch methodNameobj info callable -which methodName
+

Predefined Methods

Dispatch, Aliases, etc.

Assertions

- - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + @@ -248,5 +369,5 @@
- Last modified: Mon Jan 4 21:25:17 CET 2010 + Last modified: Tue Jan 5 18:26:03 CET 2010 Index: generic/gentclAPI.decls =================================================================== diff -u -r6b3921be54ad92034e563a09300ab2e4f49645aa -rff41e1a0cb88c3aa7b96ca3b67b27043794991b0 --- generic/gentclAPI.decls (.../gentclAPI.decls) (revision 6b3921be54ad92034e563a09300ab2e4f49645aa) +++ generic/gentclAPI.decls (.../gentclAPI.decls) (revision ff41e1a0cb88c3aa7b96ca3b67b27043794991b0) @@ -276,16 +276,17 @@ infoObjectMethod callable XOTclObjInfoCallableMethod { {-argName "object" -type object} {-argName "-which"} - {-argName "-methodtype" -nrargs 1 -type "all|scripted|system|alias|forwarder|object|setter"} + {-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 "-nomixins"} {-argName "-incontext"} {-argName "pattern" -required 0} } infoObjectMethod methods XOTclObjInfoMethodsMethod { {-argName "object" -type object} - {-argName "-methodtype" -nrargs 1 -type "all|scripted|system|alias|forwarder|object|setter"} + {-argName "-methodtype" -nrargs 1 -type "all|scripted|builtin|alias|forwarder|object|setter"} {-argName "-callprotection" -nrargs 1 -type "all|protected|public" -default public} {-argName "-nomixins"} {-argName "-incontext"} @@ -294,7 +295,7 @@ ### TODO move finally to infoclassmethod infoClassMethod methods XOTclClassInfoMethodsMethod { {-argName "object" -type class} - {-argName "-methodtype" -nrargs 1 -type "all|scripted|system|alias|forwarder|object|setter"} + {-argName "-methodtype" -nrargs 1 -type "all|scripted|builtin|alias|forwarder|object|setter"} {-argName "-callprotection" -nrargs 1 -type "all|protected|public" -default public} {-argName "-nomixins"} {-argName "-incontext"} Index: generic/tclAPI.h =================================================================== diff -u -r6b3921be54ad92034e563a09300ab2e4f49645aa -rff41e1a0cb88c3aa7b96ca3b67b27043794991b0 --- generic/tclAPI.h (.../tclAPI.h) (revision 6b3921be54ad92034e563a09300ab2e4f49645aa) +++ generic/tclAPI.h (.../tclAPI.h) (revision ff41e1a0cb88c3aa7b96ca3b67b27043794991b0) @@ -10,12 +10,12 @@ static int convertToMethodtype(Tcl_Interp *interp, Tcl_Obj *objPtr, XOTclParam CONST *pPtr, ClientData *clientData) { int index, result; - static CONST char *opts[] = {"all", "scripted", "system", "alias", "forwarder", "object", "setter", NULL}; + static CONST char *opts[] = {"all", "scripted", "builtin", "alias", "forwarder", "object", "setter", NULL}; result = Tcl_GetIndexFromObj(interp, objPtr, opts, "-methodtype", 0, &index); *clientData = (ClientData) INT2PTR(index + 1); return result; } -enum MethodtypeIdx {MethodtypeNULL, MethodtypeAllIdx, MethodtypeScriptedIdx, MethodtypeSystemIdx, MethodtypeAliasIdx, MethodtypeForwarderIdx, MethodtypeObjectIdx, MethodtypeSetterIdx}; +enum MethodtypeIdx {MethodtypeNULL, MethodtypeAllIdx, MethodtypeScriptedIdx, MethodtypeBuiltinIdx, MethodtypeAliasIdx, MethodtypeForwarderIdx, MethodtypeObjectIdx, MethodtypeSetterIdx}; static int convertToCallprotection(Tcl_Interp *interp, Tcl_Obj *objPtr, XOTclParam CONST *pPtr, ClientData *clientData) { int index, result; @@ -211,7 +211,7 @@ static int XOTclClassInfoSlotsMethod(Tcl_Interp *interp, XOTclClass *class); static int XOTclClassInfoSubclassMethod(Tcl_Interp *interp, XOTclClass *class, int withClosure, char *patternString, XOTclObject *patternObj); static int XOTclClassInfoSuperclassMethod(Tcl_Interp *interp, XOTclClass *class, int withClosure, Tcl_Obj *pattern); -static int XOTclObjInfoCallableMethod(Tcl_Interp *interp, XOTclObject *object, int withWhich, int withMethodtype, int withCallprotection, int withNomixins, int withIncontext, char *pattern); +static int XOTclObjInfoCallableMethod(Tcl_Interp *interp, XOTclObject *object, int withWhich, int withMethodtype, int withCallprotection, int withApplication, int withNomixins, int withIncontext, char *pattern); static int XOTclObjInfoChildrenMethod(Tcl_Interp *interp, XOTclObject *object, char *pattern); static int XOTclObjInfoClassMethod(Tcl_Interp *interp, XOTclObject *object); static int XOTclObjInfoFilterMethod(Tcl_Interp *interp, XOTclObject *object, int withOrder, int withGuards, char *pattern); @@ -924,12 +924,13 @@ int withWhich = (int )PTR2INT(pc.clientData[1]); int withMethodtype = (int )PTR2INT(pc.clientData[2]); int withCallprotection = (int )PTR2INT(pc.clientData[3]); - int withNomixins = (int )PTR2INT(pc.clientData[4]); - int withIncontext = (int )PTR2INT(pc.clientData[5]); - char *pattern = (char *)pc.clientData[6]; + int withApplication = (int )PTR2INT(pc.clientData[4]); + int withNomixins = (int )PTR2INT(pc.clientData[5]); + int withIncontext = (int )PTR2INT(pc.clientData[6]); + char *pattern = (char *)pc.clientData[7]; parseContextRelease(&pc); - return XOTclObjInfoCallableMethod(interp, object, withWhich, withMethodtype, withCallprotection, withNomixins, withIncontext, pattern); + return XOTclObjInfoCallableMethod(interp, object, withWhich, withMethodtype, withCallprotection, withApplication, withNomixins, withIncontext, pattern); } } @@ -2056,11 +2057,12 @@ {"-closure", 0, 0, convertToString}, {"pattern", 0, 0, convertToTclobj}} }, -{"::xotcl::cmd::ObjectInfo::callable", XOTclObjInfoCallableMethodStub, 7, { +{"::xotcl::cmd::ObjectInfo::callable", XOTclObjInfoCallableMethodStub, 8, { {"object", 0, 0, convertToObject}, {"-which", 0, 0, convertToString}, {"-methodtype", 0, 1, convertToMethodtype}, {"-callprotection", 0, 1, convertToCallprotection}, + {"-application", 0, 0, convertToString}, {"-nomixins", 0, 0, convertToString}, {"-incontext", 0, 0, convertToString}, {"pattern", 0, 0, convertToString}} Index: generic/xotcl.c =================================================================== diff -u -r1c11937f4f0aea905fbedfbb9c2d1782b08833f5 -rff41e1a0cb88c3aa7b96ca3b67b27043794991b0 --- generic/xotcl.c (.../xotcl.c) (revision 1c11937f4f0aea905fbedfbb9c2d1782b08833f5) +++ generic/xotcl.c (.../xotcl.c) (revision ff41e1a0cb88c3aa7b96ca3b67b27043794991b0) @@ -10160,7 +10160,7 @@ static int ListCallableMethods(Tcl_Interp *interp, XOTclObject *object, char *pattern, int withPer_object, int methodType, int withCallprotection, - int noMixins, int inContext) { + int withApplication, int noMixins, int inContext) { XOTclClasses *pl; Tcl_HashTable *cmdTable, dupsTable, *dups = &dupsTable; @@ -10174,6 +10174,10 @@ withCallprotection = CallprotectionPublicIdx; } + if (withApplication && object->flags & (XOTCL_IS_ROOT_META_CLASS|XOTCL_IS_ROOT_CLASS)) { + return TCL_OK; + } + Tcl_InitHashTable(dups, TCL_STRING_KEYS); if (object->nsPtr) { cmdTable = Tcl_Namespace_cmdTable(object->nsPtr); @@ -10204,9 +10208,12 @@ } } - /* append per-class filters */ + /* 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 && pl->cl->object.flags & (XOTCL_IS_ROOT_META_CLASS|XOTCL_IS_ROOT_CLASS)) { + break; + } ListMethodKeys(interp, cmdTable, pattern, methodType, withCallprotection, dups, object, withPer_object); } @@ -12853,13 +12860,13 @@ switch (methodType) { case MethodtypeNULL: /* default */ case MethodtypeAllIdx: - methodType = XOTCL_METHODTYPE_SCRIPTED|XOTCL_METHODTYPE_SYSTEM; + methodType = XOTCL_METHODTYPE_SCRIPTED|XOTCL_METHODTYPE_BUILTIN; break; case MethodtypeScriptedIdx: methodType = XOTCL_METHODTYPE_SCRIPTED|XOTCL_METHODTYPE_ALIAS; break; - case MethodtypeSystemIdx: - methodType = XOTCL_METHODTYPE_SYSTEM; + case MethodtypeBuiltinIdx: + methodType = XOTCL_METHODTYPE_BUILTIN; break; case MethodtypeForwarderIdx: methodType = XOTCL_METHODTYPE_FORWARDER; @@ -12896,8 +12903,20 @@ } /* todo move me to the right place */ +/* +infoObjectMethod callable XOTclObjInfoCallableMethod { + {-argName "object" -type object} + {-argName "-which"} + {-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 "-nomixins"} + {-argName "-incontext"} + {-argName "pattern" -required 0} +*/ static int XOTclObjInfoCallableMethod(Tcl_Interp *interp, XOTclObject *object, int withWhich, int withMethodtype, int withCallprotection, + int withApplication, int withNomixins, int withIncontext, char *pattern) { if (withWhich) { XOTclClass *pcl = NULL; @@ -12912,7 +12931,7 @@ return ListCallableMethods(interp, object, pattern, 1 /* per-object */, AggregatedMethodType(withMethodtype), withCallprotection, - withNomixins, withIncontext); + withApplication, withNomixins, withIncontext); } static int XOTclObjInfoMethodMethod(Tcl_Interp *interp, XOTclObject *object, Index: generic/xotclInt.h =================================================================== diff -u -r1c11937f4f0aea905fbedfbb9c2d1782b08833f5 -rff41e1a0cb88c3aa7b96ca3b67b27043794991b0 --- generic/xotclInt.h (.../xotclInt.h) (revision 1c11937f4f0aea905fbedfbb9c2d1782b08833f5) +++ generic/xotclInt.h (.../xotclInt.h) (revision ff41e1a0cb88c3aa7b96ca3b67b27043794991b0) @@ -431,7 +431,7 @@ #define XOTCL_METHODTYPE_FORWARDER 0x0008 #define XOTCL_METHODTYPE_OBJECT 0x0010 #define XOTCL_METHODTYPE_OTHER 0x0100 -#define XOTCL_METHODTYPE_SYSTEM XOTCL_METHODTYPE_ALIAS|XOTCL_METHODTYPE_SETTER|XOTCL_METHODTYPE_FORWARDER|XOTCL_METHODTYPE_OBJECT|XOTCL_METHODTYPE_OTHER +#define XOTCL_METHODTYPE_BUILTIN XOTCL_METHODTYPE_ALIAS|XOTCL_METHODTYPE_SETTER|XOTCL_METHODTYPE_FORWARDER|XOTCL_METHODTYPE_OBJECT|XOTCL_METHODTYPE_OTHER /* disallowed options */ #define XOTCL_ARG_METHOD_PARAMETER (XOTCL_ARG_RELATION) /* maybe add ARG_INITCMD */ Index: library/lib/xotcl1.xotcl =================================================================== diff -u -r1ddb61a407f327672ce64aa1c1610e7043c10ec7 -rff41e1a0cb88c3aa7b96ca3b67b27043794991b0 --- library/lib/xotcl1.xotcl (.../xotcl1.xotcl) (revision 1ddb61a407f327672ce64aa1c1610e7043c10ec7) +++ library/lib/xotcl1.xotcl (.../xotcl1.xotcl) (revision ff41e1a0cb88c3aa7b96ca3b67b27043794991b0) @@ -327,7 +327,7 @@ } { set methodtype all if {$nocmds} {set methodtype scripted} - if {$noprocs} {if {$nocmds} {return ""}; set methodtype system} + if {$noprocs} {if {$nocmds} {return ""}; set methodtype builtin} set cmd [list ::xotcl::cmd::ObjectInfo::callable $o -methodtype $methodtype] if {$incontext} {lappend cmd -incontext} if {[::info exists pattern]} {lappend cmd $pattern} Index: tests/info-method.xotcl =================================================================== diff -u -rd70c849219212800fa401c2227796b9a63eadcaf -rff41e1a0cb88c3aa7b96ca3b67b27043794991b0 --- tests/info-method.xotcl (.../info-method.xotcl) (revision d70c849219212800fa401c2227796b9a63eadcaf) +++ tests/info-method.xotcl (.../info-method.xotcl) (revision ff41e1a0cb88c3aa7b96ca3b67b27043794991b0) @@ -74,3 +74,9 @@ ? {C info method definition a} "::C alias a ::set" ? {C object info method definition apo} "::C object alias apo ::puts" + + +? {::xotcl2::Object info callable -application} "" +? {::xotcl2::Class info callable -application} "" +? {lsort [C info callable -application]} "add1 apo fpo mpo spo" +? {lsort [c1 info callable -application]} "a addOne foo m m-with-assertions s" \ No newline at end of file
XOTcl 1XOTcl 2
objectName check checkptions::xotcl::assertion objectName check checkptionsobj check checkptions::xotcl::assertion obj check checkptions
objectName info check::xotcl::assertion objectName checkobj info check::xotcl::assertion obj check
objectName invar conditions::xotcl::assertion objectName object-invar conditionsobj invar conditions::xotcl::assertion obj object-invar conditions
objectName info invar::xotcl::assertion objectName object-invarobj info invar::xotcl::assertion obj object-invar
className instinvar conditions::xotcl::assertion className class-invar conditionscls instinvar conditions::xotcl::assertion cls class-invar conditions
className info instinvar::xotcl::assertion className class-invarcls info instinvar::xotcl::assertion cls class-invar
className invar conditions::xotcl::assertion className object-invar conditionscls invar conditions::xotcl::assertion cls object-invar conditions
className info invar::xotcl::assertion className object-invarcls info invar::xotcl::assertion cls object-invar