Both concrete and abstract methods now use the same callback in propParse()
- Now uses an is_abstract parameter - Intended to reduce clutter and duplicate codeclosure/master
parent
52b1ef657f
commit
eced0a7e91
47
lib/util.js
47
lib/util.js
|
@ -100,10 +100,8 @@ exports.propParse = function( data, options )
|
||||||
callback_each = options.each || undefined,
|
callback_each = options.each || undefined,
|
||||||
callback_prop = options.property || fvoid,
|
callback_prop = options.property || fvoid,
|
||||||
callback_method = options.method || fvoid,
|
callback_method = options.method || fvoid,
|
||||||
callback_abstract_method = options.abstractMethod || fvoid,
|
|
||||||
callback_getter = options.getter || fvoid,
|
callback_getter = options.getter || fvoid,
|
||||||
callback_setter = options.setter || fvoid,
|
callback_setter = options.setter || fvoid;
|
||||||
callback = null;
|
|
||||||
|
|
||||||
// for each of the given properties, determine what type of property we're
|
// for each of the given properties, determine what type of property we're
|
||||||
// dealing with (in the classic OO sense)
|
// dealing with (in the classic OO sense)
|
||||||
|
@ -131,20 +129,17 @@ exports.propParse = function( data, options )
|
||||||
// method
|
// method
|
||||||
else if ( value instanceof Function )
|
else if ( value instanceof Function )
|
||||||
{
|
{
|
||||||
// concrete or abstract?
|
callback_method(
|
||||||
callback = ( exports.isAbstractMethod( value ) )
|
prop,
|
||||||
? callback_abstract_method
|
value,
|
||||||
: callback_method
|
exports.isAbstractMethod( value )
|
||||||
;
|
);
|
||||||
}
|
}
|
||||||
// simple property
|
// simple property
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
callback = callback_prop;
|
callback_prop( prop, value );
|
||||||
}
|
}
|
||||||
|
|
||||||
// call the appropriate callback
|
|
||||||
callback( prop, value );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -232,28 +227,7 @@ exports.propCopy = function( props, dest, result_data )
|
||||||
dest.__defineSetter__( name, func );
|
dest.__defineSetter__( name, func );
|
||||||
},
|
},
|
||||||
|
|
||||||
abstractMethod: function( name, def )
|
method: function( name, func, is_abstract )
|
||||||
{
|
|
||||||
var data = { abstractModified: false },
|
|
||||||
pre = dest[ name ];
|
|
||||||
|
|
||||||
// check for override
|
|
||||||
if ( pre !== undefined )
|
|
||||||
{
|
|
||||||
dest[ name ] = attempt_override( name, pre, def, data );
|
|
||||||
if ( data.abstractModified )
|
|
||||||
{
|
|
||||||
abstract_regen = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
abstract_methods.push( name );
|
|
||||||
dest[ name ] = def;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
method: function( name, func )
|
|
||||||
{
|
{
|
||||||
var data = { abstractModified: false },
|
var data = { abstractModified: false },
|
||||||
pre = dest[ name ];
|
pre = dest[ name ];
|
||||||
|
@ -271,6 +245,11 @@ exports.propCopy = function( props, dest, result_data )
|
||||||
{
|
{
|
||||||
// simply copy over the method
|
// simply copy over the method
|
||||||
dest[ name ] = func;
|
dest[ name ] = func;
|
||||||
|
|
||||||
|
if ( is_abstract )
|
||||||
|
{
|
||||||
|
abstract_methods.push( name );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -80,15 +80,10 @@ util.propParse( data, {
|
||||||
props[ name ] = value;
|
props[ name ] = value;
|
||||||
},
|
},
|
||||||
|
|
||||||
// concrete method
|
method: function( name, method, is_abstract )
|
||||||
method: function( name, method )
|
|
||||||
{
|
{
|
||||||
methods[ name ] = method;
|
var to = ( is_abstract ) ? amethods : methods;
|
||||||
},
|
to[ name ] = method;
|
||||||
|
|
||||||
abstractMethod: function( name, def )
|
|
||||||
{
|
|
||||||
amethods[ name ] = def;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
getter: function( name, func )
|
getter: function( name, func )
|
||||||
|
|
Loading…
Reference in New Issue