1
0
Fork 0

Began adding member_builder

closure/master
Mike Gerwitz 2011-01-18 23:47:58 -05:00
parent 96f5b8ff58
commit 23a7d9d540
3 changed files with 99 additions and 1 deletions

View File

@ -0,0 +1,47 @@
/**
* Handles building members (properties, methods)
*
* Copyright (C) 2010 Mike Gerwitz
*
* This file is part of ease.js.
*
* ease.js is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @author Mike Gerwitz
* @package core
*/
/**
* Copies a property to the appropriate member prototype, depending on
* visibility, and assigns necessary metadata from keywords
*
* @param {{public: Object, protected: Object, private: Object}} members
*
* @param {Object} meta metadata container
* @param {string} name property name
* @param {*} value property value
*
* @param {Object.<string,boolean>} keywords parsed keywords
*
* @return {undefined}
*/
exports.buildProp = function( members, meta, name, value, keywords )
{
if ( keywords[ 'public' ] )
{
members[ 'public' ][ name ] = value;
}
};

View File

@ -0,0 +1,51 @@
/**
* Tests property builder
*
* Copyright (C) 2010 Mike Gerwitz
*
* This file is part of ease.js.
*
* ease.js is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @author Mike Gerwitz
* @package test
*/
var common = require( './common' ),
assert = require( 'assert' ),
buildProp = common.require( 'member_builder' ).buildProp
// member visibility types are quoted because they are reserved keywords
members = { 'public': {}, 'protected': {}, 'private': {} },
meta = {},
// stub values
name = 'foo',
value = 'bar'
;
( function testRecognizesPublicProperty()
{
var keywords = { 'public': true },
result = buildProp( members, meta, name, value, keywords )
;
assert.equal(
members[ 'public' ][ name ],
value,
"Public properties are copied to the public member prototype"
);
} )();

View File

@ -28,7 +28,7 @@ TPL_VAR='/**{CONTENT}**/'
RMTRAIL="$PATH_TOOLS/rmtrail" RMTRAIL="$PATH_TOOLS/rmtrail"
# order matters # order matters
CAT_MODULES="prop_parser util class interface" CAT_MODULES="prop_parser util member_builder class interface"
## ##
# Output template header # Output template header