diff OrthancFramework/Resources/CheckOrthancFrameworkSymbols.py @ 4300:b30a8de92ad9

abi continued
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 05 Nov 2020 19:33:18 +0100
parents ab4d015af660
children 44b53a2c0a13
line wrap: on
line diff
--- a/OrthancFramework/Resources/CheckOrthancFrameworkSymbols.py	Thu Nov 05 18:24:50 2020 +0100
+++ b/OrthancFramework/Resources/CheckOrthancFrameworkSymbols.py	Thu Nov 05 19:33:18 2020 +0100
@@ -86,6 +86,44 @@
 FILES = []
 COUNT = 0
 
+def ExploreClass(child, fqn):
+    visible = False
+
+    for i in child.get_children():
+        if (i.kind == clang.cindex.CursorKind.VISIBILITY_ATTR and
+            i.spelling == 'default'):
+            visible = True
+
+    if visible:
+        isPublic = (child.kind == clang.cindex.CursorKind.STRUCT_DECL)
+
+        for i in child.get_children():
+            if i.kind == clang.cindex.CursorKind.CXX_ACCESS_SPEC_DECL:
+                isPublic = (i.access_specifier == clang.cindex.AccessSpecifier.PUBLIC)
+
+            elif (i.kind == clang.cindex.CursorKind.CLASS_DECL or
+                  i.kind == clang.cindex.CursorKind.STRUCT_DECL):
+                # This is a subclass
+                ExploreClass(i, fqn + [ i.spelling ])
+                
+            elif (i.kind == clang.cindex.CursorKind.CXX_METHOD or
+                  i.kind == clang.cindex.CursorKind.CONSTRUCTOR or
+                  i.kind == clang.cindex.CursorKind.DESTRUCTOR):
+                if isPublic:
+                    hasImplementation = False
+                    for j in i.get_children():
+                        if j.kind == clang.cindex.CursorKind.COMPOUND_STMT:
+                            hasImplementation = True
+
+                    if hasImplementation:
+                        global FILES, COUNT
+                        FILES.append(os.path.normpath(str(child.location.file)))
+                        COUNT += 1
+
+                        print('Exported public method with an implementation: %s::%s()' %
+                              ('::'.join(fqn), i.spelling))
+
+
 def ExploreNamespace(node, namespace):
     for child in node.get_children():
         fqn = namespace + [ child.spelling ]
@@ -95,36 +133,7 @@
 
         elif (child.kind == clang.cindex.CursorKind.CLASS_DECL or
               child.kind == clang.cindex.CursorKind.STRUCT_DECL):
-            visible = False
-            
-            for i in child.get_children():
-                if (i.kind == clang.cindex.CursorKind.VISIBILITY_ATTR and
-                    i.spelling == 'default'):
-                    visible = True
-
-            if visible:
-                isPublic = (child.kind == clang.cindex.CursorKind.STRUCT_DECL)
-                
-                for i in child.get_children():
-                    if i.kind == clang.cindex.CursorKind.CXX_ACCESS_SPEC_DECL:
-                        isPublic = (i.access_specifier == clang.cindex.AccessSpecifier.PUBLIC)
-                        
-                    elif (i.kind == clang.cindex.CursorKind.CXX_METHOD or
-                          i.kind == clang.cindex.CursorKind.CONSTRUCTOR):
-                        if isPublic:
-                            hasImplementation = False
-                            for j in i.get_children():
-                                if j.kind == clang.cindex.CursorKind.COMPOUND_STMT:
-                                    hasImplementation = True
-
-                            if hasImplementation:
-                                global FILES, COUNT
-                                FILES.append(str(child.location.file))
-                                COUNT += 1
-                                
-                                print('Exported public method with an implementation: %s::%s()' %
-                                      ('::'.join(fqn), i.spelling))
-
+            ExploreClass(child, fqn)
 
 for node in tu.cursor.get_children():
     if (node.kind == clang.cindex.CursorKind.NAMESPACE and