Eliminate cc.* log functions invocation (#6845)

This commit is contained in:
Leslie Leigh (李的序)
2020-06-10 14:19:11 +08:00
committed by GitHub
parent 7b792b42d9
commit adfdb67bb8
37 changed files with 172 additions and 146 deletions
+2 -2
View File
@@ -23,7 +23,7 @@
THE SOFTWARE.
*/
import { legacyCC } from '../global-exports';
import { logID } from '../platform/debug';
export {default as MutableForwardIterator} from './mutable-forward-iterator';
@@ -88,7 +88,7 @@ export function verifyType<T> (array: T[], type: Function) {
if (array && array.length > 0) {
for (const item of array) {
if (!(item instanceof type)) {
legacyCC.logID(1300);
logID(1300);
return false;
}
}
+12 -13
View File
@@ -1,8 +1,7 @@
import { warnID } from '../platform/debug';
import { warnID, error, errorID } from '../platform/debug';
import IDGenerator from './id-generator';
import { EDITOR, DEV, TEST } from 'internal:constants';
import { legacyCC } from '../global-exports';
const tempCIDGenerator = new IDGenerator('TmpCId.');
/**
@@ -308,7 +307,7 @@ export function addon (object?: any, ...sources: any[]) {
for (const source of sources) {
if (source) {
if (typeof source !== 'object') {
legacyCC.errorID(5402, source);
errorID(5402, source);
continue;
}
for (const name in source) {
@@ -330,7 +329,7 @@ export function mixin (object?: any, ...sources: any[]) {
for (const source of sources) {
if (source) {
if (typeof source !== 'object') {
legacyCC.errorID(5403, source);
errorID(5403, source);
continue;
}
for (const name in source) {
@@ -351,15 +350,15 @@ export function mixin (object?: any, ...sources: any[]) {
export function extend (cls: Function, base: Function) {
if (DEV) {
if (!base) {
legacyCC.errorID(5404);
errorID(5404);
return;
}
if (!cls) {
legacyCC.errorID(5405);
errorID(5405);
return;
}
if (Object.keys(cls.prototype).length > 0) {
legacyCC.errorID(5406);
errorID(5406);
}
}
for (const p in base) { if (base.hasOwnProperty(p)) { cls[p] = base[p]; } }
@@ -449,13 +448,13 @@ export function _setClassId (id, constructor) {
if (id) {
const registered = table[id];
if (registered && registered !== constructor) {
let error = 'A Class already exists with the same ' + key + ' : "' + id + '".';
let err = 'A Class already exists with the same ' + key + ' : "' + id + '".';
if (TEST) {
error += ' (This may be caused by error of unit test.) \
err += ' (This may be caused by error of unit test.) \
If you dont need serialization, you can set class id to "". You can also call \
cc.js.unregisterClass to remove the id of unused class';
}
legacyCC.error(error);
error(err);
}
else {
table[id] = constructor;
@@ -478,13 +477,13 @@ function doSetClassName (id, constructor) {
if (id) {
const registered = table[id];
if (registered && registered !== constructor) {
let error = 'A Class already exists with the same ' + key + ' : "' + id + '".';
let err = 'A Class already exists with the same ' + key + ' : "' + id + '".';
if (TEST) {
error += ' (This may be caused by error of unit test.) \
err += ' (This may be caused by error of unit test.) \
If you dont need serialization, you can set class id to "". You can also call \
cc.js.unregisterClass to remove the id of unused class';
}
legacyCC.error(error);
error(err);
}
else {
table[id] = constructor;
+2 -1
View File
@@ -29,6 +29,7 @@
import { getClassName, getset } from './js';
import { EDITOR, DEV } from 'internal:constants';
import { legacyCC } from '../global-exports';
import { warnID } from '../platform/debug';
export const BUILTIN_CLASSID_RE = /^(?:cc|dragonBones|sp|ccsg)\..+/;
@@ -65,7 +66,7 @@ export function propertyDefine (ctor, sameNameGetSets, diffNameGetSets) {
const clsName = (legacyCC.Class._isCCClass(ctor) && getClassName(ctor)) ||
ctor.name ||
'(anonymous class)';
legacyCC.warnID(5700, propName, getter, clsName);
warnID(5700, propName, getter, clsName);
}
else {
getset(np, propName, getterFunc, np[setter]);
+2 -1
View File
@@ -28,6 +28,7 @@ import { ccclass, property } from '../data/class-decorator';
import { Quat } from '../math';
import { EDITOR, SUPPORT_JIT } from 'internal:constants';
import { legacyCC } from '../global-exports';
import { errorID } from '../platform/debug';
@ccclass('cc.PrefabInfo')
export class PrefabInfo {
@@ -88,7 +89,7 @@ export default function syncWithPrefab (node) {
// node.name += PrefabUtils.MISSING_PREFAB_SUFFIX;
}
else {
legacyCC.errorID(3701, node.name);
errorID(3701, node.name);
}
node._prefab = null;
return;