Boost logo

Boost :

From: Anton Gluck (gluc_at_[hidden])
Date: 2000-11-03 00:35:03


Dave,

> In general, py_cpp doesn't automatically convert pointer return values
> to_python because pointers have too many potential meanings. Is it an
> iterator? A pointer to a single element? An array? Is ownership being passed
> to Python or is the pointer really just a reference? If the latter, what
> happens when some C++ code deletes the referent. The only exception to this
> rule is const char*, since it has a generally accepted interpretation (could
> be trouble with some generic code, though!)
>
> If you have wrapped the Record class, you could add this to namespace py:
>
> PyObject* to_python(const Record* p) {
> return to_python(*p);
> }

I have Record wrapped already (its constructor and one of its functions),
but when I add the above code I'm getting this error:

error C2665: 'to_python' : none of the 20 overloads can convert parameter
1 from type 'const class Record'

Did I put this code into the wrong spot (it's in namspace py, in the same
area where the from_python code is that deals with enumerations,
i. e. before initClusterForPy() which wrapps Record)?

> Of course, this will cause the Record class to be copied. If you can't live
> with that (Record would have to be /really/ heavyweight to make this
> worthwhile), you can follow one of these dangerous approaches:

Records aren't all that big, so I think we can live with this. Plus, I'll
gladly avoid any approach labeled "dangerous" :-)

Thanks,

Toni


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk