[C++-sig] Generation of wrapper for arguments of type T*&

Roman Yakovenko roman.yakovenko at gmail.com
Mon Apr 17 22:45:53 CEST 2006


On 4/17/06, Haridev, Meghana <mharidev at qualcomm.com> wrote:
> Hi Folks,
> I want to wrap the following piece of code using pyplusplus:
> // Simulating an out using foo (T*& ptr)
> Class_Z
> {
>     public:
> Class_X  foo (Class_Y*& ptr)
> {
>
>             Class_Y *newptr = new Class_Y();
>>             ptr = newptr;
>             return Class_X ();
>       }
> }
> Manually, I am wrapping it like this in Boost:
> boost::python::tuple foo(Class_Z& self )
>
> {
>
>     Class_Y *ptr;
>
>     Class_X objx = self.foo (ptr);
>
>     return boost::python::make_tuple(objx, ptr);
>
> }
>
>
>
> class_<Class_Z>("Class_Z")
>
> {
>
> .def( "foo", &::foo)
>
> }
>
> I'm a newbie to boost/python/pyplusplus! Any suggestions much appreciated!


I plan to add this feature to the next release of pyplusplus.

Right now you have few ways to go:

1. If you have only few such functions, then you can wrap them manually.
    after this you can add

    .def( "for", &foo )

   code to the class, using add_code method
   #I assume that you already has module_builder_t class instance
   mb = module_builder_t( ... )
   #Get declaration of Class_Z class
   Class_Z = mb.class_( name="Class_Z" )
   #get declaration of function "foo", If "foo" function is overloaded, then
   #you can specify additional criteria: argument types
   foo = Class_Z.member_function( name="foo" )
   foo.exclude()
   Class_Z.add_code( 'def( "foo", &foo )' )

This is a simple way to do this.

Lets start with this one, if it will not help you, we will proceed to
an other one.


> Thanks,
>
> -Meghana.
> _______________________________________________
> C++-sig mailing list
> C++-sig at python.org
> http://mail.python.org/mailman/listinfo/c++-sig
>
>
>


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



More information about the Cplusplus-sig mailing list