1
0
Fork 0

Once again refactored propobj.setup(), removing unnecessary argument and separating into inheritance and non-inheritance methods

closure/master
Mike Gerwitz 2011-03-07 00:10:12 -05:00
parent d1be2d5351
commit f692ebcdfd
2 changed files with 35 additions and 13 deletions

View File

@ -796,7 +796,7 @@ function attachPropInit( prototype, properties, members )
class_instance[ this.__iid ] = inst_props;
propobj.setup( this, inst_props, properties, members );
propobj.setup( inst_props, properties, members );
});
}

View File

@ -30,22 +30,44 @@ var util = require( './util' ),
;
exports.setup = function( base, dest, properties, members )
/**
* 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 {undefined}
*/
exports.setupInherited = function( dest, properties, methods )
{
var prop_pub = properties[ 'public' ],
prop_prot = properties[ 'protected' ],
prop_priv = properties[ 'private' ],
methods_protected = members[ 'protected' ],
methods_private = members[ 'private' ]
;
// initialize each of the properties for this instance to
// ensure we're not sharing references to prototype values
doSetup( dest, prop_pub );
doSetup( dest, properties[ 'public' ] );
doSetup( dest, properties[ 'protected' ], methods[ 'protected'] );
};
doSetup( dest, prop_prot, methods_protected );
doSetup( dest, prop_priv, methods_private );
/**
* Sets up properties (non-inheriting)
*
* This includes all members (including private).
*
* @param {Object} dest destination object
* @param {Object} properties properties to copy
* @param {Object=} methods methods to copy
*
* @return {undefined}
*/
exports.setup = function( dest, properties, methods )
{
// first, set up the public and protected members
exports.setupInherited( dest, properties, methods );
// then add the private parts
doSetup( dest, properties[ 'private' ], methods[ 'private' ] );
};