sagemathinc / cowasm-python

CoWasm-Python: WebAssembly Python for Servers and Browsers
6 stars 0 forks source link

support libffi (and ctypes) #2

Open williamstein opened 1 year ago

williamstein commented 1 year ago

See:

williamstein commented 1 year ago

I've added PARTIAL support, but put the EM_JS stuff as stubs for now. This means that obviously some functionality won't work. This is just a tiny step so all those random scripts that import ctypes and do nothing with it (it's usually platform specific stuff on macos or windows) will at least not crash.

williamstein commented 1 year ago

Example:

>>> import ctypes
>>> ctypes.pythonapi["PyObject_Str"]()
STUB: ffi_call
0

There is nothing difficult about fully supporting this properly. It's just a matter of organization and understanding the hard work already done by https://github.com/hoodmane/libffi-emscripten

Thanks!

pmp-p commented 1 year ago

afaik the work is documented here https://brionv.com/log/2018/05/06/emscripten-fun-porting-libffi-to-webassembly-part-1/ https://brionv.com/log/2018/05/27/emscripten-fun-libffi-on-webassembly-part-2/