├── .gitignore ├── .gitmodules ├── Demo └── LuaJITDemo.zip ├── LuaJIT.framework ├── Headers │ ├── lauxlib.h │ ├── lua.h │ ├── lua.hpp │ ├── luaconf.h │ ├── luajit.h │ └── lualib.h └── LuaJIT ├── README.md ├── luajit-iOS6.1.sh └── luajit.sh /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | build/* 3 | *.pbxuser 4 | !default.pbxuser 5 | *.mode1v3 6 | !default.mode1v3 7 | *.mode2v3 8 | !default.mode2v3 9 | *.perspectivev3 10 | !default.perspectivev3 11 | *.xcworkspace 12 | !default.xcworkspace 13 | xcuserdata 14 | profile 15 | *.moved-aside 16 | .DS_Store 17 | */.DS_Store 18 | */*/.DS_Store 19 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "luajit-2.0"] 2 | path = luajit-2.0 3 | url = http://luajit.org/git/luajit-2.0.git 4 | -------------------------------------------------------------------------------- /Demo/LuaJITDemo.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DylanSale/LuaJIT-iOS-Framework/5275385cce48883f43374118026e47a80c582e20/Demo/LuaJITDemo.zip -------------------------------------------------------------------------------- /LuaJIT.framework/Headers/lauxlib.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lauxlib.h,v 1.88.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Auxiliary functions for building Lua libraries 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #ifndef lauxlib_h 9 | #define lauxlib_h 10 | 11 | 12 | #include 13 | #include 14 | 15 | #include "lua.h" 16 | 17 | 18 | #define luaL_getn(L,i) ((int)lua_objlen(L, i)) 19 | #define luaL_setn(L,i,j) ((void)0) /* no op! */ 20 | 21 | /* extra error code for `luaL_load' */ 22 | #define LUA_ERRFILE (LUA_ERRERR+1) 23 | 24 | typedef struct luaL_Reg { 25 | const char *name; 26 | lua_CFunction func; 27 | } luaL_Reg; 28 | 29 | LUALIB_API void (luaL_openlib) (lua_State *L, const char *libname, 30 | const luaL_Reg *l, int nup); 31 | LUALIB_API void (luaL_register) (lua_State *L, const char *libname, 32 | const luaL_Reg *l); 33 | LUALIB_API int (luaL_getmetafield) (lua_State *L, int obj, const char *e); 34 | LUALIB_API int (luaL_callmeta) (lua_State *L, int obj, const char *e); 35 | LUALIB_API int (luaL_typerror) (lua_State *L, int narg, const char *tname); 36 | LUALIB_API int (luaL_argerror) (lua_State *L, int numarg, const char *extramsg); 37 | LUALIB_API const char *(luaL_checklstring) (lua_State *L, int numArg, 38 | size_t *l); 39 | LUALIB_API const char *(luaL_optlstring) (lua_State *L, int numArg, 40 | const char *def, size_t *l); 41 | LUALIB_API lua_Number (luaL_checknumber) (lua_State *L, int numArg); 42 | LUALIB_API lua_Number (luaL_optnumber) (lua_State *L, int nArg, lua_Number def); 43 | 44 | LUALIB_API lua_Integer (luaL_checkinteger) (lua_State *L, int numArg); 45 | LUALIB_API lua_Integer (luaL_optinteger) (lua_State *L, int nArg, 46 | lua_Integer def); 47 | 48 | LUALIB_API void (luaL_checkstack) (lua_State *L, int sz, const char *msg); 49 | LUALIB_API void (luaL_checktype) (lua_State *L, int narg, int t); 50 | LUALIB_API void (luaL_checkany) (lua_State *L, int narg); 51 | 52 | LUALIB_API int (luaL_newmetatable) (lua_State *L, const char *tname); 53 | LUALIB_API void *(luaL_checkudata) (lua_State *L, int ud, const char *tname); 54 | 55 | LUALIB_API void (luaL_where) (lua_State *L, int lvl); 56 | LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...); 57 | 58 | LUALIB_API int (luaL_checkoption) (lua_State *L, int narg, const char *def, 59 | const char *const lst[]); 60 | 61 | LUALIB_API int (luaL_ref) (lua_State *L, int t); 62 | LUALIB_API void (luaL_unref) (lua_State *L, int t, int ref); 63 | 64 | LUALIB_API int (luaL_loadfile) (lua_State *L, const char *filename); 65 | LUALIB_API int (luaL_loadbuffer) (lua_State *L, const char *buff, size_t sz, 66 | const char *name); 67 | LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s); 68 | 69 | LUALIB_API lua_State *(luaL_newstate) (void); 70 | 71 | 72 | LUALIB_API const char *(luaL_gsub) (lua_State *L, const char *s, const char *p, 73 | const char *r); 74 | 75 | LUALIB_API const char *(luaL_findtable) (lua_State *L, int idx, 76 | const char *fname, int szhint); 77 | 78 | /* From Lua 5.2. */ 79 | LUALIB_API int luaL_fileresult(lua_State *L, int stat, const char *fname); 80 | LUALIB_API int luaL_execresult(lua_State *L, int stat); 81 | LUALIB_API int (luaL_loadfilex) (lua_State *L, const char *filename, 82 | const char *mode); 83 | LUALIB_API int (luaL_loadbufferx) (lua_State *L, const char *buff, size_t sz, 84 | const char *name, const char *mode); 85 | LUALIB_API void luaL_traceback (lua_State *L, lua_State *L1, const char *msg, 86 | int level); 87 | 88 | 89 | /* 90 | ** =============================================================== 91 | ** some useful macros 92 | ** =============================================================== 93 | */ 94 | 95 | #define luaL_argcheck(L, cond,numarg,extramsg) \ 96 | ((void)((cond) || luaL_argerror(L, (numarg), (extramsg)))) 97 | #define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL)) 98 | #define luaL_optstring(L,n,d) (luaL_optlstring(L, (n), (d), NULL)) 99 | #define luaL_checkint(L,n) ((int)luaL_checkinteger(L, (n))) 100 | #define luaL_optint(L,n,d) ((int)luaL_optinteger(L, (n), (d))) 101 | #define luaL_checklong(L,n) ((long)luaL_checkinteger(L, (n))) 102 | #define luaL_optlong(L,n,d) ((long)luaL_optinteger(L, (n), (d))) 103 | 104 | #define luaL_typename(L,i) lua_typename(L, lua_type(L,(i))) 105 | 106 | #define luaL_dofile(L, fn) \ 107 | (luaL_loadfile(L, fn) || lua_pcall(L, 0, LUA_MULTRET, 0)) 108 | 109 | #define luaL_dostring(L, s) \ 110 | (luaL_loadstring(L, s) || lua_pcall(L, 0, LUA_MULTRET, 0)) 111 | 112 | #define luaL_getmetatable(L,n) (lua_getfield(L, LUA_REGISTRYINDEX, (n))) 113 | 114 | #define luaL_opt(L,f,n,d) (lua_isnoneornil(L,(n)) ? (d) : f(L,(n))) 115 | 116 | /* 117 | ** {====================================================== 118 | ** Generic Buffer manipulation 119 | ** ======================================================= 120 | */ 121 | 122 | 123 | 124 | typedef struct luaL_Buffer { 125 | char *p; /* current position in buffer */ 126 | int lvl; /* number of strings in the stack (level) */ 127 | lua_State *L; 128 | char buffer[LUAL_BUFFERSIZE]; 129 | } luaL_Buffer; 130 | 131 | #define luaL_addchar(B,c) \ 132 | ((void)((B)->p < ((B)->buffer+LUAL_BUFFERSIZE) || luaL_prepbuffer(B)), \ 133 | (*(B)->p++ = (char)(c))) 134 | 135 | /* compatibility only */ 136 | #define luaL_putchar(B,c) luaL_addchar(B,c) 137 | 138 | #define luaL_addsize(B,n) ((B)->p += (n)) 139 | 140 | LUALIB_API void (luaL_buffinit) (lua_State *L, luaL_Buffer *B); 141 | LUALIB_API char *(luaL_prepbuffer) (luaL_Buffer *B); 142 | LUALIB_API void (luaL_addlstring) (luaL_Buffer *B, const char *s, size_t l); 143 | LUALIB_API void (luaL_addstring) (luaL_Buffer *B, const char *s); 144 | LUALIB_API void (luaL_addvalue) (luaL_Buffer *B); 145 | LUALIB_API void (luaL_pushresult) (luaL_Buffer *B); 146 | 147 | 148 | /* }====================================================== */ 149 | 150 | 151 | /* compatibility with ref system */ 152 | 153 | /* pre-defined references */ 154 | #define LUA_NOREF (-2) 155 | #define LUA_REFNIL (-1) 156 | 157 | #define lua_ref(L,lock) ((lock) ? luaL_ref(L, LUA_REGISTRYINDEX) : \ 158 | (lua_pushstring(L, "unlocked references are obsolete"), lua_error(L), 0)) 159 | 160 | #define lua_unref(L,ref) luaL_unref(L, LUA_REGISTRYINDEX, (ref)) 161 | 162 | #define lua_getref(L,ref) lua_rawgeti(L, LUA_REGISTRYINDEX, (ref)) 163 | 164 | 165 | #define luaL_reg luaL_Reg 166 | 167 | #endif 168 | -------------------------------------------------------------------------------- /LuaJIT.framework/Headers/lua.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lua.h,v 1.218.1.5 2008/08/06 13:30:12 roberto Exp $ 3 | ** Lua - An Extensible Extension Language 4 | ** Lua.org, PUC-Rio, Brazil (http://www.lua.org) 5 | ** See Copyright Notice at the end of this file 6 | */ 7 | 8 | 9 | #ifndef lua_h 10 | #define lua_h 11 | 12 | #include 13 | #include 14 | 15 | 16 | #include "luaconf.h" 17 | 18 | 19 | #define LUA_VERSION "Lua 5.1" 20 | #define LUA_RELEASE "Lua 5.1.4" 21 | #define LUA_VERSION_NUM 501 22 | #define LUA_COPYRIGHT "Copyright (C) 1994-2008 Lua.org, PUC-Rio" 23 | #define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo & W. Celes" 24 | 25 | 26 | /* mark for precompiled code (`Lua') */ 27 | #define LUA_SIGNATURE "\033Lua" 28 | 29 | /* option for multiple returns in `lua_pcall' and `lua_call' */ 30 | #define LUA_MULTRET (-1) 31 | 32 | 33 | /* 34 | ** pseudo-indices 35 | */ 36 | #define LUA_REGISTRYINDEX (-10000) 37 | #define LUA_ENVIRONINDEX (-10001) 38 | #define LUA_GLOBALSINDEX (-10002) 39 | #define lua_upvalueindex(i) (LUA_GLOBALSINDEX-(i)) 40 | 41 | 42 | /* thread status; 0 is OK */ 43 | #define LUA_YIELD 1 44 | #define LUA_ERRRUN 2 45 | #define LUA_ERRSYNTAX 3 46 | #define LUA_ERRMEM 4 47 | #define LUA_ERRERR 5 48 | 49 | 50 | typedef struct lua_State lua_State; 51 | 52 | typedef int (*lua_CFunction) (lua_State *L); 53 | 54 | 55 | /* 56 | ** functions that read/write blocks when loading/dumping Lua chunks 57 | */ 58 | typedef const char * (*lua_Reader) (lua_State *L, void *ud, size_t *sz); 59 | 60 | typedef int (*lua_Writer) (lua_State *L, const void* p, size_t sz, void* ud); 61 | 62 | 63 | /* 64 | ** prototype for memory-allocation functions 65 | */ 66 | typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize); 67 | 68 | 69 | /* 70 | ** basic types 71 | */ 72 | #define LUA_TNONE (-1) 73 | 74 | #define LUA_TNIL 0 75 | #define LUA_TBOOLEAN 1 76 | #define LUA_TLIGHTUSERDATA 2 77 | #define LUA_TNUMBER 3 78 | #define LUA_TSTRING 4 79 | #define LUA_TTABLE 5 80 | #define LUA_TFUNCTION 6 81 | #define LUA_TUSERDATA 7 82 | #define LUA_TTHREAD 8 83 | 84 | 85 | 86 | /* minimum Lua stack available to a C function */ 87 | #define LUA_MINSTACK 20 88 | 89 | 90 | /* 91 | ** generic extra include file 92 | */ 93 | #if defined(LUA_USER_H) 94 | #include LUA_USER_H 95 | #endif 96 | 97 | 98 | /* type of numbers in Lua */ 99 | typedef LUA_NUMBER lua_Number; 100 | 101 | 102 | /* type for integer functions */ 103 | typedef LUA_INTEGER lua_Integer; 104 | 105 | 106 | 107 | /* 108 | ** state manipulation 109 | */ 110 | LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud); 111 | LUA_API void (lua_close) (lua_State *L); 112 | LUA_API lua_State *(lua_newthread) (lua_State *L); 113 | 114 | LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf); 115 | 116 | 117 | /* 118 | ** basic stack manipulation 119 | */ 120 | LUA_API int (lua_gettop) (lua_State *L); 121 | LUA_API void (lua_settop) (lua_State *L, int idx); 122 | LUA_API void (lua_pushvalue) (lua_State *L, int idx); 123 | LUA_API void (lua_remove) (lua_State *L, int idx); 124 | LUA_API void (lua_insert) (lua_State *L, int idx); 125 | LUA_API void (lua_replace) (lua_State *L, int idx); 126 | LUA_API int (lua_checkstack) (lua_State *L, int sz); 127 | 128 | LUA_API void (lua_xmove) (lua_State *from, lua_State *to, int n); 129 | 130 | 131 | /* 132 | ** access functions (stack -> C) 133 | */ 134 | 135 | LUA_API int (lua_isnumber) (lua_State *L, int idx); 136 | LUA_API int (lua_isstring) (lua_State *L, int idx); 137 | LUA_API int (lua_iscfunction) (lua_State *L, int idx); 138 | LUA_API int (lua_isuserdata) (lua_State *L, int idx); 139 | LUA_API int (lua_type) (lua_State *L, int idx); 140 | LUA_API const char *(lua_typename) (lua_State *L, int tp); 141 | 142 | LUA_API int (lua_equal) (lua_State *L, int idx1, int idx2); 143 | LUA_API int (lua_rawequal) (lua_State *L, int idx1, int idx2); 144 | LUA_API int (lua_lessthan) (lua_State *L, int idx1, int idx2); 145 | 146 | LUA_API lua_Number (lua_tonumber) (lua_State *L, int idx); 147 | LUA_API lua_Integer (lua_tointeger) (lua_State *L, int idx); 148 | LUA_API int (lua_toboolean) (lua_State *L, int idx); 149 | LUA_API const char *(lua_tolstring) (lua_State *L, int idx, size_t *len); 150 | LUA_API size_t (lua_objlen) (lua_State *L, int idx); 151 | LUA_API lua_CFunction (lua_tocfunction) (lua_State *L, int idx); 152 | LUA_API void *(lua_touserdata) (lua_State *L, int idx); 153 | LUA_API lua_State *(lua_tothread) (lua_State *L, int idx); 154 | LUA_API const void *(lua_topointer) (lua_State *L, int idx); 155 | 156 | 157 | /* 158 | ** push functions (C -> stack) 159 | */ 160 | LUA_API void (lua_pushnil) (lua_State *L); 161 | LUA_API void (lua_pushnumber) (lua_State *L, lua_Number n); 162 | LUA_API void (lua_pushinteger) (lua_State *L, lua_Integer n); 163 | LUA_API void (lua_pushlstring) (lua_State *L, const char *s, size_t l); 164 | LUA_API void (lua_pushstring) (lua_State *L, const char *s); 165 | LUA_API const char *(lua_pushvfstring) (lua_State *L, const char *fmt, 166 | va_list argp); 167 | LUA_API const char *(lua_pushfstring) (lua_State *L, const char *fmt, ...); 168 | LUA_API void (lua_pushcclosure) (lua_State *L, lua_CFunction fn, int n); 169 | LUA_API void (lua_pushboolean) (lua_State *L, int b); 170 | LUA_API void (lua_pushlightuserdata) (lua_State *L, void *p); 171 | LUA_API int (lua_pushthread) (lua_State *L); 172 | 173 | 174 | /* 175 | ** get functions (Lua -> stack) 176 | */ 177 | LUA_API void (lua_gettable) (lua_State *L, int idx); 178 | LUA_API void (lua_getfield) (lua_State *L, int idx, const char *k); 179 | LUA_API void (lua_rawget) (lua_State *L, int idx); 180 | LUA_API void (lua_rawgeti) (lua_State *L, int idx, int n); 181 | LUA_API void (lua_createtable) (lua_State *L, int narr, int nrec); 182 | LUA_API void *(lua_newuserdata) (lua_State *L, size_t sz); 183 | LUA_API int (lua_getmetatable) (lua_State *L, int objindex); 184 | LUA_API void (lua_getfenv) (lua_State *L, int idx); 185 | 186 | 187 | /* 188 | ** set functions (stack -> Lua) 189 | */ 190 | LUA_API void (lua_settable) (lua_State *L, int idx); 191 | LUA_API void (lua_setfield) (lua_State *L, int idx, const char *k); 192 | LUA_API void (lua_rawset) (lua_State *L, int idx); 193 | LUA_API void (lua_rawseti) (lua_State *L, int idx, int n); 194 | LUA_API int (lua_setmetatable) (lua_State *L, int objindex); 195 | LUA_API int (lua_setfenv) (lua_State *L, int idx); 196 | 197 | 198 | /* 199 | ** `load' and `call' functions (load and run Lua code) 200 | */ 201 | LUA_API void (lua_call) (lua_State *L, int nargs, int nresults); 202 | LUA_API int (lua_pcall) (lua_State *L, int nargs, int nresults, int errfunc); 203 | LUA_API int (lua_cpcall) (lua_State *L, lua_CFunction func, void *ud); 204 | LUA_API int (lua_load) (lua_State *L, lua_Reader reader, void *dt, 205 | const char *chunkname); 206 | 207 | LUA_API int (lua_dump) (lua_State *L, lua_Writer writer, void *data); 208 | 209 | 210 | /* 211 | ** coroutine functions 212 | */ 213 | LUA_API int (lua_yield) (lua_State *L, int nresults); 214 | LUA_API int (lua_resume) (lua_State *L, int narg); 215 | LUA_API int (lua_status) (lua_State *L); 216 | 217 | /* 218 | ** garbage-collection function and options 219 | */ 220 | 221 | #define LUA_GCSTOP 0 222 | #define LUA_GCRESTART 1 223 | #define LUA_GCCOLLECT 2 224 | #define LUA_GCCOUNT 3 225 | #define LUA_GCCOUNTB 4 226 | #define LUA_GCSTEP 5 227 | #define LUA_GCSETPAUSE 6 228 | #define LUA_GCSETSTEPMUL 7 229 | 230 | LUA_API int (lua_gc) (lua_State *L, int what, int data); 231 | 232 | 233 | /* 234 | ** miscellaneous functions 235 | */ 236 | 237 | LUA_API int (lua_error) (lua_State *L); 238 | 239 | LUA_API int (lua_next) (lua_State *L, int idx); 240 | 241 | LUA_API void (lua_concat) (lua_State *L, int n); 242 | 243 | LUA_API lua_Alloc (lua_getallocf) (lua_State *L, void **ud); 244 | LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud); 245 | 246 | 247 | 248 | /* 249 | ** =============================================================== 250 | ** some useful macros 251 | ** =============================================================== 252 | */ 253 | 254 | #define lua_pop(L,n) lua_settop(L, -(n)-1) 255 | 256 | #define lua_newtable(L) lua_createtable(L, 0, 0) 257 | 258 | #define lua_register(L,n,f) (lua_pushcfunction(L, (f)), lua_setglobal(L, (n))) 259 | 260 | #define lua_pushcfunction(L,f) lua_pushcclosure(L, (f), 0) 261 | 262 | #define lua_strlen(L,i) lua_objlen(L, (i)) 263 | 264 | #define lua_isfunction(L,n) (lua_type(L, (n)) == LUA_TFUNCTION) 265 | #define lua_istable(L,n) (lua_type(L, (n)) == LUA_TTABLE) 266 | #define lua_islightuserdata(L,n) (lua_type(L, (n)) == LUA_TLIGHTUSERDATA) 267 | #define lua_isnil(L,n) (lua_type(L, (n)) == LUA_TNIL) 268 | #define lua_isboolean(L,n) (lua_type(L, (n)) == LUA_TBOOLEAN) 269 | #define lua_isthread(L,n) (lua_type(L, (n)) == LUA_TTHREAD) 270 | #define lua_isnone(L,n) (lua_type(L, (n)) == LUA_TNONE) 271 | #define lua_isnoneornil(L, n) (lua_type(L, (n)) <= 0) 272 | 273 | #define lua_pushliteral(L, s) \ 274 | lua_pushlstring(L, "" s, (sizeof(s)/sizeof(char))-1) 275 | 276 | #define lua_setglobal(L,s) lua_setfield(L, LUA_GLOBALSINDEX, (s)) 277 | #define lua_getglobal(L,s) lua_getfield(L, LUA_GLOBALSINDEX, (s)) 278 | 279 | #define lua_tostring(L,i) lua_tolstring(L, (i), NULL) 280 | 281 | 282 | 283 | /* 284 | ** compatibility macros and functions 285 | */ 286 | 287 | #define lua_open() luaL_newstate() 288 | 289 | #define lua_getregistry(L) lua_pushvalue(L, LUA_REGISTRYINDEX) 290 | 291 | #define lua_getgccount(L) lua_gc(L, LUA_GCCOUNT, 0) 292 | 293 | #define lua_Chunkreader lua_Reader 294 | #define lua_Chunkwriter lua_Writer 295 | 296 | 297 | /* hack */ 298 | LUA_API void lua_setlevel (lua_State *from, lua_State *to); 299 | 300 | 301 | /* 302 | ** {====================================================================== 303 | ** Debug API 304 | ** ======================================================================= 305 | */ 306 | 307 | 308 | /* 309 | ** Event codes 310 | */ 311 | #define LUA_HOOKCALL 0 312 | #define LUA_HOOKRET 1 313 | #define LUA_HOOKLINE 2 314 | #define LUA_HOOKCOUNT 3 315 | #define LUA_HOOKTAILRET 4 316 | 317 | 318 | /* 319 | ** Event masks 320 | */ 321 | #define LUA_MASKCALL (1 << LUA_HOOKCALL) 322 | #define LUA_MASKRET (1 << LUA_HOOKRET) 323 | #define LUA_MASKLINE (1 << LUA_HOOKLINE) 324 | #define LUA_MASKCOUNT (1 << LUA_HOOKCOUNT) 325 | 326 | typedef struct lua_Debug lua_Debug; /* activation record */ 327 | 328 | 329 | /* Functions to be called by the debuger in specific events */ 330 | typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar); 331 | 332 | 333 | LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar); 334 | LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar); 335 | LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n); 336 | LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n); 337 | LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n); 338 | LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n); 339 | LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask, int count); 340 | LUA_API lua_Hook lua_gethook (lua_State *L); 341 | LUA_API int lua_gethookmask (lua_State *L); 342 | LUA_API int lua_gethookcount (lua_State *L); 343 | 344 | /* From Lua 5.2. */ 345 | LUA_API void *lua_upvalueid (lua_State *L, int idx, int n); 346 | LUA_API void lua_upvaluejoin (lua_State *L, int idx1, int n1, int idx2, int n2); 347 | LUA_API int lua_loadx (lua_State *L, lua_Reader reader, void *dt, 348 | const char *chunkname, const char *mode); 349 | 350 | 351 | struct lua_Debug { 352 | int event; 353 | const char *name; /* (n) */ 354 | const char *namewhat; /* (n) `global', `local', `field', `method' */ 355 | const char *what; /* (S) `Lua', `C', `main', `tail' */ 356 | const char *source; /* (S) */ 357 | int currentline; /* (l) */ 358 | int nups; /* (u) number of upvalues */ 359 | int linedefined; /* (S) */ 360 | int lastlinedefined; /* (S) */ 361 | char short_src[LUA_IDSIZE]; /* (S) */ 362 | /* private part */ 363 | int i_ci; /* active function */ 364 | }; 365 | 366 | /* }====================================================================== */ 367 | 368 | 369 | /****************************************************************************** 370 | * Copyright (C) 1994-2008 Lua.org, PUC-Rio. All rights reserved. 371 | * 372 | * Permission is hereby granted, free of charge, to any person obtaining 373 | * a copy of this software and associated documentation files (the 374 | * "Software"), to deal in the Software without restriction, including 375 | * without limitation the rights to use, copy, modify, merge, publish, 376 | * distribute, sublicense, and/or sell copies of the Software, and to 377 | * permit persons to whom the Software is furnished to do so, subject to 378 | * the following conditions: 379 | * 380 | * The above copyright notice and this permission notice shall be 381 | * included in all copies or substantial portions of the Software. 382 | * 383 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 384 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 385 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 386 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 387 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 388 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 389 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 390 | ******************************************************************************/ 391 | 392 | 393 | #endif 394 | -------------------------------------------------------------------------------- /LuaJIT.framework/Headers/lua.hpp: -------------------------------------------------------------------------------- 1 | // C++ wrapper for LuaJIT header files. 2 | 3 | extern "C" { 4 | #include "lua.h" 5 | #include "lauxlib.h" 6 | #include "lualib.h" 7 | #include "luajit.h" 8 | } 9 | 10 | -------------------------------------------------------------------------------- /LuaJIT.framework/Headers/luaconf.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Configuration header. 3 | ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef luaconf_h 7 | #define luaconf_h 8 | 9 | #include 10 | #include 11 | 12 | /* Default path for loading Lua and C modules with require(). */ 13 | #if defined(_WIN32) 14 | /* 15 | ** In Windows, any exclamation mark ('!') in the path is replaced by the 16 | ** path of the directory of the executable file of the current process. 17 | */ 18 | #define LUA_LDIR "!\\lua\\" 19 | #define LUA_CDIR "!\\" 20 | #define LUA_PATH_DEFAULT \ 21 | ".\\?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" 22 | #define LUA_CPATH_DEFAULT \ 23 | ".\\?.dll;" LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll" 24 | #else 25 | /* 26 | ** Note to distribution maintainers: do NOT patch the following line! 27 | ** Please read ../doc/install.html#distro and pass PREFIX=/usr instead. 28 | */ 29 | #define LUA_ROOT "/usr/local/" 30 | #define LUA_LDIR LUA_ROOT "share/lua/5.1/" 31 | #define LUA_CDIR LUA_ROOT "lib/lua/5.1/" 32 | #ifdef LUA_XROOT 33 | #define LUA_JDIR LUA_XROOT "share/luajit-2.0.2/" 34 | #define LUA_XPATH \ 35 | ";" LUA_XROOT "share/lua/5.1/?.lua;" LUA_XROOT "share/lua/5.1/?/init.lua" 36 | #define LUA_XCPATH LUA_XROOT "lib/lua/5.1/?.so;" 37 | #else 38 | #define LUA_JDIR LUA_ROOT "share/luajit-2.0.2/" 39 | #define LUA_XPATH 40 | #define LUA_XCPATH 41 | #endif 42 | #define LUA_PATH_DEFAULT \ 43 | "./?.lua;" LUA_JDIR"?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua" LUA_XPATH 44 | #define LUA_CPATH_DEFAULT \ 45 | "./?.so;" LUA_CDIR"?.so;" LUA_XCPATH LUA_CDIR"loadall.so" 46 | #endif 47 | 48 | /* Environment variable names for path overrides and initialization code. */ 49 | #define LUA_PATH "LUA_PATH" 50 | #define LUA_CPATH "LUA_CPATH" 51 | #define LUA_INIT "LUA_INIT" 52 | 53 | /* Special file system characters. */ 54 | #if defined(_WIN32) 55 | #define LUA_DIRSEP "\\" 56 | #else 57 | #define LUA_DIRSEP "/" 58 | #endif 59 | #define LUA_PATHSEP ";" 60 | #define LUA_PATH_MARK "?" 61 | #define LUA_EXECDIR "!" 62 | #define LUA_IGMARK "-" 63 | #define LUA_PATH_CONFIG \ 64 | LUA_DIRSEP "\n" LUA_PATHSEP "\n" LUA_PATH_MARK "\n" \ 65 | LUA_EXECDIR "\n" LUA_IGMARK 66 | 67 | /* Quoting in error messages. */ 68 | #define LUA_QL(x) "'" x "'" 69 | #define LUA_QS LUA_QL("%s") 70 | 71 | /* Various tunables. */ 72 | #define LUAI_MAXSTACK 65500 /* Max. # of stack slots for a thread (<64K). */ 73 | #define LUAI_MAXCSTACK 8000 /* Max. # of stack slots for a C func (<10K). */ 74 | #define LUAI_GCPAUSE 200 /* Pause GC until memory is at 200%. */ 75 | #define LUAI_GCMUL 200 /* Run GC at 200% of allocation speed. */ 76 | #define LUA_MAXCAPTURES 32 /* Max. pattern captures. */ 77 | 78 | /* Compatibility with older library function names. */ 79 | #define LUA_COMPAT_MOD /* OLD: math.mod, NEW: math.fmod */ 80 | #define LUA_COMPAT_GFIND /* OLD: string.gfind, NEW: string.gmatch */ 81 | 82 | /* Configuration for the frontend (the luajit executable). */ 83 | #if defined(luajit_c) 84 | #define LUA_PROGNAME "luajit" /* Fallback frontend name. */ 85 | #define LUA_PROMPT "> " /* Interactive prompt. */ 86 | #define LUA_PROMPT2 ">> " /* Continuation prompt. */ 87 | #define LUA_MAXINPUT 512 /* Max. input line length. */ 88 | #endif 89 | 90 | /* Note: changing the following defines breaks the Lua 5.1 ABI. */ 91 | #define LUA_INTEGER ptrdiff_t 92 | #define LUA_IDSIZE 60 /* Size of lua_Debug.short_src. */ 93 | /* 94 | ** Size of lauxlib and io.* on-stack buffers. Weird workaround to avoid using 95 | ** unreasonable amounts of stack space, but still retain ABI compatibility. 96 | ** Blame Lua for depending on BUFSIZ in the ABI, blame **** for wrecking it. 97 | */ 98 | #define LUAL_BUFFERSIZE (BUFSIZ > 16384 ? 8192 : BUFSIZ) 99 | 100 | /* The following defines are here only for compatibility with luaconf.h 101 | ** from the standard Lua distribution. They must not be changed for LuaJIT. 102 | */ 103 | #define LUA_NUMBER_DOUBLE 104 | #define LUA_NUMBER double 105 | #define LUAI_UACNUMBER double 106 | #define LUA_NUMBER_SCAN "%lf" 107 | #define LUA_NUMBER_FMT "%.14g" 108 | #define lua_number2str(s, n) sprintf((s), LUA_NUMBER_FMT, (n)) 109 | #define LUAI_MAXNUMBER2STR 32 110 | #define LUA_INTFRMLEN "l" 111 | #define LUA_INTFRM_T long 112 | 113 | /* Linkage of public API functions. */ 114 | #if defined(LUA_BUILD_AS_DLL) 115 | #if defined(LUA_CORE) || defined(LUA_LIB) 116 | #define LUA_API __declspec(dllexport) 117 | #else 118 | #define LUA_API __declspec(dllimport) 119 | #endif 120 | #else 121 | #define LUA_API extern 122 | #endif 123 | 124 | #define LUALIB_API LUA_API 125 | 126 | /* Support for internal assertions. */ 127 | #if defined(LUA_USE_ASSERT) || defined(LUA_USE_APICHECK) 128 | #include 129 | #endif 130 | #ifdef LUA_USE_ASSERT 131 | #define lua_assert(x) assert(x) 132 | #endif 133 | #ifdef LUA_USE_APICHECK 134 | #define luai_apicheck(L, o) { (void)L; assert(o); } 135 | #else 136 | #define luai_apicheck(L, o) { (void)L; } 137 | #endif 138 | 139 | #endif 140 | -------------------------------------------------------------------------------- /LuaJIT.framework/Headers/luajit.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** LuaJIT -- a Just-In-Time Compiler for Lua. http://luajit.org/ 3 | ** 4 | ** Copyright (C) 2005-2013 Mike Pall. All rights reserved. 5 | ** 6 | ** Permission is hereby granted, free of charge, to any person obtaining 7 | ** a copy of this software and associated documentation files (the 8 | ** "Software"), to deal in the Software without restriction, including 9 | ** without limitation the rights to use, copy, modify, merge, publish, 10 | ** distribute, sublicense, and/or sell copies of the Software, and to 11 | ** permit persons to whom the Software is furnished to do so, subject to 12 | ** the following conditions: 13 | ** 14 | ** The above copyright notice and this permission notice shall be 15 | ** included in all copies or substantial portions of the Software. 16 | ** 17 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 21 | ** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 22 | ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 23 | ** SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | ** 25 | ** [ MIT license: http://www.opensource.org/licenses/mit-license.php ] 26 | */ 27 | 28 | #ifndef _LUAJIT_H 29 | #define _LUAJIT_H 30 | 31 | #include "lua.h" 32 | 33 | #define LUAJIT_VERSION "LuaJIT 2.0.2" 34 | #define LUAJIT_VERSION_NUM 20002 /* Version 2.0.2 = 02.00.02. */ 35 | #define LUAJIT_VERSION_SYM luaJIT_version_2_0_2 36 | #define LUAJIT_COPYRIGHT "Copyright (C) 2005-2013 Mike Pall" 37 | #define LUAJIT_URL "http://luajit.org/" 38 | 39 | /* Modes for luaJIT_setmode. */ 40 | #define LUAJIT_MODE_MASK 0x00ff 41 | 42 | enum { 43 | LUAJIT_MODE_ENGINE, /* Set mode for whole JIT engine. */ 44 | LUAJIT_MODE_DEBUG, /* Set debug mode (idx = level). */ 45 | 46 | LUAJIT_MODE_FUNC, /* Change mode for a function. */ 47 | LUAJIT_MODE_ALLFUNC, /* Recurse into subroutine protos. */ 48 | LUAJIT_MODE_ALLSUBFUNC, /* Change only the subroutines. */ 49 | 50 | LUAJIT_MODE_TRACE, /* Flush a compiled trace. */ 51 | 52 | LUAJIT_MODE_WRAPCFUNC = 0x10, /* Set wrapper mode for C function calls. */ 53 | 54 | LUAJIT_MODE_MAX 55 | }; 56 | 57 | /* Flags or'ed in to the mode. */ 58 | #define LUAJIT_MODE_OFF 0x0000 /* Turn feature off. */ 59 | #define LUAJIT_MODE_ON 0x0100 /* Turn feature on. */ 60 | #define LUAJIT_MODE_FLUSH 0x0200 /* Flush JIT-compiled code. */ 61 | 62 | /* LuaJIT public C API. */ 63 | 64 | /* Control the JIT engine. */ 65 | LUA_API int luaJIT_setmode(lua_State *L, int idx, int mode); 66 | 67 | /* Enforce (dynamic) linker error for version mismatches. Call from main. */ 68 | LUA_API void LUAJIT_VERSION_SYM(void); 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /LuaJIT.framework/Headers/lualib.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Standard library header. 3 | ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LUALIB_H 7 | #define _LUALIB_H 8 | 9 | #include "lua.h" 10 | 11 | #define LUA_FILEHANDLE "FILE*" 12 | 13 | #define LUA_COLIBNAME "coroutine" 14 | #define LUA_MATHLIBNAME "math" 15 | #define LUA_STRLIBNAME "string" 16 | #define LUA_TABLIBNAME "table" 17 | #define LUA_IOLIBNAME "io" 18 | #define LUA_OSLIBNAME "os" 19 | #define LUA_LOADLIBNAME "package" 20 | #define LUA_DBLIBNAME "debug" 21 | #define LUA_BITLIBNAME "bit" 22 | #define LUA_JITLIBNAME "jit" 23 | #define LUA_FFILIBNAME "ffi" 24 | 25 | LUALIB_API int luaopen_base(lua_State *L); 26 | LUALIB_API int luaopen_math(lua_State *L); 27 | LUALIB_API int luaopen_string(lua_State *L); 28 | LUALIB_API int luaopen_table(lua_State *L); 29 | LUALIB_API int luaopen_io(lua_State *L); 30 | LUALIB_API int luaopen_os(lua_State *L); 31 | LUALIB_API int luaopen_package(lua_State *L); 32 | LUALIB_API int luaopen_debug(lua_State *L); 33 | LUALIB_API int luaopen_bit(lua_State *L); 34 | LUALIB_API int luaopen_jit(lua_State *L); 35 | LUALIB_API int luaopen_ffi(lua_State *L); 36 | 37 | LUALIB_API void luaL_openlibs(lua_State *L); 38 | 39 | #ifndef lua_assert 40 | #define lua_assert(x) ((void)0) 41 | #endif 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /LuaJIT.framework/LuaJIT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DylanSale/LuaJIT-iOS-Framework/5275385cce48883f43374118026e47a80c582e20/LuaJIT.framework/LuaJIT -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | LuaJIT-iOS-Framework 2 | ==================== 3 | 4 | LuaJIT iOS Framework script 5 | 6 | Will compile an iOS Framework from LuaJIT's source code. 7 | 8 | Requires lua 5.1 to be installed on your machine, __XCode 4.2/iOS 5.1__ or greater 9 | 10 | BUILD 11 | ----- 12 | 1. downlaod the [source](http://luajit.org/download.html) of LuaJIT 13 | 2. extract source files and copy them to directory __"LuaJIT-iOS-Framework/luajit-2.0"__ 14 | 3. run the [__luajit.sh__](luajit.sh) (or [__luajit-iOS6.1.sh__](luajit-iOS6.1.sh) for iOS6.1) script and you will get the framework 15 | 16 | 17 | INSTALLATION 18 | ------------ 19 | 20 | + Just drop the framework into your project. 21 | + You will have to refer to \ instead of "lua.h", etc 22 | + You can create a lua.h file which just does #include \ if you have legacy code that uses lua.h 23 | + (maybe) You will also need to include /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/llvm-gcc-4.2/lib/gcc/arm-apple-darwin10/4.2.1/libgcc.a or you will get linker errors when compiling for Device. 24 | 25 | 26 | ISSUES 27 | ------ 28 | 29 | I attached a Demo project at __"LuaJIT-iOS-Framework/Demo/LuaJITDemo.zip"__ , (maybe) you should try to run it in Xcode. 30 | 31 | If there is any problems when using this, read the [LuaJIT Install Page](http://luajit.org/install.html) , read the [lua C API](http://www.lua.org/manual/5.2/manual.html#4), or contact [me](https://github.com/ziggear) via github 32 | 33 | -------------------------------------------------------------------------------- /luajit-iOS6.1.sh: -------------------------------------------------------------------------------- 1 | LUAJIT=luajit-2.0 2 | ISDK=`xcode-select -print-path`/Platforms/iPhoneOS.platform/Developer 3 | ISDKVER=iPhoneOS6.1.sdk 4 | ISDKP=$ISDK/usr/bin/ 5 | CC=/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2/bin/llvm-gcc-4.2 6 | 7 | cd $LUAJIT 8 | 9 | rm -rf iOS 10 | mkdir iOS 11 | #make for iP3/4 12 | make HOST_CC="$CC -m32 -arch i386" CROSS=$ISDKP TARGET_FLAGS="-arch armv7 -isysroot $ISDK/SDKs/$ISDKVER" TARGET=arm TARGET_SYS=iOS clean all 13 | cp -p src/libluajit.a iOS/libluajit-armv7.a 14 | 15 | #make for iP5 16 | make HOST_CC="$CC -m32 -arch i386" CROSS=$ISDKP TARGET_FLAGS="-arch armv7s -isysroot $ISDK/SDKs/$ISDKVER" TARGET=arm TARGET_SYS=iOS clean all 17 | cp -p src/libluajit.a iOS/libluajit-armv7s.a 18 | 19 | #make for Simulator 20 | make CC="$CC -m32" clean all 21 | cp -p src/libluajit.a iOS/libluajit-i386.a 22 | 23 | #combine files 24 | make clean 25 | mkdir LuaJIT.framework 26 | mkdir LuaJIT.framework/Headers 27 | lipo -create iOS/libluajit-*.a -output ./LuaJIT.framework/LuaJIT 28 | rm iOS/libluajit-*.a 29 | 30 | #copy headers 31 | cp src/luajit.h src/luaconf.h src/lua.h src/lua.hpp src/lauxlib.h src/lualib.h ./LuaJIT.framework/Headers 32 | 33 | cd .. 34 | -------------------------------------------------------------------------------- /luajit.sh: -------------------------------------------------------------------------------- 1 | LUAJIT=luajit-2.0 2 | DEVDIR=/Applications/Xcode.app/Contents/Developer/Platforms 3 | IOSVER=iPhoneOS5.1.sdk 4 | SIMVER=iPhoneSimulator5.1.sdk 5 | IOSDIR=$DEVDIR/iPhoneOS.platform/Developer 6 | SIMDIR=$DEVDIR/iPhoneSimulator.platform/Developer 7 | IOSBIN=$IOSDIR/usr/bin/ 8 | SIMBIN=$SIMDIR/usr/bin/ 9 | 10 | BUILD_DIR=build 11 | 12 | FRAMEWORK_NAME=LuaJIT 13 | FRAMEWORK_DIR=$FRAMEWORK_NAME.framework 14 | rm -rf $FRAMEWORK_DIR 15 | rm -rf $BUILD_DIR 16 | rm *.a 1>/dev/null 2>/dev/null 17 | 18 | mkdir -p $BUILD_DIR 19 | 20 | make -j -C $LUAJIT HOST_CFLAGS="-arch i386" HOST_LDFLAGS="-arch i386" TARGET_SYS=iOS TARGET=arm cleaner 21 | make -C $LUAJIT HOST_CFLAGS="-arch i386" HOST_LDFLAGS="-arch i386" TARGET_SYS=iOS TARGET=arm amalg CROSS=$IOSBIN TARGET_FLAGS="-isysroot $IOSDIR/SDKs/$IOSVER -arch armv7" 22 | mv $LUAJIT/src/libluajit.a $BUILD_DIR/libluajitA7.a 23 | make -j -C $LUAJIT HOST_CFLAGS="-arch i386" HOST_LDFLAGS="-arch i386" TARGET_SYS=iOS TARGET=arm cleaner 24 | make -j -C $LUAJIT HOST_CFLAGS="-arch i386" HOST_LDFLAGS="-arch i386" TARGET_SYS=iOS TARGET=arm amalg CROSS=$IOSBIN TARGET_FLAGS="-isysroot $IOSDIR/SDKs/$IOSVER -arch armv6" 25 | mv $LUAJIT/src/libluajit.a $BUILD_DIR/libluajitA6.a 26 | make -j -C $LUAJIT HOST_CFLAGS="-arch i386" HOST_LDFLAGS="-arch i386" TARGET_SYS=iOS TARGET=x86 cleaner 27 | make -j -C $LUAJIT HOST_CFLAGS="-arch i386" HOST_LDFLAGS="-arch i386" TARGET_SYS=iOS TARGET=x86 amalg CROSS=$SIMBIN TARGET_FLAGS="-isysroot $SIMDIR/SDKs/$SIMVER -arch i386" 28 | mv $LUAJIT/src/libluajit.a $BUILD_DIR/libluajit32.a 29 | 30 | 31 | ################################################################################ 32 | # Create iOS framework 33 | mkdir -p $FRAMEWORK_DIR 34 | 35 | # Combine all libraries into one - required for framework 36 | libtool -o $FRAMEWORK_DIR/$FRAMEWORK_NAME $BUILD_DIR/*.a 2> /dev/null 37 | 38 | # Copy public headers into framework 39 | mkdir -p $FRAMEWORK_DIR/Headers 40 | cp $LUAJIT/src/lua.h $FRAMEWORK_DIR/Headers 41 | cp $LUAJIT/src/lauxlib.h $FRAMEWORK_DIR/Headers 42 | cp $LUAJIT/src/lualib.h $FRAMEWORK_DIR/Headers 43 | cp $LUAJIT/src/luajit.h $FRAMEWORK_DIR/Headers 44 | cp $LUAJIT/src/lua.hpp $FRAMEWORK_DIR/Headers 45 | cp $LUAJIT/src/luaconf.h $FRAMEWORK_DIR/Headers 46 | 47 | 48 | # Fix-up header files to use standard framework-style include paths 49 | for FILE in `find "$FRAMEWORK_DIR/Headers" -type f` 50 | do 51 | sed -i "" "s:#include \"\(.*\)\":#include <$FRAMEWORK_NAME/\1>:" "$FILE" 52 | done --------------------------------------------------------------------------------