jsb_cocos2dx_pluginx_auto.cpp 94 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076
  1. #include "jsb_cocos2dx_pluginx_auto.hpp"
  2. #include "jsb_pluginx_spidermonkey_specifics.h"
  3. #include "jsb_pluginx_basic_conversions.h"
  4. using namespace pluginx;
  5. #include "PluginManager.h"
  6. #include "ProtocolAnalytics.h"
  7. #include "ProtocolIAP.h"
  8. #include "ProtocolAds.h"
  9. #include "ProtocolShare.h"
  10. #include "ProtocolSocial.h"
  11. #include "ProtocolUser.h"
  12. #include "AgentManager.h"
  13. #include "FacebookAgent.h"
  14. template<class T>
  15. static bool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) {
  16. JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
  17. JS::RootedValue initializing(cx);
  18. bool isNewValid = true;
  19. if (isNewValid)
  20. {
  21. TypeTest<T> t;
  22. js_type_class_t *typeClass = nullptr;
  23. std::string typeName = t.s_name();
  24. auto typeMapIter = _js_global_type_map.find(typeName);
  25. CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!");
  26. typeClass = typeMapIter->second;
  27. CCASSERT(typeClass, "The value is null.");
  28. JS::RootedObject proto(cx, typeClass->proto.get());
  29. JS::RootedObject parent(cx, typeClass->parentProto.get());
  30. JS::RootedObject _tmp(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent));
  31. T* cobj = new T();
  32. js_proxy_t *pp = jsb_new_proxy(cobj, _tmp);
  33. AddObjectRoot(cx, &pp->obj);
  34. args.rval().set(OBJECT_TO_JSVAL(_tmp));
  35. return true;
  36. }
  37. return false;
  38. }
  39. static bool empty_constructor(JSContext *cx, uint32_t argc, jsval *vp) {
  40. return false;
  41. }
  42. static bool js_is_native_obj(JSContext *cx, uint32_t argc, jsval *vp)
  43. {
  44. JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
  45. args.rval().setBoolean(true);
  46. return true;
  47. }
  48. JSClass *jsb_cocos2d_plugin_PluginProtocol_class;
  49. JSObject *jsb_cocos2d_plugin_PluginProtocol_prototype;
  50. bool js_pluginx_protocols_PluginProtocol_getPluginName(JSContext *cx, uint32_t argc, jsval *vp)
  51. {
  52. JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
  53. JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
  54. js_proxy_t *proxy = jsb_get_js_proxy(obj);
  55. cocos2d::plugin::PluginProtocol* cobj = (cocos2d::plugin::PluginProtocol *)(proxy ? proxy->ptr : NULL);
  56. JSB_PRECONDITION2( cobj, cx, false, "js_pluginx_protocols_PluginProtocol_getPluginName : Invalid Native Object");
  57. if (argc == 0) {
  58. const char* ret = cobj->getPluginName();
  59. jsval jsret = JSVAL_NULL;
  60. jsret = c_string_to_jsval(cx, ret);
  61. args.rval().set(jsret);
  62. return true;
  63. }
  64. JS_ReportError(cx, "js_pluginx_protocols_PluginProtocol_getPluginName : wrong number of arguments: %d, was expecting %d", argc, 0);
  65. return false;
  66. }
  67. bool js_pluginx_protocols_PluginProtocol_getPluginVersion(JSContext *cx, uint32_t argc, jsval *vp)
  68. {
  69. JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
  70. JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
  71. js_proxy_t *proxy = jsb_get_js_proxy(obj);
  72. cocos2d::plugin::PluginProtocol* cobj = (cocos2d::plugin::PluginProtocol *)(proxy ? proxy->ptr : NULL);
  73. JSB_PRECONDITION2( cobj, cx, false, "js_pluginx_protocols_PluginProtocol_getPluginVersion : Invalid Native Object");
  74. if (argc == 0) {
  75. std::string ret = cobj->getPluginVersion();
  76. jsval jsret = JSVAL_NULL;
  77. jsret = std_string_to_jsval(cx, ret);
  78. args.rval().set(jsret);
  79. return true;
  80. }
  81. JS_ReportError(cx, "js_pluginx_protocols_PluginProtocol_getPluginVersion : wrong number of arguments: %d, was expecting %d", argc, 0);
  82. return false;
  83. }
  84. bool js_pluginx_protocols_PluginProtocol_getSDKVersion(JSContext *cx, uint32_t argc, jsval *vp)
  85. {
  86. JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
  87. JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
  88. js_proxy_t *proxy = jsb_get_js_proxy(obj);
  89. cocos2d::plugin::PluginProtocol* cobj = (cocos2d::plugin::PluginProtocol *)(proxy ? proxy->ptr : NULL);
  90. JSB_PRECONDITION2( cobj, cx, false, "js_pluginx_protocols_PluginProtocol_getSDKVersion : Invalid Native Object");
  91. if (argc == 0) {
  92. std::string ret = cobj->getSDKVersion();
  93. jsval jsret = JSVAL_NULL;
  94. jsret = std_string_to_jsval(cx, ret);
  95. args.rval().set(jsret);
  96. return true;
  97. }
  98. JS_ReportError(cx, "js_pluginx_protocols_PluginProtocol_getSDKVersion : wrong number of arguments: %d, was expecting %d", argc, 0);
  99. return false;
  100. }
  101. bool js_pluginx_protocols_PluginProtocol_setDebugMode(JSContext *cx, uint32_t argc, jsval *vp)
  102. {
  103. JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
  104. bool ok = true;
  105. JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
  106. js_proxy_t *proxy = jsb_get_js_proxy(obj);
  107. cocos2d::plugin::PluginProtocol* cobj = (cocos2d::plugin::PluginProtocol *)(proxy ? proxy->ptr : NULL);
  108. JSB_PRECONDITION2( cobj, cx, false, "js_pluginx_protocols_PluginProtocol_setDebugMode : Invalid Native Object");
  109. if (argc == 1) {
  110. bool arg0;
  111. arg0 = JS::ToBoolean(JS::RootedValue(cx, args.get(0)));
  112. JSB_PRECONDITION2(ok, cx, false, "js_pluginx_protocols_PluginProtocol_setDebugMode : Error processing arguments");
  113. cobj->setDebugMode(arg0);
  114. args.rval().setUndefined();
  115. return true;
  116. }
  117. JS_ReportError(cx, "js_pluginx_protocols_PluginProtocol_setDebugMode : wrong number of arguments: %d, was expecting %d", argc, 1);
  118. return false;
  119. }
  120. void js_cocos2d_plugin_PluginProtocol_finalize(JSFreeOp *fop, JSObject *obj) {
  121. CCLOGINFO("jsbindings: finalizing JS object %p (PluginProtocol)", obj);
  122. js_proxy_t* nproxy;
  123. js_proxy_t* jsproxy;
  124. jsproxy = jsb_get_js_proxy(obj);
  125. if (jsproxy) {
  126. nproxy = jsb_get_native_proxy(jsproxy->ptr);
  127. cocos2d::plugin::PluginProtocol *nobj = static_cast<cocos2d::plugin::PluginProtocol *>(nproxy->ptr);
  128. if (nobj)
  129. delete nobj;
  130. jsb_remove_proxy(nproxy, jsproxy);
  131. }
  132. }
  133. void js_register_pluginx_protocols_PluginProtocol(JSContext *cx, JS::HandleObject global) {
  134. jsb_cocos2d_plugin_PluginProtocol_class = (JSClass *)calloc(1, sizeof(JSClass));
  135. jsb_cocos2d_plugin_PluginProtocol_class->name = "PluginProtocol";
  136. jsb_cocos2d_plugin_PluginProtocol_class->addProperty = JS_PropertyStub;
  137. jsb_cocos2d_plugin_PluginProtocol_class->delProperty = JS_DeletePropertyStub;
  138. jsb_cocos2d_plugin_PluginProtocol_class->getProperty = JS_PropertyStub;
  139. jsb_cocos2d_plugin_PluginProtocol_class->setProperty = JS_StrictPropertyStub;
  140. jsb_cocos2d_plugin_PluginProtocol_class->enumerate = JS_EnumerateStub;
  141. jsb_cocos2d_plugin_PluginProtocol_class->resolve = JS_ResolveStub;
  142. jsb_cocos2d_plugin_PluginProtocol_class->convert = JS_ConvertStub;
  143. jsb_cocos2d_plugin_PluginProtocol_class->finalize = js_cocos2d_plugin_PluginProtocol_finalize;
  144. jsb_cocos2d_plugin_PluginProtocol_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2);
  145. static JSPropertySpec properties[] = {
  146. JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  147. JS_PS_END
  148. };
  149. static JSFunctionSpec funcs[] = {
  150. JS_FN("getPluginName", js_pluginx_protocols_PluginProtocol_getPluginName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  151. JS_FN("getPluginVersion", js_pluginx_protocols_PluginProtocol_getPluginVersion, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  152. JS_FN("getSDKVersion", js_pluginx_protocols_PluginProtocol_getSDKVersion, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  153. JS_FN("setDebugMode", js_pluginx_protocols_PluginProtocol_setDebugMode, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  154. JS_FS_END
  155. };
  156. JSFunctionSpec *st_funcs = NULL;
  157. jsb_cocos2d_plugin_PluginProtocol_prototype = JS_InitClass(
  158. cx, global,
  159. JS::NullPtr(), // parent proto
  160. jsb_cocos2d_plugin_PluginProtocol_class,
  161. empty_constructor, 0,
  162. properties,
  163. funcs,
  164. NULL, // no static properties
  165. st_funcs);
  166. // make the class enumerable in the registered namespace
  167. // bool found;
  168. //FIXME: Removed in Firefox v27
  169. // JS_SetPropertyAttributes(cx, global, "PluginProtocol", JSPROP_ENUMERATE | JSPROP_READONLY, &found);
  170. // add the proto and JSClass to the type->js info hash table
  171. TypeTest<cocos2d::plugin::PluginProtocol> t;
  172. js_type_class_t *p;
  173. std::string typeName = t.s_name();
  174. if (_js_global_type_map.find(typeName) == _js_global_type_map.end())
  175. {
  176. p = (js_type_class_t *)malloc(sizeof(js_type_class_t));
  177. p->jsclass = jsb_cocos2d_plugin_PluginProtocol_class;
  178. p->proto = jsb_cocos2d_plugin_PluginProtocol_prototype;
  179. p->parentProto = NULL;
  180. _js_global_type_map.insert(std::make_pair(typeName, p));
  181. }
  182. }
  183. JSClass *jsb_cocos2d_plugin_PluginManager_class;
  184. JSObject *jsb_cocos2d_plugin_PluginManager_prototype;
  185. bool js_pluginx_protocols_PluginManager_unloadPlugin(JSContext *cx, uint32_t argc, jsval *vp)
  186. {
  187. JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
  188. bool ok = true;
  189. JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
  190. js_proxy_t *proxy = jsb_get_js_proxy(obj);
  191. cocos2d::plugin::PluginManager* cobj = (cocos2d::plugin::PluginManager *)(proxy ? proxy->ptr : NULL);
  192. JSB_PRECONDITION2( cobj, cx, false, "js_pluginx_protocols_PluginManager_unloadPlugin : Invalid Native Object");
  193. if (argc == 1) {
  194. const char* arg0;
  195. std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str();
  196. JSB_PRECONDITION2(ok, cx, false, "js_pluginx_protocols_PluginManager_unloadPlugin : Error processing arguments");
  197. cobj->unloadPlugin(arg0);
  198. args.rval().setUndefined();
  199. return true;
  200. }
  201. JS_ReportError(cx, "js_pluginx_protocols_PluginManager_unloadPlugin : wrong number of arguments: %d, was expecting %d", argc, 1);
  202. return false;
  203. }
  204. bool js_pluginx_protocols_PluginManager_loadPlugin(JSContext *cx, uint32_t argc, jsval *vp)
  205. {
  206. JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
  207. bool ok = true;
  208. JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
  209. js_proxy_t *proxy = jsb_get_js_proxy(obj);
  210. cocos2d::plugin::PluginManager* cobj = (cocos2d::plugin::PluginManager *)(proxy ? proxy->ptr : NULL);
  211. JSB_PRECONDITION2( cobj, cx, false, "js_pluginx_protocols_PluginManager_loadPlugin : Invalid Native Object");
  212. if (argc == 1) {
  213. const char* arg0;
  214. std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str();
  215. JSB_PRECONDITION2(ok, cx, false, "js_pluginx_protocols_PluginManager_loadPlugin : Error processing arguments");
  216. cocos2d::plugin::PluginProtocol* ret = cobj->loadPlugin(arg0);
  217. jsval jsret = JSVAL_NULL;
  218. do {
  219. if (ret) {
  220. js_proxy_t *jsProxy = js_get_or_create_proxy<cocos2d::plugin::PluginProtocol>(cx, (cocos2d::plugin::PluginProtocol*)ret);
  221. jsret = OBJECT_TO_JSVAL(jsProxy->obj);
  222. } else {
  223. jsret = JSVAL_NULL;
  224. }
  225. } while (0);
  226. args.rval().set(jsret);
  227. return true;
  228. }
  229. JS_ReportError(cx, "js_pluginx_protocols_PluginManager_loadPlugin : wrong number of arguments: %d, was expecting %d", argc, 1);
  230. return false;
  231. }
  232. bool js_pluginx_protocols_PluginManager_end(JSContext *cx, uint32_t argc, jsval *vp)
  233. {
  234. JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
  235. if (argc == 0) {
  236. cocos2d::plugin::PluginManager::end();
  237. args.rval().setUndefined();
  238. return true;
  239. }
  240. JS_ReportError(cx, "js_pluginx_protocols_PluginManager_end : wrong number of arguments");
  241. return false;
  242. }
  243. bool js_pluginx_protocols_PluginManager_getInstance(JSContext *cx, uint32_t argc, jsval *vp)
  244. {
  245. JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
  246. if (argc == 0) {
  247. cocos2d::plugin::PluginManager* ret = cocos2d::plugin::PluginManager::getInstance();
  248. jsval jsret = JSVAL_NULL;
  249. do {
  250. if (ret) {
  251. js_proxy_t *jsProxy = js_get_or_create_proxy<cocos2d::plugin::PluginManager>(cx, (cocos2d::plugin::PluginManager*)ret);
  252. jsret = OBJECT_TO_JSVAL(jsProxy->obj);
  253. } else {
  254. jsret = JSVAL_NULL;
  255. }
  256. } while (0);
  257. args.rval().set(jsret);
  258. return true;
  259. }
  260. JS_ReportError(cx, "js_pluginx_protocols_PluginManager_getInstance : wrong number of arguments");
  261. return false;
  262. }
  263. void js_cocos2d_plugin_PluginManager_finalize(JSFreeOp *fop, JSObject *obj) {
  264. CCLOGINFO("jsbindings: finalizing JS object %p (PluginManager)", obj);
  265. js_proxy_t* nproxy;
  266. js_proxy_t* jsproxy;
  267. jsproxy = jsb_get_js_proxy(obj);
  268. if (jsproxy) {
  269. nproxy = jsb_get_native_proxy(jsproxy->ptr);
  270. cocos2d::plugin::PluginManager *nobj = static_cast<cocos2d::plugin::PluginManager *>(nproxy->ptr);
  271. if (nobj)
  272. delete nobj;
  273. jsb_remove_proxy(nproxy, jsproxy);
  274. }
  275. }
  276. void js_register_pluginx_protocols_PluginManager(JSContext *cx, JS::HandleObject global) {
  277. jsb_cocos2d_plugin_PluginManager_class = (JSClass *)calloc(1, sizeof(JSClass));
  278. jsb_cocos2d_plugin_PluginManager_class->name = "PluginManager";
  279. jsb_cocos2d_plugin_PluginManager_class->addProperty = JS_PropertyStub;
  280. jsb_cocos2d_plugin_PluginManager_class->delProperty = JS_DeletePropertyStub;
  281. jsb_cocos2d_plugin_PluginManager_class->getProperty = JS_PropertyStub;
  282. jsb_cocos2d_plugin_PluginManager_class->setProperty = JS_StrictPropertyStub;
  283. jsb_cocos2d_plugin_PluginManager_class->enumerate = JS_EnumerateStub;
  284. jsb_cocos2d_plugin_PluginManager_class->resolve = JS_ResolveStub;
  285. jsb_cocos2d_plugin_PluginManager_class->convert = JS_ConvertStub;
  286. jsb_cocos2d_plugin_PluginManager_class->finalize = js_cocos2d_plugin_PluginManager_finalize;
  287. jsb_cocos2d_plugin_PluginManager_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2);
  288. static JSPropertySpec properties[] = {
  289. JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  290. JS_PS_END
  291. };
  292. static JSFunctionSpec funcs[] = {
  293. JS_FN("unloadPlugin", js_pluginx_protocols_PluginManager_unloadPlugin, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  294. JS_FN("loadPlugin", js_pluginx_protocols_PluginManager_loadPlugin, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  295. JS_FS_END
  296. };
  297. static JSFunctionSpec st_funcs[] = {
  298. JS_FN("end", js_pluginx_protocols_PluginManager_end, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  299. JS_FN("getInstance", js_pluginx_protocols_PluginManager_getInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  300. JS_FS_END
  301. };
  302. jsb_cocos2d_plugin_PluginManager_prototype = JS_InitClass(
  303. cx, global,
  304. JS::NullPtr(), // parent proto
  305. jsb_cocos2d_plugin_PluginManager_class,
  306. empty_constructor, 0,
  307. properties,
  308. funcs,
  309. NULL, // no static properties
  310. st_funcs);
  311. // make the class enumerable in the registered namespace
  312. // bool found;
  313. //FIXME: Removed in Firefox v27
  314. // JS_SetPropertyAttributes(cx, global, "PluginManager", JSPROP_ENUMERATE | JSPROP_READONLY, &found);
  315. // add the proto and JSClass to the type->js info hash table
  316. TypeTest<cocos2d::plugin::PluginManager> t;
  317. js_type_class_t *p;
  318. std::string typeName = t.s_name();
  319. if (_js_global_type_map.find(typeName) == _js_global_type_map.end())
  320. {
  321. p = (js_type_class_t *)malloc(sizeof(js_type_class_t));
  322. p->jsclass = jsb_cocos2d_plugin_PluginManager_class;
  323. p->proto = jsb_cocos2d_plugin_PluginManager_prototype;
  324. p->parentProto = NULL;
  325. _js_global_type_map.insert(std::make_pair(typeName, p));
  326. }
  327. }
  328. JSClass *jsb_cocos2d_plugin_ProtocolAnalytics_class;
  329. JSObject *jsb_cocos2d_plugin_ProtocolAnalytics_prototype;
  330. bool js_pluginx_protocols_ProtocolAnalytics_logTimedEventBegin(JSContext *cx, uint32_t argc, jsval *vp)
  331. {
  332. JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
  333. bool ok = true;
  334. JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
  335. js_proxy_t *proxy = jsb_get_js_proxy(obj);
  336. cocos2d::plugin::ProtocolAnalytics* cobj = (cocos2d::plugin::ProtocolAnalytics *)(proxy ? proxy->ptr : NULL);
  337. JSB_PRECONDITION2( cobj, cx, false, "js_pluginx_protocols_ProtocolAnalytics_logTimedEventBegin : Invalid Native Object");
  338. if (argc == 1) {
  339. const char* arg0;
  340. std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str();
  341. JSB_PRECONDITION2(ok, cx, false, "js_pluginx_protocols_ProtocolAnalytics_logTimedEventBegin : Error processing arguments");
  342. cobj->logTimedEventBegin(arg0);
  343. args.rval().setUndefined();
  344. return true;
  345. }
  346. JS_ReportError(cx, "js_pluginx_protocols_ProtocolAnalytics_logTimedEventBegin : wrong number of arguments: %d, was expecting %d", argc, 1);
  347. return false;
  348. }
  349. bool js_pluginx_protocols_ProtocolAnalytics_logError(JSContext *cx, uint32_t argc, jsval *vp)
  350. {
  351. JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
  352. bool ok = true;
  353. JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
  354. js_proxy_t *proxy = jsb_get_js_proxy(obj);
  355. cocos2d::plugin::ProtocolAnalytics* cobj = (cocos2d::plugin::ProtocolAnalytics *)(proxy ? proxy->ptr : NULL);
  356. JSB_PRECONDITION2( cobj, cx, false, "js_pluginx_protocols_ProtocolAnalytics_logError : Invalid Native Object");
  357. if (argc == 2) {
  358. const char* arg0;
  359. const char* arg1;
  360. std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str();
  361. std::string arg1_tmp; ok &= jsval_to_std_string(cx, args.get(1), &arg1_tmp); arg1 = arg1_tmp.c_str();
  362. JSB_PRECONDITION2(ok, cx, false, "js_pluginx_protocols_ProtocolAnalytics_logError : Error processing arguments");
  363. cobj->logError(arg0, arg1);
  364. args.rval().setUndefined();
  365. return true;
  366. }
  367. JS_ReportError(cx, "js_pluginx_protocols_ProtocolAnalytics_logError : wrong number of arguments: %d, was expecting %d", argc, 2);
  368. return false;
  369. }
  370. bool js_pluginx_protocols_ProtocolAnalytics_setCaptureUncaughtException(JSContext *cx, uint32_t argc, jsval *vp)
  371. {
  372. JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
  373. bool ok = true;
  374. JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
  375. js_proxy_t *proxy = jsb_get_js_proxy(obj);
  376. cocos2d::plugin::ProtocolAnalytics* cobj = (cocos2d::plugin::ProtocolAnalytics *)(proxy ? proxy->ptr : NULL);
  377. JSB_PRECONDITION2( cobj, cx, false, "js_pluginx_protocols_ProtocolAnalytics_setCaptureUncaughtException : Invalid Native Object");
  378. if (argc == 1) {
  379. bool arg0;
  380. arg0 = JS::ToBoolean(JS::RootedValue(cx, args.get(0)));
  381. JSB_PRECONDITION2(ok, cx, false, "js_pluginx_protocols_ProtocolAnalytics_setCaptureUncaughtException : Error processing arguments");
  382. cobj->setCaptureUncaughtException(arg0);
  383. args.rval().setUndefined();
  384. return true;
  385. }
  386. JS_ReportError(cx, "js_pluginx_protocols_ProtocolAnalytics_setCaptureUncaughtException : wrong number of arguments: %d, was expecting %d", argc, 1);
  387. return false;
  388. }
  389. bool js_pluginx_protocols_ProtocolAnalytics_setSessionContinueMillis(JSContext *cx, uint32_t argc, jsval *vp)
  390. {
  391. JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
  392. bool ok = true;
  393. JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
  394. js_proxy_t *proxy = jsb_get_js_proxy(obj);
  395. cocos2d::plugin::ProtocolAnalytics* cobj = (cocos2d::plugin::ProtocolAnalytics *)(proxy ? proxy->ptr : NULL);
  396. JSB_PRECONDITION2( cobj, cx, false, "js_pluginx_protocols_ProtocolAnalytics_setSessionContinueMillis : Invalid Native Object");
  397. if (argc == 1) {
  398. long arg0;
  399. ok &= pluginx::jsval_to_long(cx, args.get(0), &arg0);
  400. JSB_PRECONDITION2(ok, cx, false, "js_pluginx_protocols_ProtocolAnalytics_setSessionContinueMillis : Error processing arguments");
  401. cobj->setSessionContinueMillis(arg0);
  402. args.rval().setUndefined();
  403. return true;
  404. }
  405. JS_ReportError(cx, "js_pluginx_protocols_ProtocolAnalytics_setSessionContinueMillis : wrong number of arguments: %d, was expecting %d", argc, 1);
  406. return false;
  407. }
  408. bool js_pluginx_protocols_ProtocolAnalytics_logEvent(JSContext *cx, uint32_t argc, jsval *vp)
  409. {
  410. JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
  411. bool ok = true;
  412. JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
  413. js_proxy_t *proxy = jsb_get_js_proxy(obj);
  414. cocos2d::plugin::ProtocolAnalytics* cobj = (cocos2d::plugin::ProtocolAnalytics *)(proxy ? proxy->ptr : NULL);
  415. JSB_PRECONDITION2( cobj, cx, false, "js_pluginx_protocols_ProtocolAnalytics_logEvent : Invalid Native Object");
  416. if (argc == 1) {
  417. const char* arg0;
  418. std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str();
  419. JSB_PRECONDITION2(ok, cx, false, "js_pluginx_protocols_ProtocolAnalytics_logEvent : Error processing arguments");
  420. cobj->logEvent(arg0);
  421. args.rval().setUndefined();
  422. return true;
  423. }
  424. if (argc == 2) {
  425. const char* arg0;
  426. std::map<std::string, std::string>* arg1;
  427. std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str();
  428. std::map<std::string, std::string> arg1_tmp; ok &= jsval_to_std_map_string_string(cx, args.get(1), &arg1_tmp); arg1 = &arg1_tmp;
  429. JSB_PRECONDITION2(ok, cx, false, "js_pluginx_protocols_ProtocolAnalytics_logEvent : Error processing arguments");
  430. cobj->logEvent(arg0, arg1);
  431. args.rval().setUndefined();
  432. return true;
  433. }
  434. JS_ReportError(cx, "js_pluginx_protocols_ProtocolAnalytics_logEvent : wrong number of arguments: %d, was expecting %d", argc, 1);
  435. return false;
  436. }
  437. bool js_pluginx_protocols_ProtocolAnalytics_startSession(JSContext *cx, uint32_t argc, jsval *vp)
  438. {
  439. JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
  440. bool ok = true;
  441. JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
  442. js_proxy_t *proxy = jsb_get_js_proxy(obj);
  443. cocos2d::plugin::ProtocolAnalytics* cobj = (cocos2d::plugin::ProtocolAnalytics *)(proxy ? proxy->ptr : NULL);
  444. JSB_PRECONDITION2( cobj, cx, false, "js_pluginx_protocols_ProtocolAnalytics_startSession : Invalid Native Object");
  445. if (argc == 1) {
  446. const char* arg0;
  447. std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str();
  448. JSB_PRECONDITION2(ok, cx, false, "js_pluginx_protocols_ProtocolAnalytics_startSession : Error processing arguments");
  449. cobj->startSession(arg0);
  450. args.rval().setUndefined();
  451. return true;
  452. }
  453. JS_ReportError(cx, "js_pluginx_protocols_ProtocolAnalytics_startSession : wrong number of arguments: %d, was expecting %d", argc, 1);
  454. return false;
  455. }
  456. bool js_pluginx_protocols_ProtocolAnalytics_stopSession(JSContext *cx, uint32_t argc, jsval *vp)
  457. {
  458. JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
  459. JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
  460. js_proxy_t *proxy = jsb_get_js_proxy(obj);
  461. cocos2d::plugin::ProtocolAnalytics* cobj = (cocos2d::plugin::ProtocolAnalytics *)(proxy ? proxy->ptr : NULL);
  462. JSB_PRECONDITION2( cobj, cx, false, "js_pluginx_protocols_ProtocolAnalytics_stopSession : Invalid Native Object");
  463. if (argc == 0) {
  464. cobj->stopSession();
  465. args.rval().setUndefined();
  466. return true;
  467. }
  468. JS_ReportError(cx, "js_pluginx_protocols_ProtocolAnalytics_stopSession : wrong number of arguments: %d, was expecting %d", argc, 0);
  469. return false;
  470. }
  471. bool js_pluginx_protocols_ProtocolAnalytics_logTimedEventEnd(JSContext *cx, uint32_t argc, jsval *vp)
  472. {
  473. JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
  474. bool ok = true;
  475. JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
  476. js_proxy_t *proxy = jsb_get_js_proxy(obj);
  477. cocos2d::plugin::ProtocolAnalytics* cobj = (cocos2d::plugin::ProtocolAnalytics *)(proxy ? proxy->ptr : NULL);
  478. JSB_PRECONDITION2( cobj, cx, false, "js_pluginx_protocols_ProtocolAnalytics_logTimedEventEnd : Invalid Native Object");
  479. if (argc == 1) {
  480. const char* arg0;
  481. std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str();
  482. JSB_PRECONDITION2(ok, cx, false, "js_pluginx_protocols_ProtocolAnalytics_logTimedEventEnd : Error processing arguments");
  483. cobj->logTimedEventEnd(arg0);
  484. args.rval().setUndefined();
  485. return true;
  486. }
  487. JS_ReportError(cx, "js_pluginx_protocols_ProtocolAnalytics_logTimedEventEnd : wrong number of arguments: %d, was expecting %d", argc, 1);
  488. return false;
  489. }
  490. extern JSObject *jsb_cocos2d_plugin_PluginProtocol_prototype;
  491. void js_cocos2d_plugin_ProtocolAnalytics_finalize(JSFreeOp *fop, JSObject *obj) {
  492. CCLOGINFO("jsbindings: finalizing JS object %p (ProtocolAnalytics)", obj);
  493. js_proxy_t* nproxy;
  494. js_proxy_t* jsproxy;
  495. jsproxy = jsb_get_js_proxy(obj);
  496. if (jsproxy) {
  497. nproxy = jsb_get_native_proxy(jsproxy->ptr);
  498. cocos2d::plugin::ProtocolAnalytics *nobj = static_cast<cocos2d::plugin::ProtocolAnalytics *>(nproxy->ptr);
  499. if (nobj)
  500. delete nobj;
  501. jsb_remove_proxy(nproxy, jsproxy);
  502. }
  503. }
  504. void js_register_pluginx_protocols_ProtocolAnalytics(JSContext *cx, JS::HandleObject global) {
  505. jsb_cocos2d_plugin_ProtocolAnalytics_class = (JSClass *)calloc(1, sizeof(JSClass));
  506. jsb_cocos2d_plugin_ProtocolAnalytics_class->name = "ProtocolAnalytics";
  507. jsb_cocos2d_plugin_ProtocolAnalytics_class->addProperty = JS_PropertyStub;
  508. jsb_cocos2d_plugin_ProtocolAnalytics_class->delProperty = JS_DeletePropertyStub;
  509. jsb_cocos2d_plugin_ProtocolAnalytics_class->getProperty = JS_PropertyStub;
  510. jsb_cocos2d_plugin_ProtocolAnalytics_class->setProperty = JS_StrictPropertyStub;
  511. jsb_cocos2d_plugin_ProtocolAnalytics_class->enumerate = JS_EnumerateStub;
  512. jsb_cocos2d_plugin_ProtocolAnalytics_class->resolve = JS_ResolveStub;
  513. jsb_cocos2d_plugin_ProtocolAnalytics_class->convert = JS_ConvertStub;
  514. jsb_cocos2d_plugin_ProtocolAnalytics_class->finalize = js_cocos2d_plugin_ProtocolAnalytics_finalize;
  515. jsb_cocos2d_plugin_ProtocolAnalytics_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2);
  516. static JSPropertySpec properties[] = {
  517. JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  518. JS_PS_END
  519. };
  520. static JSFunctionSpec funcs[] = {
  521. JS_FN("logTimedEventBegin", js_pluginx_protocols_ProtocolAnalytics_logTimedEventBegin, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  522. JS_FN("logError", js_pluginx_protocols_ProtocolAnalytics_logError, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  523. JS_FN("setCaptureUncaughtException", js_pluginx_protocols_ProtocolAnalytics_setCaptureUncaughtException, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  524. JS_FN("setSessionContinueMillis", js_pluginx_protocols_ProtocolAnalytics_setSessionContinueMillis, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  525. JS_FN("logEvent", js_pluginx_protocols_ProtocolAnalytics_logEvent, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  526. JS_FN("startSession", js_pluginx_protocols_ProtocolAnalytics_startSession, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  527. JS_FN("stopSession", js_pluginx_protocols_ProtocolAnalytics_stopSession, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  528. JS_FN("logTimedEventEnd", js_pluginx_protocols_ProtocolAnalytics_logTimedEventEnd, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  529. JS_FS_END
  530. };
  531. JSFunctionSpec *st_funcs = NULL;
  532. jsb_cocos2d_plugin_ProtocolAnalytics_prototype = JS_InitClass(
  533. cx, global,
  534. JS::RootedObject(cx, jsb_cocos2d_plugin_PluginProtocol_prototype),
  535. jsb_cocos2d_plugin_ProtocolAnalytics_class,
  536. empty_constructor, 0,
  537. properties,
  538. funcs,
  539. NULL, // no static properties
  540. st_funcs);
  541. // make the class enumerable in the registered namespace
  542. // bool found;
  543. //FIXME: Removed in Firefox v27
  544. // JS_SetPropertyAttributes(cx, global, "ProtocolAnalytics", JSPROP_ENUMERATE | JSPROP_READONLY, &found);
  545. // add the proto and JSClass to the type->js info hash table
  546. TypeTest<cocos2d::plugin::ProtocolAnalytics> t;
  547. js_type_class_t *p;
  548. std::string typeName = t.s_name();
  549. if (_js_global_type_map.find(typeName) == _js_global_type_map.end())
  550. {
  551. p = (js_type_class_t *)malloc(sizeof(js_type_class_t));
  552. p->jsclass = jsb_cocos2d_plugin_ProtocolAnalytics_class;
  553. p->proto = jsb_cocos2d_plugin_ProtocolAnalytics_prototype;
  554. p->parentProto = jsb_cocos2d_plugin_PluginProtocol_prototype;
  555. _js_global_type_map.insert(std::make_pair(typeName, p));
  556. }
  557. }
  558. JSClass *jsb_cocos2d_plugin_ProtocolIAP_class;
  559. JSObject *jsb_cocos2d_plugin_ProtocolIAP_prototype;
  560. bool js_pluginx_protocols_ProtocolIAP_onPayResult(JSContext *cx, uint32_t argc, jsval *vp)
  561. {
  562. JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
  563. bool ok = true;
  564. JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
  565. js_proxy_t *proxy = jsb_get_js_proxy(obj);
  566. cocos2d::plugin::ProtocolIAP* cobj = (cocos2d::plugin::ProtocolIAP *)(proxy ? proxy->ptr : NULL);
  567. JSB_PRECONDITION2( cobj, cx, false, "js_pluginx_protocols_ProtocolIAP_onPayResult : Invalid Native Object");
  568. if (argc == 2) {
  569. cocos2d::plugin::PayResultCode arg0;
  570. const char* arg1;
  571. ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0);
  572. std::string arg1_tmp; ok &= jsval_to_std_string(cx, args.get(1), &arg1_tmp); arg1 = arg1_tmp.c_str();
  573. JSB_PRECONDITION2(ok, cx, false, "js_pluginx_protocols_ProtocolIAP_onPayResult : Error processing arguments");
  574. cobj->onPayResult(arg0, arg1);
  575. args.rval().setUndefined();
  576. return true;
  577. }
  578. JS_ReportError(cx, "js_pluginx_protocols_ProtocolIAP_onPayResult : wrong number of arguments: %d, was expecting %d", argc, 2);
  579. return false;
  580. }
  581. bool js_pluginx_protocols_ProtocolIAP_getCallback(JSContext *cx, uint32_t argc, jsval *vp)
  582. {
  583. JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
  584. JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
  585. js_proxy_t *proxy = jsb_get_js_proxy(obj);
  586. cocos2d::plugin::ProtocolIAP* cobj = (cocos2d::plugin::ProtocolIAP *)(proxy ? proxy->ptr : NULL);
  587. JSB_PRECONDITION2( cobj, cx, false, "js_pluginx_protocols_ProtocolIAP_getCallback : Invalid Native Object");
  588. if (argc == 0) {
  589. cocos2d::plugin::ProtocolIAP::ProtocolIAPCallback ret = cobj->getCallback();
  590. jsval jsret = JSVAL_NULL;
  591. #pragma warning NO CONVERSION FROM NATIVE FOR std::function;
  592. args.rval().set(jsret);
  593. return true;
  594. }
  595. JS_ReportError(cx, "js_pluginx_protocols_ProtocolIAP_getCallback : wrong number of arguments: %d, was expecting %d", argc, 0);
  596. return false;
  597. }
  598. bool js_pluginx_protocols_ProtocolIAP_configDeveloperInfo(JSContext *cx, uint32_t argc, jsval *vp)
  599. {
  600. JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
  601. bool ok = true;
  602. JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
  603. js_proxy_t *proxy = jsb_get_js_proxy(obj);
  604. cocos2d::plugin::ProtocolIAP* cobj = (cocos2d::plugin::ProtocolIAP *)(proxy ? proxy->ptr : NULL);
  605. JSB_PRECONDITION2( cobj, cx, false, "js_pluginx_protocols_ProtocolIAP_configDeveloperInfo : Invalid Native Object");
  606. if (argc == 1) {
  607. std::map<std::string, std::string> arg0;
  608. ok &= jsval_to_std_map_string_string(cx, args.get(0), &arg0);
  609. JSB_PRECONDITION2(ok, cx, false, "js_pluginx_protocols_ProtocolIAP_configDeveloperInfo : Error processing arguments");
  610. cobj->configDeveloperInfo(arg0);
  611. args.rval().setUndefined();
  612. return true;
  613. }
  614. JS_ReportError(cx, "js_pluginx_protocols_ProtocolIAP_configDeveloperInfo : wrong number of arguments: %d, was expecting %d", argc, 1);
  615. return false;
  616. }
  617. extern JSObject *jsb_cocos2d_plugin_PluginProtocol_prototype;
  618. void js_cocos2d_plugin_ProtocolIAP_finalize(JSFreeOp *fop, JSObject *obj) {
  619. CCLOGINFO("jsbindings: finalizing JS object %p (ProtocolIAP)", obj);
  620. js_proxy_t* nproxy;
  621. js_proxy_t* jsproxy;
  622. jsproxy = jsb_get_js_proxy(obj);
  623. if (jsproxy) {
  624. nproxy = jsb_get_native_proxy(jsproxy->ptr);
  625. cocos2d::plugin::ProtocolIAP *nobj = static_cast<cocos2d::plugin::ProtocolIAP *>(nproxy->ptr);
  626. if (nobj)
  627. delete nobj;
  628. jsb_remove_proxy(nproxy, jsproxy);
  629. }
  630. }
  631. void js_register_pluginx_protocols_ProtocolIAP(JSContext *cx, JS::HandleObject global) {
  632. jsb_cocos2d_plugin_ProtocolIAP_class = (JSClass *)calloc(1, sizeof(JSClass));
  633. jsb_cocos2d_plugin_ProtocolIAP_class->name = "ProtocolIAP";
  634. jsb_cocos2d_plugin_ProtocolIAP_class->addProperty = JS_PropertyStub;
  635. jsb_cocos2d_plugin_ProtocolIAP_class->delProperty = JS_DeletePropertyStub;
  636. jsb_cocos2d_plugin_ProtocolIAP_class->getProperty = JS_PropertyStub;
  637. jsb_cocos2d_plugin_ProtocolIAP_class->setProperty = JS_StrictPropertyStub;
  638. jsb_cocos2d_plugin_ProtocolIAP_class->enumerate = JS_EnumerateStub;
  639. jsb_cocos2d_plugin_ProtocolIAP_class->resolve = JS_ResolveStub;
  640. jsb_cocos2d_plugin_ProtocolIAP_class->convert = JS_ConvertStub;
  641. jsb_cocos2d_plugin_ProtocolIAP_class->finalize = js_cocos2d_plugin_ProtocolIAP_finalize;
  642. jsb_cocos2d_plugin_ProtocolIAP_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2);
  643. static JSPropertySpec properties[] = {
  644. JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  645. JS_PS_END
  646. };
  647. static JSFunctionSpec funcs[] = {
  648. JS_FN("onPayResult", js_pluginx_protocols_ProtocolIAP_onPayResult, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  649. JS_FN("getCallback", js_pluginx_protocols_ProtocolIAP_getCallback, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  650. JS_FN("configDeveloperInfo", js_pluginx_protocols_ProtocolIAP_configDeveloperInfo, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  651. JS_FS_END
  652. };
  653. JSFunctionSpec *st_funcs = NULL;
  654. jsb_cocos2d_plugin_ProtocolIAP_prototype = JS_InitClass(
  655. cx, global,
  656. JS::RootedObject(cx, jsb_cocos2d_plugin_PluginProtocol_prototype),
  657. jsb_cocos2d_plugin_ProtocolIAP_class,
  658. empty_constructor, 0,
  659. properties,
  660. funcs,
  661. NULL, // no static properties
  662. st_funcs);
  663. // make the class enumerable in the registered namespace
  664. // bool found;
  665. //FIXME: Removed in Firefox v27
  666. // JS_SetPropertyAttributes(cx, global, "ProtocolIAP", JSPROP_ENUMERATE | JSPROP_READONLY, &found);
  667. // add the proto and JSClass to the type->js info hash table
  668. TypeTest<cocos2d::plugin::ProtocolIAP> t;
  669. js_type_class_t *p;
  670. std::string typeName = t.s_name();
  671. if (_js_global_type_map.find(typeName) == _js_global_type_map.end())
  672. {
  673. p = (js_type_class_t *)malloc(sizeof(js_type_class_t));
  674. p->jsclass = jsb_cocos2d_plugin_ProtocolIAP_class;
  675. p->proto = jsb_cocos2d_plugin_ProtocolIAP_prototype;
  676. p->parentProto = jsb_cocos2d_plugin_PluginProtocol_prototype;
  677. _js_global_type_map.insert(std::make_pair(typeName, p));
  678. }
  679. }
  680. JSClass *jsb_cocos2d_plugin_ProtocolAds_class;
  681. JSObject *jsb_cocos2d_plugin_ProtocolAds_prototype;
  682. bool js_pluginx_protocols_ProtocolAds_showAds(JSContext *cx, uint32_t argc, jsval *vp)
  683. {
  684. JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
  685. bool ok = true;
  686. JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
  687. js_proxy_t *proxy = jsb_get_js_proxy(obj);
  688. cocos2d::plugin::ProtocolAds* cobj = (cocos2d::plugin::ProtocolAds *)(proxy ? proxy->ptr : NULL);
  689. JSB_PRECONDITION2( cobj, cx, false, "js_pluginx_protocols_ProtocolAds_showAds : Invalid Native Object");
  690. if (argc == 1) {
  691. std::map<std::string, std::string> arg0;
  692. ok &= jsval_to_std_map_string_string(cx, args.get(0), &arg0);
  693. JSB_PRECONDITION2(ok, cx, false, "js_pluginx_protocols_ProtocolAds_showAds : Error processing arguments");
  694. cobj->showAds(arg0);
  695. args.rval().setUndefined();
  696. return true;
  697. }
  698. if (argc == 2) {
  699. std::map<std::string, std::string> arg0;
  700. cocos2d::plugin::ProtocolAds::AdsPos arg1;
  701. ok &= jsval_to_std_map_string_string(cx, args.get(0), &arg0);
  702. ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1);
  703. JSB_PRECONDITION2(ok, cx, false, "js_pluginx_protocols_ProtocolAds_showAds : Error processing arguments");
  704. cobj->showAds(arg0, arg1);
  705. args.rval().setUndefined();
  706. return true;
  707. }
  708. JS_ReportError(cx, "js_pluginx_protocols_ProtocolAds_showAds : wrong number of arguments: %d, was expecting %d", argc, 1);
  709. return false;
  710. }
  711. bool js_pluginx_protocols_ProtocolAds_hideAds(JSContext *cx, uint32_t argc, jsval *vp)
  712. {
  713. JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
  714. bool ok = true;
  715. JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
  716. js_proxy_t *proxy = jsb_get_js_proxy(obj);
  717. cocos2d::plugin::ProtocolAds* cobj = (cocos2d::plugin::ProtocolAds *)(proxy ? proxy->ptr : NULL);
  718. JSB_PRECONDITION2( cobj, cx, false, "js_pluginx_protocols_ProtocolAds_hideAds : Invalid Native Object");
  719. if (argc == 1) {
  720. std::map<std::string, std::string> arg0;
  721. ok &= jsval_to_std_map_string_string(cx, args.get(0), &arg0);
  722. JSB_PRECONDITION2(ok, cx, false, "js_pluginx_protocols_ProtocolAds_hideAds : Error processing arguments");
  723. cobj->hideAds(arg0);
  724. args.rval().setUndefined();
  725. return true;
  726. }
  727. JS_ReportError(cx, "js_pluginx_protocols_ProtocolAds_hideAds : wrong number of arguments: %d, was expecting %d", argc, 1);
  728. return false;
  729. }
  730. bool js_pluginx_protocols_ProtocolAds_queryPoints(JSContext *cx, uint32_t argc, jsval *vp)
  731. {
  732. JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
  733. JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
  734. js_proxy_t *proxy = jsb_get_js_proxy(obj);
  735. cocos2d::plugin::ProtocolAds* cobj = (cocos2d::plugin::ProtocolAds *)(proxy ? proxy->ptr : NULL);
  736. JSB_PRECONDITION2( cobj, cx, false, "js_pluginx_protocols_ProtocolAds_queryPoints : Invalid Native Object");
  737. if (argc == 0) {
  738. cobj->queryPoints();
  739. args.rval().setUndefined();
  740. return true;
  741. }
  742. JS_ReportError(cx, "js_pluginx_protocols_ProtocolAds_queryPoints : wrong number of arguments: %d, was expecting %d", argc, 0);
  743. return false;
  744. }
  745. bool js_pluginx_protocols_ProtocolAds_getCallback(JSContext *cx, uint32_t argc, jsval *vp)
  746. {
  747. JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
  748. JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
  749. js_proxy_t *proxy = jsb_get_js_proxy(obj);
  750. cocos2d::plugin::ProtocolAds* cobj = (cocos2d::plugin::ProtocolAds *)(proxy ? proxy->ptr : NULL);
  751. JSB_PRECONDITION2( cobj, cx, false, "js_pluginx_protocols_ProtocolAds_getCallback : Invalid Native Object");
  752. if (argc == 0) {
  753. cocos2d::plugin::ProtocolAds::ProtocolAdsCallback ret = cobj->getCallback();
  754. jsval jsret = JSVAL_NULL;
  755. #pragma warning NO CONVERSION FROM NATIVE FOR std::function;
  756. args.rval().set(jsret);
  757. return true;
  758. }
  759. JS_ReportError(cx, "js_pluginx_protocols_ProtocolAds_getCallback : wrong number of arguments: %d, was expecting %d", argc, 0);
  760. return false;
  761. }
  762. bool js_pluginx_protocols_ProtocolAds_spendPoints(JSContext *cx, uint32_t argc, jsval *vp)
  763. {
  764. JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
  765. bool ok = true;
  766. JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
  767. js_proxy_t *proxy = jsb_get_js_proxy(obj);
  768. cocos2d::plugin::ProtocolAds* cobj = (cocos2d::plugin::ProtocolAds *)(proxy ? proxy->ptr : NULL);
  769. JSB_PRECONDITION2( cobj, cx, false, "js_pluginx_protocols_ProtocolAds_spendPoints : Invalid Native Object");
  770. if (argc == 1) {
  771. int arg0;
  772. ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0);
  773. JSB_PRECONDITION2(ok, cx, false, "js_pluginx_protocols_ProtocolAds_spendPoints : Error processing arguments");
  774. cobj->spendPoints(arg0);
  775. args.rval().setUndefined();
  776. return true;
  777. }
  778. JS_ReportError(cx, "js_pluginx_protocols_ProtocolAds_spendPoints : wrong number of arguments: %d, was expecting %d", argc, 1);
  779. return false;
  780. }
  781. bool js_pluginx_protocols_ProtocolAds_configDeveloperInfo(JSContext *cx, uint32_t argc, jsval *vp)
  782. {
  783. JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
  784. bool ok = true;
  785. JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
  786. js_proxy_t *proxy = jsb_get_js_proxy(obj);
  787. cocos2d::plugin::ProtocolAds* cobj = (cocos2d::plugin::ProtocolAds *)(proxy ? proxy->ptr : NULL);
  788. JSB_PRECONDITION2( cobj, cx, false, "js_pluginx_protocols_ProtocolAds_configDeveloperInfo : Invalid Native Object");
  789. if (argc == 1) {
  790. std::map<std::string, std::string> arg0;
  791. ok &= jsval_to_std_map_string_string(cx, args.get(0), &arg0);
  792. JSB_PRECONDITION2(ok, cx, false, "js_pluginx_protocols_ProtocolAds_configDeveloperInfo : Error processing arguments");
  793. cobj->configDeveloperInfo(arg0);
  794. args.rval().setUndefined();
  795. return true;
  796. }
  797. JS_ReportError(cx, "js_pluginx_protocols_ProtocolAds_configDeveloperInfo : wrong number of arguments: %d, was expecting %d", argc, 1);
  798. return false;
  799. }
  800. extern JSObject *jsb_cocos2d_plugin_PluginProtocol_prototype;
  801. void js_cocos2d_plugin_ProtocolAds_finalize(JSFreeOp *fop, JSObject *obj) {
  802. CCLOGINFO("jsbindings: finalizing JS object %p (ProtocolAds)", obj);
  803. js_proxy_t* nproxy;
  804. js_proxy_t* jsproxy;
  805. jsproxy = jsb_get_js_proxy(obj);
  806. if (jsproxy) {
  807. nproxy = jsb_get_native_proxy(jsproxy->ptr);
  808. cocos2d::plugin::ProtocolAds *nobj = static_cast<cocos2d::plugin::ProtocolAds *>(nproxy->ptr);
  809. if (nobj)
  810. delete nobj;
  811. jsb_remove_proxy(nproxy, jsproxy);
  812. }
  813. }
  814. void js_register_pluginx_protocols_ProtocolAds(JSContext *cx, JS::HandleObject global) {
  815. jsb_cocos2d_plugin_ProtocolAds_class = (JSClass *)calloc(1, sizeof(JSClass));
  816. jsb_cocos2d_plugin_ProtocolAds_class->name = "ProtocolAds";
  817. jsb_cocos2d_plugin_ProtocolAds_class->addProperty = JS_PropertyStub;
  818. jsb_cocos2d_plugin_ProtocolAds_class->delProperty = JS_DeletePropertyStub;
  819. jsb_cocos2d_plugin_ProtocolAds_class->getProperty = JS_PropertyStub;
  820. jsb_cocos2d_plugin_ProtocolAds_class->setProperty = JS_StrictPropertyStub;
  821. jsb_cocos2d_plugin_ProtocolAds_class->enumerate = JS_EnumerateStub;
  822. jsb_cocos2d_plugin_ProtocolAds_class->resolve = JS_ResolveStub;
  823. jsb_cocos2d_plugin_ProtocolAds_class->convert = JS_ConvertStub;
  824. jsb_cocos2d_plugin_ProtocolAds_class->finalize = js_cocos2d_plugin_ProtocolAds_finalize;
  825. jsb_cocos2d_plugin_ProtocolAds_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2);
  826. static JSPropertySpec properties[] = {
  827. JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  828. JS_PS_END
  829. };
  830. static JSFunctionSpec funcs[] = {
  831. JS_FN("showAds", js_pluginx_protocols_ProtocolAds_showAds, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  832. JS_FN("hideAds", js_pluginx_protocols_ProtocolAds_hideAds, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  833. JS_FN("queryPoints", js_pluginx_protocols_ProtocolAds_queryPoints, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  834. JS_FN("getCallback", js_pluginx_protocols_ProtocolAds_getCallback, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  835. JS_FN("spendPoints", js_pluginx_protocols_ProtocolAds_spendPoints, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  836. JS_FN("configDeveloperInfo", js_pluginx_protocols_ProtocolAds_configDeveloperInfo, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  837. JS_FS_END
  838. };
  839. JSFunctionSpec *st_funcs = NULL;
  840. jsb_cocos2d_plugin_ProtocolAds_prototype = JS_InitClass(
  841. cx, global,
  842. JS::RootedObject(cx, jsb_cocos2d_plugin_PluginProtocol_prototype),
  843. jsb_cocos2d_plugin_ProtocolAds_class,
  844. empty_constructor, 0,
  845. properties,
  846. funcs,
  847. NULL, // no static properties
  848. st_funcs);
  849. // make the class enumerable in the registered namespace
  850. // bool found;
  851. //FIXME: Removed in Firefox v27
  852. // JS_SetPropertyAttributes(cx, global, "ProtocolAds", JSPROP_ENUMERATE | JSPROP_READONLY, &found);
  853. // add the proto and JSClass to the type->js info hash table
  854. TypeTest<cocos2d::plugin::ProtocolAds> t;
  855. js_type_class_t *p;
  856. std::string typeName = t.s_name();
  857. if (_js_global_type_map.find(typeName) == _js_global_type_map.end())
  858. {
  859. p = (js_type_class_t *)malloc(sizeof(js_type_class_t));
  860. p->jsclass = jsb_cocos2d_plugin_ProtocolAds_class;
  861. p->proto = jsb_cocos2d_plugin_ProtocolAds_prototype;
  862. p->parentProto = jsb_cocos2d_plugin_PluginProtocol_prototype;
  863. _js_global_type_map.insert(std::make_pair(typeName, p));
  864. }
  865. }
  866. JSClass *jsb_cocos2d_plugin_ProtocolShare_class;
  867. JSObject *jsb_cocos2d_plugin_ProtocolShare_prototype;
  868. bool js_pluginx_protocols_ProtocolShare_onShareResult(JSContext *cx, uint32_t argc, jsval *vp)
  869. {
  870. JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
  871. bool ok = true;
  872. JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
  873. js_proxy_t *proxy = jsb_get_js_proxy(obj);
  874. cocos2d::plugin::ProtocolShare* cobj = (cocos2d::plugin::ProtocolShare *)(proxy ? proxy->ptr : NULL);
  875. JSB_PRECONDITION2( cobj, cx, false, "js_pluginx_protocols_ProtocolShare_onShareResult : Invalid Native Object");
  876. if (argc == 2) {
  877. cocos2d::plugin::ShareResultCode arg0;
  878. const char* arg1;
  879. ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0);
  880. std::string arg1_tmp; ok &= jsval_to_std_string(cx, args.get(1), &arg1_tmp); arg1 = arg1_tmp.c_str();
  881. JSB_PRECONDITION2(ok, cx, false, "js_pluginx_protocols_ProtocolShare_onShareResult : Error processing arguments");
  882. cobj->onShareResult(arg0, arg1);
  883. args.rval().setUndefined();
  884. return true;
  885. }
  886. JS_ReportError(cx, "js_pluginx_protocols_ProtocolShare_onShareResult : wrong number of arguments: %d, was expecting %d", argc, 2);
  887. return false;
  888. }
  889. bool js_pluginx_protocols_ProtocolShare_getCallback(JSContext *cx, uint32_t argc, jsval *vp)
  890. {
  891. JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
  892. JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
  893. js_proxy_t *proxy = jsb_get_js_proxy(obj);
  894. cocos2d::plugin::ProtocolShare* cobj = (cocos2d::plugin::ProtocolShare *)(proxy ? proxy->ptr : NULL);
  895. JSB_PRECONDITION2( cobj, cx, false, "js_pluginx_protocols_ProtocolShare_getCallback : Invalid Native Object");
  896. if (argc == 0) {
  897. cocos2d::plugin::ProtocolShare::ProtocolShareCallback ret = cobj->getCallback();
  898. jsval jsret = JSVAL_NULL;
  899. #pragma warning NO CONVERSION FROM NATIVE FOR std::function;
  900. args.rval().set(jsret);
  901. return true;
  902. }
  903. JS_ReportError(cx, "js_pluginx_protocols_ProtocolShare_getCallback : wrong number of arguments: %d, was expecting %d", argc, 0);
  904. return false;
  905. }
  906. bool js_pluginx_protocols_ProtocolShare_configDeveloperInfo(JSContext *cx, uint32_t argc, jsval *vp)
  907. {
  908. JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
  909. bool ok = true;
  910. JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
  911. js_proxy_t *proxy = jsb_get_js_proxy(obj);
  912. cocos2d::plugin::ProtocolShare* cobj = (cocos2d::plugin::ProtocolShare *)(proxy ? proxy->ptr : NULL);
  913. JSB_PRECONDITION2( cobj, cx, false, "js_pluginx_protocols_ProtocolShare_configDeveloperInfo : Invalid Native Object");
  914. if (argc == 1) {
  915. std::map<std::string, std::string> arg0;
  916. ok &= jsval_to_std_map_string_string(cx, args.get(0), &arg0);
  917. JSB_PRECONDITION2(ok, cx, false, "js_pluginx_protocols_ProtocolShare_configDeveloperInfo : Error processing arguments");
  918. cobj->configDeveloperInfo(arg0);
  919. args.rval().setUndefined();
  920. return true;
  921. }
  922. JS_ReportError(cx, "js_pluginx_protocols_ProtocolShare_configDeveloperInfo : wrong number of arguments: %d, was expecting %d", argc, 1);
  923. return false;
  924. }
  925. extern JSObject *jsb_cocos2d_plugin_PluginProtocol_prototype;
  926. void js_cocos2d_plugin_ProtocolShare_finalize(JSFreeOp *fop, JSObject *obj) {
  927. CCLOGINFO("jsbindings: finalizing JS object %p (ProtocolShare)", obj);
  928. js_proxy_t* nproxy;
  929. js_proxy_t* jsproxy;
  930. jsproxy = jsb_get_js_proxy(obj);
  931. if (jsproxy) {
  932. nproxy = jsb_get_native_proxy(jsproxy->ptr);
  933. cocos2d::plugin::ProtocolShare *nobj = static_cast<cocos2d::plugin::ProtocolShare *>(nproxy->ptr);
  934. if (nobj)
  935. delete nobj;
  936. jsb_remove_proxy(nproxy, jsproxy);
  937. }
  938. }
  939. void js_register_pluginx_protocols_ProtocolShare(JSContext *cx, JS::HandleObject global) {
  940. jsb_cocos2d_plugin_ProtocolShare_class = (JSClass *)calloc(1, sizeof(JSClass));
  941. jsb_cocos2d_plugin_ProtocolShare_class->name = "ProtocolShare";
  942. jsb_cocos2d_plugin_ProtocolShare_class->addProperty = JS_PropertyStub;
  943. jsb_cocos2d_plugin_ProtocolShare_class->delProperty = JS_DeletePropertyStub;
  944. jsb_cocos2d_plugin_ProtocolShare_class->getProperty = JS_PropertyStub;
  945. jsb_cocos2d_plugin_ProtocolShare_class->setProperty = JS_StrictPropertyStub;
  946. jsb_cocos2d_plugin_ProtocolShare_class->enumerate = JS_EnumerateStub;
  947. jsb_cocos2d_plugin_ProtocolShare_class->resolve = JS_ResolveStub;
  948. jsb_cocos2d_plugin_ProtocolShare_class->convert = JS_ConvertStub;
  949. jsb_cocos2d_plugin_ProtocolShare_class->finalize = js_cocos2d_plugin_ProtocolShare_finalize;
  950. jsb_cocos2d_plugin_ProtocolShare_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2);
  951. static JSPropertySpec properties[] = {
  952. JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  953. JS_PS_END
  954. };
  955. static JSFunctionSpec funcs[] = {
  956. JS_FN("onShareResult", js_pluginx_protocols_ProtocolShare_onShareResult, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  957. JS_FN("getCallback", js_pluginx_protocols_ProtocolShare_getCallback, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  958. JS_FN("configDeveloperInfo", js_pluginx_protocols_ProtocolShare_configDeveloperInfo, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  959. JS_FS_END
  960. };
  961. JSFunctionSpec *st_funcs = NULL;
  962. jsb_cocos2d_plugin_ProtocolShare_prototype = JS_InitClass(
  963. cx, global,
  964. JS::RootedObject(cx, jsb_cocos2d_plugin_PluginProtocol_prototype),
  965. jsb_cocos2d_plugin_ProtocolShare_class,
  966. empty_constructor, 0,
  967. properties,
  968. funcs,
  969. NULL, // no static properties
  970. st_funcs);
  971. // make the class enumerable in the registered namespace
  972. // bool found;
  973. //FIXME: Removed in Firefox v27
  974. // JS_SetPropertyAttributes(cx, global, "ProtocolShare", JSPROP_ENUMERATE | JSPROP_READONLY, &found);
  975. // add the proto and JSClass to the type->js info hash table
  976. TypeTest<cocos2d::plugin::ProtocolShare> t;
  977. js_type_class_t *p;
  978. std::string typeName = t.s_name();
  979. if (_js_global_type_map.find(typeName) == _js_global_type_map.end())
  980. {
  981. p = (js_type_class_t *)malloc(sizeof(js_type_class_t));
  982. p->jsclass = jsb_cocos2d_plugin_ProtocolShare_class;
  983. p->proto = jsb_cocos2d_plugin_ProtocolShare_prototype;
  984. p->parentProto = jsb_cocos2d_plugin_PluginProtocol_prototype;
  985. _js_global_type_map.insert(std::make_pair(typeName, p));
  986. }
  987. }
  988. JSClass *jsb_cocos2d_plugin_ProtocolSocial_class;
  989. JSObject *jsb_cocos2d_plugin_ProtocolSocial_prototype;
  990. bool js_pluginx_protocols_ProtocolSocial_showLeaderboard(JSContext *cx, uint32_t argc, jsval *vp)
  991. {
  992. JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
  993. bool ok = true;
  994. JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
  995. js_proxy_t *proxy = jsb_get_js_proxy(obj);
  996. cocos2d::plugin::ProtocolSocial* cobj = (cocos2d::plugin::ProtocolSocial *)(proxy ? proxy->ptr : NULL);
  997. JSB_PRECONDITION2( cobj, cx, false, "js_pluginx_protocols_ProtocolSocial_showLeaderboard : Invalid Native Object");
  998. if (argc == 1) {
  999. const char* arg0;
  1000. std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str();
  1001. JSB_PRECONDITION2(ok, cx, false, "js_pluginx_protocols_ProtocolSocial_showLeaderboard : Error processing arguments");
  1002. cobj->showLeaderboard(arg0);
  1003. args.rval().setUndefined();
  1004. return true;
  1005. }
  1006. JS_ReportError(cx, "js_pluginx_protocols_ProtocolSocial_showLeaderboard : wrong number of arguments: %d, was expecting %d", argc, 1);
  1007. return false;
  1008. }
  1009. bool js_pluginx_protocols_ProtocolSocial_showAchievements(JSContext *cx, uint32_t argc, jsval *vp)
  1010. {
  1011. JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
  1012. JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
  1013. js_proxy_t *proxy = jsb_get_js_proxy(obj);
  1014. cocos2d::plugin::ProtocolSocial* cobj = (cocos2d::plugin::ProtocolSocial *)(proxy ? proxy->ptr : NULL);
  1015. JSB_PRECONDITION2( cobj, cx, false, "js_pluginx_protocols_ProtocolSocial_showAchievements : Invalid Native Object");
  1016. if (argc == 0) {
  1017. cobj->showAchievements();
  1018. args.rval().setUndefined();
  1019. return true;
  1020. }
  1021. JS_ReportError(cx, "js_pluginx_protocols_ProtocolSocial_showAchievements : wrong number of arguments: %d, was expecting %d", argc, 0);
  1022. return false;
  1023. }
  1024. bool js_pluginx_protocols_ProtocolSocial_getCallback(JSContext *cx, uint32_t argc, jsval *vp)
  1025. {
  1026. JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
  1027. JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
  1028. js_proxy_t *proxy = jsb_get_js_proxy(obj);
  1029. cocos2d::plugin::ProtocolSocial* cobj = (cocos2d::plugin::ProtocolSocial *)(proxy ? proxy->ptr : NULL);
  1030. JSB_PRECONDITION2( cobj, cx, false, "js_pluginx_protocols_ProtocolSocial_getCallback : Invalid Native Object");
  1031. if (argc == 0) {
  1032. std::function<void (int, std::basic_string<char> &)>& ret = cobj->getCallback();
  1033. jsval jsret = JSVAL_NULL;
  1034. #pragma warning NO CONVERSION FROM NATIVE FOR std::function;
  1035. args.rval().set(jsret);
  1036. return true;
  1037. }
  1038. JS_ReportError(cx, "js_pluginx_protocols_ProtocolSocial_getCallback : wrong number of arguments: %d, was expecting %d", argc, 0);
  1039. return false;
  1040. }
  1041. bool js_pluginx_protocols_ProtocolSocial_configDeveloperInfo(JSContext *cx, uint32_t argc, jsval *vp)
  1042. {
  1043. JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
  1044. bool ok = true;
  1045. JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
  1046. js_proxy_t *proxy = jsb_get_js_proxy(obj);
  1047. cocos2d::plugin::ProtocolSocial* cobj = (cocos2d::plugin::ProtocolSocial *)(proxy ? proxy->ptr : NULL);
  1048. JSB_PRECONDITION2( cobj, cx, false, "js_pluginx_protocols_ProtocolSocial_configDeveloperInfo : Invalid Native Object");
  1049. if (argc == 1) {
  1050. std::map<std::string, std::string> arg0;
  1051. ok &= jsval_to_std_map_string_string(cx, args.get(0), &arg0);
  1052. JSB_PRECONDITION2(ok, cx, false, "js_pluginx_protocols_ProtocolSocial_configDeveloperInfo : Error processing arguments");
  1053. cobj->configDeveloperInfo(arg0);
  1054. args.rval().setUndefined();
  1055. return true;
  1056. }
  1057. JS_ReportError(cx, "js_pluginx_protocols_ProtocolSocial_configDeveloperInfo : wrong number of arguments: %d, was expecting %d", argc, 1);
  1058. return false;
  1059. }
  1060. extern JSObject *jsb_cocos2d_plugin_PluginProtocol_prototype;
  1061. void js_cocos2d_plugin_ProtocolSocial_finalize(JSFreeOp *fop, JSObject *obj) {
  1062. CCLOGINFO("jsbindings: finalizing JS object %p (ProtocolSocial)", obj);
  1063. js_proxy_t* nproxy;
  1064. js_proxy_t* jsproxy;
  1065. jsproxy = jsb_get_js_proxy(obj);
  1066. if (jsproxy) {
  1067. nproxy = jsb_get_native_proxy(jsproxy->ptr);
  1068. cocos2d::plugin::ProtocolSocial *nobj = static_cast<cocos2d::plugin::ProtocolSocial *>(nproxy->ptr);
  1069. if (nobj)
  1070. delete nobj;
  1071. jsb_remove_proxy(nproxy, jsproxy);
  1072. }
  1073. }
  1074. void js_register_pluginx_protocols_ProtocolSocial(JSContext *cx, JS::HandleObject global) {
  1075. jsb_cocos2d_plugin_ProtocolSocial_class = (JSClass *)calloc(1, sizeof(JSClass));
  1076. jsb_cocos2d_plugin_ProtocolSocial_class->name = "ProtocolSocial";
  1077. jsb_cocos2d_plugin_ProtocolSocial_class->addProperty = JS_PropertyStub;
  1078. jsb_cocos2d_plugin_ProtocolSocial_class->delProperty = JS_DeletePropertyStub;
  1079. jsb_cocos2d_plugin_ProtocolSocial_class->getProperty = JS_PropertyStub;
  1080. jsb_cocos2d_plugin_ProtocolSocial_class->setProperty = JS_StrictPropertyStub;
  1081. jsb_cocos2d_plugin_ProtocolSocial_class->enumerate = JS_EnumerateStub;
  1082. jsb_cocos2d_plugin_ProtocolSocial_class->resolve = JS_ResolveStub;
  1083. jsb_cocos2d_plugin_ProtocolSocial_class->convert = JS_ConvertStub;
  1084. jsb_cocos2d_plugin_ProtocolSocial_class->finalize = js_cocos2d_plugin_ProtocolSocial_finalize;
  1085. jsb_cocos2d_plugin_ProtocolSocial_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2);
  1086. static JSPropertySpec properties[] = {
  1087. JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  1088. JS_PS_END
  1089. };
  1090. static JSFunctionSpec funcs[] = {
  1091. JS_FN("showLeaderboard", js_pluginx_protocols_ProtocolSocial_showLeaderboard, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  1092. JS_FN("showAchievements", js_pluginx_protocols_ProtocolSocial_showAchievements, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  1093. JS_FN("getCallback", js_pluginx_protocols_ProtocolSocial_getCallback, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  1094. JS_FN("configDeveloperInfo", js_pluginx_protocols_ProtocolSocial_configDeveloperInfo, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  1095. JS_FS_END
  1096. };
  1097. JSFunctionSpec *st_funcs = NULL;
  1098. jsb_cocos2d_plugin_ProtocolSocial_prototype = JS_InitClass(
  1099. cx, global,
  1100. JS::RootedObject(cx, jsb_cocos2d_plugin_PluginProtocol_prototype),
  1101. jsb_cocos2d_plugin_ProtocolSocial_class,
  1102. empty_constructor, 0,
  1103. properties,
  1104. funcs,
  1105. NULL, // no static properties
  1106. st_funcs);
  1107. // make the class enumerable in the registered namespace
  1108. // bool found;
  1109. //FIXME: Removed in Firefox v27
  1110. // JS_SetPropertyAttributes(cx, global, "ProtocolSocial", JSPROP_ENUMERATE | JSPROP_READONLY, &found);
  1111. // add the proto and JSClass to the type->js info hash table
  1112. TypeTest<cocos2d::plugin::ProtocolSocial> t;
  1113. js_type_class_t *p;
  1114. std::string typeName = t.s_name();
  1115. if (_js_global_type_map.find(typeName) == _js_global_type_map.end())
  1116. {
  1117. p = (js_type_class_t *)malloc(sizeof(js_type_class_t));
  1118. p->jsclass = jsb_cocos2d_plugin_ProtocolSocial_class;
  1119. p->proto = jsb_cocos2d_plugin_ProtocolSocial_prototype;
  1120. p->parentProto = jsb_cocos2d_plugin_PluginProtocol_prototype;
  1121. _js_global_type_map.insert(std::make_pair(typeName, p));
  1122. }
  1123. }
  1124. JSClass *jsb_cocos2d_plugin_ProtocolUser_class;
  1125. JSObject *jsb_cocos2d_plugin_ProtocolUser_prototype;
  1126. bool js_pluginx_protocols_ProtocolUser_getCallback(JSContext *cx, uint32_t argc, jsval *vp)
  1127. {
  1128. JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
  1129. JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
  1130. js_proxy_t *proxy = jsb_get_js_proxy(obj);
  1131. cocos2d::plugin::ProtocolUser* cobj = (cocos2d::plugin::ProtocolUser *)(proxy ? proxy->ptr : NULL);
  1132. JSB_PRECONDITION2( cobj, cx, false, "js_pluginx_protocols_ProtocolUser_getCallback : Invalid Native Object");
  1133. if (argc == 0) {
  1134. std::function<void (int, std::basic_string<char> &)>& ret = cobj->getCallback();
  1135. jsval jsret = JSVAL_NULL;
  1136. #pragma warning NO CONVERSION FROM NATIVE FOR std::function;
  1137. args.rval().set(jsret);
  1138. return true;
  1139. }
  1140. JS_ReportError(cx, "js_pluginx_protocols_ProtocolUser_getCallback : wrong number of arguments: %d, was expecting %d", argc, 0);
  1141. return false;
  1142. }
  1143. bool js_pluginx_protocols_ProtocolUser_configDeveloperInfo(JSContext *cx, uint32_t argc, jsval *vp)
  1144. {
  1145. JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
  1146. bool ok = true;
  1147. JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
  1148. js_proxy_t *proxy = jsb_get_js_proxy(obj);
  1149. cocos2d::plugin::ProtocolUser* cobj = (cocos2d::plugin::ProtocolUser *)(proxy ? proxy->ptr : NULL);
  1150. JSB_PRECONDITION2( cobj, cx, false, "js_pluginx_protocols_ProtocolUser_configDeveloperInfo : Invalid Native Object");
  1151. if (argc == 1) {
  1152. std::map<std::string, std::string> arg0;
  1153. ok &= jsval_to_std_map_string_string(cx, args.get(0), &arg0);
  1154. JSB_PRECONDITION2(ok, cx, false, "js_pluginx_protocols_ProtocolUser_configDeveloperInfo : Error processing arguments");
  1155. cobj->configDeveloperInfo(arg0);
  1156. args.rval().setUndefined();
  1157. return true;
  1158. }
  1159. JS_ReportError(cx, "js_pluginx_protocols_ProtocolUser_configDeveloperInfo : wrong number of arguments: %d, was expecting %d", argc, 1);
  1160. return false;
  1161. }
  1162. bool js_pluginx_protocols_ProtocolUser_isLoggedIn(JSContext *cx, uint32_t argc, jsval *vp)
  1163. {
  1164. JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
  1165. JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
  1166. js_proxy_t *proxy = jsb_get_js_proxy(obj);
  1167. cocos2d::plugin::ProtocolUser* cobj = (cocos2d::plugin::ProtocolUser *)(proxy ? proxy->ptr : NULL);
  1168. JSB_PRECONDITION2( cobj, cx, false, "js_pluginx_protocols_ProtocolUser_isLoggedIn : Invalid Native Object");
  1169. if (argc == 0) {
  1170. bool ret = cobj->isLoggedIn();
  1171. jsval jsret = JSVAL_NULL;
  1172. jsret = BOOLEAN_TO_JSVAL(ret);
  1173. args.rval().set(jsret);
  1174. return true;
  1175. }
  1176. JS_ReportError(cx, "js_pluginx_protocols_ProtocolUser_isLoggedIn : wrong number of arguments: %d, was expecting %d", argc, 0);
  1177. return false;
  1178. }
  1179. bool js_pluginx_protocols_ProtocolUser_getSessionID(JSContext *cx, uint32_t argc, jsval *vp)
  1180. {
  1181. JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
  1182. JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
  1183. js_proxy_t *proxy = jsb_get_js_proxy(obj);
  1184. cocos2d::plugin::ProtocolUser* cobj = (cocos2d::plugin::ProtocolUser *)(proxy ? proxy->ptr : NULL);
  1185. JSB_PRECONDITION2( cobj, cx, false, "js_pluginx_protocols_ProtocolUser_getSessionID : Invalid Native Object");
  1186. if (argc == 0) {
  1187. std::string ret = cobj->getSessionID();
  1188. jsval jsret = JSVAL_NULL;
  1189. jsret = std_string_to_jsval(cx, ret);
  1190. args.rval().set(jsret);
  1191. return true;
  1192. }
  1193. JS_ReportError(cx, "js_pluginx_protocols_ProtocolUser_getSessionID : wrong number of arguments: %d, was expecting %d", argc, 0);
  1194. return false;
  1195. }
  1196. bool js_pluginx_protocols_ProtocolUser_getAccessToken(JSContext *cx, uint32_t argc, jsval *vp)
  1197. {
  1198. JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
  1199. JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
  1200. js_proxy_t *proxy = jsb_get_js_proxy(obj);
  1201. cocos2d::plugin::ProtocolUser* cobj = (cocos2d::plugin::ProtocolUser *)(proxy ? proxy->ptr : NULL);
  1202. JSB_PRECONDITION2( cobj, cx, false, "js_pluginx_protocols_ProtocolUser_getAccessToken : Invalid Native Object");
  1203. if (argc == 0) {
  1204. std::string ret = cobj->getAccessToken();
  1205. jsval jsret = JSVAL_NULL;
  1206. jsret = std_string_to_jsval(cx, ret);
  1207. args.rval().set(jsret);
  1208. return true;
  1209. }
  1210. JS_ReportError(cx, "js_pluginx_protocols_ProtocolUser_getAccessToken : wrong number of arguments: %d, was expecting %d", argc, 0);
  1211. return false;
  1212. }
  1213. extern JSObject *jsb_cocos2d_plugin_PluginProtocol_prototype;
  1214. void js_cocos2d_plugin_ProtocolUser_finalize(JSFreeOp *fop, JSObject *obj) {
  1215. CCLOGINFO("jsbindings: finalizing JS object %p (ProtocolUser)", obj);
  1216. js_proxy_t* nproxy;
  1217. js_proxy_t* jsproxy;
  1218. jsproxy = jsb_get_js_proxy(obj);
  1219. if (jsproxy) {
  1220. nproxy = jsb_get_native_proxy(jsproxy->ptr);
  1221. cocos2d::plugin::ProtocolUser *nobj = static_cast<cocos2d::plugin::ProtocolUser *>(nproxy->ptr);
  1222. if (nobj)
  1223. delete nobj;
  1224. jsb_remove_proxy(nproxy, jsproxy);
  1225. }
  1226. }
  1227. void js_register_pluginx_protocols_ProtocolUser(JSContext *cx, JS::HandleObject global) {
  1228. jsb_cocos2d_plugin_ProtocolUser_class = (JSClass *)calloc(1, sizeof(JSClass));
  1229. jsb_cocos2d_plugin_ProtocolUser_class->name = "ProtocolUser";
  1230. jsb_cocos2d_plugin_ProtocolUser_class->addProperty = JS_PropertyStub;
  1231. jsb_cocos2d_plugin_ProtocolUser_class->delProperty = JS_DeletePropertyStub;
  1232. jsb_cocos2d_plugin_ProtocolUser_class->getProperty = JS_PropertyStub;
  1233. jsb_cocos2d_plugin_ProtocolUser_class->setProperty = JS_StrictPropertyStub;
  1234. jsb_cocos2d_plugin_ProtocolUser_class->enumerate = JS_EnumerateStub;
  1235. jsb_cocos2d_plugin_ProtocolUser_class->resolve = JS_ResolveStub;
  1236. jsb_cocos2d_plugin_ProtocolUser_class->convert = JS_ConvertStub;
  1237. jsb_cocos2d_plugin_ProtocolUser_class->finalize = js_cocos2d_plugin_ProtocolUser_finalize;
  1238. jsb_cocos2d_plugin_ProtocolUser_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2);
  1239. static JSPropertySpec properties[] = {
  1240. JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  1241. JS_PS_END
  1242. };
  1243. static JSFunctionSpec funcs[] = {
  1244. JS_FN("getCallback", js_pluginx_protocols_ProtocolUser_getCallback, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  1245. JS_FN("configDeveloperInfo", js_pluginx_protocols_ProtocolUser_configDeveloperInfo, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  1246. JS_FN("isLoggedIn", js_pluginx_protocols_ProtocolUser_isLoggedIn, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  1247. JS_FN("getSessionID", js_pluginx_protocols_ProtocolUser_getSessionID, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  1248. JS_FN("getAccessToken", js_pluginx_protocols_ProtocolUser_getAccessToken, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  1249. JS_FS_END
  1250. };
  1251. JSFunctionSpec *st_funcs = NULL;
  1252. jsb_cocos2d_plugin_ProtocolUser_prototype = JS_InitClass(
  1253. cx, global,
  1254. JS::RootedObject(cx, jsb_cocos2d_plugin_PluginProtocol_prototype),
  1255. jsb_cocos2d_plugin_ProtocolUser_class,
  1256. empty_constructor, 0,
  1257. properties,
  1258. funcs,
  1259. NULL, // no static properties
  1260. st_funcs);
  1261. // make the class enumerable in the registered namespace
  1262. // bool found;
  1263. //FIXME: Removed in Firefox v27
  1264. // JS_SetPropertyAttributes(cx, global, "ProtocolUser", JSPROP_ENUMERATE | JSPROP_READONLY, &found);
  1265. // add the proto and JSClass to the type->js info hash table
  1266. TypeTest<cocos2d::plugin::ProtocolUser> t;
  1267. js_type_class_t *p;
  1268. std::string typeName = t.s_name();
  1269. if (_js_global_type_map.find(typeName) == _js_global_type_map.end())
  1270. {
  1271. p = (js_type_class_t *)malloc(sizeof(js_type_class_t));
  1272. p->jsclass = jsb_cocos2d_plugin_ProtocolUser_class;
  1273. p->proto = jsb_cocos2d_plugin_ProtocolUser_prototype;
  1274. p->parentProto = jsb_cocos2d_plugin_PluginProtocol_prototype;
  1275. _js_global_type_map.insert(std::make_pair(typeName, p));
  1276. }
  1277. }
  1278. JSClass *jsb_cocos2d_plugin_AgentManager_class;
  1279. JSObject *jsb_cocos2d_plugin_AgentManager_prototype;
  1280. bool js_pluginx_protocols_AgentManager_getSocialPlugin(JSContext *cx, uint32_t argc, jsval *vp)
  1281. {
  1282. JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
  1283. JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
  1284. js_proxy_t *proxy = jsb_get_js_proxy(obj);
  1285. cocos2d::plugin::AgentManager* cobj = (cocos2d::plugin::AgentManager *)(proxy ? proxy->ptr : NULL);
  1286. JSB_PRECONDITION2( cobj, cx, false, "js_pluginx_protocols_AgentManager_getSocialPlugin : Invalid Native Object");
  1287. if (argc == 0) {
  1288. cocos2d::plugin::ProtocolSocial* ret = cobj->getSocialPlugin();
  1289. jsval jsret = JSVAL_NULL;
  1290. do {
  1291. if (ret) {
  1292. js_proxy_t *jsProxy = js_get_or_create_proxy<cocos2d::plugin::ProtocolSocial>(cx, (cocos2d::plugin::ProtocolSocial*)ret);
  1293. jsret = OBJECT_TO_JSVAL(jsProxy->obj);
  1294. } else {
  1295. jsret = JSVAL_NULL;
  1296. }
  1297. } while (0);
  1298. args.rval().set(jsret);
  1299. return true;
  1300. }
  1301. JS_ReportError(cx, "js_pluginx_protocols_AgentManager_getSocialPlugin : wrong number of arguments: %d, was expecting %d", argc, 0);
  1302. return false;
  1303. }
  1304. bool js_pluginx_protocols_AgentManager_getAdsPlugin(JSContext *cx, uint32_t argc, jsval *vp)
  1305. {
  1306. JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
  1307. JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
  1308. js_proxy_t *proxy = jsb_get_js_proxy(obj);
  1309. cocos2d::plugin::AgentManager* cobj = (cocos2d::plugin::AgentManager *)(proxy ? proxy->ptr : NULL);
  1310. JSB_PRECONDITION2( cobj, cx, false, "js_pluginx_protocols_AgentManager_getAdsPlugin : Invalid Native Object");
  1311. if (argc == 0) {
  1312. cocos2d::plugin::ProtocolAds* ret = cobj->getAdsPlugin();
  1313. jsval jsret = JSVAL_NULL;
  1314. do {
  1315. if (ret) {
  1316. js_proxy_t *jsProxy = js_get_or_create_proxy<cocos2d::plugin::ProtocolAds>(cx, (cocos2d::plugin::ProtocolAds*)ret);
  1317. jsret = OBJECT_TO_JSVAL(jsProxy->obj);
  1318. } else {
  1319. jsret = JSVAL_NULL;
  1320. }
  1321. } while (0);
  1322. args.rval().set(jsret);
  1323. return true;
  1324. }
  1325. JS_ReportError(cx, "js_pluginx_protocols_AgentManager_getAdsPlugin : wrong number of arguments: %d, was expecting %d", argc, 0);
  1326. return false;
  1327. }
  1328. bool js_pluginx_protocols_AgentManager_purge(JSContext *cx, uint32_t argc, jsval *vp)
  1329. {
  1330. JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
  1331. JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
  1332. js_proxy_t *proxy = jsb_get_js_proxy(obj);
  1333. cocos2d::plugin::AgentManager* cobj = (cocos2d::plugin::AgentManager *)(proxy ? proxy->ptr : NULL);
  1334. JSB_PRECONDITION2( cobj, cx, false, "js_pluginx_protocols_AgentManager_purge : Invalid Native Object");
  1335. if (argc == 0) {
  1336. cobj->purge();
  1337. args.rval().setUndefined();
  1338. return true;
  1339. }
  1340. JS_ReportError(cx, "js_pluginx_protocols_AgentManager_purge : wrong number of arguments: %d, was expecting %d", argc, 0);
  1341. return false;
  1342. }
  1343. bool js_pluginx_protocols_AgentManager_getUserPlugin(JSContext *cx, uint32_t argc, jsval *vp)
  1344. {
  1345. JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
  1346. JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
  1347. js_proxy_t *proxy = jsb_get_js_proxy(obj);
  1348. cocos2d::plugin::AgentManager* cobj = (cocos2d::plugin::AgentManager *)(proxy ? proxy->ptr : NULL);
  1349. JSB_PRECONDITION2( cobj, cx, false, "js_pluginx_protocols_AgentManager_getUserPlugin : Invalid Native Object");
  1350. if (argc == 0) {
  1351. cocos2d::plugin::ProtocolUser* ret = cobj->getUserPlugin();
  1352. jsval jsret = JSVAL_NULL;
  1353. do {
  1354. if (ret) {
  1355. js_proxy_t *jsProxy = js_get_or_create_proxy<cocos2d::plugin::ProtocolUser>(cx, (cocos2d::plugin::ProtocolUser*)ret);
  1356. jsret = OBJECT_TO_JSVAL(jsProxy->obj);
  1357. } else {
  1358. jsret = JSVAL_NULL;
  1359. }
  1360. } while (0);
  1361. args.rval().set(jsret);
  1362. return true;
  1363. }
  1364. JS_ReportError(cx, "js_pluginx_protocols_AgentManager_getUserPlugin : wrong number of arguments: %d, was expecting %d", argc, 0);
  1365. return false;
  1366. }
  1367. bool js_pluginx_protocols_AgentManager_getIAPPlugin(JSContext *cx, uint32_t argc, jsval *vp)
  1368. {
  1369. JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
  1370. JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
  1371. js_proxy_t *proxy = jsb_get_js_proxy(obj);
  1372. cocos2d::plugin::AgentManager* cobj = (cocos2d::plugin::AgentManager *)(proxy ? proxy->ptr : NULL);
  1373. JSB_PRECONDITION2( cobj, cx, false, "js_pluginx_protocols_AgentManager_getIAPPlugin : Invalid Native Object");
  1374. if (argc == 0) {
  1375. cocos2d::plugin::ProtocolIAP* ret = cobj->getIAPPlugin();
  1376. jsval jsret = JSVAL_NULL;
  1377. do {
  1378. if (ret) {
  1379. js_proxy_t *jsProxy = js_get_or_create_proxy<cocos2d::plugin::ProtocolIAP>(cx, (cocos2d::plugin::ProtocolIAP*)ret);
  1380. jsret = OBJECT_TO_JSVAL(jsProxy->obj);
  1381. } else {
  1382. jsret = JSVAL_NULL;
  1383. }
  1384. } while (0);
  1385. args.rval().set(jsret);
  1386. return true;
  1387. }
  1388. JS_ReportError(cx, "js_pluginx_protocols_AgentManager_getIAPPlugin : wrong number of arguments: %d, was expecting %d", argc, 0);
  1389. return false;
  1390. }
  1391. bool js_pluginx_protocols_AgentManager_getSharePlugin(JSContext *cx, uint32_t argc, jsval *vp)
  1392. {
  1393. JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
  1394. JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
  1395. js_proxy_t *proxy = jsb_get_js_proxy(obj);
  1396. cocos2d::plugin::AgentManager* cobj = (cocos2d::plugin::AgentManager *)(proxy ? proxy->ptr : NULL);
  1397. JSB_PRECONDITION2( cobj, cx, false, "js_pluginx_protocols_AgentManager_getSharePlugin : Invalid Native Object");
  1398. if (argc == 0) {
  1399. cocos2d::plugin::ProtocolShare* ret = cobj->getSharePlugin();
  1400. jsval jsret = JSVAL_NULL;
  1401. do {
  1402. if (ret) {
  1403. js_proxy_t *jsProxy = js_get_or_create_proxy<cocos2d::plugin::ProtocolShare>(cx, (cocos2d::plugin::ProtocolShare*)ret);
  1404. jsret = OBJECT_TO_JSVAL(jsProxy->obj);
  1405. } else {
  1406. jsret = JSVAL_NULL;
  1407. }
  1408. } while (0);
  1409. args.rval().set(jsret);
  1410. return true;
  1411. }
  1412. JS_ReportError(cx, "js_pluginx_protocols_AgentManager_getSharePlugin : wrong number of arguments: %d, was expecting %d", argc, 0);
  1413. return false;
  1414. }
  1415. bool js_pluginx_protocols_AgentManager_getAnalyticsPlugin(JSContext *cx, uint32_t argc, jsval *vp)
  1416. {
  1417. JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
  1418. JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
  1419. js_proxy_t *proxy = jsb_get_js_proxy(obj);
  1420. cocos2d::plugin::AgentManager* cobj = (cocos2d::plugin::AgentManager *)(proxy ? proxy->ptr : NULL);
  1421. JSB_PRECONDITION2( cobj, cx, false, "js_pluginx_protocols_AgentManager_getAnalyticsPlugin : Invalid Native Object");
  1422. if (argc == 0) {
  1423. cocos2d::plugin::ProtocolAnalytics* ret = cobj->getAnalyticsPlugin();
  1424. jsval jsret = JSVAL_NULL;
  1425. do {
  1426. if (ret) {
  1427. js_proxy_t *jsProxy = js_get_or_create_proxy<cocos2d::plugin::ProtocolAnalytics>(cx, (cocos2d::plugin::ProtocolAnalytics*)ret);
  1428. jsret = OBJECT_TO_JSVAL(jsProxy->obj);
  1429. } else {
  1430. jsret = JSVAL_NULL;
  1431. }
  1432. } while (0);
  1433. args.rval().set(jsret);
  1434. return true;
  1435. }
  1436. JS_ReportError(cx, "js_pluginx_protocols_AgentManager_getAnalyticsPlugin : wrong number of arguments: %d, was expecting %d", argc, 0);
  1437. return false;
  1438. }
  1439. bool js_pluginx_protocols_AgentManager_destroyInstance(JSContext *cx, uint32_t argc, jsval *vp)
  1440. {
  1441. JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
  1442. if (argc == 0) {
  1443. cocos2d::plugin::AgentManager::destroyInstance();
  1444. args.rval().setUndefined();
  1445. return true;
  1446. }
  1447. JS_ReportError(cx, "js_pluginx_protocols_AgentManager_destroyInstance : wrong number of arguments");
  1448. return false;
  1449. }
  1450. bool js_pluginx_protocols_AgentManager_getInstance(JSContext *cx, uint32_t argc, jsval *vp)
  1451. {
  1452. JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
  1453. if (argc == 0) {
  1454. cocos2d::plugin::AgentManager* ret = cocos2d::plugin::AgentManager::getInstance();
  1455. jsval jsret = JSVAL_NULL;
  1456. do {
  1457. if (ret) {
  1458. js_proxy_t *jsProxy = js_get_or_create_proxy<cocos2d::plugin::AgentManager>(cx, (cocos2d::plugin::AgentManager*)ret);
  1459. jsret = OBJECT_TO_JSVAL(jsProxy->obj);
  1460. } else {
  1461. jsret = JSVAL_NULL;
  1462. }
  1463. } while (0);
  1464. args.rval().set(jsret);
  1465. return true;
  1466. }
  1467. JS_ReportError(cx, "js_pluginx_protocols_AgentManager_getInstance : wrong number of arguments");
  1468. return false;
  1469. }
  1470. void js_cocos2d_plugin_AgentManager_finalize(JSFreeOp *fop, JSObject *obj) {
  1471. CCLOGINFO("jsbindings: finalizing JS object %p (AgentManager)", obj);
  1472. js_proxy_t* nproxy;
  1473. js_proxy_t* jsproxy;
  1474. jsproxy = jsb_get_js_proxy(obj);
  1475. if (jsproxy) {
  1476. nproxy = jsb_get_native_proxy(jsproxy->ptr);
  1477. cocos2d::plugin::AgentManager *nobj = static_cast<cocos2d::plugin::AgentManager *>(nproxy->ptr);
  1478. if (nobj)
  1479. delete nobj;
  1480. jsb_remove_proxy(nproxy, jsproxy);
  1481. }
  1482. }
  1483. void js_register_pluginx_protocols_AgentManager(JSContext *cx, JS::HandleObject global) {
  1484. jsb_cocos2d_plugin_AgentManager_class = (JSClass *)calloc(1, sizeof(JSClass));
  1485. jsb_cocos2d_plugin_AgentManager_class->name = "AgentManager";
  1486. jsb_cocos2d_plugin_AgentManager_class->addProperty = JS_PropertyStub;
  1487. jsb_cocos2d_plugin_AgentManager_class->delProperty = JS_DeletePropertyStub;
  1488. jsb_cocos2d_plugin_AgentManager_class->getProperty = JS_PropertyStub;
  1489. jsb_cocos2d_plugin_AgentManager_class->setProperty = JS_StrictPropertyStub;
  1490. jsb_cocos2d_plugin_AgentManager_class->enumerate = JS_EnumerateStub;
  1491. jsb_cocos2d_plugin_AgentManager_class->resolve = JS_ResolveStub;
  1492. jsb_cocos2d_plugin_AgentManager_class->convert = JS_ConvertStub;
  1493. jsb_cocos2d_plugin_AgentManager_class->finalize = js_cocos2d_plugin_AgentManager_finalize;
  1494. jsb_cocos2d_plugin_AgentManager_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2);
  1495. static JSPropertySpec properties[] = {
  1496. JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  1497. JS_PS_END
  1498. };
  1499. static JSFunctionSpec funcs[] = {
  1500. JS_FN("getSocialPlugin", js_pluginx_protocols_AgentManager_getSocialPlugin, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  1501. JS_FN("getAdsPlugin", js_pluginx_protocols_AgentManager_getAdsPlugin, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  1502. JS_FN("purge", js_pluginx_protocols_AgentManager_purge, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  1503. JS_FN("getUserPlugin", js_pluginx_protocols_AgentManager_getUserPlugin, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  1504. JS_FN("getIAPPlugin", js_pluginx_protocols_AgentManager_getIAPPlugin, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  1505. JS_FN("getSharePlugin", js_pluginx_protocols_AgentManager_getSharePlugin, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  1506. JS_FN("getAnalyticsPlugin", js_pluginx_protocols_AgentManager_getAnalyticsPlugin, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  1507. JS_FS_END
  1508. };
  1509. static JSFunctionSpec st_funcs[] = {
  1510. JS_FN("destroyInstance", js_pluginx_protocols_AgentManager_destroyInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  1511. JS_FN("getInstance", js_pluginx_protocols_AgentManager_getInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  1512. JS_FS_END
  1513. };
  1514. jsb_cocos2d_plugin_AgentManager_prototype = JS_InitClass(
  1515. cx, global,
  1516. JS::NullPtr(), // parent proto
  1517. jsb_cocos2d_plugin_AgentManager_class,
  1518. empty_constructor, 0,
  1519. properties,
  1520. funcs,
  1521. NULL, // no static properties
  1522. st_funcs);
  1523. // make the class enumerable in the registered namespace
  1524. // bool found;
  1525. //FIXME: Removed in Firefox v27
  1526. // JS_SetPropertyAttributes(cx, global, "AgentManager", JSPROP_ENUMERATE | JSPROP_READONLY, &found);
  1527. // add the proto and JSClass to the type->js info hash table
  1528. TypeTest<cocos2d::plugin::AgentManager> t;
  1529. js_type_class_t *p;
  1530. std::string typeName = t.s_name();
  1531. if (_js_global_type_map.find(typeName) == _js_global_type_map.end())
  1532. {
  1533. p = (js_type_class_t *)malloc(sizeof(js_type_class_t));
  1534. p->jsclass = jsb_cocos2d_plugin_AgentManager_class;
  1535. p->proto = jsb_cocos2d_plugin_AgentManager_prototype;
  1536. p->parentProto = NULL;
  1537. _js_global_type_map.insert(std::make_pair(typeName, p));
  1538. }
  1539. }
  1540. JSClass *jsb_cocos2d_plugin_FacebookAgent_class;
  1541. JSObject *jsb_cocos2d_plugin_FacebookAgent_prototype;
  1542. bool js_pluginx_protocols_FacebookAgent_activateApp(JSContext *cx, uint32_t argc, jsval *vp)
  1543. {
  1544. JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
  1545. JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
  1546. js_proxy_t *proxy = jsb_get_js_proxy(obj);
  1547. cocos2d::plugin::FacebookAgent* cobj = (cocos2d::plugin::FacebookAgent *)(proxy ? proxy->ptr : NULL);
  1548. JSB_PRECONDITION2( cobj, cx, false, "js_pluginx_protocols_FacebookAgent_activateApp : Invalid Native Object");
  1549. if (argc == 0) {
  1550. cobj->activateApp();
  1551. args.rval().setUndefined();
  1552. return true;
  1553. }
  1554. JS_ReportError(cx, "js_pluginx_protocols_FacebookAgent_activateApp : wrong number of arguments: %d, was expecting %d", argc, 0);
  1555. return false;
  1556. }
  1557. bool js_pluginx_protocols_FacebookAgent_getUserID(JSContext *cx, uint32_t argc, jsval *vp)
  1558. {
  1559. JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
  1560. JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
  1561. js_proxy_t *proxy = jsb_get_js_proxy(obj);
  1562. cocos2d::plugin::FacebookAgent* cobj = (cocos2d::plugin::FacebookAgent *)(proxy ? proxy->ptr : NULL);
  1563. JSB_PRECONDITION2( cobj, cx, false, "js_pluginx_protocols_FacebookAgent_getUserID : Invalid Native Object");
  1564. if (argc == 0) {
  1565. std::string ret = cobj->getUserID();
  1566. jsval jsret = JSVAL_NULL;
  1567. jsret = std_string_to_jsval(cx, ret);
  1568. args.rval().set(jsret);
  1569. return true;
  1570. }
  1571. JS_ReportError(cx, "js_pluginx_protocols_FacebookAgent_getUserID : wrong number of arguments: %d, was expecting %d", argc, 0);
  1572. return false;
  1573. }
  1574. bool js_pluginx_protocols_FacebookAgent_logEvent(JSContext *cx, uint32_t argc, jsval *vp)
  1575. {
  1576. JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
  1577. bool ok = true;
  1578. JS::RootedObject obj(cx);
  1579. cocos2d::plugin::FacebookAgent* cobj = NULL;
  1580. obj = args.thisv().toObjectOrNull();
  1581. js_proxy_t *proxy = jsb_get_js_proxy(obj);
  1582. cobj = (cocos2d::plugin::FacebookAgent *)(proxy ? proxy->ptr : NULL);
  1583. JSB_PRECONDITION2( cobj, cx, false, "js_pluginx_protocols_FacebookAgent_logEvent : Invalid Native Object");
  1584. do {
  1585. if (argc == 2) {
  1586. std::string arg0;
  1587. ok &= jsval_to_std_string(cx, args.get(0), &arg0);
  1588. if (!ok) { ok = true; break; }
  1589. double arg1;
  1590. ok &= JS::ToNumber( cx, JS::RootedValue(cx, args.get(1)), &arg1);
  1591. if (!ok) { ok = true; break; }
  1592. cobj->logEvent(arg0, arg1);
  1593. args.rval().setUndefined();
  1594. return true;
  1595. }
  1596. } while(0);
  1597. do {
  1598. if (argc == 1) {
  1599. std::string arg0;
  1600. ok &= jsval_to_std_string(cx, args.get(0), &arg0);
  1601. if (!ok) { ok = true; break; }
  1602. cobj->logEvent(arg0);
  1603. args.rval().setUndefined();
  1604. return true;
  1605. }
  1606. } while(0);
  1607. do {
  1608. if (argc == 2) {
  1609. std::string arg0;
  1610. ok &= jsval_to_std_string(cx, args.get(0), &arg0);
  1611. if (!ok) { ok = true; break; }
  1612. std::map<std::string, std::string> arg1;
  1613. ok &= jsval_to_std_map_string_string(cx, args.get(1), &arg1);
  1614. if (!ok) { ok = true; break; }
  1615. cobj->logEvent(arg0, arg1);
  1616. args.rval().setUndefined();
  1617. return true;
  1618. }
  1619. } while(0);
  1620. do {
  1621. if (argc == 3) {
  1622. std::string arg0;
  1623. ok &= jsval_to_std_string(cx, args.get(0), &arg0);
  1624. if (!ok) { ok = true; break; }
  1625. double arg1;
  1626. ok &= JS::ToNumber( cx, JS::RootedValue(cx, args.get(1)), &arg1);
  1627. if (!ok) { ok = true; break; }
  1628. std::map<std::string, std::string> arg2;
  1629. ok &= jsval_to_std_map_string_string(cx, args.get(2), &arg2);
  1630. if (!ok) { ok = true; break; }
  1631. cobj->logEvent(arg0, arg1, arg2);
  1632. args.rval().setUndefined();
  1633. return true;
  1634. }
  1635. } while(0);
  1636. JS_ReportError(cx, "js_pluginx_protocols_FacebookAgent_logEvent : wrong number of arguments");
  1637. return false;
  1638. }
  1639. bool js_pluginx_protocols_FacebookAgent_logout(JSContext *cx, uint32_t argc, jsval *vp)
  1640. {
  1641. JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
  1642. JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
  1643. js_proxy_t *proxy = jsb_get_js_proxy(obj);
  1644. cocos2d::plugin::FacebookAgent* cobj = (cocos2d::plugin::FacebookAgent *)(proxy ? proxy->ptr : NULL);
  1645. JSB_PRECONDITION2( cobj, cx, false, "js_pluginx_protocols_FacebookAgent_logout : Invalid Native Object");
  1646. if (argc == 0) {
  1647. cobj->logout();
  1648. args.rval().setUndefined();
  1649. return true;
  1650. }
  1651. JS_ReportError(cx, "js_pluginx_protocols_FacebookAgent_logout : wrong number of arguments: %d, was expecting %d", argc, 0);
  1652. return false;
  1653. }
  1654. bool js_pluginx_protocols_FacebookAgent_getSDKVersion(JSContext *cx, uint32_t argc, jsval *vp)
  1655. {
  1656. JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
  1657. JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
  1658. js_proxy_t *proxy = jsb_get_js_proxy(obj);
  1659. cocos2d::plugin::FacebookAgent* cobj = (cocos2d::plugin::FacebookAgent *)(proxy ? proxy->ptr : NULL);
  1660. JSB_PRECONDITION2( cobj, cx, false, "js_pluginx_protocols_FacebookAgent_getSDKVersion : Invalid Native Object");
  1661. if (argc == 0) {
  1662. std::string ret = cobj->getSDKVersion();
  1663. jsval jsret = JSVAL_NULL;
  1664. jsret = std_string_to_jsval(cx, ret);
  1665. args.rval().set(jsret);
  1666. return true;
  1667. }
  1668. JS_ReportError(cx, "js_pluginx_protocols_FacebookAgent_getSDKVersion : wrong number of arguments: %d, was expecting %d", argc, 0);
  1669. return false;
  1670. }
  1671. bool js_pluginx_protocols_FacebookAgent_logPurchase(JSContext *cx, uint32_t argc, jsval *vp)
  1672. {
  1673. JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
  1674. bool ok = true;
  1675. JS::RootedObject obj(cx);
  1676. cocos2d::plugin::FacebookAgent* cobj = NULL;
  1677. obj = args.thisv().toObjectOrNull();
  1678. js_proxy_t *proxy = jsb_get_js_proxy(obj);
  1679. cobj = (cocos2d::plugin::FacebookAgent *)(proxy ? proxy->ptr : NULL);
  1680. JSB_PRECONDITION2( cobj, cx, false, "js_pluginx_protocols_FacebookAgent_logPurchase : Invalid Native Object");
  1681. do {
  1682. if (argc == 3) {
  1683. double arg0;
  1684. ok &= JS::ToNumber( cx, JS::RootedValue(cx, args.get(0)), &arg0);
  1685. if (!ok) { ok = true; break; }
  1686. std::string arg1;
  1687. ok &= jsval_to_std_string(cx, args.get(1), &arg1);
  1688. if (!ok) { ok = true; break; }
  1689. std::map<std::string, std::string> arg2;
  1690. ok &= jsval_to_std_map_string_string(cx, args.get(2), &arg2);
  1691. if (!ok) { ok = true; break; }
  1692. cobj->logPurchase(arg0, arg1, arg2);
  1693. args.rval().setUndefined();
  1694. return true;
  1695. }
  1696. } while(0);
  1697. do {
  1698. if (argc == 2) {
  1699. double arg0;
  1700. ok &= JS::ToNumber( cx, JS::RootedValue(cx, args.get(0)), &arg0);
  1701. if (!ok) { ok = true; break; }
  1702. std::string arg1;
  1703. ok &= jsval_to_std_string(cx, args.get(1), &arg1);
  1704. if (!ok) { ok = true; break; }
  1705. cobj->logPurchase(arg0, arg1);
  1706. args.rval().setUndefined();
  1707. return true;
  1708. }
  1709. } while(0);
  1710. JS_ReportError(cx, "js_pluginx_protocols_FacebookAgent_logPurchase : wrong number of arguments");
  1711. return false;
  1712. }
  1713. bool js_pluginx_protocols_FacebookAgent_isLoggedIn(JSContext *cx, uint32_t argc, jsval *vp)
  1714. {
  1715. JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
  1716. JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
  1717. js_proxy_t *proxy = jsb_get_js_proxy(obj);
  1718. cocos2d::plugin::FacebookAgent* cobj = (cocos2d::plugin::FacebookAgent *)(proxy ? proxy->ptr : NULL);
  1719. JSB_PRECONDITION2( cobj, cx, false, "js_pluginx_protocols_FacebookAgent_isLoggedIn : Invalid Native Object");
  1720. if (argc == 0) {
  1721. bool ret = cobj->isLoggedIn();
  1722. jsval jsret = JSVAL_NULL;
  1723. jsret = BOOLEAN_TO_JSVAL(ret);
  1724. args.rval().set(jsret);
  1725. return true;
  1726. }
  1727. JS_ReportError(cx, "js_pluginx_protocols_FacebookAgent_isLoggedIn : wrong number of arguments: %d, was expecting %d", argc, 0);
  1728. return false;
  1729. }
  1730. bool js_pluginx_protocols_FacebookAgent_canPresentDialogWithParams(JSContext *cx, uint32_t argc, jsval *vp)
  1731. {
  1732. JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
  1733. bool ok = true;
  1734. JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
  1735. js_proxy_t *proxy = jsb_get_js_proxy(obj);
  1736. cocos2d::plugin::FacebookAgent* cobj = (cocos2d::plugin::FacebookAgent *)(proxy ? proxy->ptr : NULL);
  1737. JSB_PRECONDITION2( cobj, cx, false, "js_pluginx_protocols_FacebookAgent_canPresentDialogWithParams : Invalid Native Object");
  1738. if (argc == 1) {
  1739. std::map<std::string, std::string> arg0;
  1740. ok &= jsval_to_std_map_string_string(cx, args.get(0), &arg0);
  1741. JSB_PRECONDITION2(ok, cx, false, "js_pluginx_protocols_FacebookAgent_canPresentDialogWithParams : Error processing arguments");
  1742. bool ret = cobj->canPresentDialogWithParams(arg0);
  1743. jsval jsret = JSVAL_NULL;
  1744. jsret = BOOLEAN_TO_JSVAL(ret);
  1745. args.rval().set(jsret);
  1746. return true;
  1747. }
  1748. JS_ReportError(cx, "js_pluginx_protocols_FacebookAgent_canPresentDialogWithParams : wrong number of arguments: %d, was expecting %d", argc, 1);
  1749. return false;
  1750. }
  1751. bool js_pluginx_protocols_FacebookAgent_getAccessToken(JSContext *cx, uint32_t argc, jsval *vp)
  1752. {
  1753. JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
  1754. JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
  1755. js_proxy_t *proxy = jsb_get_js_proxy(obj);
  1756. cocos2d::plugin::FacebookAgent* cobj = (cocos2d::plugin::FacebookAgent *)(proxy ? proxy->ptr : NULL);
  1757. JSB_PRECONDITION2( cobj, cx, false, "js_pluginx_protocols_FacebookAgent_getAccessToken : Invalid Native Object");
  1758. if (argc == 0) {
  1759. std::string ret = cobj->getAccessToken();
  1760. jsval jsret = JSVAL_NULL;
  1761. jsret = std_string_to_jsval(cx, ret);
  1762. args.rval().set(jsret);
  1763. return true;
  1764. }
  1765. JS_ReportError(cx, "js_pluginx_protocols_FacebookAgent_getAccessToken : wrong number of arguments: %d, was expecting %d", argc, 0);
  1766. return false;
  1767. }
  1768. bool js_pluginx_protocols_FacebookAgent_destroyInstance(JSContext *cx, uint32_t argc, jsval *vp)
  1769. {
  1770. JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
  1771. if (argc == 0) {
  1772. cocos2d::plugin::FacebookAgent::destroyInstance();
  1773. args.rval().setUndefined();
  1774. return true;
  1775. }
  1776. JS_ReportError(cx, "js_pluginx_protocols_FacebookAgent_destroyInstance : wrong number of arguments");
  1777. return false;
  1778. }
  1779. bool js_pluginx_protocols_FacebookAgent_getInstanceJs(JSContext *cx, uint32_t argc, jsval *vp)
  1780. {
  1781. JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
  1782. if (argc == 0) {
  1783. cocos2d::plugin::FacebookAgent* ret = cocos2d::plugin::FacebookAgent::getInstanceJs();
  1784. jsval jsret = JSVAL_NULL;
  1785. do {
  1786. if (ret) {
  1787. js_proxy_t *jsProxy = js_get_or_create_proxy<cocos2d::plugin::FacebookAgent>(cx, (cocos2d::plugin::FacebookAgent*)ret);
  1788. jsret = OBJECT_TO_JSVAL(jsProxy->obj);
  1789. } else {
  1790. jsret = JSVAL_NULL;
  1791. }
  1792. } while (0);
  1793. args.rval().set(jsret);
  1794. return true;
  1795. }
  1796. JS_ReportError(cx, "js_pluginx_protocols_FacebookAgent_getInstanceJs : wrong number of arguments");
  1797. return false;
  1798. }
  1799. void js_cocos2d_plugin_FacebookAgent_finalize(JSFreeOp *fop, JSObject *obj) {
  1800. CCLOGINFO("jsbindings: finalizing JS object %p (FacebookAgent)", obj);
  1801. js_proxy_t* nproxy;
  1802. js_proxy_t* jsproxy;
  1803. jsproxy = jsb_get_js_proxy(obj);
  1804. if (jsproxy) {
  1805. nproxy = jsb_get_native_proxy(jsproxy->ptr);
  1806. cocos2d::plugin::FacebookAgent *nobj = static_cast<cocos2d::plugin::FacebookAgent *>(nproxy->ptr);
  1807. if (nobj)
  1808. delete nobj;
  1809. jsb_remove_proxy(nproxy, jsproxy);
  1810. }
  1811. }
  1812. void js_register_pluginx_protocols_FacebookAgent(JSContext *cx, JS::HandleObject global) {
  1813. jsb_cocos2d_plugin_FacebookAgent_class = (JSClass *)calloc(1, sizeof(JSClass));
  1814. jsb_cocos2d_plugin_FacebookAgent_class->name = "FacebookAgent";
  1815. jsb_cocos2d_plugin_FacebookAgent_class->addProperty = JS_PropertyStub;
  1816. jsb_cocos2d_plugin_FacebookAgent_class->delProperty = JS_DeletePropertyStub;
  1817. jsb_cocos2d_plugin_FacebookAgent_class->getProperty = JS_PropertyStub;
  1818. jsb_cocos2d_plugin_FacebookAgent_class->setProperty = JS_StrictPropertyStub;
  1819. jsb_cocos2d_plugin_FacebookAgent_class->enumerate = JS_EnumerateStub;
  1820. jsb_cocos2d_plugin_FacebookAgent_class->resolve = JS_ResolveStub;
  1821. jsb_cocos2d_plugin_FacebookAgent_class->convert = JS_ConvertStub;
  1822. jsb_cocos2d_plugin_FacebookAgent_class->finalize = js_cocos2d_plugin_FacebookAgent_finalize;
  1823. jsb_cocos2d_plugin_FacebookAgent_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2);
  1824. static JSPropertySpec properties[] = {
  1825. JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  1826. JS_PS_END
  1827. };
  1828. static JSFunctionSpec funcs[] = {
  1829. JS_FN("activateApp", js_pluginx_protocols_FacebookAgent_activateApp, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  1830. JS_FN("getUserID", js_pluginx_protocols_FacebookAgent_getUserID, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  1831. JS_FN("logEvent", js_pluginx_protocols_FacebookAgent_logEvent, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  1832. JS_FN("_logout", js_pluginx_protocols_FacebookAgent_logout, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  1833. JS_FN("getSDKVersion", js_pluginx_protocols_FacebookAgent_getSDKVersion, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  1834. JS_FN("logPurchase", js_pluginx_protocols_FacebookAgent_logPurchase, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  1835. JS_FN("isLoggedIn", js_pluginx_protocols_FacebookAgent_isLoggedIn, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  1836. JS_FN("canPresentDialog", js_pluginx_protocols_FacebookAgent_canPresentDialogWithParams, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  1837. JS_FN("getAccessToken", js_pluginx_protocols_FacebookAgent_getAccessToken, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  1838. JS_FS_END
  1839. };
  1840. static JSFunctionSpec st_funcs[] = {
  1841. JS_FN("destroyInstance", js_pluginx_protocols_FacebookAgent_destroyInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  1842. JS_FN("getInstanceJs", js_pluginx_protocols_FacebookAgent_getInstanceJs, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
  1843. JS_FS_END
  1844. };
  1845. jsb_cocos2d_plugin_FacebookAgent_prototype = JS_InitClass(
  1846. cx, global,
  1847. JS::NullPtr(), // parent proto
  1848. jsb_cocos2d_plugin_FacebookAgent_class,
  1849. empty_constructor, 0,
  1850. properties,
  1851. funcs,
  1852. NULL, // no static properties
  1853. st_funcs);
  1854. // make the class enumerable in the registered namespace
  1855. // bool found;
  1856. //FIXME: Removed in Firefox v27
  1857. // JS_SetPropertyAttributes(cx, global, "FacebookAgent", JSPROP_ENUMERATE | JSPROP_READONLY, &found);
  1858. // add the proto and JSClass to the type->js info hash table
  1859. TypeTest<cocos2d::plugin::FacebookAgent> t;
  1860. js_type_class_t *p;
  1861. std::string typeName = t.s_name();
  1862. if (_js_global_type_map.find(typeName) == _js_global_type_map.end())
  1863. {
  1864. p = (js_type_class_t *)malloc(sizeof(js_type_class_t));
  1865. p->jsclass = jsb_cocos2d_plugin_FacebookAgent_class;
  1866. p->proto = jsb_cocos2d_plugin_FacebookAgent_prototype;
  1867. p->parentProto = NULL;
  1868. _js_global_type_map.insert(std::make_pair(typeName, p));
  1869. }
  1870. }
  1871. void register_all_pluginx_protocols(JSContext* cx, JS::HandleObject obj) {
  1872. // Get the ns
  1873. JS::RootedObject ns(cx);
  1874. get_or_create_js_obj(cx, obj, "plugin", &ns);
  1875. js_register_pluginx_protocols_FacebookAgent(cx, ns);
  1876. js_register_pluginx_protocols_PluginProtocol(cx, ns);
  1877. js_register_pluginx_protocols_ProtocolUser(cx, ns);
  1878. js_register_pluginx_protocols_ProtocolShare(cx, ns);
  1879. js_register_pluginx_protocols_ProtocolIAP(cx, ns);
  1880. js_register_pluginx_protocols_AgentManager(cx, ns);
  1881. js_register_pluginx_protocols_ProtocolSocial(cx, ns);
  1882. js_register_pluginx_protocols_ProtocolAnalytics(cx, ns);
  1883. js_register_pluginx_protocols_ProtocolAds(cx, ns);
  1884. js_register_pluginx_protocols_PluginManager(cx, ns);
  1885. }