/gameplay/src/lua/lua_ScriptTargetEventRegistry.cpp

https://github.com/blackberry/GamePlay · C++ · 322 lines · 270 code · 35 blank · 17 comment · 40 complexity · d4268c6d6c0acf443f5967349c782a77 MD5 · raw file

  1. // Autogenerated by gameplay-luagen
  2. #include "Base.h"
  3. #include "ScriptController.h"
  4. #include "lua_ScriptTargetEventRegistry.h"
  5. #include "AnimationClip.h"
  6. #include "Base.h"
  7. #include "Button.h"
  8. #include "CheckBox.h"
  9. #include "Container.h"
  10. #include "Control.h"
  11. #include "Form.h"
  12. #include "ImageControl.h"
  13. #include "Joint.h"
  14. #include "JoystickControl.h"
  15. #include "Label.h"
  16. #include "Node.h"
  17. #include "PhysicsController.h"
  18. #include "RadioButton.h"
  19. #include "ScriptController.h"
  20. #include "ScriptTarget.h"
  21. #include "Slider.h"
  22. #include "TextBox.h"
  23. #include "Transform.h"
  24. namespace gameplay
  25. {
  26. static ScriptTarget::EventRegistry* getInstance(lua_State* state)
  27. {
  28. void* userdata = luaL_checkudata(state, 1, "ScriptTargetEventRegistry");
  29. luaL_argcheck(state, userdata != NULL, 1, "'ScriptTargetEventRegistry' expected.");
  30. return (ScriptTarget::EventRegistry*)((gameplay::ScriptUtil::LuaObject*)userdata)->instance;
  31. }
  32. static int lua_ScriptTargetEventRegistry__gc(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. void* userdata = luaL_checkudata(state, 1, "ScriptTargetEventRegistry");
  44. luaL_argcheck(state, userdata != NULL, 1, "'ScriptTargetEventRegistry' expected.");
  45. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)userdata;
  46. if (object->owns)
  47. {
  48. ScriptTarget::EventRegistry* instance = (ScriptTarget::EventRegistry*)object->instance;
  49. SAFE_DELETE(instance);
  50. }
  51. return 0;
  52. }
  53. lua_pushstring(state, "lua_ScriptTargetEventRegistry__gc - Failed to match the given parameters to a valid function signature.");
  54. lua_error(state);
  55. break;
  56. }
  57. default:
  58. {
  59. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  60. lua_error(state);
  61. break;
  62. }
  63. }
  64. return 0;
  65. }
  66. static int lua_ScriptTargetEventRegistry__init(lua_State* state)
  67. {
  68. // Get the number of parameters.
  69. int paramCount = lua_gettop(state);
  70. // Attempt to match the parameters to a valid binding.
  71. switch (paramCount)
  72. {
  73. case 0:
  74. {
  75. void* returnPtr = ((void*)new ScriptTarget::EventRegistry());
  76. if (returnPtr)
  77. {
  78. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  79. object->instance = returnPtr;
  80. object->owns = true;
  81. luaL_getmetatable(state, "ScriptTargetEventRegistry");
  82. lua_setmetatable(state, -2);
  83. }
  84. else
  85. {
  86. lua_pushnil(state);
  87. }
  88. return 1;
  89. break;
  90. }
  91. default:
  92. {
  93. lua_pushstring(state, "Invalid number of parameters (expected 0).");
  94. lua_error(state);
  95. break;
  96. }
  97. }
  98. return 0;
  99. }
  100. static int lua_ScriptTargetEventRegistry_addEvent(lua_State* state)
  101. {
  102. // Get the number of parameters.
  103. int paramCount = lua_gettop(state);
  104. // Attempt to match the parameters to a valid binding.
  105. switch (paramCount)
  106. {
  107. case 2:
  108. {
  109. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  110. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
  111. {
  112. // Get parameter 1 off the stack.
  113. const char* param1 = gameplay::ScriptUtil::getString(2, false);
  114. ScriptTarget::EventRegistry* instance = getInstance(state);
  115. void* returnPtr = ((void*)instance->addEvent(param1));
  116. if (returnPtr)
  117. {
  118. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  119. object->instance = returnPtr;
  120. object->owns = false;
  121. luaL_getmetatable(state, "ScriptTargetEvent");
  122. lua_setmetatable(state, -2);
  123. }
  124. else
  125. {
  126. lua_pushnil(state);
  127. }
  128. return 1;
  129. }
  130. lua_pushstring(state, "lua_ScriptTargetEventRegistry_addEvent - Failed to match the given parameters to a valid function signature.");
  131. lua_error(state);
  132. break;
  133. }
  134. case 3:
  135. {
  136. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  137. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  138. (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL))
  139. {
  140. // Get parameter 1 off the stack.
  141. const char* param1 = gameplay::ScriptUtil::getString(2, false);
  142. // Get parameter 2 off the stack.
  143. const char* param2 = gameplay::ScriptUtil::getString(3, false);
  144. ScriptTarget::EventRegistry* instance = getInstance(state);
  145. void* returnPtr = ((void*)instance->addEvent(param1, param2));
  146. if (returnPtr)
  147. {
  148. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  149. object->instance = returnPtr;
  150. object->owns = false;
  151. luaL_getmetatable(state, "ScriptTargetEvent");
  152. lua_setmetatable(state, -2);
  153. }
  154. else
  155. {
  156. lua_pushnil(state);
  157. }
  158. return 1;
  159. }
  160. lua_pushstring(state, "lua_ScriptTargetEventRegistry_addEvent - Failed to match the given parameters to a valid function signature.");
  161. lua_error(state);
  162. break;
  163. }
  164. default:
  165. {
  166. lua_pushstring(state, "Invalid number of parameters (expected 2 or 3).");
  167. lua_error(state);
  168. break;
  169. }
  170. }
  171. return 0;
  172. }
  173. static int lua_ScriptTargetEventRegistry_getEvent(lua_State* state)
  174. {
  175. // Get the number of parameters.
  176. int paramCount = lua_gettop(state);
  177. // Attempt to match the parameters to a valid binding.
  178. switch (paramCount)
  179. {
  180. case 2:
  181. {
  182. do
  183. {
  184. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  185. lua_type(state, 2) == LUA_TNUMBER)
  186. {
  187. // Get parameter 1 off the stack.
  188. unsigned int param1 = (unsigned int)luaL_checkunsigned(state, 2);
  189. ScriptTarget::EventRegistry* instance = getInstance(state);
  190. void* returnPtr = ((void*)instance->getEvent(param1));
  191. if (returnPtr)
  192. {
  193. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  194. object->instance = returnPtr;
  195. object->owns = false;
  196. luaL_getmetatable(state, "ScriptTargetEvent");
  197. lua_setmetatable(state, -2);
  198. }
  199. else
  200. {
  201. lua_pushnil(state);
  202. }
  203. return 1;
  204. }
  205. } while (0);
  206. do
  207. {
  208. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  209. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
  210. {
  211. // Get parameter 1 off the stack.
  212. const char* param1 = gameplay::ScriptUtil::getString(2, false);
  213. ScriptTarget::EventRegistry* instance = getInstance(state);
  214. void* returnPtr = ((void*)instance->getEvent(param1));
  215. if (returnPtr)
  216. {
  217. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  218. object->instance = returnPtr;
  219. object->owns = false;
  220. luaL_getmetatable(state, "ScriptTargetEvent");
  221. lua_setmetatable(state, -2);
  222. }
  223. else
  224. {
  225. lua_pushnil(state);
  226. }
  227. return 1;
  228. }
  229. } while (0);
  230. lua_pushstring(state, "lua_ScriptTargetEventRegistry_getEvent - Failed to match the given parameters to a valid function signature.");
  231. lua_error(state);
  232. break;
  233. }
  234. default:
  235. {
  236. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  237. lua_error(state);
  238. break;
  239. }
  240. }
  241. return 0;
  242. }
  243. static int lua_ScriptTargetEventRegistry_getEventCount(lua_State* state)
  244. {
  245. // Get the number of parameters.
  246. int paramCount = lua_gettop(state);
  247. // Attempt to match the parameters to a valid binding.
  248. switch (paramCount)
  249. {
  250. case 1:
  251. {
  252. if ((lua_type(state, 1) == LUA_TUSERDATA))
  253. {
  254. ScriptTarget::EventRegistry* instance = getInstance(state);
  255. unsigned int result = instance->getEventCount();
  256. // Push the return value onto the stack.
  257. lua_pushunsigned(state, result);
  258. return 1;
  259. }
  260. lua_pushstring(state, "lua_ScriptTargetEventRegistry_getEventCount - Failed to match the given parameters to a valid function signature.");
  261. lua_error(state);
  262. break;
  263. }
  264. default:
  265. {
  266. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  267. lua_error(state);
  268. break;
  269. }
  270. }
  271. return 0;
  272. }
  273. void luaRegister_ScriptTargetEventRegistry()
  274. {
  275. const luaL_Reg lua_members[] =
  276. {
  277. {"addEvent", lua_ScriptTargetEventRegistry_addEvent},
  278. {"getEvent", lua_ScriptTargetEventRegistry_getEvent},
  279. {"getEventCount", lua_ScriptTargetEventRegistry_getEventCount},
  280. {NULL, NULL}
  281. };
  282. const luaL_Reg* lua_statics = NULL;
  283. std::vector<std::string> scopePath;
  284. scopePath.push_back("ScriptTarget");
  285. gameplay::ScriptUtil::registerClass("ScriptTargetEventRegistry", lua_members, lua_ScriptTargetEventRegistry__init, lua_ScriptTargetEventRegistry__gc, lua_statics, scopePath);
  286. }
  287. }