diff --git a/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp b/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp index 1f8bc98cae..273a692ef5 100644 --- a/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp +++ b/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp @@ -2430,13 +2430,13 @@ bool js_cocos2dx_CCNode_setColor(JSContext *cx, uint32_t argc, jsval *vp) cobj->setColor(arg0); // int32_t alpha; -// ok &= jsval_cccolor_to_opacity(cx, args.get(0), &alpha); +// ok &= jsval_cccolor_to_opacity(cx, args.get(0), &alpha); // if (ok) { // cobj->setOpacity(alpha); // } args.rval().setUndefined(); - return true; - } + return true; + } JS_ReportError(cx, "js_cocos2dx_Node_setColor : wrong number of arguments: %d, was expecting %d", argc, 1); return false; @@ -5353,81 +5353,81 @@ bool js_cocos2dx_Scene_getPhysics3DWorld(JSContext *cx, uint32_t argc, jsval *vp #if CC_USE_NAVMESH bool js_cocos2dx_Scene_setNavMeshDebugCamera(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::Scene* cobj = (cocos2d::Scene *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2(cobj, cx, false, "js_cocos2dx_Scene_setNavMeshDebugCamera : Invalid Native Object"); - if (argc == 1) { - cocos2d::Camera* arg0; - do { - if (args.get(0).isNull()) { arg0 = nullptr; break; } - if (!args.get(0).isObject()) { ok = false; break; } - js_proxy_t *jsProxy; - JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); - jsProxy = jsb_get_js_proxy(tmpObj); - arg0 = (cocos2d::Camera*)(jsProxy ? jsProxy->ptr : NULL); - JSB_PRECONDITION2(arg0, cx, false, "Invalid Native Object"); - } while (0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Scene_setNavMeshDebugCamera : Error processing arguments"); - cobj->setNavMeshDebugCamera(arg0); - args.rval().setUndefined(); - return true; - } + 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::Scene* cobj = (cocos2d::Scene *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2(cobj, cx, false, "js_cocos2dx_Scene_setNavMeshDebugCamera : Invalid Native Object"); + if (argc == 1) { + cocos2d::Camera* arg0; + do { + if (args.get(0).isNull()) { arg0 = nullptr; break; } + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Camera*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2(arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Scene_setNavMeshDebugCamera : Error processing arguments"); + cobj->setNavMeshDebugCamera(arg0); + args.rval().setUndefined(); + return true; + } - JS_ReportError(cx, "js_cocos2dx_Scene_setNavMeshDebugCamera : wrong number of arguments: %d, was expecting %d", argc, 1); - return false; + JS_ReportError(cx, "js_cocos2dx_Scene_setNavMeshDebugCamera : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; } bool js_cocos2dx_Scene_setNavMesh(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::Scene* cobj = (cocos2d::Scene *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2(cobj, cx, false, "js_cocos2dx_Scene_setNavMesh : Invalid Native Object"); - if (argc == 1) { - cocos2d::NavMesh* arg0; - do { - if (args.get(0).isNull()) { arg0 = nullptr; break; } - if (!args.get(0).isObject()) { ok = false; break; } - js_proxy_t *jsProxy; - JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); - jsProxy = jsb_get_js_proxy(tmpObj); - arg0 = (cocos2d::NavMesh*)(jsProxy ? jsProxy->ptr : NULL); - JSB_PRECONDITION2(arg0, cx, false, "Invalid Native Object"); - } while (0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Scene_setNavMesh : Error processing arguments"); - cobj->setNavMesh(arg0); - args.rval().setUndefined(); - return true; - } + 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::Scene* cobj = (cocos2d::Scene *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2(cobj, cx, false, "js_cocos2dx_Scene_setNavMesh : Invalid Native Object"); + if (argc == 1) { + cocos2d::NavMesh* arg0; + do { + if (args.get(0).isNull()) { arg0 = nullptr; break; } + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::NavMesh*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2(arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Scene_setNavMesh : Error processing arguments"); + cobj->setNavMesh(arg0); + args.rval().setUndefined(); + return true; + } - JS_ReportError(cx, "js_cocos2dx_Scene_setNavMesh : wrong number of arguments: %d, was expecting %d", argc, 1); - return false; + JS_ReportError(cx, "js_cocos2dx_Scene_setNavMesh : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; } bool js_cocos2dx_Scene_getNavMesh(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); - cocos2d::Scene* cobj = (cocos2d::Scene *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2(cobj, cx, false, "js_cocos2dx_Scene_getNavMesh : Invalid Native Object"); - if (argc == 0) { - cocos2d::NavMesh* ret = cobj->getNavMesh(); - jsval jsret = JSVAL_NULL; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Scene* cobj = (cocos2d::Scene *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2(cobj, cx, false, "js_cocos2dx_Scene_getNavMesh : Invalid Native Object"); + if (argc == 0) { + cocos2d::NavMesh* ret = cobj->getNavMesh(); + jsval jsret = JSVAL_NULL; if (ret) { js_type_class_t *typeClass = js_get_type_from_native(ret); jsret = OBJECT_TO_JSVAL(jsb_ref_get_or_create_jsobject(cx, ret, typeClass, "cocos2d::NavMesh")); } - args.rval().set(jsret); - return true; - } + args.rval().set(jsret); + return true; + } - JS_ReportError(cx, "js_cocos2dx_Scene_getNavMesh : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; + JS_ReportError(cx, "js_cocos2dx_Scene_getNavMesh : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; } #endif //CC_USE_NAVMESH @@ -5453,13 +5453,13 @@ bool js_cocos2dx_PolygonInfo_getArea(JSContext *cx, uint32_t argc, jsval *vp) JS_ReportError(cx, "js_cocos2dx_PolygonInfo_getArea : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } -bool js_cocos2dx_PolygonInfo_getTriaglesCount(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_PolygonInfo_getTrianglesCount(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); cocos2d::PolygonInfo* cobj = (cocos2d::PolygonInfo *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_PolygonInfo_getTriaglesCount : Invalid Native Object"); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_PolygonInfo_getTrianglesCount : Invalid Native Object"); if (argc == 0) { const unsigned int ret = cobj->getTrianglesCount(); @@ -5469,7 +5469,7 @@ bool js_cocos2dx_PolygonInfo_getTriaglesCount(JSContext *cx, uint32_t argc, jsva return true; } - JS_ReportError(cx, "js_cocos2dx_PolygonInfo_getTriaglesCount : wrong number of arguments: %d, was expecting %d", argc, 0); + JS_ReportError(cx, "js_cocos2dx_PolygonInfo_getTrianglesCount : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } bool js_cocos2dx_PolygonInfo_getVertCount(JSContext *cx, uint32_t argc, jsval *vp) @@ -5630,7 +5630,8 @@ void js_register_cocos2dx_PolygonInfo(JSContext *cx, JS::HandleObject global) static JSFunctionSpec funcs[] = { JS_FN("getArea", js_cocos2dx_PolygonInfo_getArea, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("getTriaglesCount", js_cocos2dx_PolygonInfo_getTriaglesCount, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTrianglesCount", js_cocos2dx_PolygonInfo_getTrianglesCount, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTriaglesCount", js_cocos2dx_PolygonInfo_getTrianglesCount, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getVertCount", js_cocos2dx_PolygonInfo_getVertCount, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -6237,9 +6238,9 @@ void register_cocos2dx_js_core(JSContext* cx, JS::HandleObject global) #endif //CC_ENABLE_BULLET_INTEGRATION && CC_USE_3D_PHYSICS #if CC_USE_NAVMESH - tmpObj.set(jsb_cocos2d_Scene_prototype); - JS_DefineFunction(cx, tmpObj, "getNavMesh", js_cocos2dx_Scene_getNavMesh, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); - JS_DefineFunction(cx, tmpObj, "setNavMeshDebugCamera", js_cocos2dx_Scene_setNavMeshDebugCamera, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); - JS_DefineFunction(cx, tmpObj, "setNavMesh", js_cocos2dx_Scene_setNavMesh, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); + tmpObj.set(jsb_cocos2d_Scene_prototype); + JS_DefineFunction(cx, tmpObj, "getNavMesh", js_cocos2dx_Scene_getNavMesh, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "setNavMeshDebugCamera", js_cocos2dx_Scene_setNavMeshDebugCamera, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "setNavMesh", js_cocos2dx_Scene_setNavMesh, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); #endif //CC_USE_NAVMESH } diff --git a/tests/js-tests/src/SpritePolygonTest/SpritePolygonTest.js b/tests/js-tests/src/SpritePolygonTest/SpritePolygonTest.js index da11edf7fc..e20d9293f9 100644 --- a/tests/js-tests/src/SpritePolygonTest/SpritePolygonTest.js +++ b/tests/js-tests/src/SpritePolygonTest/SpritePolygonTest.js @@ -429,7 +429,7 @@ var SpritePolygonPerformanceTestDynamic = SpritePolygonPerformance.extend({ }, initIncrementStats: function () { this._incVert = this._polygons.getVertCount(); - this._incTri = this._polygons.getTriaglesCount(); + this._incTri = this._polygons.getTrianglesCount(); this._incPix = this._polygons.getArea(); }, makeSprite: function () { diff --git a/tests/lua-tests/src/SpritePolygonTest/SpritePolygonTest.lua b/tests/lua-tests/src/SpritePolygonTest/SpritePolygonTest.lua index c5d3362e17..0718317b1c 100644 --- a/tests/lua-tests/src/SpritePolygonTest/SpritePolygonTest.lua +++ b/tests/lua-tests/src/SpritePolygonTest/SpritePolygonTest.lua @@ -690,7 +690,7 @@ end function SpritePolygonPerformanceTestDynamic:initIncrementStats() self._incVert = self._info:getVertCount() - self._incTri = self._info:getTriaglesCount() + self._incTri = self._info:getTrianglesCount() self._incPix = self._info:getArea() end @@ -746,4 +746,4 @@ function SpritePolygonTest() scene:addChild(CreateBackMenuItem()) return scene -end \ No newline at end of file +end