mirror of https://github.com/axmolengine/axmol.git
Update the JS binding for the change of class ProtocolAds.
This commit is contained in:
parent
bbe649812a
commit
4ea5d0509f
|
@ -734,6 +734,28 @@ void js_register_pluginx_protocols_ProtocolIAP(JSContext *cx, JSObject *global)
|
|||
JSClass *jsb_ProtocolAds_class;
|
||||
JSObject *jsb_ProtocolAds_prototype;
|
||||
|
||||
JSBool js_pluginx_protocols_ProtocolAds_showAds(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
jsval *argv = JS_ARGV(cx, vp);
|
||||
JSBool ok = JS_TRUE;
|
||||
JSObject *obj = JS_THIS_OBJECT(cx, vp);
|
||||
js_proxy_t *proxy = jsb_get_js_proxy(obj);
|
||||
cocos2d::plugin::ProtocolAds* cobj = (cocos2d::plugin::ProtocolAds *)(proxy ? proxy->ptr : NULL);
|
||||
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
|
||||
if (argc == 2) {
|
||||
TAdsInfo arg0;
|
||||
cocos2d::plugin::ProtocolAds::AdsPos arg1;
|
||||
#pragma warning NO CONVERSION TO NATIVE FOR TAdsInfo;
|
||||
ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1);
|
||||
JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
|
||||
cobj->showAds(arg0, arg1);
|
||||
JS_SET_RVAL(cx, vp, JSVAL_VOID);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 2);
|
||||
return JS_FALSE;
|
||||
}
|
||||
JSBool js_pluginx_protocols_ProtocolAds_hideAds(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
jsval *argv = JS_ARGV(cx, vp);
|
||||
|
@ -743,8 +765,8 @@ JSBool js_pluginx_protocols_ProtocolAds_hideAds(JSContext *cx, uint32_t argc, js
|
|||
cocos2d::plugin::ProtocolAds* cobj = (cocos2d::plugin::ProtocolAds *)(proxy ? proxy->ptr : NULL);
|
||||
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
|
||||
if (argc == 1) {
|
||||
cocos2d::plugin::ProtocolAds::AdsType arg0;
|
||||
ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0);
|
||||
TAdsInfo arg0;
|
||||
#pragma warning NO CONVERSION TO NATIVE FOR TAdsInfo;
|
||||
JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
|
||||
cobj->hideAds(arg0);
|
||||
JS_SET_RVAL(cx, vp, JSVAL_VOID);
|
||||
|
@ -769,28 +791,6 @@ JSBool js_pluginx_protocols_ProtocolAds_queryPoints(JSContext *cx, uint32_t argc
|
|||
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0);
|
||||
return JS_FALSE;
|
||||
}
|
||||
JSBool js_pluginx_protocols_ProtocolAds_onAdsResult(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
jsval *argv = JS_ARGV(cx, vp);
|
||||
JSBool ok = JS_TRUE;
|
||||
JSObject *obj = JS_THIS_OBJECT(cx, vp);
|
||||
js_proxy_t *proxy = jsb_get_js_proxy(obj);
|
||||
cocos2d::plugin::ProtocolAds* cobj = (cocos2d::plugin::ProtocolAds *)(proxy ? proxy->ptr : NULL);
|
||||
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
|
||||
if (argc == 2) {
|
||||
cocos2d::plugin::AdsResultCode arg0;
|
||||
const char* arg1;
|
||||
ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0);
|
||||
std::string arg1_tmp; ok &= jsval_to_std_string(cx, argv[1], &arg1_tmp); arg1 = arg1_tmp.c_str();
|
||||
JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
|
||||
cobj->onAdsResult(arg0, arg1);
|
||||
JS_SET_RVAL(cx, vp, JSVAL_VOID);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 2);
|
||||
return JS_FALSE;
|
||||
}
|
||||
JSBool js_pluginx_protocols_ProtocolAds_spendPoints(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
jsval *argv = JS_ARGV(cx, vp);
|
||||
|
@ -831,24 +831,28 @@ JSBool js_pluginx_protocols_ProtocolAds_configDeveloperInfo(JSContext *cx, uint3
|
|||
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1);
|
||||
return JS_FALSE;
|
||||
}
|
||||
JSBool js_pluginx_protocols_ProtocolAds_onPlayerGetPoints(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
JSBool js_pluginx_protocols_ProtocolAds_getAdsListener(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
jsval *argv = JS_ARGV(cx, vp);
|
||||
JSBool ok = JS_TRUE;
|
||||
JSObject *obj = JS_THIS_OBJECT(cx, vp);
|
||||
js_proxy_t *proxy = jsb_get_js_proxy(obj);
|
||||
cocos2d::plugin::ProtocolAds* cobj = (cocos2d::plugin::ProtocolAds *)(proxy ? proxy->ptr : NULL);
|
||||
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
|
||||
if (argc == 1) {
|
||||
int arg0;
|
||||
ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0);
|
||||
JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
|
||||
cobj->onPlayerGetPoints(arg0);
|
||||
JS_SET_RVAL(cx, vp, JSVAL_VOID);
|
||||
if (argc == 0) {
|
||||
cocos2d::plugin::AdsListener* ret = cobj->getAdsListener();
|
||||
jsval jsret;
|
||||
do {
|
||||
if (ret) {
|
||||
js_proxy_t *proxy = js_get_or_create_proxy<cocos2d::plugin::AdsListener>(cx, ret);
|
||||
jsret = OBJECT_TO_JSVAL(proxy->obj);
|
||||
} else {
|
||||
jsret = JSVAL_NULL;
|
||||
}
|
||||
} while (0);
|
||||
JS_SET_RVAL(cx, vp, jsret);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
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, 0);
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -889,12 +893,12 @@ void js_register_pluginx_protocols_ProtocolAds(JSContext *cx, JSObject *global)
|
|||
};
|
||||
|
||||
static JSFunctionSpec funcs[] = {
|
||||
JS_FN("showAds", js_pluginx_protocols_ProtocolAds_showAds, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE),
|
||||
JS_FN("hideAds", js_pluginx_protocols_ProtocolAds_hideAds, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
|
||||
JS_FN("queryPoints", js_pluginx_protocols_ProtocolAds_queryPoints, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
|
||||
JS_FN("onAdsResult", js_pluginx_protocols_ProtocolAds_onAdsResult, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE),
|
||||
JS_FN("spendPoints", js_pluginx_protocols_ProtocolAds_spendPoints, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
|
||||
JS_FN("configDeveloperInfo", js_pluginx_protocols_ProtocolAds_configDeveloperInfo, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
|
||||
JS_FN("onPlayerGetPoints", js_pluginx_protocols_ProtocolAds_onPlayerGetPoints, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
|
||||
JS_FN("getAdsListener", js_pluginx_protocols_ProtocolAds_getAdsListener, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
|
||||
JS_FS_END
|
||||
};
|
||||
|
||||
|
|
|
@ -63,12 +63,12 @@ JSBool js_pluginx_protocols_ProtocolAds_constructor(JSContext *cx, uint32_t argc
|
|||
void js_pluginx_protocols_ProtocolAds_finalize(JSContext *cx, JSObject *obj);
|
||||
void js_register_pluginx_protocols_ProtocolAds(JSContext *cx, JSObject *global);
|
||||
void register_all_pluginx_protocols(JSContext* cx, JSObject* obj);
|
||||
JSBool js_pluginx_protocols_ProtocolAds_showAds(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
JSBool js_pluginx_protocols_ProtocolAds_hideAds(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
JSBool js_pluginx_protocols_ProtocolAds_queryPoints(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
JSBool js_pluginx_protocols_ProtocolAds_onAdsResult(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
JSBool js_pluginx_protocols_ProtocolAds_spendPoints(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_getAdsListener(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
|
||||
extern JSClass *jsb_ProtocolShare_class;
|
||||
extern JSObject *jsb_ProtocolShare_prototype;
|
||||
|
|
|
@ -152,9 +152,16 @@ configDeveloperInfo : function () {},
|
|||
*/
|
||||
plugin.ProtocolAds = {
|
||||
|
||||
/**
|
||||
* @method showAds
|
||||
* @param {TAdsInfo}
|
||||
* @param {cocos2d::plugin::ProtocolAds::AdsPos}
|
||||
*/
|
||||
showAds : function () {},
|
||||
|
||||
/**
|
||||
* @method hideAds
|
||||
* @param {cocos2d::plugin::ProtocolAds::AdsType}
|
||||
* @param {TAdsInfo}
|
||||
*/
|
||||
hideAds : function () {},
|
||||
|
||||
|
@ -163,13 +170,6 @@ hideAds : function () {},
|
|||
*/
|
||||
queryPoints : function () {},
|
||||
|
||||
/**
|
||||
* @method onAdsResult
|
||||
* @param {cocos2d::plugin::AdsResultCode}
|
||||
* @param {const char*}
|
||||
*/
|
||||
onAdsResult : function () {},
|
||||
|
||||
/**
|
||||
* @method spendPoints
|
||||
* @param {int}
|
||||
|
@ -183,10 +183,10 @@ spendPoints : function () {},
|
|||
configDeveloperInfo : function () {},
|
||||
|
||||
/**
|
||||
* @method onPlayerGetPoints
|
||||
* @param {int}
|
||||
* @method getAdsListener
|
||||
* @return A value converted from C/C++ "cocos2d::plugin::AdsListener*"
|
||||
*/
|
||||
onPlayerGetPoints : function () {},
|
||||
getAdsListener : function () {},
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -16,11 +16,6 @@ plugin.ProtocolAds.AdsResultCode.PointsSpendFailed = 4;
|
|||
plugin.ProtocolAds.AdsResultCode.NetworkError = 5;
|
||||
plugin.ProtocolAds.AdsResultCode.UnknownError = 6;
|
||||
|
||||
plugin.ProtocolAds.AdsType = {};
|
||||
plugin.ProtocolAds.AdsType.BannerAd = 0;
|
||||
plugin.ProtocolAds.AdsType.FullScreenAd = 1;
|
||||
plugin.ProtocolAds.AdsType.MoreApp = 2;
|
||||
|
||||
plugin.ProtocolAds.AdsPos = {};
|
||||
plugin.ProtocolAds.AdsPos.PosCenter = 0;
|
||||
plugin.ProtocolAds.AdsPos.PosTop = 1;
|
||||
|
|
|
@ -206,6 +206,11 @@ JSBool jsval_to_TAdsDeveloperInfo(JSContext *cx, jsval v, TAdsDeveloperInfo* ret
|
|||
return jsval_to_TProductInfo(cx, v, ret);
|
||||
}
|
||||
|
||||
JSBool jsval_to_TAdsInfo(JSContext *cx, jsval v, TAdsInfo* ret)
|
||||
{
|
||||
return jsval_to_TProductInfo(cx, v, ret);
|
||||
}
|
||||
|
||||
JSBool jsval_to_TShareDeveloperInfo(JSContext *cx, jsval v, TShareDeveloperInfo* ret)
|
||||
{
|
||||
return jsval_to_TProductInfo(cx, v, ret);
|
||||
|
|
|
@ -29,6 +29,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_TIAPDeveloperInfo(JSContext *cx, jsval v, TIAPDeveloperInfo* ret);
|
||||
JSBool jsval_to_TAdsDeveloperInfo(JSContext *cx, jsval v, TAdsDeveloperInfo* ret);
|
||||
JSBool jsval_to_TAdsInfo(JSContext *cx, jsval v, TAdsInfo* ret);
|
||||
JSBool jsval_to_TShareDeveloperInfo(JSContext *cx, jsval v, TShareDeveloperInfo* ret);
|
||||
JSBool jsval_to_TShareInfo(JSContext *cx, jsval v, TShareInfo* ret);
|
||||
JSBool jsval_to_TSocialDeveloperInfo(JSContext *cx, jsval v, TSocialDeveloperInfo* ret);
|
||||
|
|
|
@ -33,7 +33,6 @@ 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_ProtocolAds_prototype, "setAdsListener", js_pluginx_ProtocolAds_setAdsListener, 1, JSPROP_READONLY | JSPROP_PERMANENT);
|
||||
JS_DefineFunction(cx, jsb_ProtocolAds_prototype, "showAds", js_pluginx_ProtocolAds_showAds, 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_ProtocolSocial_prototype, "setListener", js_pluginx_ProtocolSocial_setListener, 1, JSPROP_READONLY | JSPROP_PERMANENT);
|
||||
JS_DefineFunction(cx, jsb_ProtocolUser_prototype, "setActionListener", js_pluginx_ProtocolUser_setActionListener, 1, JSPROP_READONLY | JSPROP_PERMANENT);
|
||||
|
|
|
@ -173,47 +173,6 @@ JSBool js_pluginx_ProtocolAds_setAdsListener(JSContext *cx, uint32_t argc, jsval
|
|||
return JS_FALSE;
|
||||
}
|
||||
|
||||
JSBool js_pluginx_ProtocolAds_showAds(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
jsval *argv = JS_ARGV(cx, vp);
|
||||
JSBool ok = JS_TRUE;
|
||||
JSObject *obj = JS_THIS_OBJECT(cx, vp);
|
||||
js_proxy_t *proxy = jsb_get_js_proxy(obj);
|
||||
cocos2d::plugin::ProtocolAds* cobj = (cocos2d::plugin::ProtocolAds *)(proxy ? proxy->ptr : NULL);
|
||||
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
|
||||
if (argc == 1) {
|
||||
jsval params = argv[0];
|
||||
JSObject* tmp = JSVAL_TO_OBJECT(params);
|
||||
JSB_PRECONDITION2(tmp, cx, JS_FALSE, "Error processing arguments");
|
||||
|
||||
jsval tempVal;
|
||||
cocos2d::plugin::ProtocolAds::AdsType arg0;
|
||||
ok &= JS_GetProperty(cx, tmp, "AdsType", &tempVal);
|
||||
JSB_PRECONDITION2(ok, cx, JS_FALSE, "It should be contains 'AdsType' in parameter.");
|
||||
ok &= jsval_to_int32(cx, tempVal, (int32_t *) &arg0);
|
||||
JSB_PRECONDITION2(ok, cx, JS_FALSE, "Value of 'AdsType' must be int");
|
||||
|
||||
int sizeEnum = 0;
|
||||
if (JS_GetProperty(cx, tmp, "SizeEnum", &tempVal)) {
|
||||
ok &= jsval_to_int32(cx, tempVal, (int32_t *) &sizeEnum);
|
||||
JSB_PRECONDITION2(ok, cx, JS_FALSE, "Value of 'SizeEnum' should be int");
|
||||
}
|
||||
|
||||
cocos2d::plugin::ProtocolAds::AdsPos pos;
|
||||
if (JS_GetProperty(cx, tmp, "AdsPos", &tempVal)) {
|
||||
ok &= jsval_to_int32(cx, tempVal, (int32_t *) &pos);
|
||||
JSB_PRECONDITION2(ok, cx, JS_FALSE, "Value of 'AdsPos' should be int");
|
||||
}
|
||||
|
||||
cobj->showAds(arg0, sizeEnum, pos);
|
||||
JS_SET_RVAL(cx, vp, JSVAL_VOID);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1);
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
class Pluginx_ShareResult : public cocos2d::plugin::ShareResultListener
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
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_showAds(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
JSBool js_pluginx_ProtocolShare_setResultListener(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
JSBool js_pluginx_ProtocolSocial_setListener(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
JSBool js_pluginx_ProtocolUser_setActionListener(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
|
|
|
@ -37,7 +37,7 @@ classes = PluginProtocol PluginManager ProtocolIAP ProtocolAnalytics ProtocolAds
|
|||
# functions from all classes.
|
||||
|
||||
skip = ProtocolIAP::[setResultListener],
|
||||
ProtocolAds::[setAdsListener showAds],
|
||||
ProtocolAds::[setAdsListener],
|
||||
ProtocolShare::[setResultListener],
|
||||
ProtocolSocial::[setListener getListener],
|
||||
ProtocolUser::[setActionListener getActionListener],
|
||||
|
|
Loading…
Reference in New Issue