1
0
Fork 0

Added virtual members to class metadata

There does not seem to be tests for any of the metadata at present; they are
implicitly tested through various implementations that make use of them.
This will also be the case here ("will"---in coming commits), but needs to
change.

The upcoming reflection implementation would be an excellent time to do so.
perfodd
Mike Gerwitz 2014-02-02 23:28:09 -05:00
parent a0a5c61631
commit 3c7cd0e57a
1 changed files with 14 additions and 0 deletions

View File

@ -308,6 +308,10 @@ exports.prototype.build = function extend( _, __ )
abstract_methods =
util.clone( exports.getMeta( base ).abstractMethods )
|| { __length: 0 }
virtual_members =
util.clone( exports.getMeta( base ).virtualMembers )
|| {}
;
// prevent extending final classes
@ -350,6 +354,7 @@ exports.prototype.build = function extend( _, __ )
all: members,
'abstract': abstract_methods,
'static': static_members,
'virtual': virtual_members,
},
function( inst )
{
@ -409,6 +414,7 @@ exports.prototype.build = function extend( _, __ )
// create internal metadata for the new class
var meta = createMeta( new_class, base );
meta.abstractMethods = abstract_methods;
meta.virtualMembers = virtual_members;
meta.name = cname;
attachAbstract( new_class, abstract_methods );
@ -449,9 +455,12 @@ exports.prototype.buildMembers = function buildMembers(
var hasOwn = Array.prototype.hasOwnProperty,
defs = {},
// TODO: there does not seem to be tests for these guys; perhaps
// this can be rectified with the reflection implementation
members = memberdest.all,
abstract_methods = memberdest['abstract'],
static_members = memberdest['static'],
virtual_members = memberdest['virtual'],
smethods = static_members.methods,
sprops = static_members.props,
@ -562,6 +571,11 @@ exports.prototype.buildMembers = function buildMembers(
delete abstract_methods[ name ];
abstract_methods.__length--;
}
if ( keywords['virtual'] )
{
virtual_members[ name ] = true;
}
},
} );