Replies: 1 comment 1 reply
-
an initial implementation effort has been started, see #90 |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
We need to support calling C code (ideally C++ too but that seems to be a much harder problem).
This requires designing and implementing at least two parts, one on the VM side (the actual call), and another in the image side (the bindings). Consider this just a starting point to iterate and improve the design.
The constraints I'm thinking of are the following:
VM side
For the cpp vm, using libffi could be a simple option, as an FFI primitive can take the args from the st stack and pass them to libffi. For the LMR, it looks more difficult, as the LMR would need itself to call libffi, which falls into an infinite recursion. We would need some bootstrap mechanism to be able to call libfii, or just implement a libffi in our own (how hard could that be?™).
Image side
On the image side we will have a model of the things outside the image: objects for external memory, C functions, C structures, C types. I personally like the idea of doing most FFI in the image side (i.e. creating external objects and preparing things for the call).
For bindings, I'd go for the traditional design where each C library is a subclass. Each C function inside it is a method with a C prama. Something like:
Beta Was this translation helpful? Give feedback.
All reactions