
On Apr 13, 2020, at 11:26 AM, Daniel Holth dholth@gmail.com wrote:
Was it regular cffi or cffi's embedding API, which is used a bit differently than regular cffi, that "seems to only solve a fraction of the problem"? Was just playing around with the embedding API and was impressed.
In Python:
@ffi.def_extern() def uwsgi_pyexample_init(): print("init called")
return 0
In C (embedded in the same plugin):
CFFI_DLLEXPORT struct uwsgi_plugin pyexample_plugin = { .init = uwsgi_pyexample_init };
Seems to be happily importing and exporting APIs. Interpreter starts the first time a @ffi.def_extern() function is called.
https://cffi.readthedocs.io/en/latest/embedding.html https://cffi.readthedocs.io/en/latest/embedding.html
https://github.com/unbit/uwsgi/blob/f6ad0c6dfe431d91ffe365bed3105ed052bef6e4... https://github.com/unbit/uwsgi/blob/f6ad0c6dfe431d91ffe365bed3105ed052bef6e4/plugins/pyexample/pyexample_plugin.py
I might need to understand cffi embedding more to really answer your question - and it’s entirely possible cffi can do this - but as a simple example:
How would I call a Python function from the C++ application that returns a Python object to C++ and then call a method on that Python object from C++?
My specific example is that I create Python handlers for Qt windows and then from the Qt/C++ I call methods on those Python objects from C++ such as “handle mouse event”.