在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):facebookarchive/luaffifb开源软件地址(OpenSource Url):https://github.com/facebookarchive/luaffifb开源编程语言(OpenSource Language):C 68.0%开源软件介绍(OpenSource Introduction):AboutThis is a library for calling C function and manipulating C types from lua. It is designed to be interface compatible with the FFI library in LuaJIT (see http://luajit.org/ext_ffi.html). It can parse C function declarations and struct definitions that have been directly copied out of C header files and into lua source as a string. This is a fork of https://github.com/jmckaskill/luaffi Sourcehttps://github.com/facebook/luaffifb PlatformsCurrently supported:
Runs with Lua 5.1, 5.2, and 5.3 BuildIn a terminal: git clone https://github.com/facebook/luaffifb
cd luaffifb
luarocks make DocumentationThis library is designed to be source compatible with LuaJIT's FFI extension. The documentation at http://luajit.org/ext_ffi.html describes the API and semantics. Pointer ComparisonUse ffi.new('void *', 0) == ffi.NULL -- true Known Issues
How it worksTypes are represented by a struct ctype structure and an associated user value table. The table is shared between all related types for structs, unions, and functions. It's members have the types of struct members, function argument types, etc. The struct ctype structure then contains the modifications from the base type (eg number of pointers, array size, etc). Types are pushed into lua as a userdata containing the struct ctype with a user value (or fenv in 5.1) set to the shared type table. Boxed cdata types are pushed into lua as a userdata containing the struct cdata structure (which contains the struct ctype of the data as its header) followed by the boxed data. The functions in C functions (and function pointers) are pushed into lua as a lua c function with the function pointer cdata as the first upvalue. The actual code is JITed using dynasm (see call_x86.dasc). The JITed code does the following in order:
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论