SWIG C++ TCL : Handling pre-existing objects in memory

Go To StackoverFlow.com


How do I access objects for which I don't have the string reference when using SWIG TCL wrappers?

Basically in my program some of the objects are predefined even before loading the the TCL shell. If writing the wrappers myself I would pass a pointer to a object which in turn has the pointers to all the objects created thus far. How can I achieve the same behavior through SWIG?

2012-04-04 06:54
by balaji kommineni


The simplest method would be to add static methods to the class (or some other wrapped class) that return these special instances. SWIG will then wrap the access correctly, and you'll be able to use the static method calling convention to get handles to those instances.

set foo [YourClass_specialFoo]     ;# Get the special instance once
$foo bar ...                       ;# invoke methods on it
2012-04-04 07:28
by Donal Fellows
Thanks Donal, let me try it out - balaji kommineni 2012-04-04 15:41