From 716db6d086e206b8db60a75cd3239333db36b2b5 Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Sun, 14 Nov 2010 01:02:57 -0500 Subject: [PATCH] prop_copy() will now keep track of abstract methods --- lib/class.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/class.js b/lib/class.js index 1d3bf20..04e8048 100644 --- a/lib/class.js +++ b/lib/class.js @@ -58,10 +58,13 @@ exports.extend = function( base ) */ exports.abstractMethod = function( definition ) { - return function() + var method = function() { throw new Error( "Cannot call abstract method" ); - } + }; + + method.abstractFlag = true; + return method; } @@ -94,6 +97,11 @@ function prop_copy( props, dest, result_data ) { result_data = result_data || {}; + // initialize result_data + result_data = { + abstractMethods: [], + }; + // copy each of the properties to the destination object for ( property in props ) { @@ -105,6 +113,12 @@ function prop_copy( props, dest, result_data ) getter = ( ( getset ) ? props.__lookupGetter__( property ) : null ), setter = ( ( getset ) ? props.__lookupSetter__( property ) : null ); + // did we find an abstract method? + if ( ( prop instanceof Function ) && ( prop.abstractFlag === true ) ) + { + result_data.abstractMethods.push( property ); + } + // check for getter/setter overrides if ( getter || setter ) {