static bool constructHook(JSContext* cx, unsigned argc, JS::Value* vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); // Check that arguments were passed properly from JS_New. JS::RootedObject obj(cx, JS_NewPlainObject(cx)); if (!obj) { JS_ReportError(cx, "test failed, could not construct object"); return false; } if (strcmp(JS_GetClass(obj)->name, "Object") != 0) { JS_ReportError(cx, "test failed, wrong class for 'this'"); return false; } if (args.length() != 3) { JS_ReportError(cx, "test failed, argc == %d", args.length()); return false; } if (!args[0].isInt32() || args[2].toInt32() != 2) { JS_ReportError(cx, "test failed, wrong value in args[2]"); return false; } if (!args.isConstructing()) { JS_ReportError(cx, "test failed, not constructing"); return false; } // Perform a side-effect to indicate that this hook was actually called. JS::RootedValue value(cx, args[0]); JS::RootedObject callee(cx, &args.callee()); if (!JS_SetElement(cx, callee, 0, value)) return false; args.rval().setObject(*obj); // trash the argv, perversely args[0].setUndefined(); args[1].setUndefined(); args[2].setUndefined(); return true; }
bool runtime_FileUtils_addSearchPath(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "cocos2dx_FileUtils_addSearchPath : Invalid Native Object"); if (argc == 1 || argc == 2) { std::string arg0; bool arg1 = false; ok &= jsval_to_std_string(cx, args.get(0), &arg0); JSB_PRECONDITION2(ok, cx, false, "cocos2dx_FileUtils_addSearchPath : Error processing arguments"); if (argc == 2) { arg1 = JS::ToBoolean(args.get(1)); } if (! FileUtils::getInstance()->isAbsolutePath(arg0)) { // add write path to search path if (FileServer::getShareInstance()->getIsUsingWritePath()) { cobj->addSearchPath(FileServer::getShareInstance()->getWritePath() + arg0, arg1); } else { cobj->addSearchPath(arg0, arg1); } #if(CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) // add project path to search path cobj->addSearchPath(g_projectPath + arg0, arg1); #endif } args.rval().setUndefined(); return true; } JS_ReportError(cx, "cocos2dx_FileUtils_addSearchPath : wrong number of arguments: %d, was expecting %d", argc, 1); return false; }
//manual-binding bool js_cocos2dx_cocosAds_CocosAds_addBannerAdListener(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); CocosAds* cobj = (CocosAds *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_cocosAds_CocosAds_addBannerAdListener : Invalid Native Object"); if (argc == 1) { std::function<void (int, std::basic_string<char>)> arg0; do { if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) { std::shared_ptr<JSFunctionWrapper> func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(0))); auto lambda = [=](int larg0, std::basic_string<char> larg1) -> void { cocos2d::Director::getInstance()->getScheduler()->performFunctionInCocosThread([=]{ JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[2]; largv[0] = int32_to_jsval(cx, larg0); largv[1] = std_string_to_jsval(cx, larg1); JS::RootedValue rval(cx); bool succeed = func->invoke(2, &largv[0], &rval); if (!succeed && JS_IsExceptionPending(cx)) { JS_ReportPendingException(cx); } }); }; arg0 = lambda; } else { arg0 = nullptr; } } while(0) ; JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_cocosAds_CocosAds_addBannerAdListener : Error processing arguments"); cobj->addBannerAdListener(arg0); args.rval().setUndefined(); return true; } JS_ReportError(cx, "js_cocos2dx_cocosAds_CocosAds_addBannerAdListener : wrong number of arguments: %d, was expecting %d", argc, 1); return false; }
bool js_cocos2dx_DrawNode3D_drawCube(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::DrawNode3D* cobj = (cocos2d::DrawNode3D *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_DrawNode3D_drawCube : Invalid Native Object"); if (argc == 2) { cocos2d::Vec3 arg0[8]; cocos2d::Color4F arg1; JS::RootedObject jsVec3Array(cx, args.get(0).toObjectOrNull()); JSB_PRECONDITION3( jsVec3Array && JS_IsArrayObject( cx, jsVec3Array), cx, false, "augument must be an array"); uint32_t len = 0; JS_GetArrayLength(cx, jsVec3Array, &len); if (len != 8) { JS_ReportError(cx, "array length error: %d, was expecting 8", len); } for (uint32_t i=0; i < len; i++) { JS::RootedValue value(cx); if (JS_GetElement(cx, jsVec3Array, i, &value)) { ok &= jsval_to_vector3(cx, value, &arg0[i]); if(!ok) break; } } ok &= jsval_to_cccolor4f(cx, args.get(1), &arg1); JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_DrawNode3D_drawCube : Error processing arguments"); cobj->drawCube(arg0, arg1); args.rval().setUndefined(); return true; } JS_ReportError(cx, "js_cocos2dx_DrawNode3D_drawCube : wrong number of arguments: %d, was expecting %d", argc, 2); return false; }
bool JSB_glGetProgramInfoLog(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; uint32_t arg0; ok &= jsval_to_uint( cx, args.get(0), &arg0 ); JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); GLsizei length; glGetProgramiv(arg0, GL_INFO_LOG_LENGTH, &length); GLchar* src = new GLchar[length]; glGetProgramInfoLog(arg0, length, NULL, src); args.rval().set(charptr_to_jsval(cx, src)); CC_SAFE_DELETE_ARRAY(src); return true; }
bool js_PluginChartboostJS_PluginChartboost_handleOpenURL(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; if (argc == 2) { std::string arg0; std::string arg1; ok &= jsval_to_std_string(cx, args.get(0), &arg0); ok &= jsval_to_std_string(cx, args.get(1), &arg1); JSB_PRECONDITION2(ok, cx, false, "js_PluginChartboostJS_PluginChartboost_handleOpenURL : Error processing arguments"); bool ret = sdkbox::PluginChartboost::handleOpenURL(arg0, arg1); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); args.rval().set(jsret); return true; } JS_ReportError(cx, "js_PluginChartboostJS_PluginChartboost_handleOpenURL : wrong number of arguments"); return false; }
static bool _js_get_SIOClient_tag(JSContext* cx, uint32_t argc, jsval* vp) { CCLOG("JSB SocketIO.getTag method called"); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JSObject* jsobj = args.thisv().toObjectOrNull(); js_proxy_t *proxy = jsb_get_js_proxy(jsobj); SIOClient* cobj = (SIOClient *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); if (cobj) { args.rval().set(std_string_to_jsval(cx, cobj->getTag())); return true; } else { JS_ReportError(cx, "Error: SocketIO instance is invalid."); return false; } }
static JSBool AfxGlImage_floatDepthBufferToByteBuffer(JSContext *cx, unsigned argc, JS::Value *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); if(0 > args.length()) return JS_FALSE; JSObject * jsObj; if(!JS_ValueToObject(cx, args.thisv(), &jsObj)) return JS_FALSE; AfxGlImage *afxGlImage = (AfxGlImage *)JS_GetPrivate(jsObj); if(!AfxImageUtils::FloatDepthBufferToByteBuffer(afxGlImage)) return JS_FALSE; args.rval().set(JSVAL_VOID); return JS_TRUE; }
bool js_EventListenerFocus_create(JSContext *cx, uint32_t argc, jsval *vp) { if(argc == 0) { auto ret = EventListenerFocus::create(); ret->onFocusChanged = [ret](ui::Widget* widgetLoseFocus, ui::Widget* widgetGetFocus){ ScriptingCore::getInstance()->handleFocusEvent(ret, widgetLoseFocus, widgetGetFocus); }; JS::RootedValue jsret(cx, OBJECT_TO_JSVAL(js_get_or_create_jsobject<EventListenerFocus>(cx, ret))); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); args.rval().set(jsret); return true; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0); return false; }
static JSBool copyPathFlat_func(JSContext *context, unsigned argc, jsval *vp) { JS::CallArgs argv = JS::CallArgsFromVp (argc, vp); JSObject *obj = JSVAL_TO_OBJECT(argv.thisv()); cairo_path_t *path; cairo_t *cr; if (!gjs_parse_call_args(context, "", "", argv)) return JS_FALSE; cr = gjs_cairo_context_get_context(context, obj); path = cairo_copy_path_flat(cr); argv.rval().set(OBJECT_TO_JSVAL(gjs_cairo_path_from_path(context, path))); return JS_TRUE; }
bool js_cocos2dx_audioengine_AudioEngine_setCurrentTime(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; if (argc == 2) { int arg0; double arg1; ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); ok &= JS::ToNumber( cx, args.get(1), &arg1) && !std::isnan(arg1); JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_audioengine_AudioEngine_setCurrentTime : Error processing arguments"); bool ret = cocos2d::experimental::AudioEngine::setCurrentTime(arg0, arg1); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); args.rval().set(jsret); return true; } JS_ReportError(cx, "js_cocos2dx_audioengine_AudioEngine_setCurrentTime : wrong number of arguments"); return false; }
bool jsb_util_getFileStat(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); //JS::RootedString appArgs(cx); if (argc == 1) { std::string arg0; bool ok = jsval_to_std_string(cx, args.get(0), &arg0); JSB_PRECONDITION2(ok, cx, false, "jsb_util_getFileStat : Error processing arguments"); auto stat = Utils::GetFileStat(arg0.c_str()); args.rval().setObjectOrNull(c_pointer_to_js_object<Utils::FileStat>(cx, stat)); return true; } JS_ReportError(cx, "jsb_util_getFileStat : wrong number of arguments"); return false; }
bool js_cocos2dx_Bundle3D_getTrianglesList(JSContext *cx, uint32_t argc, jsval *vp) { if(argc == 1) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); std::string path; bool ok = jsval_to_std_string(cx, args.get(0), &path); JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); std::vector<cocos2d::Vec3> triangles = cocos2d::Bundle3D::getTrianglesList(path); JS::RootedValue ret(cx, std_vector_vec3_to_jsval(cx, triangles)); args.rval().set(ret); return true; } JS_ReportError(cx, "wrong number of arguments"); return false; }
static bool jsb_ErayLayer_setJSHandler(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); ErayLayer* cobj = (ErayLayer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2(cobj, cx, false, "Invalid Native Object"); if (argc == 1) { // save the delegate JSB_ErayDelegate* nativeDelegate = new (std::nothrow) JSB_ErayDelegate(); nativeDelegate->setJSDelegate(args.get(0)); cobj->setDelegate(nativeDelegate); args.rval().setUndefined(); nativeDelegate->release(); return true; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); return false; }
// DOMString? getShaderSource(WebGLShader? shader); bool JSB_glGetShaderSource(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; uint32_t arg0; ok &= jsval_to_uint( cx, args.get(0), &arg0 ); JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); GLsizei length; glGetShaderiv(arg0, GL_SHADER_SOURCE_LENGTH, &length); GLchar* src = new (std::nothrow) GLchar[length]; glGetShaderSource(arg0, length, NULL, src); args.rval().set(charptr_to_jsval(cx, src)); CC_SAFE_DELETE_ARRAY(src); return true; }
bool js_PluginGoogleAnalyticsJS_PluginGoogleAnalytics_logSocial(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; if (argc == 3) { std::string arg0; std::string arg1; std::string arg2; ok &= jsval_to_std_string(cx, args.get(0), &arg0); ok &= jsval_to_std_string(cx, args.get(1), &arg1); ok &= jsval_to_std_string(cx, args.get(2), &arg2); JSB_PRECONDITION2(ok, cx, false, "js_PluginGoogleAnalyticsJS_PluginGoogleAnalytics_logSocial : Error processing arguments"); sdkbox::PluginGoogleAnalytics::logSocial(arg0, arg1, arg2); args.rval().setUndefined(); return true; } JS_ReportError(cx, "js_PluginGoogleAnalyticsJS_PluginGoogleAnalytics_logSocial : wrong number of arguments"); return false; }
void TimestampInfo::construct(JSContext* cx, JS::CallArgs args) { auto scope = getScope(cx); JS::RootedObject thisv(cx); scope->getProto<TimestampInfo>().newObject(&thisv); ObjectWrapper o(cx, thisv); if (args.length() == 0) { o.setNumber(InternedString::t, 0); o.setNumber(InternedString::i, 0); } else if (args.length() == 2) { o.setNumber(InternedString::t, getTimestampArg(cx, args, 0, "Timestamp time (seconds)")); o.setNumber(InternedString::i, getTimestampArg(cx, args, 1, "Timestamp increment")); } else { uasserted(ErrorCodes::BadValue, "Timestamp needs 0 or 2 arguments"); } args.rval().setObjectOrNull(thisv); }
bool js_cocos2dx_physics3d_Physics3dShape_createHeightfield(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 8 || argc == 9) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; int arg0; int arg1; std::vector<float> arg2; double arg3; double arg4; double arg5; bool arg6; bool arg7; bool arg8; ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); ok &= jsval_to_std_vector_float(cx, args.get(2), &arg2); ok &= JS::ToNumber( cx, args.get(3), &arg3) && !isnan(arg3); ok &= JS::ToNumber( cx, args.get(4), &arg4) && !isnan(arg4); ok &= JS::ToNumber( cx, args.get(5), &arg5) && !isnan(arg5); arg6 = JS::ToBoolean(args.get(6)); arg7 = JS::ToBoolean(args.get(7)); if(argc == 9) arg8 = JS::ToBoolean(args.get(8)); JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_physics3d_Physics3DShape_createHeightfield : Error processing arguments"); cocos2d::Physics3DShape* ret = nullptr; if(argc == 8) ret = cocos2d::Physics3DShape::createHeightfield(arg0, arg1, &arg2[0], arg3, arg4, arg5, arg6, arg7); else if(argc == 9) ret = cocos2d::Physics3DShape::createHeightfield(arg0, arg1, &arg2[0], arg3, arg4, arg5, arg6, arg7, arg8); JS::RootedObject jsobj(cx, js_get_or_create_jsobject<cocos2d::Physics3DShape>(cx, ret)); jsval jsret = OBJECT_TO_JSVAL(jsobj); args.rval().set(jsret); return true; } JS_ReportError(cx, "js_cocos2dx_physics3d_Physics3DShape_createHeightfield : wrong number of arguments"); return false; }
bool js_cocos2dx_nativehelper_NativeHelper_setPacketAssembler(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::NativeHelper* cobj = (cocos2d::NativeHelper *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_nativehelper_NativeHelper_setPacketAssembler : Invalid Native Object"); if (argc == 1) { std::function<void (std::basic_string<char>, int)> arg0; do { if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) { std::shared_ptr<JSFunctionWrapper> func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(0))); auto lambda = [=](std::basic_string<char> larg0, int larg1) -> void { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval largv[2]; largv[0] = std_string_to_jsval(cx, larg0); largv[1] = int32_to_jsval(cx, larg1); JS::RootedValue rval(cx); bool ok = func->invoke(2, &largv[0], &rval); if (!ok && JS_IsExceptionPending(cx)) { JS_ReportPendingException(cx); } }; arg0 = lambda; } else { arg0 = nullptr; } } while(0) ; JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_nativehelper_NativeHelper_setPacketAssembler : Error processing arguments"); cobj->setPacketAssembler(arg0); args.rval().setUndefined(); return true; } JS_ReportError(cx, "js_cocos2dx_nativehelper_NativeHelper_setPacketAssembler : wrong number of arguments: %d, was expecting %d", argc, 1); return false; }
bool js_cocos2dx_Effect3DOutline_create(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); if (argc == 0) { Effect3DOutline* ret = Effect3DOutline::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *jsProxy = js_get_or_create_proxy<Effect3DOutline>(cx, (Effect3DOutline*)ret); jsret = OBJECT_TO_JSVAL(jsProxy->obj); } else { jsret = JSVAL_NULL; } } while (0); args.rval().set(jsret); return true; } JS_ReportError(cx, "js_cocos2dx_Effect3DOutline_create : wrong number of arguments"); return false; }
bool jsb_spine_TrackEntry_get_mixingFrom(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(jsthis); spTrackEntry* cobj = (spTrackEntry *)(proxy ? proxy->ptr : NULL); if (cobj) { JS::RootedValue jsret(cx, JS::NullValue()); if (cobj->mixingFrom) { jsret = sptrackentry_to_jsval(cx, *cobj->mixingFrom); } args.rval().set(jsret); return true; } else { CCLOGERROR("jsb_spine_TrackEntry_get_previous : Invalid Native Object"); return false; } }
bool js_cocos2dx_extension_ImagePicker_getInstance(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); if (argc == 0) { cocos2d::ImagePicker* ret = cocos2d::ImagePicker::getInstance(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *jsProxy = js_get_or_create_proxy<cocos2d::ImagePicker>(cx, (cocos2d::ImagePicker*)ret); jsret = OBJECT_TO_JSVAL(jsProxy->obj); } else { jsret = JSVAL_NULL; } } while (0); args.rval().set(jsret); return true; } JS_ReportError(cx, "js_cocos2dx_extension_ImagePicker_getInstance : wrong number of arguments"); return false; }
bool js_cocos2dx_Effect3DOutline_setOutlineColor(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); Effect3DOutline* cobj = (Effect3DOutline *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Effect3DOutline_setOutlineColor : Invalid Native Object"); if (argc == 1) { cocos2d::Vec3 arg0; ok &= jsval_to_vector3(cx, args.get(0), &arg0); JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Effect3DOutline_setOutlineColor : Error processing arguments"); cobj->setOutlineColor(arg0); args.rval().setUndefined(); return true; } JS_ReportError(cx, "js_cocos2dx_Effect3DOutline_setOutlineColor : wrong number of arguments: %d, was expecting %d", argc, 1); return false; }
bool js_cocos2dx_experimental_webView_WebView_create(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); if (argc == 0) { cocos2d::experimental::ui::WebView* ret = cocos2d::experimental::ui::WebView::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *jsProxy = js_get_or_create_proxy<cocos2d::experimental::ui::WebView>(cx, (cocos2d::experimental::ui::WebView*)ret); jsret = OBJECT_TO_JSVAL(jsProxy->obj); } else { jsret = JSVAL_NULL; } } while (0); args.rval().set(jsret); return true; } JS_ReportError(cx, "js_cocos2dx_experimental_webView_WebView_create : wrong number of arguments"); return false; }
bool jsb_util_setIniInt(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); //JS::RootedString appArgs(cx); if (argc == 4) { std::string arg0, arg1, arg2; int arg3; bool ok = jsval_to_std_string(cx, args.get(0), &arg0); ok &= jsval_to_std_string(cx, args.get(1), &arg1); ok &= jsval_to_std_string(cx, args.get(2), &arg2); ok &= jsval_to_int32(cx, args.get(3), (int32_t *)&arg3); JSB_PRECONDITION2(ok, cx, false, "jsb_util_setIniInt : Error processing arguments"); args.rval().setBoolean(Utils::SetIniInt(arg0.c_str(), arg1.c_str(), arg2.c_str(), arg3)); return true; } JS_ReportError(cx, "jsb_util_setIniInt : wrong number of arguments"); return false; }
bool js_cocos2dx_experimental_video_VideoPlayer_setKeepAspectRatioEnabled(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::experimental::ui::VideoPlayer* cobj = (cocos2d::experimental::ui::VideoPlayer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_experimental_video_VideoPlayer_setKeepAspectRatioEnabled : Invalid Native Object"); if (argc == 1) { bool arg0; arg0 = JS::ToBoolean(args.get(0)); JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_experimental_video_VideoPlayer_setKeepAspectRatioEnabled : Error processing arguments"); cobj->setKeepAspectRatioEnabled(arg0); args.rval().setUndefined(); return true; } JS_ReportError(cx, "js_cocos2dx_experimental_video_VideoPlayer_setKeepAspectRatioEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); return false; }
bool js_cocos2dx_experimental_webView_WebView_setJavascriptInterfaceScheme(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::experimental::ui::WebView* cobj = (cocos2d::experimental::ui::WebView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_experimental_webView_WebView_setJavascriptInterfaceScheme : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, args.get(0), &arg0); JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_experimental_webView_WebView_setJavascriptInterfaceScheme : Error processing arguments"); cobj->setJavascriptInterfaceScheme(arg0); args.rval().setUndefined(); return true; } JS_ReportError(cx, "js_cocos2dx_experimental_webView_WebView_setJavascriptInterfaceScheme : wrong number of arguments: %d, was expecting %d", argc, 1); return false; }
bool js_cocos2dx_nativehelper_NativeHelper_singleton(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); if (argc == 0) { cocos2d::NativeHelper* ret = cocos2d::NativeHelper::singleton(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *jsProxy = js_get_or_create_proxy<cocos2d::NativeHelper>(cx, (cocos2d::NativeHelper*)ret); jsret = OBJECT_TO_JSVAL(jsProxy->obj); } else { jsret = JSVAL_NULL; } } while (0); args.rval().set(jsret); return true; } JS_ReportError(cx, "js_cocos2dx_nativehelper_NativeHelper_singleton : wrong number of arguments"); return false; }
bool jsb_util_exec(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); //JS::RootedString appArgs(cx); if (argc == 3) { std::string arg0, arg1, arg2; bool ok = jsval_to_std_string(cx, args.get(0), &arg0); ok &= jsval_to_std_string(cx, args.get(1), &arg1); ok &= jsval_to_std_string(cx, args.get(2), &arg2); JSB_PRECONDITION2(ok, cx, false, "jsb_util_exec : Error processing arguments"); Utils::Exec(arg0.c_str(), arg1.c_str(), arg2.c_str()); args.rval().setUndefined(); return true; } JS_ReportError(cx, "jsb_util_exec : wrong number of arguments"); return false; }
// jsb.loadRemoteImg(url, function(succeed, result) {}) bool js_load_remote_image(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JSObject *obj = JS_THIS_OBJECT(cx, vp); if (argc == 2) { std::string url; bool ok = jsval_to_std_string(cx, args.get(0), &url); jsval callback = args.get(1); __JSDownloaderDelegator::download(cx, obj, url, callback); JSB_PRECONDITION2(ok, cx, false, "js_console_log : Error processing arguments"); args.rval().setUndefined(); return true; } JS_ReportError(cx, "js_load_remote_image : wrong number of arguments"); return false; }