diff --git a/lib/class.js b/lib/class.js index ee6fd57..9a86c13 100644 --- a/lib/class.js +++ b/lib/class.js @@ -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 ); }); } diff --git a/lib/propobj.js b/lib/propobj.js index cf5e122..0902b42 100644 --- a/lib/propobj.js +++ b/lib/propobj.js @@ -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' ] ); };