Revision: 242
Author: roman_yakovenko
Date: 2006-06-21 14:57:30 -0700 (Wed, 21 Jun 2006)
ViewCVS: http://svn.sourceforge.net/pygccxml/?rev=242&view=rev
Log Message:
-----------
adding is_class and has_public_equal type traits
Modified Paths:
--------------
pygccxml_dev/pygccxml/declarations/__init__.py
pygccxml_dev/pygccxml/declarations/type_traits.py
Modified: pygccxml_dev/pygccxml/declarations/__init__.py
===================================================================
--- pygccxml_dev/pygccxml/declarations/__init__.py 2006-06-21 19:50:27 UTC (rev 241)
+++ pygccxml_dev/pygccxml/declarations/__init__.py 2006-06-21 21:57:30 UTC (rev 242)
@@ -109,6 +109,7 @@
from type_traits import is_same
from type_traits import is_void
from type_traits import is_void_pointer
+from type_traits import is_class
from type_traits import is_const
from type_traits import base_type
from type_traits import is_array
@@ -140,6 +141,7 @@
from type_traits import has_destructor
from type_traits import has_trivial_copy
+from type_traits import has_public_equal
from type_traits import has_public_assign
from type_traits import has_public_destructor
from type_traits import has_public_constructor
Modified: pygccxml_dev/pygccxml/declarations/type_traits.py
===================================================================
--- pygccxml_dev/pygccxml/declarations/type_traits.py 2006-06-21 19:50:27 UTC (rev 241)
+++ pygccxml_dev/pygccxml/declarations/type_traits.py 2006-06-21 21:57:30 UTC (rev 242)
@@ -280,9 +280,8 @@
nake_type = remove_alias( type )
nake_type = remove_reference( nake_type )
nake_type = remove_cv( nake_type )
-
- return isinstance( nake_type, cpptypes.declarated_t ) \
- and isinstance( nake_type.declaration, class_declaration.class_t )
+ nake_type = remove_declarated( nake_type )
+ return isinstance( nake_type, class_declaration.class_t)
def find_trivial_constructor( type ):
"""returns reference to trivial constructor or None"""
@@ -358,6 +357,32 @@
, type.public_members )
return bool( constructors )
+def has_public_equal( type ):
+ """returns True if class has public operator==, otherwise False"""
+ 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='==', allow_empty=True, recursive=False )
+ if equals:
+ 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='==', arg_types=[t, None], allow_empty=True, recursive=False )
+ if equals:
+ 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='==', allow_empty=True, recursive=False )
+ if equals:
+ return True
+ return False
+
def is_unary_operator( oper ):
"""returns True if operator is unary operator, otherwise False"""
#~ definition:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|