Altered abstract method declaration (using strings to represent arguments rather than a function)
parent
837422c46f
commit
2e8097e21e
10
lib/util.js
10
lib/util.js
|
@ -194,13 +194,15 @@ exports.propCopy = function( props, dest, result_data )
|
||||||
* considered to be abstract and cannot be instantiated. It may only be
|
* considered to be abstract and cannot be instantiated. It may only be
|
||||||
* extended.
|
* extended.
|
||||||
*
|
*
|
||||||
* @param {Function} definition function definition that concrete
|
* @param {...string} definition function definition that concrete
|
||||||
* implementations must follow
|
* implementations must follow
|
||||||
*
|
*
|
||||||
* @return {Function}
|
* @return {Function}
|
||||||
*/
|
*/
|
||||||
exports.createAbstractMethod = function( definition )
|
exports.createAbstractMethod = function()
|
||||||
{
|
{
|
||||||
|
var definition = Array.prototype.slice.call( arguments );
|
||||||
|
|
||||||
var method = function()
|
var method = function()
|
||||||
{
|
{
|
||||||
throw new Error( "Cannot call abstract method" );
|
throw new Error( "Cannot call abstract method" );
|
||||||
|
@ -256,10 +258,10 @@ function method_override(
|
||||||
// if we were given a concrete method to an abstract method,
|
// if we were given a concrete method to an abstract method,
|
||||||
// then the method should no longer be considered abstract
|
// then the method should no longer be considered abstract
|
||||||
if ( ( abstract_map[ name ] !== undefined )
|
if ( ( abstract_map[ name ] !== undefined )
|
||||||
&& ( new_method.abstractFlag !== true )
|
&& ( exports.isAbstractMethod( new_method.abstractFlag ) === false )
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if ( super_method.definition instanceof Function )
|
if ( super_method.definition instanceof Array )
|
||||||
{
|
{
|
||||||
// ensure the concrete definition is compatible with
|
// ensure the concrete definition is compatible with
|
||||||
// that of its supertype
|
// that of its supertype
|
||||||
|
|
|
@ -42,7 +42,7 @@ var AbstractFoo = Class.extend(
|
||||||
this.ctorCalled = true;
|
this.ctorCalled = true;
|
||||||
},
|
},
|
||||||
|
|
||||||
method: abstractMethod( function( one, two, three ){} ),
|
method: abstractMethod( 'one', 'two', 'three' ),
|
||||||
|
|
||||||
second: abstractMethod(),
|
second: abstractMethod(),
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue