binddynamic.d 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465
  1. // Copyright 2019 - 2021 Michael D. Parker
  2. // Distributed under the Boost Software License, Version 1.0.
  3. // (See accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. module bindbc.lua.v51.binddynamic;
  6. version(BindBC_Static) version = BindLua_Static;
  7. version(BindLua_Static) {}
  8. else version = BindLua_Dynamic;
  9. version(LUA_51) {
  10. version(BindLua_Dynamic) version = LUA_51_DYNAMIC;
  11. }
  12. version(LUA_51_DYNAMIC):
  13. import core.stdc.stdarg : va_list;
  14. import bindbc.loader;
  15. import bindbc.lua.config;
  16. import bindbc.lua.v51.types;
  17. extern(C) @nogc nothrow {
  18. // lauxlib.h
  19. alias pluaI_openlib = void function(lua_State* L,const(char)* libname, const(luaL_Reg)* l, int nup);
  20. alias pluaL_register = void function(lua_State* L, const(char)* libname, const(luaL_Reg)* l);
  21. alias pluaL_getmetafield = int function(lua_State* L, int obj, const(char)* e);
  22. alias pluaL_callmeta = int function(lua_State* L, int obj, const(char)* e);
  23. alias pluaL_typerror = int function(lua_State* L, int narg, const(char)* tname);
  24. alias pluaL_argerror = int function(lua_State* L, int numarg, const(char)* extramsg);
  25. alias pluaL_checklstring = const(char)* function(lua_State* L, int numarg, size_t* l);
  26. alias pluaL_optlstring = const(char)* function(lua_State* L, int numArg, const(char)* def, size_t* l);
  27. alias pluaL_checknumber = lua_Number function(lua_State* L, int numArg);
  28. alias pluaL_optnumber = lua_Number function(lua_State* L, int nArg, lua_Number def);
  29. alias pluaL_checkinteger = lua_Integer function(lua_State* L, int numArg);
  30. alias pluaL_optinteger = lua_Integer function(lua_State* L, int nArg, lua_Integer def);
  31. alias pluaL_checkstack = void function(lua_State* L, int sz, const(char)* msg);
  32. alias pluaL_checktype = void function(lua_State* L, int narg, int t);
  33. alias pluaL_checkany = void function(lua_State* L, int narg);
  34. alias pluaL_newmetatable = int function(lua_State* L, const(char)* tname);
  35. alias pluaL_checkudata = void* function(lua_State* L, int ud, const(char)* tname);
  36. alias pluaL_where = void function(lua_State* L, int lvl);
  37. alias pluaL_error = int function(lua_State* L, const(char)* fmt, ...);
  38. alias pluaL_checkoption = int function(lua_State* L, int narg, const(char)* def, const(char)** lst);
  39. alias pluaL_ref = int function(lua_State* L, int t);
  40. alias pluaL_unref = void function(lua_State* L, int t, int ref_);
  41. alias pluaL_loadfile = int function(lua_State* L, const(char)* filename);
  42. alias pluaL_loadbuffer = int function(lua_State* L, const(char)* buff, size_t sz, const(char)* name);
  43. alias pluaL_loadstring = int function(lua_State* L, const(char)* s);
  44. alias pluaL_newstate = lua_State* function();
  45. alias pluaL_gsub = const(char)* function(lua_State* L, const(char)* s, const(char)* p, const(char)* r);
  46. alias pluaL_findtable = const(char)* function(lua_State* L, int idx, const(char)* fname, int szhint);
  47. alias pluaL_buffinit = void function(lua_State* L, luaL_Buffer* B);
  48. alias pluaL_prepbuffer = char* function(luaL_Buffer* B);
  49. alias pluaL_addlstring = void function(luaL_Buffer* B, const(char)* s, size_t l);
  50. alias pluaL_addstring = void function(luaL_Buffer* B, const(char)* s);
  51. alias pluaL_addvalue = void function(luaL_Buffer* B);
  52. alias pluaL_pushresult = void function(luaL_Buffer* B);
  53. // lua.h
  54. alias plua_newstate = lua_State* function(lua_Alloc f, void *ud);
  55. alias plua_close = void function(lua_State* L);
  56. alias plua_newthread = lua_State* function(lua_State* L);
  57. alias plua_atpanic = lua_CFunction function(lua_State* L, lua_CFunction panicf);
  58. alias plua_gettop = int function(lua_State* L);
  59. alias plua_settop = void function(lua_State* L, int idx);
  60. alias plua_pushvalue = void function(lua_State* L, int idx);
  61. alias plua_remove = void function(lua_State* L, int idx);
  62. alias plua_insert = void function(lua_State* L, int idx);
  63. alias plua_replace = void function(lua_State* L, int idx);
  64. alias plua_checkstack = int function(lua_State* L, int idx);
  65. alias plua_xmove = void function(lua_State* L, lua_State*, int idx);
  66. alias plua_isnumber = int function(lua_State* L, int idx);
  67. alias plua_isstring = int function(lua_State* L, int idx);
  68. alias plua_iscfunction = int function(lua_State* L, int idx);
  69. alias plua_isuserdata = int function(lua_State* L, int idx);
  70. alias plua_type = int function(lua_State* L, int idx);
  71. alias plua_typename = const(char)* function(lua_State* L, int tp);
  72. alias plua_equal = int function(lua_State* L, int idx1, int idx2);
  73. alias plua_rawequal = int function(lua_State* L, int idx1, int idx2);
  74. alias plua_lessthan = int function(lua_State* L, int idx1, int idx2);
  75. alias plua_tonumber = lua_Number function(lua_State* L, int idx);
  76. alias plua_tointeger = lua_Integer function(lua_State* L, int idx);
  77. alias plua_toboolean = int function(lua_State* L, int idx);
  78. alias plua_tolstring = const(char)* function(lua_State* L, int idx, size_t* len);
  79. alias plua_objlen = size_t function(lua_State* L, int idx);
  80. alias plua_tocfunction = lua_CFunction function(lua_State* L, int idx);
  81. alias plua_touserdata = void* function(lua_State* L, int idx);
  82. alias plua_tothread = lua_State* function(lua_State* L, int idx);
  83. alias plua_topointer = const(void)* function(lua_State* L, int idx);
  84. alias plua_pushnil = void function(lua_State* L);
  85. alias plua_pushnumber = void function(lua_State* L, lua_Number n);
  86. alias plua_pushinteger = void function(lua_State* L, lua_Integer n);
  87. alias plua_pushlstring = void function(lua_State* L, const(char)* s, size_t l);
  88. alias plua_pushstring = void function(lua_State* L, const(char)* s);
  89. alias plua_pushvfstring = const(char)* function(lua_State* L, const(char)* fmt, va_list argp);
  90. alias plua_pushfstring = const(char)* function(lua_State* L, const(char)* fmt, ...);
  91. alias plua_pushcclosure = void function(lua_State* L, lua_CFunction fn, int n);
  92. alias plua_pushboolean = void function(lua_State* L, int b);
  93. alias plua_pushlightuserdata = void function(lua_State* L, void* p);
  94. alias plua_pushthread = int function(lua_State* L);
  95. alias plua_gettable = void function(lua_State* L, int idx);
  96. alias plua_getfield = void function(lua_State* L, int idx, const(char)* k);
  97. alias plua_rawget = void function(lua_State* L, int idx);
  98. alias plua_rawgeti = void function(lua_State* L, int idx, int n);
  99. alias plua_createtable = void function(lua_State* L, int narr, int nrec);
  100. alias plua_newuserdata = void* function(lua_State* L, size_t sz);
  101. alias plua_getmetatable = int function(lua_State* L, int objindex);
  102. alias plua_getfenv = void function(lua_State* L, int idx);
  103. alias plua_settable = void function(lua_State* L, int idx);
  104. alias plua_setfield = void function(lua_State* L, int idx, const(char)* k);
  105. alias plua_rawset = void function(lua_State* L, int idx);
  106. alias plua_rawseti = void function(lua_State* L, int idx, int n);
  107. alias plua_setmetatable = int function(lua_State* L, int objindex);
  108. alias plua_setfenv = int function(lua_State* L, int idx);
  109. alias plua_call = void function(lua_State* L, int nargs, int nresults);
  110. alias plua_pcall = int function(lua_State* L, int nargs, int nresults, int errFunc);
  111. alias plua_cpcall = int function(lua_State* L, lua_CFunction func, void* ud);
  112. alias plua_load = int function(lua_State* L, lua_Reader reader, void* dt, const(char)* chunkname);
  113. alias plua_dump = int function(lua_State* L, lua_Writer writer, void* data);
  114. alias plua_yield = int function(lua_State* L, int nresults);
  115. alias plua_resume = int function(lua_State* L, int nargs);
  116. alias plua_status = int function(lua_State* L);
  117. alias plua_gc = int function(lua_State* L, int what, int data);
  118. alias plua_error = int function(lua_State* L);
  119. alias plua_next = int function(lua_State* L, int idx);
  120. alias plua_concat = void function(lua_State* L, int n);
  121. alias plua_getallocf = lua_Alloc function(lua_State* L, void** ud);
  122. alias plua_setallocf = void function(lua_State* L, lua_Alloc f, void* ud);
  123. alias plua_setlevel = void function(lua_State* from, lua_State* to);
  124. alias plua_getstack = int function(lua_State* L, int level, lua_Debug* ar);
  125. alias plua_getinfo = int function(lua_State* L, const(char)* what, lua_Debug* ar);
  126. alias plua_getlocal = const(char)* function(lua_State* L, const(lua_Debug)* ar, int n);
  127. alias plua_setlocal = const(char)* function(lua_State* L, const(lua_Debug)* ar, int n);
  128. alias plua_getupvalue = const(char)* function(lua_State* L, int funcindex, int n);
  129. alias plua_setupvalue = const(char)* function(lua_State* L, int funcindex, int n);
  130. alias plua_sethook = int function(lua_State* L, lua_Hook func, int mask, int count);
  131. alias plua_gethook = lua_Hook function(lua_State* L);
  132. alias plua_gethookmask = int function(lua_State* L);
  133. alias plua_gethookcount = int function(lua_State* L);
  134. // lualib.h
  135. alias pluaopen_base = int function(lua_State* L);
  136. alias pluaopen_table = int function(lua_State* L);
  137. alias pluaopen_io = int function(lua_State* L);
  138. alias pluaopen_os = int function(lua_State* L);
  139. alias pluaopen_string = int function(lua_State* L);
  140. alias pluaopen_math = int function(lua_State* L);
  141. alias pluaopen_debug = int function(lua_State* L);
  142. alias pluaopen_package = int function(lua_State* L);
  143. alias pluaL_openlibs = void function(lua_State* L);
  144. }
  145. __gshared {
  146. // lauxlib.h
  147. pluaI_openlib luaI_openlib;
  148. pluaL_register luaL_register;
  149. pluaL_getmetafield luaL_getmetafield;
  150. pluaL_callmeta luaL_callmeta;
  151. pluaL_typerror luaL_typerror;
  152. pluaL_argerror luaL_argerror;
  153. pluaL_checklstring luaL_checklstring;
  154. pluaL_optlstring luaL_optlstring;
  155. pluaL_checknumber luaL_checknumber;
  156. pluaL_optnumber luaL_optnumber;
  157. pluaL_checkinteger luaL_checkinteger;
  158. pluaL_optinteger luaL_optinteger;
  159. pluaL_checkstack luaL_checkstack;
  160. pluaL_checktype luaL_checktype;
  161. pluaL_checkany luaL_checkany;
  162. pluaL_newmetatable luaL_newmetatable;
  163. pluaL_checkudata luaL_checkudata;
  164. pluaL_where luaL_where;
  165. pluaL_error luaL_error;
  166. pluaL_checkoption luaL_checkoption;
  167. pluaL_ref luaL_ref;
  168. pluaL_unref luaL_unref;
  169. pluaL_loadfile luaL_loadfile;
  170. pluaL_loadbuffer luaL_loadbuffer;
  171. pluaL_loadstring luaL_loadstring;
  172. pluaL_newstate luaL_newstate;
  173. pluaL_gsub luaL_gsub;
  174. pluaL_findtable luaL_findtable;
  175. pluaL_buffinit luaL_buffinit;
  176. pluaL_prepbuffer luaL_prepbuffer;
  177. pluaL_addlstring luaL_addlstring;
  178. pluaL_addstring luaL_addstring;
  179. pluaL_addvalue luaL_addvalue;
  180. pluaL_pushresult luaL_pushresult;
  181. // lua.h
  182. plua_newstate lua_newstate;
  183. plua_close lua_close;
  184. plua_newthread lua_newthread;
  185. plua_atpanic lua_atpanic;
  186. plua_gettop lua_gettop;
  187. plua_settop lua_settop;
  188. plua_pushvalue lua_pushvalue;
  189. plua_remove lua_remove;
  190. plua_insert lua_insert;
  191. plua_replace lua_replace;
  192. plua_checkstack lua_checkstack;
  193. plua_xmove lua_xmove;
  194. plua_isnumber lua_isnumber;
  195. plua_isstring lua_isstring;
  196. plua_iscfunction lua_iscfunction;
  197. plua_isuserdata lua_isuserdata;
  198. plua_type lua_type;
  199. plua_typename lua_typename;
  200. plua_equal lua_equal;
  201. plua_rawequal lua_rawequal;
  202. plua_lessthan lua_lessthan;
  203. plua_tonumber lua_tonumber;
  204. plua_tointeger lua_tointeger;
  205. plua_toboolean lua_toboolean;
  206. plua_tolstring lua_tolstring;
  207. plua_objlen lua_objlen;
  208. plua_tocfunction lua_tocfunction;
  209. plua_touserdata lua_touserdata;
  210. plua_tothread lua_tothread;
  211. plua_topointer lua_topointer;
  212. plua_pushnil lua_pushnil;
  213. plua_pushnumber lua_pushnumber;
  214. plua_pushinteger lua_pushinteger;
  215. plua_pushlstring lua_pushlstring;
  216. plua_pushstring lua_pushstring;
  217. plua_pushvfstring lua_pushvfstring;
  218. plua_pushfstring lua_pushfstring;
  219. plua_pushcclosure lua_pushcclosure;
  220. plua_pushboolean lua_pushboolean;
  221. plua_pushlightuserdata lua_pushlightuserdata;
  222. plua_pushthread lua_pushthread;
  223. plua_gettable lua_gettable;
  224. plua_getfield lua_getfield;
  225. plua_rawget lua_rawget;
  226. plua_rawgeti lua_rawgeti;
  227. plua_createtable lua_createtable;
  228. plua_newuserdata lua_newuserdata;
  229. plua_getmetatable lua_getmetatable;
  230. plua_getfenv lua_getfenv;
  231. plua_settable lua_settable;
  232. plua_setfield lua_setfield;
  233. plua_rawset lua_rawset;
  234. plua_rawseti lua_rawseti;
  235. plua_setmetatable lua_setmetatable;
  236. plua_setfenv lua_setfenv;
  237. plua_call lua_call;
  238. plua_pcall lua_pcall;
  239. plua_cpcall lua_cpcall;
  240. plua_load lua_load;
  241. plua_dump lua_dump;
  242. plua_yield lua_yield;
  243. plua_resume lua_resume;
  244. plua_status lua_status;
  245. plua_gc lua_gc;
  246. plua_error lua_error;
  247. plua_next lua_next;
  248. plua_concat lua_concat;
  249. plua_getallocf lua_getallocf;
  250. plua_setallocf lua_setallocf;
  251. plua_setlevel lua_setlevel;
  252. plua_getstack lua_getstack;
  253. plua_getinfo lua_getinfo;
  254. plua_getlocal lua_getlocal;
  255. plua_setlocal lua_setlocal;
  256. plua_getupvalue lua_getupvalue;
  257. plua_setupvalue lua_setupvalue;
  258. plua_sethook lua_sethook;
  259. plua_gethook lua_gethook;
  260. plua_gethookmask lua_gethookmask;
  261. plua_gethookcount lua_gethookcount;
  262. // lualib.h
  263. pluaopen_base luaopen_base;
  264. pluaopen_table luaopen_table;
  265. pluaopen_io luaopen_io;
  266. pluaopen_os luaopen_os;
  267. pluaopen_string luaopen_string;
  268. pluaopen_math luaopen_math;
  269. pluaopen_debug luaopen_debug;
  270. pluaopen_package luaopen_package;
  271. pluaL_openlibs luaL_openlibs;
  272. }
  273. private {
  274. SharedLib lib;
  275. LuaSupport loadedVersion;
  276. }
  277. @nogc nothrow:
  278. void unloadLua()
  279. {
  280. if(lib != invalidHandle) {
  281. lib.unload;
  282. }
  283. }
  284. LuaSupport loadedLuaVersion() @safe { return loadedVersion; }
  285. bool isLuaLoaded() @safe { return lib != invalidHandle; }
  286. LuaSupport loadLua()
  287. {
  288. version(Windows) {
  289. const(char)[][3] libNames = ["lua5.1.dll", "lua51.dll", "lua5.1.5.dll"];
  290. }
  291. else version(OSX) {
  292. const(char)[][1] libNames = "liblua.5.1.dylib";
  293. }
  294. else version(Posix) {
  295. const(char)[][3] libNames = ["liblua.so.5.1", "liblua5.1.so", "liblua-5.1.so"];
  296. }
  297. else static assert(0, "bindbc-lua support for Lua 5.1 is not implemented on this platform.");
  298. LuaSupport ret;
  299. foreach(name; libNames) {
  300. ret = loadLua(name.ptr);
  301. if(ret != LuaSupport.noLibrary) break;
  302. }
  303. return ret;
  304. }
  305. LuaSupport loadLua(const(char)* libName)
  306. {
  307. lib = load(libName);
  308. if(lib == invalidHandle) {
  309. return LuaSupport.noLibrary;
  310. }
  311. auto errCount = errorCount();
  312. loadedVersion = LuaSupport.badLibrary;
  313. // lauxlib.h
  314. lib.bindSymbol(cast(void**)&luaI_openlib, "luaI_openlib");
  315. lib.bindSymbol(cast(void**)&luaL_register, "luaL_register");
  316. lib.bindSymbol(cast(void**)&luaL_getmetafield,"luaL_getmetafield");
  317. lib.bindSymbol(cast(void**)&luaL_callmeta, "luaL_callmeta");
  318. lib.bindSymbol(cast(void**)&luaL_typerror, "luaL_typerror");
  319. lib.bindSymbol(cast(void**)&luaL_checklstring, "luaL_checklstring");
  320. lib.bindSymbol(cast(void**)&luaL_argerror, "luaL_argerror");
  321. lib.bindSymbol(cast(void**)&luaL_optlstring, "luaL_optlstring");
  322. lib.bindSymbol(cast(void**)&luaL_checknumber, "luaL_checknumber");
  323. lib.bindSymbol(cast(void**)&luaL_optnumber, "luaL_optnumber");
  324. lib.bindSymbol(cast(void**)&luaL_checkinteger, "luaL_checkinteger");
  325. lib.bindSymbol(cast(void**)&luaL_optinteger, "luaL_optinteger");
  326. lib.bindSymbol(cast(void**)&luaL_checkstack, "luaL_checkstack");
  327. lib.bindSymbol(cast(void**)&luaL_checktype, "luaL_checktype");
  328. lib.bindSymbol(cast(void**)&luaL_checkany, "luaL_checkany");
  329. lib.bindSymbol(cast(void**)&luaL_newmetatable, "luaL_newmetatable");
  330. lib.bindSymbol(cast(void**)&luaL_checkudata, "luaL_checkudata");
  331. lib.bindSymbol(cast(void**)&luaL_where, "luaL_where");
  332. lib.bindSymbol(cast(void**)&luaL_error, "luaL_error");
  333. lib.bindSymbol(cast(void**)&luaL_checkoption, "luaL_checkoption");
  334. lib.bindSymbol(cast(void**)&luaL_ref, "luaL_ref");
  335. lib.bindSymbol(cast(void**)&luaL_unref, "luaL_unref");
  336. lib.bindSymbol(cast(void**)&luaL_loadfile, "luaL_loadfile");
  337. lib.bindSymbol(cast(void**)&luaL_loadbuffer, "luaL_loadbuffer");
  338. lib.bindSymbol(cast(void**)&luaL_loadstring, "luaL_loadstring");
  339. lib.bindSymbol(cast(void**)&luaL_newstate, "luaL_newstate");
  340. lib.bindSymbol(cast(void**)&luaL_gsub, "luaL_gsub");
  341. lib.bindSymbol(cast(void**)&luaL_findtable, "luaL_findtable");
  342. lib.bindSymbol(cast(void**)&luaL_buffinit, "luaL_buffinit");
  343. lib.bindSymbol(cast(void**)&luaL_prepbuffer, "luaL_prepbuffer");
  344. lib.bindSymbol(cast(void**)&luaL_addlstring, "luaL_addlstring");
  345. lib.bindSymbol(cast(void**)&luaL_addstring, "luaL_addstring");
  346. lib.bindSymbol(cast(void**)&luaL_addvalue, "luaL_addvalue");
  347. lib.bindSymbol(cast(void**)&luaL_pushresult, "luaL_pushresult");
  348. // lua.h
  349. lib.bindSymbol(cast(void**)&lua_newstate, "lua_newstate");
  350. lib.bindSymbol(cast(void**)&lua_close, "lua_close");
  351. lib.bindSymbol(cast(void**)&lua_newthread, "lua_newthread");
  352. lib.bindSymbol(cast(void**)&lua_atpanic, "lua_atpanic");
  353. lib.bindSymbol(cast(void**)&lua_gettop, "lua_gettop");
  354. lib.bindSymbol(cast(void**)&lua_settop, "lua_settop");
  355. lib.bindSymbol(cast(void**)&lua_pushvalue, "lua_pushvalue");
  356. lib.bindSymbol(cast(void**)&lua_remove, "lua_remove");
  357. lib.bindSymbol(cast(void**)&lua_insert, "lua_insert");
  358. lib.bindSymbol(cast(void**)&lua_replace, "lua_replace");
  359. lib.bindSymbol(cast(void**)&lua_checkstack, "lua_checkstack");
  360. lib.bindSymbol(cast(void**)&lua_xmove, "lua_xmove");
  361. lib.bindSymbol(cast(void**)&lua_isnumber, "lua_isnumber");
  362. lib.bindSymbol(cast(void**)&lua_isstring, "lua_isstring");
  363. lib.bindSymbol(cast(void**)&lua_iscfunction, "lua_iscfunction");
  364. lib.bindSymbol(cast(void**)&lua_isuserdata, "lua_isuserdata");
  365. lib.bindSymbol(cast(void**)&lua_type, "lua_type");
  366. lib.bindSymbol(cast(void**)&lua_typename, "lua_typename");
  367. lib.bindSymbol(cast(void**)&lua_equal, "lua_equal");
  368. lib.bindSymbol(cast(void**)&lua_rawequal, "lua_rawequal");
  369. lib.bindSymbol(cast(void**)&lua_lessthan, "lua_lessthan");
  370. lib.bindSymbol(cast(void**)&lua_tonumber, "lua_tonumber");
  371. lib.bindSymbol(cast(void**)&lua_tointeger, "lua_tointeger");
  372. lib.bindSymbol(cast(void**)&lua_toboolean, "lua_toboolean");
  373. lib.bindSymbol(cast(void**)&lua_tolstring, "lua_tolstring");
  374. lib.bindSymbol(cast(void**)&lua_objlen, "lua_objlen");
  375. lib.bindSymbol(cast(void**)&lua_tocfunction, "lua_tocfunction");
  376. lib.bindSymbol(cast(void**)&lua_touserdata, "lua_touserdata");
  377. lib.bindSymbol(cast(void**)&lua_tothread, "lua_tothread");
  378. lib.bindSymbol(cast(void**)&lua_topointer, "lua_topointer");
  379. lib.bindSymbol(cast(void**)&lua_pushnil, "lua_pushnil");
  380. lib.bindSymbol(cast(void**)&lua_pushnumber, "lua_pushnumber");
  381. lib.bindSymbol(cast(void**)&lua_pushinteger, "lua_pushinteger");
  382. lib.bindSymbol(cast(void**)&lua_pushlstring, "lua_pushlstring");
  383. lib.bindSymbol(cast(void**)&lua_pushstring, "lua_pushstring");
  384. lib.bindSymbol(cast(void**)&lua_pushvfstring, "lua_pushvfstring");
  385. lib.bindSymbol(cast(void**)&lua_pushfstring, "lua_pushfstring");
  386. lib.bindSymbol(cast(void**)&lua_pushcclosure, "lua_pushcclosure");
  387. lib.bindSymbol(cast(void**)&lua_pushboolean, "lua_pushboolean");
  388. lib.bindSymbol(cast(void**)&lua_pushlightuserdata, "lua_pushlightuserdata");
  389. lib.bindSymbol(cast(void**)&lua_pushthread, "lua_pushthread");
  390. lib.bindSymbol(cast(void**)&lua_gettable, "lua_gettable");
  391. lib.bindSymbol(cast(void**)&lua_getfield, "lua_getfield");
  392. lib.bindSymbol(cast(void**)&lua_rawget, "lua_rawget");
  393. lib.bindSymbol(cast(void**)&lua_rawgeti, "lua_rawgeti");
  394. lib.bindSymbol(cast(void**)&lua_createtable, "lua_createtable");
  395. lib.bindSymbol(cast(void**)&lua_newuserdata, "lua_newuserdata");
  396. lib.bindSymbol(cast(void**)&lua_getmetatable, "lua_getmetatable");
  397. lib.bindSymbol(cast(void**)&lua_getfenv, "lua_getfenv");
  398. lib.bindSymbol(cast(void**)&lua_settable, "lua_settable");
  399. lib.bindSymbol(cast(void**)&lua_setfield, "lua_setfield");
  400. lib.bindSymbol(cast(void**)&lua_rawset, "lua_rawset");
  401. lib.bindSymbol(cast(void**)&lua_rawseti, "lua_rawseti");
  402. lib.bindSymbol(cast(void**)&lua_setmetatable, "lua_setmetatable");
  403. lib.bindSymbol(cast(void**)&lua_setfenv, "lua_setfenv");
  404. lib.bindSymbol(cast(void**)&lua_call, "lua_call");
  405. lib.bindSymbol(cast(void**)&lua_pcall, "lua_pcall");
  406. lib.bindSymbol(cast(void**)&lua_cpcall, "lua_cpcall");
  407. lib.bindSymbol(cast(void**)&lua_load, "lua_load");
  408. lib.bindSymbol(cast(void**)&lua_dump, "lua_dump");
  409. lib.bindSymbol(cast(void**)&lua_yield, "lua_yield");
  410. lib.bindSymbol(cast(void**)&lua_resume, "lua_resume");
  411. lib.bindSymbol(cast(void**)&lua_status, "lua_status");
  412. lib.bindSymbol(cast(void**)&lua_gc, "lua_gc");
  413. lib.bindSymbol(cast(void**)&lua_error, "lua_error");
  414. lib.bindSymbol(cast(void**)&lua_next, "lua_next");
  415. lib.bindSymbol(cast(void**)&lua_concat, "lua_concat");
  416. lib.bindSymbol(cast(void**)&lua_getallocf, "lua_getallocf");
  417. lib.bindSymbol(cast(void**)&lua_setallocf, "lua_setallocf");
  418. lib.bindSymbol(cast(void**)&lua_setlevel, "lua_setlevel");
  419. lib.bindSymbol(cast(void**)&lua_getstack, "lua_getstack");
  420. lib.bindSymbol(cast(void**)&lua_getinfo, "lua_getinfo");
  421. lib.bindSymbol(cast(void**)&lua_getlocal, "lua_getlocal");
  422. lib.bindSymbol(cast(void**)&lua_setlocal, "lua_setlocal");
  423. lib.bindSymbol(cast(void**)&lua_getupvalue, "lua_getupvalue");
  424. lib.bindSymbol(cast(void**)&lua_setupvalue, "lua_setupvalue");
  425. lib.bindSymbol(cast(void**)&lua_sethook, "lua_sethook");
  426. lib.bindSymbol(cast(void**)&lua_gethook, "lua_gethook");
  427. lib.bindSymbol(cast(void**)&lua_gethookmask, "lua_gethookmask");
  428. lib.bindSymbol(cast(void**)&lua_gethookcount, "lua_gethookcount");
  429. // lualib.h
  430. lib.bindSymbol(cast(void**)&luaopen_base, "luaopen_base");
  431. lib.bindSymbol(cast(void**)&luaopen_table, "luaopen_table");
  432. lib.bindSymbol(cast(void**)&luaopen_io, "luaopen_io");
  433. lib.bindSymbol(cast(void**)&luaopen_os, "luaopen_os");
  434. lib.bindSymbol(cast(void**)&luaopen_string, "luaopen_string");
  435. lib.bindSymbol(cast(void**)&luaopen_math, "luaopen_math");
  436. lib.bindSymbol(cast(void**)&luaopen_debug, "luaopen_debug");
  437. lib.bindSymbol(cast(void**)&luaopen_package, "luaopen_package");
  438. lib.bindSymbol(cast(void**)&luaL_openlibs, "luaL_openlibs");
  439. return LuaSupport.lua51;
  440. }