lua_DepthStencilTarget.cpp 14 KB

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