Are you finding "Boost.Python.register_ptr_to_python" ?
Please look this document http://www.boost.org/doc/libs/1_41_0/libs/python/doc/v2/register_ptr_to_python.html
Is this sample same as you require ?
Thanks,
Xiongjia Le ( http://notes.xj-labs.net/ )
Made a mistake... srry for my lacking knowledge/experience in C++. Trying to improve :D.
For test purposes I changed the Python Script so it inits an instance, and then tries to fetch the instance through the PyCallback:
#####
from EngineCallback import *
a = EngineCallback()
b = PyCallback(a)
>>> a
<EngineCallback.EngineCallback object at 0x7ffbe74c5208>
>>> b
<EngineCallback.EngineCallback object at 0x7ffbe74b0050>
#####
On the C++ side I had to change this, its now passing the argument by value (which I dont want)
shared_ptr<EngineCallback> PyCallback( EngineCallback* test ) { return shared_ptr<EngineCallback>(test); }
If I passed it per reference EngineCallback* &test (hope Im getting the jargon right and not mixing up definitions) it would say:by changing it to pass by value it works, though isnt it making a copy of the instance? how do I get just a reference to the instance passed to Python?
did not match C++ signature:
PyCallback(EngineCallback* {lvalue})
On 25 May 2010 16:56, Steven Watanabe <watanabesj@gmail.com> wrote:
AMDG
Leonhard Weber wrote:
EngineCallback* test = new EngineCallback;shared_ptr<EngineCallback> PyCallback( EngineCallback* &test );
// Entrypoint for Python to come ant fetch the Application Callback
<snip>
# test.py
from EngineCallback import PyCallback
from EngineCallback import EngineCallback
test = PyCallback()
PyCallback takes one argument. Hence the exception below.
Did you intend to use the global "test" instead of taking test
as an argument in PyCallback?
Traceback (most recent call last):
File "test.py", line 5, in <module>
test = PyCallback()
Boost.Python.ArgumentError: Python argument types in
EngineCallback.PyCallback()
did not match C++ signature:
PyCallback(EngineCallback* {lvalue})
In Christ,
Steven Watanabe
_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users