lua_AudioSource.cpp 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844
  1. #include "Base.h"
  2. #include "ScriptController.h"
  3. #include "lua_AudioSource.h"
  4. #include "Animation.h"
  5. #include "AnimationTarget.h"
  6. #include "AudioBuffer.h"
  7. #include "AudioController.h"
  8. #include "AudioSource.h"
  9. #include "Base.h"
  10. #include "Game.h"
  11. #include "Node.h"
  12. #include "Ref.h"
  13. #include "ScriptController.h"
  14. #include "ScriptTarget.h"
  15. #include "Transform.h"
  16. #include "lua_AudioSourceState.h"
  17. #include "lua_CurveInterpolationType.h"
  18. namespace gameplay
  19. {
  20. void luaRegister_AudioSource()
  21. {
  22. const luaL_Reg lua_members[] =
  23. {
  24. {"addRef", lua_AudioSource_addRef},
  25. {"getGain", lua_AudioSource_getGain},
  26. {"getNode", lua_AudioSource_getNode},
  27. {"getPitch", lua_AudioSource_getPitch},
  28. {"getRefCount", lua_AudioSource_getRefCount},
  29. {"getState", lua_AudioSource_getState},
  30. {"getVelocity", lua_AudioSource_getVelocity},
  31. {"isLooped", lua_AudioSource_isLooped},
  32. {"pause", lua_AudioSource_pause},
  33. {"play", lua_AudioSource_play},
  34. {"release", lua_AudioSource_release},
  35. {"resume", lua_AudioSource_resume},
  36. {"rewind", lua_AudioSource_rewind},
  37. {"setGain", lua_AudioSource_setGain},
  38. {"setLooped", lua_AudioSource_setLooped},
  39. {"setPitch", lua_AudioSource_setPitch},
  40. {"setVelocity", lua_AudioSource_setVelocity},
  41. {"stop", lua_AudioSource_stop},
  42. {NULL, NULL}
  43. };
  44. const luaL_Reg lua_statics[] =
  45. {
  46. {"create", lua_AudioSource_static_create},
  47. {NULL, NULL}
  48. };
  49. std::vector<std::string> scopePath;
  50. ScriptUtil::registerClass("AudioSource", lua_members, NULL, lua_AudioSource__gc, lua_statics, scopePath);
  51. }
  52. static AudioSource* getInstance(lua_State* state)
  53. {
  54. void* userdata = luaL_checkudata(state, 1, "AudioSource");
  55. luaL_argcheck(state, userdata != NULL, 1, "'AudioSource' expected.");
  56. return (AudioSource*)((ScriptUtil::LuaObject*)userdata)->instance;
  57. }
  58. int lua_AudioSource__gc(lua_State* state)
  59. {
  60. // Get the number of parameters.
  61. int paramCount = lua_gettop(state);
  62. // Attempt to match the parameters to a valid binding.
  63. switch (paramCount)
  64. {
  65. case 1:
  66. {
  67. if ((lua_type(state, 1) == LUA_TUSERDATA))
  68. {
  69. void* userdata = luaL_checkudata(state, 1, "AudioSource");
  70. luaL_argcheck(state, userdata != NULL, 1, "'AudioSource' expected.");
  71. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)userdata;
  72. if (object->owns)
  73. {
  74. AudioSource* instance = (AudioSource*)object->instance;
  75. SAFE_RELEASE(instance);
  76. }
  77. return 0;
  78. }
  79. lua_pushstring(state, "lua_AudioSource__gc - Failed to match the given parameters to a valid function signature.");
  80. lua_error(state);
  81. break;
  82. }
  83. default:
  84. {
  85. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  86. lua_error(state);
  87. break;
  88. }
  89. }
  90. return 0;
  91. }
  92. int lua_AudioSource_addRef(lua_State* state)
  93. {
  94. // Get the number of parameters.
  95. int paramCount = lua_gettop(state);
  96. // Attempt to match the parameters to a valid binding.
  97. switch (paramCount)
  98. {
  99. case 1:
  100. {
  101. if ((lua_type(state, 1) == LUA_TUSERDATA))
  102. {
  103. AudioSource* instance = getInstance(state);
  104. instance->addRef();
  105. return 0;
  106. }
  107. lua_pushstring(state, "lua_AudioSource_addRef - Failed to match the given parameters to a valid function signature.");
  108. lua_error(state);
  109. break;
  110. }
  111. default:
  112. {
  113. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  114. lua_error(state);
  115. break;
  116. }
  117. }
  118. return 0;
  119. }
  120. int lua_AudioSource_getGain(lua_State* state)
  121. {
  122. // Get the number of parameters.
  123. int paramCount = lua_gettop(state);
  124. // Attempt to match the parameters to a valid binding.
  125. switch (paramCount)
  126. {
  127. case 1:
  128. {
  129. if ((lua_type(state, 1) == LUA_TUSERDATA))
  130. {
  131. AudioSource* instance = getInstance(state);
  132. float result = instance->getGain();
  133. // Push the return value onto the stack.
  134. lua_pushnumber(state, result);
  135. return 1;
  136. }
  137. lua_pushstring(state, "lua_AudioSource_getGain - Failed to match the given parameters to a valid function signature.");
  138. lua_error(state);
  139. break;
  140. }
  141. default:
  142. {
  143. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  144. lua_error(state);
  145. break;
  146. }
  147. }
  148. return 0;
  149. }
  150. int lua_AudioSource_getNode(lua_State* state)
  151. {
  152. // Get the number of parameters.
  153. int paramCount = lua_gettop(state);
  154. // Attempt to match the parameters to a valid binding.
  155. switch (paramCount)
  156. {
  157. case 1:
  158. {
  159. if ((lua_type(state, 1) == LUA_TUSERDATA))
  160. {
  161. AudioSource* instance = getInstance(state);
  162. void* returnPtr = (void*)instance->getNode();
  163. if (returnPtr)
  164. {
  165. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  166. object->instance = returnPtr;
  167. object->owns = false;
  168. luaL_getmetatable(state, "Node");
  169. lua_setmetatable(state, -2);
  170. }
  171. else
  172. {
  173. lua_pushnil(state);
  174. }
  175. return 1;
  176. }
  177. lua_pushstring(state, "lua_AudioSource_getNode - Failed to match the given parameters to a valid function signature.");
  178. lua_error(state);
  179. break;
  180. }
  181. default:
  182. {
  183. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  184. lua_error(state);
  185. break;
  186. }
  187. }
  188. return 0;
  189. }
  190. int lua_AudioSource_getPitch(lua_State* state)
  191. {
  192. // Get the number of parameters.
  193. int paramCount = lua_gettop(state);
  194. // Attempt to match the parameters to a valid binding.
  195. switch (paramCount)
  196. {
  197. case 1:
  198. {
  199. if ((lua_type(state, 1) == LUA_TUSERDATA))
  200. {
  201. AudioSource* instance = getInstance(state);
  202. float result = instance->getPitch();
  203. // Push the return value onto the stack.
  204. lua_pushnumber(state, result);
  205. return 1;
  206. }
  207. lua_pushstring(state, "lua_AudioSource_getPitch - Failed to match the given parameters to a valid function signature.");
  208. lua_error(state);
  209. break;
  210. }
  211. default:
  212. {
  213. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  214. lua_error(state);
  215. break;
  216. }
  217. }
  218. return 0;
  219. }
  220. int lua_AudioSource_getRefCount(lua_State* state)
  221. {
  222. // Get the number of parameters.
  223. int paramCount = lua_gettop(state);
  224. // Attempt to match the parameters to a valid binding.
  225. switch (paramCount)
  226. {
  227. case 1:
  228. {
  229. if ((lua_type(state, 1) == LUA_TUSERDATA))
  230. {
  231. AudioSource* instance = getInstance(state);
  232. unsigned int result = instance->getRefCount();
  233. // Push the return value onto the stack.
  234. lua_pushunsigned(state, result);
  235. return 1;
  236. }
  237. lua_pushstring(state, "lua_AudioSource_getRefCount - Failed to match the given parameters to a valid function signature.");
  238. lua_error(state);
  239. break;
  240. }
  241. default:
  242. {
  243. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  244. lua_error(state);
  245. break;
  246. }
  247. }
  248. return 0;
  249. }
  250. int lua_AudioSource_getState(lua_State* state)
  251. {
  252. // Get the number of parameters.
  253. int paramCount = lua_gettop(state);
  254. // Attempt to match the parameters to a valid binding.
  255. switch (paramCount)
  256. {
  257. case 1:
  258. {
  259. if ((lua_type(state, 1) == LUA_TUSERDATA))
  260. {
  261. AudioSource* instance = getInstance(state);
  262. AudioSource::State result = instance->getState();
  263. // Push the return value onto the stack.
  264. lua_pushstring(state, lua_stringFromEnum_AudioSourceState(result));
  265. return 1;
  266. }
  267. lua_pushstring(state, "lua_AudioSource_getState - Failed to match the given parameters to a valid function signature.");
  268. lua_error(state);
  269. break;
  270. }
  271. default:
  272. {
  273. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  274. lua_error(state);
  275. break;
  276. }
  277. }
  278. return 0;
  279. }
  280. int lua_AudioSource_getVelocity(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. AudioSource* instance = getInstance(state);
  292. void* returnPtr = (void*)&(instance->getVelocity());
  293. if (returnPtr)
  294. {
  295. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  296. object->instance = returnPtr;
  297. object->owns = false;
  298. luaL_getmetatable(state, "Vector3");
  299. lua_setmetatable(state, -2);
  300. }
  301. else
  302. {
  303. lua_pushnil(state);
  304. }
  305. return 1;
  306. }
  307. lua_pushstring(state, "lua_AudioSource_getVelocity - Failed to match the given parameters to a valid function signature.");
  308. lua_error(state);
  309. break;
  310. }
  311. default:
  312. {
  313. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  314. lua_error(state);
  315. break;
  316. }
  317. }
  318. return 0;
  319. }
  320. int lua_AudioSource_isLooped(lua_State* state)
  321. {
  322. // Get the number of parameters.
  323. int paramCount = lua_gettop(state);
  324. // Attempt to match the parameters to a valid binding.
  325. switch (paramCount)
  326. {
  327. case 1:
  328. {
  329. if ((lua_type(state, 1) == LUA_TUSERDATA))
  330. {
  331. AudioSource* instance = getInstance(state);
  332. bool result = instance->isLooped();
  333. // Push the return value onto the stack.
  334. lua_pushboolean(state, result);
  335. return 1;
  336. }
  337. lua_pushstring(state, "lua_AudioSource_isLooped - Failed to match the given parameters to a valid function signature.");
  338. lua_error(state);
  339. break;
  340. }
  341. default:
  342. {
  343. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  344. lua_error(state);
  345. break;
  346. }
  347. }
  348. return 0;
  349. }
  350. int lua_AudioSource_pause(lua_State* state)
  351. {
  352. // Get the number of parameters.
  353. int paramCount = lua_gettop(state);
  354. // Attempt to match the parameters to a valid binding.
  355. switch (paramCount)
  356. {
  357. case 1:
  358. {
  359. if ((lua_type(state, 1) == LUA_TUSERDATA))
  360. {
  361. AudioSource* instance = getInstance(state);
  362. instance->pause();
  363. return 0;
  364. }
  365. lua_pushstring(state, "lua_AudioSource_pause - Failed to match the given parameters to a valid function signature.");
  366. lua_error(state);
  367. break;
  368. }
  369. default:
  370. {
  371. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  372. lua_error(state);
  373. break;
  374. }
  375. }
  376. return 0;
  377. }
  378. int lua_AudioSource_play(lua_State* state)
  379. {
  380. // Get the number of parameters.
  381. int paramCount = lua_gettop(state);
  382. // Attempt to match the parameters to a valid binding.
  383. switch (paramCount)
  384. {
  385. case 1:
  386. {
  387. if ((lua_type(state, 1) == LUA_TUSERDATA))
  388. {
  389. AudioSource* instance = getInstance(state);
  390. instance->play();
  391. return 0;
  392. }
  393. lua_pushstring(state, "lua_AudioSource_play - Failed to match the given parameters to a valid function signature.");
  394. lua_error(state);
  395. break;
  396. }
  397. default:
  398. {
  399. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  400. lua_error(state);
  401. break;
  402. }
  403. }
  404. return 0;
  405. }
  406. int lua_AudioSource_release(lua_State* state)
  407. {
  408. // Get the number of parameters.
  409. int paramCount = lua_gettop(state);
  410. // Attempt to match the parameters to a valid binding.
  411. switch (paramCount)
  412. {
  413. case 1:
  414. {
  415. if ((lua_type(state, 1) == LUA_TUSERDATA))
  416. {
  417. AudioSource* instance = getInstance(state);
  418. instance->release();
  419. return 0;
  420. }
  421. lua_pushstring(state, "lua_AudioSource_release - Failed to match the given parameters to a valid function signature.");
  422. lua_error(state);
  423. break;
  424. }
  425. default:
  426. {
  427. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  428. lua_error(state);
  429. break;
  430. }
  431. }
  432. return 0;
  433. }
  434. int lua_AudioSource_resume(lua_State* state)
  435. {
  436. // Get the number of parameters.
  437. int paramCount = lua_gettop(state);
  438. // Attempt to match the parameters to a valid binding.
  439. switch (paramCount)
  440. {
  441. case 1:
  442. {
  443. if ((lua_type(state, 1) == LUA_TUSERDATA))
  444. {
  445. AudioSource* instance = getInstance(state);
  446. instance->resume();
  447. return 0;
  448. }
  449. lua_pushstring(state, "lua_AudioSource_resume - Failed to match the given parameters to a valid function signature.");
  450. lua_error(state);
  451. break;
  452. }
  453. default:
  454. {
  455. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  456. lua_error(state);
  457. break;
  458. }
  459. }
  460. return 0;
  461. }
  462. int lua_AudioSource_rewind(lua_State* state)
  463. {
  464. // Get the number of parameters.
  465. int paramCount = lua_gettop(state);
  466. // Attempt to match the parameters to a valid binding.
  467. switch (paramCount)
  468. {
  469. case 1:
  470. {
  471. if ((lua_type(state, 1) == LUA_TUSERDATA))
  472. {
  473. AudioSource* instance = getInstance(state);
  474. instance->rewind();
  475. return 0;
  476. }
  477. lua_pushstring(state, "lua_AudioSource_rewind - Failed to match the given parameters to a valid function signature.");
  478. lua_error(state);
  479. break;
  480. }
  481. default:
  482. {
  483. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  484. lua_error(state);
  485. break;
  486. }
  487. }
  488. return 0;
  489. }
  490. int lua_AudioSource_setGain(lua_State* state)
  491. {
  492. // Get the number of parameters.
  493. int paramCount = lua_gettop(state);
  494. // Attempt to match the parameters to a valid binding.
  495. switch (paramCount)
  496. {
  497. case 2:
  498. {
  499. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  500. lua_type(state, 2) == LUA_TNUMBER)
  501. {
  502. // Get parameter 1 off the stack.
  503. float param1 = (float)luaL_checknumber(state, 2);
  504. AudioSource* instance = getInstance(state);
  505. instance->setGain(param1);
  506. return 0;
  507. }
  508. lua_pushstring(state, "lua_AudioSource_setGain - Failed to match the given parameters to a valid function signature.");
  509. lua_error(state);
  510. break;
  511. }
  512. default:
  513. {
  514. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  515. lua_error(state);
  516. break;
  517. }
  518. }
  519. return 0;
  520. }
  521. int lua_AudioSource_setLooped(lua_State* state)
  522. {
  523. // Get the number of parameters.
  524. int paramCount = lua_gettop(state);
  525. // Attempt to match the parameters to a valid binding.
  526. switch (paramCount)
  527. {
  528. case 2:
  529. {
  530. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  531. lua_type(state, 2) == LUA_TBOOLEAN)
  532. {
  533. // Get parameter 1 off the stack.
  534. bool param1 = ScriptUtil::luaCheckBool(state, 2);
  535. AudioSource* instance = getInstance(state);
  536. instance->setLooped(param1);
  537. return 0;
  538. }
  539. lua_pushstring(state, "lua_AudioSource_setLooped - Failed to match the given parameters to a valid function signature.");
  540. lua_error(state);
  541. break;
  542. }
  543. default:
  544. {
  545. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  546. lua_error(state);
  547. break;
  548. }
  549. }
  550. return 0;
  551. }
  552. int lua_AudioSource_setPitch(lua_State* state)
  553. {
  554. // Get the number of parameters.
  555. int paramCount = lua_gettop(state);
  556. // Attempt to match the parameters to a valid binding.
  557. switch (paramCount)
  558. {
  559. case 2:
  560. {
  561. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  562. lua_type(state, 2) == LUA_TNUMBER)
  563. {
  564. // Get parameter 1 off the stack.
  565. float param1 = (float)luaL_checknumber(state, 2);
  566. AudioSource* instance = getInstance(state);
  567. instance->setPitch(param1);
  568. return 0;
  569. }
  570. lua_pushstring(state, "lua_AudioSource_setPitch - Failed to match the given parameters to a valid function signature.");
  571. lua_error(state);
  572. break;
  573. }
  574. default:
  575. {
  576. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  577. lua_error(state);
  578. break;
  579. }
  580. }
  581. return 0;
  582. }
  583. int lua_AudioSource_setVelocity(lua_State* state)
  584. {
  585. // Get the number of parameters.
  586. int paramCount = lua_gettop(state);
  587. // Attempt to match the parameters to a valid binding.
  588. switch (paramCount)
  589. {
  590. case 2:
  591. {
  592. do
  593. {
  594. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  595. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL))
  596. {
  597. // Get parameter 1 off the stack.
  598. bool param1Valid;
  599. ScriptUtil::LuaArray<Vector3> param1 = ScriptUtil::getObjectPointer<Vector3>(2, "Vector3", true, &param1Valid);
  600. if (!param1Valid)
  601. break;
  602. AudioSource* instance = getInstance(state);
  603. instance->setVelocity(*param1);
  604. return 0;
  605. }
  606. } while (0);
  607. lua_pushstring(state, "lua_AudioSource_setVelocity - Failed to match the given parameters to a valid function signature.");
  608. lua_error(state);
  609. break;
  610. }
  611. case 4:
  612. {
  613. do
  614. {
  615. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  616. lua_type(state, 2) == LUA_TNUMBER &&
  617. lua_type(state, 3) == LUA_TNUMBER &&
  618. lua_type(state, 4) == LUA_TNUMBER)
  619. {
  620. // Get parameter 1 off the stack.
  621. float param1 = (float)luaL_checknumber(state, 2);
  622. // Get parameter 2 off the stack.
  623. float param2 = (float)luaL_checknumber(state, 3);
  624. // Get parameter 3 off the stack.
  625. float param3 = (float)luaL_checknumber(state, 4);
  626. AudioSource* instance = getInstance(state);
  627. instance->setVelocity(param1, param2, param3);
  628. return 0;
  629. }
  630. } while (0);
  631. lua_pushstring(state, "lua_AudioSource_setVelocity - Failed to match the given parameters to a valid function signature.");
  632. lua_error(state);
  633. break;
  634. }
  635. default:
  636. {
  637. lua_pushstring(state, "Invalid number of parameters (expected 2 or 4).");
  638. lua_error(state);
  639. break;
  640. }
  641. }
  642. return 0;
  643. }
  644. int lua_AudioSource_static_create(lua_State* state)
  645. {
  646. // Get the number of parameters.
  647. int paramCount = lua_gettop(state);
  648. // Attempt to match the parameters to a valid binding.
  649. switch (paramCount)
  650. {
  651. case 1:
  652. {
  653. do
  654. {
  655. if ((lua_type(state, 1) == LUA_TSTRING || lua_type(state, 1) == LUA_TNIL))
  656. {
  657. // Get parameter 1 off the stack.
  658. ScriptUtil::LuaArray<const char> param1 = ScriptUtil::getString(1, false);
  659. void* returnPtr = (void*)AudioSource::create(param1);
  660. if (returnPtr)
  661. {
  662. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  663. object->instance = returnPtr;
  664. object->owns = true;
  665. luaL_getmetatable(state, "AudioSource");
  666. lua_setmetatable(state, -2);
  667. }
  668. else
  669. {
  670. lua_pushnil(state);
  671. }
  672. return 1;
  673. }
  674. } while (0);
  675. do
  676. {
  677. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TTABLE || lua_type(state, 1) == LUA_TNIL))
  678. {
  679. // Get parameter 1 off the stack.
  680. bool param1Valid;
  681. ScriptUtil::LuaArray<Properties> param1 = ScriptUtil::getObjectPointer<Properties>(1, "Properties", false, &param1Valid);
  682. if (!param1Valid)
  683. break;
  684. void* returnPtr = (void*)AudioSource::create(param1);
  685. if (returnPtr)
  686. {
  687. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  688. object->instance = returnPtr;
  689. object->owns = true;
  690. luaL_getmetatable(state, "AudioSource");
  691. lua_setmetatable(state, -2);
  692. }
  693. else
  694. {
  695. lua_pushnil(state);
  696. }
  697. return 1;
  698. }
  699. } while (0);
  700. lua_pushstring(state, "lua_AudioSource_static_create - Failed to match the given parameters to a valid function signature.");
  701. lua_error(state);
  702. break;
  703. }
  704. default:
  705. {
  706. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  707. lua_error(state);
  708. break;
  709. }
  710. }
  711. return 0;
  712. }
  713. int lua_AudioSource_stop(lua_State* state)
  714. {
  715. // Get the number of parameters.
  716. int paramCount = lua_gettop(state);
  717. // Attempt to match the parameters to a valid binding.
  718. switch (paramCount)
  719. {
  720. case 1:
  721. {
  722. if ((lua_type(state, 1) == LUA_TUSERDATA))
  723. {
  724. AudioSource* instance = getInstance(state);
  725. instance->stop();
  726. return 0;
  727. }
  728. lua_pushstring(state, "lua_AudioSource_stop - Failed to match the given parameters to a valid function signature.");
  729. lua_error(state);
  730. break;
  731. }
  732. default:
  733. {
  734. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  735. lua_error(state);
  736. break;
  737. }
  738. }
  739. return 0;
  740. }
  741. }