Lua脚本语言开发luaLua

FFI

2016-05-26  本文已影响53人  cptn3m0

FFI

FFI stands for Foreign Function Interface.
A foreign function interface is the popular name for the interface that allows code written in one language to call code written in another language.
The libffi library really only rovides the lowest, machine dependent layer of a fully featured foreign function interface.
A layer must exist above libffi that handles type conversions for values passed between the two languages.


为什么要有FFI

  1. FFI 是一种约定
  2. 具体来说FFI是一种调用关系的约定 [ 传参数,返回值]
  3. libfft 适用于最底层的调用(c?)

这里提到FFI,主要是要解决一个问题,就是如何用lua来调用c写的code。


python 的ctypes 是应用了libffi
lua 的alien 也是

下面就要用一下alien 这个工具


REF

  1. http://alien.luaforge.net/
  2. http://luajit.org/ext_ffi_semantics.html
  3. https://github.com/libffi/libffi
  4. http://www.atmark-techno.com/~yashi/libffi.html#Introduction
上一篇下一篇

猜你喜欢

热点阅读