diff --git a/lib/class.js b/lib/class.js index 9933fdf..16e5f44 100644 --- a/lib/class.js +++ b/lib/class.js @@ -774,10 +774,13 @@ function initInstance( iid, instance ) */ function attachPropInit( prototype, properties, members ) { - util.defineSecureProp( prototype, '__initProps', function( inherit ) + util.defineSecureProp( prototype, '__initProps', function( inherit, sid ) { - // defaults to false + // defaults to false, sid = super identifier inherit = !!inherit; + sid = ( sid ) ? +sid : 0; + + var iid = this.__iid; // first initialize the parent's properties, so that ours will overwrite // them @@ -787,22 +790,20 @@ function attachPropInit( prototype, properties, members ) // call the parent prop_init, letting it know that it's been // inherited so that it does not initialize private members or // perform other unnecessary tasks - parent_init.call( this, true ); + parent_init.call( this, true, ( sid + 1 ) ); } // this will return our property proxy, if supported by our environment, // otherwise just a normal object with everything merged in var inst_props = propobj.createPropProxy( - this, class_instance[ this.__iid ], properties[ 'public' ] + this, class_instance[ iid ], properties[ 'public' ] ); // if we're inheriting, perform a setup that doesn't include everything // that we don't want (e.g. private properties) - var setup = ( inherit ) - ? propobj.setupInherited - : propobj.setup - ; - class_instance[ this.__iid ] = setup( inst_props, properties, members ); + class_instance[ iid ][ sid ] = propobj.setup( + inst_props, properties, members, sid + ); }); } @@ -993,7 +994,7 @@ function getMethodInstance( method ) data = class_instance[ method.__iid ]; return ( iid && data ) - ? data + ? data[ 0 ] : null ; } diff --git a/lib/propobj.js b/lib/propobj.js index 5e25e91..7ea372d 100644 --- a/lib/propobj.js +++ b/lib/propobj.js @@ -30,28 +30,6 @@ var util = require( './util' ), ; -/** - * Sets up properties when inheriting - * - * This does not include private members. - * - * @param {Object} dest destination object - * @param {Object} properties properties to copy - * @param {Object=} methods methods to copy - * - * @return {Object} dest - */ -exports.setupInherited = function( dest, properties, methods ) -{ - // initialize each of the properties for this instance to - // ensure we're not sharing references to prototype values - doSetup( dest, properties[ 'public' ] ); - doSetup( dest, properties[ 'protected' ], methods[ 'protected'] ); - - return dest; -}; - - /** * Sets up properties (non-inheriting) * @@ -75,8 +53,10 @@ exports.setup = function( dest, properties, methods ) var obj = new obj_ctor(); - // first, set up the public and protected members - exports.setupInherited( dest, properties, methods ); + // initialize each of the properties for this instance to + // ensure we're not sharing references to prototype values + doSetup( dest, properties[ 'public' ] ); + doSetup( dest, properties[ 'protected' ], methods[ 'protected'] ); // then add the private parts doSetup( obj, properties[ 'private' ], methods[ 'private' ] );