2
0

lua_ThemeUVs.cpp 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. #include "Base.h"
  2. #include "ScriptController.h"
  3. #include "lua_ThemeUVs.h"
  4. #include "Base.h"
  5. #include "Game.h"
  6. #include "Ref.h"
  7. #include "Theme.h"
  8. #include "ThemeStyle.h"
  9. namespace gameplay
  10. {
  11. void luaRegister_ThemeUVs()
  12. {
  13. const luaL_Reg lua_members[] =
  14. {
  15. {"u1", lua_ThemeUVs_u1},
  16. {"u2", lua_ThemeUVs_u2},
  17. {"v1", lua_ThemeUVs_v1},
  18. {"v2", lua_ThemeUVs_v2},
  19. {NULL, NULL}
  20. };
  21. const luaL_Reg lua_statics[] =
  22. {
  23. {"empty", lua_ThemeUVs_static_empty},
  24. {"full", lua_ThemeUVs_static_full},
  25. {NULL, NULL}
  26. };
  27. std::vector<std::string> scopePath;
  28. scopePath.push_back("Theme");
  29. gameplay::ScriptUtil::registerClass("ThemeUVs", lua_members, lua_ThemeUVs__init, lua_ThemeUVs__gc, lua_statics, scopePath);
  30. }
  31. static Theme::UVs* getInstance(lua_State* state)
  32. {
  33. void* userdata = luaL_checkudata(state, 1, "ThemeUVs");
  34. luaL_argcheck(state, userdata != NULL, 1, "'ThemeUVs' expected.");
  35. return (Theme::UVs*)((gameplay::ScriptUtil::LuaObject*)userdata)->instance;
  36. }
  37. int lua_ThemeUVs__gc(lua_State* state)
  38. {
  39. // Get the number of parameters.
  40. int paramCount = lua_gettop(state);
  41. // Attempt to match the parameters to a valid binding.
  42. switch (paramCount)
  43. {
  44. case 1:
  45. {
  46. if ((lua_type(state, 1) == LUA_TUSERDATA))
  47. {
  48. void* userdata = luaL_checkudata(state, 1, "ThemeUVs");
  49. luaL_argcheck(state, userdata != NULL, 1, "'ThemeUVs' expected.");
  50. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)userdata;
  51. if (object->owns)
  52. {
  53. Theme::UVs* instance = (Theme::UVs*)object->instance;
  54. SAFE_DELETE(instance);
  55. }
  56. return 0;
  57. }
  58. lua_pushstring(state, "lua_ThemeUVs__gc - Failed to match the given parameters to a valid function signature.");
  59. lua_error(state);
  60. break;
  61. }
  62. default:
  63. {
  64. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  65. lua_error(state);
  66. break;
  67. }
  68. }
  69. return 0;
  70. }
  71. int lua_ThemeUVs__init(lua_State* state)
  72. {
  73. // Get the number of parameters.
  74. int paramCount = lua_gettop(state);
  75. // Attempt to match the parameters to a valid binding.
  76. switch (paramCount)
  77. {
  78. case 0:
  79. {
  80. void* returnPtr = (void*)new Theme::UVs();
  81. if (returnPtr)
  82. {
  83. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  84. object->instance = returnPtr;
  85. object->owns = true;
  86. luaL_getmetatable(state, "ThemeUVs");
  87. lua_setmetatable(state, -2);
  88. }
  89. else
  90. {
  91. lua_pushnil(state);
  92. }
  93. return 1;
  94. break;
  95. }
  96. case 4:
  97. {
  98. do
  99. {
  100. if (lua_type(state, 1) == LUA_TNUMBER &&
  101. lua_type(state, 2) == LUA_TNUMBER &&
  102. lua_type(state, 3) == LUA_TNUMBER &&
  103. lua_type(state, 4) == LUA_TNUMBER)
  104. {
  105. // Get parameter 1 off the stack.
  106. float param1 = (float)luaL_checknumber(state, 1);
  107. // Get parameter 2 off the stack.
  108. float param2 = (float)luaL_checknumber(state, 2);
  109. // Get parameter 3 off the stack.
  110. float param3 = (float)luaL_checknumber(state, 3);
  111. // Get parameter 4 off the stack.
  112. float param4 = (float)luaL_checknumber(state, 4);
  113. void* returnPtr = (void*)new Theme::UVs(param1, param2, param3, param4);
  114. if (returnPtr)
  115. {
  116. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  117. object->instance = returnPtr;
  118. object->owns = true;
  119. luaL_getmetatable(state, "ThemeUVs");
  120. lua_setmetatable(state, -2);
  121. }
  122. else
  123. {
  124. lua_pushnil(state);
  125. }
  126. return 1;
  127. }
  128. } while (0);
  129. lua_pushstring(state, "lua_ThemeUVs__init - Failed to match the given parameters to a valid function signature.");
  130. lua_error(state);
  131. break;
  132. }
  133. default:
  134. {
  135. lua_pushstring(state, "Invalid number of parameters (expected 0 or 4).");
  136. lua_error(state);
  137. break;
  138. }
  139. }
  140. return 0;
  141. }
  142. int lua_ThemeUVs_static_empty(lua_State* state)
  143. {
  144. // Get the number of parameters.
  145. int paramCount = lua_gettop(state);
  146. // Attempt to match the parameters to a valid binding.
  147. switch (paramCount)
  148. {
  149. case 0:
  150. {
  151. void* returnPtr = (void*)&(Theme::UVs::empty());
  152. if (returnPtr)
  153. {
  154. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  155. object->instance = returnPtr;
  156. object->owns = false;
  157. luaL_getmetatable(state, "ThemeUVs");
  158. lua_setmetatable(state, -2);
  159. }
  160. else
  161. {
  162. lua_pushnil(state);
  163. }
  164. return 1;
  165. break;
  166. }
  167. default:
  168. {
  169. lua_pushstring(state, "Invalid number of parameters (expected 0).");
  170. lua_error(state);
  171. break;
  172. }
  173. }
  174. return 0;
  175. }
  176. int lua_ThemeUVs_static_full(lua_State* state)
  177. {
  178. // Get the number of parameters.
  179. int paramCount = lua_gettop(state);
  180. // Attempt to match the parameters to a valid binding.
  181. switch (paramCount)
  182. {
  183. case 0:
  184. {
  185. void* returnPtr = (void*)&(Theme::UVs::full());
  186. if (returnPtr)
  187. {
  188. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  189. object->instance = returnPtr;
  190. object->owns = false;
  191. luaL_getmetatable(state, "ThemeUVs");
  192. lua_setmetatable(state, -2);
  193. }
  194. else
  195. {
  196. lua_pushnil(state);
  197. }
  198. return 1;
  199. break;
  200. }
  201. default:
  202. {
  203. lua_pushstring(state, "Invalid number of parameters (expected 0).");
  204. lua_error(state);
  205. break;
  206. }
  207. }
  208. return 0;
  209. }
  210. int lua_ThemeUVs_u1(lua_State* state)
  211. {
  212. // Validate the number of parameters.
  213. if (lua_gettop(state) > 2)
  214. {
  215. lua_pushstring(state, "Invalid number of parameters (expected 1 or 2).");
  216. lua_error(state);
  217. }
  218. Theme::UVs* instance = getInstance(state);
  219. if (lua_gettop(state) == 2)
  220. {
  221. // Get parameter 2 off the stack.
  222. float param2 = (float)luaL_checknumber(state, 2);
  223. instance->u1 = param2;
  224. return 0;
  225. }
  226. else
  227. {
  228. float result = instance->u1;
  229. // Push the return value onto the stack.
  230. lua_pushnumber(state, result);
  231. return 1;
  232. }
  233. }
  234. int lua_ThemeUVs_u2(lua_State* state)
  235. {
  236. // Validate the number of parameters.
  237. if (lua_gettop(state) > 2)
  238. {
  239. lua_pushstring(state, "Invalid number of parameters (expected 1 or 2).");
  240. lua_error(state);
  241. }
  242. Theme::UVs* instance = getInstance(state);
  243. if (lua_gettop(state) == 2)
  244. {
  245. // Get parameter 2 off the stack.
  246. float param2 = (float)luaL_checknumber(state, 2);
  247. instance->u2 = param2;
  248. return 0;
  249. }
  250. else
  251. {
  252. float result = instance->u2;
  253. // Push the return value onto the stack.
  254. lua_pushnumber(state, result);
  255. return 1;
  256. }
  257. }
  258. int lua_ThemeUVs_v1(lua_State* state)
  259. {
  260. // Validate the number of parameters.
  261. if (lua_gettop(state) > 2)
  262. {
  263. lua_pushstring(state, "Invalid number of parameters (expected 1 or 2).");
  264. lua_error(state);
  265. }
  266. Theme::UVs* instance = getInstance(state);
  267. if (lua_gettop(state) == 2)
  268. {
  269. // Get parameter 2 off the stack.
  270. float param2 = (float)luaL_checknumber(state, 2);
  271. instance->v1 = param2;
  272. return 0;
  273. }
  274. else
  275. {
  276. float result = instance->v1;
  277. // Push the return value onto the stack.
  278. lua_pushnumber(state, result);
  279. return 1;
  280. }
  281. }
  282. int lua_ThemeUVs_v2(lua_State* state)
  283. {
  284. // Validate the number of parameters.
  285. if (lua_gettop(state) > 2)
  286. {
  287. lua_pushstring(state, "Invalid number of parameters (expected 1 or 2).");
  288. lua_error(state);
  289. }
  290. Theme::UVs* instance = getInstance(state);
  291. if (lua_gettop(state) == 2)
  292. {
  293. // Get parameter 2 off the stack.
  294. float param2 = (float)luaL_checknumber(state, 2);
  295. instance->v2 = param2;
  296. return 0;
  297. }
  298. else
  299. {
  300. float result = instance->v2;
  301. // Push the return value onto the stack.
  302. lua_pushnumber(state, result);
  303. return 1;
  304. }
  305. }
  306. }