Robert Gabriel Jakabosky
Robert Gabriel Jakabosky
@fungos I have opened this issue to get feedback on the API. Once the TODOs are done and more examples/testing have been done. I will send a PR.
@rokups I have an idea for allowing nesting. Each protected call into the plugin would increment a counter. If `counter > 0` skip rollback/reload check. The plugin callback that crashed...
If you didn't want crash handling/reload/rollback for plugin callbacks, then the trampoline would be very simple to generate: 1. Load `cr_symbol`
Some useful links about generating closures: 1. [C closure as a library](https://nullprogram.com/blog/2017/01/08/) 2. [See section 'Moving to thunks'](https://hokstad.com/how-to-implement-closures)
Possible solutions to generate safe wrappers for plugin callbacks: 1. Use an external JIT library: [libjit](https://www.gnu.org/software/libjit/doc/libjit.html), [nanojit](https://github.com/dibyendumajumdar/nanojit), [asmjit](https://github.com/asmjit/asmjit), [xbyak - header only](https://github.com/herumi/xbyak) 2. Use assembly templates for generating trampoline function...
@fungos Yes. I found a way to do it without JIT/assembly. I created [n_closure](https://github.com/Neopallium/n_closure) to test the idea. Right now it only wraps a function to test if it worked....
The `n_closure` idea works on Linux/OSX/Windows, 32bit and 64bit. Win64 ABI is a pain, while it is working right now there is a restriction on the trampoline function. For Win64...
One problem with generating `host_trampoline_mouse_events` is that it has to be in the host and the plugin will need to get the address when registering callbacks. On linux/mac that isn't...
@fungos I am not sure the best way to deal with the DLL linking issues (plugins calling host functions). Since I want to let plugins to get a re-loadable `cr_symbol`,...
@pixelherodev Don't you still need to link the plugins to the host?