[View] [Edit] [Lock] [References] [Attachments] [History] [Home] [Changes] [Search] [Help]
[jx8-ios] Extending jxcore with internal module for s8
This page contain description of changes made to jxcore to add an internal binding to implement direct access to FFI.
Adding module files to project
- New folder for source files at src/s8
- Add two files (s8_ffi.h and s8_ffi.cc) for sources of s8-ffi module at src/s8
- Add a new line to file node_extensions.h to register node_s8_ffi module in (internal) node extensions list
- Add 'src/s8/s8_ffi.cc' to jx.gpy after line 'src/wrappers/node_zlib.cc'; to ensure our module will be included in build
Building the jxcore
- Open terminal window and cd to root of jxcore project folder
- execute build script
./build_scripts/ios_compile.sh
- it is not smalltalk, so relax and wait the build to finish
Installing the new jxcore engine
- copy the folders (bin and include) under out_ios/ios to jx8-ios project under jx8-ios/jxcore
Running jx8-ios and accessing our new s8 binding
- Run jx8-ios in the device with xcode debug
- Connect a workspace from desktop U8 contribution
- To access the s8 library evaluate with showIt
- NodeJS process handle #binding: #s8_ffi
- Note: it will trigger an error if the binding is not installed
- To see the methods published by the library evaluate with showIt
- JS@>(NodeJS process handle #binding: #s8_ffi)
Initializing the bindings
| obj cif nargs rtype atypes abi |
obj := Object new json.
(NodeJS process handle #binding: #s8_ffi)
#initializeBindings: obj.
JS@>obj['FFI_TYPES'].
JS@>obj['StaticFunctions'][#dlopen].
{'cif = new Buffer("hello");'}.
nargs := 0.
rtype := #void.
atypes := #aTypes.
abi := 1.
obj #ffi_prep_cif: cif
nargs: nargs
rtype: rtype
atypes: atypes
abi: abi