Update the JS binding for plugin.

This commit is contained in:
zhangbin 2013-06-24 17:00:02 +08:00
parent 622f1e7a4a
commit c72cdcb88e
18 changed files with 76 additions and 70 deletions

View File

@ -6,7 +6,7 @@ using namespace pluginx;
#include "ProtocolAnalytics.h" #include "ProtocolAnalytics.h"
#include "ProtocolIAP.h" #include "ProtocolIAP.h"
#include "ProtocolAds.h" #include "ProtocolAds.h"
#include "ProtocolSocial.h" #include "ProtocolShare.h"
template<class T> template<class T>
static JSBool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) { static JSBool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) {
@ -970,16 +970,16 @@ void js_register_pluginx_protocols_ProtocolAds(JSContext *cx, JSObject *global)
} }
JSClass *jsb_ProtocolSocial_class; JSClass *jsb_ProtocolShare_class;
JSObject *jsb_ProtocolSocial_prototype; JSObject *jsb_ProtocolShare_prototype;
JSBool js_pluginx_protocols_ProtocolSocial_onShareResult(JSContext *cx, uint32_t argc, jsval *vp) JSBool js_pluginx_protocols_ProtocolShare_onShareResult(JSContext *cx, uint32_t argc, jsval *vp)
{ {
jsval *argv = JS_ARGV(cx, vp); jsval *argv = JS_ARGV(cx, vp);
JSBool ok = JS_TRUE; JSBool ok = JS_TRUE;
JSObject *obj = JS_THIS_OBJECT(cx, vp); JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy = jsb_get_js_proxy(obj); js_proxy_t *proxy = jsb_get_js_proxy(obj);
cocos2d::plugin::ProtocolSocial* cobj = (cocos2d::plugin::ProtocolSocial *)(proxy ? proxy->ptr : NULL); cocos2d::plugin::ProtocolShare* cobj = (cocos2d::plugin::ProtocolShare *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
if (argc == 2) { if (argc == 2) {
cocos2d::plugin::ShareResultCode arg0; cocos2d::plugin::ShareResultCode arg0;
@ -995,13 +995,13 @@ JSBool js_pluginx_protocols_ProtocolSocial_onShareResult(JSContext *cx, uint32_t
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 2); JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 2);
return JS_FALSE; return JS_FALSE;
} }
JSBool js_pluginx_protocols_ProtocolSocial_share(JSContext *cx, uint32_t argc, jsval *vp) JSBool js_pluginx_protocols_ProtocolShare_share(JSContext *cx, uint32_t argc, jsval *vp)
{ {
jsval *argv = JS_ARGV(cx, vp); jsval *argv = JS_ARGV(cx, vp);
JSBool ok = JS_TRUE; JSBool ok = JS_TRUE;
JSObject *obj = JS_THIS_OBJECT(cx, vp); JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy = jsb_get_js_proxy(obj); js_proxy_t *proxy = jsb_get_js_proxy(obj);
cocos2d::plugin::ProtocolSocial* cobj = (cocos2d::plugin::ProtocolSocial *)(proxy ? proxy->ptr : NULL); cocos2d::plugin::ProtocolShare* cobj = (cocos2d::plugin::ProtocolShare *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
if (argc == 1) { if (argc == 1) {
TShareInfo arg0; TShareInfo arg0;
@ -1015,17 +1015,17 @@ JSBool js_pluginx_protocols_ProtocolSocial_share(JSContext *cx, uint32_t argc, j
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1);
return JS_FALSE; return JS_FALSE;
} }
JSBool js_pluginx_protocols_ProtocolSocial_configDeveloperInfo(JSContext *cx, uint32_t argc, jsval *vp) JSBool js_pluginx_protocols_ProtocolShare_configDeveloperInfo(JSContext *cx, uint32_t argc, jsval *vp)
{ {
jsval *argv = JS_ARGV(cx, vp); jsval *argv = JS_ARGV(cx, vp);
JSBool ok = JS_TRUE; JSBool ok = JS_TRUE;
JSObject *obj = JS_THIS_OBJECT(cx, vp); JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy = jsb_get_js_proxy(obj); js_proxy_t *proxy = jsb_get_js_proxy(obj);
cocos2d::plugin::ProtocolSocial* cobj = (cocos2d::plugin::ProtocolSocial *)(proxy ? proxy->ptr : NULL); cocos2d::plugin::ProtocolShare* cobj = (cocos2d::plugin::ProtocolShare *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
if (argc == 1) { if (argc == 1) {
TSocialDeveloperInfo arg0; TShareDeveloperInfo arg0;
ok &= jsval_to_TSocialDeveloperInfo(cx, argv[0], &arg0); ok &= jsval_to_TShareDeveloperInfo(cx, argv[0], &arg0);
JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
cobj->configDeveloperInfo(arg0); cobj->configDeveloperInfo(arg0);
JS_SET_RVAL(cx, vp, JSVAL_VOID); JS_SET_RVAL(cx, vp, JSVAL_VOID);
@ -1039,15 +1039,15 @@ JSBool js_pluginx_protocols_ProtocolSocial_configDeveloperInfo(JSContext *cx, ui
extern JSObject *jsb_PluginProtocol_prototype; extern JSObject *jsb_PluginProtocol_prototype;
void js_pluginx_protocols_ProtocolSocial_finalize(JSFreeOp *fop, JSObject *obj) { void js_pluginx_protocols_ProtocolShare_finalize(JSFreeOp *fop, JSObject *obj) {
CCLOGINFO("jsbindings: finalizing JS object %p (ProtocolSocial)", obj); CCLOGINFO("jsbindings: finalizing JS object %p (ProtocolShare)", obj);
js_proxy_t* nproxy; js_proxy_t* nproxy;
js_proxy_t* jsproxy; js_proxy_t* jsproxy;
jsproxy = jsb_get_js_proxy(obj); jsproxy = jsb_get_js_proxy(obj);
if (jsproxy) { if (jsproxy) {
nproxy = jsb_get_native_proxy(jsproxy->ptr); nproxy = jsb_get_native_proxy(jsproxy->ptr);
// cocos2d::plugin::ProtocolSocial *nobj = static_cast<cocos2d::plugin::ProtocolSocial *>(nproxy->ptr); // cocos2d::plugin::ProtocolShare *nobj = static_cast<cocos2d::plugin::ProtocolShare *>(nproxy->ptr);
// if (nobj) // if (nobj)
// delete nobj; // delete nobj;
@ -1055,36 +1055,36 @@ void js_pluginx_protocols_ProtocolSocial_finalize(JSFreeOp *fop, JSObject *obj)
} }
} }
void js_register_pluginx_protocols_ProtocolSocial(JSContext *cx, JSObject *global) { void js_register_pluginx_protocols_ProtocolShare(JSContext *cx, JSObject *global) {
jsb_ProtocolSocial_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_ProtocolShare_class = (JSClass *)calloc(1, sizeof(JSClass));
jsb_ProtocolSocial_class->name = "ProtocolSocial"; jsb_ProtocolShare_class->name = "ProtocolShare";
jsb_ProtocolSocial_class->addProperty = JS_PropertyStub; jsb_ProtocolShare_class->addProperty = JS_PropertyStub;
jsb_ProtocolSocial_class->delProperty = JS_PropertyStub; jsb_ProtocolShare_class->delProperty = JS_PropertyStub;
jsb_ProtocolSocial_class->getProperty = JS_PropertyStub; jsb_ProtocolShare_class->getProperty = JS_PropertyStub;
jsb_ProtocolSocial_class->setProperty = JS_StrictPropertyStub; jsb_ProtocolShare_class->setProperty = JS_StrictPropertyStub;
jsb_ProtocolSocial_class->enumerate = JS_EnumerateStub; jsb_ProtocolShare_class->enumerate = JS_EnumerateStub;
jsb_ProtocolSocial_class->resolve = JS_ResolveStub; jsb_ProtocolShare_class->resolve = JS_ResolveStub;
jsb_ProtocolSocial_class->convert = JS_ConvertStub; jsb_ProtocolShare_class->convert = JS_ConvertStub;
jsb_ProtocolSocial_class->finalize = js_pluginx_protocols_ProtocolSocial_finalize; jsb_ProtocolShare_class->finalize = js_pluginx_protocols_ProtocolShare_finalize;
jsb_ProtocolSocial_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); jsb_ProtocolShare_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2);
static JSPropertySpec properties[] = { static JSPropertySpec properties[] = {
{0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER}
}; };
static JSFunctionSpec funcs[] = { static JSFunctionSpec funcs[] = {
JS_FN("onShareResult", js_pluginx_protocols_ProtocolSocial_onShareResult, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("onShareResult", js_pluginx_protocols_ProtocolShare_onShareResult, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("share", js_pluginx_protocols_ProtocolSocial_share, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("share", js_pluginx_protocols_ProtocolShare_share, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("configDeveloperInfo", js_pluginx_protocols_ProtocolSocial_configDeveloperInfo, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("configDeveloperInfo", js_pluginx_protocols_ProtocolShare_configDeveloperInfo, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FS_END JS_FS_END
}; };
JSFunctionSpec *st_funcs = NULL; JSFunctionSpec *st_funcs = NULL;
jsb_ProtocolSocial_prototype = JS_InitClass( jsb_ProtocolShare_prototype = JS_InitClass(
cx, global, cx, global,
jsb_PluginProtocol_prototype, jsb_PluginProtocol_prototype,
jsb_ProtocolSocial_class, jsb_ProtocolShare_class,
empty_constructor, 0, empty_constructor, 0,
properties, properties,
funcs, funcs,
@ -1092,18 +1092,18 @@ void js_register_pluginx_protocols_ProtocolSocial(JSContext *cx, JSObject *globa
st_funcs); st_funcs);
// make the class enumerable in the registered namespace // make the class enumerable in the registered namespace
JSBool found; JSBool found;
JS_SetPropertyAttributes(cx, global, "ProtocolSocial", JSPROP_ENUMERATE | JSPROP_READONLY, &found); JS_SetPropertyAttributes(cx, global, "ProtocolShare", JSPROP_ENUMERATE | JSPROP_READONLY, &found);
// add the proto and JSClass to the type->js info hash table // add the proto and JSClass to the type->js info hash table
TypeTest<cocos2d::plugin::ProtocolSocial> t; TypeTest<cocos2d::plugin::ProtocolShare> t;
js_type_class_t *p; js_type_class_t *p;
uint32_t typeId = t.s_id(); uint32_t typeId = t.s_id();
HASH_FIND_INT(_js_global_type_ht, &typeId, p); HASH_FIND_INT(_js_global_type_ht, &typeId, p);
if (!p) { if (!p) {
p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p = (js_type_class_t *)malloc(sizeof(js_type_class_t));
p->type = typeId; p->type = typeId;
p->jsclass = jsb_ProtocolSocial_class; p->jsclass = jsb_ProtocolShare_class;
p->proto = jsb_ProtocolSocial_prototype; p->proto = jsb_ProtocolShare_prototype;
p->parentProto = jsb_PluginProtocol_prototype; p->parentProto = jsb_PluginProtocol_prototype;
HASH_ADD_INT(_js_global_type_ht, type, p); HASH_ADD_INT(_js_global_type_ht, type, p);
} }
@ -1124,8 +1124,8 @@ void register_all_pluginx_protocols(JSContext* cx, JSObject* obj) {
obj = ns; obj = ns;
js_register_pluginx_protocols_PluginProtocol(cx, obj); js_register_pluginx_protocols_PluginProtocol(cx, obj);
js_register_pluginx_protocols_ProtocolShare(cx, obj);
js_register_pluginx_protocols_ProtocolIAP(cx, obj); js_register_pluginx_protocols_ProtocolIAP(cx, obj);
js_register_pluginx_protocols_ProtocolSocial(cx, obj);
js_register_pluginx_protocols_ProtocolAnalytics(cx, obj); js_register_pluginx_protocols_ProtocolAnalytics(cx, obj);
js_register_pluginx_protocols_ProtocolAds(cx, obj); js_register_pluginx_protocols_ProtocolAds(cx, obj);
js_register_pluginx_protocols_PluginManager(cx, obj); js_register_pluginx_protocols_PluginManager(cx, obj);

View File

@ -71,15 +71,15 @@ JSBool js_pluginx_protocols_ProtocolAds_spendPoints(JSContext *cx, uint32_t argc
JSBool js_pluginx_protocols_ProtocolAds_configDeveloperInfo(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_pluginx_protocols_ProtocolAds_configDeveloperInfo(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolAds_onPlayerGetPoints(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_pluginx_protocols_ProtocolAds_onPlayerGetPoints(JSContext *cx, uint32_t argc, jsval *vp);
extern JSClass *jsb_ProtocolSocial_class; extern JSClass *jsb_ProtocolShare_class;
extern JSObject *jsb_ProtocolSocial_prototype; extern JSObject *jsb_ProtocolShare_prototype;
JSBool js_pluginx_protocols_ProtocolSocial_constructor(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_pluginx_protocols_ProtocolShare_constructor(JSContext *cx, uint32_t argc, jsval *vp);
void js_pluginx_protocols_ProtocolSocial_finalize(JSContext *cx, JSObject *obj); void js_pluginx_protocols_ProtocolShare_finalize(JSContext *cx, JSObject *obj);
void js_register_pluginx_protocols_ProtocolSocial(JSContext *cx, JSObject *global); void js_register_pluginx_protocols_ProtocolShare(JSContext *cx, JSObject *global);
void register_all_pluginx_protocols(JSContext* cx, JSObject* obj); void register_all_pluginx_protocols(JSContext* cx, JSObject* obj);
JSBool js_pluginx_protocols_ProtocolSocial_onShareResult(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_pluginx_protocols_ProtocolShare_onShareResult(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolSocial_share(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_pluginx_protocols_ProtocolShare_share(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolSocial_configDeveloperInfo(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_pluginx_protocols_ProtocolShare_configDeveloperInfo(JSContext *cx, uint32_t argc, jsval *vp);
#endif #endif

View File

@ -199,9 +199,9 @@ onPlayerGetPoints : function () {},
}; };
/** /**
* @class ProtocolSocial * @class ProtocolShare
*/ */
plugin.ProtocolSocial = { plugin.ProtocolShare = {
/** /**
* @method onShareResult * @method onShareResult
@ -218,7 +218,7 @@ share : function () {},
/** /**
* @method configDeveloperInfo * @method configDeveloperInfo
* @param {TSocialDeveloperInfo} * @param {TShareDeveloperInfo}
*/ */
configDeveloperInfo : function () {}, configDeveloperInfo : function () {},

View File

@ -36,9 +36,9 @@ plugin.ProtocolIAP.PayResultCode.PayFail = 1;
plugin.ProtocolIAP.PayResultCode.PayCancel = 2; plugin.ProtocolIAP.PayResultCode.PayCancel = 2;
plugin.ProtocolIAP.PayResultCode.PayTimeOut = 3; plugin.ProtocolIAP.PayResultCode.PayTimeOut = 3;
plugin.ProtocolSocial.ShareResultCode = {}; plugin.ProtocolShare.ShareResultCode = {};
plugin.ProtocolSocial.ShareResultCode.ShareSuccess = 0; plugin.ProtocolShare.ShareResultCode.ShareSuccess = 0;
plugin.ProtocolSocial.ShareResultCode.ShareFail = 1; plugin.ProtocolShare.ShareResultCode.ShareFail = 1;
plugin.ProtocolSocial.ShareResultCode.ShareCancel = 2; plugin.ProtocolShare.ShareResultCode.ShareCancel = 2;
plugin.ProtocolSocial.ShareResultCode.ShareTimeOut = 3; plugin.ProtocolShare.ShareResultCode.ShareTimeOut = 3;

View File

@ -206,7 +206,7 @@ JSBool jsval_to_TAdsDeveloperInfo(JSContext *cx, jsval v, TAdsDeveloperInfo* ret
return jsval_to_TProductInfo(cx, v, ret); return jsval_to_TProductInfo(cx, v, ret);
} }
JSBool jsval_to_TSocialDeveloperInfo(JSContext *cx, jsval v, TSocialDeveloperInfo* ret) JSBool jsval_to_TShareDeveloperInfo(JSContext *cx, jsval v, TShareDeveloperInfo* ret)
{ {
return jsval_to_TProductInfo(cx, v, ret); return jsval_to_TProductInfo(cx, v, ret);
} }

View File

@ -7,7 +7,7 @@
#include "ProtocolIAP.h" #include "ProtocolIAP.h"
#include "ProtocolAnalytics.h" #include "ProtocolAnalytics.h"
#include "ProtocolAds.h" #include "ProtocolAds.h"
#include "ProtocolSocial.h" #include "ProtocolShare.h"
#ifndef CCLOGINFO #ifndef CCLOGINFO
#define CCLOGINFO(...) #define CCLOGINFO(...)
@ -27,7 +27,7 @@ JSBool jsval_to_std_string(JSContext *cx, jsval v, std::string* ret);
JSBool jsval_to_TProductInfo(JSContext *cx, jsval v, TProductInfo* ret); JSBool jsval_to_TProductInfo(JSContext *cx, jsval v, TProductInfo* ret);
JSBool jsval_to_TIAPDeveloperInfo(JSContext *cx, jsval v, TIAPDeveloperInfo* ret); JSBool jsval_to_TIAPDeveloperInfo(JSContext *cx, jsval v, TIAPDeveloperInfo* ret);
JSBool jsval_to_TAdsDeveloperInfo(JSContext *cx, jsval v, TAdsDeveloperInfo* ret); JSBool jsval_to_TAdsDeveloperInfo(JSContext *cx, jsval v, TAdsDeveloperInfo* ret);
JSBool jsval_to_TSocialDeveloperInfo(JSContext *cx, jsval v, TSocialDeveloperInfo* ret); JSBool jsval_to_TShareDeveloperInfo(JSContext *cx, jsval v, TShareDeveloperInfo* ret);
JSBool jsval_to_TShareInfo(JSContext *cx, jsval v, TShareInfo* ret); JSBool jsval_to_TShareInfo(JSContext *cx, jsval v, TShareInfo* ret);
JSBool jsval_to_TPaymentInfo(JSContext *cx, jsval v, std::map<std::string, std::string>* ret); JSBool jsval_to_TPaymentInfo(JSContext *cx, jsval v, std::map<std::string, std::string>* ret);
JSBool jsval_to_LogEventParamMap(JSContext *cx, jsval v, LogEventParamMap** ret); JSBool jsval_to_LogEventParamMap(JSContext *cx, jsval v, LogEventParamMap** ret);

View File

@ -12,7 +12,7 @@ static jsval anonEvaluate(JSContext *cx, JSObject *thisObj, const char* string)
extern JSObject *jsb_ProtocolIAP_prototype; extern JSObject *jsb_ProtocolIAP_prototype;
extern JSObject *jsb_ProtocolAds_prototype; extern JSObject *jsb_ProtocolAds_prototype;
extern JSObject *jsb_ProtocolSocial_prototype; extern JSObject *jsb_ProtocolShare_prototype;
extern JSObject *jsb_PluginProtocol_prototype; extern JSObject *jsb_PluginProtocol_prototype;
void register_pluginx_js_extensions(JSContext* cx, JSObject* global) void register_pluginx_js_extensions(JSContext* cx, JSObject* global)
@ -31,7 +31,7 @@ void register_pluginx_js_extensions(JSContext* cx, JSObject* global)
JS_DefineFunction(cx, jsb_ProtocolIAP_prototype, "setResultListener", js_pluginx_ProtocolIAP_setResultListener, 1, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_ProtocolIAP_prototype, "setResultListener", js_pluginx_ProtocolIAP_setResultListener, 1, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(cx, jsb_ProtocolAds_prototype, "setAdsListener", js_pluginx_ProtocolAds_setAdsListener, 1, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_ProtocolAds_prototype, "setAdsListener", js_pluginx_ProtocolAds_setAdsListener, 1, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(cx, jsb_ProtocolSocial_prototype, "setResultListener", js_pluginx_ProtocolSocial_setResultListener, 1, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_ProtocolShare_prototype, "setResultListener", js_pluginx_ProtocolShare_setResultListener, 1, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(cx, jsb_PluginProtocol_prototype, "callFuncWithParam", js_pluginx_PluginProtocol_callFuncWithParam, 1, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_PluginProtocol_prototype, "callFuncWithParam", js_pluginx_PluginProtocol_callFuncWithParam, 1, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(cx, jsb_PluginProtocol_prototype, "callStringFuncWithParam", js_pluginx_PluginProtocol_callStringFuncWithParam, 1, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_PluginProtocol_prototype, "callStringFuncWithParam", js_pluginx_PluginProtocol_callStringFuncWithParam, 1, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(cx, jsb_PluginProtocol_prototype, "callIntFuncWithParam", js_pluginx_PluginProtocol_callIntFuncWithParam, 1, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_PluginProtocol_prototype, "callIntFuncWithParam", js_pluginx_PluginProtocol_callIntFuncWithParam, 1, JSPROP_READONLY | JSPROP_PERMANENT);

View File

@ -212,13 +212,13 @@ private:
JSObject* _JSDelegate; JSObject* _JSDelegate;
}; };
JSBool js_pluginx_ProtocolSocial_setResultListener(JSContext *cx, uint32_t argc, jsval *vp) JSBool js_pluginx_ProtocolShare_setResultListener(JSContext *cx, uint32_t argc, jsval *vp)
{ {
s_cx = cx; s_cx = cx;
jsval *argv = JS_ARGV(cx, vp); jsval *argv = JS_ARGV(cx, vp);
JSObject *obj = JS_THIS_OBJECT(cx, vp); JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj); js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::plugin::ProtocolSocial* cobj = (cocos2d::plugin::ProtocolSocial *)(proxy ? proxy->ptr : NULL); cocos2d::plugin::ProtocolShare* cobj = (cocos2d::plugin::ProtocolShare *)(proxy ? proxy->ptr : NULL);
JSBool ok = JS_TRUE; JSBool ok = JS_TRUE;
if (argc == 1) { if (argc == 1) {

View File

@ -6,6 +6,6 @@
JSBool js_pluginx_ProtocolIAP_setResultListener(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_pluginx_ProtocolIAP_setResultListener(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_ProtocolAds_setAdsListener(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_pluginx_ProtocolAds_setAdsListener(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_ProtocolSocial_setResultListener(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_pluginx_ProtocolShare_setResultListener(JSContext *cx, uint32_t argc, jsval *vp);
#endif /* __JS_MANUAL_CALLBACK_H__ */ #endif /* __JS_MANUAL_CALLBACK_H__ */

View File

@ -7,11 +7,11 @@ prefix = pluginx_protocols
# all classes will be embedded in that namespace # all classes will be embedded in that namespace
target_namespace = plugin target_namespace = plugin
android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include/linux -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.6/include -I%(androidndkdir)s/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/lib/gcc/arm-linux-androideabi/4.6/include android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include
android_flags = -D_SIZE_T_DEFINED_ android_flags = -D_SIZE_T_DEFINED_
clang_headers = -I%(clangllvmdir)s/lib/clang/3.1/include clang_headers = -I%(clangllvmdir)s/lib/clang/3.3/include
clang_flags = -nostdinc -x c++ clang_flags = -nostdinc -x c++ -std=c++11
cocos_headers = -I%(pluginxdir)s/protocols/include cocos_headers = -I%(pluginxdir)s/protocols/include
@ -23,11 +23,11 @@ cxxgenerator_headers = -I%(cxxgeneratordir)s/targets/spidermonkey/common
extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s
# what headers to parse # what headers to parse
headers = %(pluginxdir)s/protocols/include/PluginManager.h %(pluginxdir)s/protocols/include/ProtocolAnalytics.h %(pluginxdir)s/protocols/include/ProtocolIAP.h %(pluginxdir)s/protocols/include/ProtocolAds.h %(pluginxdir)s/protocols/include/ProtocolSocial.h headers = %(pluginxdir)s/protocols/include/PluginManager.h %(pluginxdir)s/protocols/include/ProtocolAnalytics.h %(pluginxdir)s/protocols/include/ProtocolIAP.h %(pluginxdir)s/protocols/include/ProtocolAds.h %(pluginxdir)s/protocols/include/ProtocolShare.h
# what classes to produce code for. You can use regular expressions here. When testing the regular # what classes to produce code for. You can use regular expressions here. When testing the regular
# expression, it will be enclosed in "^$", like this: "^CCMenu*$". # expression, it will be enclosed in "^$", like this: "^CCMenu*$".
classes = PluginProtocol PluginManager ProtocolIAP ProtocolAnalytics ProtocolAds ProtocolSocial classes = PluginProtocol PluginManager ProtocolIAP ProtocolAnalytics ProtocolAds ProtocolShare
# what should we skip? in the format ClassName::[function function] # what should we skip? in the format ClassName::[function function]
# ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also # ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also
@ -38,7 +38,7 @@ classes = PluginProtocol PluginManager ProtocolIAP ProtocolAnalytics ProtocolAds
skip = ProtocolIAP::[setResultListener], skip = ProtocolIAP::[setResultListener],
ProtocolAds::[setAdsListener], ProtocolAds::[setAdsListener],
ProtocolSocial::[setResultListener], ProtocolShare::[setResultListener],
PluginProtocol::[callFuncWithParam callStringFuncWithParam callIntFuncWithParam callBoolFuncWithParam callFloatFuncWithParam] PluginProtocol::[callFuncWithParam callStringFuncWithParam callIntFuncWithParam callBoolFuncWithParam callFloatFuncWithParam]
rename_functions = rename_functions =
@ -56,7 +56,7 @@ base_classes_to_skip =
# classes that create no constructor # classes that create no constructor
# CCSet is special and we will use a hand-written constructor # CCSet is special and we will use a hand-written constructor
abstract_classes = PluginProtocol ProtocolIAP ProtocolAnalytics PluginManager ProtocolAds ProtocolSocial abstract_classes = PluginProtocol ProtocolIAP ProtocolAnalytics PluginManager ProtocolAds ProtocolShare
# Determining whether to use script object(js object) to control the lifecycle of native(cpp) object or the other way around. Supported values are 'yes' or 'no'. # Determining whether to use script object(js object) to control the lifecycle of native(cpp) object or the other way around. Supported values are 'yes' or 'no'.
script_control_cpp = yes script_control_cpp = yes

View File

@ -1,2 +1,3 @@
APP_STL := gnustl_static APP_STL := gnustl_static
APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -DCOCOS2D_DEBUG=1 -std=c++11 APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -DCOCOS2D_DEBUG=1 -std=c++11
NDK_TOOLCHAIN_VERSION=4.7

View File

@ -1,3 +1,4 @@
APP_STL := gnustl_static APP_STL := gnustl_static
APP_CPPFLAGS := -frtti -DCOCOS2D_JAVASCRIPT=1 -std=c++11 APP_CPPFLAGS := -frtti -DCOCOS2D_JAVASCRIPT=1 -std=c++11
APP_CPPFLAGS += -DCOCOS2D_DEBUG=1 -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 APP_CPPFLAGS += -DCOCOS2D_DEBUG=1 -DCC_ENABLE_CHIPMUNK_INTEGRATION=1
NDK_TOOLCHAIN_VERSION=4.7

View File

@ -1,2 +1,3 @@
APP_STL := gnustl_static APP_STL := gnustl_static
APP_CPPFLAGS += -frtti -std=c++11 APP_CPPFLAGS += -frtti -std=c++11
NDK_TOOLCHAIN_VERSION=4.7

View File

@ -1,3 +1,4 @@
APP_STL := gnustl_static APP_STL := gnustl_static
APP_CPPFLAGS := -frtti -DCOCOS2D_JAVASCRIPT=1 -std=c++11 APP_CPPFLAGS := -frtti -DCOCOS2D_JAVASCRIPT=1 -std=c++11
APP_CPPFLAGS += -DCOCOS2D_DEBUG=1 -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 APP_CPPFLAGS += -DCOCOS2D_DEBUG=1 -DCC_ENABLE_CHIPMUNK_INTEGRATION=1
NDK_TOOLCHAIN_VERSION=4.7

View File

@ -1,2 +1,3 @@
APP_STL := gnustl_static APP_STL := gnustl_static
APP_CPPFLAGS += -frtti -std=c++11 APP_CPPFLAGS += -frtti -std=c++11
NDK_TOOLCHAIN_VERSION=4.7

View File

@ -1,2 +1,3 @@
APP_STL := gnustl_static APP_STL := gnustl_static
APP_CPPFLAGS += -frtti -std=c++11 APP_CPPFLAGS += -frtti -std=c++11
NDK_TOOLCHAIN_VERSION=4.7

View File

@ -40,7 +40,7 @@ conversions:
TIAPDeveloperInfo: "ok &= jsval_to_TIAPDeveloperInfo(cx, ${in_value}, &${out_value})" TIAPDeveloperInfo: "ok &= jsval_to_TIAPDeveloperInfo(cx, ${in_value}, &${out_value})"
TPaymentInfo: "ok &= jsval_to_TPaymentInfo(cx, ${in_value}, &${out_value})" TPaymentInfo: "ok &= jsval_to_TPaymentInfo(cx, ${in_value}, &${out_value})"
TAdsDeveloperInfo: "ok &= jsval_to_TAdsDeveloperInfo(cx, ${in_value}, &${out_value})" TAdsDeveloperInfo: "ok &= jsval_to_TAdsDeveloperInfo(cx, ${in_value}, &${out_value})"
TSocialDeveloperInfo: "ok &= jsval_to_TSocialDeveloperInfo(cx, ${in_value}, &${out_value})" TShareDeveloperInfo: "ok &= jsval_to_TShareDeveloperInfo(cx, ${in_value}, &${out_value})"
TShareInfo: "ok &= jsval_to_TShareInfo(cx, ${in_value}, &${out_value})" TShareInfo: "ok &= jsval_to_TShareInfo(cx, ${in_value}, &${out_value})"
LogEventParamMap*: | LogEventParamMap*: |
LogEventParamMap ${out_value}_tmp; LogEventParamMap ${out_value}_tmp;
@ -65,7 +65,7 @@ conversions:
TIAPDeveloperInfo: "${out_value} = TIAPDeveloperInfo_to_jsval(cx, ${in_value})" TIAPDeveloperInfo: "${out_value} = TIAPDeveloperInfo_to_jsval(cx, ${in_value})"
TPaymentInfo: "${out_value} = TPaymentInfo_to_jsval(cx, ${in_value})" TPaymentInfo: "${out_value} = TPaymentInfo_to_jsval(cx, ${in_value})"
TAdsDeveloperInfo: "${out_value} = TAdsDeveloperInfo_to_jsval(cx, ${in_value})" TAdsDeveloperInfo: "${out_value} = TAdsDeveloperInfo_to_jsval(cx, ${in_value})"
TSocialDeveloperInfo: "${out_value} = TSocialDeveloperInfo_to_jsval(cx, ${in_value})" TShareDeveloperInfo: "${out_value} = TShareDeveloperInfo_to_jsval(cx, ${in_value})"
TShareInfo: "${out_value} = TShareInfo_to_jsval(cx, ${in_value})" TShareInfo: "${out_value} = TShareInfo_to_jsval(cx, ${in_value})"
LogEventParamMap*: "${out_value} = LogEventParamMap_to_jsval(cx, ${in_value})" LogEventParamMap*: "${out_value} = LogEventParamMap_to_jsval(cx, ${in_value})"
long: "${out_value} = long_to_jsval(cx, ${in_value})" long: "${out_value} = long_to_jsval(cx, ${in_value})"

View File

@ -97,7 +97,7 @@ set -x
mv $CXX_GENERATOR_ROOT/targets/spidermonkey/conversions.yaml $CXX_GENERATOR_ROOT/targets/spidermonkey/conversions.yaml.backup mv $CXX_GENERATOR_ROOT/targets/spidermonkey/conversions.yaml $CXX_GENERATOR_ROOT/targets/spidermonkey/conversions.yaml.backup
cp conversions.yaml $CXX_GENERATOR_ROOT/targets/spidermonkey cp conversions.yaml $CXX_GENERATOR_ROOT/targets/spidermonkey
LD_LIBRARY_PATH=${CLANG_ROOT}/lib LD_LIBRARY_PATH=${CLANG_ROOT}/lib \
$PYTHON_BIN ${CXX_GENERATOR_ROOT}/generator.py ${PLUGINX_ROOT}/${SUB_DIR}$PLUGIN_NAME/$INI_NAME -s $PLUGIN_NAME -o $PLUGINX_ROOT/jsbindings/auto -n $OUTPUT_FILENAME $PYTHON_BIN ${CXX_GENERATOR_ROOT}/generator.py ${PLUGINX_ROOT}/${SUB_DIR}$PLUGIN_NAME/$INI_NAME -s $PLUGIN_NAME -o $PLUGINX_ROOT/jsbindings/auto -n $OUTPUT_FILENAME
mv $CXX_GENERATOR_ROOT/targets/spidermonkey/conversions.yaml.backup $CXX_GENERATOR_ROOT/targets/spidermonkey/conversions.yaml mv $CXX_GENERATOR_ROOT/targets/spidermonkey/conversions.yaml.backup $CXX_GENERATOR_ROOT/targets/spidermonkey/conversions.yaml