refine code

This commit is contained in:
yinkaile
2017-10-20 09:29:45 +08:00
parent 62841321a5
commit dc7ae7fc8f
4 changed files with 20 additions and 19 deletions
+1 -1
View File
@@ -47,7 +47,7 @@ var supportJit = cc.supportJit;
var callPreload = supportJit ? 'c.__preload();' : function (c) { c.__preload(); }
var callOnLoad = supportJit ? ('c.onLoad();c._objFlags|=' + IsOnLoadCalled) : function (c) {
c.onLoad();
c._objFlags|= IsOnLoadCalled;
c._objFlags |= IsOnLoadCalled;
}
// for __preload: use internally, no sort
+17 -16
View File
@@ -622,34 +622,35 @@ var _createCtor = cc.supportJit ? function (ctors, baseClass, className, options
this.__initProps__(CCClass);
var args = arguments;
var self = this;
function init () {
if (ctorLen === 1) {
CCClass.__ctors__[0].apply(self, args);
}
else {
var cs = CCClass.__ctors__;
for (var i = 0; i < ctorLen; i++) {
cs[i].apply(self, args);;
}
}
}
// call user constructors
var ctorLen = ctors.length;
var cs = CCClass.__ctors__;
if (ctorLen > 0) {
var useTryCatch = ! (className && className.startsWith('cc.'));
if (useTryCatch) {
try {
init();
if (ctorLen === 1) {
cs[0].apply(this, arguments);
}
else {
for (var i = 0; i < ctorLen; i++) {
cs[i].apply(this, arguments);;
}
}
}
catch(e) {
cc._throw(e);
}
}
else {
init();
if (ctorLen === 1) {
cs[0].apply(this, arguments);
}
else {
for (var i = 0; i < ctorLen; i++) {
cs[i].apply(this, arguments);;
}
}
}
}
};
+1 -1
View File
@@ -139,7 +139,7 @@ defineMacro('CC_BUILD', false);
cc = {};
// check whether support jit
cc.supportJit = Function('') !== undefined;
cc.supportJit = typeof Function('') === 'function';
// The namespace for original nodes rendering in scene graph.
_ccsg = {};
+1 -1
View File
@@ -26,7 +26,7 @@
'use strict';
// check whether support jit
cc.supportJit = Function('') !== undefined;
cc.supportJit = typeof Function('') === 'function';
function defineMacro (name, defaultValue) {
// if "global_defs" not preprocessed by uglify, just declare them globally,