]> git.saurik.com Git - wxWidgets.git/commitdiff
Add the ability to query if a class is derived from another class.
authorKevin Ollivier <kevino@theolliviers.com>
Sat, 2 May 2009 22:20:40 +0000 (22:20 +0000)
committerKevin Ollivier <kevino@theolliviers.com>
Sat, 2 May 2009 22:20:40 +0000 (22:20 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@60489 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/doxygen/doxymlparser.py

index ab6bcd27228f0e621e015743c1d0d92096d8d33c..414cf988d28426574588302201bc8704e045fd72 100755 (executable)
@@ -42,6 +42,12 @@ for opt in option_dict:
 
 options, arguments = parser.parse_args()
 
+def get_first_value(alist):
+    if len(alist) > 0:
+        return alist[0]
+    else:
+        return ""
+
 class ClassDefinition:
     def __init__(self):
         self.name = ""
@@ -114,6 +120,38 @@ class DoxyMLParser:
     def __init__(self):
         self.classes = []
 
+    def find_class(self, name):
+        for aclass in self.classes:
+            if aclass.name == name:
+                return aclass
+                
+        return None
+
+    def get_enums_and_functions(self, filename, aclass):
+        file_path = os.path.dirname(filename)
+        enum_filename = os.path.join(file_path, aclass.name[2:] + "_8h.xml")
+        if os.path.exists(enum_filename):
+            root = minidom.parse(enum_filename).documentElement
+            for method in root.getElementsByTagName("memberdef"):
+                if method.getAttribute("kind") == "enum":
+                    self.parse_enum(aclass, method, root)
+
+    def is_derived_from_base(self, aclass, abase):
+        base = get_first_value(aclass.bases)
+        while base and base != "":
+            
+            if base == abase:
+                return True
+                
+            parentclass = self.find_class(base)
+            
+            if parentclass:
+                base = get_first_value(parentclass.bases)
+            else:
+                base = None
+                
+        return False
+
     def parse(self, filename):
         self.xmldoc = minidom.parse(filename).documentElement
         for node in self.xmldoc.getElementsByTagName("compounddef"):
@@ -139,15 +177,6 @@ class DoxyMLParser:
 
         return new_class
         
-    def get_enums_and_functions(self, filename, aclass):
-        file_path = os.path.dirname(filename)
-        enum_filename = os.path.join(file_path, aclass.name[2:] + "_8h.xml")
-        if os.path.exists(enum_filename):
-            root = minidom.parse(enum_filename).documentElement
-            for method in root.getElementsByTagName("memberdef"):
-                if method.getAttribute("kind") == "enum":
-                    self.parse_enum(aclass, method, root)
-    
     def parse_enum(self, new_class, enum, root):
         enum_name = ""
         enum_values = []