From: Dan Nuffer (dnuffer_at_[hidden])
Date: 2002-11-07 01:15:28
I've started using Boost.Python to wrap some classes from OpenWBEM. So
far I've got one class mostly done: OW_String. So far I have been very
impressed, and think the library is great. But I've had a few problems.
Here's some questions and comments:
1. It took me some searching to find
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS, I think it should be at least
mentioned in the tutorial.
2. Is is possible to wrap member functions which take a variable number
of arguments (e.g. int format(const char* fmt, ...); ) ? I tried
.def("format", &OW_String::format) but that doesn't work.
3. OW_String has some methods like OW_String& concat(const OW_String&
arg); which return *this;. I assume the correct return policy to use is
return_internal_reference<>(). The documentation refers to the case
where a reference is returned to an instance data member, but not the
instance itself. Is return_internal_reference correct in this case?
4. If the return policy is omitted from a member function which returns
OW_String&, the error says: "specify_a_result_policy..." This should
say return, not result, since the documentation doesn't mention result
5. It would be nice if you gave an example in the tutorial about how to
specify overloads, since casting the member function pointer is not
something that is completely obvious (at least it took me a while to
figure it out).
6. How can I get python indexing and slicing to work on OW_String? I
couldn't see any information about this in the docs.
7. Do I need to expose the copy constructor and assignment operator via
8. When I exposed the OW_String(const char*) and OW_String(char)
constructors, python would always call OW_String(char) instead of
OW_String(const char*). Is this intentional or a bug? I just removed
the OW_String(char) constructor, since Python doesn't have chars anyway.
9. I have an operator<< defined, but .def(str(self)) doesn't compile.
Here's the error: no matching function for call to `
10. I added implicitly_convertible<const char*,OW_String>(); It compiled
fine, but it didn't work:
>>> import owclient
>>> s = owclient.OW_String("a")
<owclient.OW_String object at 0x817267c>
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: bad argument type for built-in operation
Any ideas why this didn't work?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk