lua_DepthStencilTarget.cpp 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  1. #include "Base.h"
  2. #include "ScriptController.h"
  3. #include "lua_DepthStencilTarget.h"
  4. #include "Base.h"
  5. #include "DepthStencilTarget.h"
  6. #include "Game.h"
  7. #include "Ref.h"
  8. #include "lua_DepthStencilTargetFormat.h"
  9. namespace gameplay
  10. {
  11. void luaRegister_DepthStencilTarget()
  12. {
  13. const luaL_Reg lua_members[] =
  14. {
  15. {"addRef", lua_DepthStencilTarget_addRef},
  16. {"getFormat", lua_DepthStencilTarget_getFormat},
  17. {"getId", lua_DepthStencilTarget_getId},
  18. {"getRefCount", lua_DepthStencilTarget_getRefCount},
  19. {"release", lua_DepthStencilTarget_release},
  20. {NULL, NULL}
  21. };
  22. const luaL_Reg lua_statics[] =
  23. {
  24. {"create", lua_DepthStencilTarget_static_create},
  25. {"getDepthStencilTarget", lua_DepthStencilTarget_static_getDepthStencilTarget},
  26. {NULL, NULL}
  27. };
  28. std::vector<std::string> scopePath;
  29. ScriptUtil::registerClass("DepthStencilTarget", lua_members, NULL, lua_DepthStencilTarget__gc, lua_statics, scopePath);
  30. }
  31. static DepthStencilTarget* getInstance(lua_State* state)
  32. {
  33. void* userdata = luaL_checkudata(state, 1, "DepthStencilTarget");
  34. luaL_argcheck(state, userdata != NULL, 1, "'DepthStencilTarget' expected.");
  35. return (DepthStencilTarget*)((ScriptUtil::LuaObject*)userdata)->instance;
  36. }
  37. int lua_DepthStencilTarget__gc(lua_State* state)
  38. {
  39. // Get the number of parameters.
  40. int paramCount = lua_gettop(state);
  41. // Attempt to match the parameters to a valid binding.
  42. switch (paramCount)
  43. {
  44. case 1:
  45. {
  46. if ((lua_type(state, 1) == LUA_TUSERDATA))
  47. {
  48. void* userdata = luaL_checkudata(state, 1, "DepthStencilTarget");
  49. luaL_argcheck(state, userdata != NULL, 1, "'DepthStencilTarget' expected.");
  50. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)userdata;
  51. if (object->owns)
  52. {
  53. DepthStencilTarget* instance = (DepthStencilTarget*)object->instance;
  54. SAFE_RELEASE(instance);
  55. }
  56. return 0;
  57. }
  58. else
  59. {
  60. lua_pushstring(state, "lua_DepthStencilTarget__gc - Failed to match the given parameters to a valid function signature.");
  61. lua_error(state);
  62. }
  63. break;
  64. }
  65. default:
  66. {
  67. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  68. lua_error(state);
  69. break;
  70. }
  71. }
  72. return 0;
  73. }
  74. int lua_DepthStencilTarget_addRef(lua_State* state)
  75. {
  76. // Get the number of parameters.
  77. int paramCount = lua_gettop(state);
  78. // Attempt to match the parameters to a valid binding.
  79. switch (paramCount)
  80. {
  81. case 1:
  82. {
  83. if ((lua_type(state, 1) == LUA_TUSERDATA))
  84. {
  85. DepthStencilTarget* instance = getInstance(state);
  86. instance->addRef();
  87. return 0;
  88. }
  89. else
  90. {
  91. lua_pushstring(state, "lua_DepthStencilTarget_addRef - Failed to match the given parameters to a valid function signature.");
  92. lua_error(state);
  93. }
  94. break;
  95. }
  96. default:
  97. {
  98. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  99. lua_error(state);
  100. break;
  101. }
  102. }
  103. return 0;
  104. }
  105. int lua_DepthStencilTarget_getFormat(lua_State* state)
  106. {
  107. // Get the number of parameters.
  108. int paramCount = lua_gettop(state);
  109. // Attempt to match the parameters to a valid binding.
  110. switch (paramCount)
  111. {
  112. case 1:
  113. {
  114. if ((lua_type(state, 1) == LUA_TUSERDATA))
  115. {
  116. DepthStencilTarget* instance = getInstance(state);
  117. DepthStencilTarget::Format result = instance->getFormat();
  118. // Push the return value onto the stack.
  119. lua_pushstring(state, lua_stringFromEnum_DepthStencilTargetFormat(result));
  120. return 1;
  121. }
  122. else
  123. {
  124. lua_pushstring(state, "lua_DepthStencilTarget_getFormat - Failed to match the given parameters to a valid function signature.");
  125. lua_error(state);
  126. }
  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_DepthStencilTarget_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. DepthStencilTarget* 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. else
  156. {
  157. lua_pushstring(state, "lua_DepthStencilTarget_getId - Failed to match the given parameters to a valid function signature.");
  158. lua_error(state);
  159. }
  160. break;
  161. }
  162. default:
  163. {
  164. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  165. lua_error(state);
  166. break;
  167. }
  168. }
  169. return 0;
  170. }
  171. int lua_DepthStencilTarget_getRefCount(lua_State* state)
  172. {
  173. // Get the number of parameters.
  174. int paramCount = lua_gettop(state);
  175. // Attempt to match the parameters to a valid binding.
  176. switch (paramCount)
  177. {
  178. case 1:
  179. {
  180. if ((lua_type(state, 1) == LUA_TUSERDATA))
  181. {
  182. DepthStencilTarget* instance = getInstance(state);
  183. unsigned int result = instance->getRefCount();
  184. // Push the return value onto the stack.
  185. lua_pushunsigned(state, result);
  186. return 1;
  187. }
  188. else
  189. {
  190. lua_pushstring(state, "lua_DepthStencilTarget_getRefCount - Failed to match the given parameters to a valid function signature.");
  191. lua_error(state);
  192. }
  193. break;
  194. }
  195. default:
  196. {
  197. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  198. lua_error(state);
  199. break;
  200. }
  201. }
  202. return 0;
  203. }
  204. int lua_DepthStencilTarget_release(lua_State* state)
  205. {
  206. // Get the number of parameters.
  207. int paramCount = lua_gettop(state);
  208. // Attempt to match the parameters to a valid binding.
  209. switch (paramCount)
  210. {
  211. case 1:
  212. {
  213. if ((lua_type(state, 1) == LUA_TUSERDATA))
  214. {
  215. DepthStencilTarget* instance = getInstance(state);
  216. instance->release();
  217. return 0;
  218. }
  219. else
  220. {
  221. lua_pushstring(state, "lua_DepthStencilTarget_release - Failed to match the given parameters to a valid function signature.");
  222. lua_error(state);
  223. }
  224. break;
  225. }
  226. default:
  227. {
  228. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  229. lua_error(state);
  230. break;
  231. }
  232. }
  233. return 0;
  234. }
  235. int lua_DepthStencilTarget_static_create(lua_State* state)
  236. {
  237. // Get the number of parameters.
  238. int paramCount = lua_gettop(state);
  239. // Attempt to match the parameters to a valid binding.
  240. switch (paramCount)
  241. {
  242. case 4:
  243. {
  244. if ((lua_type(state, 1) == LUA_TSTRING || lua_type(state, 1) == LUA_TNIL) &&
  245. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  246. lua_type(state, 3) == LUA_TNUMBER &&
  247. lua_type(state, 4) == LUA_TNUMBER)
  248. {
  249. // Get parameter 1 off the stack.
  250. const char* param1 = ScriptUtil::getString(1, false);
  251. // Get parameter 2 off the stack.
  252. DepthStencilTarget::Format param2 = (DepthStencilTarget::Format)lua_enumFromString_DepthStencilTargetFormat(luaL_checkstring(state, 2));
  253. // Get parameter 3 off the stack.
  254. unsigned int param3 = (unsigned int)luaL_checkunsigned(state, 3);
  255. // Get parameter 4 off the stack.
  256. unsigned int param4 = (unsigned int)luaL_checkunsigned(state, 4);
  257. void* returnPtr = (void*)DepthStencilTarget::create(param1, param2, param3, param4);
  258. if (returnPtr)
  259. {
  260. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  261. object->instance = returnPtr;
  262. object->owns = false;
  263. luaL_getmetatable(state, "DepthStencilTarget");
  264. lua_setmetatable(state, -2);
  265. }
  266. else
  267. {
  268. lua_pushnil(state);
  269. }
  270. return 1;
  271. }
  272. else
  273. {
  274. lua_pushstring(state, "lua_DepthStencilTarget_static_create - Failed to match the given parameters to a valid function signature.");
  275. lua_error(state);
  276. }
  277. break;
  278. }
  279. default:
  280. {
  281. lua_pushstring(state, "Invalid number of parameters (expected 4).");
  282. lua_error(state);
  283. break;
  284. }
  285. }
  286. return 0;
  287. }
  288. int lua_DepthStencilTarget_static_getDepthStencilTarget(lua_State* state)
  289. {
  290. // Get the number of parameters.
  291. int paramCount = lua_gettop(state);
  292. // Attempt to match the parameters to a valid binding.
  293. switch (paramCount)
  294. {
  295. case 1:
  296. {
  297. if ((lua_type(state, 1) == LUA_TSTRING || lua_type(state, 1) == LUA_TNIL))
  298. {
  299. // Get parameter 1 off the stack.
  300. const char* param1 = ScriptUtil::getString(1, false);
  301. void* returnPtr = (void*)DepthStencilTarget::getDepthStencilTarget(param1);
  302. if (returnPtr)
  303. {
  304. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  305. object->instance = returnPtr;
  306. object->owns = false;
  307. luaL_getmetatable(state, "DepthStencilTarget");
  308. lua_setmetatable(state, -2);
  309. }
  310. else
  311. {
  312. lua_pushnil(state);
  313. }
  314. return 1;
  315. }
  316. else
  317. {
  318. lua_pushstring(state, "lua_DepthStencilTarget_static_getDepthStencilTarget - Failed to match the given parameters to a valid function signature.");
  319. lua_error(state);
  320. }
  321. break;
  322. }
  323. default:
  324. {
  325. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  326. lua_error(state);
  327. break;
  328. }
  329. }
  330. return 0;
  331. }
  332. }