diff --git a/native/cocos/scripting/js-bindings/auto/jsb_box2d_auto.cpp b/native/cocos/scripting/js-bindings/auto/jsb_box2d_auto.cpp index 66c48052a9..0d5707dce5 100644 --- a/native/cocos/scripting/js-bindings/auto/jsb_box2d_auto.cpp +++ b/native/cocos/scripting/js-bindings/auto/jsb_box2d_auto.cpp @@ -1,5 +1,6 @@ #include "scripting/js-bindings/auto/jsb_box2d_auto.hpp" #include "scripting/js-bindings/manual/jsb_conversions.hpp" +#include "scripting/js-bindings/manual/jsb_global.h" #include "Box2D/Box2D.h" se::Object* __jsb_b2Draw_proto = nullptr; diff --git a/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_audioengine_auto.cpp b/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_audioengine_auto.cpp index 727761febb..8b2d5425a6 100644 --- a/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_audioengine_auto.cpp +++ b/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_audioengine_auto.cpp @@ -1,6 +1,7 @@ #include "scripting/js-bindings/auto/jsb_cocos2dx_audioengine_auto.hpp" #if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) #include "scripting/js-bindings/manual/jsb_conversions.hpp" +#include "scripting/js-bindings/manual/jsb_global.h" #include "audio/include/AudioEngine.h" se::Object* __jsb_cocos2d_experimental_AudioProfile_proto = nullptr; diff --git a/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp b/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp index 6509bb5f84..981d0c97d6 100644 --- a/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp +++ b/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp @@ -1,5 +1,6 @@ #include "scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp" #include "scripting/js-bindings/manual/jsb_conversions.hpp" +#include "scripting/js-bindings/manual/jsb_global.h" #include "cocos2d.h" #include "scripting/js-bindings/manual/BaseJSAction.h" @@ -1777,7 +1778,7 @@ bool js_register_cocos2dx_Component(se::Object* obj) __jsb_cocos2d_Component_proto = cls->getProto(); __jsb_cocos2d_Component_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.Component.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "Component"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -4655,7 +4656,7 @@ bool js_register_cocos2dx_Node(se::Object* obj) __jsb_cocos2d_Node_proto = cls->getProto(); __jsb_cocos2d_Node_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.Node.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "Node"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -4806,7 +4807,7 @@ bool js_register_cocos2dx_Scene(se::Object* obj) __jsb_cocos2d_Scene_proto = cls->getProto(); __jsb_cocos2d_Scene_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.Scene.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "Scene"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -12277,7 +12278,7 @@ bool js_register_cocos2dx_SpriteFrame(se::Object* obj) __jsb_cocos2d_SpriteFrame_proto = cls->getProto(); __jsb_cocos2d_SpriteFrame_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.SpriteFrame.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "SpriteFrame"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -12479,7 +12480,7 @@ bool js_register_cocos2dx_Sequence(se::Object* obj) __jsb_cocos2d_Sequence_proto = cls->getProto(); __jsb_cocos2d_Sequence_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.Sequence.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "Sequence"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -12597,7 +12598,7 @@ bool js_register_cocos2dx_Repeat(se::Object* obj) __jsb_cocos2d_Repeat_proto = cls->getProto(); __jsb_cocos2d_Repeat_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.Repeat.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "Repeat"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -12713,7 +12714,7 @@ bool js_register_cocos2dx_RepeatForever(se::Object* obj) __jsb_cocos2d_RepeatForever_proto = cls->getProto(); __jsb_cocos2d_RepeatForever_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.RepeatForever.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "RepeatForever"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -12814,7 +12815,7 @@ bool js_register_cocos2dx_Spawn(se::Object* obj) __jsb_cocos2d_Spawn_proto = cls->getProto(); __jsb_cocos2d_Spawn_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.Spawn.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "Spawn"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -12937,7 +12938,7 @@ bool js_register_cocos2dx_RotateTo(se::Object* obj) __jsb_cocos2d_RotateTo_proto = cls->getProto(); __jsb_cocos2d_RotateTo_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.RotateTo.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "RotateTo"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -13080,7 +13081,7 @@ bool js_register_cocos2dx_RotateBy(se::Object* obj) __jsb_cocos2d_RotateBy_proto = cls->getProto(); __jsb_cocos2d_RotateBy_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.RotateBy.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "RotateBy"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -13183,7 +13184,7 @@ bool js_register_cocos2dx_MoveBy(se::Object* obj) __jsb_cocos2d_MoveBy_proto = cls->getProto(); __jsb_cocos2d_MoveBy_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.MoveBy.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "MoveBy"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -13286,7 +13287,7 @@ bool js_register_cocos2dx_MoveTo(se::Object* obj) __jsb_cocos2d_MoveTo_proto = cls->getProto(); __jsb_cocos2d_MoveTo_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.MoveTo.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "MoveTo"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -13393,7 +13394,7 @@ bool js_register_cocos2dx_SkewTo(se::Object* obj) __jsb_cocos2d_SkewTo_proto = cls->getProto(); __jsb_cocos2d_SkewTo_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.SkewTo.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "SkewTo"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -13500,7 +13501,7 @@ bool js_register_cocos2dx_SkewBy(se::Object* obj) __jsb_cocos2d_SkewBy_proto = cls->getProto(); __jsb_cocos2d_SkewBy_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.SkewBy.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "SkewBy"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -13611,7 +13612,7 @@ bool js_register_cocos2dx_JumpBy(se::Object* obj) __jsb_cocos2d_JumpBy_proto = cls->getProto(); __jsb_cocos2d_JumpBy_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.JumpBy.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "JumpBy"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -13722,7 +13723,7 @@ bool js_register_cocos2dx_JumpTo(se::Object* obj) __jsb_cocos2d_JumpTo_proto = cls->getProto(); __jsb_cocos2d_JumpTo_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.JumpTo.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "JumpTo"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -13777,7 +13778,7 @@ bool js_register_cocos2dx_BezierBy(se::Object* obj) __jsb_cocos2d_BezierBy_proto = cls->getProto(); __jsb_cocos2d_BezierBy_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.BezierBy.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "BezierBy"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -13832,7 +13833,7 @@ bool js_register_cocos2dx_BezierTo(se::Object* obj) __jsb_cocos2d_BezierTo_proto = cls->getProto(); __jsb_cocos2d_BezierTo_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.BezierTo.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "BezierTo"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -14016,7 +14017,7 @@ bool js_register_cocos2dx_ScaleTo(se::Object* obj) __jsb_cocos2d_ScaleTo_proto = cls->getProto(); __jsb_cocos2d_ScaleTo_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.ScaleTo.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "ScaleTo"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -14133,7 +14134,7 @@ bool js_register_cocos2dx_ScaleBy(se::Object* obj) __jsb_cocos2d_ScaleBy_proto = cls->getProto(); __jsb_cocos2d_ScaleBy_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.ScaleBy.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "ScaleBy"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -14236,7 +14237,7 @@ bool js_register_cocos2dx_Blink(se::Object* obj) __jsb_cocos2d_Blink_proto = cls->getProto(); __jsb_cocos2d_Blink_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.Blink.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "Blink"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -14339,7 +14340,7 @@ bool js_register_cocos2dx_FadeTo(se::Object* obj) __jsb_cocos2d_FadeTo_proto = cls->getProto(); __jsb_cocos2d_FadeTo_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.FadeTo.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "FadeTo"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -14436,7 +14437,7 @@ bool js_register_cocos2dx_FadeIn(se::Object* obj) __jsb_cocos2d_FadeIn_proto = cls->getProto(); __jsb_cocos2d_FadeIn_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.FadeIn.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "FadeIn"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -14533,7 +14534,7 @@ bool js_register_cocos2dx_FadeOut(se::Object* obj) __jsb_cocos2d_FadeOut_proto = cls->getProto(); __jsb_cocos2d_FadeOut_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.FadeOut.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "FadeOut"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -14661,7 +14662,7 @@ bool js_register_cocos2dx_TintTo(se::Object* obj) __jsb_cocos2d_TintTo_proto = cls->getProto(); __jsb_cocos2d_TintTo_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.TintTo.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "TintTo"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -14772,7 +14773,7 @@ bool js_register_cocos2dx_TintBy(se::Object* obj) __jsb_cocos2d_TintBy_proto = cls->getProto(); __jsb_cocos2d_TintBy_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.TintBy.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "TintBy"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -14849,7 +14850,7 @@ bool js_register_cocos2dx_DelayTime(se::Object* obj) __jsb_cocos2d_DelayTime_proto = cls->getProto(); __jsb_cocos2d_DelayTime_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.DelayTime.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "DelayTime"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -14948,7 +14949,7 @@ bool js_register_cocos2dx_ReverseTime(se::Object* obj) __jsb_cocos2d_ReverseTime_proto = cls->getProto(); __jsb_cocos2d_ReverseTime_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.ReverseTime.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "ReverseTime"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -15078,7 +15079,7 @@ bool js_register_cocos2dx_TargetedAction(se::Object* obj) __jsb_cocos2d_TargetedAction_proto = cls->getProto(); __jsb_cocos2d_TargetedAction_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.TargetedAction.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "TargetedAction"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -15501,7 +15502,7 @@ bool js_register_cocos2dx_EaseIn(se::Object* obj) __jsb_cocos2d_EaseIn_proto = cls->getProto(); __jsb_cocos2d_EaseIn_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.EaseIn.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "EaseIn"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -15580,7 +15581,7 @@ bool js_register_cocos2dx_EaseOut(se::Object* obj) __jsb_cocos2d_EaseOut_proto = cls->getProto(); __jsb_cocos2d_EaseOut_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.EaseOut.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "EaseOut"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -15659,7 +15660,7 @@ bool js_register_cocos2dx_EaseInOut(se::Object* obj) __jsb_cocos2d_EaseInOut_proto = cls->getProto(); __jsb_cocos2d_EaseInOut_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.EaseInOut.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "EaseInOut"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -15736,7 +15737,7 @@ bool js_register_cocos2dx_EaseExponentialIn(se::Object* obj) __jsb_cocos2d_EaseExponentialIn_proto = cls->getProto(); __jsb_cocos2d_EaseExponentialIn_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.EaseExponentialIn.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "EaseExponentialIn"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -15813,7 +15814,7 @@ bool js_register_cocos2dx_EaseExponentialOut(se::Object* obj) __jsb_cocos2d_EaseExponentialOut_proto = cls->getProto(); __jsb_cocos2d_EaseExponentialOut_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.EaseExponentialOut.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "EaseExponentialOut"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -15890,7 +15891,7 @@ bool js_register_cocos2dx_EaseExponentialInOut(se::Object* obj) __jsb_cocos2d_EaseExponentialInOut_proto = cls->getProto(); __jsb_cocos2d_EaseExponentialInOut_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.EaseExponentialInOut.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "EaseExponentialInOut"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -15967,7 +15968,7 @@ bool js_register_cocos2dx_EaseSineIn(se::Object* obj) __jsb_cocos2d_EaseSineIn_proto = cls->getProto(); __jsb_cocos2d_EaseSineIn_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.EaseSineIn.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "EaseSineIn"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -16044,7 +16045,7 @@ bool js_register_cocos2dx_EaseSineOut(se::Object* obj) __jsb_cocos2d_EaseSineOut_proto = cls->getProto(); __jsb_cocos2d_EaseSineOut_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.EaseSineOut.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "EaseSineOut"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -16121,7 +16122,7 @@ bool js_register_cocos2dx_EaseSineInOut(se::Object* obj) __jsb_cocos2d_EaseSineInOut_proto = cls->getProto(); __jsb_cocos2d_EaseSineInOut_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.EaseSineInOut.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "EaseSineInOut"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -16305,7 +16306,7 @@ bool js_register_cocos2dx_EaseElasticIn(se::Object* obj) __jsb_cocos2d_EaseElasticIn_proto = cls->getProto(); __jsb_cocos2d_EaseElasticIn_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.EaseElasticIn.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "EaseElasticIn"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -16396,7 +16397,7 @@ bool js_register_cocos2dx_EaseElasticOut(se::Object* obj) __jsb_cocos2d_EaseElasticOut_proto = cls->getProto(); __jsb_cocos2d_EaseElasticOut_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.EaseElasticOut.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "EaseElasticOut"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -16487,7 +16488,7 @@ bool js_register_cocos2dx_EaseElasticInOut(se::Object* obj) __jsb_cocos2d_EaseElasticInOut_proto = cls->getProto(); __jsb_cocos2d_EaseElasticInOut_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.EaseElasticInOut.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "EaseElasticInOut"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -16585,7 +16586,7 @@ bool js_register_cocos2dx_EaseBounceIn(se::Object* obj) __jsb_cocos2d_EaseBounceIn_proto = cls->getProto(); __jsb_cocos2d_EaseBounceIn_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.EaseBounceIn.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "EaseBounceIn"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -16662,7 +16663,7 @@ bool js_register_cocos2dx_EaseBounceOut(se::Object* obj) __jsb_cocos2d_EaseBounceOut_proto = cls->getProto(); __jsb_cocos2d_EaseBounceOut_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.EaseBounceOut.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "EaseBounceOut"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -16739,7 +16740,7 @@ bool js_register_cocos2dx_EaseBounceInOut(se::Object* obj) __jsb_cocos2d_EaseBounceInOut_proto = cls->getProto(); __jsb_cocos2d_EaseBounceInOut_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.EaseBounceInOut.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "EaseBounceInOut"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -16816,7 +16817,7 @@ bool js_register_cocos2dx_EaseBackIn(se::Object* obj) __jsb_cocos2d_EaseBackIn_proto = cls->getProto(); __jsb_cocos2d_EaseBackIn_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.EaseBackIn.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "EaseBackIn"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -16893,7 +16894,7 @@ bool js_register_cocos2dx_EaseBackOut(se::Object* obj) __jsb_cocos2d_EaseBackOut_proto = cls->getProto(); __jsb_cocos2d_EaseBackOut_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.EaseBackOut.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "EaseBackOut"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -16970,7 +16971,7 @@ bool js_register_cocos2dx_EaseBackInOut(se::Object* obj) __jsb_cocos2d_EaseBackInOut_proto = cls->getProto(); __jsb_cocos2d_EaseBackInOut_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.EaseBackInOut.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "EaseBackInOut"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -17073,7 +17074,7 @@ bool js_register_cocos2dx_EaseBezierAction(se::Object* obj) __jsb_cocos2d_EaseBezierAction_proto = cls->getProto(); __jsb_cocos2d_EaseBezierAction_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.EaseBezierAction.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "EaseBezierAction"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -17150,7 +17151,7 @@ bool js_register_cocos2dx_EaseQuadraticActionIn(se::Object* obj) __jsb_cocos2d_EaseQuadraticActionIn_proto = cls->getProto(); __jsb_cocos2d_EaseQuadraticActionIn_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.EaseQuadraticActionIn.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "EaseQuadraticActionIn"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -17227,7 +17228,7 @@ bool js_register_cocos2dx_EaseQuadraticActionOut(se::Object* obj) __jsb_cocos2d_EaseQuadraticActionOut_proto = cls->getProto(); __jsb_cocos2d_EaseQuadraticActionOut_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.EaseQuadraticActionOut.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "EaseQuadraticActionOut"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -17304,7 +17305,7 @@ bool js_register_cocos2dx_EaseQuadraticActionInOut(se::Object* obj) __jsb_cocos2d_EaseQuadraticActionInOut_proto = cls->getProto(); __jsb_cocos2d_EaseQuadraticActionInOut_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.EaseQuadraticActionInOut.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "EaseQuadraticActionInOut"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -17381,7 +17382,7 @@ bool js_register_cocos2dx_EaseQuarticActionIn(se::Object* obj) __jsb_cocos2d_EaseQuarticActionIn_proto = cls->getProto(); __jsb_cocos2d_EaseQuarticActionIn_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.EaseQuarticActionIn.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "EaseQuarticActionIn"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -17458,7 +17459,7 @@ bool js_register_cocos2dx_EaseQuarticActionOut(se::Object* obj) __jsb_cocos2d_EaseQuarticActionOut_proto = cls->getProto(); __jsb_cocos2d_EaseQuarticActionOut_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.EaseQuarticActionOut.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "EaseQuarticActionOut"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -17535,7 +17536,7 @@ bool js_register_cocos2dx_EaseQuarticActionInOut(se::Object* obj) __jsb_cocos2d_EaseQuarticActionInOut_proto = cls->getProto(); __jsb_cocos2d_EaseQuarticActionInOut_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.EaseQuarticActionInOut.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "EaseQuarticActionInOut"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -17612,7 +17613,7 @@ bool js_register_cocos2dx_EaseQuinticActionIn(se::Object* obj) __jsb_cocos2d_EaseQuinticActionIn_proto = cls->getProto(); __jsb_cocos2d_EaseQuinticActionIn_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.EaseQuinticActionIn.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "EaseQuinticActionIn"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -17689,7 +17690,7 @@ bool js_register_cocos2dx_EaseQuinticActionOut(se::Object* obj) __jsb_cocos2d_EaseQuinticActionOut_proto = cls->getProto(); __jsb_cocos2d_EaseQuinticActionOut_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.EaseQuinticActionOut.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "EaseQuinticActionOut"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -17766,7 +17767,7 @@ bool js_register_cocos2dx_EaseQuinticActionInOut(se::Object* obj) __jsb_cocos2d_EaseQuinticActionInOut_proto = cls->getProto(); __jsb_cocos2d_EaseQuinticActionInOut_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.EaseQuinticActionInOut.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "EaseQuinticActionInOut"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -17843,7 +17844,7 @@ bool js_register_cocos2dx_EaseCircleActionIn(se::Object* obj) __jsb_cocos2d_EaseCircleActionIn_proto = cls->getProto(); __jsb_cocos2d_EaseCircleActionIn_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.EaseCircleActionIn.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "EaseCircleActionIn"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -17920,7 +17921,7 @@ bool js_register_cocos2dx_EaseCircleActionOut(se::Object* obj) __jsb_cocos2d_EaseCircleActionOut_proto = cls->getProto(); __jsb_cocos2d_EaseCircleActionOut_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.EaseCircleActionOut.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "EaseCircleActionOut"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -17997,7 +17998,7 @@ bool js_register_cocos2dx_EaseCircleActionInOut(se::Object* obj) __jsb_cocos2d_EaseCircleActionInOut_proto = cls->getProto(); __jsb_cocos2d_EaseCircleActionInOut_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.EaseCircleActionInOut.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "EaseCircleActionInOut"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -18074,7 +18075,7 @@ bool js_register_cocos2dx_EaseCubicActionIn(se::Object* obj) __jsb_cocos2d_EaseCubicActionIn_proto = cls->getProto(); __jsb_cocos2d_EaseCubicActionIn_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.EaseCubicActionIn.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "EaseCubicActionIn"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -18151,7 +18152,7 @@ bool js_register_cocos2dx_EaseCubicActionOut(se::Object* obj) __jsb_cocos2d_EaseCubicActionOut_proto = cls->getProto(); __jsb_cocos2d_EaseCubicActionOut_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.EaseCubicActionOut.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "EaseCubicActionOut"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -18228,7 +18229,7 @@ bool js_register_cocos2dx_EaseCubicActionInOut(se::Object* obj) __jsb_cocos2d_EaseCubicActionInOut_proto = cls->getProto(); __jsb_cocos2d_EaseCubicActionInOut_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.EaseCubicActionInOut.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "EaseCubicActionInOut"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -18323,7 +18324,7 @@ bool js_register_cocos2dx_Show(se::Object* obj) __jsb_cocos2d_Show_proto = cls->getProto(); __jsb_cocos2d_Show_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.Show.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "Show"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -18397,7 +18398,7 @@ bool js_register_cocos2dx_Hide(se::Object* obj) __jsb_cocos2d_Hide_proto = cls->getProto(); __jsb_cocos2d_Hide_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.Hide.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "Hide"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -18655,7 +18656,7 @@ bool js_register_cocos2dx_FlipX(se::Object* obj) __jsb_cocos2d_FlipX_proto = cls->getProto(); __jsb_cocos2d_FlipX_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.FlipX.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "FlipX"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -18754,7 +18755,7 @@ bool js_register_cocos2dx_FlipY(se::Object* obj) __jsb_cocos2d_FlipY_proto = cls->getProto(); __jsb_cocos2d_FlipY_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.FlipY.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "FlipY"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -18853,7 +18854,7 @@ bool js_register_cocos2dx_Place(se::Object* obj) __jsb_cocos2d_Place_proto = cls->getProto(); __jsb_cocos2d_Place_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.Place.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "Place"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -18924,7 +18925,7 @@ bool js_register_cocos2dx_CallFunc(se::Object* obj) __jsb_cocos2d_CallFunc_proto = cls->getProto(); __jsb_cocos2d_CallFunc_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc._CallFunc.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "_CallFunc"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -18979,7 +18980,7 @@ bool js_register_cocos2dx_CallFuncN(se::Object* obj) __jsb_cocos2d_CallFuncN_proto = cls->getProto(); __jsb_cocos2d_CallFuncN_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.CallFunc.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "CallFunc"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -19324,7 +19325,7 @@ bool js_register_cocos2dx_ActionManager(se::Object* obj) __jsb_cocos2d_ActionManager_proto = cls->getProto(); __jsb_cocos2d_ActionManager_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.ActionManager.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "ActionManager"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -20597,7 +20598,7 @@ bool js_register_cocos2dx_DrawNode(se::Object* obj) __jsb_cocos2d_DrawNode_proto = cls->getProto(); __jsb_cocos2d_DrawNode_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.DrawNode.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "DrawNode"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -22633,7 +22634,7 @@ bool js_register_cocos2dx_Label(se::Object* obj) __jsb_cocos2d_Label_proto = cls->getProto(); __jsb_cocos2d_Label_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.Label.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "Label"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -22707,7 +22708,7 @@ bool js_register_cocos2dx_LabelTTF(se::Object* obj) __jsb_cocos2d_LabelTTF_proto = cls->getProto(); __jsb_cocos2d_LabelTTF_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.LabelTTF.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "LabelTTF"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -22781,7 +22782,7 @@ bool js_register_cocos2dx_Layer(se::Object* obj) __jsb_cocos2d_Layer_proto = cls->getProto(); __jsb_cocos2d_Layer_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.Layer.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "Layer"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -23027,7 +23028,7 @@ bool js_register_cocos2dx_LayerColor(se::Object* obj) __jsb_cocos2d_LayerColor_proto = cls->getProto(); __jsb_cocos2d_LayerColor_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.LayerColor.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "LayerColor"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -23412,7 +23413,7 @@ bool js_register_cocos2dx_LayerGradient(se::Object* obj) __jsb_cocos2d_LayerGradient_proto = cls->getProto(); __jsb_cocos2d_LayerGradient_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.LayerGradient.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "LayerGradient"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -23549,7 +23550,7 @@ bool js_register_cocos2dx_LayerMultiplex(se::Object* obj) __jsb_cocos2d_LayerMultiplex_proto = cls->getProto(); __jsb_cocos2d_LayerMultiplex_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.LayerMultiplex.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "LayerMultiplex"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -23829,7 +23830,7 @@ bool js_register_cocos2dx_MenuItem(se::Object* obj) __jsb_cocos2d_MenuItem_proto = cls->getProto(); __jsb_cocos2d_MenuItem_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.MenuItem.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "MenuItem"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -24054,7 +24055,7 @@ bool js_register_cocos2dx_MenuItemLabel(se::Object* obj) __jsb_cocos2d_MenuItemLabel_proto = cls->getProto(); __jsb_cocos2d_MenuItemLabel_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.MenuItemLabel.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "MenuItemLabel"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -24170,7 +24171,7 @@ bool js_register_cocos2dx_MenuItemAtlasFont(se::Object* obj) __jsb_cocos2d_MenuItemAtlasFont_proto = cls->getProto(); __jsb_cocos2d_MenuItemAtlasFont_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.MenuItemAtlasFont.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "MenuItemAtlasFont"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -24426,7 +24427,7 @@ bool js_register_cocos2dx_MenuItemFont(se::Object* obj) __jsb_cocos2d_MenuItemFont_proto = cls->getProto(); __jsb_cocos2d_MenuItemFont_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.MenuItemFont.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "MenuItemFont"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -24707,7 +24708,7 @@ bool js_register_cocos2dx_MenuItemSprite(se::Object* obj) __jsb_cocos2d_MenuItemSprite_proto = cls->getProto(); __jsb_cocos2d_MenuItemSprite_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.MenuItemSprite.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "MenuItemSprite"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -24898,7 +24899,7 @@ bool js_register_cocos2dx_MenuItemImage(se::Object* obj) __jsb_cocos2d_MenuItemImage_proto = cls->getProto(); __jsb_cocos2d_MenuItemImage_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.MenuItemImage.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "MenuItemImage"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -25104,7 +25105,7 @@ bool js_register_cocos2dx_MenuItemToggle(se::Object* obj) __jsb_cocos2d_MenuItemToggle_proto = cls->getProto(); __jsb_cocos2d_MenuItemToggle_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.MenuItemToggle.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "MenuItemToggle"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -25332,7 +25333,7 @@ bool js_register_cocos2dx_Menu(se::Object* obj) __jsb_cocos2d_Menu_proto = cls->getProto(); __jsb_cocos2d_Menu_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.Menu.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "Menu"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -25814,7 +25815,7 @@ bool js_register_cocos2dx_MotionStreak(se::Object* obj) __jsb_cocos2d_MotionStreak_proto = cls->getProto(); __jsb_cocos2d_MotionStreak_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.MotionStreak.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "MotionStreak"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -26169,7 +26170,7 @@ bool js_register_cocos2dx_ParticleBatchNode(se::Object* obj) __jsb_cocos2d_ParticleBatchNode_proto = cls->getProto(); __jsb_cocos2d_ParticleBatchNode_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.ParticleBatchNode.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "ParticleBatchNode"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -28288,7 +28289,7 @@ bool js_register_cocos2dx_ParticleSystem(se::Object* obj) __jsb_cocos2d_ParticleSystem_proto = cls->getProto(); __jsb_cocos2d_ParticleSystem_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc._ParticleSystem.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "_ParticleSystem"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -30933,7 +30934,7 @@ bool js_register_cocos2dx_Sprite(se::Object* obj) __jsb_cocos2d_Sprite_proto = cls->getProto(); __jsb_cocos2d_Sprite_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.Sprite.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "Sprite"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -31585,7 +31586,7 @@ bool js_register_cocos2dx_RenderTexture(se::Object* obj) __jsb_cocos2d_RenderTexture_proto = cls->getProto(); __jsb_cocos2d_RenderTexture_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.RenderTexture.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "RenderTexture"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -32260,7 +32261,7 @@ bool js_register_cocos2dx_GLProgram(se::Object* obj) __jsb_cocos2d_GLProgram_proto = cls->getProto(); __jsb_cocos2d_GLProgram_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.GLProgram.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "GLProgram"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -33639,7 +33640,7 @@ bool js_register_cocos2dx_SpriteBatchNode(se::Object* obj) __jsb_cocos2d_SpriteBatchNode_proto = cls->getProto(); __jsb_cocos2d_SpriteBatchNode_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.SpriteBatchNode.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "SpriteBatchNode"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -34469,7 +34470,7 @@ bool js_register_cocos2dx_TextFieldTTF(se::Object* obj) __jsb_cocos2d_TextFieldTTF_proto = cls->getProto(); __jsb_cocos2d_TextFieldTTF_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.TextFieldTTF.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "TextFieldTTF"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -34589,7 +34590,7 @@ bool js_register_cocos2dx_ParallaxNode(se::Object* obj) __jsb_cocos2d_ParallaxNode_proto = cls->getProto(); __jsb_cocos2d_ParallaxNode_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.ParallaxNode.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "ParallaxNode"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -36442,7 +36443,7 @@ bool js_register_cocos2dx_TMXMapInfo(se::Object* obj) __jsb_cocos2d_TMXMapInfo_proto = cls->getProto(); __jsb_cocos2d_TMXMapInfo_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.TMXMapInfo.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "TMXMapInfo"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -37008,7 +37009,7 @@ bool js_register_cocos2dx_TMXLayer(se::Object* obj) __jsb_cocos2d_TMXLayer_proto = cls->getProto(); __jsb_cocos2d_TMXLayer_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.TMXLayer.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "TMXLayer"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -37474,7 +37475,7 @@ bool js_register_cocos2dx_TMXTiledMap(se::Object* obj) __jsb_cocos2d_TMXTiledMap_proto = cls->getProto(); __jsb_cocos2d_TMXTiledMap_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.TMXTiledMap.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "TMXTiledMap"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -37645,7 +37646,7 @@ bool js_register_cocos2dx_TileMapAtlas(se::Object* obj) __jsb_cocos2d_TileMapAtlas_proto = cls->getProto(); __jsb_cocos2d_TileMapAtlas_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.TileMapAtlas.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "TileMapAtlas"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -37700,7 +37701,7 @@ bool js_register_cocos2dx_BaseJSAction(se::Object* obj) __jsb_cocos2d_BaseJSAction_proto = cls->getProto(); __jsb_cocos2d_BaseJSAction_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.BaseJSAction.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "BaseJSAction"); se::ScriptEngine::getInstance()->clearException(); return true; } 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 a8f27e1bc6..64252472cf 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 @@ -1,5 +1,6 @@ #include "scripting/js-bindings/auto/jsb_cocos2dx_dragonbones_auto.hpp" #include "scripting/js-bindings/manual/jsb_conversions.hpp" +#include "scripting/js-bindings/manual/jsb_global.h" #include "editor-support/dragonbones/cocos2dx/CCDragonBonesHeaders.h" se::Object* __jsb_dragonBones_BaseObject_proto = nullptr; diff --git a/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_experimental_video_auto.cpp b/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_experimental_video_auto.cpp index 727f7d0304..30feeb3066 100644 --- a/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_experimental_video_auto.cpp +++ b/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_experimental_video_auto.cpp @@ -1,6 +1,7 @@ #include "scripting/js-bindings/auto/jsb_cocos2dx_experimental_video_auto.hpp" #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && !defined(CC_TARGET_OS_TVOS) #include "scripting/js-bindings/manual/jsb_conversions.hpp" +#include "scripting/js-bindings/manual/jsb_global.h" #include "ui/UIVideoPlayer.h" se::Object* __jsb_cocos2d_experimental_ui_VideoPlayer_proto = nullptr; diff --git a/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_experimental_webView_auto.cpp b/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_experimental_webView_auto.cpp index 090a0493da..177508f598 100644 --- a/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_experimental_webView_auto.cpp +++ b/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_experimental_webView_auto.cpp @@ -1,6 +1,7 @@ #include "scripting/js-bindings/auto/jsb_cocos2dx_experimental_webView_auto.hpp" #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && !defined(CC_TARGET_OS_TVOS) #include "scripting/js-bindings/manual/jsb_conversions.hpp" +#include "scripting/js-bindings/manual/jsb_global.h" #include "ui/UIWebView.h" se::Object* __jsb_cocos2d_experimental_ui_WebView_proto = nullptr; diff --git a/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_extension_auto.cpp b/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_extension_auto.cpp index 5970a9f09e..3fa8a199d0 100644 --- a/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_extension_auto.cpp +++ b/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_extension_auto.cpp @@ -1,5 +1,6 @@ #include "scripting/js-bindings/auto/jsb_cocos2dx_extension_auto.hpp" #include "scripting/js-bindings/manual/jsb_conversions.hpp" +#include "scripting/js-bindings/manual/jsb_global.h" #include "extensions/cocos-ext.h" se::Object* __jsb_cocos2d_extension_EventAssetsManagerEx_proto = nullptr; diff --git a/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_network_auto.cpp b/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_network_auto.cpp index 302b9d59cc..83812277b0 100644 --- a/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_network_auto.cpp +++ b/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_network_auto.cpp @@ -1,5 +1,6 @@ #include "scripting/js-bindings/auto/jsb_cocos2dx_network_auto.hpp" #include "scripting/js-bindings/manual/jsb_conversions.hpp" +#include "scripting/js-bindings/manual/jsb_global.h" #include "network/CCDownloader.h" se::Object* __jsb_cocos2d_network_Downloader_proto = nullptr; diff --git a/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_spine_auto.cpp b/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_spine_auto.cpp index ae6ef31843..538cf635f3 100644 --- a/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_spine_auto.cpp +++ b/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_spine_auto.cpp @@ -1,5 +1,6 @@ #include "scripting/js-bindings/auto/jsb_cocos2dx_spine_auto.hpp" #include "scripting/js-bindings/manual/jsb_conversions.hpp" +#include "scripting/js-bindings/manual/jsb_global.h" #include "spine/spine-cocos2dx.h" se::Object* __jsb_spine_SkeletonRenderer_proto = nullptr; @@ -1721,7 +1722,7 @@ bool js_register_cocos2dx_spine_SkeletonAnimation(se::Object* obj) __jsb_spine_SkeletonAnimation_proto = cls->getProto(); __jsb_spine_SkeletonAnimation_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { sp.SkeletonAnimation.extend = cc.Class.extend; })()"); + jsb_set_extend_property("sp", "SkeletonAnimation"); se::ScriptEngine::getInstance()->clearException(); return true; } diff --git a/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.cpp b/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.cpp index 0ed70f8e31..026ce76768 100644 --- a/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.cpp +++ b/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.cpp @@ -1,5 +1,6 @@ #include "scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.hpp" #include "scripting/js-bindings/manual/jsb_conversions.hpp" +#include "scripting/js-bindings/manual/jsb_global.h" #include "ui/CocosGUI.h" se::Object* __jsb_cocos2d_ui_Widget_proto = nullptr; @@ -1424,7 +1425,7 @@ bool js_register_cocos2dx_ui_Widget(se::Object* obj) __jsb_cocos2d_ui_Widget_proto = cls->getProto(); __jsb_cocos2d_ui_Widget_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { ccui.Widget.extend = cc.Class.extend; })()"); + jsb_set_extend_property("ccui", "Widget"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -2690,7 +2691,7 @@ bool js_register_cocos2dx_ui_Scale9Sprite(se::Object* obj) __jsb_cocos2d_ui_Scale9Sprite_proto = cls->getProto(); __jsb_cocos2d_ui_Scale9Sprite_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { ccui.Scale9Sprite.extend = cc.Class.extend; })()"); + jsb_set_extend_property("ccui", "Scale9Sprite"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -3285,7 +3286,7 @@ bool js_register_cocos2dx_ui_EditBox(se::Object* obj) __jsb_cocos2d_ui_EditBox_proto = cls->getProto(); __jsb_cocos2d_ui_EditBox_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { ccui.EditBox.extend = cc.Class.extend; })()"); + jsb_set_extend_property("ccui", "EditBox"); se::ScriptEngine::getInstance()->clearException(); return true; } 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 af170bd6a5..ae424a5eb4 100644 --- a/native/cocos/scripting/js-bindings/auto/jsb_creator_auto.cpp +++ b/native/cocos/scripting/js-bindings/auto/jsb_creator_auto.cpp @@ -1,5 +1,6 @@ #include "scripting/js-bindings/auto/jsb_creator_auto.hpp" #include "scripting/js-bindings/manual/jsb_conversions.hpp" +#include "scripting/js-bindings/manual/jsb_global.h" #include "creator/CCScale9Sprite.h" #include "creator/CCGraphicsNode.h" #include "editor-support/creator/physics/CCPhysicsDebugDraw.h" @@ -749,7 +750,7 @@ bool js_register_creator_Scale9SpriteV2(se::Object* obj) __jsb_creator_Scale9SpriteV2_proto = cls->getProto(); __jsb_creator_Scale9SpriteV2_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.Scale9SpriteV2.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "Scale9SpriteV2"); se::ScriptEngine::getInstance()->clearException(); return true; } @@ -1518,7 +1519,7 @@ bool js_register_creator_GraphicsNode(se::Object* obj) __jsb_creator_GraphicsNode_proto = cls->getProto(); __jsb_creator_GraphicsNode_class = cls; - se::ScriptEngine::getInstance()->evalString("(function () { cc.GraphicsNode.extend = cc.Class.extend; })()"); + jsb_set_extend_property("cc", "GraphicsNode"); se::ScriptEngine::getInstance()->clearException(); return true; } diff --git a/native/cocos/scripting/js-bindings/docs/JSB2.0-learning-zh.md b/native/cocos/scripting/js-bindings/docs/JSB2.0-learning-zh.md index 36753fbc67..b0081dcc7d 100644 --- a/native/cocos/scripting/js-bindings/docs/JSB2.0-learning-zh.md +++ b/native/cocos/scripting/js-bindings/docs/JSB2.0-learning-zh.md @@ -256,9 +256,9 @@ bool foo() * JS引擎在se::Object::createXXX后,如果由于某种原因JS引擎做了GC操作,导致后续使用的se::Object内部引用了一个非法指针,引发程序崩溃 -为了解决上述两个问题,抽象层定义了一个辅助管理**手动创建对象**的类型,即se::handleObject。 +为了解决上述两个问题,抽象层定义了一个辅助管理**手动创建对象**的类型,即`se::HandleObject`。 -se::HandleObject是一个辅助类,用于更加简单地管理手动创建的se::Object对象的释放、root和unroot操作。 +`se::HandleObject`是一个辅助类,用于更加简单地管理手动创建的se::Object对象的释放、root和unroot操作。 以下两种代码写法是等价的,使用se::HandleObject的代码量明显少很多,而且更加安全。 ```c++ @@ -805,24 +805,72 @@ persistent_classes = TextureCache SpriteFrameCache FileUtils EventDispatcher Act classes_owned_by_cpp = ``` -## 远程调试 +## 远程调试与Profile + +默认远程调试和Profile是在debug模式中生效的,如果需要在release模式下也启用,需要手动修改cocos/scripting/js-bindings/jswrapper/config.hpp中的宏开关。 + +```c++ +#if defined(COCOS2D_DEBUG) && COCOS2D_DEBUG > 0 +#define SE_ENABLE_INSPECTOR 1 +#define SE_DEBUG 2 +#else +#define SE_ENABLE_INSPECTOR 0 +#define SE_DEBUG 0 +#endif +``` + +改为: + +```c++ +#if 1 // 这里改为1,强制启用调试 +#define SE_ENABLE_INSPECTOR 1 +#define SE_DEBUG 2 +#else +#define SE_ENABLE_INSPECTOR 0 +#define SE_DEBUG 0 +#endif +``` ### Chrome远程调试V8 -TBD +#### Windows -Windows: +* 运行游戏 +* 用Chrome浏览器打开[chrome-devtools://devtools/bundled/inspector.html?v8only=true&ws=127.0.0.1:5086/00010002-0003-4004-8005-000600070008](chrome-devtools://devtools/bundled/inspector.html?v8only=true&ws=127.0.0.1:5086/00010002-0003-4004-8005-000600070008) + +断点调试: +![](v8-win32-debug.jpg) + +抓取JS Heap +![](v8-win32-memory.jpg) + +Profile +![](v8-win32-profile.jpg) + +#### Android + +* 运行游戏 +* 用Chrome浏览器打开[chrome-devtools://devtools/bundled/inspector.html?v8only=true&ws=xxx.xxx.xxx.xxx:5086/00010002-0003-4004-8005-000600070008](chrome-devtools://devtools/bundled/inspector.html?v8only=true&ws=xxx.xxx.xxx.xxx:5086/00010002-0003-4004-8005-000600070008), 其中`xxx.xxx.xxx.xxx`为局域网中Android设备的IP地址 +* 调试界面与Windows相同 -Android: ### Safari远程调试JavaScriptCore -TBD +#### macOS -Mac: +1. 打开Mac上的Safari,偏好设置 -> 高级 -> 显示开发者选项 +2. 为Xcode工程添加entitlements文件,如果entitlements存在则跳过此步骤。如果不存在,则到工程的Capabilities设置中打开App Sandbox,然后再关闭,这时.entitlements文件会自动被添加进工程。![](jsc-entitlements.png) +3. 打开entitlements文件,添加com.apple.security.get-task-allow,值类型为Boolean,值为true. ![](jsc-security-key.png) +4. 运行游戏 +5. Safari菜单中选择Develop -> 你的Mac设备名称 -> Cocos2d-x JSB 会自动打开Web Inspector页面,然后即可进行设置断点、Timeline profile、console等操作。![](jsc-mac-debug.png) ![](jsc-breakpoint.png) ![](jsc-timeline.png) -iOS: +#### iOS +1. 先打开iPhone的设置 -> Safari -> 高级 -> Web检查器 +2. 为Xcode工程添加entitlements文件,如果entitlements存在则跳过此步骤。如果不存在,则到工程的Capabilities设置中打开App Sandbox,然后再关闭,这时.entitlements文件会自动被添加进工程。 (图示与macOS的第2步类似) +3. 打开entitlements文件,添加com.apple.security.get-task-allow,值类型为Boolean,值为true。(图示与macOS的第3步类似) +4. 运行游戏 +5. Safari菜单中选择Develop -> 你的iPhone设备名称 -> Cocos2d-x JSB 会自动打开Web Inspector页面,然后即可进行设置断点、Timeline profile、console等操作。(图示与macOS的第5步类似) ## Q & A @@ -851,7 +899,10 @@ bool AppDelegate::applicationDidFinishLaunching() ``` ### se::Object::root/unroot 与 se::Object::incRef/decRef的区别? -TBD +root/unroot用于控制JS对象是否受GC控制,root表示不受GC控制,unroot则相反,表示交由GC控制,对一个se::Object来说,root和unroot可以被调用多次,se::Object内部有_rootCount变量用于表示root的次数。当unroot被调用,且_rootCount为0时,se::Object关联的JS对象将交由GC管理。还有一种情况,即如果se::Object的析构被触发了,如果_rootCount > 0,则强制把JS对象交由GC控制。 + +incRef/decRef用于控制se::Object这个`cpp`对象的生命周期,前面章节已经提及,建议用户使用se::HandleObject来控制`手动创建非绑定对象`的方式控制se::Object的生命周期。因此,一般情况下,开发者不需要接触到incRef/decRef。 + ### 对象生命周期的关联与解除关联 diff --git a/native/cocos/scripting/js-bindings/docs/jsc-breakpoint.png b/native/cocos/scripting/js-bindings/docs/jsc-breakpoint.png new file mode 100644 index 0000000000..5551a83528 Binary files /dev/null and b/native/cocos/scripting/js-bindings/docs/jsc-breakpoint.png differ diff --git a/native/cocos/scripting/js-bindings/docs/jsc-entitlements.png b/native/cocos/scripting/js-bindings/docs/jsc-entitlements.png new file mode 100644 index 0000000000..16807e950b Binary files /dev/null and b/native/cocos/scripting/js-bindings/docs/jsc-entitlements.png differ diff --git a/native/cocos/scripting/js-bindings/docs/jsc-mac-debug.png b/native/cocos/scripting/js-bindings/docs/jsc-mac-debug.png new file mode 100644 index 0000000000..cc024596ee Binary files /dev/null and b/native/cocos/scripting/js-bindings/docs/jsc-mac-debug.png differ diff --git a/native/cocos/scripting/js-bindings/docs/jsc-security-key.png b/native/cocos/scripting/js-bindings/docs/jsc-security-key.png new file mode 100644 index 0000000000..50ca422b43 Binary files /dev/null and b/native/cocos/scripting/js-bindings/docs/jsc-security-key.png differ diff --git a/native/cocos/scripting/js-bindings/docs/jsc-timeline.png b/native/cocos/scripting/js-bindings/docs/jsc-timeline.png new file mode 100644 index 0000000000..8b65b22354 Binary files /dev/null and b/native/cocos/scripting/js-bindings/docs/jsc-timeline.png differ diff --git a/native/cocos/scripting/js-bindings/docs/v8-win32-debug.jpg b/native/cocos/scripting/js-bindings/docs/v8-win32-debug.jpg new file mode 100644 index 0000000000..40b6aac3cd Binary files /dev/null and b/native/cocos/scripting/js-bindings/docs/v8-win32-debug.jpg differ diff --git a/native/cocos/scripting/js-bindings/docs/v8-win32-memory.jpg b/native/cocos/scripting/js-bindings/docs/v8-win32-memory.jpg new file mode 100644 index 0000000000..54f8ba2a7c Binary files /dev/null and b/native/cocos/scripting/js-bindings/docs/v8-win32-memory.jpg differ diff --git a/native/cocos/scripting/js-bindings/docs/v8-win32-profile.jpg b/native/cocos/scripting/js-bindings/docs/v8-win32-profile.jpg new file mode 100644 index 0000000000..3297816571 Binary files /dev/null and b/native/cocos/scripting/js-bindings/docs/v8-win32-profile.jpg differ diff --git a/native/cocos/scripting/js-bindings/jswrapper/chakracore/Base.h b/native/cocos/scripting/js-bindings/jswrapper/chakracore/Base.h index 7831e941c2..c80b0eef08 100644 --- a/native/cocos/scripting/js-bindings/jswrapper/chakracore/Base.h +++ b/native/cocos/scripting/js-bindings/jswrapper/chakracore/Base.h @@ -2,6 +2,7 @@ #include "ChakraCore.h" +#include "ChakraCoreVersion.h" #include #include diff --git a/native/cocos/scripting/js-bindings/jswrapper/chakracore/Object.cpp b/native/cocos/scripting/js-bindings/jswrapper/chakracore/Object.cpp index 1ceae6dceb..afb432b1f8 100644 --- a/native/cocos/scripting/js-bindings/jswrapper/chakracore/Object.cpp +++ b/native/cocos/scripting/js-bindings/jswrapper/chakracore/Object.cpp @@ -225,13 +225,14 @@ namespace se { return exist; } - void Object::setProperty(const char* name, const Value& v) + bool Object::setProperty(const char* name, const Value& v) { JsValueRef jsValue = JS_INVALID_REFERENCE; internal::seToJsValue(v, &jsValue); JsPropertyIdRef propertyId; _CHECK(JsCreatePropertyId(name, strlen(name), &propertyId)); _CHECK(JsSetProperty(_obj, propertyId, jsValue, true)); + return true; } bool Object::defineProperty(const char *name, JsNativeFunction getter, JsNativeFunction setter) diff --git a/native/cocos/scripting/js-bindings/jswrapper/chakracore/Object.hpp b/native/cocos/scripting/js-bindings/jswrapper/chakracore/Object.hpp index db26d0ca35..9ffc6dff15 100644 --- a/native/cocos/scripting/js-bindings/jswrapper/chakracore/Object.hpp +++ b/native/cocos/scripting/js-bindings/jswrapper/chakracore/Object.hpp @@ -24,7 +24,7 @@ namespace se { static Object* createObjectWithClass(Class* cls); bool getProperty(const char* name, Value* data); - void setProperty(const char* name, const Value& v); + bool setProperty(const char* name, const Value& v); bool defineProperty(const char *name, JsNativeFunction getter, JsNativeFunction setter); bool isFunction() const; diff --git a/native/cocos/scripting/js-bindings/jswrapper/chakracore/ScriptEngine.cpp b/native/cocos/scripting/js-bindings/jswrapper/chakracore/ScriptEngine.cpp index fe38c4ec09..86d37c9348 100644 --- a/native/cocos/scripting/js-bindings/jswrapper/chakracore/ScriptEngine.cpp +++ b/native/cocos/scripting/js-bindings/jswrapper/chakracore/ScriptEngine.cpp @@ -70,7 +70,6 @@ namespace se { : _rt(JS_INVALID_RUNTIME_HANDLE) , _cx(JS_INVALID_REFERENCE) , _globalObj(nullptr) - , _nodeEventListener(nullptr) , _exceptionCallback(nullptr) , _currentSourceContext(0) , _vmId(0) @@ -84,7 +83,7 @@ namespace se { bool ScriptEngine::init() { cleanup(); - LOGD("Initializing ChakraCore ... \n"); + LOGD("Initializing ChakraCore, version: %d.%d.%d\n", CHAKRA_CORE_MAJOR_VERSION, CHAKRA_CORE_MINOR_VERSION, CHAKRA_CORE_PATCH_VERSION); ++_vmId; for (const auto& hook : _beforeInitHookArray) @@ -159,7 +158,6 @@ namespace se { _cx = nullptr; _globalObj = nullptr; _isValid = false; - _nodeEventListener = nullptr; _registerCallbackArray.clear(); @@ -423,23 +421,17 @@ namespace se { iterOwner->second->detachObject(iterTarget->second); } - bool ScriptEngine::_onReceiveNodeEvent(void* node, NodeEventType type) - { - assert(_nodeEventListener != nullptr); - return _nodeEventListener(node, type); - } - - bool ScriptEngine::_setNodeEventListener(NodeEventListener listener) - { - _nodeEventListener = listener; - return true; - } - - void ScriptEngine::enableDebugger(unsigned int port/* = 5086*/) + void ScriptEngine::enableDebugger(const std::string& serverAddr, uint32_t port) { //FIXME: } + bool ScriptEngine::isDebuggerEnabled() const + { + //FIXME: + return false; + } + void ScriptEngine::mainLoopUpdate() { //FIXME: diff --git a/native/cocos/scripting/js-bindings/jswrapper/chakracore/ScriptEngine.hpp b/native/cocos/scripting/js-bindings/jswrapper/chakracore/ScriptEngine.hpp index 8d86c535a2..5292692fc3 100644 --- a/native/cocos/scripting/js-bindings/jswrapper/chakracore/ScriptEngine.hpp +++ b/native/cocos/scripting/js-bindings/jswrapper/chakracore/ScriptEngine.hpp @@ -119,7 +119,8 @@ namespace se { void setExceptionCallback(const ExceptionCallback& cb); const std::chrono::steady_clock::time_point& getStartTime() const { return _startTime; } - void enableDebugger(unsigned int port = 5086); + void enableDebugger(const std::string& serverAddr, uint32_t port); + bool isDebuggerEnabled() const; void mainLoopUpdate(); uint32_t getVMId() const { return _vmId; } @@ -127,18 +128,6 @@ namespace se { void _retainScriptObject(void* owner, void* target); void _releaseScriptObject(void* owner, void* target); - enum class NodeEventType - { - ENTER, - EXIT, - ENTER_TRANSITION_DID_FINISH, - EXIT_TRANSITION_DID_START, - CLEANUP - }; - bool _onReceiveNodeEvent(void* node, NodeEventType type); - using NodeEventListener = bool(*)(void*, NodeEventType); - bool _setNodeEventListener(NodeEventListener listener); - private: struct ExceptionInfo { @@ -164,7 +153,6 @@ namespace se { JsContextRef _cx; Object* _globalObj; - NodeEventListener _nodeEventListener; FileOperationDelegate _fileOperationDelegate; ExceptionCallback _exceptionCallback; diff --git a/native/cocos/scripting/js-bindings/jswrapper/config.hpp b/native/cocos/scripting/js-bindings/jswrapper/config.hpp index 15b8163336..7ff0fde09b 100644 --- a/native/cocos/scripting/js-bindings/jswrapper/config.hpp +++ b/native/cocos/scripting/js-bindings/jswrapper/config.hpp @@ -14,9 +14,13 @@ #define SCRIPT_ENGINE_TYPE SCRIPT_ENGINE_NONE #endif -#define SE_ENABLE_INSPECTOR 0 - +#if defined(COCOS2D_DEBUG) && COCOS2D_DEBUG > 0 +#define SE_ENABLE_INSPECTOR 1 #define SE_DEBUG 2 +#else +#define SE_ENABLE_INSPECTOR 0 +#define SE_DEBUG 0 +#endif #ifdef ANDROID @@ -61,6 +65,7 @@ void seLog(const char * format, ...); #ifndef __SSIZE_T #define __SSIZE_T typedef SSIZE_T ssize_t; +#define _SSIZE_T_DEFINED // libuv also defines ssize_t, use the one defined here. #endif // __SSIZE_T #endif diff --git a/native/cocos/scripting/js-bindings/jswrapper/jsc/Object.cpp b/native/cocos/scripting/js-bindings/jswrapper/jsc/Object.cpp index 4fff432689..8fd2d6743d 100644 --- a/native/cocos/scripting/js-bindings/jswrapper/jsc/Object.cpp +++ b/native/cocos/scripting/js-bindings/jswrapper/jsc/Object.cpp @@ -227,8 +227,9 @@ namespace se { return exist; } - void Object::setProperty(const char* name, const Value& v) + bool Object::setProperty(const char* name, const Value& v) { + bool ret = true; JSStringRef jsName = JSStringCreateWithUTF8CString(name); JSValueRef jsValue = nullptr; JSObjectRef obj = _obj; @@ -265,9 +266,12 @@ namespace se { if (exception != nullptr) { ScriptEngine::getInstance()->_clearException(exception); + ret = false; } JSStringRelease(jsName); + + return ret; } bool Object::defineProperty(const char *name, JSObjectCallAsFunctionCallback getter, JSObjectCallAsFunctionCallback setter) diff --git a/native/cocos/scripting/js-bindings/jswrapper/jsc/Object.hpp b/native/cocos/scripting/js-bindings/jswrapper/jsc/Object.hpp index 025ee544ec..c7c445531f 100644 --- a/native/cocos/scripting/js-bindings/jswrapper/jsc/Object.hpp +++ b/native/cocos/scripting/js-bindings/jswrapper/jsc/Object.hpp @@ -87,8 +87,9 @@ namespace se { * @brief Sets a property to an object. * @param[in] name A utf-8 string containing the property's name. * @param[in] value A value to be used as the property's value. + * @return true if the property is set successfully, otherwise false. */ - void setProperty(const char* name, const Value& value); + bool setProperty(const char* name, const Value& value); /** * @brief Defines a property with native accessor callbacks for an object. diff --git a/native/cocos/scripting/js-bindings/jswrapper/jsc/ScriptEngine.cpp b/native/cocos/scripting/js-bindings/jswrapper/jsc/ScriptEngine.cpp index 9fcea1458a..75019f4452 100644 --- a/native/cocos/scripting/js-bindings/jswrapper/jsc/ScriptEngine.cpp +++ b/native/cocos/scripting/js-bindings/jswrapper/jsc/ScriptEngine.cpp @@ -83,13 +83,13 @@ namespace se { ScriptEngine::ScriptEngine() : _cx(nullptr) , _globalObj(nullptr) - , _nodeEventListener(nullptr) , _exceptionCallback(nullptr) , _vmId(0) , _isGarbageCollecting(false) , _isValid(false) , _isInCleanup(false) , _isErrorHandleWorking(false) + , _isDebuggerEnabled(false) { } @@ -183,7 +183,6 @@ namespace se { _cx = nullptr; _globalObj = nullptr; _isValid = false; - _nodeEventListener = nullptr; _registerCallbackArray.clear(); @@ -393,11 +392,20 @@ namespace se { if (fileName == nullptr) fileName = "(no filename)"; + // Fix the source url is too long displayed in Safari debugger. + std::string sourceUrl = fileName; + static const std::string prefixKey = "/temp/quick-scripts/"; + size_t prefixPos = sourceUrl.find(prefixKey); + if (prefixPos != std::string::npos) + { + sourceUrl = sourceUrl.substr(prefixPos + prefixKey.length()); + } + std::string exceptionStr; std::string scriptStr(script, length); JSValueRef exception = nullptr; - JSStringRef jsSourceUrl = JSStringCreateWithUTF8CString(fileName); + JSStringRef jsSourceUrl = JSStringCreateWithUTF8CString(sourceUrl.c_str()); JSStringRef jsScript = JSStringCreateWithUTF8CString(scriptStr.c_str()); JSValueRef result = nullptr; @@ -490,26 +498,20 @@ namespace se { iterOwner->second->detachObject(iterTarget->second); } - bool ScriptEngine::_onReceiveNodeEvent(void* node, NodeEventType type) - { - assert(_nodeEventListener != nullptr); - return _nodeEventListener(node, type); - } - - bool ScriptEngine::_setNodeEventListener(NodeEventListener listener) - { - _nodeEventListener = listener; - return true; - } - void ScriptEngine::clearException() { //FIXME: } - void ScriptEngine::enableDebugger(unsigned int port/* = 5086*/) + void ScriptEngine::enableDebugger(const std::string& serverAddr, uint32_t port) { // empty implementation + _isDebuggerEnabled = true; + } + + bool ScriptEngine::isDebuggerEnabled() const + { + return _isDebuggerEnabled; } void ScriptEngine::mainLoopUpdate() diff --git a/native/cocos/scripting/js-bindings/jswrapper/jsc/ScriptEngine.hpp b/native/cocos/scripting/js-bindings/jswrapper/jsc/ScriptEngine.hpp index a2f7180de2..4eedded9df 100644 --- a/native/cocos/scripting/js-bindings/jswrapper/jsc/ScriptEngine.hpp +++ b/native/cocos/scripting/js-bindings/jswrapper/jsc/ScriptEngine.hpp @@ -202,6 +202,7 @@ namespace se { /** * @brief Gets the start time of script engine. + * @return The start time of script engine. */ const std::chrono::steady_clock::time_point& getStartTime() const { return _startTime; } @@ -209,7 +210,13 @@ namespace se { * @brief Enables JavaScript debugger * @param[in] port The port of debugger server will use. */ - void enableDebugger(unsigned int port = 5086); + void enableDebugger(const std::string& serverAddr, uint32_t port); + + /** + * @brief Tests whether JavaScript debugger is enabled + * @return true if JavaScript debugger is enabled, otherwise false. + */ + bool isDebuggerEnabled() const; /** * @brief Main loop update trigger, it's need to invoked in main thread every frame. @@ -225,18 +232,6 @@ namespace se { void _retainScriptObject(void* owner, void* target); void _releaseScriptObject(void* owner, void* target); - enum class NodeEventType - { - ENTER, - EXIT, - ENTER_TRANSITION_DID_FINISH, - EXIT_TRANSITION_DID_START, - CLEANUP - }; - bool _onReceiveNodeEvent(void* node, NodeEventType type); - using NodeEventListener = bool(*)(void*, NodeEventType); - bool _setNodeEventListener(NodeEventListener listener); - void _clearException(JSValueRef exception); JSContextRef _getContext() const { return _cx; } @@ -279,7 +274,6 @@ namespace se { JSGlobalContextRef _cx; Object* _globalObj; - NodeEventListener _nodeEventListener; FileOperationDelegate _fileOperationDelegate; ExceptionCallback _exceptionCallback; @@ -289,6 +283,7 @@ namespace se { bool _isValid; bool _isInCleanup; bool _isErrorHandleWorking; + bool _isDebuggerEnabled; }; } // namespace se { diff --git a/native/cocos/scripting/js-bindings/jswrapper/sm/Object.cpp b/native/cocos/scripting/js-bindings/jswrapper/sm/Object.cpp index 2cba64ecf5..9ab8dd148a 100644 --- a/native/cocos/scripting/js-bindings/jswrapper/sm/Object.cpp +++ b/native/cocos/scripting/js-bindings/jswrapper/sm/Object.cpp @@ -176,13 +176,13 @@ namespace se { return ok; } - void Object::setProperty(const char* name, const Value& v) + bool Object::setProperty(const char* name, const Value& v) { JS::RootedObject object(__cx, _getJSObject()); JS::RootedValue value(__cx); internal::seToJsValue(__cx, v, &value); - JS_SetProperty(__cx, object, name, value); + return JS_SetProperty(__cx, object, name, value); } bool Object::defineProperty(const char *name, JSNative getter, JSNative setter) diff --git a/native/cocos/scripting/js-bindings/jswrapper/sm/Object.hpp b/native/cocos/scripting/js-bindings/jswrapper/sm/Object.hpp index 323a1bf8c3..ef64affc3e 100644 --- a/native/cocos/scripting/js-bindings/jswrapper/sm/Object.hpp +++ b/native/cocos/scripting/js-bindings/jswrapper/sm/Object.hpp @@ -24,7 +24,7 @@ namespace se { static Object* getObjectWithPtr(void* ptr); bool getProperty(const char* name, Value* data); - void setProperty(const char* name, const Value& v); + bool setProperty(const char* name, const Value& v); bool defineProperty(const char *name, JSNative getter, JSNative setter); bool isFunction() const; diff --git a/native/cocos/scripting/js-bindings/jswrapper/sm/ScriptEngine.cpp b/native/cocos/scripting/js-bindings/jswrapper/sm/ScriptEngine.cpp index 6ba0b41942..2b2a7540a4 100644 --- a/native/cocos/scripting/js-bindings/jswrapper/sm/ScriptEngine.cpp +++ b/native/cocos/scripting/js-bindings/jswrapper/sm/ScriptEngine.cpp @@ -248,8 +248,8 @@ namespace se { , _globalObj(nullptr) , _debugGlobalObj(nullptr) , _oldCompartment(nullptr) - , _nodeEventListener(nullptr) , _exceptionCallback(nullptr) + , _debuggerServerPort(0) , _vmId(0) , _isGarbageCollecting(false) , _isValid(false) @@ -302,7 +302,7 @@ namespace se { bool ScriptEngine::init() { cleanup(); - LOGD("Initializing SpiderMonkey \n"); + LOGD("Initializing SpiderMonkey, version: %s\n", JS_GetImplementationVersion()); ++_vmId; for (const auto& hook : _beforeInitHookArray) @@ -453,7 +453,6 @@ namespace se { _globalObj = nullptr; _oldCompartment = nullptr; _isValid = false; - _nodeEventListener = nullptr; _registerCallbackArray.clear(); @@ -512,11 +511,317 @@ namespace se { _registerCallbackArray.push_back(cb); } +#pragma mark - Debug + + static std::string inData; + static std::string outData; + static std::vector g_queue; + static std::mutex g_qMutex; + static std::mutex g_rwMutex; + static int clientSocket = -1; + static uint32_t s_nestedLoopLevel = 0; + + static void cc_closesocket(int fd) + { +#ifdef _WIN32 + closesocket(fd); +#else + close(fd); +#endif + } + + void ScriptEngine::_debugProcessInput(const std::string& str) + { + JS::RootedObject debugGlobal(_cx, _debugGlobalObj->_getJSObject()); + JSCompartment *globalCpt = JS_EnterCompartment(_cx, debugGlobal); + + Value func; + if (_debugGlobalObj->getProperty("processInput", &func) && func.isObject() && func.toObject()->isFunction()) + { + ValueArray args; + args.push_back(Value(str)); + func.toObject()->call(args, _debugGlobalObj); + } + + JS_LeaveCompartment(_cx, globalCpt); + } + + static bool NS_ProcessNextEvent() + { + std::string message; + size_t messageCount = 0; + while (true) + { + g_qMutex.lock(); + messageCount = g_queue.size(); + if (messageCount > 0) + { + auto first = g_queue.begin(); + message = *first; + g_queue.erase(first); + --messageCount; + } + g_qMutex.unlock(); + + if (!message.empty()) + { + ScriptEngine::getInstance()->_debugProcessInput(message); + } + + if (messageCount == 0) + break; + } + // std::this_thread::yield(); + std::this_thread::sleep_for(std::chrono::milliseconds(10)); + + return true; + } + + static bool JSBDebug_enterNestedEventLoop(State& s) + { + enum { + NS_OK = 0, + NS_ERROR_UNEXPECTED + }; + +#define NS_SUCCEEDED(v) ((v) == NS_OK) + + int rv = NS_OK; + + uint32_t nestLevel = ++s_nestedLoopLevel; + + while (NS_SUCCEEDED(rv) && s_nestedLoopLevel >= nestLevel) { + drainJobQueue(); + if (!NS_ProcessNextEvent()) + rv = NS_ERROR_UNEXPECTED; + } + + assert(s_nestedLoopLevel <= nestLevel); + + s.rval().setInt32(s_nestedLoopLevel); + return true; + } + SE_BIND_FUNC(JSBDebug_enterNestedEventLoop) + + static bool JSBDebug_exitNestedEventLoop(State& s) + { + if (s_nestedLoopLevel > 0) { + --s_nestedLoopLevel; + } else { + s.rval().setInt32(0); + return true; + } + return true; + } + SE_BIND_FUNC(JSBDebug_exitNestedEventLoop) + + static bool JSBDebug_getEventLoopNestLevel(State& s) + { + s.rval().setInt32(s_nestedLoopLevel); + return true; + } + SE_BIND_FUNC(JSBDebug_getEventLoopNestLevel) + + static void _clientSocketWriteAndClearString(std::string& s) + { + ::send(clientSocket, s.c_str(), s.length(), 0); + s.clear(); + } + + static void processInput(const std::string& data) { + std::lock_guard lk(g_qMutex); + g_queue.push_back(data); + } + + static void clearBuffers() { + std::lock_guard lk(g_rwMutex); + // only process input if there's something and we're not locked + if (!inData.empty()) { + processInput(inData); + inData.clear(); + } + if (!outData.empty()) { + _clientSocketWriteAndClearString(outData); + } + } + + static void serverEntryPoint(uint32_t port) + { + // start a server, accept the connection and keep reading data from it + struct addrinfo hints, *result = nullptr, *rp = nullptr; + int s = 0; + memset(&hints, 0, sizeof(struct addrinfo)); + hints.ai_family = AF_UNSPEC; + hints.ai_socktype = SOCK_STREAM; // TCP stream sockets + hints.ai_flags = AI_PASSIVE; // fill in my IP for me + + std::stringstream portstr; + portstr << port; + + int err = 0; + +#ifdef _WIN32 + WSADATA wsaData; + err = WSAStartup(MAKEWORD(2, 2),&wsaData); +#endif + + if ((err = getaddrinfo(NULL, portstr.str().c_str(), &hints, &result)) != 0) { + LOGD("getaddrinfo error : %s\n", gai_strerror(err)); + } + + for (rp = result; rp != NULL; rp = rp->ai_next) { + if ((s = socket(rp->ai_family, rp->ai_socktype, 0)) < 0) { + continue; + } + int optval = 1; + if ((setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char*)&optval, sizeof(optval))) < 0) { + cc_closesocket(s); + TRACE_DEBUGGER_SERVER("debug server : error setting socket option SO_REUSEADDR\n"); + return; + } + +#ifdef __APPLE__ + if ((setsockopt(s, SOL_SOCKET, SO_NOSIGPIPE, &optval, sizeof(optval))) < 0) { + close(s); + TRACE_DEBUGGER_SERVER("debug server : error setting socket option SO_NOSIGPIPE\n"); + return; + } +#endif + + if ((::bind(s, rp->ai_addr, rp->ai_addrlen)) == 0) { + break; + } + cc_closesocket(s); + s = -1; + } + if (s < 0 || rp == NULL) { + TRACE_DEBUGGER_SERVER("debug server : error creating/binding socket\n"); + return; + } + + freeaddrinfo(result); + + listen(s, 1); + +#define MAX_RECEIVED_SIZE 1024 +#define BUF_SIZE MAX_RECEIVED_SIZE + 1 + + char buf[BUF_SIZE] = {0}; + int readBytes = 0; + while (true) { + clientSocket = accept(s, NULL, NULL); + + if (clientSocket < 0) + { + TRACE_DEBUGGER_SERVER("debug server : error on accept\n"); + return; + } + else + { + // read/write data + TRACE_DEBUGGER_SERVER("debug server : client connected\n"); + + inData = "connected"; + // process any input, send any output + clearBuffers(); + + while ((readBytes = (int)::recv(clientSocket, buf, MAX_RECEIVED_SIZE, 0)) > 0) + { + buf[readBytes] = '\0'; + // TRACE_DEBUGGER_SERVER("debug server : received command >%s", buf); + + // no other thread is using this + inData.append(buf); + // process any input, send any output + clearBuffers(); + } // while(read) + + cc_closesocket(clientSocket); + } + } // while(true) + +#undef BUF_SIZE +#undef MAX_RECEIVED_SIZE + } + + static bool JSBDebug_require(State& s) + { + const auto& args = s.args(); + int argc = (int)args.size(); + + if (argc >= 1) + { + ScriptEngine::getInstance()->runScript(args[0].toString()); + return true; + } + + SE_REPORT_ERROR("Wrong number of arguments: %d, expected: %d", argc, 1); + return false; + } + SE_BIND_FUNC(JSBDebug_require) + + static bool JSBDebug_BufferWrite(State& s) + { + const auto& args = s.args(); + int argc = (int)args.size(); + if (argc == 1) + { + // this is safe because we're already inside a lock (from clearBuffers) + outData.append(args[0].toString()); + _clientSocketWriteAndClearString(outData); + } + return true; + } + SE_BIND_FUNC(JSBDebug_BufferWrite) + bool ScriptEngine::start() { if (!init()) return false; + if (_debugGlobalObj == nullptr) + { + JS::CompartmentOptions options; + options.behaviors().setVersion(JSVERSION_LATEST); + options.creationOptions().setSharedMemoryAndAtomicsEnabled(true); + + JS::RootedObject debugGlobal(_cx, JS_NewGlobalObject(_cx, &__globalClass, nullptr, JS::DontFireOnNewGlobalHook, options)); + _debugGlobalObj = Object::_createJSObject(nullptr, debugGlobal); + _debugGlobalObj->root(); + + JSCompartment *globalCpt = JS_EnterCompartment(_cx, debugGlobal); + JS_InitStandardClasses(_cx, debugGlobal); + JS_FireOnNewGlobalObject(_cx, debugGlobal); + JS_DefineDebuggerObject(_cx, debugGlobal); + + // these are used in the debug program + JS_DefineFunction(_cx, debugGlobal, "log", __log, 0, JSPROP_PERMANENT); + _debugGlobalObj->defineFunction("require", _SE(JSBDebug_require)); + _debugGlobalObj->defineFunction("_bufferWrite", _SE(JSBDebug_BufferWrite)); + _debugGlobalObj->defineFunction("_enterNestedEventLoop", _SE(JSBDebug_enterNestedEventLoop)); + _debugGlobalObj->defineFunction("_exitNestedEventLoop", _SE(JSBDebug_exitNestedEventLoop)); + _debugGlobalObj->defineFunction("_getEventLoopNestLevel", _SE(JSBDebug_getEventLoopNestLevel)); + + JS::RootedObject globalObj(_cx, _globalObj->_getJSObject()); + JS_WrapObject(_cx, &globalObj); + + runScript("script/jsb_debugger.js"); + + // prepare the debugger + Value prepareDebuggerFunc; + assert(_debugGlobalObj->getProperty("_prepareDebugger", &prepareDebuggerFunc) && prepareDebuggerFunc.isObject() && prepareDebuggerFunc.toObject()->isFunction()); + + ValueArray args; + args.push_back(Value(_globalObj)); + prepareDebuggerFunc.toObject()->call(args, _debugGlobalObj); + + // start bg thread + auto t = std::thread(&serverEntryPoint, _debuggerServerPort); + t.detach(); + + JS_LeaveCompartment(_cx, globalCpt); + } + bool ok = false; _startTime = std::chrono::steady_clock::now(); @@ -721,18 +1026,6 @@ namespace se { iterOwner->second->detachObject(iterTarget->second); } - bool ScriptEngine::_onReceiveNodeEvent(void* node, NodeEventType type) - { - assert(_nodeEventListener != nullptr); - return _nodeEventListener(node, type); - } - - bool ScriptEngine::_setNodeEventListener(NodeEventListener listener) - { - _nodeEventListener = listener; - return true; - } - void ScriptEngine::clearException() { if (_cx == nullptr) @@ -813,317 +1106,15 @@ namespace se { _exceptionCallback = cb; } -#pragma mark - Debug - - static std::string inData; - static std::string outData; - static std::vector g_queue; - static std::mutex g_qMutex; - static std::mutex g_rwMutex; - static int clientSocket = -1; - static uint32_t s_nestedLoopLevel = 0; - - static void cc_closesocket(int fd) + void ScriptEngine::enableDebugger(const std::string& serverAddr, uint32_t port) { -#ifdef _WIN32 - closesocket(fd); -#else - close(fd); -#endif + _debuggerServerAddr = serverAddr; + _debuggerServerPort = port; } - void ScriptEngine::_debugProcessInput(const std::string& str) + bool ScriptEngine::isDebuggerEnabled() const { - JS::RootedObject debugGlobal(_cx, _debugGlobalObj->_getJSObject()); - JSCompartment *globalCpt = JS_EnterCompartment(_cx, debugGlobal); - - Value func; - if (_debugGlobalObj->getProperty("processInput", &func) && func.isObject() && func.toObject()->isFunction()) - { - ValueArray args; - args.push_back(Value(str)); - func.toObject()->call(args, _debugGlobalObj); - } - - JS_LeaveCompartment(_cx, globalCpt); - } - - static bool NS_ProcessNextEvent() - { - std::string message; - size_t messageCount = 0; - while (true) - { - g_qMutex.lock(); - messageCount = g_queue.size(); - if (messageCount > 0) - { - auto first = g_queue.begin(); - message = *first; - g_queue.erase(first); - --messageCount; - } - g_qMutex.unlock(); - - if (!message.empty()) - { - ScriptEngine::getInstance()->_debugProcessInput(message); - } - - if (messageCount == 0) - break; - } - // std::this_thread::yield(); - std::this_thread::sleep_for(std::chrono::milliseconds(10)); - - return true; - } - - static bool JSBDebug_enterNestedEventLoop(State& s) - { - enum { - NS_OK = 0, - NS_ERROR_UNEXPECTED - }; - -#define NS_SUCCEEDED(v) ((v) == NS_OK) - - int rv = NS_OK; - - uint32_t nestLevel = ++s_nestedLoopLevel; - - while (NS_SUCCEEDED(rv) && s_nestedLoopLevel >= nestLevel) { - drainJobQueue(); - if (!NS_ProcessNextEvent()) - rv = NS_ERROR_UNEXPECTED; - } - - assert(s_nestedLoopLevel <= nestLevel); - - s.rval().setInt32(s_nestedLoopLevel); - return true; - } - SE_BIND_FUNC(JSBDebug_enterNestedEventLoop) - - static bool JSBDebug_exitNestedEventLoop(State& s) - { - if (s_nestedLoopLevel > 0) { - --s_nestedLoopLevel; - } else { - s.rval().setInt32(0); - return true; - } - return true; - } - SE_BIND_FUNC(JSBDebug_exitNestedEventLoop) - - static bool JSBDebug_getEventLoopNestLevel(State& s) - { - s.rval().setInt32(s_nestedLoopLevel); - return true; - } - SE_BIND_FUNC(JSBDebug_getEventLoopNestLevel) - - static void _clientSocketWriteAndClearString(std::string& s) - { - ::send(clientSocket, s.c_str(), s.length(), 0); - s.clear(); - } - - static void processInput(const std::string& data) { - std::lock_guard lk(g_qMutex); - g_queue.push_back(data); - } - - static void clearBuffers() { - std::lock_guard lk(g_rwMutex); - // only process input if there's something and we're not locked - if (!inData.empty()) { - processInput(inData); - inData.clear(); - } - if (!outData.empty()) { - _clientSocketWriteAndClearString(outData); - } - } - - static void serverEntryPoint(unsigned int port) - { - // start a server, accept the connection and keep reading data from it - struct addrinfo hints, *result = nullptr, *rp = nullptr; - int s = 0; - memset(&hints, 0, sizeof(struct addrinfo)); - hints.ai_family = AF_UNSPEC; - hints.ai_socktype = SOCK_STREAM; // TCP stream sockets - hints.ai_flags = AI_PASSIVE; // fill in my IP for me - - std::stringstream portstr; - portstr << port; - - int err = 0; - -#ifdef _WIN32 - WSADATA wsaData; - err = WSAStartup(MAKEWORD(2, 2),&wsaData); -#endif - - if ((err = getaddrinfo(NULL, portstr.str().c_str(), &hints, &result)) != 0) { - LOGD("getaddrinfo error : %s\n", gai_strerror(err)); - } - - for (rp = result; rp != NULL; rp = rp->ai_next) { - if ((s = socket(rp->ai_family, rp->ai_socktype, 0)) < 0) { - continue; - } - int optval = 1; - if ((setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char*)&optval, sizeof(optval))) < 0) { - cc_closesocket(s); - TRACE_DEBUGGER_SERVER("debug server : error setting socket option SO_REUSEADDR"); - return; - } - -#ifdef __APPLE__ - if ((setsockopt(s, SOL_SOCKET, SO_NOSIGPIPE, &optval, sizeof(optval))) < 0) { - close(s); - TRACE_DEBUGGER_SERVER("debug server : error setting socket option SO_NOSIGPIPE"); - return; - } -#endif - - if ((::bind(s, rp->ai_addr, rp->ai_addrlen)) == 0) { - break; - } - cc_closesocket(s); - s = -1; - } - if (s < 0 || rp == NULL) { - TRACE_DEBUGGER_SERVER("debug server : error creating/binding socket"); - return; - } - - freeaddrinfo(result); - - listen(s, 1); - -#define MAX_RECEIVED_SIZE 1024 -#define BUF_SIZE MAX_RECEIVED_SIZE + 1 - - char buf[BUF_SIZE] = {0}; - int readBytes = 0; - while (true) { - clientSocket = accept(s, NULL, NULL); - - if (clientSocket < 0) - { - TRACE_DEBUGGER_SERVER("debug server : error on accept"); - return; - } - else - { - // read/write data - TRACE_DEBUGGER_SERVER("debug server : client connected"); - - inData = "connected"; - // process any input, send any output - clearBuffers(); - - while ((readBytes = (int)::recv(clientSocket, buf, MAX_RECEIVED_SIZE, 0)) > 0) - { - buf[readBytes] = '\0'; - // TRACE_DEBUGGER_SERVER("debug server : received command >%s", buf); - - // no other thread is using this - inData.append(buf); - // process any input, send any output - clearBuffers(); - } // while(read) - - cc_closesocket(clientSocket); - } - } // while(true) - -#undef BUF_SIZE -#undef MAX_RECEIVED_SIZE - } - - static bool JSBDebug_require(State& s) - { - const auto& args = s.args(); - int argc = (int)args.size(); - - if (argc >= 1) - { - ScriptEngine::getInstance()->runScript(args[0].toString()); - return true; - } - - SE_REPORT_ERROR("Wrong number of arguments: %d, expected: %d", argc, 1); - return false; - } - SE_BIND_FUNC(JSBDebug_require) - - static bool JSBDebug_BufferWrite(State& s) - { - const auto& args = s.args(); - int argc = (int)args.size(); - if (argc == 1) - { - // this is safe because we're already inside a lock (from clearBuffers) - outData.append(args[0].toString()); - _clientSocketWriteAndClearString(outData); - } - return true; - } - SE_BIND_FUNC(JSBDebug_BufferWrite) - - void ScriptEngine::enableDebugger(unsigned int port) - { - if (_debugGlobalObj != nullptr) - { - LOGD("Debugger was enabled!"); - return; - } - - JS::CompartmentOptions options; - options.behaviors().setVersion(JSVERSION_LATEST); - options.creationOptions().setSharedMemoryAndAtomicsEnabled(true); - - JS::RootedObject debugGlobal(_cx, JS_NewGlobalObject(_cx, &__globalClass, nullptr, JS::DontFireOnNewGlobalHook, options)); - _debugGlobalObj = Object::_createJSObject(nullptr, debugGlobal); - _debugGlobalObj->root(); - - JSCompartment *globalCpt = JS_EnterCompartment(_cx, debugGlobal); - JS_InitStandardClasses(_cx, debugGlobal); - //cjh registerDefaultClasses(_cx, debugGlobal); - JS_FireOnNewGlobalObject(_cx, debugGlobal); - JS_DefineDebuggerObject(_cx, debugGlobal); - - // these are used in the debug program - JS_DefineFunction(_cx, debugGlobal, "log", __log, 0, JSPROP_PERMANENT); - _debugGlobalObj->defineFunction("require", _SE(JSBDebug_require)); - _debugGlobalObj->defineFunction("_bufferWrite", _SE(JSBDebug_BufferWrite)); - _debugGlobalObj->defineFunction("_enterNestedEventLoop", _SE(JSBDebug_enterNestedEventLoop)); - _debugGlobalObj->defineFunction("_exitNestedEventLoop", _SE(JSBDebug_exitNestedEventLoop)); - _debugGlobalObj->defineFunction("_getEventLoopNestLevel", _SE(JSBDebug_getEventLoopNestLevel)); - - JS::RootedObject globalObj(_cx, _globalObj->_getJSObject()); - JS_WrapObject(_cx, &globalObj); - - runScript("script/jsb_debugger.js"); - - // prepare the debugger - Value prepareDebuggerFunc; - assert(_debugGlobalObj->getProperty("_prepareDebugger", &prepareDebuggerFunc) && prepareDebuggerFunc.isObject() && prepareDebuggerFunc.toObject()->isFunction()); - - ValueArray args; - args.push_back(Value(_globalObj)); - prepareDebuggerFunc.toObject()->call(args, _debugGlobalObj); - - // start bg thread - auto t = std::thread(&serverEntryPoint, port); - t.detach(); - - JS_LeaveCompartment(_cx, globalCpt); + return !_debuggerServerAddr.empty() && _debuggerServerPort > 0; } void ScriptEngine::mainLoopUpdate() diff --git a/native/cocos/scripting/js-bindings/jswrapper/sm/ScriptEngine.hpp b/native/cocos/scripting/js-bindings/jswrapper/sm/ScriptEngine.hpp index d15ea494ab..ddd7ac5d23 100644 --- a/native/cocos/scripting/js-bindings/jswrapper/sm/ScriptEngine.hpp +++ b/native/cocos/scripting/js-bindings/jswrapper/sm/ScriptEngine.hpp @@ -104,7 +104,8 @@ namespace se { const std::chrono::steady_clock::time_point& getStartTime() const { return _startTime; } - void enableDebugger(unsigned int port = 5086); + void enableDebugger(const std::string& serverAddr, uint32_t port); + bool isDebuggerEnabled() const; void mainLoopUpdate(); uint32_t getVMId() const { return _vmId; } @@ -112,19 +113,6 @@ namespace se { void _retainScriptObject(void* owner, void* target); void _releaseScriptObject(void* owner, void* target); - enum class NodeEventType - { - ENTER, - EXIT, - ENTER_TRANSITION_DID_FINISH, - EXIT_TRANSITION_DID_START, - CLEANUP - }; - bool _onReceiveNodeEvent(void* node, NodeEventType type); - - using NodeEventListener = bool(*)(void*, NodeEventType); - bool _setNodeEventListener(NodeEventListener listener); - void _debugProcessInput(const std::string& str); private: @@ -139,7 +127,6 @@ namespace se { Object* _globalObj; Object* _debugGlobalObj; - NodeEventListener _nodeEventListener; FileOperationDelegate _fileOperationDelegate; @@ -156,6 +143,9 @@ namespace se { // name ~> JSScript map std::unordered_map _filenameScriptMap; + std::string _debuggerServerAddr; + uint32_t _debuggerServerPort; + uint32_t _vmId; bool _isGarbageCollecting; diff --git a/native/cocos/scripting/js-bindings/jswrapper/v8/Object.cpp b/native/cocos/scripting/js-bindings/jswrapper/v8/Object.cpp index 0819476c58..00c4557eb3 100644 --- a/native/cocos/scripting/js-bindings/jswrapper/v8/Object.cpp +++ b/native/cocos/scripting/js-bindings/jswrapper/v8/Object.cpp @@ -256,11 +256,11 @@ namespace se { return true; } - void Object::setProperty(const char *name, const Value& data) + bool Object::setProperty(const char *name, const Value& data) { v8::MaybeLocal nameValue = v8::String::NewFromUtf8(__isolate, name, v8::NewStringType::kNormal); if (nameValue.IsEmpty()) - return; + return false; v8::Local value; internal::seToJsValue(__isolate, data, &value); @@ -268,7 +268,9 @@ namespace se { if (ret.IsNothing()) { LOGD("ERROR: %s, Set return nothing ...\n", __FUNCTION__); + return false; } + return true; } bool Object::defineProperty(const char *name, v8::AccessorNameGetterCallback getter, v8::AccessorNameSetterCallback setter) diff --git a/native/cocos/scripting/js-bindings/jswrapper/v8/Object.hpp b/native/cocos/scripting/js-bindings/jswrapper/v8/Object.hpp index eaddbc08f0..3324d33cc7 100644 --- a/native/cocos/scripting/js-bindings/jswrapper/v8/Object.hpp +++ b/native/cocos/scripting/js-bindings/jswrapper/v8/Object.hpp @@ -30,7 +30,7 @@ namespace se { bool getProperty(const char *name, Value* data); - void setProperty(const char *name, const Value& data); + bool setProperty(const char *name, const Value& data); bool defineProperty(const char *name, v8::AccessorNameGetterCallback getter, v8::AccessorNameSetterCallback setter); bool isFunction() const; diff --git a/native/cocos/scripting/js-bindings/jswrapper/v8/SHA1.cpp b/native/cocos/scripting/js-bindings/jswrapper/v8/SHA1.cpp index a652de3232..5062767e18 100644 --- a/native/cocos/scripting/js-bindings/jswrapper/v8/SHA1.cpp +++ b/native/cocos/scripting/js-bindings/jswrapper/v8/SHA1.cpp @@ -8,7 +8,7 @@ //#include "mozilla/EndianUtils.h" #include "SHA1.h" -#if defined(SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR +#if (SCRIPT_ENGINE_TYPE == SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR #include #include @@ -527,4 +527,4 @@ shaCompress(volatile unsigned* aX, const uint32_t* aBuf) XH(4) += E; } -#endif // #if defined(SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR +#endif // #if (SCRIPT_ENGINE_TYPE == SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR diff --git a/native/cocos/scripting/js-bindings/jswrapper/v8/SHA1.h b/native/cocos/scripting/js-bindings/jswrapper/v8/SHA1.h index fa32dfc859..62fb65aa2c 100644 --- a/native/cocos/scripting/js-bindings/jswrapper/v8/SHA1.h +++ b/native/cocos/scripting/js-bindings/jswrapper/v8/SHA1.h @@ -9,7 +9,7 @@ #pragma once #include "../config.hpp" -#if defined(SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR +#if (SCRIPT_ENGINE_TYPE == SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR //#include "mozilla/Types.h" @@ -68,5 +68,5 @@ public: } /* namespace se */ -#endif // #if defined(SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR +#endif // #if (SCRIPT_ENGINE_TYPE == SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR diff --git a/native/cocos/scripting/js-bindings/jswrapper/v8/ScriptEngine.cpp b/native/cocos/scripting/js-bindings/jswrapper/v8/ScriptEngine.cpp index c48c149209..7d3def6208 100644 --- a/native/cocos/scripting/js-bindings/jswrapper/v8/ScriptEngine.cpp +++ b/native/cocos/scripting/js-bindings/jswrapper/v8/ScriptEngine.cpp @@ -204,11 +204,11 @@ namespace se { , _handleScope(nullptr) , _allocator(nullptr) , _globalObj(nullptr) - , _nodeEventListener(nullptr) , _exceptionCallback(nullptr) #if SE_ENABLE_INSPECTOR , _env(nullptr) #endif + , _debuggerServerPort(0) , _vmId(0) , _isValid(false) , _isGarbageCollecting(false) @@ -235,7 +235,7 @@ namespace se { bool ScriptEngine::init() { cleanup(); - LOGD("Initializing V8\n"); + LOGD("Initializing V8, version: %s\n", v8::V8::GetVersion()); ++_vmId; for (const auto& hook : _beforeInitHookArray) @@ -331,7 +331,6 @@ namespace se { _isolate = nullptr; _globalObj = nullptr; _isValid = false; - _nodeEventListener = nullptr; _registerCallbackArray.clear(); @@ -385,6 +384,24 @@ namespace se { return false; se::AutoHandleScope hs; + + // debugger + if (isDebuggerEnabled()) + { +#if SE_ENABLE_INSPECTOR + // V8 inspector stuff, most code are taken from NodeJS. + _isolateData = node::CreateIsolateData(_isolate, uv_default_loop()); + _env = node::CreateEnvironment(_isolateData, _context.Get(_isolate), 0, nullptr, 0, nullptr); + + node::DebugOptions options; + options.set_wait_for_connect(false); // Don't wait for connect, otherwise, the program will be hung up. + options.set_inspector_enabled(true); + options.set_port((int)_debuggerServerPort); + options.set_host_name(_debuggerServerAddr.c_str()); + _env->inspector_agent()->Start(_platform, "", options); +#endif + } + // bool ok = false; _startTime = std::chrono::steady_clock::now(); @@ -439,13 +456,22 @@ namespace se { if (fileName == nullptr) fileName = "(no filename)"; + // Fix the source url is too long displayed in Chrome debugger. + std::string sourceUrl = fileName; + static const std::string prefixKey = "/temp/quick-scripts/"; + size_t prefixPos = sourceUrl.find(prefixKey); + if (prefixPos != std::string::npos) + { + sourceUrl = sourceUrl.substr(prefixPos + prefixKey.length()); + } + std::string scriptStr(script, length); v8::MaybeLocal source = v8::String::NewFromUtf8(_isolate, scriptStr.c_str(), v8::NewStringType::kNormal); if (source.IsEmpty()) return false; - v8::MaybeLocal originStr = v8::String::NewFromUtf8(_isolate, fileName, v8::NewStringType::kNormal); + v8::MaybeLocal originStr = v8::String::NewFromUtf8(_isolate, sourceUrl.c_str(), v8::NewStringType::kNormal); if (originStr.IsEmpty()) return false; @@ -535,18 +561,6 @@ namespace se { iterOwner->second->detachObject(iterTarget->second); } - bool ScriptEngine::_onReceiveNodeEvent(void* node, NodeEventType type) - { - assert(_nodeEventListener != nullptr); - return _nodeEventListener(node, type); - } - - bool ScriptEngine::_setNodeEventListener(NodeEventListener listener) - { - _nodeEventListener = listener; - return true; - } - void ScriptEngine::clearException() { //FIXME: @@ -562,24 +576,15 @@ namespace se { return _context.Get(_isolate); } - void ScriptEngine::enableDebugger(unsigned int port/* = 5086*/) + void ScriptEngine::enableDebugger(const std::string& serverAddr, uint32_t port) { -#if SE_ENABLE_INSPECTOR - AutoHandleScope hs; - // V8 inspector stuff, most code are taken from NodeJS. + _debuggerServerAddr = serverAddr; + _debuggerServerPort = port; + } - _isolateData = node::CreateIsolateData(_isolate, uv_default_loop()); - _env = node::CreateEnvironment(_isolateData, _context.Get(_isolate), 0, nullptr, 0, nullptr); - - node::DebugOptions options; - options.set_wait_for_connect(true); - options.set_inspector_enabled(true); - options.set_port((int)port); - // options.set_host_name("192.168.2.4"); // Change IP while remote debugging on Android device. - _env->inspector_agent()->Start(_platform, "", options); - - // -#endif + bool ScriptEngine::isDebuggerEnabled() const + { + return !_debuggerServerAddr.empty() && _debuggerServerPort > 0; } void ScriptEngine::mainLoopUpdate() diff --git a/native/cocos/scripting/js-bindings/jswrapper/v8/ScriptEngine.hpp b/native/cocos/scripting/js-bindings/jswrapper/v8/ScriptEngine.hpp index 8791d0dd25..a09ccd7397 100644 --- a/native/cocos/scripting/js-bindings/jswrapper/v8/ScriptEngine.hpp +++ b/native/cocos/scripting/js-bindings/jswrapper/v8/ScriptEngine.hpp @@ -138,7 +138,8 @@ namespace se { const std::chrono::steady_clock::time_point& getStartTime() const { return _startTime; } - void enableDebugger(unsigned int port = 5086); + void enableDebugger(const std::string& serverAddr, uint32_t port); + bool isDebuggerEnabled() const; void mainLoopUpdate(); uint32_t getVMId() const { return _vmId; } @@ -146,18 +147,6 @@ namespace se { void _retainScriptObject(void* owner, void* target); void _releaseScriptObject(void* owner, void* target); - enum class NodeEventType - { - ENTER, - EXIT, - ENTER_TRANSITION_DID_FINISH, - EXIT_TRANSITION_DID_START, - CLEANUP - }; - bool _onReceiveNodeEvent(void* node, NodeEventType type); - using NodeEventListener = bool(*)(void*, NodeEventType); - bool _setNodeEventListener(NodeEventListener listener); - v8::Local _getContext() const; private: static void privateDataFinalize(void* nativeObj); @@ -182,7 +171,6 @@ namespace se { v8::ArrayBuffer::Allocator* _allocator; Object* _globalObj; - NodeEventListener _nodeEventListener; FileOperationDelegate _fileOperationDelegate; ExceptionCallback _exceptionCallback; @@ -191,6 +179,9 @@ namespace se { node::IsolateData* _isolateData; #endif + std::string _debuggerServerAddr; + uint32_t _debuggerServerPort; + uint32_t _vmId; bool _isValid; diff --git a/native/cocos/scripting/js-bindings/jswrapper/v8/env.cc b/native/cocos/scripting/js-bindings/jswrapper/v8/env.cc index 01b3525933..0376e29975 100644 --- a/native/cocos/scripting/js-bindings/jswrapper/v8/env.cc +++ b/native/cocos/scripting/js-bindings/jswrapper/v8/env.cc @@ -1,6 +1,6 @@ #include "env.h" -#if defined(SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR +#if (SCRIPT_ENGINE_TYPE == SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR #include "uv.h" @@ -119,4 +119,4 @@ namespace node { } // namespace node { -#endif // #if defined(SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR +#endif // #if (SCRIPT_ENGINE_TYPE == SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR diff --git a/native/cocos/scripting/js-bindings/jswrapper/v8/env.h b/native/cocos/scripting/js-bindings/jswrapper/v8/env.h index b080eeb7e1..9a971e2236 100644 --- a/native/cocos/scripting/js-bindings/jswrapper/v8/env.h +++ b/native/cocos/scripting/js-bindings/jswrapper/v8/env.h @@ -1,7 +1,7 @@ #pragma once #include "../config.hpp" -#if defined(SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR +#if (SCRIPT_ENGINE_TYPE == SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR #include "inspector_agent.h" @@ -295,7 +295,7 @@ v8::Eternal PropertyName ## _; uv_loop_t* const event_loop_; uint32_t* const zero_fill_field_; - DISALLOW_COPY_AND_ASSIGN(IsolateData); + NODE_DISALLOW_COPY_AND_ASSIGN(IsolateData); }; class Environment @@ -396,7 +396,7 @@ v8::Eternal PropertyName ## _; private: Environment* env_; - DISALLOW_COPY_AND_ASSIGN(AsyncCallbackScope); + NODE_DISALLOW_COPY_AND_ASSIGN(AsyncCallbackScope); }; private: @@ -625,5 +625,5 @@ Environment::NewFunctionTemplate(v8::FunctionCallback callback, } // namespace node { -#endif // #if defined(SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR +#endif // #if (SCRIPT_ENGINE_TYPE == SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR diff --git a/native/cocos/scripting/js-bindings/jswrapper/v8/http_parser.c b/native/cocos/scripting/js-bindings/jswrapper/v8/http_parser.c index 15cf87a903..42634f1749 100644 --- a/native/cocos/scripting/js-bindings/jswrapper/v8/http_parser.c +++ b/native/cocos/scripting/js-bindings/jswrapper/v8/http_parser.c @@ -23,7 +23,7 @@ */ #include "http_parser.h" -#if defined(SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR +#if (SCRIPT_ENGINE_TYPE == SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR #include #include @@ -2470,4 +2470,4 @@ http_parser_version(void) { HTTP_PARSER_VERSION_PATCH * 0x00001; } -#endif // #if defined(SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR +#endif // #if (SCRIPT_ENGINE_TYPE == SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR diff --git a/native/cocos/scripting/js-bindings/jswrapper/v8/http_parser.h b/native/cocos/scripting/js-bindings/jswrapper/v8/http_parser.h index 0e974d81c7..fbcc595d09 100644 --- a/native/cocos/scripting/js-bindings/jswrapper/v8/http_parser.h +++ b/native/cocos/scripting/js-bindings/jswrapper/v8/http_parser.h @@ -22,7 +22,7 @@ #define http_parser_h #include "../config.hpp" -#if defined(SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR +#if (SCRIPT_ENGINE_TYPE == SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR #ifdef __cplusplus extern "C" { @@ -364,6 +364,6 @@ int http_body_is_final(const http_parser *parser); } #endif -#endif // #if defined(SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR +#endif // #if (SCRIPT_ENGINE_TYPE == SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR #endif diff --git a/native/cocos/scripting/js-bindings/jswrapper/v8/inspector_agent.cc b/native/cocos/scripting/js-bindings/jswrapper/v8/inspector_agent.cc index d2a16492a2..1e3e23e6ed 100644 --- a/native/cocos/scripting/js-bindings/jswrapper/v8/inspector_agent.cc +++ b/native/cocos/scripting/js-bindings/jswrapper/v8/inspector_agent.cc @@ -1,6 +1,6 @@ #include "inspector_agent.h" -#if defined(SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR +#if (SCRIPT_ENGINE_TYPE == SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR #include "inspector_io.h" #include "env.h" @@ -812,4 +812,4 @@ void Agent::RequestIoThreadStart() { //cjh NODE_MODULE_CONTEXT_AWARE_BUILTIN(inspector, // node::inspector::Agent::InitInspector); -#endif // #if defined(SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR +#endif // #if (SCRIPT_ENGINE_TYPE == SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR diff --git a/native/cocos/scripting/js-bindings/jswrapper/v8/inspector_agent.h b/native/cocos/scripting/js-bindings/jswrapper/v8/inspector_agent.h index 719bf78355..f280ca9a05 100644 --- a/native/cocos/scripting/js-bindings/jswrapper/v8/inspector_agent.h +++ b/native/cocos/scripting/js-bindings/jswrapper/v8/inspector_agent.h @@ -2,7 +2,7 @@ #define SRC_INSPECTOR_AGENT_H_ #include "../config.hpp" -#if defined(SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR +#if (SCRIPT_ENGINE_TYPE == SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR #include @@ -113,6 +113,6 @@ class Agent { } // namespace inspector } // namespace node -#endif // #if defined(SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR +#endif // #if (SCRIPT_ENGINE_TYPE == SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR #endif // SRC_INSPECTOR_AGENT_H_ diff --git a/native/cocos/scripting/js-bindings/jswrapper/v8/inspector_io.cc b/native/cocos/scripting/js-bindings/jswrapper/v8/inspector_io.cc index 5de6b08c21..3f9c35f739 100644 --- a/native/cocos/scripting/js-bindings/jswrapper/v8/inspector_io.cc +++ b/native/cocos/scripting/js-bindings/jswrapper/v8/inspector_io.cc @@ -1,5 +1,5 @@ #include "inspector_io.h" -#if defined(SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR +#if (SCRIPT_ENGINE_TYPE == SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR #include "inspector_socket_server.h" #include "env.h" @@ -527,4 +527,4 @@ void IoSessionDelegate::SendMessageToFrontend( } // namespace inspector } // namespace node -#endif // #if defined(SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR +#endif // #if (SCRIPT_ENGINE_TYPE == SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR diff --git a/native/cocos/scripting/js-bindings/jswrapper/v8/inspector_io.h b/native/cocos/scripting/js-bindings/jswrapper/v8/inspector_io.h index 6ba6f6bdf8..0af48eb745 100644 --- a/native/cocos/scripting/js-bindings/jswrapper/v8/inspector_io.h +++ b/native/cocos/scripting/js-bindings/jswrapper/v8/inspector_io.h @@ -2,7 +2,7 @@ #define SRC_INSPECTOR_IO_H_ #include "../config.hpp" -#if defined(SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR +#if (SCRIPT_ENGINE_TYPE == SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR #include "inspector_socket_server.h" #include "node_debug_options.h" @@ -175,6 +175,6 @@ std::unique_ptr Utf8ToStringView( } // namespace inspector } // namespace node -#endif // #if defined(SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR +#endif // #if (SCRIPT_ENGINE_TYPE == SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR #endif // SRC_INSPECTOR_IO_H_ diff --git a/native/cocos/scripting/js-bindings/jswrapper/v8/inspector_socket.cc b/native/cocos/scripting/js-bindings/jswrapper/v8/inspector_socket.cc index a9d4eb9a87..975acbbd4e 100644 --- a/native/cocos/scripting/js-bindings/jswrapper/v8/inspector_socket.cc +++ b/native/cocos/scripting/js-bindings/jswrapper/v8/inspector_socket.cc @@ -1,6 +1,6 @@ #include "inspector_socket.h" -#if defined(SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR +#if (SCRIPT_ENGINE_TYPE == SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR #include "util.h" @@ -637,4 +637,4 @@ void InspectorSocket::reinit() { } // namespace inspector } // namespace node -#endif // #if defined(SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR +#endif // #if (SCRIPT_ENGINE_TYPE == SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR diff --git a/native/cocos/scripting/js-bindings/jswrapper/v8/inspector_socket.h b/native/cocos/scripting/js-bindings/jswrapper/v8/inspector_socket.h index 2cd8fd94fd..274dc57295 100644 --- a/native/cocos/scripting/js-bindings/jswrapper/v8/inspector_socket.h +++ b/native/cocos/scripting/js-bindings/jswrapper/v8/inspector_socket.h @@ -2,7 +2,7 @@ #define SRC_INSPECTOR_SOCKET_H_ #include "../config.hpp" -#if defined(SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR +#if (SCRIPT_ENGINE_TYPE == SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR #include "http_parser.h" #include "util.h" @@ -67,7 +67,7 @@ class InspectorSocket { bool connection_eof; private: - DISALLOW_COPY_AND_ASSIGN(InspectorSocket); + NODE_DISALLOW_COPY_AND_ASSIGN(InspectorSocket); }; int inspector_accept(uv_stream_t* server, InspectorSocket* inspector, @@ -100,6 +100,6 @@ inline InspectorSocket* inspector_from_stream(uv_handle_t* stream) { } // namespace inspector } // namespace node -#endif // #if defined(SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR +#endif // #if (SCRIPT_ENGINE_TYPE == SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR #endif // SRC_INSPECTOR_SOCKET_H_ diff --git a/native/cocos/scripting/js-bindings/jswrapper/v8/inspector_socket_server.cc b/native/cocos/scripting/js-bindings/jswrapper/v8/inspector_socket_server.cc index c6bb84e716..cec096f409 100644 --- a/native/cocos/scripting/js-bindings/jswrapper/v8/inspector_socket_server.cc +++ b/native/cocos/scripting/js-bindings/jswrapper/v8/inspector_socket_server.cc @@ -1,6 +1,6 @@ #include "inspector_socket_server.h" -#if defined(SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR +#if (SCRIPT_ENGINE_TYPE == SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR #include "node.h" #include "uv.h" @@ -643,4 +643,4 @@ void ServerSocket::SocketClosedCallback(uv_handle_t* tcp_socket) { } // namespace inspector } // namespace node -#endif // #if defined(SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR +#endif // #if (SCRIPT_ENGINE_TYPE == SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR diff --git a/native/cocos/scripting/js-bindings/jswrapper/v8/inspector_socket_server.h b/native/cocos/scripting/js-bindings/jswrapper/v8/inspector_socket_server.h index 78fe979a68..a6d8bd17fc 100644 --- a/native/cocos/scripting/js-bindings/jswrapper/v8/inspector_socket_server.h +++ b/native/cocos/scripting/js-bindings/jswrapper/v8/inspector_socket_server.h @@ -2,7 +2,7 @@ #define SRC_INSPECTOR_SOCKET_SERVER_H_ #include "../config.hpp" -#if defined(SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR +#if (SCRIPT_ENGINE_TYPE == SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR #include "inspector_agent.h" #include "inspector_socket.h" @@ -99,6 +99,6 @@ class InspectorSocketServer { } // namespace inspector } // namespace node -#endif // #if defined(SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR +#endif // #if (SCRIPT_ENGINE_TYPE == SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR #endif // SRC_INSPECTOR_SOCKET_SERVER_H_ diff --git a/native/cocos/scripting/js-bindings/jswrapper/v8/node.cc b/native/cocos/scripting/js-bindings/jswrapper/v8/node.cc index e830454b6d..77f3365e09 100644 --- a/native/cocos/scripting/js-bindings/jswrapper/v8/node.cc +++ b/native/cocos/scripting/js-bindings/jswrapper/v8/node.cc @@ -1,6 +1,6 @@ #include "node.h" -#if defined(SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR +#if (SCRIPT_ENGINE_TYPE == SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR #include "util.h" #include "env.h" @@ -809,6 +809,8 @@ void SetupProcessObject(Environment* env, READONLY_PROPERTY(versions, "uv", OneByteString(env->isolate(), uv_version_string())); + + LOGD("libuv version: %s\n", uv_version_string()); // READONLY_PROPERTY(versions, // "zlib", // FIXED_ONE_BYTE_STRING(env->isolate(), ZLIB_VERSION)); @@ -1133,4 +1135,4 @@ void SetupProcessObject(Environment* env, } // namespace node { -#endif // #if defined(SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR +#endif // #if (SCRIPT_ENGINE_TYPE == SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR diff --git a/native/cocos/scripting/js-bindings/jswrapper/v8/node.h b/native/cocos/scripting/js-bindings/jswrapper/v8/node.h index 2f50432d66..ae2efd6a78 100644 --- a/native/cocos/scripting/js-bindings/jswrapper/v8/node.h +++ b/native/cocos/scripting/js-bindings/jswrapper/v8/node.h @@ -1,7 +1,7 @@ #pragma once #include "../config.hpp" -#if defined(SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR +#if (SCRIPT_ENGINE_TYPE == SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR #include "v8.h" @@ -162,4 +162,4 @@ void SetupProcessObject(Environment* env, } // namespace node { -#endif // #if defined(SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR +#endif // #if (SCRIPT_ENGINE_TYPE == SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR diff --git a/native/cocos/scripting/js-bindings/jswrapper/v8/node_debug_options.cc b/native/cocos/scripting/js-bindings/jswrapper/v8/node_debug_options.cc index e006c1682f..103435a5d0 100644 --- a/native/cocos/scripting/js-bindings/jswrapper/v8/node_debug_options.cc +++ b/native/cocos/scripting/js-bindings/jswrapper/v8/node_debug_options.cc @@ -1,6 +1,6 @@ #include "node_debug_options.h" -#if defined(SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR +#if (SCRIPT_ENGINE_TYPE == SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR #include #include @@ -138,4 +138,4 @@ int DebugOptions::port() const { } // namespace node -#endif // #if defined(SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR +#endif // #if (SCRIPT_ENGINE_TYPE == SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR diff --git a/native/cocos/scripting/js-bindings/jswrapper/v8/node_debug_options.h b/native/cocos/scripting/js-bindings/jswrapper/v8/node_debug_options.h index 4ab00d2f20..e44c5fb76e 100644 --- a/native/cocos/scripting/js-bindings/jswrapper/v8/node_debug_options.h +++ b/native/cocos/scripting/js-bindings/jswrapper/v8/node_debug_options.h @@ -2,7 +2,7 @@ #define SRC_NODE_DEBUG_OPTIONS_H_ #include "../config.hpp" -#if defined(SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR +#if (SCRIPT_ENGINE_TYPE == SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR #include @@ -40,6 +40,6 @@ class DebugOptions { } // namespace node -#endif // #if defined(SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR +#endif // #if (SCRIPT_ENGINE_TYPE == SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR #endif // SRC_NODE_DEBUG_OPTIONS_H_ diff --git a/native/cocos/scripting/js-bindings/jswrapper/v8/node_mutex.h b/native/cocos/scripting/js-bindings/jswrapper/v8/node_mutex.h index 2c149f196a..4f3f00b2f8 100644 --- a/native/cocos/scripting/js-bindings/jswrapper/v8/node_mutex.h +++ b/native/cocos/scripting/js-bindings/jswrapper/v8/node_mutex.h @@ -2,7 +2,7 @@ #define SRC_NODE_MUTEX_H_ #include "../config.hpp" -#if defined(SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR +#if (SCRIPT_ENGINE_TYPE == SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR #include "util.h" #include "uv.h" @@ -37,7 +37,7 @@ class MutexBase { template friend class ConditionVariableBase; friend class ScopedUnlock; const MutexBase& mutex_; - DISALLOW_COPY_AND_ASSIGN(ScopedLock); + NODE_DISALLOW_COPY_AND_ASSIGN(ScopedLock); }; class ScopedUnlock { @@ -48,13 +48,13 @@ class MutexBase { private: friend class ScopedLock; const MutexBase& mutex_; - DISALLOW_COPY_AND_ASSIGN(ScopedUnlock); + NODE_DISALLOW_COPY_AND_ASSIGN(ScopedUnlock); }; private: template friend class ConditionVariableBase; mutable typename Traits::MutexT mutex_; - DISALLOW_COPY_AND_ASSIGN(MutexBase); + NODE_DISALLOW_COPY_AND_ASSIGN(MutexBase); }; template @@ -70,7 +70,7 @@ class ConditionVariableBase { private: typename Traits::CondT cond_; - DISALLOW_COPY_AND_ASSIGN(ConditionVariableBase); + NODE_DISALLOW_COPY_AND_ASSIGN(ConditionVariableBase); }; struct LibuvMutexTraits { @@ -187,6 +187,6 @@ MutexBase::ScopedUnlock::~ScopedUnlock() { } // namespace node -#endif // #if defined(SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR +#endif // #if (SCRIPT_ENGINE_TYPE == SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR #endif // SRC_NODE_MUTEX_H_ diff --git a/native/cocos/scripting/js-bindings/jswrapper/v8/util.cc b/native/cocos/scripting/js-bindings/jswrapper/v8/util.cc index 5a418c73b5..290d0c53f9 100644 --- a/native/cocos/scripting/js-bindings/jswrapper/v8/util.cc +++ b/native/cocos/scripting/js-bindings/jswrapper/v8/util.cc @@ -21,7 +21,7 @@ #include "util.h" -#if defined(SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR +#if (SCRIPT_ENGINE_TYPE == SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR //cjh #include "string_bytes.h" //#include "node_buffer.h" @@ -114,4 +114,4 @@ void DumpBacktrace(FILE* fp) { } // namespace node -#endif // #if defined(SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR +#endif // #if (SCRIPT_ENGINE_TYPE == SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR diff --git a/native/cocos/scripting/js-bindings/jswrapper/v8/util.h b/native/cocos/scripting/js-bindings/jswrapper/v8/util.h index c7f8bf822c..f47b1a6a7f 100644 --- a/native/cocos/scripting/js-bindings/jswrapper/v8/util.h +++ b/native/cocos/scripting/js-bindings/jswrapper/v8/util.h @@ -23,7 +23,7 @@ #define SRC_UTIL_H_ #include "../config.hpp" -#if defined(SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR +#if (SCRIPT_ENGINE_TYPE == SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR #define NODE_WANT_INTERNALS 1 //cjh added @@ -92,7 +92,7 @@ template using remove_reference = std::remove_reference; #define FIXED_ONE_BYTE_STRING(isolate, string) \ (node::OneByteString((isolate), (string), sizeof(string) - 1)) -#define DISALLOW_COPY_AND_ASSIGN(TypeName) \ +#define NODE_DISALLOW_COPY_AND_ASSIGN(TypeName) \ void operator=(const TypeName&) = delete; \ void operator=(TypeName&&) = delete; \ TypeName(const TypeName&) = delete; \ @@ -166,7 +166,7 @@ class ListNode { template (U::*M)> friend class ListHead; ListNode* prev_; ListNode* next_; - DISALLOW_COPY_AND_ASSIGN(ListNode); + NODE_DISALLOW_COPY_AND_ASSIGN(ListNode); }; template (T::*M)> @@ -196,7 +196,7 @@ class ListHead { private: ListNode head_; - DISALLOW_COPY_AND_ASSIGN(ListHead); + NODE_DISALLOW_COPY_AND_ASSIGN(ListHead); }; // The helper is for doing safe downcasts from base types to derived types. @@ -441,6 +441,6 @@ class BufferValue : public MaybeStackBuffer { #define NODE_UTIL_H_INCLUDE #include "util-inl.h" -#endif // #if defined(SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR +#endif // #if (SCRIPT_ENGINE_TYPE == SCRIPT_ENGINE_V8) && SE_ENABLE_INSPECTOR #endif // SRC_UTIL_H_ diff --git a/native/cocos/scripting/js-bindings/manual/ScriptingCore.cpp b/native/cocos/scripting/js-bindings/manual/ScriptingCore.cpp index 80d97b9b58..adb174810b 100644 --- a/native/cocos/scripting/js-bindings/manual/ScriptingCore.cpp +++ b/native/cocos/scripting/js-bindings/manual/ScriptingCore.cpp @@ -38,7 +38,8 @@ ScriptingCore* ScriptingCore::getInstance() } ScriptingCore::ScriptingCore() -: _callFromScript(false) +: _nodeEventListener(nullptr) +, _callFromScript(false) { } @@ -193,6 +194,12 @@ int ScriptingCore::handleActionEvent(void* data) return ret; } +bool ScriptingCore::setNodeEventListener(NodeEventListener listener) +{ + _nodeEventListener = listener; + return true; +} + int ScriptingCore::handleNodeEvent(void* data) { if (nullptr == data) @@ -208,23 +215,23 @@ int ScriptingCore::handleNodeEvent(void* data) bool ret = false; if (action == kNodeOnEnter) { - ret = se::ScriptEngine::getInstance()->_onReceiveNodeEvent(node, se::ScriptEngine::NodeEventType::ENTER); + ret = _nodeEventListener(node, NodeEventType::ENTER); } else if (action == kNodeOnExit) { - ret = se::ScriptEngine::getInstance()->_onReceiveNodeEvent(node, se::ScriptEngine::NodeEventType::EXIT); + ret = _nodeEventListener(node, NodeEventType::EXIT); } else if (action == kNodeOnEnterTransitionDidFinish) { - ret = se::ScriptEngine::getInstance()->_onReceiveNodeEvent(node, se::ScriptEngine::NodeEventType::ENTER_TRANSITION_DID_FINISH); + ret = _nodeEventListener(node, NodeEventType::ENTER_TRANSITION_DID_FINISH); } else if (action == kNodeOnExitTransitionDidStart) { - ret = se::ScriptEngine::getInstance()->_onReceiveNodeEvent(node, se::ScriptEngine::NodeEventType::EXIT_TRANSITION_DID_START); + ret = _nodeEventListener(node, NodeEventType::EXIT_TRANSITION_DID_START); } else if (action == kNodeOnCleanup) { - ret = se::ScriptEngine::getInstance()->_onReceiveNodeEvent(node, se::ScriptEngine::NodeEventType::CLEANUP); + ret = _nodeEventListener(node, NodeEventType::CLEANUP); } return ret ? 1 : 0; diff --git a/native/cocos/scripting/js-bindings/manual/ScriptingCore.h b/native/cocos/scripting/js-bindings/manual/ScriptingCore.h index 155ced31d8..2f8e991598 100644 --- a/native/cocos/scripting/js-bindings/manual/ScriptingCore.h +++ b/native/cocos/scripting/js-bindings/manual/ScriptingCore.h @@ -132,12 +132,25 @@ public: void restartVM(); + enum class NodeEventType + { + ENTER, + EXIT, + ENTER_TRANSITION_DID_FINISH, + EXIT_TRANSITION_DID_START, + CLEANUP + }; + + using NodeEventListener = bool(*)(void*, NodeEventType); + bool setNodeEventListener(NodeEventListener listener); + private: ScriptingCore(); int handleActionEvent(void* data); int handleNodeEvent(void* data); + NodeEventListener _nodeEventListener; bool _callFromScript; }; diff --git a/native/cocos/scripting/js-bindings/manual/jsb_dragonbones_manual.cpp b/native/cocos/scripting/js-bindings/manual/jsb_dragonbones_manual.cpp index 4ae8445605..45741905ca 100644 --- a/native/cocos/scripting/js-bindings/manual/jsb_dragonbones_manual.cpp +++ b/native/cocos/scripting/js-bindings/manual/jsb_dragonbones_manual.cpp @@ -420,6 +420,9 @@ bool register_all_dragonbones_manual(se::Object* obj) // std::string typeName = typeid(*obj).name(); auto cleanup = [=](){ + if (!se::ScriptEngine::getInstance()->isValid()) + return; + se::AutoHandleScope hs; se::ScriptEngine::getInstance()->clearException(); diff --git a/native/cocos/scripting/js-bindings/manual/jsb_global.cpp b/native/cocos/scripting/js-bindings/manual/jsb_global.cpp index e6a6118b23..37c003f984 100644 --- a/native/cocos/scripting/js-bindings/manual/jsb_global.cpp +++ b/native/cocos/scripting/js-bindings/manual/jsb_global.cpp @@ -12,14 +12,15 @@ se::Object* __jscObj = nullptr; se::Object* __ccObj = nullptr; se::Object* __jsbObj = nullptr; -static const char* BYTE_CODE_FILE_EXT = ".jsc"; static std::string xxteaKey = ""; - void jsb_set_xxtea_key(const std::string& key) { xxteaKey = key; } +#if SCRIPT_ENGINE_TYPE != SCRIPT_ENGINE_SM +static const char* BYTE_CODE_FILE_EXT = ".jsc"; + static std::string removeFileExt(const std::string& filePath) { size_t pos = filePath.rfind('.'); @@ -29,35 +30,36 @@ static std::string removeFileExt(const std::string& filePath) } return filePath; } +#endif -bool jsb_run_script(const std::string& filePath) +void jsb_init_file_operation_delegate() { static se::ScriptEngine::FileOperationDelegate delegate; if (!delegate.isValid()) { delegate.onGetDataFromFile = [](const std::string& path, const std::function& readCallback) -> void{ assert(!path.empty()); - + Data fileData; - + #if SCRIPT_ENGINE_TYPE != SCRIPT_ENGINE_SM std::string byteCodePath = removeFileExt(path) + BYTE_CODE_FILE_EXT; if (FileUtils::getInstance()->isFileExist(byteCodePath)) { fileData = FileUtils::getInstance()->getDataFromFile(byteCodePath); - + size_t dataLen = 0; uint8_t* data = xxtea_decrypt((unsigned char*)fileData.getBytes(), (uint32_t)fileData.getSize(), (unsigned char*)xxteaKey.c_str(), (uint32_t)xxteaKey.size(), (uint32_t*)&dataLen); - + if (data == nullptr) { SE_REPORT_ERROR("Can't decrypt code for %s", byteCodePath.c_str()); } - + readCallback(data, dataLen); free(data); - + return; } - + #endif fileData = FileUtils::getInstance()->getDataFromFile(path); readCallback(fileData.getBytes(), fileData.getSize()); @@ -65,27 +67,27 @@ bool jsb_run_script(const std::string& filePath) delegate.onGetStringFromFile = [](const std::string& path) -> std::string{ assert(!path.empty()); - + #if SCRIPT_ENGINE_TYPE != SCRIPT_ENGINE_SM std::string byteCodePath = removeFileExt(path) + BYTE_CODE_FILE_EXT; if (FileUtils::getInstance()->isFileExist(byteCodePath)) { Data fileData = FileUtils::getInstance()->getDataFromFile(byteCodePath); - + uint32_t retLength; uint8_t* data = xxtea_decrypt((uint8_t*)fileData.getBytes(), (uint32_t)fileData.getSize(), (uint8_t*)xxteaKey.c_str(), (uint32_t)xxteaKey.size(), &retLength); - + if (data == nullptr) { SE_REPORT_ERROR("Can't decrypt code for %s", byteCodePath.c_str()); return ""; } - + std::string ret(reinterpret_cast(data), retLength); free(data); - + return ret; } #endif - + return FileUtils::getInstance()->getStringFromFile(path); }; @@ -103,7 +105,59 @@ bool jsb_run_script(const std::string& filePath) se::ScriptEngine::getInstance()->setFileOperationDelegate(delegate); } +} +bool jsb_enable_debugger(const std::string& debuggerServerAddr, uint32_t port) +{ + if (debuggerServerAddr.empty() || port == 0) + return false; + + auto se = se::ScriptEngine::getInstance(); + se->enableDebugger(debuggerServerAddr.c_str(), port); + + // For debugger main loop + class SimpleRunLoop + { + public: + void update(float dt) + { + se::ScriptEngine::getInstance()->mainLoopUpdate(); + } + }; + static SimpleRunLoop runLoop; + Director::getInstance()->getScheduler()->scheduleUpdate(&runLoop, 0, false); + return true; +} + +bool jsb_set_extend_property(const char* ns, const char* clsName) +{ + se::Object* globalObj = se::ScriptEngine::getInstance()->getGlobalObject(); + se::Value nsVal; + if (globalObj->getProperty(ns, &nsVal) && nsVal.isObject()) + { + se::Value ccVal; + if (globalObj->getProperty("cc", &ccVal) && ccVal.isObject()) + { + se::Value ccClassVal; + if (ccVal.toObject()->getProperty("Class", &ccClassVal) && ccClassVal.isObject()) + { + se::Value extendVal; + if (ccClassVal.toObject()->getProperty("extend", &extendVal) && extendVal.isObject() && extendVal.toObject()->isFunction()) + { + se::Value targetClsVal; + if (nsVal.toObject()->getProperty(clsName, &targetClsVal) && targetClsVal.isObject()) + { + return targetClsVal.toObject()->setProperty("extend", extendVal); + } + } + } + } + } + return false; +} + +bool jsb_run_script(const std::string& filePath) +{ se::AutoHandleScope hs; return se::ScriptEngine::getInstance()->runScript(filePath); } diff --git a/native/cocos/scripting/js-bindings/manual/jsb_global.h b/native/cocos/scripting/js-bindings/manual/jsb_global.h index 64c8d92c26..0352e84e63 100644 --- a/native/cocos/scripting/js-bindings/manual/jsb_global.h +++ b/native/cocos/scripting/js-bindings/manual/jsb_global.h @@ -12,6 +12,9 @@ extern se::Object* __jsbObj; bool jsb_register_global_variables(se::Object* global); +void jsb_init_file_operation_delegate(); +bool jsb_enable_debugger(const std::string& debuggerServerAddr, uint32_t port); +bool jsb_set_extend_property(const char* ns, const char* clsName); bool jsb_run_script(const std::string& filePath); void jsb_set_xxtea_key(const std::string& key); diff --git a/native/cocos/scripting/js-bindings/manual/jsb_node.cpp b/native/cocos/scripting/js-bindings/manual/jsb_node.cpp index 209d2c7f3f..a5940f37d0 100644 --- a/native/cocos/scripting/js-bindings/manual/jsb_node.cpp +++ b/native/cocos/scripting/js-bindings/manual/jsb_node.cpp @@ -1443,7 +1443,7 @@ static void cleanupAllSchedulesForTarget(Node* node, se::Object* jsThis) node->getScheduler()->unscheduleAllForTarget(jsThis); } -static bool onReceiveNodeEvent(void* node, se::ScriptEngine::NodeEventType type) +static bool onReceiveNodeEvent(void* node, ScriptingCore::NodeEventType type) { auto iter = se::NativePtrToObjectMap::find(node); if (iter == se::NativePtrToObjectMap::end()) @@ -1459,35 +1459,35 @@ static bool onReceiveNodeEvent(void* node, se::ScriptEngine::NodeEventType type) #if SCRIPT_ENGINE_TYPE == SCRIPT_ENGINE_SM JSNative func = nullptr; #endif - if (type == se::ScriptEngine::NodeEventType::ENTER) + if (type == ScriptingCore::NodeEventType::ENTER) { funcName = "onEnter"; #if SCRIPT_ENGINE_TYPE == SCRIPT_ENGINE_SM func = _SE(Node_onEnter); #endif } - else if (type == se::ScriptEngine::NodeEventType::EXIT) + else if (type == ScriptingCore::NodeEventType::EXIT) { funcName = "onExit"; #if SCRIPT_ENGINE_TYPE == SCRIPT_ENGINE_SM func = _SE(Node_onExit); #endif } - else if (type == se::ScriptEngine::NodeEventType::ENTER_TRANSITION_DID_FINISH) + else if (type == ScriptingCore::NodeEventType::ENTER_TRANSITION_DID_FINISH) { funcName = "onEnterTransitionDidFinish"; #if SCRIPT_ENGINE_TYPE == SCRIPT_ENGINE_SM func = _SE(Node_onEnterTransitionDidFinish); #endif } - else if (type == se::ScriptEngine::NodeEventType::EXIT_TRANSITION_DID_START) + else if (type == ScriptingCore::NodeEventType::EXIT_TRANSITION_DID_START) { funcName = "onExitTransitionDidStart"; #if SCRIPT_ENGINE_TYPE == SCRIPT_ENGINE_SM func = _SE(Node_onExitTransitionDidStart); #endif } - else if (type == se::ScriptEngine::NodeEventType::CLEANUP) + else if (type == ScriptingCore::NodeEventType::CLEANUP) { funcName = "cleanup"; #if SCRIPT_ENGINE_TYPE == SCRIPT_ENGINE_SM @@ -1513,15 +1513,15 @@ static bool onReceiveNodeEvent(void* node, se::ScriptEngine::NodeEventType type) } // Handle schedule stuff - if (type == se::ScriptEngine::NodeEventType::ENTER) + if (type == ScriptingCore::NodeEventType::ENTER) { resumeAllSchedulesForTarget((Node*)node, target); } - else if (type == se::ScriptEngine::NodeEventType::EXIT) + else if (type == ScriptingCore::NodeEventType::EXIT) { pauseAllSchedulesForTarget((Node*)node, target); } - else if (type == se::ScriptEngine::NodeEventType::CLEANUP) + else if (type == ScriptingCore::NodeEventType::CLEANUP) { cleanupAllSchedulesForTarget((Node*)node, target); } @@ -1588,7 +1588,7 @@ bool jsb_register_Node_manual(se::Object* global) __jsb_Node_proto->setProperty("var2", se::Value(10000.323)); #endif - se::ScriptEngine::getInstance()->_setNodeEventListener(onReceiveNodeEvent); + ScriptingCore::getInstance()->setNodeEventListener(onReceiveNodeEvent); se::ScriptEngine::getInstance()->clearException(); return true; diff --git a/native/cocos/scripting/js-bindings/proj.android/Android.mk b/native/cocos/scripting/js-bindings/proj.android/Android.mk index 358b160b34..5c8ed051bb 100644 --- a/native/cocos/scripting/js-bindings/proj.android/Android.mk +++ b/native/cocos/scripting/js-bindings/proj.android/Android.mk @@ -92,6 +92,7 @@ LOCAL_EXPORT_LDLIBS := -lz LOCAL_STATIC_LIBRARIES := cocos2dx_static # LOCAL_STATIC_LIBRARIES += spidermonkey_static +LOCAL_STATIC_LIBRARIES += uv_static LOCAL_STATIC_LIBRARIES += v8_static include $(BUILD_STATIC_LIBRARY) diff --git a/native/cocos/scripting/js-bindings/proj.win32/libjscocos2d.vcxproj b/native/cocos/scripting/js-bindings/proj.win32/libjscocos2d.vcxproj index 34bc8ca636..3a1e1231c5 100644 --- a/native/cocos/scripting/js-bindings/proj.win32/libjscocos2d.vcxproj +++ b/native/cocos/scripting/js-bindings/proj.win32/libjscocos2d.vcxproj @@ -195,7 +195,7 @@ Level3 Disabled WIN32;_WINDOWS;HAVE_INSPECTOR;_DEBUG;_LIB;COCOS2D_DEBUG=1;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;_USRJSSTATIC;%(PreprocessorDefinitions) - $(ProjectDir)..;$(EngineRoot);$(EngineRoot)cocos\editor-support;$(ProjectDir)..\auto;$(ProjectDir)..\manual;$(EngineRoot)external\win32\include\spidermonkey;$(EngineRoot)external\win32\include\v8;$(EngineRoot)external\win32\include\uv;%(AdditionalIncludeDirectories) + $(ProjectDir)..;$(EngineRoot);$(EngineRoot)cocos\editor-support;$(ProjectDir)..\auto;$(ProjectDir)..\manual;$(EngineRoot)external\win32\include\v8;$(EngineRoot)external\win32\include\uv;%(AdditionalIncludeDirectories) 4068;4101;4800;4251;4244;4099;4083;4700;%(DisableSpecificWarnings) true false @@ -219,7 +219,7 @@ true true WIN32;_WINDOWS;HAVE_INSPECTOR;NDEBUG;_LIB;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;_USRJSSTATIC;%(PreprocessorDefinitions) - $(ProjectDir)..;$(EngineRoot);$(EngineRoot)cocos\editor-support;$(ProjectDir)..\auto;$(ProjectDir)..\manual;$(EngineRoot)external\win32\include\spidermonkey;$(EngineRoot)external\win32\include\v8;$(EngineRoot)external\win32\include\uv;%(AdditionalIncludeDirectories) + $(ProjectDir)..;$(EngineRoot);$(EngineRoot)cocos\editor-support;$(ProjectDir)..\auto;$(ProjectDir)..\manual;$(EngineRoot)external\win32\include\v8;$(EngineRoot)external\win32\include\uv;%(AdditionalIncludeDirectories) 4068;4101;4800;4251;4244;4099;4083;4700;%(DisableSpecificWarnings) true None diff --git a/native/extensions/anysdk/js-bindings/jsb_anysdk_protocols_auto.cpp b/native/extensions/anysdk/js-bindings/jsb_anysdk_protocols_auto.cpp index 0e443f41a8..ac435dd675 100644 --- a/native/extensions/anysdk/js-bindings/jsb_anysdk_protocols_auto.cpp +++ b/native/extensions/anysdk/js-bindings/jsb_anysdk_protocols_auto.cpp @@ -1,5 +1,6 @@ #include "jsb_anysdk_protocols_auto.hpp" #include "scripting/js-bindings/manual/jsb_conversions.hpp" +#include "scripting/js-bindings/manual/jsb_global.hpp" #include "PluginManager.h" #include "ProtocolAnalytics.h" #include "ProtocolIAP.h" diff --git a/native/extensions/anysdk/platform/ios/appstore/js-bindings/jsb_anysdk_protocols_auto.cpp b/native/extensions/anysdk/platform/ios/appstore/js-bindings/jsb_anysdk_protocols_auto.cpp index 304b730c7c..98ec4e3d52 100644 --- a/native/extensions/anysdk/platform/ios/appstore/js-bindings/jsb_anysdk_protocols_auto.cpp +++ b/native/extensions/anysdk/platform/ios/appstore/js-bindings/jsb_anysdk_protocols_auto.cpp @@ -1,5 +1,6 @@ #include "jsb_anysdk_protocols_auto.hpp" #include "scripting/js-bindings/manual/jsb_conversions.hpp" +#include "scripting/js-bindings/manual/jsb_global.hpp" #include "PluginManager.h" #include "ProtocolAnalytics.h" #include "ProtocolYAP.h" diff --git a/native/external/config.json b/native/external/config.json index c9c2e9fada..e5736e52ec 100644 --- a/native/external/config.json +++ b/native/external/config.json @@ -1,5 +1,5 @@ { - "version": "v3-deps-46", + "version": "v3-deps-47", "zip_file_size": "114318593", "repo_name": "cocos2d-x-lite-external", "repo_parent": "https://github.com/cocos-creator/" diff --git a/native/templates/js-template-binary/frameworks/runtime-src/Classes/AppDelegate.cpp b/native/templates/js-template-binary/frameworks/runtime-src/Classes/AppDelegate.cpp index b15fb9e7d1..7e712e1335 100755 --- a/native/templates/js-template-binary/frameworks/runtime-src/Classes/AppDelegate.cpp +++ b/native/templates/js-template-binary/frameworks/runtime-src/Classes/AppDelegate.cpp @@ -60,6 +60,18 @@ bool AppDelegate::applicationDidFinishLaunching() se::ScriptEngine* se = se::ScriptEngine::getInstance(); + jsb_set_xxtea_key(""); + jsb_init_file_operation_delegate(); + +#if defined(COCOS2D_DEBUG) && (COCOS2D_DEBUG > 0) + jsb_enable_debugger("127.0.0.1", 5086); // Enable debugger here +#endif + + se->setExceptionCallback([](const char* location, const char* message, const char* stack){ + // Send exception information to server like Tencent Bugly. + + }); + jsb_register_all_modules(); #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && PACKAGE_AS @@ -68,24 +80,7 @@ bool AppDelegate::applicationDidFinishLaunching() #endif se->start(); - -#if defined(COCOS2D_DEBUG) && (COCOS2D_DEBUG > 0) - se->enableDebugger(); // Enable debugger here - - class SimpleRunLoop - { - public: - void update(float dt) - { - se::ScriptEngine::getInstance()->mainLoopUpdate(); - } - }; - static SimpleRunLoop runLoop; - director->getScheduler()->scheduleUpdate(&runLoop, 0, false); - -#endif - - jsb_set_xxtea_key(""); + jsb_run_script("main.js"); return true; diff --git a/native/templates/js-template-binary/frameworks/runtime-src/proj.android-studio/app/jni/Application.mk b/native/templates/js-template-binary/frameworks/runtime-src/proj.android-studio/app/jni/Application.mk index 22933f3d45..3059fd0da8 100755 --- a/native/templates/js-template-binary/frameworks/runtime-src/proj.android-studio/app/jni/Application.mk +++ b/native/templates/js-template-binary/frameworks/runtime-src/proj.android-studio/app/jni/Application.mk @@ -18,9 +18,11 @@ endif ifeq ($(NDK_DEBUG),1) APP_CPPFLAGS += -DCOCOS2D_DEBUG=1 + APP_CFLAGS += -DCOCOS2D_DEBUG=1 APP_OPTIM := debug else APP_CPPFLAGS += -DNDEBUG + APP_CFLAGS += -DNDEBUG APP_OPTIM := release endif diff --git a/native/templates/js-template-binary/frameworks/runtime-src/proj.android/jni/Application.mk b/native/templates/js-template-binary/frameworks/runtime-src/proj.android/jni/Application.mk index 22933f3d45..3059fd0da8 100755 --- a/native/templates/js-template-binary/frameworks/runtime-src/proj.android/jni/Application.mk +++ b/native/templates/js-template-binary/frameworks/runtime-src/proj.android/jni/Application.mk @@ -18,9 +18,11 @@ endif ifeq ($(NDK_DEBUG),1) APP_CPPFLAGS += -DCOCOS2D_DEBUG=1 + APP_CFLAGS += -DCOCOS2D_DEBUG=1 APP_OPTIM := debug else APP_CPPFLAGS += -DNDEBUG + APP_CFLAGS += -DNDEBUG APP_OPTIM := release endif diff --git a/native/templates/js-template-binary/frameworks/runtime-src/proj.win32/HelloJavascript.vcxproj b/native/templates/js-template-binary/frameworks/runtime-src/proj.win32/HelloJavascript.vcxproj index c4e29c233c..e65091c34e 100755 --- a/native/templates/js-template-binary/frameworks/runtime-src/proj.win32/HelloJavascript.vcxproj +++ b/native/templates/js-template-binary/frameworks/runtime-src/proj.win32/HelloJavascript.vcxproj @@ -91,7 +91,7 @@ Disabled - $(ProjectDir)..\Classes;$(ProjectDir)..\Classes\service;$(COCOS_X_ROOT)\tools\simulator\libsimulator\lib\runtime;$(COCOS_X_ROOT)\tools\simulator\libsimulator\lib\protobuf-lite;$(COCOS_X_ROOT)\external\win32-specific\zlib\include;$(COCOS_X_ROOT)\tools\simulator\libsimulator\proj.win32;$(COCOS_X_ROOT)\tools\simulator\libsimulator\lib;$(COCOS_X_ROOT)\;$(COCOS_X_ROOT)\cocos;$(COCOS_X_ROOT)\cocos\base;$(COCOS_X_ROOT)\external;$(COCOS_X_ROOT)\cocos\storage;$(COCOS_X_ROOT)\cocos\editor-support;$(COCOS_X_ROOT)\cocos\scripting\js-bindings\auto;$(COCOS_X_ROOT)\cocos\scripting\js-bindings\manual;$(COCOS_X_ROOT)\cocos\audio\include;$(COCOS_X_ROOT)\external\win32\include\spidermonkey;$(COCOS_X_ROOT)\external\win32\include\v8;$(COCOS_X_ROOT)\external\win32\include\chipmunk;$(COCOS_X_ROOT)\external\win32\include\curl;$(COCOS_X_ROOT)\external\win32\include\glfw3;$(COCOS_X_ROOT)\extensions;%(AdditionalIncludeDirectories) + $(ProjectDir)..\Classes;$(ProjectDir)..\Classes\service;$(COCOS_X_ROOT)\tools\simulator\libsimulator\lib\runtime;$(COCOS_X_ROOT)\tools\simulator\libsimulator\lib\protobuf-lite;$(COCOS_X_ROOT)\external\win32-specific\zlib\include;$(COCOS_X_ROOT)\tools\simulator\libsimulator\proj.win32;$(COCOS_X_ROOT)\tools\simulator\libsimulator\lib;$(COCOS_X_ROOT)\;$(COCOS_X_ROOT)\cocos;$(COCOS_X_ROOT)\cocos\base;$(COCOS_X_ROOT)\external;$(COCOS_X_ROOT)\cocos\storage;$(COCOS_X_ROOT)\cocos\editor-support;$(COCOS_X_ROOT)\cocos\scripting\js-bindings\auto;$(COCOS_X_ROOT)\cocos\scripting\js-bindings\manual;$(COCOS_X_ROOT)\cocos\audio\include;$(COCOS_X_ROOT)\external\win32\include\v8;$(COCOS_X_ROOT)\external\win32\include\chipmunk;$(COCOS_X_ROOT)\external\win32\include\curl;$(COCOS_X_ROOT)\external\win32\include\glfw3;$(COCOS_X_ROOT)\extensions;%(AdditionalIncludeDirectories) WIN32;_WINDOWS;STRICT;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_DEBUG=1;COCOS2D_JAVASCRIPT=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;GLFW_EXPOSE_NATIVE_WIN32;GLFW_EXPOSE_NATIVE_WGL;_USRJSSTATIC;_USRLIBSIMSTATIC;%(PreprocessorDefinitions) false EnableFastChecks @@ -116,7 +116,7 @@ xcopy /Y /Q "$(COCOS_X_ROOT)\prebuilt\win32\*.*" "$(OutDir)" - v8.dll.lib;v8_libbase.dll.lib;v8_libplatform.dll.lib;%(AdditionalDependencies) + v8.dll.lib;v8_libbase.dll.lib;v8_libplatform.dll.lib;libuv.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) libcmt.lib true @@ -162,7 +162,7 @@ copy "$(ProjectDir)..\..\..\project.json" "$(LocalDebuggerWorkingDirectory)" /Y< game_p.c - $(ProjectDir)..\Classes;$(ProjectDir)..\Classes\service;$(COCOS_X_ROOT)\tools\simulator\libsimulator\lib\runtime;$(COCOS_X_ROOT)\tools\simulator\libsimulator\lib\protobuf-lite;$(COCOS_X_ROOT)\external\win32-specific\zlib\include;$(COCOS_X_ROOT)\tools\simulator\libsimulator\proj.win32;$(COCOS_X_ROOT)\tools\simulator\libsimulator\lib;$(COCOS_X_ROOT)\;$(COCOS_X_ROOT)\cocos;$(COCOS_X_ROOT)\cocos\base;$(COCOS_X_ROOT)\external;$(COCOS_X_ROOT)\cocos\storage;$(COCOS_X_ROOT)\cocos\editor-support;$(COCOS_X_ROOT)\cocos\scripting\js-bindings\auto;$(COCOS_X_ROOT)\cocos\scripting\js-bindings\manual;$(COCOS_X_ROOT)\cocos\audio\include;$(COCOS_X_ROOT)\external\win32\include\spidermonkey;$(COCOS_X_ROOT)\external\win32\include\v8;$(COCOS_X_ROOT)\external\win32\include\chipmunk;$(COCOS_X_ROOT)\external\win32\include\glfw3;$(COCOS_X_ROOT)\external\win32\include\curl;$(COCOS_X_ROOT)\extensions;%(AdditionalIncludeDirectories) + $(ProjectDir)..\Classes;$(ProjectDir)..\Classes\service;$(COCOS_X_ROOT)\tools\simulator\libsimulator\lib\runtime;$(COCOS_X_ROOT)\tools\simulator\libsimulator\lib\protobuf-lite;$(COCOS_X_ROOT)\external\win32-specific\zlib\include;$(COCOS_X_ROOT)\tools\simulator\libsimulator\proj.win32;$(COCOS_X_ROOT)\tools\simulator\libsimulator\lib;$(COCOS_X_ROOT)\;$(COCOS_X_ROOT)\cocos;$(COCOS_X_ROOT)\cocos\base;$(COCOS_X_ROOT)\external;$(COCOS_X_ROOT)\cocos\storage;$(COCOS_X_ROOT)\cocos\editor-support;$(COCOS_X_ROOT)\cocos\scripting\js-bindings\auto;$(COCOS_X_ROOT)\cocos\scripting\js-bindings\manual;$(COCOS_X_ROOT)\cocos\audio\include;$(COCOS_X_ROOT)\external\win32\include\v8;$(COCOS_X_ROOT)\external\win32\include\chipmunk;$(COCOS_X_ROOT)\external\win32\include\glfw3;$(COCOS_X_ROOT)\external\win32\include\curl;$(COCOS_X_ROOT)\extensions;%(AdditionalIncludeDirectories) WIN32;_WINDOWS;STRICT;NDEBUG;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;GLFW_EXPOSE_NATIVE_WIN32;GLFW_EXPOSE_NATIVE_WGL;_USRJSSTATIC;_USRLIBSIMSTATIC;%(PreprocessorDefinitions) @@ -187,7 +187,7 @@ xcopy /Y /Q "$(COCOS_X_ROOT)\prebuilt\win32\*.*" "$(OutDir)" - v8.dll.lib;v8_libbase.dll.lib;v8_libplatform.dll.lib;%(AdditionalDependencies) + v8.dll.lib;v8_libbase.dll.lib;v8_libplatform.dll.lib;libuv.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) libcmt.lib Windows diff --git a/native/templates/js-template-default/frameworks/runtime-src/Classes/AppDelegate.cpp b/native/templates/js-template-default/frameworks/runtime-src/Classes/AppDelegate.cpp index b15fb9e7d1..58afe2a0ed 100755 --- a/native/templates/js-template-default/frameworks/runtime-src/Classes/AppDelegate.cpp +++ b/native/templates/js-template-default/frameworks/runtime-src/Classes/AppDelegate.cpp @@ -60,6 +60,20 @@ bool AppDelegate::applicationDidFinishLaunching() se::ScriptEngine* se = se::ScriptEngine::getInstance(); + jsb_set_xxtea_key(""); + jsb_init_file_operation_delegate(); + +#if defined(COCOS2D_DEBUG) && (COCOS2D_DEBUG > 0) + // Enable debugger here + // Change IP while remote debugging on Android device. + jsb_enable_debugger("127.0.0.1", 5086); +#endif + + se->setExceptionCallback([](const char* location, const char* message, const char* stack){ + // Send exception information to server like Tencent Bugly. + + }); + jsb_register_all_modules(); #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && PACKAGE_AS @@ -69,23 +83,6 @@ bool AppDelegate::applicationDidFinishLaunching() se->start(); -#if defined(COCOS2D_DEBUG) && (COCOS2D_DEBUG > 0) - se->enableDebugger(); // Enable debugger here - - class SimpleRunLoop - { - public: - void update(float dt) - { - se::ScriptEngine::getInstance()->mainLoopUpdate(); - } - }; - static SimpleRunLoop runLoop; - director->getScheduler()->scheduleUpdate(&runLoop, 0, false); - -#endif - - jsb_set_xxtea_key(""); jsb_run_script("main.js"); return true; diff --git a/native/templates/js-template-default/frameworks/runtime-src/proj.android-studio/app/jni/Application.mk b/native/templates/js-template-default/frameworks/runtime-src/proj.android-studio/app/jni/Application.mk index 866d525d31..ca7481714b 100755 --- a/native/templates/js-template-default/frameworks/runtime-src/proj.android-studio/app/jni/Application.mk +++ b/native/templates/js-template-default/frameworks/runtime-src/proj.android-studio/app/jni/Application.mk @@ -18,8 +18,10 @@ endif ifeq ($(NDK_DEBUG),1) APP_CPPFLAGS += -DCOCOS2D_DEBUG=1 + APP_CFLAGS += -DCOCOS2D_DEBUG=1 APP_OPTIM := debug else APP_CPPFLAGS += -DNDEBUG + APP_CFLAGS += -DNDEBUG APP_OPTIM := release endif diff --git a/native/templates/js-template-default/frameworks/runtime-src/proj.android/jni/Application.mk b/native/templates/js-template-default/frameworks/runtime-src/proj.android/jni/Application.mk index 866d525d31..ca7481714b 100755 --- a/native/templates/js-template-default/frameworks/runtime-src/proj.android/jni/Application.mk +++ b/native/templates/js-template-default/frameworks/runtime-src/proj.android/jni/Application.mk @@ -18,8 +18,10 @@ endif ifeq ($(NDK_DEBUG),1) APP_CPPFLAGS += -DCOCOS2D_DEBUG=1 + APP_CFLAGS += -DCOCOS2D_DEBUG=1 APP_OPTIM := debug else APP_CPPFLAGS += -DNDEBUG + APP_CFLAGS += -DNDEBUG APP_OPTIM := release endif diff --git a/native/templates/js-template-default/frameworks/runtime-src/proj.win32/HelloJavascript.vcxproj b/native/templates/js-template-default/frameworks/runtime-src/proj.win32/HelloJavascript.vcxproj index 68b652b881..a7b69b249b 100755 --- a/native/templates/js-template-default/frameworks/runtime-src/proj.win32/HelloJavascript.vcxproj +++ b/native/templates/js-template-default/frameworks/runtime-src/proj.win32/HelloJavascript.vcxproj @@ -85,7 +85,7 @@ Disabled - $(ProjectDir)..\Classes;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\base;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\scripting\js-bindings\auto;$(EngineRoot)cocos\scripting\js-bindings\manual;$(EngineRoot)cocos\audio\include;$(EngineRoot)external\win32\include\;$(EngineRoot)external\win32\include\spidermonkey;$(EngineRoot)external\win32\include\v8;$(EngineRoot)external\win32\include\chipmunk;$(EngineRoot)external\win32\include\glfw3;$(EngineRoot)extensions;%(AdditionalIncludeDirectories) + $(ProjectDir)..\Classes;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\base;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\scripting\js-bindings\auto;$(EngineRoot)cocos\scripting\js-bindings\manual;$(EngineRoot)cocos\audio\include;$(EngineRoot)external\win32\include\;$(EngineRoot)external\win32\include\v8;$(EngineRoot)external\win32\include\chipmunk;$(EngineRoot)external\win32\include\glfw3;$(EngineRoot)extensions;%(AdditionalIncludeDirectories) WIN32;_WINDOWS;STRICT;_DEBUG;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_DEBUG=1;COCOS2D_JAVASCRIPT=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;_USRJSSTATIC;_USRLIBSIMSTATIC;%(PreprocessorDefinitions) false EnableFastChecks @@ -107,7 +107,7 @@ - v8.dll.lib;v8_libbase.dll.lib;v8_libplatform.dll.lib;%(AdditionalDependencies) + v8.dll.lib;v8_libbase.dll.lib;v8_libplatform.dll.lib;libuv.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) true Windows @@ -147,7 +147,7 @@ copy "$(ProjectDir)..\..\..\project.json" "$(OutDir)\" /Y game_p.c - $(ProjectDir)..\Classes;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\base;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\scripting\js-bindings\auto;$(EngineRoot)cocos\scripting\js-bindings\manual;$(EngineRoot)cocos\audio\include;$(EngineRoot)external\win32\include\spidermonkey;$(EngineRoot)external\win32\include\v8;$(EngineRoot)external\win32\include\chipmunk;$(EngineRoot)external\win32\include;$(EngineRoot)extensions;%(AdditionalIncludeDirectories) + $(ProjectDir)..\Classes;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\base;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\scripting\js-bindings\auto;$(EngineRoot)cocos\scripting\js-bindings\manual;$(EngineRoot)cocos\audio\include;$(EngineRoot)external\win32\include\v8;$(EngineRoot)external\win32\include\chipmunk;$(EngineRoot)external\win32\include;$(EngineRoot)extensions;%(AdditionalIncludeDirectories) WIN32;_WINDOWS;STRICT;NDEBUG;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;_USRJSSTATIC;_USRLIBSIMSTATIC;%(PreprocessorDefinitions) @@ -170,7 +170,7 @@ copy "$(ProjectDir)..\..\..\project.json" "$(OutDir)\" /Y - v8.dll.lib;v8_libbase.dll.lib;v8_libplatform.dll.lib;%(AdditionalDependencies) + v8.dll.lib;v8_libbase.dll.lib;v8_libplatform.dll.lib;libuv.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) Windows MachineX86 diff --git a/native/templates/js-template-link/frameworks/runtime-src/Classes/AppDelegate.cpp b/native/templates/js-template-link/frameworks/runtime-src/Classes/AppDelegate.cpp index b15fb9e7d1..58afe2a0ed 100755 --- a/native/templates/js-template-link/frameworks/runtime-src/Classes/AppDelegate.cpp +++ b/native/templates/js-template-link/frameworks/runtime-src/Classes/AppDelegate.cpp @@ -60,6 +60,20 @@ bool AppDelegate::applicationDidFinishLaunching() se::ScriptEngine* se = se::ScriptEngine::getInstance(); + jsb_set_xxtea_key(""); + jsb_init_file_operation_delegate(); + +#if defined(COCOS2D_DEBUG) && (COCOS2D_DEBUG > 0) + // Enable debugger here + // Change IP while remote debugging on Android device. + jsb_enable_debugger("127.0.0.1", 5086); +#endif + + se->setExceptionCallback([](const char* location, const char* message, const char* stack){ + // Send exception information to server like Tencent Bugly. + + }); + jsb_register_all_modules(); #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && PACKAGE_AS @@ -69,23 +83,6 @@ bool AppDelegate::applicationDidFinishLaunching() se->start(); -#if defined(COCOS2D_DEBUG) && (COCOS2D_DEBUG > 0) - se->enableDebugger(); // Enable debugger here - - class SimpleRunLoop - { - public: - void update(float dt) - { - se::ScriptEngine::getInstance()->mainLoopUpdate(); - } - }; - static SimpleRunLoop runLoop; - director->getScheduler()->scheduleUpdate(&runLoop, 0, false); - -#endif - - jsb_set_xxtea_key(""); jsb_run_script("main.js"); return true; diff --git a/native/templates/js-template-link/frameworks/runtime-src/proj.android-studio/app/jni/Application.mk b/native/templates/js-template-link/frameworks/runtime-src/proj.android-studio/app/jni/Application.mk index 866d525d31..ca7481714b 100755 --- a/native/templates/js-template-link/frameworks/runtime-src/proj.android-studio/app/jni/Application.mk +++ b/native/templates/js-template-link/frameworks/runtime-src/proj.android-studio/app/jni/Application.mk @@ -18,8 +18,10 @@ endif ifeq ($(NDK_DEBUG),1) APP_CPPFLAGS += -DCOCOS2D_DEBUG=1 + APP_CFLAGS += -DCOCOS2D_DEBUG=1 APP_OPTIM := debug else APP_CPPFLAGS += -DNDEBUG + APP_CFLAGS += -DNDEBUG APP_OPTIM := release endif diff --git a/native/templates/js-template-link/frameworks/runtime-src/proj.android/jni/Application.mk b/native/templates/js-template-link/frameworks/runtime-src/proj.android/jni/Application.mk index 866d525d31..ca7481714b 100755 --- a/native/templates/js-template-link/frameworks/runtime-src/proj.android/jni/Application.mk +++ b/native/templates/js-template-link/frameworks/runtime-src/proj.android/jni/Application.mk @@ -18,8 +18,10 @@ endif ifeq ($(NDK_DEBUG),1) APP_CPPFLAGS += -DCOCOS2D_DEBUG=1 + APP_CFLAGS += -DCOCOS2D_DEBUG=1 APP_OPTIM := debug else APP_CPPFLAGS += -DNDEBUG + APP_CFLAGS += -DNDEBUG APP_OPTIM := release endif diff --git a/native/templates/js-template-link/frameworks/runtime-src/proj.win32/HelloJavascript.vcxproj b/native/templates/js-template-link/frameworks/runtime-src/proj.win32/HelloJavascript.vcxproj index 03f0b3998b..3c7aa9e8be 100755 --- a/native/templates/js-template-link/frameworks/runtime-src/proj.win32/HelloJavascript.vcxproj +++ b/native/templates/js-template-link/frameworks/runtime-src/proj.win32/HelloJavascript.vcxproj @@ -85,7 +85,7 @@ Disabled - $(ProjectDir)..\Classes;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\base;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\scripting\js-bindings\auto;$(EngineRoot)cocos\scripting\js-bindings\manual;$(EngineRoot)cocos\audio\include;$(EngineRoot)external\win32\include\;$(EngineRoot)external\win32\include\spidermonkey;$(EngineRoot)external\win32\include\v8;$(EngineRoot)external\win32\include\chipmunk;$(EngineRoot)external\win32\include\glfw3;$(EngineRoot)extensions;%(AdditionalIncludeDirectories) + $(ProjectDir)..\Classes;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\base;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\scripting\js-bindings\auto;$(EngineRoot)cocos\scripting\js-bindings\manual;$(EngineRoot)cocos\audio\include;$(EngineRoot)external\win32\include\;$(EngineRoot)external\win32\include\v8;$(EngineRoot)external\win32\include\chipmunk;$(EngineRoot)external\win32\include\glfw3;$(EngineRoot)extensions;%(AdditionalIncludeDirectories) WIN32;_WINDOWS;STRICT;_DEBUG;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_DEBUG=1;COCOS2D_JAVASCRIPT=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;_USRJSSTATIC;_USRLIBSIMSTATIC;%(PreprocessorDefinitions) false EnableFastChecks @@ -107,7 +107,7 @@ - v8.dll.lib;v8_libbase.dll.lib;v8_libplatform.dll.lib;%(AdditionalDependencies) + v8.dll.lib;v8_libbase.dll.lib;v8_libplatform.dll.lib;libuv.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) true Windows @@ -147,7 +147,7 @@ copy "$(ProjectDir)..\..\..\project.json" "$(OutDir)\" /Y game_p.c - $(ProjectDir)..\Classes;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\base;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\scripting\js-bindings\auto;$(EngineRoot)cocos\scripting\js-bindings\manual;$(EngineRoot)cocos\audio\include;$(EngineRoot)external\win32\include\spidermonkey;$(EngineRoot)external\win32\include\v8;$(EngineRoot)external\win32\include\chipmunk;$(EngineRoot)external\win32\include;$(EngineRoot)extensions;%(AdditionalIncludeDirectories) + $(ProjectDir)..\Classes;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\base;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\scripting\js-bindings\auto;$(EngineRoot)cocos\scripting\js-bindings\manual;$(EngineRoot)cocos\audio\include;$(EngineRoot)external\win32\include\v8;$(EngineRoot)external\win32\include\chipmunk;$(EngineRoot)external\win32\include;$(EngineRoot)extensions;%(AdditionalIncludeDirectories) WIN32;_WINDOWS;STRICT;NDEBUG;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;_USRJSSTATIC;_USRLIBSIMSTATIC;%(PreprocessorDefinitions) @@ -170,7 +170,7 @@ copy "$(ProjectDir)..\..\..\project.json" "$(OutDir)\" /Y - v8.dll.lib;v8_libbase.dll.lib;v8_libplatform.dll.lib;%(AdditionalDependencies) + v8.dll.lib;v8_libbase.dll.lib;v8_libplatform.dll.lib;libuv.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) Windows MachineX86 diff --git a/native/tools/bindings-generator b/native/tools/bindings-generator index d282641f99..d74a80c6e4 160000 --- a/native/tools/bindings-generator +++ b/native/tools/bindings-generator @@ -1 +1 @@ -Subproject commit d282641f99fac97c81cc4fdb9617062a41827fbc +Subproject commit d74a80c6e4c05fb58c6e07fd78a87d0113b493bd diff --git a/native/tools/cocos2d-console b/native/tools/cocos2d-console index c4118fc5e7..eb9f5af3eb 160000 --- a/native/tools/cocos2d-console +++ b/native/tools/cocos2d-console @@ -1 +1 @@ -Subproject commit c4118fc5e73152edb0f75c406d3d97dbe1166481 +Subproject commit eb9f5af3eb4c2ea0a84b42246becbd6334f6c7c1 diff --git a/native/tools/simulator/frameworks/runtime-src/Classes/ide-support/RuntimeJsImpl.cpp b/native/tools/simulator/frameworks/runtime-src/Classes/ide-support/RuntimeJsImpl.cpp index ecb88c1be6..bde6a8b0d2 100755 --- a/native/tools/simulator/frameworks/runtime-src/Classes/ide-support/RuntimeJsImpl.cpp +++ b/native/tools/simulator/frameworks/runtime-src/Classes/ide-support/RuntimeJsImpl.cpp @@ -22,8 +22,6 @@ #include "scripting/js-bindings/manual/jsb_module_register.hpp" #include "scripting/js-bindings/manual/jsb_global.h" -static const char *RUNTIME_JS_BOOT_SCRIPT = "script/jsb_boot.js"; - static bool reloadScript(const string& file) { auto director = cocos2d::Director::getInstance(); @@ -155,10 +153,25 @@ bool RuntimeJsImpl::initJsEnv() cocos2d::ScriptEngineProtocol *engine = ScriptingCore::getInstance(); cocos2d::ScriptEngineManager::getInstance()->setScriptEngine(engine); + auto se = se::ScriptEngine::getInstance(); + jsb_set_xxtea_key(""); + jsb_init_file_operation_delegate(); + +#if defined(COCOS2D_DEBUG) && (COCOS2D_DEBUG > 0) + // Enable debugger here + // Change IP while remote debugging on Android device. + jsb_enable_debugger("127.0.0.1", 5086); +#endif + + se->setExceptionCallback([](const char* location, const char* message, const char* stack){ + // Send exception information to server like Tencent Bugly. + + }); + jsb_register_all_modules(); - se::ScriptEngine::getInstance()->addRegisterCallback(register_FileUtils); - se::ScriptEngine::getInstance()->start(); + se->addRegisterCallback(register_FileUtils); + se->start(); return true; } diff --git a/native/tools/simulator/frameworks/runtime-src/proj.ios_mac/mac/Simulator.entitlements b/native/tools/simulator/frameworks/runtime-src/proj.ios_mac/mac/Simulator.entitlements new file mode 100644 index 0000000000..3842541b7b --- /dev/null +++ b/native/tools/simulator/frameworks/runtime-src/proj.ios_mac/mac/Simulator.entitlements @@ -0,0 +1,8 @@ + + + + + com.apple.security.get-task-allow + + + diff --git a/native/tools/simulator/frameworks/runtime-src/proj.ios_mac/simulator.xcodeproj/project.pbxproj b/native/tools/simulator/frameworks/runtime-src/proj.ios_mac/simulator.xcodeproj/project.pbxproj index 1d97910a60..a4b0349f29 100755 --- a/native/tools/simulator/frameworks/runtime-src/proj.ios_mac/simulator.xcodeproj/project.pbxproj +++ b/native/tools/simulator/frameworks/runtime-src/proj.ios_mac/simulator.xcodeproj/project.pbxproj @@ -177,6 +177,7 @@ 1A16779E1F540F7C00294BB1 /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; }; 1A1677BB1F54218800294BB1 /* CFNetwork.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CFNetwork.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.3.sdk/System/Library/Frameworks/CFNetwork.framework; sourceTree = DEVELOPER_DIR; }; 1A1677BD1F54219E00294BB1 /* libicucore.A.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libicucore.A.tbd; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.3.sdk/usr/lib/libicucore.A.tbd; sourceTree = DEVELOPER_DIR; }; + 1A719F531F8CB0480022549D /* Simulator.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Simulator.entitlements; sourceTree = ""; }; 1AF4C402178663F200122817 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; }; 3EB51526195187AF006966AA /* CFNetwork.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CFNetwork.framework; path = System/Library/Frameworks/CFNetwork.framework; sourceTree = SDKROOT; }; 3EEEDB60197107C0006A9FF8 /* MediaPlayer.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MediaPlayer.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk/System/Library/Frameworks/MediaPlayer.framework; sourceTree = DEVELOPER_DIR; }; @@ -340,6 +341,7 @@ 5023817117EBBE3400990C9B /* mac */ = { isa = PBXGroup; children = ( + 1A719F531F8CB0480022549D /* Simulator.entitlements */, DA9648A01A70F925001F41E8 /* ConsoleWindow.xib */, 9FD6FC701A5D2A820028EDC6 /* ConsoleWindowController.h */, 9FD6FC711A5D2A820028EDC6 /* ConsoleWindowController.m */, @@ -741,6 +743,7 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; ARCHS = "$(ARCHS_STANDARD_64_BIT)"; + CODE_SIGN_ENTITLEMENTS = mac/Simulator.entitlements; COMBINE_HIDPI_IMAGES = YES; CONFIGURATION_BUILD_DIR = ../../../../../simulator/mac; GCC_DYNAMIC_NO_PIC = NO; @@ -778,6 +781,7 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; ARCHS = "$(ARCHS_STANDARD_64_BIT)"; + CODE_SIGN_ENTITLEMENTS = mac/Simulator.entitlements; COMBINE_HIDPI_IMAGES = YES; CONFIGURATION_BUILD_DIR = ../../../../../simulator/mac; GCC_PRECOMPILE_PREFIX_HEADER = YES; diff --git a/native/tools/simulator/frameworks/runtime-src/proj.win32/simulator.vcxproj b/native/tools/simulator/frameworks/runtime-src/proj.win32/simulator.vcxproj index a58592915a..da72937821 100755 --- a/native/tools/simulator/frameworks/runtime-src/proj.win32/simulator.vcxproj +++ b/native/tools/simulator/frameworks/runtime-src/proj.win32/simulator.vcxproj @@ -73,7 +73,7 @@ - $(ProjectDir)..\Classes;$(ProjectDir)..\Classes\runtime;$(ProjectDir)..\Classes\ide-support;$(EngineRoot)cocos\base;$(EngineRoot)external\win32-specific\zlib\include;$(EngineRoot)cocos\scripting\js-bindings\auto;$(EngineRoot)cocos\scripting\js-bindings\manual;$(EngineRoot)cocos\audio\include;$(EngineRoot)external;$(EngineRoot)external\win32\include;$(EngineRoot)external\win32\include\chipmunk;$(EngineRoot)external\win32\include\curl;$(EngineRoot)external\win32\include\glfw3;$(EngineRoot)external\win32\include\spidermonkey;$(EngineRoot)external\win32\include\v8;$(EngineRoot)tools\simulator\libsimulator\lib;$(EngineRoot)tools\simulator\libsimulator\lib\protobuf-lite;$(EngineRoot)extensions;$(EngineRoot);%(AdditionalIncludeDirectories) + $(ProjectDir)..\Classes;$(ProjectDir)..\Classes\runtime;$(ProjectDir)..\Classes\ide-support;$(EngineRoot)cocos\base;$(EngineRoot)external\win32-specific\zlib\include;$(EngineRoot)cocos\scripting\js-bindings\auto;$(EngineRoot)cocos\scripting\js-bindings\manual;$(EngineRoot)cocos\audio\include;$(EngineRoot)external;$(EngineRoot)external\win32\include;$(EngineRoot)external\win32\include\chipmunk;$(EngineRoot)external\win32\include\curl;$(EngineRoot)external\win32\include\glfw3;$(EngineRoot)external\win32\include\v8;$(EngineRoot)tools\simulator\libsimulator\lib;$(EngineRoot)tools\simulator\libsimulator\lib\protobuf-lite;$(EngineRoot)extensions;$(EngineRoot);%(AdditionalIncludeDirectories) NotUsing Level3 MultiThreadedDebugDLL @@ -93,7 +93,7 @@ MachineX86 true $(OutDir);$(EngineRoot)external\win32\libs;%(AdditionalLibraryDirectories) - libcurl.lib;websockets.lib;libSpine.lib;libDragonBones.lib;v8.dll.lib;v8_libbase.dll.lib;v8_libplatform.dll.lib;%(AdditionalDependencies) + libcurl.lib;websockets.lib;libSpine.lib;libDragonBones.lib;v8.dll.lib;v8_libbase.dll.lib;v8_libplatform.dll.lib;libuv.lib;%(AdditionalDependencies) $(OutDir)$(TargetName).pdb $(OutDir)$(TargetName)$(TargetExt) libcmt.lib;%(IgnoreSpecificDefaultLibraries) @@ -116,9 +116,9 @@ - if not exist "$(OutDir)" mkdir "$(OutDir)" - -xcopy /Y /Q "$(ProjectDir)..\Classes\ide-support\lang" "$(OutDir)" + if not exist "$(OutDir)" mkdir "$(OutDir)" + +xcopy /Y /Q "$(ProjectDir)..\Classes\ide-support\lang" "$(OutDir)" @@ -128,22 +128,22 @@ xcopy /Y /Q "$(ProjectDir)..\Classes\ide-support\lang" "$(OutDir)" - if not exist "$(ProjectDir)..\..\..\runtime" mkdir "$(ProjectDir)..\..\..\runtime" - -if not exist "$(ProjectDir)..\..\..\runtime\win32" mkdir "$(ProjectDir)..\..\..\runtime\win32" - -xcopy /Y /Q "$(OutDir)*.dll" "$(ProjectDir)..\..\..\runtime\win32" -xcopy /Y /Q "$(OutDir)*.exe" "$(ProjectDir)..\..\..\runtime\win32" -xcopy /Y /Q "$(OutDir)lang" "$(ProjectDir)..\..\..\runtime\win32" - - -if exist "$(ProjectDir)..\..\..\..\..\simulator\win32\config.json" copy "$(ProjectDir)..\..\..\..\..\simulator\win32\config.json" "$(OutDir)config.json" + if not exist "$(ProjectDir)..\..\..\runtime" mkdir "$(ProjectDir)..\..\..\runtime" + +if not exist "$(ProjectDir)..\..\..\runtime\win32" mkdir "$(ProjectDir)..\..\..\runtime\win32" + +xcopy /Y /Q "$(OutDir)*.dll" "$(ProjectDir)..\..\..\runtime\win32" +xcopy /Y /Q "$(OutDir)*.exe" "$(ProjectDir)..\..\..\runtime\win32" +xcopy /Y /Q "$(OutDir)lang" "$(ProjectDir)..\..\..\runtime\win32" + + +if exist "$(ProjectDir)..\..\..\..\..\simulator\win32\config.json" copy "$(ProjectDir)..\..\..\..\..\simulator\win32\config.json" "$(OutDir)config.json" - $(ProjectDir)..\Classes;$(ProjectDir)..\Classes\runtime;$(ProjectDir)..\Classes\ide-support;$(EngineRoot)cocos\base;$(EngineRoot)tools\simulator\libsimulator\lib\protobuf-lite;$(EngineRoot)external\win32-specific\zlib\include;$(EngineRoot)cocos\scripting\lua-bindings\auto;$(EngineRoot)cocos\scripting\lua-bindings\manual;$(EngineRoot)cocos\scripting\js-bindings\auto;$(EngineRoot)cocos\scripting\js-bindings\manual;$(EngineRoot)cocos\audio\include;$(EngineRoot)external;$(EngineRoot)extensions;$(EngineRoot)external\win32\include;$(EngineRoot)external\win32\include\chipmunk;$(EngineRoot)external\win32\include\curl;$(EngineRoot)external\win32\include\glfw3;$(EngineRoot)external\win32\include\spidermonkey;$(EngineRoot)external\win32\include\v8;$(EngineRoot)tools\simulator\libsimulator\lib;$(EngineRoot);%(AdditionalIncludeDirectories) + $(ProjectDir)..\Classes;$(ProjectDir)..\Classes\runtime;$(ProjectDir)..\Classes\ide-support;$(EngineRoot)cocos\base;$(EngineRoot)tools\simulator\libsimulator\lib\protobuf-lite;$(EngineRoot)external\win32-specific\zlib\include;$(EngineRoot)cocos\scripting\lua-bindings\auto;$(EngineRoot)cocos\scripting\lua-bindings\manual;$(EngineRoot)cocos\scripting\js-bindings\auto;$(EngineRoot)cocos\scripting\js-bindings\manual;$(EngineRoot)cocos\audio\include;$(EngineRoot)external;$(EngineRoot)extensions;$(EngineRoot)external\win32\include;$(EngineRoot)external\win32\include\chipmunk;$(EngineRoot)external\win32\include\curl;$(EngineRoot)external\win32\include\glfw3;$(EngineRoot)external\win32\include\v8;$(EngineRoot)tools\simulator\libsimulator\lib;$(EngineRoot);%(AdditionalIncludeDirectories) NotUsing Level3 MultiThreadedDLL @@ -162,7 +162,7 @@ if exist "$(ProjectDir)..\..\..\..\..\simulator\win32\config.json" copy "$(Proje Windows MachineX86 $(OutDir);$(EngineRoot)external\spidermonkey\prebuilt\win32;%(AdditionalLibraryDirectories) - libcurl.lib;websockets.lib;libSpine.lib;libDragonBones.lib;v8.dll.lib;v8_libbase.dll.lib;v8_libplatform.dll.lib;%(AdditionalDependencies) + libcurl.lib;websockets.lib;libSpine.lib;libDragonBones.lib;v8.dll.lib;v8_libbase.dll.lib;v8_libplatform.dll.lib;libuv.lib;%(AdditionalDependencies) false $(OutDir)$(ProjectName).exe libcmt.lib;%(IgnoreSpecificDefaultLibraries) @@ -185,9 +185,9 @@ if exist "$(ProjectDir)..\..\..\..\..\simulator\win32\config.json" copy "$(Proje - if not exist "$(OutDir)" mkdir "$(OutDir)" - -xcopy /Y /Q "$(ProjectDir)..\Classes\ide-support\lang" "$(OutDir)" + if not exist "$(OutDir)" mkdir "$(OutDir)" + +xcopy /Y /Q "$(ProjectDir)..\Classes\ide-support\lang" "$(OutDir)" @@ -197,13 +197,13 @@ xcopy /Y /Q "$(ProjectDir)..\Classes\ide-support\lang" "$(OutDir)" - if not exist "$(ProjectDir)..\..\..\runtime" mkdir "$(ProjectDir)..\..\..\runtime" - -if not exist "$(ProjectDir)..\..\..\runtime\win32" mkdir "$(ProjectDir)..\..\..\runtime\win32" - -xcopy /Y /Q "$(OutDir)*.dll" "$(ProjectDir)..\..\..\runtime\win32" -xcopy /Y /Q "$(OutDir)*.exe" "$(ProjectDir)..\..\..\runtime\win32" -xcopy /Y /Q "$(OutDir)lang" "$(ProjectDir)..\..\..\runtime\win32" + if not exist "$(ProjectDir)..\..\..\runtime" mkdir "$(ProjectDir)..\..\..\runtime" + +if not exist "$(ProjectDir)..\..\..\runtime\win32" mkdir "$(ProjectDir)..\..\..\runtime\win32" + +xcopy /Y /Q "$(OutDir)*.dll" "$(ProjectDir)..\..\..\runtime\win32" +xcopy /Y /Q "$(OutDir)*.exe" "$(ProjectDir)..\..\..\runtime\win32" +xcopy /Y /Q "$(OutDir)lang" "$(ProjectDir)..\..\..\runtime\win32"