Variables
Const BUILTIN_ENTRIES
BUILTIN_ENTRIES: string[] = ['name', 'extends', 'mixins', 'ctor', '__ctor__', 'properties', 'statics', 'editor', '__ES6__']
Const CACHE_KEY
CACHE_KEY: "__ccclassCache__" = "__ccclassCache__"
Const DEFAULT
DEFAULT: string = Attr.DELIMETER + 'default'
Const DELIMETER
DELIMETER: "$_$" = attributeUtils.DELIMETER
Const Deactivating
Deactivating: number = 1 << 8
Const Destroyed
Destroyed: any = CCObject.Flags.Destroyed
Const Destroyed
Destroyed: any = CCObject.Flags.Destroyed
Const Destroyed
Destroyed: number = 1 << 0
Const Destroying
Destroying: number = 1 << 7
Const Dirty
Dirty: number = 1 << 5
Const DontDestroy
DontDestroy: number = 1 << 6
Const DontSave
DontSave: number = 1 << 3
Const EditorOnly
EditorOnly: number = 1 << 4
Const HideInHierarchy
HideInHierarchy: number = 1 << 10
Const IDENTIFIER_RE
IDENTIFIER_RE: RegExp = /^[A-Za-z_$][0-9A-Za-z_$]*$/
Const IDENTIFIER_RE
IDENTIFIER_RE: RegExp = CCClass.IDENTIFIER_RE
Const INVALID_STATICS_DEV
INVALID_STATICS_DEV: string[] = ['name', '__ctors__', '__props__', 'arguments', 'call', 'apply', 'caller', 'length', 'prototype']
Const IsAnchorLocked
IsAnchorLocked: number = 1 << 19
Const IsEditorOnEnableCalled
IsEditorOnEnableCalled: number = 1 << 12
Const IsOnEnableCalled
IsOnEnableCalled: number = 1 << 11
Const IsOnLoadCalled
IsOnLoadCalled: number = 1 << 14
Const IsOnLoadStarted
IsOnLoadStarted: number = 1 << 15
Const IsPositionLocked
IsPositionLocked: number = 1 << 21
Const IsPreloadStarted
IsPreloadStarted: number = 1 << 13
Const IsRotationLocked
IsRotationLocked: number = 1 << 17
Const IsScaleLocked
IsScaleLocked: number = 1 << 18
Const IsSizeLocked
IsSizeLocked: number = 1 << 20
Const IsStartCalled
IsStartCalled: number = 1 << 16
Const LINE_INDEX_OF_NEW_OBJ
LINE_INDEX_OF_NEW_OBJ: 0 = 0
Const LOCAL_ARRAY
LOCAL_ARRAY: "a" = "a"
Const LOCAL_OBJ
LOCAL_OBJ: "o" = "o"
Const LOCAL_TEMP_OBJ
LOCAL_TEMP_OBJ: "t" = "t"
Const LockedInEditor
LockedInEditor: number = 1 << 9
Const PersistentMask
PersistentMask: any = CCObject.Flags.PersistentMask
Const PersistentMask
PersistentMask: number = ~(ToDestroy | Dirty | Destroying | DontDestroy | Deactivating |IsPreloadStarted | IsOnLoadStarted | IsOnLoadCalled | IsStartCalled |IsOnEnableCalled | IsEditorOnEnableCalled |IsRotationLocked | IsScaleLocked | IsAnchorLocked | IsSizeLocked | IsPositionLocked/*RegisteredInEditor*/)
Const PersistentMask
PersistentMask: any = CCObject.Flags.PersistentMask
Const RealDestroyed
RealDestroyed: number = 1 << 1
Const SuperCallReg
SuperCallReg: RegExp = superCllRegCondition ? /\b\._super\b/ : /.*/
Const SuperCallRegStrict
SuperCallRegStrict: RegExp = superCllRegCondition ? /this\._super\s*\(/ : /(NONE){99}/
Const ToDestroy
ToDestroy: number = 1 << 2
Const VAR
VAR: "var " = "var "
Const _createCtor
_createCtor: (Anonymous function) = CC_SUPPORT_JIT ? function (ctors, baseClass, className, options) {const superCallBounded = baseClass && boundSuperCalls(baseClass, options, className);const ctorName = CC_DEV ? normalizeClassName_DEV(className) : 'CCClass';let body = 'return function ' + ctorName + '(){\n';if (superCallBounded) {body += 'this._super=null;\n';}// instantiate propsbody += 'this.__initProps__(' + ctorName + ');\n';// call user constructorsconst ctorLen = ctors.length;if (ctorLen > 0) {const useTryCatch = CC_DEV && !(className && className.startsWith('cc.'));if (useTryCatch) {body += 'try{\n';}const SNIPPET = '].apply(this,arguments);\n';if (ctorLen === 1) {body += ctorName + '.__ctors__[0' + SNIPPET;}else {body += 'var cs=' + ctorName + '.__ctors__;\n';for (let i = 0; i < ctorLen; i++) {body += 'cs[' + i + SNIPPET;}}if (useTryCatch) {body += '}catch(e){\n' +'cc._throw(e);\n' +'}\n';}}body += '}';return Function(body)();} : function (ctors, baseClass, className, options) {const superCallBounded = baseClass && boundSuperCalls(baseClass, options, className);const ctorLen = ctors.length;let Class;if (ctorLen > 0) {if (superCallBounded) {if (ctorLen === 2) {// User ComponentClass = function (this: any) {this._super = null;this.__initProps__(Class);ctors[0].apply(this, arguments);ctors[1].apply(this, arguments);};}else {Class = function (this: any) {this._super = null;this.__initProps__(Class);for (let i = 0; i < ctors.length; ++i) {ctors[i].apply(this, arguments);}};}}else {if (ctorLen === 3) {// NodeClass = function (this: any) {this.__initProps__(Class);ctors[0].apply(this, arguments);ctors[1].apply(this, arguments);ctors[2].apply(this, arguments);};}else {Class = function (this: any) {this.__initProps__(Class);const ctors = Class.__ctors__;for (let i = 0; i < ctors.length; ++i) {ctors[i].apply(this, arguments);}};}}}else {Class = function (this: any) {if (superCallBounded) {this._super = null;}this.__initProps__(Class);};}return Class;}
Const boolean
boolean: function = type(CCBoolean)
Type declaration
-
- (target: Object, propertyKey: string | symbol): void
-
Parameters
-
target: Object
-
propertyKey: string | symbol
Returns void
Const ccclass
ccclass: (Anonymous function) = checkCtorArgument(function (ctor, name) {// if (FIX_BABEL6) {// eval('if(typeof _classCallCheck==="function"){_classCallCheck=function(){};}');// }let base = js.getSuper(ctor);if (base === Object) {base = null;}const proto = {name,extends: base,ctor,__ES6__: true,};const cache = ctor[CACHE_KEY];if (cache) {const decoratedProto = cache.proto;if (decoratedProto) {// decoratedProto.properties = createProperties(ctor, decoratedProto.properties);js.mixin(proto, decoratedProto);}ctor[CACHE_KEY] = undefined;}const res = cc.Class(proto);// validate methodsif (CC_DEV) {const propNames = Object.getOwnPropertyNames(ctor.prototype);for (let i = 0; i < propNames.length; ++i) {const prop = propNames[i];if (prop !== 'constructor') {const desc = Object.getOwnPropertyDescriptor(ctor.prototype, prop);const func = desc && desc.value;if (typeof func === 'function') {doValidateMethodWithProps_DEV(func, prop, js.getClassName(ctor), ctor, base);}}}}return res;})
Const checkCompArgument
checkCompArgument: function = _checkNormalArgument.bind(null, CC_DEV && function (arg, decoratorName) {if (!cc.Class._isCCClass(arg)) {error('The parameter for %s is missing.', decoratorName);return false;}})
Const checkNumberArgument
checkNumberArgument: function = _argumentChecker('number')
Const checkStringArgument
checkStringArgument: function = _argumentChecker('string')
Const compileDeserialize
compileDeserialize: (Anonymous function) = CC_SUPPORT_JIT ? (self, klass) => {const TYPE = Attr.DELIMETER + 'type';const EDITOR_ONLY = Attr.DELIMETER + 'editorOnly';const DEFAULT = Attr.DELIMETER + 'default';const SAVE_URL_AS_ASSET = Attr.DELIMETER + 'saveUrlAsAsset';const FORMERLY_SERIALIZED_AS = Attr.DELIMETER + 'formerlySerializedAs';const attrs = Attr.getClassAttrs(klass);const props = klass.__values__;// self, obj, serializedData, klass, targetconst sources = ['var prop;',];const fastMode = misc.BUILTIN_CLASSID_RE.test(js._getClassId(klass));// sources.push('var vb,vn,vs,vo,vu,vf;'); // boolean, number, string, object, undefined, function// tslint:disable-next-line: prefer-for-offor (let p = 0; p < props.length; p++) {const propName = props[p];if ((CC_PREVIEW || (CC_EDITOR && self._ignoreEditorOnly)) && attrs[propName + EDITOR_ONLY]) {continue; // skip editor only if in preview}let accessorToSet;let propNameLiteralToSet;if (CCClass.IDENTIFIER_RE.test(propName)) {propNameLiteralToSet = '"' + propName + '"';accessorToSet = '.' + propName;}else {propNameLiteralToSet = CCClass.escapeForJS(propName);accessorToSet = '[' + propNameLiteralToSet + ']';}let accessorToGet = accessorToSet;if (attrs[propName + FORMERLY_SERIALIZED_AS]) {const propNameToRead = attrs[propName + FORMERLY_SERIALIZED_AS];if (CCClass.IDENTIFIER_RE.test(propNameToRead)) {accessorToGet = '.' + propNameToRead;}else {accessorToGet = '[' + CCClass.escapeForJS(propNameToRead) + ']';}}sources.push('prop=d' + accessorToGet + ';');sources.push(`if(typeof ${CC_JSB ? '(prop)' : 'prop'}!=="undefined"){`);const stillUseUrl = attrs[propName + SAVE_URL_AS_ASSET];// function undefined object(null) string boolean numberconst defaultValue = CCClass.getDefault(attrs[propName + DEFAULT]);if (fastMode) {let isPrimitiveType;const userType = attrs[propName + TYPE];if (defaultValue === undefined && userType) {isPrimitiveType = userType === cc.String ||userType === cc.Integer ||userType === cc.Float ||userType === cc.Boolean;}else {const defaultType = typeof defaultValue;isPrimitiveType = (defaultType === 'string' && !stillUseUrl) ||defaultType === 'number' ||defaultType === 'boolean';}if (isPrimitiveType) {sources.push(`o${accessorToSet}=prop;`);}else {compileObjectTypeJit(sources, defaultValue, accessorToSet, propNameLiteralToSet, true, stillUseUrl);}}else {sources.push(`if(typeof ${CC_JSB ? '(prop)' : 'prop'}!=="object"){` +'o' + accessorToSet + '=prop;' +'}else{');compileObjectTypeJit(sources, defaultValue, accessorToSet, propNameLiteralToSet, false, stillUseUrl);sources.push('}');}sources.push('}');}if (cc.js.isChildClassOf(klass, cc._BaseNode) || cc.js.isChildClassOf(klass, cc.Component)) {if (CC_PREVIEW || (CC_EDITOR && self._ignoreEditorOnly)) {const mayUsedInPersistRoot = js.isChildClassOf(klass, cc.Node);if (mayUsedInPersistRoot) {sources.push('d._id&&(o._id=d._id);');}}else {sources.push('d._id&&(o._id=d._id);');}}if (props[props.length - 1] === '_$erialized') {// deep copy original serialized datasources.push('o._$erialized=JSON.parse(JSON.stringify(d));');// parse the serialized data as primitive javascript object, so its __id__ will be dereferencedsources.push('s._deserializePrimitiveObject(o._$erialized,d);');}return Function('s', 'o', 'd', 'k', 't', sources.join(''));} : (self, klass) => {const fastMode = misc.BUILTIN_CLASSID_RE.test(js._getClassId(klass));const shouldCopyId = cc.js.isChildClassOf(klass, cc._BaseNode) || cc.js.isChildClassOf(klass, cc.Component);let shouldCopyRawData;const simpleProps: any = [];let simplePropsToRead = simpleProps;const advancedProps: any = [];let advancedPropsToRead = advancedProps;const advancedPropsUseUrl: any = [];const advancedPropsValueType: any = [];(() => {const props = klass.__values__;shouldCopyRawData = props[props.length - 1] === '_$erialized';const attrs = Attr.getClassAttrs(klass);const TYPE = Attr.DELIMETER + 'type';const DEFAULT = Attr.DELIMETER + 'default';const SAVE_URL_AS_ASSET = Attr.DELIMETER + 'saveUrlAsAsset';const FORMERLY_SERIALIZED_AS = Attr.DELIMETER + 'formerlySerializedAs';// tslint:disable-next-line: prefer-for-offor (let p = 0; p < props.length; p++) {const propName = props[p];let propNameToRead = propName;if (attrs[propName + FORMERLY_SERIALIZED_AS]) {propNameToRead = attrs[propName + FORMERLY_SERIALIZED_AS];}const stillUseUrl = attrs[propName + SAVE_URL_AS_ASSET];// function undefined object(null) string boolean numberconst defaultValue = CCClass.getDefault(attrs[propName + DEFAULT]);let isPrimitiveType = false;if (fastMode) {const userType = attrs[propName + TYPE];if (defaultValue === undefined && userType) {isPrimitiveType = userType === cc.String ||userType === cc.Integer ||userType === cc.Float ||userType === cc.Boolean;}else {const defaultType = typeof defaultValue;isPrimitiveType = (defaultType === 'string' && !stillUseUrl) ||defaultType === 'number' ||defaultType === 'boolean';}}if (fastMode && isPrimitiveType) {if (propNameToRead !== propName && simplePropsToRead === simpleProps) {simplePropsToRead = simpleProps.slice();}simpleProps.push(propName);if (simplePropsToRead !== simpleProps) {simplePropsToRead.push(propNameToRead);}}else {if (propNameToRead !== propName && advancedPropsToRead === advancedProps) {advancedPropsToRead = advancedProps.slice();}advancedProps.push(propName);if (advancedPropsToRead !== advancedProps) {advancedPropsToRead.push(propNameToRead);}advancedPropsUseUrl.push(stillUseUrl);advancedPropsValueType.push((defaultValue instanceof cc.ValueType) && defaultValue.constructor);}}})();return (s, o, d, k, t) => {for (let i = 0; i < simpleProps.length; ++i) {const prop = d[simplePropsToRead[i]];if (prop !== undefined) {o[simpleProps[i]] = prop;}}for (let i = 0; i < advancedProps.length; ++i) {const propName = advancedProps[i];const prop = d[advancedPropsToRead[i]];if (prop === undefined) {continue;}if (!fastMode && typeof prop !== 'object') {o[propName] = prop;}else {// fastMode (so will not simpleProp) or objectconst valueTypeCtor = advancedPropsValueType[i];if (valueTypeCtor) {if (fastMode || prop) {s._deserializeTypedObject(o[propName], prop, valueTypeCtor);}else {o[propName] = null;}}else {if (prop) {s._deserializeObjField(o,prop,propName,(CC_EDITOR || CC_TEST) ? (t && o) : null,advancedPropsUseUrl[i],);}else {o[propName] = null;}}}}if (shouldCopyId && d._id) {o._id = d._id;}if (shouldCopyRawData) {// deep copy original serialized datao._$erialized = JSON.parse(JSON.stringify(d));// parse the serialized data as primitive javascript object, so its __id__ will be dereferenceds._deserializePrimitiveObject(o._$erialized, d);}};}
Let deferredDestroyTimer
deferredDestroyTimer: null = null
Const disallowMultiple
disallowMultiple: any = (CC_DEV ? createEditorDecorator : createDummyDecorator)(checkCtorArgument, 'disallowMultiple')
Const executeInEditMode
executeInEditMode: any = (CC_DEV ? createEditorDecorator : createDummyDecorator)(checkCtorArgument, 'executeInEditMode', true)
Const executionOrder
executionOrder: any = createEditorDecorator(checkNumberArgument, 'executionOrder')
Const float
float: function = type(CCFloat)
Type declaration
-
- (target: Object, propertyKey: string | symbol): void
-
Parameters
-
target: Object
-
propertyKey: string | symbol
Returns void
Const help
help: any = (CC_DEV ? createEditorDecorator : createDummyDecorator)(checkStringArgument, 'help')
Private Const icon
icon: any = (CC_DEV ? createEditorDecorator : createDummyDecorator)(checkStringArgument, 'icon')
Const inspector
inspector: any = (CC_DEV ? createEditorDecorator : createDummyDecorator)(checkStringArgument, 'inspector')
Const integer
integer: function = type(CCInteger)
Type declaration
-
- (target: Object, propertyKey: string | symbol): void
-
Parameters
-
target: Object
-
propertyKey: string | symbol
Returns void
Const menu
menu: any = (CC_DEV ? createEditorDecorator : createDummyDecorator)(checkStringArgument, 'menu')
Const objectsToDestroy
objectsToDestroy: any = []
Const objsToClearTmpVar
objsToClearTmpVar: any = []
Const playOnFocus
playOnFocus: any = (CC_DEV ? createEditorDecorator : createDummyDecorator)(checkCtorArgument, 'playOnFocus')
Const prototype
prototype
: CCObject = CCObject.prototype
Const requireComponent
requireComponent: any = createEditorDecorator(checkCompArgument, 'requireComponent')
Const string
string: function = type(CCString)
Type declaration
-
- (target: Object, propertyKey: string | symbol): void
-
Parameters
-
target: Object
-
propertyKey: string | symbol
Returns void
Const superCllRegCondition
superCllRegCondition: boolean = /xyz/.test(function () { const xyz = 0; }.toString())
Const tmpArray
tmpArray: never[] = []
Const tmpAttrs
tmpAttrs: never[] = []
将该属性标记为 cc 布尔值。