trelau / pyOCCT_binder

Binding generator for pyOCCT project
GNU Lesser General Public License v2.1
7 stars 1 forks source link

Detect "getter" methods and automatically set refrerence internal rv policy #27

Closed frmdstryr closed 2 years ago

frmdstryr commented 2 years ago

Builds on #26 .

This adds a new property is_getter_method to the binder and adds a check when generating the method to automatically set the return value policy to reference_internal when the function returns a reference has the class has a Set<name> method.

Currently pybind returns a copy that must be set to apply any changes.

Eg:

Before this change I need to do:

attrs = ais_shape.Attributes()
aspect = attrs.WireAspect()
aspect.SetTypeOfLine(type_of_line)
attrs.SetWireAspect(aspect)
ais_shape.SetAttributes(attrs)

With this change it's just

ais_shape.Attributes().LineAspect().SetTypeOfLine(type_of_line)