Once again refactored propobj.setup(), removing unnecessary argument and separating into inheritance and non-inheritance methods
parent
d1be2d5351
commit
f692ebcdfd
|
@ -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 );
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -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' ] );
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue