purescript-native icon indicating copy to clipboard operation
purescript-native copied to clipboard

creating shared objects with purescript-native-cpp

Open freylax opened this issue 5 years ago • 1 comments

I propose to use extern "C" functions for all exposed functions.This makes it possible to use them in shared libraries and shared object files. This solves two issues which could not be addressed with the current c++ functions:

  • get rid of the dictionary lookup for ffi calls if you try to use an ffi function which is not implemented yet you will get an error at library or shared object load time, not at runtime of the missing function
  • allow for using plugins in an running application this is not quite a repl but it allows live coding in a runnig application. You can edit the plugin module, recompile and reload it in the runnig application as shared object. #27

A runnig example can be found here: hello world which is implemented by changed the pscpp pscpp and ported the ffi functions for the standard library to the C function interface ffi I just used Linux, so no effort was made to make it work on other platforms. I apreciate your comments and wish you a mery christmas.

freylax avatar Dec 23 '19 22:12 freylax

Using zephirs dead code elimination I was able to link in only the modules and ffi's which are truely needed. This allowes for a gradual completion of the ffi's for the shared library and having the gurantee that the neede ffi's which are used by the executable are actually all in there. https://github.com/freylax/purescript-native-build

freylax avatar Jan 10 '20 21:01 freylax