I'm trying to save a void* pointer (or any pointer) into a tcl Object so I can retrieve it later. I saw SWIG convert it to a string with some encoding and later decode it. But in order to make it more efficient, I want to directly get the pointer in and out of the tcl obj. Something like a Tcl_GetPointerFromObj(). Is there anyway to do it? Do I need to dig into the Tcl_Obj structure and do some dirty work?
A:
You could use the Tcl API: Tcl_GetWideIntFromObj()
, though I think storing pointers in Tcl is the first step toward madness....
Trey Jackson
2010-10-06 23:43:43
To use a big int seems too dangerous, I won't risk it... I want to have both flexibility and speed, so that's the only way.
CyberSnoopy
2010-10-07 20:49:18
+3
A:
I suggest reading this page on the Tcler's Wiki which is on the topic.
Donal Fellows
2010-10-06 23:44:54
+1
A:
You can use Tcl_RegisterObjType to create a new Tcl object type that holds a void pointer. This allows you to extend Tcl so that Tcl_ObjType can be used to store (in your case) void* and to be able to write Tcl_GetPointerfromObj.
Jackson
2010-10-07 09:11:17