From 9c9759a2b1a0881546b2de7b99b12649202f33e0 Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Fri, 14 Oct 2011 22:14:29 -0400 Subject: [PATCH] Moved validateMethod() function into MemberBuilder prototype to prepare for overriding with FallbackMemberBuilder --- lib/MemberBuilder.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/MemberBuilder.js b/lib/MemberBuilder.js index 3eafb77..ac8dae1 100644 --- a/lib/MemberBuilder.js +++ b/lib/MemberBuilder.js @@ -111,7 +111,7 @@ exports.buildMethod = function( // ensure that the declaration is valid (keywords make sense, argument // length, etc) - validateMethod( keywords, prev_data, prev_keywords, value, name ); + this._validateMethod( keywords, prev_data, prev_keywords, value, name ); // we might be overriding an existing method if ( prev ) @@ -161,7 +161,8 @@ exports.buildMethod = function( * @param {*} value property value * @param {string} name property name */ -function validateMethod( keywords, prev_data, prev_keywords, value, name ) +exports._validateMethod = function( + keywords, prev_data, prev_keywords, value, name ) { var prev = ( prev_data ) ? prev_data.member : null; @@ -243,7 +244,7 @@ function validateMethod( keywords, prev_data, prev_keywords, value, name ) } // do not permit visibility deescalation - if ( prev_data.visibility < getVisibilityValue( keywords ) ) + if ( prev_data.visibility < this._getVisibilityValue( keywords ) ) { throw TypeError( "Cannot de-escalate visibility of method '" + name + "'" @@ -309,7 +310,9 @@ exports.buildProp = function( members, meta, name, value, keywords, base ) } // do not permit visibility de-escalation - if ( prev && ( prev_data.visibility < getVisibilityValue( keywords ) ) ) + if ( prev && + ( prev_data.visibility < this._getVisibilityValue( keywords ) ) + ) { throw TypeError( "Cannot de-escalate visibility of property '" + name + "'" @@ -608,7 +611,7 @@ exports._overrideMethod = function( * * @return {number} visibility level as a numeric value */ -function getVisibilityValue( keywords ) +exports._getVisibilityValue = function( keywords ) { if ( fallback ) {