lua_VisibleSetDefault.cpp 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. #include "Base.h"
  2. #include "ScriptController.h"
  3. #include "lua_VisibleSetDefault.h"
  4. #include "Base.h"
  5. #include "VisibleSetDefault.h"
  6. namespace gameplay
  7. {
  8. void luaRegister_VisibleSetDefault()
  9. {
  10. const luaL_Reg lua_members[] =
  11. {
  12. {"getNext", lua_VisibleSetDefault_getNext},
  13. {"getScene", lua_VisibleSetDefault_getScene},
  14. {"reset", lua_VisibleSetDefault_reset},
  15. {"setScene", lua_VisibleSetDefault_setScene},
  16. {NULL, NULL}
  17. };
  18. const luaL_Reg lua_statics[] =
  19. {
  20. {"create", lua_VisibleSetDefault_static_create},
  21. {NULL, NULL}
  22. };
  23. std::vector<std::string> scopePath;
  24. gameplay::ScriptUtil::registerClass("VisibleSetDefault", lua_members, NULL, NULL, lua_statics, scopePath);
  25. }
  26. static VisibleSetDefault* getInstance(lua_State* state)
  27. {
  28. void* userdata = luaL_checkudata(state, 1, "VisibleSetDefault");
  29. luaL_argcheck(state, userdata != NULL, 1, "'VisibleSetDefault' expected.");
  30. return (VisibleSetDefault*)((gameplay::ScriptUtil::LuaObject*)userdata)->instance;
  31. }
  32. int lua_VisibleSetDefault_getNext(lua_State* state)
  33. {
  34. // Get the number of parameters.
  35. int paramCount = lua_gettop(state);
  36. // Attempt to match the parameters to a valid binding.
  37. switch (paramCount)
  38. {
  39. case 1:
  40. {
  41. if ((lua_type(state, 1) == LUA_TUSERDATA))
  42. {
  43. VisibleSetDefault* instance = getInstance(state);
  44. void* returnPtr = (void*)instance->getNext();
  45. if (returnPtr)
  46. {
  47. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  48. object->instance = returnPtr;
  49. object->owns = false;
  50. luaL_getmetatable(state, "Node");
  51. lua_setmetatable(state, -2);
  52. }
  53. else
  54. {
  55. lua_pushnil(state);
  56. }
  57. return 1;
  58. }
  59. lua_pushstring(state, "lua_VisibleSetDefault_getNext - Failed to match the given parameters to a valid function signature.");
  60. lua_error(state);
  61. break;
  62. }
  63. default:
  64. {
  65. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  66. lua_error(state);
  67. break;
  68. }
  69. }
  70. return 0;
  71. }
  72. int lua_VisibleSetDefault_getScene(lua_State* state)
  73. {
  74. // Get the number of parameters.
  75. int paramCount = lua_gettop(state);
  76. // Attempt to match the parameters to a valid binding.
  77. switch (paramCount)
  78. {
  79. case 1:
  80. {
  81. if ((lua_type(state, 1) == LUA_TUSERDATA))
  82. {
  83. VisibleSetDefault* instance = getInstance(state);
  84. void* returnPtr = (void*)instance->getScene();
  85. if (returnPtr)
  86. {
  87. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  88. object->instance = returnPtr;
  89. object->owns = false;
  90. luaL_getmetatable(state, "Scene");
  91. lua_setmetatable(state, -2);
  92. }
  93. else
  94. {
  95. lua_pushnil(state);
  96. }
  97. return 1;
  98. }
  99. lua_pushstring(state, "lua_VisibleSetDefault_getScene - Failed to match the given parameters to a valid function signature.");
  100. lua_error(state);
  101. break;
  102. }
  103. default:
  104. {
  105. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  106. lua_error(state);
  107. break;
  108. }
  109. }
  110. return 0;
  111. }
  112. int lua_VisibleSetDefault_reset(lua_State* state)
  113. {
  114. // Get the number of parameters.
  115. int paramCount = lua_gettop(state);
  116. // Attempt to match the parameters to a valid binding.
  117. switch (paramCount)
  118. {
  119. case 1:
  120. {
  121. if ((lua_type(state, 1) == LUA_TUSERDATA))
  122. {
  123. VisibleSetDefault* instance = getInstance(state);
  124. instance->reset();
  125. return 0;
  126. }
  127. lua_pushstring(state, "lua_VisibleSetDefault_reset - Failed to match the given parameters to a valid function signature.");
  128. lua_error(state);
  129. break;
  130. }
  131. default:
  132. {
  133. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  134. lua_error(state);
  135. break;
  136. }
  137. }
  138. return 0;
  139. }
  140. int lua_VisibleSetDefault_setScene(lua_State* state)
  141. {
  142. // Get the number of parameters.
  143. int paramCount = lua_gettop(state);
  144. // Attempt to match the parameters to a valid binding.
  145. switch (paramCount)
  146. {
  147. case 2:
  148. {
  149. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  150. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL))
  151. {
  152. // Get parameter 1 off the stack.
  153. bool param1Valid;
  154. gameplay::ScriptUtil::LuaArray<Scene> param1 = gameplay::ScriptUtil::getObjectPointer<Scene>(2, "Scene", false, &param1Valid);
  155. if (!param1Valid)
  156. {
  157. lua_pushstring(state, "Failed to convert parameter 1 to type 'Scene'.");
  158. lua_error(state);
  159. }
  160. VisibleSetDefault* instance = getInstance(state);
  161. instance->setScene(param1);
  162. return 0;
  163. }
  164. lua_pushstring(state, "lua_VisibleSetDefault_setScene - Failed to match the given parameters to a valid function signature.");
  165. lua_error(state);
  166. break;
  167. }
  168. default:
  169. {
  170. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  171. lua_error(state);
  172. break;
  173. }
  174. }
  175. return 0;
  176. }
  177. int lua_VisibleSetDefault_static_create(lua_State* state)
  178. {
  179. // Get the number of parameters.
  180. int paramCount = lua_gettop(state);
  181. // Attempt to match the parameters to a valid binding.
  182. switch (paramCount)
  183. {
  184. case 1:
  185. {
  186. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TTABLE || lua_type(state, 1) == LUA_TNIL))
  187. {
  188. // Get parameter 1 off the stack.
  189. bool param1Valid;
  190. gameplay::ScriptUtil::LuaArray<Scene> param1 = gameplay::ScriptUtil::getObjectPointer<Scene>(1, "Scene", false, &param1Valid);
  191. if (!param1Valid)
  192. {
  193. lua_pushstring(state, "Failed to convert parameter 1 to type 'Scene'.");
  194. lua_error(state);
  195. }
  196. void* returnPtr = (void*)VisibleSetDefault::create(param1);
  197. if (returnPtr)
  198. {
  199. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  200. object->instance = returnPtr;
  201. object->owns = false;
  202. luaL_getmetatable(state, "VisibleSetDefault");
  203. lua_setmetatable(state, -2);
  204. }
  205. else
  206. {
  207. lua_pushnil(state);
  208. }
  209. return 1;
  210. }
  211. lua_pushstring(state, "lua_VisibleSetDefault_static_create - Failed to match the given parameters to a valid function signature.");
  212. lua_error(state);
  213. break;
  214. }
  215. default:
  216. {
  217. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  218. lua_error(state);
  219. break;
  220. }
  221. }
  222. return 0;
  223. }
  224. }