lua_Platform.cpp 31 KB

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