AMDG Leonhard Weber wrote:
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
b
##### 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?
Since you take a pointer, the pointer will be copied, the object that it points to won't be copied. However, you should probably make the argument a shared_ptr. Otherwise, you'll run into trouble because the new shared_ptr thinks that it has exclusive ownership. In Christ, Steven Watanabe