How can I create a pointer to existing data using the LuaJIT FFI?

后端 未结 3 1031
情深已故
情深已故 2021-01-19 14:50

I know there are examples of creating pointers using the LuaJIT FFI, but most of these aren\'t pointed to existing data. One such example of this is here: How to pass a poin

3条回答
  •  悲哀的现实
    2021-01-19 15:38

    There's no way to get a pointer to a cdata object in the FFI.

    I remember reading in the LuaJIT mailing list that this was done intentionally for some optimizations to work, though I can't find the exact message in the archive.

    So far, I haven't had a need for getting the pointer of a cdata object; LuaJIT refers to cdata by reference (similar to tables) and the type[1] trick works for out parameters.

提交回复
热议问题