lua_DepthStencilTarget.cpp 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  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. {"getHeight", lua_DepthStencilTarget_getHeight},
  18. {"getId", lua_DepthStencilTarget_getId},
  19. {"getRefCount", lua_DepthStencilTarget_getRefCount},
  20. {"getWidth", lua_DepthStencilTarget_getWidth},
  21. {"release", lua_DepthStencilTarget_release},
  22. {NULL, NULL}
  23. };
  24. const luaL_Reg lua_statics[] =
  25. {
  26. {"create", lua_DepthStencilTarget_static_create},
  27. {"getDepthStencilTarget", lua_DepthStencilTarget_static_getDepthStencilTarget},
  28. {NULL, NULL}
  29. };
  30. std::vector<std::string> scopePath;
  31. gameplay::ScriptUtil::registerClass("DepthStencilTarget", lua_members, NULL, lua_DepthStencilTarget__gc, lua_statics, scopePath);
  32. }
  33. static DepthStencilTarget* getInstance(lua_State* state)
  34. {
  35. void* userdata = luaL_checkudata(state, 1, "DepthStencilTarget");
  36. luaL_argcheck(state, userdata != NULL, 1, "'DepthStencilTarget' expected.");
  37. return (DepthStencilTarget*)((gameplay::ScriptUtil::LuaObject*)userdata)->instance;
  38. }
  39. int lua_DepthStencilTarget__gc(lua_State* state)
  40. {
  41. // Get the number of parameters.
  42. int paramCount = lua_gettop(state);
  43. // Attempt to match the parameters to a valid binding.
  44. switch (paramCount)
  45. {
  46. case 1:
  47. {
  48. if ((lua_type(state, 1) == LUA_TUSERDATA))
  49. {
  50. void* userdata = luaL_checkudata(state, 1, "DepthStencilTarget");
  51. luaL_argcheck(state, userdata != NULL, 1, "'DepthStencilTarget' expected.");
  52. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)userdata;
  53. if (object->owns)
  54. {
  55. DepthStencilTarget* instance = (DepthStencilTarget*)object->instance;
  56. SAFE_RELEASE(instance);
  57. }
  58. return 0;
  59. }
  60. lua_pushstring(state, "lua_DepthStencilTarget__gc - Failed to match the given parameters to a valid function signature.");
  61. lua_error(state);
  62. break;
  63. }
  64. default:
  65. {
  66. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  67. lua_error(state);
  68. break;
  69. }
  70. }
  71. return 0;
  72. }
  73. int lua_DepthStencilTarget_addRef(lua_State* state)
  74. {
  75. // Get the number of parameters.
  76. int paramCount = lua_gettop(state);
  77. // Attempt to match the parameters to a valid binding.
  78. switch (paramCount)
  79. {
  80. case 1:
  81. {
  82. if ((lua_type(state, 1) == LUA_TUSERDATA))
  83. {
  84. DepthStencilTarget* instance = getInstance(state);
  85. instance->addRef();
  86. return 0;
  87. }
  88. lua_pushstring(state, "lua_DepthStencilTarget_addRef - Failed to match the given parameters to a valid function signature.");
  89. lua_error(state);
  90. break;
  91. }
  92. default:
  93. {
  94. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  95. lua_error(state);
  96. break;
  97. }
  98. }
  99. return 0;
  100. }
  101. int lua_DepthStencilTarget_getFormat(lua_State* state)
  102. {
  103. // Get the number of parameters.
  104. int paramCount = lua_gettop(state);
  105. // Attempt to match the parameters to a valid binding.
  106. switch (paramCount)
  107. {
  108. case 1:
  109. {
  110. if ((lua_type(state, 1) == LUA_TUSERDATA))
  111. {
  112. DepthStencilTarget* instance = getInstance(state);
  113. DepthStencilTarget::Format result = instance->getFormat();
  114. // Push the return value onto the stack.
  115. lua_pushstring(state, lua_stringFromEnum_DepthStencilTargetFormat(result));
  116. return 1;
  117. }
  118. lua_pushstring(state, "lua_DepthStencilTarget_getFormat - Failed to match the given parameters to a valid function signature.");
  119. lua_error(state);
  120. break;
  121. }
  122. default:
  123. {
  124. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  125. lua_error(state);
  126. break;
  127. }
  128. }
  129. return 0;
  130. }
  131. int lua_DepthStencilTarget_getHeight(lua_State* state)
  132. {
  133. // Get the number of parameters.
  134. int paramCount = lua_gettop(state);
  135. // Attempt to match the parameters to a valid binding.
  136. switch (paramCount)
  137. {
  138. case 1:
  139. {
  140. if ((lua_type(state, 1) == LUA_TUSERDATA))
  141. {
  142. DepthStencilTarget* instance = getInstance(state);
  143. unsigned int result = instance->getHeight();
  144. // Push the return value onto the stack.
  145. lua_pushunsigned(state, result);
  146. return 1;
  147. }
  148. lua_pushstring(state, "lua_DepthStencilTarget_getHeight - Failed to match the given parameters to a valid function signature.");
  149. lua_error(state);
  150. break;
  151. }
  152. default:
  153. {
  154. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  155. lua_error(state);
  156. break;
  157. }
  158. }
  159. return 0;
  160. }
  161. int lua_DepthStencilTarget_getId(lua_State* state)
  162. {
  163. // Get the number of parameters.
  164. int paramCount = lua_gettop(state);
  165. // Attempt to match the parameters to a valid binding.
  166. switch (paramCount)
  167. {
  168. case 1:
  169. {
  170. if ((lua_type(state, 1) == LUA_TUSERDATA))
  171. {
  172. DepthStencilTarget* instance = getInstance(state);
  173. const char* result = instance->getId();
  174. // Push the return value onto the stack.
  175. lua_pushstring(state, result);
  176. return 1;
  177. }
  178. lua_pushstring(state, "lua_DepthStencilTarget_getId - Failed to match the given parameters to a valid function signature.");
  179. lua_error(state);
  180. break;
  181. }
  182. default:
  183. {
  184. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  185. lua_error(state);
  186. break;
  187. }
  188. }
  189. return 0;
  190. }
  191. int lua_DepthStencilTarget_getRefCount(lua_State* state)
  192. {
  193. // Get the number of parameters.
  194. int paramCount = lua_gettop(state);
  195. // Attempt to match the parameters to a valid binding.
  196. switch (paramCount)
  197. {
  198. case 1:
  199. {
  200. if ((lua_type(state, 1) == LUA_TUSERDATA))
  201. {
  202. DepthStencilTarget* instance = getInstance(state);
  203. unsigned int result = instance->getRefCount();
  204. // Push the return value onto the stack.
  205. lua_pushunsigned(state, result);
  206. return 1;
  207. }
  208. lua_pushstring(state, "lua_DepthStencilTarget_getRefCount - Failed to match the given parameters to a valid function signature.");
  209. lua_error(state);
  210. break;
  211. }
  212. default:
  213. {
  214. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  215. lua_error(state);
  216. break;
  217. }
  218. }
  219. return 0;
  220. }
  221. int lua_DepthStencilTarget_getWidth(lua_State* state)
  222. {
  223. // Get the number of parameters.
  224. int paramCount = lua_gettop(state);
  225. // Attempt to match the parameters to a valid binding.
  226. switch (paramCount)
  227. {
  228. case 1:
  229. {
  230. if ((lua_type(state, 1) == LUA_TUSERDATA))
  231. {
  232. DepthStencilTarget* instance = getInstance(state);
  233. unsigned int result = instance->getWidth();
  234. // Push the return value onto the stack.
  235. lua_pushunsigned(state, result);
  236. return 1;
  237. }
  238. lua_pushstring(state, "lua_DepthStencilTarget_getWidth - Failed to match the given parameters to a valid function signature.");
  239. lua_error(state);
  240. break;
  241. }
  242. default:
  243. {
  244. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  245. lua_error(state);
  246. break;
  247. }
  248. }
  249. return 0;
  250. }
  251. int lua_DepthStencilTarget_release(lua_State* state)
  252. {
  253. // Get the number of parameters.
  254. int paramCount = lua_gettop(state);
  255. // Attempt to match the parameters to a valid binding.
  256. switch (paramCount)
  257. {
  258. case 1:
  259. {
  260. if ((lua_type(state, 1) == LUA_TUSERDATA))
  261. {
  262. DepthStencilTarget* instance = getInstance(state);
  263. instance->release();
  264. return 0;
  265. }
  266. lua_pushstring(state, "lua_DepthStencilTarget_release - 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 1).");
  273. lua_error(state);
  274. break;
  275. }
  276. }
  277. return 0;
  278. }
  279. int lua_DepthStencilTarget_static_create(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 4:
  287. {
  288. if ((lua_type(state, 1) == LUA_TSTRING || lua_type(state, 1) == LUA_TNIL) &&
  289. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  290. lua_type(state, 3) == LUA_TNUMBER &&
  291. lua_type(state, 4) == LUA_TNUMBER)
  292. {
  293. // Get parameter 1 off the stack.
  294. const char* param1 = gameplay::ScriptUtil::getString(1, false);
  295. // Get parameter 2 off the stack.
  296. DepthStencilTarget::Format param2 = (DepthStencilTarget::Format)lua_enumFromString_DepthStencilTargetFormat(luaL_checkstring(state, 2));
  297. // Get parameter 3 off the stack.
  298. unsigned int param3 = (unsigned int)luaL_checkunsigned(state, 3);
  299. // Get parameter 4 off the stack.
  300. unsigned int param4 = (unsigned int)luaL_checkunsigned(state, 4);
  301. void* returnPtr = (void*)DepthStencilTarget::create(param1, param2, param3, param4);
  302. if (returnPtr)
  303. {
  304. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  305. object->instance = returnPtr;
  306. object->owns = true;
  307. luaL_getmetatable(state, "DepthStencilTarget");
  308. lua_setmetatable(state, -2);
  309. }
  310. else
  311. {
  312. lua_pushnil(state);
  313. }
  314. return 1;
  315. }
  316. lua_pushstring(state, "lua_DepthStencilTarget_static_create - Failed to match the given parameters to a valid function signature.");
  317. lua_error(state);
  318. break;
  319. }
  320. default:
  321. {
  322. lua_pushstring(state, "Invalid number of parameters (expected 4).");
  323. lua_error(state);
  324. break;
  325. }
  326. }
  327. return 0;
  328. }
  329. int lua_DepthStencilTarget_static_getDepthStencilTarget(lua_State* state)
  330. {
  331. // Get the number of parameters.
  332. int paramCount = lua_gettop(state);
  333. // Attempt to match the parameters to a valid binding.
  334. switch (paramCount)
  335. {
  336. case 1:
  337. {
  338. if ((lua_type(state, 1) == LUA_TSTRING || lua_type(state, 1) == LUA_TNIL))
  339. {
  340. // Get parameter 1 off the stack.
  341. const char* param1 = gameplay::ScriptUtil::getString(1, false);
  342. void* returnPtr = (void*)DepthStencilTarget::getDepthStencilTarget(param1);
  343. if (returnPtr)
  344. {
  345. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  346. object->instance = returnPtr;
  347. object->owns = false;
  348. luaL_getmetatable(state, "DepthStencilTarget");
  349. lua_setmetatable(state, -2);
  350. }
  351. else
  352. {
  353. lua_pushnil(state);
  354. }
  355. return 1;
  356. }
  357. lua_pushstring(state, "lua_DepthStencilTarget_static_getDepthStencilTarget - Failed to match the given parameters to a valid function signature.");
  358. lua_error(state);
  359. break;
  360. }
  361. default:
  362. {
  363. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  364. lua_error(state);
  365. break;
  366. }
  367. }
  368. return 0;
  369. }
  370. }