lua_pluginx_manual_callback.cpp 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222
  1. #include "lua_pluginx_manual_callback.h"
  2. #include "PluginManager.h"
  3. #include "ProtocolAnalytics.h"
  4. #include "ProtocolIAP.h"
  5. #include "ProtocolAds.h"
  6. #include "ProtocolShare.h"
  7. #include "ProtocolSocial.h"
  8. #include "ProtocolUser.h"
  9. #include "tolua_fix.h"
  10. #include "LuaBasicConversions.h"
  11. #include "CCLuaValue.h"
  12. #include "CCLuaEngine.h"
  13. #include "lua_pluginx_basic_conversions.h"
  14. using namespace std;
  15. using namespace cocos2d::plugin;
  16. static map<PluginProtocol*, LUA_FUNCTION> callbacks;
  17. int lua_pluginx_protocols_PluginProtocol_setCallback(lua_State* tolua_S)
  18. {
  19. int argc = 0;
  20. cocos2d::plugin::PluginProtocol* cobj = nullptr;
  21. #if COCOS2D_DEBUG >= 1
  22. tolua_Error tolua_err;
  23. #endif
  24. #if COCOS2D_DEBUG >= 1
  25. if (!tolua_isusertype(tolua_S,1,"plugin.PluginProtocol",0,&tolua_err)) goto tolua_lerror;
  26. #endif
  27. cobj = (cocos2d::plugin::PluginProtocol*)tolua_tousertype(tolua_S,1,0);
  28. #if COCOS2D_DEBUG >= 1
  29. if (!cobj)
  30. {
  31. tolua_error(tolua_S,"invalid 'cobj' in function 'lua_pluginx_protocols_PluginProtocol_setCallback'", nullptr);
  32. return 0;
  33. }
  34. #endif
  35. argc = lua_gettop(tolua_S)-1;
  36. if (argc == 1)
  37. {
  38. LUA_FUNCTION callback = toluafix_ref_function(tolua_S, 2, 0);
  39. if(!callback)
  40. return 0;
  41. std::function<void (int, std::basic_string<char> &)> arg0 = [=](int ret, std::string& productInfo) {
  42. tolua_pushnumber(tolua_S, ret);
  43. tolua_pushstring(tolua_S, productInfo.c_str());
  44. LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(callback, 2);
  45. };
  46. if (dynamic_cast<ProtocolIAP*>(cobj)) {
  47. dynamic_cast<ProtocolIAP*>(cobj)->setCallback(arg0);
  48. } else if (dynamic_cast<ProtocolAds*>(cobj)) {
  49. dynamic_cast<ProtocolAds*>(cobj)->setCallback(arg0);
  50. } else if (dynamic_cast<ProtocolShare*>(cobj)) {
  51. dynamic_cast<ProtocolShare*>(cobj)->setCallback(arg0);
  52. } else if (dynamic_cast<ProtocolSocial*>(cobj)) {
  53. dynamic_cast<ProtocolSocial*>(cobj)->setCallback(arg0);
  54. } else if (dynamic_cast<ProtocolUser*>(cobj)) {
  55. dynamic_cast<ProtocolUser*>(cobj)->setCallback(arg0);
  56. } else {
  57. return 0;
  58. }
  59. if (callbacks.count(cobj) != 0) {
  60. LuaEngine::getInstance()->removeScriptHandler(callbacks[cobj]);
  61. }
  62. callbacks[cobj] = callback;
  63. return 0;
  64. }
  65. CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setCallback",argc, 1);
  66. return 0;
  67. #if COCOS2D_DEBUG >= 1
  68. tolua_lerror:
  69. tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_PluginProtocol_setCallback'.",&tolua_err);
  70. #endif
  71. return 0;
  72. }
  73. int lua_pluginx_protocols_PluginProtocol_getCallback(lua_State* tolua_S)
  74. {
  75. int argc = 0;
  76. cocos2d::plugin::PluginProtocol* cobj = nullptr;
  77. bool ok = true;
  78. #if COCOS2D_DEBUG >= 1
  79. tolua_Error tolua_err;
  80. #endif
  81. #if COCOS2D_DEBUG >= 1
  82. if (!tolua_isusertype(tolua_S,1,"plugin.PluginProtocol",0,&tolua_err)) goto tolua_lerror;
  83. #endif
  84. cobj = (cocos2d::plugin::PluginProtocol*)tolua_tousertype(tolua_S,1,0);
  85. #if COCOS2D_DEBUG >= 1
  86. if (!cobj)
  87. {
  88. tolua_error(tolua_S,"invalid 'cobj' in function 'lua_pluginx_protocols_PluginProtocol_getCallback'", nullptr);
  89. return 0;
  90. }
  91. #endif
  92. argc = lua_gettop(tolua_S)-1;
  93. if (argc == 0)
  94. {
  95. ok = LuaEngine::getInstance()->getLuaStack()->pushFunctionByHandler(callbacks[cobj]);
  96. if(!ok)
  97. return 0;
  98. return 1;
  99. }
  100. CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getCallback",argc, 0);
  101. return 0;
  102. #if COCOS2D_DEBUG >= 1
  103. tolua_lerror:
  104. tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_PluginProtocol_getCallback'.",&tolua_err);
  105. #endif
  106. return 0;
  107. }
  108. static void extendPluginProtocol(lua_State* tolua_S)
  109. {
  110. lua_pushstring(tolua_S, "plugin.PluginProtocol");
  111. lua_rawget(tolua_S, LUA_REGISTRYINDEX);
  112. if (lua_istable(tolua_S,-1))
  113. {
  114. tolua_function(tolua_S, "setCallback", lua_pluginx_protocols_PluginProtocol_setCallback);
  115. tolua_function(tolua_S, "getCallback", lua_pluginx_protocols_PluginProtocol_getCallback);
  116. }
  117. lua_pop(tolua_S, 1);
  118. }
  119. int lua_pluginx_protocols_ProtocolIAP_payForProduct(lua_State* tolua_S)
  120. {
  121. int argc = 0;
  122. cocos2d::plugin::ProtocolIAP* cobj = nullptr;
  123. bool ok = true;
  124. #if COCOS2D_DEBUG >= 1
  125. tolua_Error tolua_err;
  126. #endif
  127. #if COCOS2D_DEBUG >= 1
  128. if (!tolua_isusertype(tolua_S,1,"plugin.ProtocolIAP",0,&tolua_err)) goto tolua_lerror;
  129. #endif
  130. cobj = (cocos2d::plugin::ProtocolIAP*)tolua_tousertype(tolua_S,1,0);
  131. #if COCOS2D_DEBUG >= 1
  132. if (!cobj)
  133. {
  134. tolua_error(tolua_S,"invalid 'cobj' in function 'lua_pluginx_protocols_ProtocolIAP_payForProduct'", nullptr);
  135. return 0;
  136. }
  137. #endif
  138. argc = lua_gettop(tolua_S)-1;
  139. do{
  140. if (argc == 2) {
  141. TProductInfo arg0;
  142. ok &= pluginx::luaval_to_TProductInfo(tolua_S, 2, &arg0);
  143. if (!ok) { break; }
  144. LUA_FUNCTION callback = toluafix_ref_function(tolua_S, 3, 0);
  145. cobj->payForProduct(arg0, [=](int ret, std::string& productInfo) {
  146. tolua_pushnumber(tolua_S, ret);
  147. tolua_pushstring(tolua_S, productInfo.c_str());
  148. LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(callback, 2);
  149. LuaEngine::getInstance()->removeScriptHandler(callback);
  150. });
  151. return 0;
  152. }
  153. }while(0);
  154. ok = true;
  155. do{
  156. if (argc == 1) {
  157. TProductInfo arg0;
  158. ok &= pluginx::luaval_to_TProductInfo(tolua_S, 2, &arg0);
  159. if (!ok) { break; }
  160. cobj->payForProduct(arg0);
  161. return 0;
  162. }
  163. }while(0);
  164. ok = true;
  165. CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "payForProduct",argc, 1);
  166. return 0;
  167. #if COCOS2D_DEBUG >= 1
  168. tolua_lerror:
  169. tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_ProtocolIAP_payForProduct'.",&tolua_err);
  170. #endif
  171. return 0;
  172. }
  173. static void extendProtocolIAP(lua_State* tolua_S)
  174. {
  175. lua_pushstring(tolua_S, "plugin.ProtocolIAP");
  176. lua_rawget(tolua_S, LUA_REGISTRYINDEX);
  177. if (lua_istable(tolua_S,-1))
  178. {
  179. tolua_function(tolua_S, "payForProduct", lua_pluginx_protocols_ProtocolIAP_payForProduct);
  180. }
  181. lua_pop(tolua_S, 1);
  182. }
  183. int lua_pluginx_protocols_ProtocolShare_share(lua_State* tolua_S)
  184. {
  185. int argc = 0;
  186. cocos2d::plugin::ProtocolShare* cobj = nullptr;
  187. bool ok = true;
  188. #if COCOS2D_DEBUG >= 1
  189. tolua_Error tolua_err;
  190. #endif
  191. #if COCOS2D_DEBUG >= 1
  192. if (!tolua_isusertype(tolua_S,1,"plugin.ProtocolShare",0,&tolua_err)) goto tolua_lerror;
  193. #endif
  194. cobj = (cocos2d::plugin::ProtocolShare*)tolua_tousertype(tolua_S,1,0);
  195. #if COCOS2D_DEBUG >= 1
  196. if (!cobj)
  197. {
  198. tolua_error(tolua_S,"invalid 'cobj' in function 'lua_pluginx_protocols_ProtocolShare_share'", nullptr);
  199. return 0;
  200. }
  201. #endif
  202. argc = lua_gettop(tolua_S)-1;
  203. do{
  204. if (argc == 2) {
  205. TShareInfo arg0;
  206. ok &= pluginx::luaval_to_TShareInfo(tolua_S, 2, &arg0);
  207. if (!ok) { break; }
  208. LUA_FUNCTION callback = toluafix_ref_function(tolua_S, 3, 0);
  209. function<void(int, string&)> arg1 = [=](int ret, string& shareInfo) {
  210. tolua_pushnumber(tolua_S, ret);
  211. tolua_pushstring(tolua_S, shareInfo.c_str());
  212. LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(callback, 2);
  213. LuaEngine::getInstance()->removeScriptHandler(callback);
  214. };
  215. cobj->share(arg0, arg1);
  216. return 0;
  217. }
  218. }while(0);
  219. ok = true;
  220. do{
  221. if (argc == 1) {
  222. TShareInfo arg0;
  223. ok &= pluginx::luaval_to_TShareInfo(tolua_S, 2, &arg0);
  224. if (!ok) { break; }
  225. cobj->share(arg0);
  226. return 0;
  227. }
  228. }while(0);
  229. ok = true;
  230. CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "share",argc, 1);
  231. return 0;
  232. #if COCOS2D_DEBUG >= 1
  233. tolua_lerror:
  234. tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_ProtocolShare_share'.",&tolua_err);
  235. #endif
  236. return 0;
  237. }
  238. static void extendProtocolShare(lua_State* tolua_S)
  239. {
  240. lua_pushstring(tolua_S, "plugin.ProtocolShare");
  241. lua_rawget(tolua_S, LUA_REGISTRYINDEX);
  242. if (lua_istable(tolua_S,-1))
  243. {
  244. tolua_function(tolua_S, "share", lua_pluginx_protocols_ProtocolShare_share);
  245. }
  246. lua_pop(tolua_S, 1);
  247. }
  248. int lua_pluginx_protocols_ProtocolSocial_submitScore(lua_State* tolua_S)
  249. {
  250. int argc = 0;
  251. cocos2d::plugin::ProtocolSocial* cobj = nullptr;
  252. bool ok = true;
  253. #if COCOS2D_DEBUG >= 1
  254. tolua_Error tolua_err;
  255. #endif
  256. #if COCOS2D_DEBUG >= 1
  257. if (!tolua_isusertype(tolua_S,1,"plugin.ProtocolSocial",0,&tolua_err)) goto tolua_lerror;
  258. #endif
  259. cobj = (cocos2d::plugin::ProtocolSocial*)tolua_tousertype(tolua_S,1,0);
  260. #if COCOS2D_DEBUG >= 1
  261. if (!cobj)
  262. {
  263. tolua_error(tolua_S,"invalid 'cobj' in function 'lua_pluginx_protocols_ProtocolSocial_submitScore'", nullptr);
  264. return 0;
  265. }
  266. #endif
  267. argc = lua_gettop(tolua_S)-1;
  268. do{
  269. if (argc == 3) {
  270. const char* arg0;
  271. std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str();
  272. if (!ok) { break; }
  273. long arg1;
  274. ok &= luaval_to_long(tolua_S, 3, &arg1);
  275. if (!ok) { break; }
  276. std::function<void (int, std::basic_string<char> &)> arg2;
  277. LUA_FUNCTION callback = toluafix_ref_function(tolua_S, 4, 0);
  278. arg2 = [=](int ret, string& scoreInfo) {
  279. tolua_pushnumber(tolua_S, ret);
  280. tolua_pushstring(tolua_S, scoreInfo.c_str());
  281. LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(callback, 2);
  282. LuaEngine::getInstance()->removeScriptHandler(callback);
  283. };
  284. if (!ok) { break; }
  285. cobj->submitScore(arg0, arg1, arg2);
  286. return 0;
  287. }
  288. }while(0);
  289. ok = true;
  290. do{
  291. if (argc == 2) {
  292. const char* arg0;
  293. std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str();
  294. if (!ok) { break; }
  295. long arg1;
  296. ok &= luaval_to_long(tolua_S, 3, &arg1);
  297. if (!ok) { break; }
  298. cobj->submitScore(arg0, arg1);
  299. return 0;
  300. }
  301. }while(0);
  302. ok = true;
  303. CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "submitScore",argc, 2);
  304. return 0;
  305. #if COCOS2D_DEBUG >= 1
  306. tolua_lerror:
  307. tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_ProtocolSocial_submitScore'.",&tolua_err);
  308. #endif
  309. return 0;
  310. }
  311. int lua_pluginx_protocols_ProtocolSocial_unlockAchievement(lua_State* tolua_S)
  312. {
  313. int argc = 0;
  314. cocos2d::plugin::ProtocolSocial* cobj = nullptr;
  315. bool ok = true;
  316. #if COCOS2D_DEBUG >= 1
  317. tolua_Error tolua_err;
  318. #endif
  319. #if COCOS2D_DEBUG >= 1
  320. if (!tolua_isusertype(tolua_S,1,"plugin.ProtocolSocial",0,&tolua_err)) goto tolua_lerror;
  321. #endif
  322. cobj = (cocos2d::plugin::ProtocolSocial*)tolua_tousertype(tolua_S,1,0);
  323. #if COCOS2D_DEBUG >= 1
  324. if (!cobj)
  325. {
  326. tolua_error(tolua_S,"invalid 'cobj' in function 'lua_pluginx_protocols_ProtocolSocial_unlockAchievement'", nullptr);
  327. return 0;
  328. }
  329. #endif
  330. argc = lua_gettop(tolua_S)-1;
  331. do{
  332. if (argc == 2) {
  333. cocos2d::plugin::TAchievementInfo arg0;
  334. ok &= pluginx::luaval_to_TAchievementInfo(tolua_S, 2, &arg0);
  335. if (!ok) { break; }
  336. std::function<void (int, std::basic_string<char> &)> arg1;
  337. LUA_FUNCTION callback = toluafix_ref_function(tolua_S, 3, 0);
  338. arg1 = [=](int ret, string& unlockInfo) {
  339. tolua_pushnumber(tolua_S, ret);
  340. tolua_pushstring(tolua_S, unlockInfo.c_str());
  341. LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(callback, 2);
  342. LuaEngine::getInstance()->removeScriptHandler(callback);
  343. };
  344. if (!ok) { break; }
  345. cobj->unlockAchievement(arg0, arg1);
  346. return 0;
  347. }
  348. }while(0);
  349. ok = true;
  350. do{
  351. if (argc == 1) {
  352. cocos2d::plugin::TAchievementInfo arg0;
  353. ok &= pluginx::luaval_to_TAchievementInfo(tolua_S, 2, &arg0);
  354. if (!ok) { break; }
  355. cobj->unlockAchievement(arg0);
  356. return 0;
  357. }
  358. }while(0);
  359. ok = true;
  360. CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "unlockAchievement",argc, 1);
  361. return 0;
  362. #if COCOS2D_DEBUG >= 1
  363. tolua_lerror:
  364. tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_ProtocolSocial_unlockAchievement'.",&tolua_err);
  365. #endif
  366. return 0;
  367. }
  368. static void extendProtocolSocial(lua_State* tolua_S)
  369. {
  370. lua_pushstring(tolua_S, "plugin.ProtocolSocial");
  371. lua_rawget(tolua_S, LUA_REGISTRYINDEX);
  372. if (lua_istable(tolua_S,-1))
  373. {
  374. tolua_function(tolua_S, "submitScore", lua_pluginx_protocols_ProtocolSocial_submitScore);
  375. tolua_function(tolua_S, "unlockAchievement", lua_pluginx_protocols_ProtocolSocial_unlockAchievement);
  376. }
  377. lua_pop(tolua_S, 1);
  378. }
  379. int lua_pluginx_protocols_ProtocolUser_login(lua_State* tolua_S)
  380. {
  381. int argc = 0;
  382. cocos2d::plugin::ProtocolUser* cobj = nullptr;
  383. bool ok = true;
  384. #if COCOS2D_DEBUG >= 1
  385. tolua_Error tolua_err;
  386. #endif
  387. #if COCOS2D_DEBUG >= 1
  388. if (!tolua_isusertype(tolua_S,1,"plugin.ProtocolUser",0,&tolua_err)) goto tolua_lerror;
  389. #endif
  390. cobj = (cocos2d::plugin::ProtocolUser*)tolua_tousertype(tolua_S,1,0);
  391. #if COCOS2D_DEBUG >= 1
  392. if (!cobj)
  393. {
  394. tolua_error(tolua_S,"invalid 'cobj' in function 'lua_pluginx_protocols_ProtocolUser_login'", nullptr);
  395. return 0;
  396. }
  397. #endif
  398. argc = lua_gettop(tolua_S)-1;
  399. do{
  400. if (argc == 1) {
  401. std::function<void (int, std::basic_string<char> &)> arg0;
  402. LUA_FUNCTION callback = toluafix_ref_function(tolua_S, 2, 0);
  403. arg0 = [=](int ret, string& loginInfo) {
  404. tolua_pushnumber(tolua_S, ret);
  405. tolua_pushstring(tolua_S, loginInfo.c_str());
  406. LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(callback, 2);
  407. LuaEngine::getInstance()->removeScriptHandler(callback);
  408. };
  409. if (!ok) { break; }
  410. cobj->login(arg0);
  411. return 0;
  412. }
  413. }while(0);
  414. ok = true;
  415. do{
  416. if (argc == 0) {
  417. cobj->login();
  418. return 0;
  419. }
  420. }while(0);
  421. ok = true;
  422. CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "login",argc, 0);
  423. return 0;
  424. #if COCOS2D_DEBUG >= 1
  425. tolua_lerror:
  426. tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_ProtocolUser_login'.",&tolua_err);
  427. #endif
  428. return 0;
  429. }
  430. int lua_pluginx_protocols_ProtocolUser_logout(lua_State* tolua_S)
  431. {
  432. int argc = 0;
  433. cocos2d::plugin::ProtocolUser* cobj = nullptr;
  434. bool ok = true;
  435. #if COCOS2D_DEBUG >= 1
  436. tolua_Error tolua_err;
  437. #endif
  438. #if COCOS2D_DEBUG >= 1
  439. if (!tolua_isusertype(tolua_S,1,"plugin.ProtocolUser",0,&tolua_err)) goto tolua_lerror;
  440. #endif
  441. cobj = (cocos2d::plugin::ProtocolUser*)tolua_tousertype(tolua_S,1,0);
  442. #if COCOS2D_DEBUG >= 1
  443. if (!cobj)
  444. {
  445. tolua_error(tolua_S,"invalid 'cobj' in function 'lua_pluginx_protocols_ProtocolUser_logout'", nullptr);
  446. return 0;
  447. }
  448. #endif
  449. argc = lua_gettop(tolua_S)-1;
  450. do{
  451. if (argc == 1) {
  452. std::function<void (int, std::basic_string<char> &)> arg0;
  453. LUA_FUNCTION callback = toluafix_ref_function(tolua_S, 2, 0);
  454. arg0 = [=](int ret, string& logoutInfo) {
  455. tolua_pushnumber(tolua_S, ret);
  456. tolua_pushstring(tolua_S, logoutInfo.c_str());
  457. LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(callback, 2);
  458. LuaEngine::getInstance()->removeScriptHandler(callback);
  459. };
  460. if (!ok) { break; }
  461. cobj->logout(arg0);
  462. return 0;
  463. }
  464. }while(0);
  465. ok = true;
  466. do{
  467. if (argc == 0) {
  468. cobj->logout();
  469. return 0;
  470. }
  471. }while(0);
  472. ok = true;
  473. CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "logout",argc, 0);
  474. return 0;
  475. #if COCOS2D_DEBUG >= 1
  476. tolua_lerror:
  477. tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_ProtocolUser_logout'.",&tolua_err);
  478. #endif
  479. return 0;
  480. }
  481. static void extendProtocolUser(lua_State* tolua_S)
  482. {
  483. lua_pushstring(tolua_S, "plugin.ProtocolUser");
  484. lua_rawget(tolua_S, LUA_REGISTRYINDEX);
  485. if (lua_istable(tolua_S,-1))
  486. {
  487. tolua_function(tolua_S, "login", lua_pluginx_protocols_ProtocolUser_login);
  488. tolua_function(tolua_S, "logout", lua_pluginx_protocols_ProtocolUser_logout);
  489. }
  490. lua_pop(tolua_S, 1);
  491. }
  492. int lua_pluginx_protocols_FacebookAgent_api(lua_State* tolua_S)
  493. {
  494. int argc = 0;
  495. cocos2d::plugin::FacebookAgent* cobj = nullptr;
  496. bool ok = true;
  497. #if COCOS2D_DEBUG >= 1
  498. tolua_Error tolua_err;
  499. #endif
  500. #if COCOS2D_DEBUG >= 1
  501. if (!tolua_isusertype(tolua_S,1,"plugin.FacebookAgent",0,&tolua_err)) goto tolua_lerror;
  502. #endif
  503. cobj = (cocos2d::plugin::FacebookAgent*)tolua_tousertype(tolua_S,1,0);
  504. #if COCOS2D_DEBUG >= 1
  505. if (!cobj)
  506. {
  507. tolua_error(tolua_S,"invalid 'cobj' in function 'lua_pluginx_protocols_FacebookAgent_api'", nullptr);
  508. return 0;
  509. }
  510. #endif
  511. argc = lua_gettop(tolua_S)-1;
  512. if (argc == 4)
  513. {
  514. std::string arg0;
  515. int arg1;
  516. cocos2d::plugin::FacebookAgent::FBInfo arg2;
  517. ok &= luaval_to_std_string(tolua_S, 2,&arg0, "plugin.FacebookAgent:api");
  518. ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1, "plugin.FacebookAgent:api");
  519. ok &= pluginx::luaval_to_FBInfo(tolua_S, 4, &arg2, "plugin.FacebookAgent:api");
  520. if(!ok)
  521. return 0;
  522. #if COCOS2D_DEBUG >= 1
  523. if (!toluafix_isfunction(tolua_S,5,"LUA_FUNCTION",0,&tolua_err))
  524. {
  525. goto tolua_lerror;
  526. }
  527. #endif
  528. LUA_FUNCTION handler = toluafix_ref_function(tolua_S, 5, 0);
  529. cobj->api(arg0, arg1, arg2, [=](int ret, std::string& msg){
  530. tolua_pushnumber(tolua_S, ret);
  531. tolua_pushstring(tolua_S, msg.c_str());
  532. LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(handler, 2);
  533. LuaEngine::getInstance()->removeScriptHandler(handler);
  534. });
  535. return 0;
  536. }
  537. CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "plugin.FacebookAgent:api",argc, 4);
  538. return 0;
  539. #if COCOS2D_DEBUG >= 1
  540. tolua_lerror:
  541. tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_FacebookAgent_api'.",&tolua_err);
  542. #endif
  543. return 0;
  544. }
  545. int lua_pluginx_protocols_FacebookAgent_share(lua_State* tolua_S)
  546. {
  547. int argc = 0;
  548. cocos2d::plugin::FacebookAgent* cobj = nullptr;
  549. bool ok = true;
  550. #if COCOS2D_DEBUG >= 1
  551. tolua_Error tolua_err;
  552. #endif
  553. #if COCOS2D_DEBUG >= 1
  554. if (!tolua_isusertype(tolua_S,1,"plugin.FacebookAgent",0,&tolua_err)) goto tolua_lerror;
  555. #endif
  556. cobj = (cocos2d::plugin::FacebookAgent*)tolua_tousertype(tolua_S,1,0);
  557. #if COCOS2D_DEBUG >= 1
  558. if (!cobj)
  559. {
  560. tolua_error(tolua_S,"invalid 'cobj' in function 'lua_pluginx_protocols_FacebookAgent_share'", nullptr);
  561. return 0;
  562. }
  563. #endif
  564. argc = lua_gettop(tolua_S)-1;
  565. if (argc == 2)
  566. {
  567. cocos2d::plugin::FacebookAgent::FBInfo arg0;
  568. ok &= pluginx::luaval_to_FBInfo(tolua_S, 2, &arg0, "plugin.FacebookAgent:share");
  569. if(!ok)
  570. return 0;
  571. #if COCOS2D_DEBUG >= 1
  572. if (!toluafix_isfunction(tolua_S,3,"LUA_FUNCTION",0,&tolua_err))
  573. {
  574. goto tolua_lerror;
  575. }
  576. #endif
  577. LUA_FUNCTION handler = toluafix_ref_function(tolua_S, 3, 0);
  578. cobj->share(arg0, [=](int ret, std::string& msg){
  579. tolua_pushnumber(tolua_S, ret);
  580. tolua_pushstring(tolua_S, msg.c_str());
  581. LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(handler, 2);
  582. LuaEngine::getInstance()->removeScriptHandler(handler);
  583. });
  584. return 0;
  585. }
  586. CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "plugin.FacebookAgent:share",argc, 2);
  587. return 0;
  588. #if COCOS2D_DEBUG >= 1
  589. tolua_lerror:
  590. tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_FacebookAgent_share'.",&tolua_err);
  591. #endif
  592. return 0;
  593. }
  594. int lua_pluginx_protocols_FacebookAgent_dialog(lua_State* tolua_S)
  595. {
  596. int argc = 0;
  597. cocos2d::plugin::FacebookAgent* cobj = nullptr;
  598. bool ok = true;
  599. #if COCOS2D_DEBUG >= 1
  600. tolua_Error tolua_err;
  601. #endif
  602. #if COCOS2D_DEBUG >= 1
  603. if (!tolua_isusertype(tolua_S,1,"plugin.FacebookAgent",0,&tolua_err)) goto tolua_lerror;
  604. #endif
  605. cobj = (cocos2d::plugin::FacebookAgent*)tolua_tousertype(tolua_S,1,0);
  606. #if COCOS2D_DEBUG >= 1
  607. if (!cobj)
  608. {
  609. tolua_error(tolua_S,"invalid 'cobj' in function 'lua_pluginx_protocols_FacebookAgent_dialog'", nullptr);
  610. return 0;
  611. }
  612. #endif
  613. argc = lua_gettop(tolua_S)-1;
  614. if (argc == 2)
  615. {
  616. cocos2d::plugin::FacebookAgent::FBInfo arg0;
  617. ok &= pluginx::luaval_to_FBInfo(tolua_S, 2, &arg0, "plugin.FacebookAgent:dialog");
  618. if(!ok)
  619. return 0;
  620. auto iter = arg0.begin();
  621. for (; iter != arg0.end(); iter++)
  622. {
  623. CCLOG("key is %s, value is %s", iter->first.c_str(), iter->second.c_str());
  624. }
  625. #if COCOS2D_DEBUG >= 1
  626. if (!toluafix_isfunction(tolua_S,3,"LUA_FUNCTION",0,&tolua_err))
  627. {
  628. goto tolua_lerror;
  629. }
  630. #endif
  631. LUA_FUNCTION handler = toluafix_ref_function(tolua_S, 3, 0);
  632. cobj->dialog(arg0, [=](int ret, std::string& msg){
  633. tolua_pushnumber(tolua_S, ret);
  634. tolua_pushstring(tolua_S, msg.c_str());
  635. LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(handler, 2);
  636. LuaEngine::getInstance()->removeScriptHandler(handler);
  637. });
  638. return 0;
  639. }
  640. CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "plugin.FacebookAgent:dialog",argc, 2);
  641. return 0;
  642. #if COCOS2D_DEBUG >= 1
  643. tolua_lerror:
  644. tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_FacebookAgent_dialog'.",&tolua_err);
  645. #endif
  646. return 0;
  647. }
  648. int lua_pluginx_protocols_FacebookAgent_login(lua_State* tolua_S)
  649. {
  650. int argc = 0;
  651. cocos2d::plugin::FacebookAgent* cobj = nullptr;
  652. bool ok = true;
  653. #if COCOS2D_DEBUG >= 1
  654. tolua_Error tolua_err;
  655. #endif
  656. #if COCOS2D_DEBUG >= 1
  657. if (!tolua_isusertype(tolua_S,1,"plugin.FacebookAgent",0,&tolua_err)) goto tolua_lerror;
  658. #endif
  659. cobj = (cocos2d::plugin::FacebookAgent*)tolua_tousertype(tolua_S,1,0);
  660. #if COCOS2D_DEBUG >= 1
  661. if (!cobj)
  662. {
  663. tolua_error(tolua_S,"invalid 'cobj' in function 'lua_pluginx_protocols_FacebookAgent_login'", nullptr);
  664. return 0;
  665. }
  666. #endif
  667. argc = lua_gettop(tolua_S)-1;
  668. do{
  669. if (argc == 1) {
  670. if (!toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err))
  671. ok = false;
  672. if (!ok) { break; }
  673. LUA_FUNCTION handler = toluafix_ref_function(tolua_S, 2, 0);
  674. cobj->login([=](int ret, std::string& msg){
  675. tolua_pushnumber(tolua_S, ret);
  676. tolua_pushstring(tolua_S, msg.c_str());
  677. LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(handler, 2);
  678. LuaEngine::getInstance()->removeScriptHandler(handler);
  679. });
  680. return 0;
  681. }
  682. }while(0);
  683. ok = true;
  684. do{
  685. if (argc == 2) {
  686. std::string arg0;
  687. ok &= luaval_to_std_string(tolua_S, 2,&arg0, "plugin.FacebookAgent:login");
  688. if (!ok) { break; }
  689. if (!toluafix_isfunction(tolua_S,3,"LUA_FUNCTION",0,&tolua_err))
  690. ok = false;
  691. if (!ok) { break; }
  692. LUA_FUNCTION handler = toluafix_ref_function(tolua_S, 3, 0);
  693. cobj->login(arg0, [=](int ret, std::string& msg){
  694. tolua_pushnumber(tolua_S, ret);
  695. tolua_pushstring(tolua_S, msg.c_str());
  696. LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(handler, 2);
  697. LuaEngine::getInstance()->removeScriptHandler(handler);
  698. });
  699. return 0;
  700. }
  701. }while(0);
  702. ok = true;
  703. CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "plugin.FacebookAgent:login",argc, 1);
  704. return 0;
  705. #if COCOS2D_DEBUG >= 1
  706. tolua_lerror:
  707. tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_FacebookAgent_login'.",&tolua_err);
  708. #endif
  709. return 0;
  710. }
  711. int lua_pluginx_protocols_FacebookAgent_appRequest(lua_State* tolua_S)
  712. {
  713. int argc = 0;
  714. cocos2d::plugin::FacebookAgent* cobj = nullptr;
  715. bool ok = true;
  716. #if COCOS2D_DEBUG >= 1
  717. tolua_Error tolua_err;
  718. #endif
  719. #if COCOS2D_DEBUG >= 1
  720. if (!tolua_isusertype(tolua_S,1,"plugin.FacebookAgent",0,&tolua_err)) goto tolua_lerror;
  721. #endif
  722. cobj = (cocos2d::plugin::FacebookAgent*)tolua_tousertype(tolua_S,1,0);
  723. #if COCOS2D_DEBUG >= 1
  724. if (!cobj)
  725. {
  726. tolua_error(tolua_S,"invalid 'cobj' in function 'lua_pluginx_protocols_FacebookAgent_appRequest'", nullptr);
  727. return 0;
  728. }
  729. #endif
  730. argc = lua_gettop(tolua_S)-1;
  731. if (argc == 2)
  732. {
  733. cocos2d::plugin::FacebookAgent::FBInfo arg0;
  734. ok &= pluginx::luaval_to_FBInfo(tolua_S, 2, &arg0, "plugin.FacebookAgent:appRequest");
  735. if(!ok)
  736. return 0;
  737. #if COCOS2D_DEBUG >= 1
  738. if (!toluafix_isfunction(tolua_S,3,"LUA_FUNCTION",0,&tolua_err))
  739. {
  740. goto tolua_lerror;
  741. }
  742. #endif
  743. LUA_FUNCTION handler = toluafix_ref_function(tolua_S, 3, 0);
  744. cobj->appRequest(arg0, [=](int ret, std::string& msg){
  745. tolua_pushnumber(tolua_S, ret);
  746. tolua_pushstring(tolua_S, msg.c_str());
  747. LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(handler, 2);
  748. LuaEngine::getInstance()->removeScriptHandler(handler);
  749. });
  750. return 0;
  751. }
  752. CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "plugin.FacebookAgent:appRequest",argc, 2);
  753. return 0;
  754. #if COCOS2D_DEBUG >= 1
  755. tolua_lerror:
  756. tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_FacebookAgent_appRequest'.",&tolua_err);
  757. #endif
  758. return 0;
  759. }
  760. int lua_pluginx_protocols_FacebookAgent_logEvent(lua_State* tolua_S)
  761. {
  762. int argc = 0;
  763. cocos2d::plugin::FacebookAgent* cobj = nullptr;
  764. bool ok = true;
  765. #if COCOS2D_DEBUG >= 1
  766. tolua_Error tolua_err;
  767. #endif
  768. #if COCOS2D_DEBUG >= 1
  769. if (!tolua_isusertype(tolua_S,1,"plugin.FacebookAgent",0,&tolua_err)) goto tolua_lerror;
  770. #endif
  771. cobj = (cocos2d::plugin::FacebookAgent*)tolua_tousertype(tolua_S,1,0);
  772. #if COCOS2D_DEBUG >= 1
  773. if (!cobj)
  774. {
  775. tolua_error(tolua_S,"invalid 'cobj' in function 'lua_pluginx_protocols_FacebookAgent_logEvent'", nullptr);
  776. return 0;
  777. }
  778. #endif
  779. argc = lua_gettop(tolua_S)-1;
  780. do{
  781. if (argc == 2) {
  782. std::string arg0;
  783. ok &= luaval_to_std_string(tolua_S, 2,&arg0, "plugin.FacebookAgent:logEvent");
  784. if (!ok) { break; }
  785. double arg1;
  786. ok &= luaval_to_number(tolua_S, 3,&arg1, "plugin.FacebookAgent:logEvent");
  787. if (!ok) { break; }
  788. cobj->logEvent(arg0, arg1);
  789. return 0;
  790. }
  791. }while(0);
  792. ok = true;
  793. do{
  794. if (argc == 1) {
  795. std::string arg0;
  796. ok &= luaval_to_std_string(tolua_S, 2,&arg0, "plugin.FacebookAgent:logEvent");
  797. if (!ok) { break; }
  798. cobj->logEvent(arg0);
  799. return 0;
  800. }
  801. }while(0);
  802. ok = true;
  803. do{
  804. if (argc == 2) {
  805. std::string arg0;
  806. ok &= luaval_to_std_string(tolua_S, 2,&arg0, "plugin.FacebookAgent:logEvent");
  807. if (!ok) { break; }
  808. cocos2d::plugin::FacebookAgent::FBInfo arg1;
  809. ok &= pluginx::luaval_to_FBInfo(tolua_S, 3, &arg1, "plugin.FacebookAgent:logEvent");
  810. if (!ok) { break; }
  811. cobj->logEvent(arg0, arg1);
  812. return 0;
  813. }
  814. }while(0);
  815. ok = true;
  816. do{
  817. if (argc == 3) {
  818. std::string arg0;
  819. ok &= luaval_to_std_string(tolua_S, 2,&arg0, "plugin.FacebookAgent:logEvent");
  820. if (!ok) { break; }
  821. double arg1;
  822. ok &= luaval_to_number(tolua_S, 3,&arg1, "plugin.FacebookAgent:logEvent");
  823. if (!ok) { break; }
  824. cocos2d::plugin::FacebookAgent::FBInfo arg2;
  825. ok &= pluginx::luaval_to_FBInfo(tolua_S, 4, &arg2, "plugin.FacebookAgent:logEvent");
  826. if (!ok) { break; }
  827. cobj->logEvent(arg0, arg1, arg2);
  828. return 0;
  829. }
  830. }while(0);
  831. ok = true;
  832. CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "plugin.FacebookAgent:logEvent",argc, 3);
  833. return 0;
  834. #if COCOS2D_DEBUG >= 1
  835. tolua_lerror:
  836. tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_FacebookAgent_logEvent'.",&tolua_err);
  837. #endif
  838. return 0;
  839. }
  840. int lua_pluginx_protocols_FacebookAgent_webDialog(lua_State* tolua_S)
  841. {
  842. int argc = 0;
  843. cocos2d::plugin::FacebookAgent* cobj = nullptr;
  844. bool ok = true;
  845. #if COCOS2D_DEBUG >= 1
  846. tolua_Error tolua_err;
  847. #endif
  848. #if COCOS2D_DEBUG >= 1
  849. if (!tolua_isusertype(tolua_S,1,"plugin.FacebookAgent",0,&tolua_err)) goto tolua_lerror;
  850. #endif
  851. cobj = (cocos2d::plugin::FacebookAgent*)tolua_tousertype(tolua_S,1,0);
  852. #if COCOS2D_DEBUG >= 1
  853. if (!cobj)
  854. {
  855. tolua_error(tolua_S,"invalid 'cobj' in function 'lua_pluginx_protocols_FacebookAgent_webDialog'", nullptr);
  856. return 0;
  857. }
  858. #endif
  859. argc = lua_gettop(tolua_S)-1;
  860. if (argc == 2)
  861. {
  862. cocos2d::plugin::FacebookAgent::FBInfo arg0;
  863. ok &= pluginx::luaval_to_FBInfo(tolua_S, 2, &arg0, "plugin.FacebookAgent:webDialog");
  864. if(!ok)
  865. return 0;
  866. auto iter = arg0.begin();
  867. for (; iter != arg0.end(); iter++)
  868. {
  869. CCLOG("key is %s, value is %s", iter->first.c_str(), iter->second.c_str());
  870. }
  871. #if COCOS2D_DEBUG >= 1
  872. if (!toluafix_isfunction(tolua_S,3,"LUA_FUNCTION",0,&tolua_err))
  873. {
  874. goto tolua_lerror;
  875. }
  876. #endif
  877. LUA_FUNCTION handler = toluafix_ref_function(tolua_S, 3, 0);
  878. cobj->webDialog(arg0, [=](int ret, std::string& msg){
  879. tolua_pushnumber(tolua_S, ret);
  880. tolua_pushstring(tolua_S, msg.c_str());
  881. LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(handler, 2);
  882. LuaEngine::getInstance()->removeScriptHandler(handler);
  883. });
  884. return 0;
  885. }
  886. CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "plugin.FacebookAgent:webDialog",argc, 2);
  887. return 0;
  888. #if COCOS2D_DEBUG >= 1
  889. tolua_lerror:
  890. tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_FacebookAgent_webDialog'.",&tolua_err);
  891. #endif
  892. return 0;
  893. }
  894. int lua_pluginx_protocols_FacebookAgent_logPurchase(lua_State* tolua_S)
  895. {
  896. int argc = 0;
  897. cocos2d::plugin::FacebookAgent* cobj = nullptr;
  898. bool ok = true;
  899. #if COCOS2D_DEBUG >= 1
  900. tolua_Error tolua_err;
  901. #endif
  902. #if COCOS2D_DEBUG >= 1
  903. if (!tolua_isusertype(tolua_S,1,"plugin.FacebookAgent",0,&tolua_err)) goto tolua_lerror;
  904. #endif
  905. cobj = (cocos2d::plugin::FacebookAgent*)tolua_tousertype(tolua_S,1,0);
  906. #if COCOS2D_DEBUG >= 1
  907. if (!cobj)
  908. {
  909. tolua_error(tolua_S,"invalid 'cobj' in function 'lua_pluginx_protocols_FacebookAgent_logPurchase'", nullptr);
  910. return 0;
  911. }
  912. #endif
  913. argc = lua_gettop(tolua_S)-1;
  914. if (argc == 3)
  915. {
  916. float mount;
  917. std::string currency;
  918. cocos2d::plugin::FacebookAgent::FBInfo fbInfo;
  919. #if COCOS2D_DEBUG >= 1
  920. if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err) ||
  921. !tolua_isstring(tolua_S, 3, 0, &tolua_err))
  922. {
  923. goto tolua_lerror;
  924. }
  925. #endif
  926. mount = lua_tonumber(tolua_S, 2);
  927. currency = tolua_tocppstring(tolua_S, 3, 0);
  928. ok &= pluginx::luaval_to_FBInfo(tolua_S, 4, &fbInfo, "plugin.FacebookAgent:logPurchase");
  929. if(!ok)
  930. return 0;
  931. cobj->logPurchase(mount, currency, fbInfo);
  932. return 0;
  933. }
  934. CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "plugin.FacebookAgent:logPurchase",argc, 3);
  935. return 0;
  936. #if COCOS2D_DEBUG >= 1
  937. tolua_lerror:
  938. tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_FacebookAgent_logPurchase'.",&tolua_err);
  939. #endif
  940. return 0;
  941. }
  942. int lua_pluginx_protocols_FacebookAgent_canPresentDialogWithParams(lua_State* tolua_S)
  943. {
  944. int argc = 0;
  945. cocos2d::plugin::FacebookAgent* cobj = nullptr;
  946. bool ok = true;
  947. #if COCOS2D_DEBUG >= 1
  948. tolua_Error tolua_err;
  949. #endif
  950. #if COCOS2D_DEBUG >= 1
  951. if (!tolua_isusertype(tolua_S,1,"plugin.FacebookAgent",0,&tolua_err)) goto tolua_lerror;
  952. #endif
  953. cobj = (cocos2d::plugin::FacebookAgent*)tolua_tousertype(tolua_S,1,0);
  954. #if COCOS2D_DEBUG >= 1
  955. if (!cobj)
  956. {
  957. tolua_error(tolua_S,"invalid 'cobj' in function 'lua_pluginx_protocols_FacebookAgent_canPresentDialogWithParams'", nullptr);
  958. return 0;
  959. }
  960. #endif
  961. argc = lua_gettop(tolua_S)-1;
  962. if (argc == 1)
  963. {
  964. cocos2d::plugin::FacebookAgent::FBInfo fbInfo;
  965. ok &= pluginx::luaval_to_FBInfo(tolua_S, 2, &fbInfo, "plugin.FacebookAgent:canPresentDialogWithParams");
  966. if(!ok)
  967. return 0;
  968. bool ret = cobj->canPresentDialogWithParams(fbInfo);
  969. tolua_pushboolean(tolua_S, ret);
  970. return 1;
  971. }
  972. CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "plugin.FacebookAgent:canPresentDialogWithParams",argc, 1);
  973. return 0;
  974. #if COCOS2D_DEBUG >= 1
  975. tolua_lerror:
  976. tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_FacebookAgent_canPresentDialogWithParams'.",&tolua_err);
  977. #endif
  978. return 0;
  979. }
  980. int lua_pluginx_protocols_FacebookAgent_getInstance(lua_State* tolua_S)
  981. {
  982. int argc = 0;
  983. bool ok = true;
  984. #if COCOS2D_DEBUG >= 1
  985. tolua_Error tolua_err;
  986. #endif
  987. #if COCOS2D_DEBUG >= 1
  988. if (!tolua_isusertable(tolua_S,1,"plugin.FacebookAgent",0,&tolua_err)) goto tolua_lerror;
  989. #endif
  990. argc = lua_gettop(tolua_S) - 1;
  991. if (argc == 0)
  992. {
  993. if(!ok)
  994. return 0;
  995. cocos2d::plugin::FacebookAgent* ret = cocos2d::plugin::FacebookAgent::getInstanceLua();
  996. object_to_luaval<cocos2d::plugin::FacebookAgent>(tolua_S, "plugin.FacebookAgent",(cocos2d::plugin::FacebookAgent*)ret);
  997. return 1;
  998. }
  999. CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "plugin.FacebookAgent:getInstance",argc, 0);
  1000. return 0;
  1001. #if COCOS2D_DEBUG >= 1
  1002. tolua_lerror:
  1003. tolua_error(tolua_S,"#ferror in function 'lua_pluginx_protocols_FacebookAgent_getInstance'.",&tolua_err);
  1004. #endif
  1005. return 0;
  1006. }
  1007. static void extendFacebookAgent(lua_State* tolua_S)
  1008. {
  1009. lua_pushstring(tolua_S, "plugin.FacebookAgent");
  1010. lua_rawget(tolua_S, LUA_REGISTRYINDEX);
  1011. if (lua_istable(tolua_S,-1))
  1012. {
  1013. tolua_function(tolua_S, "api", lua_pluginx_protocols_FacebookAgent_api);
  1014. tolua_function(tolua_S, "share", lua_pluginx_protocols_FacebookAgent_share);
  1015. tolua_function(tolua_S, "dialog", lua_pluginx_protocols_FacebookAgent_dialog);
  1016. tolua_function(tolua_S, "login", lua_pluginx_protocols_FacebookAgent_login);
  1017. tolua_function(tolua_S, "appRequest", lua_pluginx_protocols_FacebookAgent_appRequest);
  1018. tolua_function(tolua_S, "logEvent", lua_pluginx_protocols_FacebookAgent_logEvent);
  1019. tolua_function(tolua_S, "webDialog", lua_pluginx_protocols_FacebookAgent_webDialog);
  1020. tolua_function(tolua_S, "logPurchase", lua_pluginx_protocols_FacebookAgent_logPurchase);
  1021. tolua_function(tolua_S, "canPresentDialogWithParams", lua_pluginx_protocols_FacebookAgent_canPresentDialogWithParams);
  1022. tolua_function(tolua_S, "getInstance", lua_pluginx_protocols_FacebookAgent_getInstance);
  1023. }
  1024. lua_pop(tolua_S, 1);
  1025. }
  1026. int register_all_pluginx_manual_callback(lua_State* tolua_S)
  1027. {
  1028. if (NULL == tolua_S)
  1029. return 0;
  1030. extendPluginProtocol(tolua_S);
  1031. extendProtocolIAP(tolua_S);
  1032. extendProtocolShare(tolua_S);
  1033. extendProtocolSocial(tolua_S);
  1034. extendProtocolUser(tolua_S);
  1035. extendFacebookAgent(tolua_S);
  1036. return 0;
  1037. }