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:

did not match C++ signature:
    PyCallback(EngineCallback* {lvalue})

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?



On 25 May 2010 16:56, Steven Watanabe <watanabesj@gmail.com> wrote:
AMDG

Leonhard Weber wrote:
EngineCallback* test = new EngineCallback;

// Entrypoint for Python to come ant fetch the Application Callback
shared_ptr<EngineCallback> PyCallback( EngineCallback* &test );
<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