From 3c7cd0e57aeff0255c27a196c36baf91735ac915 Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Sun, 2 Feb 2014 23:28:09 -0500 Subject: [PATCH] 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. --- lib/ClassBuilder.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/ClassBuilder.js b/lib/ClassBuilder.js index dbc259e..2b02134 100644 --- a/lib/ClassBuilder.js +++ b/lib/ClassBuilder.js @@ -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; + } }, } );