lua_VerticalLayout.cpp 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. #include "Base.h"
  2. #include "ScriptController.h"
  3. #include "lua_VerticalLayout.h"
  4. #include "Base.h"
  5. #include "Container.h"
  6. #include "Control.h"
  7. #include "Game.h"
  8. #include "Layout.h"
  9. #include "Ref.h"
  10. #include "VerticalLayout.h"
  11. #include "lua_LayoutType.h"
  12. namespace gameplay
  13. {
  14. void luaRegister_VerticalLayout()
  15. {
  16. const luaL_Reg lua_members[] =
  17. {
  18. {"addRef", lua_VerticalLayout_addRef},
  19. {"getBottomToTop", lua_VerticalLayout_getBottomToTop},
  20. {"getRefCount", lua_VerticalLayout_getRefCount},
  21. {"getSpacing", lua_VerticalLayout_getSpacing},
  22. {"getType", lua_VerticalLayout_getType},
  23. {"release", lua_VerticalLayout_release},
  24. {"setBottomToTop", lua_VerticalLayout_setBottomToTop},
  25. {"setSpacing", lua_VerticalLayout_setSpacing},
  26. {NULL, NULL}
  27. };
  28. const luaL_Reg* lua_statics = NULL;
  29. std::vector<std::string> scopePath;
  30. gameplay::ScriptUtil::registerClass("VerticalLayout", lua_members, NULL, lua_VerticalLayout__gc, lua_statics, scopePath);
  31. }
  32. static VerticalLayout* getInstance(lua_State* state)
  33. {
  34. void* userdata = luaL_checkudata(state, 1, "VerticalLayout");
  35. luaL_argcheck(state, userdata != NULL, 1, "'VerticalLayout' expected.");
  36. return (VerticalLayout*)((gameplay::ScriptUtil::LuaObject*)userdata)->instance;
  37. }
  38. int lua_VerticalLayout__gc(lua_State* state)
  39. {
  40. // Get the number of parameters.
  41. int paramCount = lua_gettop(state);
  42. // Attempt to match the parameters to a valid binding.
  43. switch (paramCount)
  44. {
  45. case 1:
  46. {
  47. if ((lua_type(state, 1) == LUA_TUSERDATA))
  48. {
  49. void* userdata = luaL_checkudata(state, 1, "VerticalLayout");
  50. luaL_argcheck(state, userdata != NULL, 1, "'VerticalLayout' expected.");
  51. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)userdata;
  52. if (object->owns)
  53. {
  54. VerticalLayout* instance = (VerticalLayout*)object->instance;
  55. SAFE_RELEASE(instance);
  56. }
  57. return 0;
  58. }
  59. lua_pushstring(state, "lua_VerticalLayout__gc - 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_VerticalLayout_addRef(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. VerticalLayout* instance = getInstance(state);
  84. instance->addRef();
  85. return 0;
  86. }
  87. lua_pushstring(state, "lua_VerticalLayout_addRef - Failed to match the given parameters to a valid function signature.");
  88. lua_error(state);
  89. break;
  90. }
  91. default:
  92. {
  93. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  94. lua_error(state);
  95. break;
  96. }
  97. }
  98. return 0;
  99. }
  100. int lua_VerticalLayout_getBottomToTop(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 1:
  108. {
  109. if ((lua_type(state, 1) == LUA_TUSERDATA))
  110. {
  111. VerticalLayout* instance = getInstance(state);
  112. bool result = instance->getBottomToTop();
  113. // Push the return value onto the stack.
  114. lua_pushboolean(state, result);
  115. return 1;
  116. }
  117. lua_pushstring(state, "lua_VerticalLayout_getBottomToTop - Failed to match the given parameters to a valid function signature.");
  118. lua_error(state);
  119. break;
  120. }
  121. default:
  122. {
  123. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  124. lua_error(state);
  125. break;
  126. }
  127. }
  128. return 0;
  129. }
  130. int lua_VerticalLayout_getRefCount(lua_State* state)
  131. {
  132. // Get the number of parameters.
  133. int paramCount = lua_gettop(state);
  134. // Attempt to match the parameters to a valid binding.
  135. switch (paramCount)
  136. {
  137. case 1:
  138. {
  139. if ((lua_type(state, 1) == LUA_TUSERDATA))
  140. {
  141. VerticalLayout* instance = getInstance(state);
  142. unsigned int result = instance->getRefCount();
  143. // Push the return value onto the stack.
  144. lua_pushunsigned(state, result);
  145. return 1;
  146. }
  147. lua_pushstring(state, "lua_VerticalLayout_getRefCount - Failed to match the given parameters to a valid function signature.");
  148. lua_error(state);
  149. break;
  150. }
  151. default:
  152. {
  153. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  154. lua_error(state);
  155. break;
  156. }
  157. }
  158. return 0;
  159. }
  160. int lua_VerticalLayout_getSpacing(lua_State* state)
  161. {
  162. // Get the number of parameters.
  163. int paramCount = lua_gettop(state);
  164. // Attempt to match the parameters to a valid binding.
  165. switch (paramCount)
  166. {
  167. case 1:
  168. {
  169. if ((lua_type(state, 1) == LUA_TUSERDATA))
  170. {
  171. VerticalLayout* instance = getInstance(state);
  172. int result = instance->getSpacing();
  173. // Push the return value onto the stack.
  174. lua_pushinteger(state, result);
  175. return 1;
  176. }
  177. lua_pushstring(state, "lua_VerticalLayout_getSpacing - Failed to match the given parameters to a valid function signature.");
  178. lua_error(state);
  179. break;
  180. }
  181. default:
  182. {
  183. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  184. lua_error(state);
  185. break;
  186. }
  187. }
  188. return 0;
  189. }
  190. int lua_VerticalLayout_getType(lua_State* state)
  191. {
  192. // Get the number of parameters.
  193. int paramCount = lua_gettop(state);
  194. // Attempt to match the parameters to a valid binding.
  195. switch (paramCount)
  196. {
  197. case 1:
  198. {
  199. if ((lua_type(state, 1) == LUA_TUSERDATA))
  200. {
  201. VerticalLayout* instance = getInstance(state);
  202. Layout::Type result = instance->getType();
  203. // Push the return value onto the stack.
  204. lua_pushstring(state, lua_stringFromEnum_LayoutType(result));
  205. return 1;
  206. }
  207. lua_pushstring(state, "lua_VerticalLayout_getType - Failed to match the given parameters to a valid function signature.");
  208. lua_error(state);
  209. break;
  210. }
  211. default:
  212. {
  213. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  214. lua_error(state);
  215. break;
  216. }
  217. }
  218. return 0;
  219. }
  220. int lua_VerticalLayout_release(lua_State* state)
  221. {
  222. // Get the number of parameters.
  223. int paramCount = lua_gettop(state);
  224. // Attempt to match the parameters to a valid binding.
  225. switch (paramCount)
  226. {
  227. case 1:
  228. {
  229. if ((lua_type(state, 1) == LUA_TUSERDATA))
  230. {
  231. VerticalLayout* instance = getInstance(state);
  232. instance->release();
  233. return 0;
  234. }
  235. lua_pushstring(state, "lua_VerticalLayout_release - Failed to match the given parameters to a valid function signature.");
  236. lua_error(state);
  237. break;
  238. }
  239. default:
  240. {
  241. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  242. lua_error(state);
  243. break;
  244. }
  245. }
  246. return 0;
  247. }
  248. int lua_VerticalLayout_setBottomToTop(lua_State* state)
  249. {
  250. // Get the number of parameters.
  251. int paramCount = lua_gettop(state);
  252. // Attempt to match the parameters to a valid binding.
  253. switch (paramCount)
  254. {
  255. case 2:
  256. {
  257. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  258. lua_type(state, 2) == LUA_TBOOLEAN)
  259. {
  260. // Get parameter 1 off the stack.
  261. bool param1 = gameplay::ScriptUtil::luaCheckBool(state, 2);
  262. VerticalLayout* instance = getInstance(state);
  263. instance->setBottomToTop(param1);
  264. return 0;
  265. }
  266. lua_pushstring(state, "lua_VerticalLayout_setBottomToTop - Failed to match the given parameters to a valid function signature.");
  267. lua_error(state);
  268. break;
  269. }
  270. default:
  271. {
  272. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  273. lua_error(state);
  274. break;
  275. }
  276. }
  277. return 0;
  278. }
  279. int lua_VerticalLayout_setSpacing(lua_State* state)
  280. {
  281. // Get the number of parameters.
  282. int paramCount = lua_gettop(state);
  283. // Attempt to match the parameters to a valid binding.
  284. switch (paramCount)
  285. {
  286. case 2:
  287. {
  288. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  289. lua_type(state, 2) == LUA_TNUMBER)
  290. {
  291. // Get parameter 1 off the stack.
  292. int param1 = (int)luaL_checkint(state, 2);
  293. VerticalLayout* instance = getInstance(state);
  294. instance->setSpacing(param1);
  295. return 0;
  296. }
  297. lua_pushstring(state, "lua_VerticalLayout_setSpacing - Failed to match the given parameters to a valid function signature.");
  298. lua_error(state);
  299. break;
  300. }
  301. default:
  302. {
  303. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  304. lua_error(state);
  305. break;
  306. }
  307. }
  308. return 0;
  309. }
  310. }