[vtk-developers] Tcl wrapping and output array arguments

Jorge Perez josp.jorge at gmail.com
Mon Mar 30 12:44:11 EDT 2015


I still do not have any useful implementation, just the design ideas based
on Tcl_ObjType. Now that I know it could be useful I will continue with the
implementation.


2015-03-30 16:58 GMT+02:00 David Gobbi <david.gobbi at gmail.com>:

> On Mon, Mar 30, 2015 at 8:31 AM, Jorge Perez <josp.jorge at gmail.com> wrote:
>
>> I was also studying the vtkWrapTcl.c code, just the part related to the
>> tasks described in 2).
>>
>> For instance, regarding to vtkVariant value,  the function int
>> checkFunctionSignature(ClassInfo *data) reject to wrap a method call if the
>> return value is vtkVariant or expect an argument of type vtkVariant in one
>> of this checks:
>>
>> if ((returnType & VTK_PARSE_INDIRECT) != VTK_PARSE_POINTER) // the return
>> type is value not a pointer
>>
>> {
>>
>> args_ok = 0;
>>
>> }
>>
>> ....
>>
>> if ((argType & VTK_PARSE_INDIRECT) != VTK_PARSE_POINTER) // the argument
>> is a value not a pointer
>>
>> {
>>
>> args_ok = 0;
>>
>> }
>>
>
> Yes, exactly.  You want to add "if" statements that allow "special" types
> like vtkVariant and vtkBoundingBox to get through.
>
>   if ((argType & VTK_PARSE_INDIRECT) == VTK_PARSE_REF || /* pass by
> reference e.g. "&param" */
>       (argType & VTK_PARSE_INDIRECT) == 0) /* pass-by-value */
>       {
>       if (strcmp(currentFunction->ReturnClass, "vtkVariant") == 0 ||
>           strcmp(currentFunction->ReturnClass, "vtkBoundingox") == 0)
>         {
>         /* is a special object passed by reference or passed by value */
>         }
>       else
>         {
>         /* is unrecognized */
>         args_ok = 0;
>         }
>
> I think that we can wrap (at least manually) some classes (vtkVariant,
>> vtkBoundingBox, ...) not derived from vtkObject as new Tcl_ObjType and
>> provide in vtkTclUtil some helper functions to convert from C++ instances
>> to Tcl_Obj and the other way from Tcl_Obj to C++ instance.
>>
>>
>> I'm experimenting with this idea: implement new Tcl_ObjType to wrap
>> vtkVariant and vtkBoundingBox.
>>
>
> Sounds like it should work, but it has been so long since I've worked with
> Tcl that I don't remember anything about creating new tcl object types!
>
>
> By the way the generated C code could be based in Tcl_Obj *objv[]
>> interface instead of char *argv[]
>>
>
> If you think it would be a good change, put it on gitlab.kitware.com and
> I'll take a look.
>
> Cheers,
>  - David
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20150330/c010d393/attachment.html>


More information about the vtk-developers mailing list