[vtk-developers] Changes to Tcl Wrapping

Ken Martin ken.martin at kitware.com
Wed Jan 5 14:23:06 EST 2005


I have checked in some changes to the Tcl wrapping that are worth
mentioning. In the past if you had a function such as:

vtkFubar *GetMySourceCode();

in a VTK class then wrapping that class would require that vtkFubar be
wrapped as well. (or you would have to //BTK //ETX the function). It turns
out that this was not really necessary so I have changed it. Now when such a
method is wrapped it no longer passes in a pointer to the return-type's
invocation function (which would cause a link error if the class was not
wrapped). Instead a string is passed with the class type. At run time the
return-instance's invocation function is looked up as follows:

1) do a GetNameOfClass() on the instance and see if that class was wrapped,
if so use it

2) take the string passed in a see if that class was wrapped, if so use it

3) use vtkObjectBase

Step 1 has not changed and provides much desired run-time downcasting. Step
2 is what changed, since it is using a string there is no guarantee that the
function will be found (such as if the class was not wrapped) in this case
the invocation table for vtkObject (step 3) is used instead. So if you did
not wrap vtkFubar then you can still call GetMySourceCode() but you will
likely only be able to invoke the methods defined in vtkObject (and
superclasses) on the resulting instance.

Thanks
Ken








More information about the vtk-developers mailing list