From b83ce1e69e7a11c7ceb51d1b0a2c56509c7effac Mon Sep 17 00:00:00 2001 From: Jare Guo Date: Tue, 26 Sep 2017 10:27:25 +0800 Subject: [PATCH 1/3] minor tweak for #834 --- .../cocos/editor-support/dragonbones/animation/Animation.cpp | 4 ++-- native/cocos/editor-support/dragonbones/animation/Animation.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/native/cocos/editor-support/dragonbones/animation/Animation.cpp b/native/cocos/editor-support/dragonbones/animation/Animation.cpp index 7942e7340e..23e49e9272 100644 --- a/native/cocos/editor-support/dragonbones/animation/Animation.cpp +++ b/native/cocos/editor-support/dragonbones/animation/Animation.cpp @@ -482,7 +482,7 @@ bool Animation::isCompleted() const return false; } -const std::string& Animation::getLastAnimationName() const +std::string Animation::getLastAnimationName() const { if (_lastAnimationState) { @@ -510,4 +510,4 @@ void Animation::setAnimations(const std::map& value } } -DRAGONBONES_NAMESPACE_END \ No newline at end of file +DRAGONBONES_NAMESPACE_END diff --git a/native/cocos/editor-support/dragonbones/animation/Animation.h b/native/cocos/editor-support/dragonbones/animation/Animation.h index a9811510ff..be3d59ea18 100644 --- a/native/cocos/editor-support/dragonbones/animation/Animation.h +++ b/native/cocos/editor-support/dragonbones/animation/Animation.h @@ -80,7 +80,7 @@ public: bool hasAnimation(const std::string& animationName) const; bool isPlaying() const; bool isCompleted() const; - const std::string& getLastAnimationName() const; + std::string getLastAnimationName() const; void setAnimations(const std::map& value); inline AnimationState* getLastAnimationState() const @@ -100,4 +100,4 @@ public: }; DRAGONBONES_NAMESPACE_END -#endif // DRAGONBONES_ANIMATION_H \ No newline at end of file +#endif // DRAGONBONES_ANIMATION_H From 40ce4bc9716dc0d5b8930aa65affc2bb2b580ec3 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Tue, 26 Sep 2017 03:05:45 +0000 Subject: [PATCH 2/3] [ci skip][AUTO]: updating jsbinding automatically --- .../js-bindings/auto/jsb_cocos2dx_dragonbones_auto.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_dragonbones_auto.cpp b/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_dragonbones_auto.cpp index f843539a76..ff13406346 100644 --- a/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_dragonbones_auto.cpp +++ b/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_dragonbones_auto.cpp @@ -3667,7 +3667,7 @@ bool js_cocos2dx_dragonbones_Animation_getLastAnimationName(JSContext *cx, uint3 dragonBones::Animation* cobj = (dragonBones::Animation *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_dragonbones_Animation_getLastAnimationName : Invalid Native Object"); if (argc == 0) { - const std::string& ret = cobj->getLastAnimationName(); + std::string ret = cobj->getLastAnimationName(); JS::RootedValue jsret(cx); ok &= std_string_to_jsval(cx, ret, &jsret); JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_dragonbones_Animation_getLastAnimationName : error parsing return value"); From 1f5cda12e2817347cd49a85aa5f45bc7b8657075 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Fri, 6 Oct 2017 15:25:06 +0800 Subject: [PATCH 3/3] Remove scheduleCallbackForTarget with selector usage --- .../js-bindings/manual/cocos2d_specifics.cpp | 104 ------------------ 1 file changed, 104 deletions(-) diff --git a/native/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp b/native/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp index dfabe5fa64..e9d44119c7 100644 --- a/native/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp +++ b/native/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp @@ -1578,85 +1578,6 @@ bool js_CCScheduler_unscheduleUpdateForTarget(JSContext *cx, uint32_t argc, JS:: return false; } -bool js_CCScheduler_scheduleCallbackForTarget(JSContext *cx, uint32_t argc, JS::Value *vp) -{ - if (argc >= 2) { - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - - JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); - js_proxy_t *proxy = jsb_get_js_proxy(cx, obj); - cocos2d::Scheduler *sched = (cocos2d::Scheduler *)(proxy ? proxy->ptr : nullptr); - - JSScheduleWrapper *tmpCObj = nullptr; - - JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); - proxy = jsb_get_js_proxy(cx, tmpObj); - - JS::RootedObject jsFunc(cx, args.get(1).toObjectOrNull()); - - double interval = 0; - if( argc >= 3 && args.get(2).isNumber() ) { - interval = args.get(2).toNumber(); - } - - // - // repeat - // - double repeat = kRepeatForever; - if( argc >= 4 && args.get(3).isNumber() ) { - repeat = args.get(3).toNumber(); - } - - // - // delay - // - double delay = 0; - if( argc >= 5 && args.get(4).isNumber() ) { - delay = args.get(4).toNumber(); - } - - bool paused = false; - - if( argc >= 6 && args.get(5).isBoolean() ) { - paused = args.get(5).toBoolean(); - } - - bool bFound = false; - auto pTargetArr = JSScheduleWrapper::getTargetForJSObject(cx, tmpObj); - if (pTargetArr) - { - JS::RootedObject wrapperFunc(cx); - for (auto&& pObj : *pTargetArr) - { - JSScheduleWrapper* pTarget = pObj; - pTarget->getJSCallback(cx, &wrapperFunc); - if (jsFunc.get() == wrapperFunc.get()) - { - tmpCObj = pTarget; - bFound = true; - break; - } - } - } - - if (!bFound) - { - tmpCObj = new (std::nothrow) JSScheduleWrapper(cx, tmpObj, jsFunc, obj); - tmpCObj->autorelease(); - - JSScheduleWrapper::setTargetForSchedule(cx, args.get(1), tmpCObj); - JSScheduleWrapper::setTargetForJSObject(cx, tmpObj, tmpCObj); - } - - sched->schedule(schedule_selector(JSScheduleWrapper::scheduleFunc), tmpCObj, interval, repeat, delay, paused); - - args.rval().setUndefined(); - return true; - } - JS_ReportErrorUTF8(cx, "wrong number of arguments"); - return false; -} - bool js_CCScheduler_schedule(JSContext *cx, uint32_t argc, JS::Value *vp) { if (argc >= 2) { @@ -1757,29 +1678,6 @@ bool js_CCScheduler_unscheduleCallbackForTarget(JSContext *cx, uint32_t argc, JS JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); cobj->unschedule(key, tmpObj); } - else { - JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); - - auto arr = JSScheduleWrapper::getTargetForJSObject(cx, tmpObj); - // If there aren't any targets, just return true. - // Otherwise, the for loop will break immediately. - // It will lead to logic errors. - // For details to reproduce it, please refer to SchedulerTest/SchedulerUpdate. - if(! arr) return true; - - JS::RootedObject tmpFunc(cx, args.get(1).toObjectOrNull()); - JSScheduleWrapper* wrapper = nullptr; - for(ssize_t i = 0; i < arr->size(); ++i) { - wrapper = (JSScheduleWrapper*)arr->at(i); - JS::RootedObject wrapperFunc(cx); - wrapper->getJSCallback(cx, &wrapperFunc); - if(wrapperFunc.get() == tmpFunc.get()) { - cobj->unschedule(schedule_selector(JSScheduleWrapper::scheduleFunc), wrapper); - JSScheduleWrapper::removeTargetForJSObject(cx, tmpObj, wrapper); - break; - } - } - } } while (0); args.rval().setUndefined(); @@ -4922,9 +4820,7 @@ void register_cocos2dx_js_core(JSContext* cx, JS::HandleObject global) JS_DefineFunction(cx, tmpObj, "scheduleUpdateForTarget", js_CCScheduler_scheduleUpdateForTarget, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, tmpObj, "unscheduleUpdate", js_CCScheduler_unscheduleUpdateForTarget, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, tmpObj, "schedule", js_CCScheduler_schedule, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT); - JS_DefineFunction(cx, tmpObj, "scheduleCallbackForTarget", js_CCScheduler_scheduleCallbackForTarget, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, tmpObj, "unschedule", js_CCScheduler_unscheduleCallbackForTarget, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT); - JS_DefineFunction(cx, tmpObj, "unscheduleCallbackForTarget", js_CCScheduler_unscheduleCallbackForTarget, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, tmpObj, "unscheduleAllForTarget", js_cocos2dx_CCScheduler_unscheduleAllSelectorsForTarget, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, tmpObj, "unscheduleAllCallbacks", js_cocos2dx_CCScheduler_unscheduleAll, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, tmpObj, "unscheduleAllCallbacksWithMinPriority", js_cocos2dx_CCScheduler_unscheduleAllCallbacksWithMinPriority, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT);