Slide 1

Slide 1 text

Introduction to LuaJIT & How to bind C++ code base using LuaJIT FFI 2012.04.14 OSDC.tw

Slide 2

Slide 2 text

How to bind complex C++ code base using LuaJIT FFI

Slide 3

Slide 3 text

About me Johnson Lin

Slide 4

Slide 4 text

About me Johnson Lin Programmer & Indie Game

Slide 5

Slide 5 text

About me Johnson Lin Programmer & Indie Game igdshare.org ( 獨立遊戲開發者分享會 )

Slide 6

Slide 6 text

About me Johnson Lin Programmer & Indie Game igdshare.org & Game Jam! (4/28 ~ 4/29) ( 獨立遊戲開發者分享會 )

Slide 7

Slide 7 text

About me Johnson Lin Programmer & Indie Game igdshare.org & Game Jam! (4/28 ~ 4/29) ( 獨立遊戲開發者分享會 ) archilife.org ( 祐生研究基金會 )

Slide 8

Slide 8 text

About me Johnson Lin Programmer & Indie Game igdshare.org & Game Jam! (4/28 ~ 4/29) ( 獨立遊戲開發者分享會 ) archilife.org & Indie game contests scholarship ( 祐生研究基金會 )

Slide 9

Slide 9 text

Overview Introduction to Lua Introduction to LuaJIT How does Lua talk to C/C++ LuaJIT FFI (Foreign Function Interface)

Slide 10

Slide 10 text

Overview Introduction to Lua Introduction to LuaJIT How does Lua talk to C/C++ LuaJIT FFI (Foreign Function Interface)

Slide 11

Slide 11 text

Introduction to LUA Introduction to LUA

Slide 12

Slide 12 text

Introduction to LUA Introduction to LUA LUA is...

Slide 13

Slide 13 text

Introduction to LUA Introduction to LUA LUA is... Lua

Slide 14

Slide 14 text

Introduction to LUA Introduction to LUA LUA is... Lua Uppercase

Slide 15

Slide 15 text

Introduction to LUA Introduction to LUA LUA is... Lua Uppercase Accident This pun came from a clever guy Joseph Manning: http://lua-users.org/lists/lua-l/2011-06/msg01112.html

Slide 16

Slide 16 text

Introduction to Lua Lua = "Moon" in Portuguese Introduction to Lua

Slide 17

Slide 17 text

Introduction to Lua Lua = "Moon" in Portuguese Introduction to Lua

Slide 18

Slide 18 text

Introduction to Lua Lua = "Moon" in Portuguese Use Cases (Game Dev): Introduction to Lua

Slide 19

Slide 19 text

Introduction to Lua Lua = "Moon" in Portuguese Use Cases (Game Dev): Grim Fandango, Introduction to Lua

Slide 20

Slide 20 text

Introduction to Lua Lua = "Moon" in Portuguese Use Cases (Game Dev): Grim Fandango, World of Warcraft UI, Introduction to Lua

Slide 21

Slide 21 text

Introduction to Lua Lua = "Moon" in Portuguese Use Cases (Game Dev): Grim Fandango, World of Warcraft UI, Angry Birds Introduction to Lua

Slide 22

Slide 22 text

Introduction to Lua By Tecgraf / PUC-Rio (1993): Roberto Ierusalimschy, Luiz Henrique de Figueiredo, Waldemar Celes Introduction to Lua

Slide 23

Slide 23 text

Introduction to Lua By Tecgraf / PUC-Rio (1993): Roberto Ierusalimschy, Luiz Henrique de Figueiredo, Waldemar Celes Current version: 5.2.0 / 5.1.5 MIT License since 5.0 (BSD License before then) Introduction to Lua

Slide 24

Slide 24 text

Lua Features Introduction to Lua

Slide 25

Slide 25 text

Lua Features Fast Fastest among other well-known interpreted language Introduction to Lua

Slide 26

Slide 26 text

Lua Features Fast Fastest among other well-known interpreted language Small ~150kB binary, ~20kB mem overhead per interpreter Introduction to Lua

Slide 27

Slide 27 text

Lua Features Fast Fastest among other well-known interpreted language Small ~150kB binary, ~20kB mem overhead per interpreter Simple 22 keywords, 27 tokens Introduction to Lua

Slide 28

Slide 28 text

Lua Features Multithreading-Friendly multiple interpreters in multiple threads concurrently without GIL Introduction to Lua

Slide 29

Slide 29 text

Lua Features Multithreading-Friendly multiple interpreters in multiple threads concurrently without GIL Easy to Embed & Extend concise Lua/C API Introduction to Lua

Slide 30

Slide 30 text

Lua Features Multithreading-Friendly multiple interpreters in multiple threads concurrently without GIL Easy to Embed & Extend concise Lua/C API But, without "battery" although Luarocks is in place Introduction to Lua

Slide 31

Slide 31 text

Lua Features Introduction to Lua Multi-paradigm:

Slide 32

Slide 32 text

Lua Features Introduction to Lua Multi-paradigm: procedural functional prototype-based OO

Slide 33

Slide 33 text

Lua Features Introduction to Lua Multi-paradigm: procedural functional prototype-based OO Think Lua as JavaScript

Slide 34

Slide 34 text

Lua Features Introduction to Lua Multi-paradigm: procedural functional prototype-based OO Think Lua as JavaScript .....without the Bad Parts

Slide 35

Slide 35 text

Z Combinator in Lua Introduction to Lua local Y = function(f) return (function(x) return f (function(y) return (x(x))(y) end) end) (function(x) return f (function(y) return (x(x))(y) end) end) end

Slide 36

Slide 36 text

Overview Introduction to Lua Introduction to LuaJIT How does Lua talk to C/C++ LuaJIT FFI (Foreign Function Interface)

Slide 37

Slide 37 text

Introduction to LuaJIT Introduction to LuaJIT

Slide 38

Slide 38 text

Introduction to LuaJIT Just-In-Time compiler for Lua Introduction to LuaJIT

Slide 39

Slide 39 text

Introduction to LuaJIT Just-In-Time compiler for Lua Mike Pall Introduction to LuaJIT

Slide 40

Slide 40 text

Introduction to LuaJIT Just-In-Time compiler for Lua Mike Pall LuaJIT1 (2005~, current 1.1.7) LuaJIT2 (2009~, current 2.0-beta9) Introduction to LuaJIT

Slide 41

Slide 41 text

LuaJIT2 Features Interpreter written in assembler (DynASM) Introduction to LuaJIT

Slide 42

Slide 42 text

LuaJIT2 Features Interpreter written in assembler (DynASM) Trace compiler Introduction to LuaJIT

Slide 43

Slide 43 text

LuaJIT2 Features Interpreter written in assembler (DynASM) Trace compiler x86/64 (Windows, OSX, Linux, etc) SSE2 instructions required Introduction to LuaJIT

Slide 44

Slide 44 text

LuaJIT2 Features Interpreter written in assembler (DynASM) Trace compiler x86/64 (Windows, OSX, Linux, etc) SSE2 instructions required ARM (Android, iOS, etc), PPC, MIPS only the interpreter part on iOS works now, blame Apple Introduction to LuaJIT

Slide 45

Slide 45 text

LuaJIT2 Features API & ABI compatible with Lua 5.1 Bytecode NOT compatible Introduction to LuaJIT

Slide 46

Slide 46 text

LuaJIT2 Features API & ABI compatible with Lua 5.1 Bytecode NOT compatible Some Lua 5.2 functionality But not going to fully catch up anytime soon Introduction to LuaJIT

Slide 47

Slide 47 text

LuaJIT2 Features API & ABI compatible with Lua 5.1 Bytecode NOT compatible Some Lua 5.2 functionality But not going to fully catch up anytime soon Foreign Function Interface with C parser and a few extensions Introduction to LuaJIT

Slide 48

Slide 48 text

LuaJIT - Behind the Scene Introduction to LuaJIT

Slide 49

Slide 49 text

LuaJIT - Behind the Scene Introduction to LuaJIT Too hard for me! Sorry!

Slide 50

Slide 50 text

Some Use Cases of LuaJIT AI Implementation in The Settlers 7 (2010) GSL Shell https://github.com/malkia/ufo Includes OpenGL, OpenCL, SDL, ZeroMQ bindings.. OpenResty web framework based on nginx Introduction to LuaJIT

Slide 51

Slide 51 text

Some benchmarks Game of Life C++ v.s. LuaJIT (using FFI) Introduction to LuaJIT

Slide 52

Slide 52 text

Some benchmarks Game of Life C++ v.s. LuaJIT (using FFI) Please keep in mind this benchmark is pretty crude and favors LuaJIT, it just shows one extreme. Introduction to LuaJIT

Slide 53

Slide 53 text

Some benchmarks Game of Life Introduction to LuaJIT

Slide 54

Slide 54 text

Some benchmarks Introduction to LuaJIT Pueudo Code: while (true) { game.update(); game.render(); end //both update & render has a big 2d loop //doing state update and drawing cells respectively https://github.com/arch-jslin/mysandbox/tree/master/cpp/lifegame_sdl

Slide 55

Slide 55 text

Some benchmarks Introduction to LuaJIT Pueudo Code: while true do game:update() -- JIT kick in game:render() -- JIT kick in end --both update & render has a big 2d loop --doing state update and drawing cells respectively https://github.com/arch-jslin/mysandbox/blob/master/lua/lifegame_ffi_sdl_gl.lua

Slide 56

Slide 56 text

Some benchmarks Introduction to LuaJIT Pueudo Code: while true do game:update() -- JIT back off game:render() -- JIT kick in end --both update & render has a big 2d loop --doing state update and drawing cells respectively

Slide 57

Slide 57 text

Some benchmarks Introduction to LuaJIT Pueudo Code: while true do game:update() -- JIT back off game:render() -- JIT back off end --both update & render has a big 2d loop --doing state update and drawing cells respectively

Slide 58

Slide 58 text

LuaJIT Roadmap Introduction to LuaJIT

Slide 59

Slide 59 text

LuaJIT Roadmap LuaJIT 2.0 almost feature freeze ARM hard-fp support looking for sponsor Introduction to LuaJIT

Slide 60

Slide 60 text

LuaJIT Roadmap LuaJIT 2.0 almost feature freeze ARM hard-fp support looking for sponsor LuaJIT 2.1 garbage collector redesign Introduction to LuaJIT

Slide 61

Slide 61 text

LuaJIT Roadmap LuaJIT 2.0 almost feature freeze ARM hard-fp support looking for sponsor LuaJIT 2.1 garbage collector redesign Other unconfirmed: FFI C preprocessor? Introduction to LuaJIT

Slide 62

Slide 62 text

Overview Introduction to Lua Introduction to LuaJIT How does Lua talk to C/C++ LuaJIT FFI (Foreign Function Interface)

Slide 63

Slide 63 text

How does Lua talk to C/C++ How does Lua talk to C/C++ Manipulate lua_State (Lua Stack) Using Lua/C API core library: lua_xxx(); aux library: luaL_xxx();

Slide 64

Slide 64 text

Lua/C API -- Lua local a, b = func_from_c(2,3) How does Lua talk to C/C++

Slide 65

Slide 65 text

Lua/C API -- Lua local a, b = func_from_c(2,3) //C static int func_from_c(lua_State* L) { int x = luaL_checkint(L, 1); int y = luaL_checkint(L, -1); lua_pushinteger(L, x+y); lua_pushinteger(L, x-y); return 2; } How does Lua talk to C/C++

Slide 66

Slide 66 text

Lua/C API -- Lua local a, b = func_from_c(2,3) //C static int func_from_c(lua_State* L) { int x = luaL_checkint(L, 1); int y = luaL_checkint(L, -1); lua_pushinteger(L, x+y); lua_pushinteger(L, x-y); return 2; } How does Lua talk to C/C++

Slide 67

Slide 67 text

What about C++ object? How does Lua talk to C/C++ -- Lua local o = Simple(1) -- C++ obj

Slide 68

Slide 68 text

What about C++ object? How does Lua talk to C/C++ -- Lua local o = Simple(1) -- C++ obj //C //Let's see some actual code...

Slide 69

Slide 69 text

What about C++ object? How does Lua talk to C/C++ So that's a bit scary..

Slide 70

Slide 70 text

Binding Libaries How does Lua talk to C/C++

Slide 71

Slide 71 text

Binding Libaries Luabind - boost & template magic How does Lua talk to C/C++

Slide 72

Slide 72 text

Binding Libaries Luabind - boost & template magic OOLua - Macro & template(?) magic How does Lua talk to C/C++

Slide 73

Slide 73 text

Binding Libaries Luabind - boost & template magic OOLua - Macro & template(?) magic Simple Lua Binder - no boost, but still templates How does Lua talk to C/C++

Slide 74

Slide 74 text

Binding Libaries Luabind - boost & template magic OOLua - Macro & template(?) magic Simple Lua Binder - no boost, but still templates ...etc (post talk addition: I am not saying these are bad or what, just our considerations. If you find these tools "just work" for you, then you probably have no reason to abandon them.) How does Lua talk to C/C++

Slide 75

Slide 75 text

Binding Generators tolua & tolua++ How does Lua talk to C/C++

Slide 76

Slide 76 text

Binding Generators tolua & tolua++ SWIG (post talk addition: I am not saying these are bad or what, just our considerations. If you find these tools "just work" for you, then you probably have no reason to abandon them.) How does Lua talk to C/C++

Slide 77

Slide 77 text

Problem with those How does Lua talk to C/C++

Slide 78

Slide 78 text

Problem with those Missing feature How does Lua talk to C/C++

Slide 79

Slide 79 text

Problem with those Missing feature Code bloat How does Lua talk to C/C++

Slide 80

Slide 80 text

Problem with those Missing feature Code bloat Runtime overhead How does Lua talk to C/C++

Slide 81

Slide 81 text

Problem with those Missing feature Code bloat Runtime overhead Yet another glue language How does Lua talk to C/C++

Slide 82

Slide 82 text

Problem with those Missing feature Code bloat Runtime overhead Yet another glue language Not sure what to do in case of bugs How does Lua talk to C/C++

Slide 83

Slide 83 text

LuaJIT Foreign Function Interface LuaJIT FFI

Slide 84

Slide 84 text

Can be JIT compiled Unlike libffi based modules or other binding methods LuaJIT Foreign Function Interface LuaJIT FFI

Slide 85

Slide 85 text

Can be JIT compiled Unlike libffi based modules or other binding methods Has a C parser built-in LuaJIT Foreign Function Interface LuaJIT FFI

Slide 86

Slide 86 text

Can be JIT compiled Unlike libffi based modules or other binding methods Has a C parser built-in Pure Lua Syntax So there's got LuaFFI => https://github.com/jmckaskill/luaffi LuaJIT Foreign Function Interface LuaJIT FFI

Slide 87

Slide 87 text

-- Using C type local ffi = require 'ffi' LuaJIT Foreign Function Interface Examples of LuaJIT FFI

Slide 88

Slide 88 text

-- Using C type local ffi = require 'ffi' local a = ffi.new("int") LuaJIT Foreign Function Interface Examples of LuaJIT FFI

Slide 89

Slide 89 text

-- Using C type local ffi = require 'ffi' local a = ffi.new("int") local b = ffi.new("char const*") LuaJIT Foreign Function Interface Examples of LuaJIT FFI

Slide 90

Slide 90 text

-- Using C type local ffi = require 'ffi' local a = ffi.new("int") local b = ffi.new("char const*") local c = ffi.new("double[10]") LuaJIT Foreign Function Interface Examples of LuaJIT FFI

Slide 91

Slide 91 text

-- Using C type local ffi = require 'ffi' local a = ffi.new("int") local b = ffi.new("char const*") local c = ffi.new("double[10]") local d = ffi.new("double[?]", 20) LuaJIT Foreign Function Interface Examples of LuaJIT FFI

Slide 92

Slide 92 text

-- Calling external C functions local ffi = require 'ffi' LuaJIT Foreign Function Interface Examples of LuaJIT FFI

Slide 93

Slide 93 text

-- Calling external C functions local ffi = require 'ffi' local C = ffi.C LuaJIT Foreign Function Interface Examples of LuaJIT FFI

Slide 94

Slide 94 text

-- Calling external C functions local ffi = require 'ffi' local C = ffi.C ffi.cdef[[ int printf(const char*, ...); ]] LuaJIT Foreign Function Interface Examples of LuaJIT FFI

Slide 95

Slide 95 text

-- Calling external C functions local ffi = require 'ffi' local C = ffi.C ffi.cdef[[ int printf(const char*, ...); ]] C.printf('Hello %s!\n', 'world') LuaJIT Foreign Function Interface Examples of LuaJIT FFI

Slide 96

Slide 96 text

-- Calling external C functions local ffi = require 'ffi' local C = ffi.C ffi.cdef[[ int printf(const char*, ...); ]] C.printf('Hello %s!\n', 'world') C.printf('%d', ffi.cast('int', 3)) LuaJIT Foreign Function Interface Examples of LuaJIT FFI

Slide 97

Slide 97 text

-- Calling external C functions local ffi = require 'ffi' LuaJIT Foreign Function Interface Examples of LuaJIT FFI

Slide 98

Slide 98 text

-- Calling external C functions local ffi = require 'ffi' ffi.cdef[[ typedef struct { int x,y,z; } Point; void do_stuff(Point*); ]] LuaJIT Foreign Function Interface Examples of LuaJIT FFI

Slide 99

Slide 99 text

-- Calling external C functions local ffi = require 'ffi' ffi.cdef[[ typedef struct { int x,y,z; } Point; void do_stuff(Point*); ]] LuaJIT Foreign Function Interface Examples of LuaJIT FFI

Slide 100

Slide 100 text

-- Calling external C functions local ffi = require 'ffi' ffi.cdef[[ typedef struct { int x,y,z; } Point; void do_stuff(Point*); ]] LuaJIT Foreign Function Interface Examples of LuaJIT FFI

Slide 101

Slide 101 text

-- Calling external C functions local ffi = require 'ffi' ffi.cdef[[ typedef struct { int x,y,z; } Point; void do_stuff(Point*); ]] local Lib = ffi.load('path/to/your_c_lib') LuaJIT Foreign Function Interface Examples of LuaJIT FFI

Slide 102

Slide 102 text

-- Calling external C functions local ffi = require 'ffi' ffi.cdef[[ typedef struct { int x,y,z; } Point; void do_stuff(Point*); ]] local Lib = ffi.load('path/to/your_c_lib') local a = ffi.new('Point', 1, 2, 3) LuaJIT Foreign Function Interface Examples of LuaJIT FFI

Slide 103

Slide 103 text

-- Calling external C functions local ffi = require 'ffi' ffi.cdef[[ typedef struct { int x,y,z; } Point; void do_stuff(Point*); ]] local Lib = ffi.load('path/to/your_c_lib') local a = ffi.new('Point', 1, 2, 3) Lib.do_stuff(a) LuaJIT Foreign Function Interface Examples of LuaJIT FFI

Slide 104

Slide 104 text

-- Using C header directly (almost) local ffi = require 'ffi' LuaJIT Foreign Function Interface Examples of LuaJIT FFI

Slide 105

Slide 105 text

-- Using C header directly (almost) local ffi = require 'ffi' ffi.cdef(io.open('header.h', 'r'):read('*a')) LuaJIT Foreign Function Interface Examples of LuaJIT FFI

Slide 106

Slide 106 text

-- Using C header directly (almost) local ffi = require 'ffi' ffi.cdef(io.open('header.h', 'r'):read('*a')) -- This header.h has to be preprocessed LuaJIT Foreign Function Interface Examples of LuaJIT FFI

Slide 107

Slide 107 text

-- Using C header directly (almost) local ffi = require 'ffi' ffi.cdef(io.open('header.h', 'r'):read('*a')) -- This header.h has to be preprocessed -- gcc -E stub.c | grep -v '^#' LuaJIT Foreign Function Interface Examples of LuaJIT FFI

Slide 108

Slide 108 text

-- Using C header directly (almost) local ffi = require 'ffi' ffi.cdef(io.open('header.h', 'r'):read('*a')) -- This header.h has to be preprocessed -- gcc -E stub.c | grep -v '^#' -- stub.c only contain #include LuaJIT Foreign Function Interface Examples of LuaJIT FFI

Slide 109

Slide 109 text

//C++ side class A { public: void method(); }; LuaJIT Foreign Function Interface But, in case of C++

Slide 110

Slide 110 text

//C++ side class A { public: void method(); }; extern "C" { A* A_new() { return new A; } void A_method(A* self) { self->method(); } void A_gc(A* self) { delete self; } } LuaJIT Foreign Function Interface But, in case of C++

Slide 111

Slide 111 text

//C++ side class A { public: void method(); }; extern "C" { A* A_new() { return new A; } void A_method(A* self) { self->method(); } void A_gc(A* self) { delete self; } } LuaJIT Foreign Function Interface But, in case of C++

Slide 112

Slide 112 text

//C++ side class A { public: void method(); }; extern "C" { A* A_new() { return new A; } void A_method(A* self) { self->method(); } void A_gc(A* self) { delete self; } } LuaJIT Foreign Function Interface But, in case of C++

Slide 113

Slide 113 text

//C++ side class A { public: void method(); }; extern "C" { //as before, export these A* A_new() { return new A; } void A_method(A* self) { self->method(); } void A_gc(A* self) { delete self; } } LuaJIT Foreign Function Interface But, in case of C++

Slide 114

Slide 114 text

ffi.cdef[[ typedef struct A A; //and then declare identical functions ]] LuaJIT Foreign Function Interface But, in case of C++

Slide 115

Slide 115 text

ffi.cdef[[ typedef struct A A; //and then declare identical functions ]] LuaJIT Foreign Function Interface But, in case of C++

Slide 116

Slide 116 text

ffi.cdef[[ typedef struct A A; //and then declare identical functions ]] local lib = ffi.load('/path/to/lib') LuaJIT Foreign Function Interface But, in case of C++

Slide 117

Slide 117 text

ffi.cdef[[ typedef struct A A; //and then declare identical functions ]] local lib = ffi.load('/path/to/lib') local mt = {} LuaJIT Foreign Function Interface But, in case of C++

Slide 118

Slide 118 text

ffi.cdef[[ typedef struct A A; //and then declare identical functions ]] local lib = ffi.load('/path/to/lib') local mt = {} mt.__index = mt LuaJIT Foreign Function Interface But, in case of C++

Slide 119

Slide 119 text

ffi.cdef[[ typedef struct A A; //and then declare identical functions ]] local lib = ffi.load('/path/to/lib') local mt = {} mt.__index = mt mt.method = lib.A_method LuaJIT Foreign Function Interface But, in case of C++

Slide 120

Slide 120 text

ffi.cdef[[ typedef struct A A; //and then declare identical functions ]] local lib = ffi.load('/path/to/lib') local mt = {} mt.__index = mt mt.method = lib.A_method ffi.metatype('A', mt) LuaJIT Foreign Function Interface But, in case of C++

Slide 121

Slide 121 text

ffi.cdef[[ typedef struct A A; //and then declare identical functions ]] local lib = ffi.load('/path/to/lib') local mt = {} mt.__index = mt mt.method = lib.A_method ffi.metatype('A', mt) local a = ffi.gc(lib.A_new(), lib.A_gc) LuaJIT Foreign Function Interface But, in case of C++

Slide 122

Slide 122 text

How to reuse header.h in case of namespace? LuaJIT Foreign Function Interface Our problems & solutions

Slide 123

Slide 123 text

How to reuse header.h in case of namespace? //after including binding target classes using namespace ns; extern "C" { #include "header.h" } LuaJIT Foreign Function Interface Our problems & solutions

Slide 124

Slide 124 text

How to reuse header.h in case of namespace? //after including binding target classes using namespace ns; extern "C" { #include "header.h" } A* A_new() { ... } void A_method(A* self) { ... } void A_gc(A* self) { ... } LuaJIT Foreign Function Interface Our problems & solutions

Slide 125

Slide 125 text

shared_ptrs are all over the place! LuaJIT Foreign Function Interface Our problems & solutions

Slide 126

Slide 126 text

Slide 127

Slide 127 text

C++ is the main body, Lua is not LuaJIT Foreign Function Interface Our problems & solutions

Slide 128

Slide 128 text

C++ is the main body, Lua is not Use Lua/C API to push a handle to Lua side at the very beginning. And everything goes. LuaJIT Foreign Function Interface Our problems & solutions

Slide 129

Slide 129 text

C++ is the main body, Lua is not Use Lua/C API to push a handle to Lua side at the very beginning. And everything goes. (have to export a set of methods of this handle to Lua, too) LuaJIT Foreign Function Interface Our problems & solutions

Slide 130

Slide 130 text

Some of our binding codes and usages: 1. https://github.com/godfat/cubeat/blob/master/cubeat-core/include/script/ai/bindings.h 2. https://github.com/godfat/cubeat/blob/master/cubeat-core/src/script/ai/bindings.cpp 3. https://github.com/godfat/cubeat/blob/master/cubeat-core/rc/script/ai/ai.lua 4. https://github.com/godfat/cubeat/blob/master/cubeat-core/rc/script/ai/normal.lua LuaJIT Foreign Function Interface Our problems & solutions

Slide 131

Slide 131 text

Lua is cool and LuaJIT is fast LuaJIT FFI is a powerful tool for bindings Binding automation can still be done (and a lot easier), Conclusion

Slide 132

Slide 132 text

Lua is cool and LuaJIT is fast LuaJIT FFI is a powerful tool for bindings Binding automation can still be done (and a lot easier), IF NECESSARY Conclusion

Slide 133

Slide 133 text

www.lua.org luajit.org lua-users.org Lua mailing list http://en.wikipedia.org/wiki/Lua_%28programming_language%29 github.com/godfat/cubeat References

Slide 134

Slide 134 text

Thank You! Q & A [email protected] gplus.to/jslin www.plurk.com/johnson_lin