[pygccxml-commit] SF.net SVN: pygccxml: [284] pygccxml_dev/unittests
Brought to you by:
mbaas,
roman_yakovenko
From: <rom...@us...> - 2006-07-09 05:31:36
|
Revision: 284 Author: roman_yakovenko Date: 2006-07-08 22:31:25 -0700 (Sat, 08 Jul 2006) ViewCVS: http://svn.sourceforge.net/pygccxml/?rev=284&view=rev Log Message: ----------- fixing has_binary_operator type traits Modified Paths: -------------- pygccxml_dev/pygccxml/declarations/type_traits.py pygccxml_dev/unittests/data/core_cache.hpp pygccxml_dev/unittests/data/has_public_binary_operator_traits.hpp pygccxml_dev/unittests/test_all.py Modified: pygccxml_dev/pygccxml/declarations/type_traits.py =================================================================== --- pygccxml_dev/pygccxml/declarations/type_traits.py 2006-07-09 05:00:25 UTC (rev 283) +++ pygccxml_dev/pygccxml/declarations/type_traits.py 2006-07-09 05:31:25 UTC (rev 284) @@ -14,7 +14,8 @@ Those functions are very valuable for code generation. Almost all functions within this module works on L{type_t} class hierarchy and\\or L{class_t}. """ - + +import filters import typedef import calldef import cpptypes @@ -366,28 +367,44 @@ return bool( constructors ) def has_public_binary_operator( type, operator_symbol ): - symbol = operator_symbol not_artificial = lambda decl: decl.is_artificial == False type = remove_alias( type ) type = remove_cv( type ) type = remove_declarated( type ) - assert isinstance( type, class_declaration.class_t ) - equals = type.member_operators( function=not_artificial, symbol=symbol, allow_empty=True, recursive=False ) - if equals: + assert isinstance( type, class_declaration.class_t ) + + if is_std_string( type ) or is_std_wstring( type ): + #In some case compare operators of std::basic_string are not instantiated + return True + + operators = type.member_operators( function=filters.custom_matcher_t( not_artificial ) \ + & filters.access_type_matcher_t( 'public' ) + , symbol=operator_symbol + , allow_empty=True + , recursive=False ) + if operators: return True t = cpptypes.declarated_t( type ) t = cpptypes.const_t( t ) t = cpptypes.reference_t( t ) - equals = type.parent.operators( function=not_artificial, symbol=symbol, arg_types=[t, None], allow_empty=True, recursive=False ) - if equals: + operators = type.top_parent.operators( function=not_artificial + , arg_types=[t, None] + , symbol=operator_symbol + , allow_empty=True + , recursive=True ) + if operators: return True for bi in type.recursive_bases: assert isinstance( bi, class_declaration.hierarchy_info_t ) if bi.access_type != class_declaration.ACCESS_TYPES.PUBLIC: continue - equals = bi.related_class.member_operators( function=not_artificial, symbol=symbol, allow_empty=True, recursive=False ) - if equals: + operators = bi.related_class.member_operators( function=filters.custom_matcher_t( not_artificial ) \ + & filters.access_type_matcher_t( 'public' ) + , symbol=operator_symbol + , allow_empty=True + , recursive=False ) + if operators: return True return False Modified: pygccxml_dev/unittests/data/core_cache.hpp =================================================================== --- pygccxml_dev/unittests/data/core_cache.hpp 2006-07-09 05:00:25 UTC (rev 283) +++ pygccxml_dev/unittests/data/core_cache.hpp 2006-07-09 05:31:25 UTC (rev 284) @@ -22,4 +22,4 @@ #endif//__core_cache_hpp__ -//touch//touch//touch \ No newline at end of file +//touch//touch//touch//touch \ No newline at end of file Modified: pygccxml_dev/unittests/data/has_public_binary_operator_traits.hpp =================================================================== --- pygccxml_dev/unittests/data/has_public_binary_operator_traits.hpp 2006-07-09 05:00:25 UTC (rev 283) +++ pygccxml_dev/unittests/data/has_public_binary_operator_traits.hpp 2006-07-09 05:31:25 UTC (rev 284) @@ -10,10 +10,6 @@ namespace yes{ typedef std::string yes1; - inline bool instantiate_templ(){ - return std::string( "1" ) == std::string( "2" ); - } - struct trivial{ bool operator==(const trivial& other); }; Modified: pygccxml_dev/unittests/test_all.py =================================================================== --- pygccxml_dev/unittests/test_all.py 2006-07-09 05:00:25 UTC (rev 283) +++ pygccxml_dev/unittests/test_all.py 2006-07-09 05:31:25 UTC (rev 284) @@ -37,6 +37,7 @@ import vector_traits_tester import string_traits_tester import declarations_cache_tester +import has_binary_operator_traits_tester def create_suite(): testers = [ @@ -72,7 +73,8 @@ , unnamed_enums_bug_tester , vector_traits_tester , string_traits_tester - , declarations_cache_tester + , declarations_cache_tester + , has_binary_operator_traits_tester ] main_suite = unittest.TestSuite() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |