lune icon indicating copy to clipboard operation
lune copied to clipboard

FFI support for lune

Open qwreey opened this issue 1 year ago • 5 comments

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 avatar Aug 21 '24 19:08 qwreey

@qwreey Small thing - is it possible to link this to the relevant issue?

CompeyDev avatar Sep 05 '24 09:09 CompeyDev

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

qwreey avatar Oct 21 '24 13:10 qwreey

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

qwreey avatar Oct 21 '24 19:10 qwreey

Current state

Tests

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

qwreey avatar Oct 24 '24 01:10 qwreey

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.

CompeyDev avatar Aug 31 '25 10:08 CompeyDev