lua_Properties.cpp 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052
  1. #include "Base.h"
  2. #include "ScriptController.h"
  3. #include "lua_Properties.h"
  4. #include "Base.h"
  5. #include "FileSystem.h"
  6. #include "Properties.h"
  7. #include "Quaternion.h"
  8. #include "lua_PropertiesType.h"
  9. namespace gameplay
  10. {
  11. void luaRegister_Properties()
  12. {
  13. const luaL_Reg lua_members[] =
  14. {
  15. {"exists", lua_Properties_exists},
  16. {"getBool", lua_Properties_getBool},
  17. {"getColor", lua_Properties_getColor},
  18. {"getFloat", lua_Properties_getFloat},
  19. {"getId", lua_Properties_getId},
  20. {"getInt", lua_Properties_getInt},
  21. {"getLong", lua_Properties_getLong},
  22. {"getMatrix", lua_Properties_getMatrix},
  23. {"getNamespace", lua_Properties_getNamespace},
  24. {"getNextNamespace", lua_Properties_getNextNamespace},
  25. {"getQuaternionFromAxisAngle", lua_Properties_getQuaternionFromAxisAngle},
  26. {"getString", lua_Properties_getString},
  27. {"getType", lua_Properties_getType},
  28. {"getVector2", lua_Properties_getVector2},
  29. {"getVector3", lua_Properties_getVector3},
  30. {"getVector4", lua_Properties_getVector4},
  31. {"rewind", lua_Properties_rewind},
  32. {NULL, NULL}
  33. };
  34. const luaL_Reg lua_statics[] =
  35. {
  36. {"create", lua_Properties_static_create},
  37. {NULL, NULL}
  38. };
  39. std::vector<std::string> scopePath;
  40. ScriptUtil::registerClass("Properties", lua_members, NULL, lua_Properties__gc, lua_statics, scopePath);
  41. }
  42. static Properties* getInstance(lua_State* state)
  43. {
  44. void* userdata = luaL_checkudata(state, 1, "Properties");
  45. luaL_argcheck(state, userdata != NULL, 1, "'Properties' expected.");
  46. return (Properties*)((ScriptUtil::LuaObject*)userdata)->instance;
  47. }
  48. int lua_Properties__gc(lua_State* state)
  49. {
  50. // Get the number of parameters.
  51. int paramCount = lua_gettop(state);
  52. // Attempt to match the parameters to a valid binding.
  53. switch (paramCount)
  54. {
  55. case 1:
  56. {
  57. if ((lua_type(state, 1) == LUA_TUSERDATA))
  58. {
  59. void* userdata = luaL_checkudata(state, 1, "Properties");
  60. luaL_argcheck(state, userdata != NULL, 1, "'Properties' expected.");
  61. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)userdata;
  62. if (object->owns)
  63. {
  64. Properties* instance = (Properties*)object->instance;
  65. SAFE_DELETE(instance);
  66. }
  67. return 0;
  68. }
  69. else
  70. {
  71. lua_pushstring(state, "lua_Properties__gc - Failed to match the given parameters to a valid function signature.");
  72. lua_error(state);
  73. }
  74. break;
  75. }
  76. default:
  77. {
  78. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  79. lua_error(state);
  80. break;
  81. }
  82. }
  83. return 0;
  84. }
  85. int lua_Properties_exists(lua_State* state)
  86. {
  87. // Get the number of parameters.
  88. int paramCount = lua_gettop(state);
  89. // Attempt to match the parameters to a valid binding.
  90. switch (paramCount)
  91. {
  92. case 2:
  93. {
  94. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  95. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
  96. {
  97. // Get parameter 1 off the stack.
  98. const char* param1 = ScriptUtil::getString(2, false);
  99. Properties* instance = getInstance(state);
  100. bool result = instance->exists(param1);
  101. // Push the return value onto the stack.
  102. lua_pushboolean(state, result);
  103. return 1;
  104. }
  105. else
  106. {
  107. lua_pushstring(state, "lua_Properties_exists - Failed to match the given parameters to a valid function signature.");
  108. lua_error(state);
  109. }
  110. break;
  111. }
  112. default:
  113. {
  114. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  115. lua_error(state);
  116. break;
  117. }
  118. }
  119. return 0;
  120. }
  121. int lua_Properties_getBool(lua_State* state)
  122. {
  123. // Get the number of parameters.
  124. int paramCount = lua_gettop(state);
  125. // Attempt to match the parameters to a valid binding.
  126. switch (paramCount)
  127. {
  128. case 1:
  129. {
  130. if ((lua_type(state, 1) == LUA_TUSERDATA))
  131. {
  132. Properties* instance = getInstance(state);
  133. bool result = instance->getBool();
  134. // Push the return value onto the stack.
  135. lua_pushboolean(state, result);
  136. return 1;
  137. }
  138. else
  139. {
  140. lua_pushstring(state, "lua_Properties_getBool - Failed to match the given parameters to a valid function signature.");
  141. lua_error(state);
  142. }
  143. break;
  144. }
  145. case 2:
  146. {
  147. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  148. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
  149. {
  150. // Get parameter 1 off the stack.
  151. const char* param1 = ScriptUtil::getString(2, false);
  152. Properties* instance = getInstance(state);
  153. bool result = instance->getBool(param1);
  154. // Push the return value onto the stack.
  155. lua_pushboolean(state, result);
  156. return 1;
  157. }
  158. else
  159. {
  160. lua_pushstring(state, "lua_Properties_getBool - Failed to match the given parameters to a valid function signature.");
  161. lua_error(state);
  162. }
  163. break;
  164. }
  165. default:
  166. {
  167. lua_pushstring(state, "Invalid number of parameters (expected 1 or 2).");
  168. lua_error(state);
  169. break;
  170. }
  171. }
  172. return 0;
  173. }
  174. int lua_Properties_getColor(lua_State* state)
  175. {
  176. // Get the number of parameters.
  177. int paramCount = lua_gettop(state);
  178. // Attempt to match the parameters to a valid binding.
  179. switch (paramCount)
  180. {
  181. case 3:
  182. {
  183. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  184. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  185. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TNIL))
  186. {
  187. // Get parameter 1 off the stack.
  188. const char* param1 = ScriptUtil::getString(2, false);
  189. // Get parameter 2 off the stack.
  190. Vector3* param2 = ScriptUtil::getObjectPointer<Vector3>(3, "Vector3", false);
  191. Properties* instance = getInstance(state);
  192. bool result = instance->getColor(param1, param2);
  193. // Push the return value onto the stack.
  194. lua_pushboolean(state, result);
  195. return 1;
  196. }
  197. else if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  198. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  199. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TNIL))
  200. {
  201. // Get parameter 1 off the stack.
  202. const char* param1 = ScriptUtil::getString(2, false);
  203. // Get parameter 2 off the stack.
  204. Vector4* param2 = ScriptUtil::getObjectPointer<Vector4>(3, "Vector4", false);
  205. Properties* instance = getInstance(state);
  206. bool result = instance->getColor(param1, param2);
  207. // Push the return value onto the stack.
  208. lua_pushboolean(state, result);
  209. return 1;
  210. }
  211. else
  212. {
  213. lua_pushstring(state, "lua_Properties_getColor - Failed to match the given parameters to a valid function signature.");
  214. lua_error(state);
  215. }
  216. break;
  217. }
  218. default:
  219. {
  220. lua_pushstring(state, "Invalid number of parameters (expected 3).");
  221. lua_error(state);
  222. break;
  223. }
  224. }
  225. return 0;
  226. }
  227. int lua_Properties_getFloat(lua_State* state)
  228. {
  229. // Get the number of parameters.
  230. int paramCount = lua_gettop(state);
  231. // Attempt to match the parameters to a valid binding.
  232. switch (paramCount)
  233. {
  234. case 1:
  235. {
  236. if ((lua_type(state, 1) == LUA_TUSERDATA))
  237. {
  238. Properties* instance = getInstance(state);
  239. float result = instance->getFloat();
  240. // Push the return value onto the stack.
  241. lua_pushnumber(state, result);
  242. return 1;
  243. }
  244. else
  245. {
  246. lua_pushstring(state, "lua_Properties_getFloat - Failed to match the given parameters to a valid function signature.");
  247. lua_error(state);
  248. }
  249. break;
  250. }
  251. case 2:
  252. {
  253. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  254. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
  255. {
  256. // Get parameter 1 off the stack.
  257. const char* param1 = ScriptUtil::getString(2, false);
  258. Properties* instance = getInstance(state);
  259. float result = instance->getFloat(param1);
  260. // Push the return value onto the stack.
  261. lua_pushnumber(state, result);
  262. return 1;
  263. }
  264. else
  265. {
  266. lua_pushstring(state, "lua_Properties_getFloat - Failed to match the given parameters to a valid function signature.");
  267. lua_error(state);
  268. }
  269. break;
  270. }
  271. default:
  272. {
  273. lua_pushstring(state, "Invalid number of parameters (expected 1 or 2).");
  274. lua_error(state);
  275. break;
  276. }
  277. }
  278. return 0;
  279. }
  280. int lua_Properties_getId(lua_State* state)
  281. {
  282. // Get the number of parameters.
  283. int paramCount = lua_gettop(state);
  284. // Attempt to match the parameters to a valid binding.
  285. switch (paramCount)
  286. {
  287. case 1:
  288. {
  289. if ((lua_type(state, 1) == LUA_TUSERDATA))
  290. {
  291. Properties* instance = getInstance(state);
  292. const char* result = instance->getId();
  293. // Push the return value onto the stack.
  294. lua_pushstring(state, result);
  295. return 1;
  296. }
  297. else
  298. {
  299. lua_pushstring(state, "lua_Properties_getId - Failed to match the given parameters to a valid function signature.");
  300. lua_error(state);
  301. }
  302. break;
  303. }
  304. default:
  305. {
  306. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  307. lua_error(state);
  308. break;
  309. }
  310. }
  311. return 0;
  312. }
  313. int lua_Properties_getInt(lua_State* state)
  314. {
  315. // Get the number of parameters.
  316. int paramCount = lua_gettop(state);
  317. // Attempt to match the parameters to a valid binding.
  318. switch (paramCount)
  319. {
  320. case 1:
  321. {
  322. if ((lua_type(state, 1) == LUA_TUSERDATA))
  323. {
  324. Properties* instance = getInstance(state);
  325. int result = instance->getInt();
  326. // Push the return value onto the stack.
  327. lua_pushinteger(state, result);
  328. return 1;
  329. }
  330. else
  331. {
  332. lua_pushstring(state, "lua_Properties_getInt - Failed to match the given parameters to a valid function signature.");
  333. lua_error(state);
  334. }
  335. break;
  336. }
  337. case 2:
  338. {
  339. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  340. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
  341. {
  342. // Get parameter 1 off the stack.
  343. const char* param1 = ScriptUtil::getString(2, false);
  344. Properties* instance = getInstance(state);
  345. int result = instance->getInt(param1);
  346. // Push the return value onto the stack.
  347. lua_pushinteger(state, result);
  348. return 1;
  349. }
  350. else
  351. {
  352. lua_pushstring(state, "lua_Properties_getInt - Failed to match the given parameters to a valid function signature.");
  353. lua_error(state);
  354. }
  355. break;
  356. }
  357. default:
  358. {
  359. lua_pushstring(state, "Invalid number of parameters (expected 1 or 2).");
  360. lua_error(state);
  361. break;
  362. }
  363. }
  364. return 0;
  365. }
  366. int lua_Properties_getLong(lua_State* state)
  367. {
  368. // Get the number of parameters.
  369. int paramCount = lua_gettop(state);
  370. // Attempt to match the parameters to a valid binding.
  371. switch (paramCount)
  372. {
  373. case 1:
  374. {
  375. if ((lua_type(state, 1) == LUA_TUSERDATA))
  376. {
  377. Properties* instance = getInstance(state);
  378. long result = instance->getLong();
  379. // Push the return value onto the stack.
  380. lua_pushinteger(state, result);
  381. return 1;
  382. }
  383. else
  384. {
  385. lua_pushstring(state, "lua_Properties_getLong - Failed to match the given parameters to a valid function signature.");
  386. lua_error(state);
  387. }
  388. break;
  389. }
  390. case 2:
  391. {
  392. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  393. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
  394. {
  395. // Get parameter 1 off the stack.
  396. const char* param1 = ScriptUtil::getString(2, false);
  397. Properties* instance = getInstance(state);
  398. long result = instance->getLong(param1);
  399. // Push the return value onto the stack.
  400. lua_pushinteger(state, result);
  401. return 1;
  402. }
  403. else
  404. {
  405. lua_pushstring(state, "lua_Properties_getLong - Failed to match the given parameters to a valid function signature.");
  406. lua_error(state);
  407. }
  408. break;
  409. }
  410. default:
  411. {
  412. lua_pushstring(state, "Invalid number of parameters (expected 1 or 2).");
  413. lua_error(state);
  414. break;
  415. }
  416. }
  417. return 0;
  418. }
  419. int lua_Properties_getMatrix(lua_State* state)
  420. {
  421. // Get the number of parameters.
  422. int paramCount = lua_gettop(state);
  423. // Attempt to match the parameters to a valid binding.
  424. switch (paramCount)
  425. {
  426. case 3:
  427. {
  428. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  429. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  430. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TNIL))
  431. {
  432. // Get parameter 1 off the stack.
  433. const char* param1 = ScriptUtil::getString(2, false);
  434. // Get parameter 2 off the stack.
  435. Matrix* param2 = ScriptUtil::getObjectPointer<Matrix>(3, "Matrix", false);
  436. Properties* instance = getInstance(state);
  437. bool result = instance->getMatrix(param1, param2);
  438. // Push the return value onto the stack.
  439. lua_pushboolean(state, result);
  440. return 1;
  441. }
  442. else
  443. {
  444. lua_pushstring(state, "lua_Properties_getMatrix - Failed to match the given parameters to a valid function signature.");
  445. lua_error(state);
  446. }
  447. break;
  448. }
  449. default:
  450. {
  451. lua_pushstring(state, "Invalid number of parameters (expected 3).");
  452. lua_error(state);
  453. break;
  454. }
  455. }
  456. return 0;
  457. }
  458. int lua_Properties_getNamespace(lua_State* state)
  459. {
  460. // Get the number of parameters.
  461. int paramCount = lua_gettop(state);
  462. // Attempt to match the parameters to a valid binding.
  463. switch (paramCount)
  464. {
  465. case 1:
  466. {
  467. if ((lua_type(state, 1) == LUA_TUSERDATA))
  468. {
  469. Properties* instance = getInstance(state);
  470. const char* result = instance->getNamespace();
  471. // Push the return value onto the stack.
  472. lua_pushstring(state, result);
  473. return 1;
  474. }
  475. else
  476. {
  477. lua_pushstring(state, "lua_Properties_getNamespace - Failed to match the given parameters to a valid function signature.");
  478. lua_error(state);
  479. }
  480. break;
  481. }
  482. case 2:
  483. {
  484. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  485. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
  486. {
  487. // Get parameter 1 off the stack.
  488. const char* param1 = ScriptUtil::getString(2, false);
  489. Properties* instance = getInstance(state);
  490. void* returnPtr = (void*)instance->getNamespace(param1);
  491. if (returnPtr)
  492. {
  493. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  494. object->instance = returnPtr;
  495. object->owns = false;
  496. luaL_getmetatable(state, "Properties");
  497. lua_setmetatable(state, -2);
  498. }
  499. else
  500. {
  501. lua_pushnil(state);
  502. }
  503. return 1;
  504. }
  505. else
  506. {
  507. lua_pushstring(state, "lua_Properties_getNamespace - Failed to match the given parameters to a valid function signature.");
  508. lua_error(state);
  509. }
  510. break;
  511. }
  512. case 3:
  513. {
  514. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  515. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  516. lua_type(state, 3) == LUA_TBOOLEAN)
  517. {
  518. // Get parameter 1 off the stack.
  519. const char* param1 = ScriptUtil::getString(2, false);
  520. // Get parameter 2 off the stack.
  521. bool param2 = ScriptUtil::luaCheckBool(state, 3);
  522. Properties* instance = getInstance(state);
  523. void* returnPtr = (void*)instance->getNamespace(param1, param2);
  524. if (returnPtr)
  525. {
  526. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  527. object->instance = returnPtr;
  528. object->owns = false;
  529. luaL_getmetatable(state, "Properties");
  530. lua_setmetatable(state, -2);
  531. }
  532. else
  533. {
  534. lua_pushnil(state);
  535. }
  536. return 1;
  537. }
  538. else
  539. {
  540. lua_pushstring(state, "lua_Properties_getNamespace - Failed to match the given parameters to a valid function signature.");
  541. lua_error(state);
  542. }
  543. break;
  544. }
  545. default:
  546. {
  547. lua_pushstring(state, "Invalid number of parameters (expected 1, 2 or 3).");
  548. lua_error(state);
  549. break;
  550. }
  551. }
  552. return 0;
  553. }
  554. int lua_Properties_getNextNamespace(lua_State* state)
  555. {
  556. // Get the number of parameters.
  557. int paramCount = lua_gettop(state);
  558. // Attempt to match the parameters to a valid binding.
  559. switch (paramCount)
  560. {
  561. case 1:
  562. {
  563. if ((lua_type(state, 1) == LUA_TUSERDATA))
  564. {
  565. Properties* instance = getInstance(state);
  566. void* returnPtr = (void*)instance->getNextNamespace();
  567. if (returnPtr)
  568. {
  569. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  570. object->instance = returnPtr;
  571. object->owns = false;
  572. luaL_getmetatable(state, "Properties");
  573. lua_setmetatable(state, -2);
  574. }
  575. else
  576. {
  577. lua_pushnil(state);
  578. }
  579. return 1;
  580. }
  581. else
  582. {
  583. lua_pushstring(state, "lua_Properties_getNextNamespace - Failed to match the given parameters to a valid function signature.");
  584. lua_error(state);
  585. }
  586. break;
  587. }
  588. default:
  589. {
  590. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  591. lua_error(state);
  592. break;
  593. }
  594. }
  595. return 0;
  596. }
  597. int lua_Properties_getQuaternionFromAxisAngle(lua_State* state)
  598. {
  599. // Get the number of parameters.
  600. int paramCount = lua_gettop(state);
  601. // Attempt to match the parameters to a valid binding.
  602. switch (paramCount)
  603. {
  604. case 3:
  605. {
  606. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  607. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  608. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TNIL))
  609. {
  610. // Get parameter 1 off the stack.
  611. const char* param1 = ScriptUtil::getString(2, false);
  612. // Get parameter 2 off the stack.
  613. Quaternion* param2 = ScriptUtil::getObjectPointer<Quaternion>(3, "Quaternion", false);
  614. Properties* instance = getInstance(state);
  615. bool result = instance->getQuaternionFromAxisAngle(param1, param2);
  616. // Push the return value onto the stack.
  617. lua_pushboolean(state, result);
  618. return 1;
  619. }
  620. else
  621. {
  622. lua_pushstring(state, "lua_Properties_getQuaternionFromAxisAngle - Failed to match the given parameters to a valid function signature.");
  623. lua_error(state);
  624. }
  625. break;
  626. }
  627. default:
  628. {
  629. lua_pushstring(state, "Invalid number of parameters (expected 3).");
  630. lua_error(state);
  631. break;
  632. }
  633. }
  634. return 0;
  635. }
  636. int lua_Properties_getString(lua_State* state)
  637. {
  638. // Get the number of parameters.
  639. int paramCount = lua_gettop(state);
  640. // Attempt to match the parameters to a valid binding.
  641. switch (paramCount)
  642. {
  643. case 1:
  644. {
  645. if ((lua_type(state, 1) == LUA_TUSERDATA))
  646. {
  647. Properties* instance = getInstance(state);
  648. const char* result = instance->getString();
  649. // Push the return value onto the stack.
  650. lua_pushstring(state, result);
  651. return 1;
  652. }
  653. else
  654. {
  655. lua_pushstring(state, "lua_Properties_getString - Failed to match the given parameters to a valid function signature.");
  656. lua_error(state);
  657. }
  658. break;
  659. }
  660. case 2:
  661. {
  662. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  663. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
  664. {
  665. // Get parameter 1 off the stack.
  666. const char* param1 = ScriptUtil::getString(2, false);
  667. Properties* instance = getInstance(state);
  668. const char* result = instance->getString(param1);
  669. // Push the return value onto the stack.
  670. lua_pushstring(state, result);
  671. return 1;
  672. }
  673. else
  674. {
  675. lua_pushstring(state, "lua_Properties_getString - Failed to match the given parameters to a valid function signature.");
  676. lua_error(state);
  677. }
  678. break;
  679. }
  680. default:
  681. {
  682. lua_pushstring(state, "Invalid number of parameters (expected 1 or 2).");
  683. lua_error(state);
  684. break;
  685. }
  686. }
  687. return 0;
  688. }
  689. int lua_Properties_getType(lua_State* state)
  690. {
  691. // Get the number of parameters.
  692. int paramCount = lua_gettop(state);
  693. // Attempt to match the parameters to a valid binding.
  694. switch (paramCount)
  695. {
  696. case 1:
  697. {
  698. if ((lua_type(state, 1) == LUA_TUSERDATA))
  699. {
  700. Properties* instance = getInstance(state);
  701. Properties::Type result = instance->getType();
  702. // Push the return value onto the stack.
  703. lua_pushstring(state, lua_stringFromEnum_PropertiesType(result));
  704. return 1;
  705. }
  706. else
  707. {
  708. lua_pushstring(state, "lua_Properties_getType - Failed to match the given parameters to a valid function signature.");
  709. lua_error(state);
  710. }
  711. break;
  712. }
  713. case 2:
  714. {
  715. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  716. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
  717. {
  718. // Get parameter 1 off the stack.
  719. const char* param1 = ScriptUtil::getString(2, false);
  720. Properties* instance = getInstance(state);
  721. Properties::Type result = instance->getType(param1);
  722. // Push the return value onto the stack.
  723. lua_pushstring(state, lua_stringFromEnum_PropertiesType(result));
  724. return 1;
  725. }
  726. else
  727. {
  728. lua_pushstring(state, "lua_Properties_getType - Failed to match the given parameters to a valid function signature.");
  729. lua_error(state);
  730. }
  731. break;
  732. }
  733. default:
  734. {
  735. lua_pushstring(state, "Invalid number of parameters (expected 1 or 2).");
  736. lua_error(state);
  737. break;
  738. }
  739. }
  740. return 0;
  741. }
  742. int lua_Properties_getVector2(lua_State* state)
  743. {
  744. // Get the number of parameters.
  745. int paramCount = lua_gettop(state);
  746. // Attempt to match the parameters to a valid binding.
  747. switch (paramCount)
  748. {
  749. case 3:
  750. {
  751. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  752. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  753. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TNIL))
  754. {
  755. // Get parameter 1 off the stack.
  756. const char* param1 = ScriptUtil::getString(2, false);
  757. // Get parameter 2 off the stack.
  758. Vector2* param2 = ScriptUtil::getObjectPointer<Vector2>(3, "Vector2", false);
  759. Properties* instance = getInstance(state);
  760. bool result = instance->getVector2(param1, param2);
  761. // Push the return value onto the stack.
  762. lua_pushboolean(state, result);
  763. return 1;
  764. }
  765. else
  766. {
  767. lua_pushstring(state, "lua_Properties_getVector2 - Failed to match the given parameters to a valid function signature.");
  768. lua_error(state);
  769. }
  770. break;
  771. }
  772. default:
  773. {
  774. lua_pushstring(state, "Invalid number of parameters (expected 3).");
  775. lua_error(state);
  776. break;
  777. }
  778. }
  779. return 0;
  780. }
  781. int lua_Properties_getVector3(lua_State* state)
  782. {
  783. // Get the number of parameters.
  784. int paramCount = lua_gettop(state);
  785. // Attempt to match the parameters to a valid binding.
  786. switch (paramCount)
  787. {
  788. case 3:
  789. {
  790. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  791. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  792. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TNIL))
  793. {
  794. // Get parameter 1 off the stack.
  795. const char* param1 = ScriptUtil::getString(2, false);
  796. // Get parameter 2 off the stack.
  797. Vector3* param2 = ScriptUtil::getObjectPointer<Vector3>(3, "Vector3", false);
  798. Properties* instance = getInstance(state);
  799. bool result = instance->getVector3(param1, param2);
  800. // Push the return value onto the stack.
  801. lua_pushboolean(state, result);
  802. return 1;
  803. }
  804. else
  805. {
  806. lua_pushstring(state, "lua_Properties_getVector3 - Failed to match the given parameters to a valid function signature.");
  807. lua_error(state);
  808. }
  809. break;
  810. }
  811. default:
  812. {
  813. lua_pushstring(state, "Invalid number of parameters (expected 3).");
  814. lua_error(state);
  815. break;
  816. }
  817. }
  818. return 0;
  819. }
  820. int lua_Properties_getVector4(lua_State* state)
  821. {
  822. // Get the number of parameters.
  823. int paramCount = lua_gettop(state);
  824. // Attempt to match the parameters to a valid binding.
  825. switch (paramCount)
  826. {
  827. case 3:
  828. {
  829. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  830. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  831. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TNIL))
  832. {
  833. // Get parameter 1 off the stack.
  834. const char* param1 = ScriptUtil::getString(2, false);
  835. // Get parameter 2 off the stack.
  836. Vector4* param2 = ScriptUtil::getObjectPointer<Vector4>(3, "Vector4", false);
  837. Properties* instance = getInstance(state);
  838. bool result = instance->getVector4(param1, param2);
  839. // Push the return value onto the stack.
  840. lua_pushboolean(state, result);
  841. return 1;
  842. }
  843. else
  844. {
  845. lua_pushstring(state, "lua_Properties_getVector4 - Failed to match the given parameters to a valid function signature.");
  846. lua_error(state);
  847. }
  848. break;
  849. }
  850. default:
  851. {
  852. lua_pushstring(state, "Invalid number of parameters (expected 3).");
  853. lua_error(state);
  854. break;
  855. }
  856. }
  857. return 0;
  858. }
  859. int lua_Properties_rewind(lua_State* state)
  860. {
  861. // Get the number of parameters.
  862. int paramCount = lua_gettop(state);
  863. // Attempt to match the parameters to a valid binding.
  864. switch (paramCount)
  865. {
  866. case 1:
  867. {
  868. if ((lua_type(state, 1) == LUA_TUSERDATA))
  869. {
  870. Properties* instance = getInstance(state);
  871. instance->rewind();
  872. return 0;
  873. }
  874. else
  875. {
  876. lua_pushstring(state, "lua_Properties_rewind - Failed to match the given parameters to a valid function signature.");
  877. lua_error(state);
  878. }
  879. break;
  880. }
  881. default:
  882. {
  883. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  884. lua_error(state);
  885. break;
  886. }
  887. }
  888. return 0;
  889. }
  890. int lua_Properties_static_create(lua_State* state)
  891. {
  892. // Get the number of parameters.
  893. int paramCount = lua_gettop(state);
  894. // Attempt to match the parameters to a valid binding.
  895. switch (paramCount)
  896. {
  897. case 1:
  898. {
  899. if ((lua_type(state, 1) == LUA_TSTRING || lua_type(state, 1) == LUA_TNIL))
  900. {
  901. // Get parameter 1 off the stack.
  902. const char* param1 = ScriptUtil::getString(1, false);
  903. void* returnPtr = (void*)Properties::create(param1);
  904. if (returnPtr)
  905. {
  906. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  907. object->instance = returnPtr;
  908. object->owns = true;
  909. luaL_getmetatable(state, "Properties");
  910. lua_setmetatable(state, -2);
  911. }
  912. else
  913. {
  914. lua_pushnil(state);
  915. }
  916. return 1;
  917. }
  918. else
  919. {
  920. lua_pushstring(state, "lua_Properties_static_create - Failed to match the given parameters to a valid function signature.");
  921. lua_error(state);
  922. }
  923. break;
  924. }
  925. default:
  926. {
  927. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  928. lua_error(state);
  929. break;
  930. }
  931. }
  932. return 0;
  933. }
  934. }