-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Add method/function for calling non-python functions by function pointer #2894
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The way MicroPython does it is by "ffi" module: https://github.com/micropython/micropython/blob/master/examples/unix/ffi_example.py . |
@pfalcon Thanks. I was looking for something like ffi but could not find it. Is there any intention to include the ffi module in the esp8266 port down the road? Or is it too large to be considered? |
I definitely thought about being able to use "ffi" module on bare-metal (well, non-unix) ports. Actually getting this done would depend on answering the usual question of why it's needed and then prioritizing the work wrt to thousands of other things. (So I personally don't think this would be done any time soon, interested parties are however welcome to make steps in the collinear direction, e.g. #2191) |
There has already been quite a bit of discussion and work done on implementing dynamic loading of C-based modules: #1627. |
Dynamic loading of native C modules is now implemented and in use for some years. Does this mean that this issue is no longer relevant, and can be closed? |
Calling C from Python is a pretty complex and deep topic, with ffi and dynamic-native-modules just two ways to do it. The original post on this issues shows another way using pure Python and But, yes, let's close this issue, it hasn't had any further progress or interest. |
Uh oh!
There was an error while loading. Please reload this page.
Sometimes it would be useful to be able to call existing non-python functions without having create a new module and recompile from source.
At present, because
asm_xtensa
functions only accept a limited number of arguments, many c-functions requiring more arguments cannot be called usingcallx0
directly.A crude implementation of what I am looking for is the following (for esp8266). The implementation is limited to 6 arguments but easily extensible to an arbitrary number of arguments:
Some toy-examples using rom-functions on the esp8266:
Of course one could also wrap this to create a c-language equivalent function signature:
Example use:
The text was updated successfully, but these errors were encountered: