mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 08:02:39 +08:00
refine code
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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);;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user