[vtk-developers] Static methods in vtkPythonArgs

David Gobbi david.gobbi at gmail.com
Tue Mar 31 10:39:04 EDT 2015


On Tue, Mar 31, 2015 at 7:51 AM, E. Tadeu <e.tadeu at gmail.com> wrote:

> Hi!
>
>   Why is there a static version for many methods in vtkPythonArgs
> (specially GetValue)?
>

It allows those methods to be called without a vtkPythonArgs object ;)

  I see that they are being used only by Py*_SequenceSize. Is there a
> special reason? Could the static versions be removed, and Py*_SequenceSize
> generated code use an instance of vtkPythonArgs, just like all other
> generated functions?
>

They're also called by the other methods that make up the python sequence
protocol, i.e. SequenceSetItem and Sequence(Get)Item.

As for why these protocol methods call the static version of GetValue(),
it's because they have no need to create a vtkPythonArgs object.  The main
purpose of the vtkPythonArgs object is to check the argument list, i.e. to
verify that the correct number of arguments has been passed, to keep track
of the current position in the argument list, etc. None of that is
necessary for python protocol methods like SequenceSize.  All they need is
a simple way to convert a python object to a C++ object or vice-versa.  The
static methods serve that purpose.

If the python wrappers handled more python protocols, the static GetValue()
methods would be more widely used.

Cheers,

 - David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20150331/35ec0aa2/attachment-0001.html>


More information about the vtk-developers mailing list