1
0
Fork 0

Beginning to move Class over to use member builders

closure/master
Mike Gerwitz 2011-01-24 23:28:48 -05:00
parent 2a54662716
commit eba32ed4cb
3 changed files with 35 additions and 13 deletions

View File

@ -214,7 +214,9 @@ var extend = ( function( extending )
prototype = new base(); prototype = new base();
var properties = {}, var properties = {},
members = member_builder.initMembers( prototype ), members = member_builder.initMembers(
prototype, prototype, prototype
),
abstract_methods = ( base.abstractMethods || [] ).slice(); abstract_methods = ( base.abstractMethods || [] ).slice();
// it's much faster to lookup a hash than it is to iterate through an // it's much faster to lookup a hash than it is to iterate through an
@ -226,35 +228,52 @@ var extend = ( function( extending )
abstract_map[ method ] = i; abstract_map[ method ] = i;
} }
util.propCopy( props, prototype, { util.propParse( props, {
each: function( name, value ) each: function( name, value, keywords )
{ {
// disallow use of our internal __initProps() method // disallow use of our internal __initProps() method
if ( name === '__initProps' ) if ( name === '__initProps' )
{ {
throw new Error( "__initProps is a reserved method" ); throw new Error( "__initProps is a reserved method" );
} }
this.performDefault( name, value );
}, },
property: function( name, value ) property: function( name, value, keywords )
{ {
properties[ name ] = value; properties[ name ] = value;
this.performDefault( name, value );
member_builder.buildProp(
members, null, name, value, keywords
);
}, },
method: function( name, func, is_abstract ) getter: function( name, value, keywords )
{ {
var pre = prototype[ name ]; member_builder.buildGetter(
members, null, name, value, keywords
);
},
this.performDefault( name, func, is_abstract ); setter: function( name, value, keywords )
{
member_builder.buildSetter(
members, null, name, value, keywords
);
},
if ( ( pre === undefined ) && is_abstract ) method: function( name, func, is_abstract, keywords )
{
member_builder.buildMethod(
members, null, name, func, keywords
);
if ( is_abstract )
{ {
abstract_methods.push( name ); abstract_methods.push( name );
} }
else if ( pre && ( is_abstract === false ) ) else if ( ( abstract_map[ name ] !== undefined )
&& ( is_abstract === false )
)
{ {
// if this was a concrete method, then it should no longer // if this was a concrete method, then it should no longer
// be marked as abstract // be marked as abstract

View File

@ -75,7 +75,9 @@ exports.buildMethod = function( members, meta, name, value, keywords )
} }
// ensure parameter list is at least the length of its supertype // ensure parameter list is at least the length of its supertype
if ( prev && ( value.length < ( prev.__length || prev.length ) ) ) if ( prev && (
( value.__length || value.length ) < ( prev.__length || prev.length )
) )
{ {
throw new TypeError( throw new TypeError(
"Declaration of method '" + name + "' must be compatiable " + "Declaration of method '" + name + "' must be compatiable " +

View File

@ -381,6 +381,7 @@ exports.createAbstractMethod = function()
exports.defineSecureProp( method, 'abstractFlag', true ); exports.defineSecureProp( method, 'abstractFlag', true );
exports.defineSecureProp( method, 'definition', definition ); exports.defineSecureProp( method, 'definition', definition );
exports.defineSecureProp( method, '__length', arguments.length );
return method; return method;
}; };