[C++-sig] Type conversion problem -- simplified
David Abrahams
dave at boost-consulting.com
Sat Nov 4 22:19:57 CET 2006
David Abrahams <dave at boost-consulting.com> writes:
>> Traceback (most recent call last):
>> ...
>> File "osg_to_sgg.py", line 153, in setupGeode
>> v[0].set( 0, 1, 2 )
>> Boost.Python.ArgumentError: Python argument types in
>> Vec3Array.__getitem__(Vec3Array, int)
>
> __getitem__ refers to the square brackets operator, so this has
> nothing to do with callability of the Vec3Array object.
>
>> did not match C++ signature:
>> __getitem__(osg::TemplateArray<osg::Vec3f, (osg::Array::Type)10, 3, 5126>*, int)
>> Note that the Vec3Array type is identical to the osg::TemplateArray<...>
>> type (via typedef), so the key difference is the extra "*" in the last
>> line.
>
> Interesting; how did you generate that __getitem__ method? Its first
> parameter should be a reference to a Vec3Array, not a pointer.
Come to think of it, the reason we prefer a reference is that wrapped
C++ functions with pointer parameters will accept a wrapped NULL
pointer, and those accepting a reference parameter will automatically
reject a NULL pointer at the library level, saving the function author
from the NULL check. So the signature of the function wrapped to
generate that __getitem__ method above is *more* permissive than if it
was built in the usual correct manner.
If you're certain that
osg::TemplateArray<osg::Vec3f, (osg::Array::Type)10, 3, 5126>
and
Vec3Array
are identical types, then I'm stumped. I'd like to see the code that
exposes Vec3Array to Python. But even more than that, I'd like to see
a minimal, reproducible example of your problem.
--
Dave Abrahams
Boost Consulting
www.boost-consulting.com
More information about the Cplusplus-sig
mailing list