[C++-sig] Wrapping class methods with array parameters
CLARKE,RON (HP-Vancouver,ex1)
ron.clarke at hp.com
Fri Nov 7 20:52:43 CET 2003
I am in the process of wrapping two C++ classes, each of which has at least
one method which takes a pointer, which is really the first item in an array
of known length. My problem is I don't see how to do it! Given that Boost
Python is so robust, I suspect I've missed something in all the
documentation, or perhaps I read it and did not grasp its relevance.
Here is one of the classes/methods:
class scifidict
{
public:
/* a bunch of stuff */
size_t getOwners(string* ps = NULL)
throw (invalid_argument);
/* more fun stuff */
};
The other C++ class' method is similar, but it uses an array of integers as
one of its arguments.
In the above method, ps is a std::string array passed in by the caller,
which getOwners() than proceeds to populate. It works fine in C++. I've
made numerous attempts to get code that works for Python, and either the
code did not compile, or it did compile but then Python didn't like the
method when I tried to execute it ("TypeError: bad argument type for
built-in operation").
What is the proper way to wrap array arguments so the data can be passed
back and forth between C++ and Python?
Thanks in advance for the help.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20031107/88cd73b4/attachment.htm>
More information about the Cplusplus-sig
mailing list