I have some classes that are defined in C using the xotcl (cersion 1.4) C API. Things seem to work (I can create objects and invoke methods), but I can't get chaining to function. I can invoke the "next" command (using Tcl_Eval( interp, "xotcl::next")), but that fails with "next: can't find self"
I've stepped into the XOTcl code and it looks like it's searching the the interpreter's call stack to determine the active object but as near as I can tell, my C-defined methods don't correctly annotate Tcl's call stack.
I'm not aware of any documentation for the C API, so I used the library code (xotclsdbm.c) as an example. Is there anything I need to do beyond XOTclAddIMethod to get "next" to function? I'm using a locally built version of XOTcl (the binary versions don't include header/libs). Is it possible I've built something incorrectly? I see two defintions for the RUNTIME_STATE macro which looks like it plays a role in this. I don't know which version I'm using or if it even matters, but I assume I'm using the default version.
Scott
On 15 Sep 2006, at 21:28, Scott Gargash wrote:
I've stepped into the XOTcl code and it looks like it's searching the the interpreter's call stack to determine the active object but as near as I can tell, my C-defined methods don't correctly annotate Tcl's call stack.
For the record I have stumbled across a related problem with at least some version of XOTcl. This was some while ago so perhaps it's not true for 1.5. I should've recorded the exact circumstances back then, but I was so busy that I didn't get round to it.
Basically, if I remember correctly, I found that doing [uplevel 1 self] did not always appear to work as expected. Ie. in some situations [self] would be reported wrong or was it that it did not work at all. I cannot recall the exact circumstances and I believe I wasn't certain what they were at the time (hence the need to spend some effort with it, which I did not get round to). OK, so this isn't likely to be a very useful report, if one can even call it that, but I thought it might be worth mentioning in case it might ring a bell or two with XOTcl developers.
Oh, also errors taking place inside filters might get really strange results. Again, this might be fixed in 1.5.
xotcl-bounces@alice.wu-wien.ac.at wrote on 09/15/2006 12:28:50 PM:
I have some classes that are defined in C using the xotcl (cersion 1.4) C API. Things seem to work (I can create objects and invoke methods), but I can't get chaining to function. I can invoke the "next" command (using Tcl_Eval( interp, "xotcl::next")), but that fails with "next: can't find self"
Just a followup for anybody searching the mailing list archives.
XOTcl requires the Tcl stack to contain information about the executing object in order to resolve the net method. By default, and prior to 1.5.1, C methods do not annotate the Tcl stack with the approriate information to allow method chaining to work.
As of 1.5.1, C methods can be registered with an additional flag, XOTCL_NONLEAF_METHOD. When a method with this flag is invoked the Tcl stack will include the information needed to allow "next" to function properly.
In addition to the new flag, 1.5.1 exports a couple of additional C functions to improve the performance of the XOTcl at the C-interface.
XOTclNextObjCmd() - invoke "xotcl::next" at the C-level without an additional interpreter evaluation XOTclCallMethodWithArgs() - invoke a method without an additional interpreter evaluation