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
*/
var util = require( './util' ),
Class = require( './class' );
var util = require( './util' ),
member_builder = require( './member_builder' ),
Class = require( './class' );
/**
@ -55,23 +56,40 @@ var extend = ( function( extending )
var args = Array.prototype.slice.call( arguments ),
props = args.pop() || {},
base = args.pop() || Interface,
prototype = new base();
prototype = new base(),
members = member_builder.initMembers(
prototype, prototype, prototype
)
;
// sanity check
inheritCheck( prototype );
var new_interface = createInterface();
util.propCopy( props, prototype, {
each: function( name, value )
util.propParse( props, {
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(
"Only abstract methods are permitted within Interface " +
"definitons"
"Only abstract methods are permitted within " +
"Interface definitions"
);
}
member_builder.buildMethod(
members, null, name, value, keywords
);
},
} );