lua_ThemeThemeImage.cpp 10 KB

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