[prev in list] [next in list] [prev in thread] [next in thread]
List: python-cpp-sig
Subject: [C++-sig] Making Boost.Python understand DerivedSafe
From: caustin () gmail ! com (Chad Austin)
Date: 2004-06-17 5:31:04
Message-ID: 2096514e0406170112773a0e76 () mail ! gmail ! com
[Download RAW message or body]
(I am not yet subscribed to the list... it seems mailman is having
trouble sending me the authorization. Please CC me on replies..
Thanks.)
Hi all,
I just started using Boost.Python to embed Python in a project of
mine. I spent a couple days evaluating, testing, and studying, but it
seems to have paid off! Great job on making such a time-saving
library!
I am wrapping an internally refcounted class called CutScene.
CutScene objects are referenced by RefPtr<CutScene> smart pointers,
typedef'd as CutScenePtr. I export the class with:
class_<CutScene, CutScenePtr>("CutScene").def /*etc*/;
So far, so good. The problem comes about when I want to pass a
CutScenePtr into object::operator() to call a function. If I pass a
CutScenePtr object in, it says something about reject_raw_object_ptr:
d:\Projects\empyrean\empyrean\third-party-vc7\include\boost\python\converter\arg_to_python.hpp(244)
: error C2784: 'void
boost::python::converter::detail::reject_raw_object_ptr(T *)' : could
not deduce template argument for 'T1 *' from 'pyr::RefPtr<T>'
with
[
T=pyr::CutScene
]
If I pass the result of CutScenePtr::get() into operator() I get a
runtime error about Boost.Python not knowing how to convert
RefDerivedSafe<T>* to a Python object. This makes sense, because
RefPtr's implicit conversion operator, operator->, and get() all
return RefDerivedSafe<T>*. (RefDerivedSafe<T> is a special class
derived from T that prevents C++ clients from accidentally calling
delete, ref(), or unref() on a smart pointer. This techique is used in
both ATL and nsCOMPtr in Mozilla).
Here's my question: Is there a way to tell Boost.Python that
ptr(someCutScenePtr) is valid and should be equivalent to
ptr(someCutScenePtr.get()) and/or that RefDerivedSafe<T>* can be
implicitly converted to T*? I've tried several different things, and
nothing seems to work...
I'm currently using Boost 1.31 with both gcc 3.3.1 and VS.NET 2003.
Many thanks,
Chad
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic