[C++-sig] pyste + wrapping + overloads

Baptiste Lepilleur gaiacrtn at free.fr
Thu Dec 2 21:11:15 CET 2004


This is a pyste limitation. You can never specify special behavior for a
given overload.

Here is what I suggest doing (that's how I deal with stuff like this in
pyogre):
- exclude all the overloaded functions
- inject your code to export those functions correctly using
declaration_code() and class_code().

This way you can keep using pyste to generate most of the binding.

Baptiste.

----- Original Message ----- 
From: "John Hunter" <jdhunter at nitace.bsd.uchicago.edu>
To: <c++-sig at python.org>
Sent: Monday, November 08, 2004 6:46 PM
Subject: [C++-sig] pyste + wrapping + overloads


>
> I am trying to wrap a class method in pyste that has a signature
>
>     void path_storage::add_poly(const double* vertices, unsigned num,
>                                 bool solid_path, unsigned end_flags)
>
> vertices is a length 2*num array of x,y doubles x0, y0, x1, y1, ....
>
> I am using the following wrapper
>
>   void add_poly_wrapper(agg::path_storage* ps, list vertices,
> bool solid_path = false,
> unsigned end_flags = agg::path_flags_none) {
>     size_t N = extract<size_t>(vertices.attr("length")());
>     double * pverts = new double[2*N];
>     for (size_t i=0; i<N; i++) {
>       tuple xy  = extract<tuple>(vertices[i]);
>       *pverts++ = extract<double>(xy[0]);
>       *pverts++ = extract<double>(xy[1]);
>     }
>     pverts -= 2*N;  //rewind
>     ps->add_poly(pverts, N, solid_path, end_flags);
>
>   }
>
> The first problem I've encountered in pyste is that the standard way of
> specifying wrappers
>
>     Include("path_storage_wrap.h")
>     PS = Class("agg::path_storage", "agg_path_storage.h")
>     set_wrapper(PS.add_poly, "add_poly_wrapper")
>
> doesn't work because there is no PS.add_poly, since pyste defines it
> with the overload macro
>
>
>
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(agg_path_storage_add_poly_overloads_2
_4, add_poly, 2, 4)
>
>
> How does one specify wrappers for overloaded functions?  I don't know
> enough about the overload macro internals to figure out how to
> proceed...
>
> Thanks,
> JDH
>
> boost_python 1.31.0 with pyste and gccxml-0.6.0
> _______________________________________________
> C++-sig mailing list
> C++-sig at python.org
> http://mail.python.org/mailman/listinfo/c++-sig
>




More information about the Cplusplus-sig mailing list