lua_ThemeThemeImage.cpp 10 KB

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