I am new to C++/Python mixed language programming and do not have much idea about Python/C API. I just started using Boost.Python to wrap a C++ library for Python. I am stuck at wrapping a function that takes pointer to an array as an argument. Following (2nd ctor) is its prototype in C++.
class AAF{ AAF(AAF_TYPE t); AAF(double v0, const double * t1, const unsigned * t2, unsigned T); ~AAF(); } Am I doing right by wrapping it like this in boost::python? class_<AAF>("AAF", init<AAF_TYPE>()) .def(init<double, const double*, const unsigned*, unsigned>()); Note that it compiled and linked successfully, but I couldn't figure out how to call it in Python. My naive tries like the following failed. >>> z = AAF(10, [4, 5.5, 10], [1, 1, 2], 3); Traceback (most recent call last): File "./test_interval.py", line 40, in <module> z = AAF(10, [4, 5.5, 10], [1, 1, 2], 3); Boost.Python.ArgumentError: Python argument types in AAF.__init__(AAF, int, list, list, int) did not match C++ signature: __init__(_object*, AAF_TYPE) __init__(_object*, double, double const*, unsigned int const*, unsigned int) >>> t1 = array.array('d', [4, 5.5, 10]) >>> t2 = array.array('I', [1, 1, 2]) >>> z = AAF(10, t1, t2, 3); Traceback (most recent call last): File "./test_interval.py", line 40, in <module> z = AAF(10, t1, t2, 3); Boost.Python.ArgumentError: Python argument types in AAF.__init__(AAF, int, array.array, array.array, int) did not match C++ signature: __init__(_object*, AAF_TYPE) __init__(_object*, double, double const*, unsigned int const*, unsigned int) My second question is that do I also need to wrap the destructor? Please specify if this might be necessary in some cases but not always.
_______________________________________________ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig