[C++-sig] Exposing c++ classes with static arrays using Boost.Python and py++

Roman Yakovenko roman.yakovenko at gmail.com
Tue Oct 3 22:09:35 CEST 2006


On 10/3/06, Haridev, Meghana <mharidev at qualcomm.com> wrote:
> Hi Roman,
> Why not just keep it simple and rather than creating a derived class
> just create a namespace(for extra uniqueness) instead and map the
> variable "staticIntArray" via some method defined in that namespace,
> such as:
> .add_property( "staticIntArray",
>              bp::make_function(
>
> (&AttributesTest_NSwrapper::pyplusplus_staticIntArray_wrapper),
>              bp::with_custodian_and_ward_postcall< 0, 1,
>              bp::default_call_policies >() ) );;
>
> and define the pyplusplus_staticIntArray_wrapper method in the
> namespace:
>
> namespace AttributesTest_NSwrapper{
>     pyplusplus::containers::static_sized::array_1_t< int, 10 >
>         pyplusplus_staticIntArray_wrapper(){
>           return pyplusplus::containers::static_sized::array_1_t< int,
> 10 >(
>             staticIntArray );
>     }
> }
>
> This solves the above mentioned problem that occurs when you use derived
> classes as wrappers instead.

It smells like a problem in Boost.Python, also I can not say this for
sure without
creating small test case that reproduce the problem.

> Any comments?

I think Py++ should use "range" functionality to expose static arrays.
I will try to find how to implement this. It will take some time so.

-- 
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/



More information about the Cplusplus-sig mailing list