Merge commit 'aade73a2f487510ff2f6138e8336d1f76b264ab7' into develop

This commit is contained in:
Jare Guo
2017-10-11 14:48:16 +08:00
23 changed files with 130 additions and 66 deletions
+3
View File
@@ -10,6 +10,9 @@ Thumbs.db
/prebuilt_mk*.zip
/simulator.json
# Ignore xcodeproj for backup
/simulator.xcodeproj
# Ignore files build by Visual Studio
*.obj
*.exe
+1 -1
View File
@@ -31,7 +31,7 @@ NS_CC_BEGIN
CC_DLL const char* cocos2dVersion()
{
return "1.6.2";
return "1.7.0";
}
NS_CC_END
@@ -835,7 +835,7 @@ classes_owned_by_cpp =
#### Windows
* 运行游戏
* 编译、运行游戏(或在Creator中直接使用模拟器运行)
* 用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)
断点调试:
@@ -849,7 +849,8 @@ Profile
#### Android
* 运行游戏
* 保证Android设备与PC或者Mac在同一个局域网中
* 编译,运行游戏
* 用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相同
@@ -861,16 +862,25 @@ Profile
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)
4. 编译、运行游戏
5. 如果是直接在Creator的模拟器中运行,则可以跳过第2,3,4步骤
6. Safari菜单中选择Develop -> 你的Mac设备名称 -> Cocos2d-x JSB 会自动打开Web Inspector页面,然后即可进行设置断点、Timeline profile、console等操作。![](jsc-mac-debug.png) ![](jsc-breakpoint.png) ![](jsc-timeline.png)
**注意**
如果开发者有修改引擎源码或者自己合并了一些Patch,需要重新编译模拟器,记得重新设置一下模拟器工程的证书。
![](jsc-mac-simulator-sign.png)
然后再调用`gulp gen-simulator`生成模拟器。
#### 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步类似)
4. 编译、运行游戏
5. Safari菜单中选择Develop -> 你的iPhone设备名称 -> Cocos2d-x JSB 会自动打开Web Inspector页面,然后即可进行设置断点、Timeline profile、console等操作。(图示与macOS的第6步类似)
## Q & A
@@ -947,9 +957,9 @@ SE_BIND_FINALIZE_FUNC(js_cocos2d_Sprite_finalize)
```c++
bool AppDelegate::applicationDidFinishLaunching()
{
...
...
se::ScriptEngine* se = se::ScriptEngine::getInstance();
...
...
se::ScriptEngine* se = se::ScriptEngine::getInstance();
se->setExceptionCallback([](const char* location, const char* message, const char* stack){
// Send exception information to server like Tencent Bugly.
@@ -958,9 +968,9 @@ bool AppDelegate::applicationDidFinishLaunching()
});
jsb_register_all_modules();
...
...
return true;
...
...
return true;
}
```
Binary file not shown.

After

Width:  |  Height:  |  Size: 110 KiB

@@ -11,7 +11,7 @@
#elif defined(ANDROID) || (defined(_WIN32) && defined(_WINDOWS)) // Windows and Android use V8
#define SCRIPT_ENGINE_TYPE SCRIPT_ENGINE_V8
#else
#define SCRIPT_ENGINE_TYPE SCRIPT_ENGINE_NONE
#error "Unknown Script Engine"
#endif
#if defined(COCOS2D_DEBUG) && COCOS2D_DEBUG > 0
@@ -62,7 +62,7 @@ static bool js_PlistParser_getInstance(se::State& s)
SAXParser* parser = delegator->getParser();
if (parser) {
native_ptr_to_seval<SAXParser>(parser, __jsb_cocos2d_SAXParser_class, &s.rval());
native_ptr_to_rooted_seval<SAXParser>(parser, __jsb_cocos2d_SAXParser_class, &s.rval());
return true;
}
return false;
@@ -136,7 +136,7 @@ bool seval_to_Vector(const se::Value& v, cocos2d::Vector<T>* ret)
for (uint32_t i = 0; i < len; ++i)
{
ok = obj->getArrayElement(i, &tmp);
if (!ok && tmp.isObject())
if (!ok || !tmp.isObject())
{
ret->clear();
return false;
@@ -150,6 +150,39 @@ bool seval_to_Vector(const se::Value& v, cocos2d::Vector<T>* ret)
return true;
}
template<typename T>
bool seval_to_Map_string_key(const se::Value& v, cocos2d::Map<std::string, T>* ret)
{
assert(ret != nullptr);
assert(v.isObject());
se::Object* obj = v.toObject();
std::vector<std::string> allKeys;
bool ok = obj->getAllKeys(&allKeys);
if (!ok)
{
ret->clear();
return false;
}
se::Value tmp;
for (const auto& key : allKeys)
{
ok = obj->getProperty(key.c_str(), &tmp);
if (!ok || !tmp.isObject())
{
ret->clear();
return false;
}
T nativeObj = (T)tmp.toObject()->getPrivateData();
ret->insert(key, nativeObj);
}
return true;
}
// native value -> se value
bool int8_to_seval(int8_t v, se::Value* ret);
bool uint8_to_seval(uint8_t v, se::Value* ret);
@@ -595,7 +595,10 @@ cc.DrawNode = cc._DrawNode.extend({
cc._DrawNode.prototype.drawDot.call(this, pos, radius, color);
},
drawSegment:function (from, to, lineWidth = this._lineWidth, color = this._drawColor) {
drawSegment:function (from, to, lineWidth, color) {
lineWidth = lineWidth || this._lineWidth;
color = color || this._drawColor;
cc._DrawNode.prototype.drawSegment.call(this, from, to, lineWidth, color);
},
@@ -1107,17 +1110,21 @@ cc.defineGetterSetter(cc.BlendFunc, "ALPHA_NON_PREMULTIPLIED", cc.BlendFunc._alp
cc.BlendFunc.ADDITIVE;
cc.defineGetterSetter(cc.BlendFunc, "ADDITIVE", cc.BlendFunc._additive);
cc.GLProgram.prototype.setUniformLocationWithMatrix2fv = function (...args) {
args = Array.prototype.concat.call(args, 2);
this.setUniformLocationWithMatrixfvUnion.apply(this, args);
cc.GLProgram.prototype.setUniformLocationWithMatrix2fv = function(){
var tempArray = Array.prototype.slice.call(arguments);
tempArray.push(2);
this.setUniformLocationWithMatrixfvUnion.apply(this, tempArray);
};
cc.GLProgram.prototype.setUniformLocationWithMatrix3fv = function (...args) {
args = Array.prototype.concat.call(args, 3);
this.setUniformLocationWithMatrixfvUnion.apply(this, args);
cc.GLProgram.prototype.setUniformLocationWithMatrix3fv = function(){
var tempArray = Array.prototype.slice.call(arguments);
tempArray.push(3);
this.setUniformLocationWithMatrixfvUnion.apply(this, tempArray);
};
cc.GLProgram.prototype.setUniformLocationWithMatrix4fv = function (...args) {
args = Array.prototype.concat.call(args, 4);
this.setUniformLocationWithMatrixfvUnion.apply(this, args);
cc.GLProgram.prototype.setUniformLocationWithMatrix4fv = function(){
var tempArray = Array.prototype.slice.call(arguments);
tempArray.push(4);
this.setUniformLocationWithMatrixfvUnion.apply(this, tempArray);
};
//
@@ -293,8 +293,8 @@ cc.ActionInterval.prototype._ctor = function(d) {
d !== undefined && this.initWithDuration(d);
};
cc.Sequence.prototype._ctor = function(...args) {
var actions = (args[0] instanceof Array) ? args[0] : args;
cc.Sequence.prototype._ctor = function(tempArray) {
var actions = (tempArray instanceof Array) ? tempArray : arguments;
var last = actions.length - 1;
if ((last >= 0) && (actions[last] == null))
cc.log('parameters should not be ending with null in Javascript');
@@ -309,8 +309,8 @@ cc.Sequence.prototype._ctor = function(...args) {
this.initWithTwoActions(prev, actions[last]);
}
};
cc.sequence = cc.Sequence.create = function (...args) {
var actions = (args[0] instanceof Array) ? args[0] : args;
cc.sequence = cc.Sequence.create = function (tempArray) {
var actions = (tempArray instanceof Array) ? tempArray : arguments;
var last = actions.length - 1;
if ((last >= 0) && (actions[last] == null))
cc.log('parameters should not be ending with null in Javascript');
@@ -343,8 +343,8 @@ cc.repeatForever = cc.RepeatForever.create = function (action) {
return new cc.RepeatForever(action);
};
cc.Spawn.prototype._ctor = function (...args) {
var actions = (args[0] instanceof Array) ? args[0] : args;
cc.Spawn.prototype._ctor = function (tempArray) {
var actions = (tempArray instanceof Array) ? tempArray : arguments;
var last = actions.length - 1;
if ((last >= 0) && (actions[last] == null))
cc.log('parameters should not be ending with null in Javascript');
@@ -359,8 +359,8 @@ cc.Spawn.prototype._ctor = function (...args) {
this.initWithTwoActions(prev, actions[last]);
}
};
cc.spawn = cc.Spawn.create = function (...args) {
var actions = (args[0] instanceof Array) ? args[0] : args;
cc.spawn = cc.Spawn.create = function (tempArray) {
var actions = (tempArray instanceof Array) ? tempArray : arguments;
var last = actions.length - 1;
if ((last >= 0) && (actions[last] == null))
cc.log('parameters should not be ending with null in Javascript');
@@ -353,11 +353,11 @@ gl.getAttachedShaders = function(program) {
// void texImage2D(GLenum target, GLint level, GLenum internalformat, GLenum format, GLenum type, HTMLImageElement image); // May throw DOMException
// void texImage2D(GLenum target, GLint level, GLenum internalformat, GLenum format, GLenum type, HTMLCanvasElement canvas); // May throw DOMException
// void texImage2D(GLenum target, GLint level, GLenum internalformat, GLenum format, GLenum type, HTMLVideoElement video); // May throw DOMException
gl.texImage2D = function (...args) {
if (args.length < 9) {
throw "texImage2D: Unsupported number of parameters:" + args.length;
}
gl._texImage2D.apply(gl, args);
gl.texImage2D = function() {
if( arguments.length < 9)
throw "texImage2D: Unsupported number of parameters:" + arguments.length;
gl._texImage2D.apply(this, arguments);
};
// XXX: Currently only the 1st one is supported
@@ -366,11 +366,11 @@ gl.texImage2D = function (...args) {
// void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLenum format, GLenum type, HTMLImageElement image); // May throw DOMException
// void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLenum format, GLenum type, HTMLCanvasElement canvas); // May throw DOMException
// void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLenum format, GLenum type, HTMLVideoElement video); // May throw DOMException
gl.texSubImage2D = function (...args) {
if (args.length < 9)
throw "texImage2D: Unsupported number of parameters";
gl.texSubImage2D = function() {
if( arguments.length < 9)
throw "texSubImage2D: Unsupported number of parameters:" + arguments.length;
gl._texSubImage2D.apply(gl, args);
gl._texSubImage2D.apply(this, arguments);
};
//
@@ -129,7 +129,7 @@ cc.Class.extend = function (prop) {
prototype[name] = typeof prop[name] == "function" &&
typeof _super[name] == "function" && fnTest.test(prop[name]) ?
(function (name, fn) {
return function (...args) {
return function () {
var tmp = this._super;
// Add a new ._super() method that is the same method
@@ -138,7 +138,7 @@ cc.Class.extend = function (prop) {
// The method only need to be bound temporarily, so we
// remove it when we're done executing
var ret = fn.apply(this, args);
var ret = fn.apply(this, arguments);
this._super = tmp;
return ret;
@@ -147,18 +147,18 @@ cc.Class.extend = function (prop) {
prop[name];
}
Class = function (...args) {
Class = function () {
if (!initializing) {
this.__instanceId = ClassManager.getNewInstanceId();
if (this.ctor) {
switch (args.length) {
switch (arguments.length) {
case 0: this.ctor(); break;
case 1: this.ctor(args[0]); break;
case 2: this.ctor(args[0], args[1]); break;
case 3: this.ctor(args[0], args[1], args[2]); break;
case 4: this.ctor(args[0], args[1], args[2], args[3]); break;
case 5: this.ctor(args[0], args[1], args[2], args[3], args[4]); break;
default: this.ctor.apply(this, args);
case 1: this.ctor(arguments[0]); break;
case 2: this.ctor(arguments[0], arguments[1]); break;
case 3: this.ctor(arguments[0], arguments[1], arguments[2]); break;
case 4: this.ctor(arguments[0], arguments[1], arguments[2], arguments[3]); break;
case 5: this.ctor(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4]); break;
default: this.ctor.apply(this, arguments);
}
}
}
+1 -1
View File
@@ -1,5 +1,5 @@
{
"version": "v3-deps-47",
"version": "v3-deps-48",
"zip_file_size": "114318593",
"repo_name": "cocos2d-x-lite-external",
"repo_parent": "https://github.com/cocos-creator/"
+6
View File
@@ -119,6 +119,10 @@ gulp.task('gen-simulator', function(cb) {
var cocosConsoleBin;
if (process.platform === 'darwin') {
cocosConsoleBin = Path.join(cocosConsoleRoot, 'cocos');
// copy mac xcode project with signing info
if (fs.existsSync('simulator.xcodeproj')) {
fs.copySync('./simulator.xcodeproj', './tools/simulator/frameworks/runtime-src/proj.ios_mac/simulator.xcodeproj');
}
} else {
cocosConsoleBin = Path.join(cocosConsoleRoot, 'cocos.bat');
}
@@ -140,6 +144,8 @@ gulp.task('gen-simulator', function(cb) {
if (code !== 0) {
console.error('Generate simulator failed');
}
//reset project file to hide code sign information.
ExecSync('git checkout -- ./tools/simulator/frameworks/runtime-src/proj.ios_mac/simulator.xcodeproj');
cb();
return;
});
+1
View File
@@ -4726,6 +4726,7 @@
"cocos/scripting/js-bindings/docs/jsc-breakpoint.png",
"cocos/scripting/js-bindings/docs/jsc-entitlements.png",
"cocos/scripting/js-bindings/docs/jsc-mac-debug.png",
"cocos/scripting/js-bindings/docs/jsc-mac-simulator-sign.png",
"cocos/scripting/js-bindings/docs/jsc-security-key.png",
"cocos/scripting/js-bindings/docs/jsc-timeline.png",
"cocos/scripting/js-bindings/docs/v8-win32-debug.jpg",
@@ -64,7 +64,8 @@ bool AppDelegate::applicationDidFinishLaunching()
jsb_init_file_operation_delegate();
#if defined(COCOS2D_DEBUG) && (COCOS2D_DEBUG > 0)
jsb_enable_debugger("127.0.0.1", 5086); // Enable debugger here
// Enable debugger here
jsb_enable_debugger("0.0.0.0", 5086);
#endif
se->setExceptionCallback([](const char* location, const char* message, const char* stack){
@@ -65,8 +65,7 @@ bool AppDelegate::applicationDidFinishLaunching()
#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);
jsb_enable_debugger("0.0.0.0", 5086);
#endif
se->setExceptionCallback([](const char* location, const char* message, const char* stack){
@@ -65,8 +65,7 @@ bool AppDelegate::applicationDidFinishLaunching()
#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);
jsb_enable_debugger("0.0.0.0", 5086);
#endif
se->setExceptionCallback([](const char* location, const char* message, const char* stack){
@@ -8,7 +8,7 @@
#include "cocos/base/CCDirector.h" // 2dx engine
#if (COCOS2D_DEBUG > 0) && (CC_CODE_IDE_DEBUG_SUPPORT > 0)
#if (CC_CODE_IDE_DEBUG_SUPPORT > 0)
#include "runtime/ConfigParser.h" // config
#include "runtime/Runtime.h"
@@ -159,8 +159,7 @@ bool RuntimeJsImpl::initJsEnv()
#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);
jsb_enable_debugger("0.0.0.0", 5086);
#endif
se->setExceptionCallback([](const char* location, const char* message, const char* stack){
@@ -9,7 +9,7 @@
#include "ide-support/CodeIDESupport.h"
#if (COCOS2D_DEBUG > 0) && (CC_CODE_IDE_DEBUG_SUPPORT > 0)
#if (CC_CODE_IDE_DEBUG_SUPPORT > 0)
#include "runtime/RuntimeProtocol.h"
class RuntimeJsImpl : public RuntimeProtocol
@@ -10,11 +10,12 @@ APP_LDFLAGS := -latomic
APP_SHORT_COMMANDS := true
ifeq ($(NDK_DEBUG),1)
APP_CFLAGS += -DCOCOS2D_DEBUG=1
APP_CPPFLAGS += -DCOCOS2D_DEBUG=1
APP_OPTIM := debug
else
APP_CFLAGS += -DNDEBUG
APP_CPPFLAGS += -DNDEBUG
APP_CPPFLAGS += -DCOCOS2D_DEBUG=1
APP_OPTIM := release
endif
@@ -7,11 +7,12 @@ APP_LDFLAGS := -latomic
APP_SHORT_COMMANDS := true
ifeq ($(NDK_DEBUG),1)
APP_CFLAGS += -DCOCOS2D_DEBUG=1
APP_CPPFLAGS += -DCOCOS2D_DEBUG=1
APP_OPTIM := debug
else
APP_CFLAGS += -DNDEBUG
APP_CPPFLAGS += -DNDEBUG
APP_CPPFLAGS += -DCOCOS2D_DEBUG=1
APP_OPTIM := release
endif
@@ -35,7 +35,9 @@ THE SOFTWARE.
#endif
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
#define bzero(a, b) memset(a, 0, b);
#ifndef bzero
#define bzero(a, b) memset(a, 0, b);
#endif
#endif
//1M size
@@ -38,7 +38,9 @@ THE SOFTWARE.
#include <io.h>
#include <WS2tcpip.h>
#ifndef bzero
#define bzero(a, b) memset(a, 0, b);
#endif
#else
#include <netdb.h>