1
0
Fork 0

Interface now uses propParse and member builders

closure/master
Mike Gerwitz 2011-01-24 23:35:45 -05:00
parent cd7b2563e5
commit 70f5d09c34
1 changed files with 26 additions and 8 deletions

View File

@ -22,8 +22,9 @@
* @package core * @package core
*/ */
var util = require( './util' ), var util = require( './util' ),
Class = require( './class' ); member_builder = require( './member_builder' ),
Class = require( './class' );
/** /**
@ -55,23 +56,40 @@ var extend = ( function( extending )
var args = Array.prototype.slice.call( arguments ), var args = Array.prototype.slice.call( arguments ),
props = args.pop() || {}, props = args.pop() || {},
base = args.pop() || Interface, base = args.pop() || Interface,
prototype = new base(); prototype = new base(),
members = member_builder.initMembers(
prototype, prototype, prototype
)
;
// sanity check // sanity check
inheritCheck( prototype ); inheritCheck( prototype );
var new_interface = createInterface(); var new_interface = createInterface();
util.propCopy( props, prototype, { util.propParse( props, {
each: function( name, value ) property: function()
{ {
if ( util.isAbstractMethod( value ) === false ) throw TypeError(
"Properties are not permitted within Interface " +
"definitions"
);
},
method: function( name, value, is_abstract, keywords )
{
if ( !is_abstract )
{ {
throw TypeError( throw TypeError(
"Only abstract methods are permitted within Interface " + "Only abstract methods are permitted within " +
"definitons" "Interface definitions"
); );
} }
member_builder.buildMethod(
members, null, name, value, keywords
);
}, },
} ); } );