FFI support for lune
There is still a lot of work to be done, Most of the specs are well polished. I have discussed it with many people (mostly, Korean) to ensure that it is done cleanly while supporting as many cases as possible, but it has not been released to the lune community yet.
At first time, It was a personal fork that I did not intend to merge into lune, but the specs and implementation have improved a lot, so I think the quality will be sufficient, so I am discussing it publicly and developing it publicly.
Since the specifications-related parts are still in Korean, we would like to translate them into English as soon as possible. There are many comments written in the code that will be helpful. (Comments are written in English.)
The direction this library pursues is to allow Lua to select which data areas Lua can handle and which areas will be automatically managed. Lua can create a space on the heap that it can manage as needed, provide that space to the outside as a pointer, or use it to hold data that Lua cannot handle. (such as unsigned 64 bit int, c struct)
Except for pointer operations, all operations are safe. I'm looking for a safer way to handle pointer arithmetic. If you have any comments about this, please write them here.
I will update progress as soon as specifications translating is done in this thread.
@qwreey Small thing - is it possible to link this to the relevant issue?
Current state:
tests/ffi/external-math :white_check_mark: tests/ffi/external-pointer :white_check_mark: tests/ffi/external-print :white_check_mark: tests/ffi/external-struct :white_check_mark: tests/ffi/pretty-print :white_check_mark: (but need box, ref test) tests/ffi/isInteger :white_check_mark:
tests/ffi/external-closure :x: failed (segfault) tests/ffi/into-boundary :x: need assertion tests/ffi/from-boundary :x: need assertion tests/ffi/cast :x: need assertion
To get more information about implement state and code structure, see lune-std-ffi/README.md
Related issues:
https://github.com/lune-org/lune/issues/157
To get discussion:
Join lune/ffi thread in Roblox OSS Community
Mistakenly committed coredump file.. nvm Removed in force-push
Current state:
tests/ffi/external-closure ✅
moonwave docs in types/ffi.luau ⏱️ partially done documentation :x:
TODO
https://github.com/lune-org/lune/pull/243/commits/12bf3bd9efb8b584811031f2fc3d99727e838e8a benchmark for callable optimization
Current state
Tests
- [x] external_math
- [x] external_pointer
- [x] external_print
- [x] external_struct
- [x] external_closure
- [x] isInteger
- [x] cast
- [ ] pretty_print - need more cases
- [ ] write_boundary - need fix
- [ ] read_boundary - need fix
Types
moonwave docs in types/ffi.luau - ⏱️ partially done (80%)
Related PR
- https://github.com/lune-org/lune/pull/267
TODO
- Rewrite error messages
- Fix deref
- Array argument in cfn
- Ref boundary fix
Bump: Can we get this PR updated? IIRC, is it almost complete, if you can finalize the missing things and resolve the merge conflicts, this could be merged.