[pygccxml-commit] SF.net SVN: pygccxml: [843] pygccxml_dev
Brought to you by:
mbaas,
roman_yakovenko
|
From: <rom...@us...> - 2007-01-04 11:35:11
|
Revision: 843
http://svn.sourceforge.net/pygccxml/?rev=843&view=rev
Author: roman_yakovenko
Date: 2007-01-04 03:35:11 -0800 (Thu, 04 Jan 2007)
Log Message:
-----------
extending is_base_and_derived to take a list of possible derived classes
Modified Paths:
--------------
pygccxml_dev/pygccxml/declarations/type_traits.py
pygccxml_dev/unittests/type_traits_tester.py
Modified: pygccxml_dev/pygccxml/declarations/type_traits.py
===================================================================
--- pygccxml_dev/pygccxml/declarations/type_traits.py 2007-01-04 06:46:32 UTC (rev 842)
+++ pygccxml_dev/pygccxml/declarations/type_traits.py 2007-01-04 11:35:11 UTC (rev 843)
@@ -390,13 +390,20 @@
def is_base_and_derived( based, derived ):
"""returns True, if there is "base and derived" relationship between classes, False otherwise"""
assert isinstance( based, class_declaration.class_t )
- assert isinstance( derived, class_declaration.class_t )
+ assert isinstance( derived, ( class_declaration.class_t, tuple ) )
- for base_desc in derived.recursive_bases:
- if base_desc.related_class == based:
- return True
+ all_derived = None
+ if isinstance( derived, class_declaration.class_t ):
+ all_derived = ( derived )
+ else: #tuple
+ all_derived = derived
+
+ for derived_cls in all_derived:
+ for base_desc in derived_cls.recursive_bases:
+ if base_desc.related_class == based:
+ return True
return False
-
+
def has_any_non_copyconstructor( type):
"""returns True, if class has any non "copy constructor", otherwise False"""
assert isinstance( type, class_declaration.class_t )
Modified: pygccxml_dev/unittests/type_traits_tester.py
===================================================================
--- pygccxml_dev/unittests/type_traits_tester.py 2007-01-04 06:46:32 UTC (rev 842)
+++ pygccxml_dev/unittests/type_traits_tester.py 2007-01-04 11:35:11 UTC (rev 843)
@@ -129,6 +129,7 @@
, type=declarations.class_t
, name='derived' )
self.failUnless( base and derived and declarations.is_base_and_derived( base, derived ) )
+ self.failUnless( base and derived and declarations.is_base_and_derived( base, ( derived, derived ) ) )
unrelated1 = declarations.find_declaration( ns.declarations
, type=declarations.class_t
@@ -232,4 +233,4 @@
unittest.TextTestRunner(verbosity=2).run( create_suite() )
if __name__ == "__main__":
- run_suite()
\ No newline at end of file
+ run_suite()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|