Reputation: 131
class ICallback
{
public: virtual void OnEvent(int a,char* b) = 0;
};
class MyListener :public ICallback
{
public: virtual void OnEvent(int a, , char* b){code here}
};
int OnComplete(char* ID, ICallback* Listener);
Hello, I have such code in C++ and I need to call OnComplete method from Python.
Please pay attention that I have to create MyListener in python, implement OnNavigationEvent in python and call OnComplete of C++.
Is it possible?
Update: I can't touch "OnComplete" method code, it's third party library
Update 2: Here is the perfect example, very compact and understandable for people like me, new for python: http://eli.thegreenplace.net/2008/08/31/ctypes-calling-cc-code-from-python/ I just can't answer on my own question because a reputation < 10 :)
Upvotes: 0
Views: 121
Reputation: 73294
It's possible, but it's not trivial; the process is too involved to try and describe it here. Fortunately the Python team provides a handy document that describes how to do it.
Upvotes: 1