diff --git a/native/.travis.yml b/native/.travis.yml index 2cde41c24c..8bb07b54d1 100644 --- a/native/.travis.yml +++ b/native/.travis.yml @@ -8,7 +8,7 @@ before_install: - tools/travis-scripts/before-install.sh branches: only: - - develop + - v1.2 env: global: - secure: bUrk522Qw5Mc3SfDXHZtJ/aF9QbLXYDnUVSOJXt1wUB1d8xAQphTcZ1ARNYu7I5m3ZXqRfzTS4POOT58qeS3sYPpJ8urWW18hgX3I/dmsL1WJXmwnOV+0J3xLt6AT3ttqj7/emaf0xxuBvZ0szyRz0rU4wprtWftWMFiUrsF8G1an2Qa/g/f5LhilnDiKAqFdHMkn0ogaggL0PbgliHeHo7SEOfSF2gQaSIBta7jzE/BEZZ3R4AuReB3oNDwxr+1E4BpPaGO1lMLzdr8MAjWBGVLBRlpVDihgFTTmdka8UYasjEWDs6GbSjJRsTZQkluOo+1UylSiLn5o1tnWMqINo5DDaayBSKWRV/x+Sx+KMG221BwHLGFHrhEm8Jwc3g5IBiFrc9Xn/PAoCL3Zi/m0m8Y/TVIlA2nWuU0jeMZYXOb0ALCplAQMrG/Yt7euzgSjZ9iPvO7HO8BkaRkUxafcp6svWyMedNeDczG6liLSquJak+XIbOpWCOW+KVxc2S2Unz37MSOQR/aB9dJ8fKI/4e3LCdYrSKW9MSKAz9BSYA2IK2F8Fgr6zY3IPTANQCi6o8i/N54wsmpY17uvzqNDGuag5m/FkNpFWVQUy/TdONanXV6m1jvREaxtDHucSnP3olmvx6pi1awRspDfRmcILK08yvul+yLol0nQwenlx0= diff --git a/native/cocos/editor-support/creator/CCGraphicsNode.cpp b/native/cocos/editor-support/creator/CCGraphicsNode.cpp index 3647390519..c6606ed4eb 100644 --- a/native/cocos/editor-support/creator/CCGraphicsNode.cpp +++ b/native/cocos/editor-support/creator/CCGraphicsNode.cpp @@ -214,7 +214,7 @@ void GraphicsNode::arc(float cx, float cy, float r, float startAngle, float endA // Clamp angles da = endAngle - startAngle; - if (!counterclockwise) { + if (counterclockwise) { if (absf(da) >= PI_2) { da = PI_2; } else { @@ -233,7 +233,7 @@ void GraphicsNode::arc(float cx, float cy, float r, float startAngle, float endA hda = (da / (float)ndivs) / 2.0f; kappa = absf(4.0f / 3.0f * (1.0f - cosf(hda)) / sinf(hda)); - if (counterclockwise) { + if (!counterclockwise) { kappa = -kappa; } diff --git a/native/cocos/scripting/js-bindings/auto/jsb_creator_auto.cpp b/native/cocos/scripting/js-bindings/auto/jsb_creator_auto.cpp index 4f75509b9f..5f7b3bad27 100644 --- a/native/cocos/scripting/js-bindings/auto/jsb_creator_auto.cpp +++ b/native/cocos/scripting/js-bindings/auto/jsb_creator_auto.cpp @@ -8,6 +8,8 @@ static bool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedValue initializing(cx); bool isNewValid = true; + JS::RootedObject global(cx, ScriptingCore::getInstance()->getGlobalObject()); + isNewValid = JS_GetProperty(cx, global, "initializing", &initializing) && initializing.toBoolean(); if (isNewValid) { TypeTest t; @@ -22,13 +24,11 @@ static bool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) { JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject _tmp(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); - T* cobj = new T(); - js_proxy_t *pp = jsb_new_proxy(cobj, _tmp); - AddObjectRoot(cx, &pp->obj); args.rval().set(OBJECT_TO_JSVAL(_tmp)); return true; } + JS_ReportError(cx, "Constructor for the requested class is not available, please refer to the API reference."); return false; } @@ -784,6 +784,10 @@ bool js_creator_Scale9SpriteV2_constructor(JSContext *cx, uint32_t argc, jsval * JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; creator::Scale9SpriteV2* cobj = new (std::nothrow) creator::Scale9SpriteV2(); + cocos2d::Ref *_ccobj = dynamic_cast(cobj); + if (_ccobj) { + _ccobj->autorelease(); + } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); @@ -796,7 +800,8 @@ bool js_creator_Scale9SpriteV2_constructor(JSContext *cx, uint32_t argc, jsval * JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object - jsb_new_proxy(cobj, obj); + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "creator::Scale9SpriteV2"); if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; @@ -805,7 +810,11 @@ bool js_creator_Scale9SpriteV2_constructor(JSContext *cx, uint32_t argc, jsval * JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); creator::Scale9SpriteV2 *nobj = new (std::nothrow) creator::Scale9SpriteV2(); + if (nobj) { + nobj->autorelease(); + } js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "creator::Scale9SpriteV2"); bool isFound = false; if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); @@ -817,18 +826,6 @@ extern JSObject *jsb_cocos2d_Node_prototype; void js_creator_Scale9SpriteV2_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (Scale9SpriteV2)", obj); - JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); - JS::RootedObject jsobj(cx, obj); - auto proxy = jsb_get_js_proxy(jsobj); - if (proxy) { - creator::Scale9SpriteV2 *nobj = static_cast(proxy->ptr); - - if (nobj) { - jsb_remove_proxy(proxy); - nobj->release(); - } - else jsb_remove_proxy(proxy); - } } void js_register_creator_Scale9SpriteV2(JSContext *cx, JS::HandleObject global) { @@ -1595,6 +1592,10 @@ bool js_creator_GraphicsNode_constructor(JSContext *cx, uint32_t argc, jsval *vp JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; creator::GraphicsNode* cobj = new (std::nothrow) creator::GraphicsNode(); + cocos2d::Ref *_ccobj = dynamic_cast(cobj); + if (_ccobj) { + _ccobj->autorelease(); + } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); @@ -1607,7 +1608,8 @@ bool js_creator_GraphicsNode_constructor(JSContext *cx, uint32_t argc, jsval *vp JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object - jsb_new_proxy(cobj, obj); + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "creator::GraphicsNode"); if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; @@ -1616,7 +1618,11 @@ bool js_creator_GraphicsNode_constructor(JSContext *cx, uint32_t argc, jsval *vp JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); creator::GraphicsNode *nobj = new (std::nothrow) creator::GraphicsNode(); + if (nobj) { + nobj->autorelease(); + } js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "creator::GraphicsNode"); bool isFound = false; if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); @@ -1628,18 +1634,6 @@ extern JSObject *jsb_cocos2d_Node_prototype; void js_creator_GraphicsNode_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (GraphicsNode)", obj); - JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); - JS::RootedObject jsobj(cx, obj); - auto proxy = jsb_get_js_proxy(jsobj); - if (proxy) { - creator::GraphicsNode *nobj = static_cast(proxy->ptr); - - if (nobj) { - jsb_remove_proxy(proxy); - nobj->release(); - } - else jsb_remove_proxy(proxy); - } } void js_register_creator_GraphicsNode(JSContext *cx, JS::HandleObject global) { diff --git a/native/tools/tojs/creator.ini b/native/tools/tojs/creator.ini index d57a7a029e..97674c8da2 100755 --- a/native/tools/tojs/creator.ini +++ b/native/tools/tojs/creator.ini @@ -63,4 +63,4 @@ base_classes_to_skip = Ref abstract_classes = Helper LayoutManager AbstractCheckButton # 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 = no