Closed mdorier closed 3 years ago
Passing a callable to a foreign function is done via an internal Jx9 API hence jx9VmCallUserFunction()
which is not publicly exported for obvious security reasons.
I'm not sure I understand the security reasons, could you give me an example of a situation where such a functionality would be unsafe?
Well, Jx9 was designed to run on restricted embedded devices such as your home router or set top box where memory and stack is limited. Suppose if a broken callable enter in an endless recursive calls/loop on your router...
How would that be different from executing the same callable from the jx9 script itself?
Jx9 internal callable are certified not to broke such as calling a recursive function or entering an infinite loop unlike passing a user defined callable to the VM which cannot be controlled. Nevertheless, making callable public shoud be straightforward by simply writing a wrapper around jx9VmCallUserFunction()
.
I could not find any documentation on this: how can I pass a callable from jx9 to a foreign function written in C, and call this callable on some data? I tried looking at how
db_fetch_all
is implemented, but it seems to be using a function that is not in the API (here).