[vtk-developers] Nested structs and python wrapping

David Lonie david.lonie at kitware.com
Wed Jan 14 14:23:59 EST 2015


Thanks David! That's a fantastically easy workaround, I should have thought
to try that ;-)

Dave

On Wed, Jan 14, 2015 at 2:19 PM, David Gobbi <david.gobbi at gmail.com> wrote:

> Hi David,
>
> I've identified the bug in the wrappers.  They are trying to wrap the
> out-of-line
> definition of vtkTextRenderer::Metrics as a class named
> "vtkRenderer::Metrics"
> in the global namespace (almost as if the "::" was actually part of the
> identifier).
> This is something that I'll fix as soon as I have time to do so (probably
> not today).
>
> If you put the definition of "Metrics" inline, i.e. within vtkTextRender,
> then the
> wrappers will have no problem.  They will automatically exclude Metrics,
> and
> any methods that use it, from wrapping.
>
>  - David
>
> On Wed, Jan 14, 2015 at 9:00 AM, David Gobbi <david.gobbi at gmail.com>
> wrote:
>
>> Hi David,
>>
>> This suggests a bug in the wrappers, because the wrappers should be
>> excluding
>> these methods automatically. The use of "#ifndef __WRAP__" should be
>> avoided,
>> if there is an option to instead fix the wrappers themselves. I'll take a
>> look at the
>> code sometime today in the hope that there is a simple fix.
>>
>> The wrappers cannot wrap nested classes or structs yet, because they use
>> a flat
>> global namespace for object types.  I did a bunch of work to fix this
>> three years ago,
>> but never finished because the "flat namespace" assumption worked well
>> for VTK.
>> I've always wanted an excuse to go back and finish this code.
>>
>>  - David
>>
>>
>> On Wed, Jan 14, 2015 at 8:24 AM, David Lonie <david.lonie at kitware.com>
>> wrote:
>>
>>> Hi folks,
>>>
>>> I'm looking for some advice on getting a patch to play nicely with the
>>> wrappers.
>>>
>>> I have a vtkObject derived class that contains a nested struct:
>>>
>>> class EXPORT_MACRO vtkTextRenderer : public vtkObject
>>> {
>>> public:
>>>   struct Metrics;
>>>
>>>   ...
>>>
>>>   bool GetMetrics(..., Metrics &);
>>> }
>>>
>>> struct vtkTextRenderer::Metrics
>>> {
>>>   ...
>>> }
>>>
>>> It looks like the python wrappers aren't happy about this, see:
>>>
>>> https://open.cdash.org/viewBuildError.php?buildid=3651284
>>>
>>> Ben pointed out that I can use the __WRAP__ define to exclude these, but
>>> I'm interested in hearing more options. I see a couple of paths forward:
>>>
>>> 1) Exclude all usages of Metrics with __WRAP__
>>>
>>> Cons: Functionality can't be used from wrapped languages. Maintenance
>>> would be a chore, as the Metrics struct is used in a number of text
>>> rendering related headers.
>>>
>>> 2) Change Metrics to a stand-alone vtkObject derived class.
>>>
>>> Cons: It's a really lightweight object, I'd like to avoid having the
>>> overhead of vtkObject enter into this.
>>>
>>> 3) Special wrapping for the metrics class.
>>>
>>> Cons: Work. Also, maintenance would be a headache as I expect this
>>> struct to have new members added over time.
>>>
>>> Any options I'm missing? I'm leaning towards 2, but a more lightweight
>>> solution would be great, if it exists!
>>>
>>> Thanks,
>>> Dave
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20150114/77a98f28/attachment.html>


More information about the vtk-developers mailing list