[pygccxml-commit] SF.net SVN: pygccxml: [1039] pygccxml_dev
Brought to you by:
mbaas,
roman_yakovenko
From: <rom...@us...> - 2007-05-27 09:18:08
|
Revision: 1039 http://svn.sourceforge.net/pygccxml/?rev=1039&view=rev Author: roman_yakovenko Date: 2007-05-27 02:18:09 -0700 (Sun, 27 May 2007) Log Message: ----------- adding is_calldef_pointer type traits Modified Paths: -------------- pygccxml_dev/pygccxml/declarations/__init__.py pygccxml_dev/pygccxml/declarations/type_traits.py pygccxml_dev/unittests/data/type_traits.hpp pygccxml_dev/unittests/type_traits_tester.py Modified: pygccxml_dev/pygccxml/declarations/__init__.py =================================================================== --- pygccxml_dev/pygccxml/declarations/__init__.py 2007-05-24 09:57:22 UTC (rev 1038) +++ pygccxml_dev/pygccxml/declarations/__init__.py 2007-05-27 09:18:09 UTC (rev 1039) @@ -136,6 +136,7 @@ from type_traits import is_std_wstring from type_traits import is_std_ostream from type_traits import is_std_wostream +from type_traits import is_calldef_pointer from type_traits import is_unary_operator from type_traits import is_binary_operator Modified: pygccxml_dev/pygccxml/declarations/type_traits.py =================================================================== --- pygccxml_dev/pygccxml/declarations/type_traits.py 2007-05-24 09:57:22 UTC (rev 1038) +++ pygccxml_dev/pygccxml/declarations/type_traits.py 2007-05-27 09:18:09 UTC (rev 1039) @@ -154,6 +154,16 @@ , cpptypes.pointer_t , (cpptypes.const_t, cpptypes.volatile_t) ) +def is_calldef_pointer(type): + """returns True, if type represents pointer to free/member function, False otherwise""" + if not is_pointer(type): + return False + nake_type = remove_alias( type ) + nake_type = remove_const( nake_type ) + nake_type = remove_volatile( nake_type ) + return isinstance( nake_type, cpptypes.compound_t ) \ + and isinstance( nake_type.base, cpptypes.calldef_type_t ) + def remove_pointer(type): """removes pointer from the type definition Modified: pygccxml_dev/unittests/data/type_traits.hpp =================================================================== --- pygccxml_dev/unittests/data/type_traits.hpp 2007-05-24 09:57:22 UTC (rev 1038) +++ pygccxml_dev/unittests/data/type_traits.hpp 2007-05-27 09:18:09 UTC (rev 1039) @@ -10,9 +10,10 @@ #include <iostream> #define TYPE_PERMUTATION( BASE, NAME ) \ - typedef BASE NAME##_t; \ - typedef BASE const NAME##_const_t; \ - typedef BASE volatile NAME##_volatile_t; + typedef BASE NAME##_t; \ + typedef BASE const NAME##_const_t; \ + typedef BASE volatile NAME##_volatile_t; \ + typedef BASE const volatile NAME##_const_volatile_t; struct some_struct_t{ void do_smth(); @@ -85,6 +86,31 @@ } } + + +namespace is_calldef_pointer{ + +namespace details{ +struct X{ + void do_smth( int ) const; +}; + +} + +namespace yes{ + typedef void (*ff1)( int, int ); + typedef void ( details::X::*mf1)( int ) const; + + TYPE_PERMUTATION( ff1, ff1_type ); + TYPE_PERMUTATION( mf1, mf1_type ); +} + +namespace no{ + typedef int int_; +} + +} + namespace is_integral{ namespace yes{ Modified: pygccxml_dev/unittests/type_traits_tester.py =================================================================== --- pygccxml_dev/unittests/type_traits_tester.py 2007-05-24 09:57:22 UTC (rev 1038) +++ pygccxml_dev/unittests/type_traits_tester.py 2007-05-27 09:18:09 UTC (rev 1039) @@ -111,6 +111,9 @@ def test_is_std_wostream(self): self.__test_type_category( 'is_std_wostream', declarations.is_std_wostream ) + def test_is_calldef_pointer(self): + self.__test_type_category( 'is_calldef_pointer', declarations.is_calldef_pointer ) + def test_has_trivial_constructor(self): self.__test_type_category( 'has_trivial_constructor', declarations.has_trivial_constructor ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |