lua_AbsoluteLayout.cpp 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. #include "Base.h"
  2. #include "ScriptController.h"
  3. #include "lua_AbsoluteLayout.h"
  4. #include "AbsoluteLayout.h"
  5. #include "Base.h"
  6. #include "Container.h"
  7. #include "Control.h"
  8. #include "Game.h"
  9. #include "Layout.h"
  10. #include "Ref.h"
  11. #include "lua_LayoutType.h"
  12. namespace gameplay
  13. {
  14. void luaRegister_AbsoluteLayout()
  15. {
  16. const luaL_Reg lua_members[] =
  17. {
  18. {"addRef", lua_AbsoluteLayout_addRef},
  19. {"getRefCount", lua_AbsoluteLayout_getRefCount},
  20. {"getType", lua_AbsoluteLayout_getType},
  21. {"release", lua_AbsoluteLayout_release},
  22. {NULL, NULL}
  23. };
  24. const luaL_Reg* lua_statics = NULL;
  25. std::vector<std::string> scopePath;
  26. gameplay::ScriptUtil::registerClass("AbsoluteLayout", lua_members, NULL, lua_AbsoluteLayout__gc, lua_statics, scopePath);
  27. }
  28. static AbsoluteLayout* getInstance(lua_State* state)
  29. {
  30. void* userdata = luaL_checkudata(state, 1, "AbsoluteLayout");
  31. luaL_argcheck(state, userdata != NULL, 1, "'AbsoluteLayout' expected.");
  32. return (AbsoluteLayout*)((gameplay::ScriptUtil::LuaObject*)userdata)->instance;
  33. }
  34. int lua_AbsoluteLayout__gc(lua_State* state)
  35. {
  36. // Get the number of parameters.
  37. int paramCount = lua_gettop(state);
  38. // Attempt to match the parameters to a valid binding.
  39. switch (paramCount)
  40. {
  41. case 1:
  42. {
  43. if ((lua_type(state, 1) == LUA_TUSERDATA))
  44. {
  45. void* userdata = luaL_checkudata(state, 1, "AbsoluteLayout");
  46. luaL_argcheck(state, userdata != NULL, 1, "'AbsoluteLayout' expected.");
  47. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)userdata;
  48. if (object->owns)
  49. {
  50. AbsoluteLayout* instance = (AbsoluteLayout*)object->instance;
  51. SAFE_RELEASE(instance);
  52. }
  53. return 0;
  54. }
  55. lua_pushstring(state, "lua_AbsoluteLayout__gc - Failed to match the given parameters to a valid function signature.");
  56. lua_error(state);
  57. break;
  58. }
  59. default:
  60. {
  61. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  62. lua_error(state);
  63. break;
  64. }
  65. }
  66. return 0;
  67. }
  68. int lua_AbsoluteLayout_addRef(lua_State* state)
  69. {
  70. // Get the number of parameters.
  71. int paramCount = lua_gettop(state);
  72. // Attempt to match the parameters to a valid binding.
  73. switch (paramCount)
  74. {
  75. case 1:
  76. {
  77. if ((lua_type(state, 1) == LUA_TUSERDATA))
  78. {
  79. AbsoluteLayout* instance = getInstance(state);
  80. instance->addRef();
  81. return 0;
  82. }
  83. lua_pushstring(state, "lua_AbsoluteLayout_addRef - Failed to match the given parameters to a valid function signature.");
  84. lua_error(state);
  85. break;
  86. }
  87. default:
  88. {
  89. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  90. lua_error(state);
  91. break;
  92. }
  93. }
  94. return 0;
  95. }
  96. int lua_AbsoluteLayout_getRefCount(lua_State* state)
  97. {
  98. // Get the number of parameters.
  99. int paramCount = lua_gettop(state);
  100. // Attempt to match the parameters to a valid binding.
  101. switch (paramCount)
  102. {
  103. case 1:
  104. {
  105. if ((lua_type(state, 1) == LUA_TUSERDATA))
  106. {
  107. AbsoluteLayout* instance = getInstance(state);
  108. unsigned int result = instance->getRefCount();
  109. // Push the return value onto the stack.
  110. lua_pushunsigned(state, result);
  111. return 1;
  112. }
  113. lua_pushstring(state, "lua_AbsoluteLayout_getRefCount - Failed to match the given parameters to a valid function signature.");
  114. lua_error(state);
  115. break;
  116. }
  117. default:
  118. {
  119. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  120. lua_error(state);
  121. break;
  122. }
  123. }
  124. return 0;
  125. }
  126. int lua_AbsoluteLayout_getType(lua_State* state)
  127. {
  128. // Get the number of parameters.
  129. int paramCount = lua_gettop(state);
  130. // Attempt to match the parameters to a valid binding.
  131. switch (paramCount)
  132. {
  133. case 1:
  134. {
  135. if ((lua_type(state, 1) == LUA_TUSERDATA))
  136. {
  137. AbsoluteLayout* instance = getInstance(state);
  138. Layout::Type result = instance->getType();
  139. // Push the return value onto the stack.
  140. lua_pushstring(state, lua_stringFromEnum_LayoutType(result));
  141. return 1;
  142. }
  143. lua_pushstring(state, "lua_AbsoluteLayout_getType - Failed to match the given parameters to a valid function signature.");
  144. lua_error(state);
  145. break;
  146. }
  147. default:
  148. {
  149. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  150. lua_error(state);
  151. break;
  152. }
  153. }
  154. return 0;
  155. }
  156. int lua_AbsoluteLayout_release(lua_State* state)
  157. {
  158. // Get the number of parameters.
  159. int paramCount = lua_gettop(state);
  160. // Attempt to match the parameters to a valid binding.
  161. switch (paramCount)
  162. {
  163. case 1:
  164. {
  165. if ((lua_type(state, 1) == LUA_TUSERDATA))
  166. {
  167. AbsoluteLayout* instance = getInstance(state);
  168. instance->release();
  169. return 0;
  170. }
  171. lua_pushstring(state, "lua_AbsoluteLayout_release - Failed to match the given parameters to a valid function signature.");
  172. lua_error(state);
  173. break;
  174. }
  175. default:
  176. {
  177. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  178. lua_error(state);
  179. break;
  180. }
  181. }
  182. return 0;
  183. }
  184. }