[pygccxml-commit] SF.net SVN: pygccxml: [618] pygccxml_dev
Brought to you by:
mbaas,
roman_yakovenko
From: <rom...@us...> - 2006-10-04 09:53:20
|
Revision: 618 http://svn.sourceforge.net/pygccxml/?rev=618&view=rev Author: roman_yakovenko Date: 2006-10-04 02:53:10 -0700 (Wed, 04 Oct 2006) Log Message: ----------- adding access_type for variable_t class Modified Paths: -------------- pygccxml_dev/pygccxml/declarations/variable.py pygccxml_dev/unittests/variable_matcher_tester.py Modified: pygccxml_dev/pygccxml/declarations/variable.py =================================================================== --- pygccxml_dev/pygccxml/declarations/variable.py 2006-10-03 22:14:04 UTC (rev 617) +++ pygccxml_dev/pygccxml/declarations/variable.py 2006-10-04 09:53:10 UTC (rev 618) @@ -8,6 +8,7 @@ """ import declaration +import class_declaration class variable_t( declaration.declaration_t ): """describes C++ global and member variable declaration""" @@ -60,3 +61,10 @@ self._bits = bits bits = property( _get_bits, _set_bits , doc="integer, that contains information about how many bit takes bit field") + + @property + def access_type(self): + if not isinstance( self.parent, class_declaration.class_t ): + raise RuntimeError( "access_type functionality only available on member variables and not on global variables" ) + return self.parent.find_out_member_access_type( self ) + Modified: pygccxml_dev/unittests/variable_matcher_tester.py =================================================================== --- pygccxml_dev/unittests/variable_matcher_tester.py 2006-10-03 22:14:04 UTC (rev 617) +++ pygccxml_dev/unittests/variable_matcher_tester.py 2006-10-04 09:53:10 UTC (rev 618) @@ -13,33 +13,35 @@ from pygccxml import declarations class tester_t( parser_test_case.parser_test_case_t ): - COMPILATION_MODE = parser.COMPILATION_MODE.ALL_AT_ONCE + COMPILATION_MODE = parser.COMPILATION_MODE.ALL_AT_ONCE def __init__(self, *args ): parser_test_case.parser_test_case_t.__init__( self, *args ) self.header = 'bit_fields.hpp' self.declarations = None - + def setUp(self): if not self.declarations: self.declarations = parser.parse( [self.header], self.config ) - - def test( self ): + + def test( self ): criteria = declarations.variable_matcher_t( name='x', type='unsigned int' ) x = declarations.matcher.get_single( criteria, self.declarations ) - + self.failUnless( str(criteria) == '(decl type==variable_t) and (name==x) and (value type==unsigned int)' ) - - criteria = declarations.variable_matcher_t( + + criteria = declarations.variable_matcher_t( name='::bit_fields::fields_t::x' , type=declarations.unsigned_int_t() , header_dir=os.path.dirname(x.location.file_name) , header_file=x.location.file_name) - + x = declarations.matcher.get_single( criteria, self.declarations ) self.failUnless( x, "Variable was not found." ) + self.failUnless( 'public' == x.access_type ) + def create_suite(): - suite = unittest.TestSuite() + suite = unittest.TestSuite() suite.addTest( unittest.makeSuite(tester_t)) return suite @@ -47,4 +49,4 @@ unittest.TextTestRunner(verbosity=2).run( create_suite() ) if __name__ == "__main__": - run_suite() \ No newline at end of file + run_suite() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |