"lazy" metadata support
parent
e866f53d4c
commit
5b6a0c0bb5
|
@ -351,14 +351,15 @@ exports.prototype.build = function extend( _, __ )
|
||||||
props: this._memberBuilder.initMembers(),
|
props: this._memberBuilder.initMembers(),
|
||||||
},
|
},
|
||||||
|
|
||||||
meta = exports.getMeta( base ) || {},
|
// constructor may be different than base
|
||||||
|
pmeta = exports.getMeta( prototype.constructor ) || {},
|
||||||
|
|
||||||
abstract_methods =
|
abstract_methods =
|
||||||
util.clone( meta.abstractMethods )
|
util.clone( pmeta.abstractMethods )
|
||||||
|| { __length: 0 },
|
|| { __length: 0 },
|
||||||
|
|
||||||
virtual_members =
|
virtual_members =
|
||||||
util.clone( meta.virtualMembers )
|
util.clone( pmeta.virtualMembers )
|
||||||
|| {}
|
|| {}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -476,7 +477,7 @@ exports.prototype.build = function extend( _, __ )
|
||||||
util.defineSecureProp( prototype, '__self', new_class.___$$svis$$ );
|
util.defineSecureProp( prototype, '__self', new_class.___$$svis$$ );
|
||||||
|
|
||||||
// create internal metadata for the new class
|
// create internal metadata for the new class
|
||||||
var meta = createMeta( new_class, base );
|
var meta = createMeta( new_class, base, pmeta );
|
||||||
meta.abstractMethods = abstract_methods;
|
meta.abstractMethods = abstract_methods;
|
||||||
meta.virtualMembers = virtual_members;
|
meta.virtualMembers = virtual_members;
|
||||||
meta.name = cname;
|
meta.name = cname;
|
||||||
|
@ -1267,18 +1268,23 @@ exports.prototype.attachStatic = function( ctor, members, base, inheriting )
|
||||||
/**
|
/**
|
||||||
* Initializes class metadata for the given class
|
* Initializes class metadata for the given class
|
||||||
*
|
*
|
||||||
|
* DYNMETA is used only when CPARENT's metadata are flagged as "lazy",
|
||||||
|
* meaning that the data are not available at the time of its definition,
|
||||||
|
* but are available now as DYNMETA.
|
||||||
|
*
|
||||||
* @param {Function} func class to initialize metadata for
|
* @param {Function} func class to initialize metadata for
|
||||||
* @param {Function} cparent class parent
|
* @param {Function} cparent class parent
|
||||||
|
* @param {?Object} dynmeta dynamic metadata
|
||||||
*
|
*
|
||||||
* @return {undefined}
|
* @return {undefined}
|
||||||
*
|
*
|
||||||
* Suppressed due to warnings for use of __cid
|
* Suppressed due to warnings for use of __cid
|
||||||
* @suppress {checkTypes}
|
* @suppress {checkTypes}
|
||||||
*/
|
*/
|
||||||
function createMeta( func, cparent )
|
function createMeta( func, cparent, dynmeta )
|
||||||
{
|
{
|
||||||
var id = func.__cid,
|
var id = func.__cid,
|
||||||
parent_meta = ( ( cparent.__cid )
|
parent_meta = ( cparent[ _priv ]
|
||||||
? exports.getMeta( cparent )
|
? exports.getMeta( cparent )
|
||||||
: undefined
|
: undefined
|
||||||
);
|
);
|
||||||
|
@ -1286,7 +1292,13 @@ function createMeta( func, cparent )
|
||||||
// copy the parent prototype's metadata if it exists (inherit metadata)
|
// copy the parent prototype's metadata if it exists (inherit metadata)
|
||||||
if ( parent_meta )
|
if ( parent_meta )
|
||||||
{
|
{
|
||||||
return func[ _priv ].meta = util.clone( parent_meta, true );
|
return func[ _priv ].meta = util.clone(
|
||||||
|
// "lazy" metadata are unavailable at the time of definition
|
||||||
|
parent_meta._lazy
|
||||||
|
? dynmeta
|
||||||
|
: parent_meta,
|
||||||
|
true
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// create empty
|
// create empty
|
||||||
|
|
Loading…
Reference in New Issue