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

John Hunter jdhunter at ace.bsd.uchicago.edu
Mon Nov 8 18:46:19 CET 2004

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

    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


boost_python 1.31.0 with pyste and gccxml-0.6.0

More information about the Cplusplus-sig mailing list