luashim.h 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /**
  2. * \file luashim.h
  3. * \brief Lua shim for premake binary modules.
  4. * \author Copyright (c) 2017 Tom van Dijck and the Premake project
  5. */
  6. #ifndef HEADER_luashim_H
  7. #define HEADER_luashim_H
  8. #include "lua.h"
  9. #include "lauxlib.h"
  10. // premake specific helper methods.
  11. void luaL_register(lua_State *L, const char *libname, const luaL_Reg *l);
  12. void shimInitialize(lua_State* L);
  13. typedef struct {
  14. void (*shimL_register)(lua_State *L, const char *libname, const luaL_Reg *l);
  15. lua_State* (*shim_newstate)(lua_Alloc f, void* ud);
  16. void (*shim_close)(lua_State* L);
  17. lua_State* (*shim_newthread)(lua_State* L);
  18. lua_CFunction (*shim_atpanic)(lua_State* L, lua_CFunction panicf);
  19. const lua_Number* (*shim_version)(lua_State* L);
  20. int (*shim_absindex)(lua_State* L, int idx);
  21. int (*shim_gettop)(lua_State* L);
  22. void (*shim_settop)(lua_State* L, int idx);
  23. void (*shim_pushvalue)(lua_State* L, int idx);
  24. void (*shim_rotate)(lua_State* L, int idx, int n);
  25. void (*shim_copy)(lua_State* L, int fromidx, int toidx);
  26. int (*shim_checkstack)(lua_State* L, int n);
  27. void (*shim_xmove)(lua_State* from, lua_State* to, int n);
  28. int (*shim_isnumber)(lua_State* L, int idx);
  29. int (*shim_isstring)(lua_State* L, int idx);
  30. int (*shim_iscfunction)(lua_State* L, int idx);
  31. int (*shim_isinteger)(lua_State* L, int idx);
  32. int (*shim_isuserdata)(lua_State* L, int idx);
  33. int (*shim_type)(lua_State* L, int idx);
  34. const char* (*shim_typename)(lua_State* L, int tp);
  35. lua_Number (*shim_tonumberx)(lua_State* L, int idx, int* isnum);
  36. lua_Integer (*shim_tointegerx)(lua_State* L, int idx, int* isnum);
  37. int (*shim_toboolean)(lua_State* L, int idx);
  38. const char* (*shim_tolstring)(lua_State* L, int idx, size_t* len);
  39. size_t (*shim_rawlen)(lua_State* L, int idx);
  40. lua_CFunction (*shim_tocfunction)(lua_State* L, int idx);
  41. void* (*shim_touserdata)(lua_State* L, int idx);
  42. lua_State* (*shim_tothread)(lua_State* L, int idx);
  43. const void* (*shim_topointer)(lua_State* L, int idx);
  44. void (*shim_arith)(lua_State* L, int op);
  45. int (*shim_rawequal)(lua_State* L, int idx1, int idx2);
  46. int (*shim_compare)(lua_State* L, int idx1, int idx2, int op);
  47. void (*shim_pushnil)(lua_State* L);
  48. void (*shim_pushnumber)(lua_State* L, lua_Number n);
  49. void (*shim_pushinteger)(lua_State* L, lua_Integer n);
  50. const char* (*shim_pushlstring)(lua_State* L, const char* s, size_t len);
  51. const char* (*shim_pushstring)(lua_State* L, const char* s);
  52. const char* (*shim_pushvfstring)(lua_State* L, const char* fmt, va_list argp);
  53. void (*shim_pushcclosure)(lua_State* L, lua_CFunction fn, int n);
  54. void (*shim_pushboolean)(lua_State* L, int b);
  55. void (*shim_pushlightuserdata)(lua_State* L, void* p);
  56. int (*shim_pushthread)(lua_State* L);
  57. int (*shim_getglobal)(lua_State* L, const char* name);
  58. int (*shim_gettable)(lua_State* L, int idx);
  59. int (*shim_getfield)(lua_State* L, int idx, const char* k);
  60. int (*shim_geti)(lua_State* L, int idx, lua_Integer n);
  61. int (*shim_rawget)(lua_State* L, int idx);
  62. int (*shim_rawgeti)(lua_State* L, int idx, lua_Integer n);
  63. int (*shim_rawgetp)(lua_State* L, int idx, const void* p);
  64. void (*shim_createtable)(lua_State* L, int narr, int nrec);
  65. void* (*shim_newuserdata)(lua_State* L, size_t sz);
  66. int (*shim_getmetatable)(lua_State* L, int objindex);
  67. int (*shim_getuservalue)(lua_State* L, int idx);
  68. void (*shim_setglobal)(lua_State* L, const char* name);
  69. void (*shim_settable)(lua_State* L, int idx);
  70. void (*shim_setfield)(lua_State* L, int idx, const char* k);
  71. void (*shim_seti)(lua_State* L, int idx, lua_Integer n);
  72. void (*shim_rawset)(lua_State* L, int idx);
  73. void (*shim_rawseti)(lua_State* L, int idx, lua_Integer n);
  74. void (*shim_rawsetp)(lua_State* L, int idx, const void* p);
  75. int (*shim_setmetatable)(lua_State* L, int objindex);
  76. void (*shim_setuservalue)(lua_State* L, int idx);
  77. void (*shim_callk)(lua_State* L, int nargs, int nresults, lua_KContext ctx, lua_KFunction k);
  78. int (*shim_pcallk)(lua_State* L, int nargs, int nresults, int errfunc, lua_KContext ctx, lua_KFunction k);
  79. int (*shim_load)(lua_State* L, lua_Reader reader, void* dt, const char* chunkname, const char* mode);
  80. int (*shim_dump)(lua_State* L, lua_Writer writer, void* data, int strip);
  81. int (*shim_yieldk)(lua_State* L, int nresults, lua_KContext ctx, lua_KFunction k);
  82. int (*shim_resume)(lua_State* L, lua_State* from, int narg);
  83. int (*shim_status)(lua_State* L);
  84. int (*shim_isyieldable)(lua_State* L);
  85. int (*shim_gc)(lua_State* L, int what, int data);
  86. int (*shim_error)(lua_State* L);
  87. int (*shim_next)(lua_State* L, int idx);
  88. void (*shim_concat)(lua_State* L, int n);
  89. void (*shim_len)(lua_State* L, int idx);
  90. size_t (*shim_stringtonumber)(lua_State* L, const char* s);
  91. lua_Alloc (*shim_getallocf)(lua_State* L, void** ud);
  92. void (*shim_setallocf)(lua_State* L, lua_Alloc f, void* ud);
  93. int (*shim_getstack)(lua_State* L, int level, lua_Debug* ar);
  94. int (*shim_getinfo)(lua_State* L, const char* what, lua_Debug* ar);
  95. const char* (*shim_getlocal)(lua_State* L, const lua_Debug* ar, int n);
  96. const char* (*shim_setlocal)(lua_State* L, const lua_Debug* ar, int n);
  97. const char* (*shim_getupvalue)(lua_State* L, int funcindex, int n);
  98. const char* (*shim_setupvalue)(lua_State* L, int funcindex, int n);
  99. void* (*shim_upvalueid)(lua_State* L, int fidx, int n);
  100. void (*shim_upvaluejoin)(lua_State* L, int fidx1, int n1, int fidx2, int n2);
  101. void (*shim_sethook)(lua_State* L, lua_Hook func, int mask, int count);
  102. lua_Hook (*shim_gethook)(lua_State* L);
  103. int (*shim_gethookmask)(lua_State* L);
  104. int (*shim_gethookcount)(lua_State* L);
  105. void (*shimL_checkversion_)(lua_State* L, lua_Number ver, size_t sz);
  106. int (*shimL_getmetafield)(lua_State* L, int obj, const char* e);
  107. int (*shimL_callmeta)(lua_State* L, int obj, const char* e);
  108. const char* (*shimL_tolstring)(lua_State* L, int idx, size_t* len);
  109. int (*shimL_argerror)(lua_State* L, int arg, const char* extramsg);
  110. const char* (*shimL_checklstring)(lua_State* L, int arg, size_t* l);
  111. const char* (*shimL_optlstring)(lua_State* L, int arg, const char* def, size_t* l);
  112. lua_Number (*shimL_checknumber)(lua_State* L, int arg);
  113. lua_Number (*shimL_optnumber)(lua_State* L, int arg, lua_Number def);
  114. lua_Integer (*shimL_checkinteger)(lua_State* L, int arg);
  115. lua_Integer (*shimL_optinteger)(lua_State* L, int arg, lua_Integer def);
  116. void (*shimL_checkstack)(lua_State* L, int sz, const char* msg);
  117. void (*shimL_checktype)(lua_State* L, int arg, int t);
  118. void (*shimL_checkany)(lua_State* L, int arg);
  119. int (*shimL_newmetatable)(lua_State* L, const char* tname);
  120. void (*shimL_setmetatable)(lua_State* L, const char* tname);
  121. void* (*shimL_testudata)(lua_State* L, int ud, const char* tname);
  122. void* (*shimL_checkudata)(lua_State* L, int ud, const char* tname);
  123. void (*shimL_where)(lua_State* L, int lvl);
  124. int (*shimL_checkoption)(lua_State* L, int arg, const char* def, const char* const lst[]);
  125. int (*shimL_fileresult)(lua_State* L, int stat, const char* fname);
  126. int (*shimL_execresult)(lua_State* L, int stat);
  127. int (*shimL_ref)(lua_State* L, int t);
  128. void (*shimL_unref)(lua_State* L, int t, int ref);
  129. int (*shimL_loadfilex)(lua_State* L, const char* filename, const char* mode);
  130. int (*shimL_loadbufferx)(lua_State* L, const char* buff, size_t sz, const char* name, const char* mode);
  131. int (*shimL_loadstring)(lua_State* L, const char* s);
  132. lua_State* (*shimL_newstate)();
  133. lua_Integer (*shimL_len)(lua_State* L, int idx);
  134. const char* (*shimL_gsub)(lua_State* L, const char* s, const char* p, const char* r);
  135. void (*shimL_setfuncs)(lua_State* L, const luaL_Reg* l, int nup);
  136. int (*shimL_getsubtable)(lua_State* L, int idx, const char* fname);
  137. void (*shimL_traceback)(lua_State* L, lua_State* L1, const char* msg, int level);
  138. void (*shimL_requiref)(lua_State* L, const char* modname, lua_CFunction openf, int glb);
  139. void (*shimL_buffinit)(lua_State* L, luaL_Buffer* B);
  140. char* (*shimL_prepbuffsize)(luaL_Buffer* B, size_t sz);
  141. void (*shimL_addlstring)(luaL_Buffer* B, const char* s, size_t l);
  142. void (*shimL_addstring)(luaL_Buffer* B, const char* s);
  143. void (*shimL_addvalue)(luaL_Buffer* B);
  144. void (*shimL_pushresult)(luaL_Buffer* B);
  145. void (*shimL_pushresultsize)(luaL_Buffer* B, size_t sz);
  146. char* (*shimL_buffinitsize)(lua_State* L, luaL_Buffer* B, size_t sz);
  147. } LuaFunctionTable_t;
  148. #endif