[pygccxml-commit] SF.net SVN: pygccxml: [212] pygccxml_dev/unittests
Brought to you by:
mbaas,
roman_yakovenko
From: <rom...@us...> - 2006-06-07 20:11:10
|
Revision: 212 Author: roman_yakovenko Date: 2006-06-05 08:17:25 -0700 (Mon, 05 Jun 2006) ViewCVS: http://svn.sourceforge.net/pygccxml/?rev=212&view=rev Log Message: ----------- some fixes for vector_traits Modified Paths: -------------- pygccxml_dev/pygccxml/declarations/type_traits.py pygccxml_dev/unittests/data/vector_traits.hpp pygccxml_dev/unittests/vector_traits_tester.py Modified: pygccxml_dev/pygccxml/declarations/type_traits.py =================================================================== --- pygccxml_dev/pygccxml/declarations/type_traits.py 2006-06-05 15:16:30 UTC (rev 211) +++ pygccxml_dev/pygccxml/declarations/type_traits.py 2006-06-05 15:17:25 UTC (rev 212) @@ -21,6 +21,7 @@ import variable import algorithm import namespace +import templates import enumeration import class_declaration from sets import Set as set @@ -210,11 +211,17 @@ return type else: return nake_type.base - + +def remove_declarated( type ): + type = remove_alias( type ) + if isinstance( type, cpptypes.declarated_t ): + type = type.declaration + return type + def is_same(type1, type2): """returns True if type1 and type2 are same types""" - nake_type1 = remove_alias( type1 ) - nake_type2 = remove_alias( type2 ) + nake_type1 = remove_declarated( type1 ) + nake_type2 = remove_declarated( type2 ) return nake_type1 == nake_type2 def is_volatile(type): @@ -793,7 +800,15 @@ if isinstance( cls, class_declaration.class_t ): return cls.typedef( "value_type" ).type else: - + value_type_str = templates.args( cls.name )[0] + found = cls.top_parent.classes( value_type_str, allow_empty=True ) + if not found: + if cpptypes.FUNDAMENTAL_TYPES.has_key( value_type_str ): + return cpptypes.FUNDAMENTAL_TYPES[value_type_str] + if len( found ) == 1: + return found[0] + else: + raise RuntimeError( "Unable to find out vector value type. vector class is: %s" % cls.decl_string ) Modified: pygccxml_dev/unittests/data/vector_traits.hpp =================================================================== --- pygccxml_dev/unittests/data/vector_traits.hpp 2006-06-05 15:16:30 UTC (rev 211) +++ pygccxml_dev/unittests/data/vector_traits.hpp 2006-06-05 15:17:25 UTC (rev 212) @@ -6,39 +6,55 @@ #include <string> #include <vector> + + struct _0_{}; + typedef std::vector< _0_ > container; + namespace vector_traits{ namespace yes{ struct _1_{ typedef int value_type; typedef std::vector< int > container; + + container do_nothing(){}; }; struct _2_{ typedef _0_ value_type; typedef std::vector< _0_ > container; + + container do_nothing(){}; }; struct _3_{ typedef std::string value_type; typedef std::vector< std::string > container; + + container do_nothing(){}; }; struct _4_{ typedef std::vector<int> value_type; typedef std::vector< std::vector<int> > container; + + container do_nothing(){}; }; struct _5_{ typedef int value_type; typedef const std::vector< int > container; + + container do_nothing(){}; }; struct _6_{ typedef const int value_type; typedef const std::vector< const int > container; + + container do_nothing(){}; }; } Modified: pygccxml_dev/unittests/vector_traits_tester.py =================================================================== --- pygccxml_dev/unittests/vector_traits_tester.py 2006-06-05 15:16:30 UTC (rev 211) +++ pygccxml_dev/unittests/vector_traits_tester.py 2006-06-05 15:17:25 UTC (rev 212) @@ -35,6 +35,16 @@ value_type = self.global_ns.class_( '_0_' ) container = self.global_ns.typedef( 'container', recursive=False ) self.validate_yes( value_type, container ) + + def test_yes( self ): + yes_ns = self.global_ns.namespace( 'yes' ) + for struct in yes_ns.classes(): + if not struct.name.startswith( '_' ): + continue + if not struct.name.endswith( '_' ): + continue + self.validate_yes( struct.typedef( 'value_type' ) + , struct.typedef( 'container' ) ) def create_suite(): suite = unittest.TestSuite() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |