[pygccxml-commit] SF.net SVN: pygccxml:[1735] pygccxml_dev
Brought to you by:
mbaas,
roman_yakovenko
From: <rom...@us...> - 2009-05-17 08:29:28
|
Revision: 1735 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1735&view=rev Author: roman_yakovenko Date: 2009-05-17 08:29:22 +0000 (Sun, 17 May 2009) Log Message: ----------- fix 2779781 bug( pygccxml reverses array dimensions ) Modified Paths: -------------- pygccxml_dev/pygccxml/declarations/cpptypes.py pygccxml_dev/unittests/test_all.py Added Paths: ----------- pygccxml_dev/unittests/array_bug_tester.py Modified: pygccxml_dev/pygccxml/declarations/cpptypes.py =================================================================== --- pygccxml_dev/pygccxml/declarations/cpptypes.py 2009-05-17 05:48:47 UTC (rev 1734) +++ pygccxml_dev/pygccxml/declarations/cpptypes.py 2009-05-17 08:29:22 UTC (rev 1735) @@ -446,8 +446,23 @@ doc="returns array size" ) def build_decl_string(self, with_defaults=True): - return self.base.build_decl_string(with_defaults) + '[%d]' % self.size + #return self.base.build_decl_string(with_defaults) + '[%d]' % self.size + return self.__bds_for_multi_dim_arrays( None, with_defaults ) + def __bds_for_multi_dim_arrays(self, parent_dims=None, with_defaults=True): + if parent_dims: + parent_dims.append( self.size ) + else: + parent_dims = [self.size] + + if isinstance( self.base, array_t ): + return self.base.__bds_for_multi_dim_arrays( parent_dims, with_defaults) + else: + tmp = [] + for s in parent_dims: + tmp.append( '[%d]' % s ) + return self.base.build_decl_string(with_defaults) + ''.join( tmp ) + def _clone_impl( self ): return array_t( self.base.clone(), self.size ) Added: pygccxml_dev/unittests/array_bug_tester.py =================================================================== --- pygccxml_dev/unittests/array_bug_tester.py (rev 0) +++ pygccxml_dev/unittests/array_bug_tester.py 2009-05-17 08:29:22 UTC (rev 1735) @@ -0,0 +1,58 @@ +# Copyright 2004-2008 Roman Yakovenko. +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +import os +import unittest +import autoconfig +import parser_test_case + +from pygccxml import utils +from pygccxml import parser +from pygccxml import declarations + + +class tester_t( parser_test_case.parser_test_case_t ): + def __init__(self, *args): + parser_test_case.parser_test_case_t.__init__(self, *args) + + def test1(self): + code = 'int aaaa[2][3][4][5];' + src_reader = parser.source_reader_t( self.config ) + global_ns = declarations.get_global_namespace( src_reader.read_string( code ) ) + aaaa_type = global_ns.var('aaaa').type + self.failUnless( 'int[2][3][4][5]' == aaaa_type.decl_string, aaaa_type.decl_string ) + + def test2(self): + code = 'int* aaaa[2][3][4][5];' + src_reader = parser.source_reader_t( self.config ) + global_ns = declarations.get_global_namespace( src_reader.read_string( code ) ) + aaaa_type = global_ns.var('aaaa').type + self.failUnless( 'int *[2][3][4][5]' == aaaa_type.decl_string, aaaa_type.decl_string ) + + def test3(self): + code = 'int aaaa[2];' + src_reader = parser.source_reader_t( self.config ) + global_ns = declarations.get_global_namespace( src_reader.read_string( code ) ) + aaaa_type = global_ns.var('aaaa').type + self.failUnless( 'int[2]' == aaaa_type.decl_string, aaaa_type.decl_string ) + + def test4(self): + code = 'struct xyz{}; xyz aaaa[2][3];' + src_reader = parser.source_reader_t( self.config ) + global_ns = declarations.get_global_namespace( src_reader.read_string( code ) ) + aaaa_type = global_ns.var('aaaa').type + self.failUnless( '::xyz[2][3]' == aaaa_type.decl_string, aaaa_type.decl_string ) + + +def create_suite(): + suite = unittest.TestSuite() + suite.addTest( unittest.makeSuite(tester_t)) + return suite + +def run_suite(): + unittest.TextTestRunner(verbosity=2).run( create_suite() ) + +if __name__ == "__main__": + run_suite() Modified: pygccxml_dev/unittests/test_all.py =================================================================== --- pygccxml_dev/unittests/test_all.py 2009-05-17 05:48:47 UTC (rev 1734) +++ pygccxml_dev/unittests/test_all.py 2009-05-17 08:29:22 UTC (rev 1735) @@ -54,6 +54,7 @@ import undname_creator_tester import calling_convention_tester import const_volatile_arg_tester +import array_bug_tester testers = [ decl_string_tester @@ -104,6 +105,7 @@ , undname_creator_tester , calling_convention_tester , const_volatile_arg_tester + , array_bug_tester ] def create_suite(): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |