comparison 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
comparison
equal deleted inserted replaced
4299:3f85db78c441 4300:b30a8de92ad9
84 84
85 85
86 FILES = [] 86 FILES = []
87 COUNT = 0 87 COUNT = 0
88 88
89 def ExploreClass(child, fqn):
90 visible = False
91
92 for i in child.get_children():
93 if (i.kind == clang.cindex.CursorKind.VISIBILITY_ATTR and
94 i.spelling == 'default'):
95 visible = True
96
97 if visible:
98 isPublic = (child.kind == clang.cindex.CursorKind.STRUCT_DECL)
99
100 for i in child.get_children():
101 if i.kind == clang.cindex.CursorKind.CXX_ACCESS_SPEC_DECL:
102 isPublic = (i.access_specifier == clang.cindex.AccessSpecifier.PUBLIC)
103
104 elif (i.kind == clang.cindex.CursorKind.CLASS_DECL or
105 i.kind == clang.cindex.CursorKind.STRUCT_DECL):
106 # This is a subclass
107 ExploreClass(i, fqn + [ i.spelling ])
108
109 elif (i.kind == clang.cindex.CursorKind.CXX_METHOD or
110 i.kind == clang.cindex.CursorKind.CONSTRUCTOR or
111 i.kind == clang.cindex.CursorKind.DESTRUCTOR):
112 if isPublic:
113 hasImplementation = False
114 for j in i.get_children():
115 if j.kind == clang.cindex.CursorKind.COMPOUND_STMT:
116 hasImplementation = True
117
118 if hasImplementation:
119 global FILES, COUNT
120 FILES.append(os.path.normpath(str(child.location.file)))
121 COUNT += 1
122
123 print('Exported public method with an implementation: %s::%s()' %
124 ('::'.join(fqn), i.spelling))
125
126
89 def ExploreNamespace(node, namespace): 127 def ExploreNamespace(node, namespace):
90 for child in node.get_children(): 128 for child in node.get_children():
91 fqn = namespace + [ child.spelling ] 129 fqn = namespace + [ child.spelling ]
92 130
93 if child.kind == clang.cindex.CursorKind.NAMESPACE: 131 if child.kind == clang.cindex.CursorKind.NAMESPACE:
94 ExploreNamespace(child, fqn) 132 ExploreNamespace(child, fqn)
95 133
96 elif (child.kind == clang.cindex.CursorKind.CLASS_DECL or 134 elif (child.kind == clang.cindex.CursorKind.CLASS_DECL or
97 child.kind == clang.cindex.CursorKind.STRUCT_DECL): 135 child.kind == clang.cindex.CursorKind.STRUCT_DECL):
98 visible = False 136 ExploreClass(child, fqn)
99
100 for i in child.get_children():
101 if (i.kind == clang.cindex.CursorKind.VISIBILITY_ATTR and
102 i.spelling == 'default'):
103 visible = True
104
105 if visible:
106 isPublic = (child.kind == clang.cindex.CursorKind.STRUCT_DECL)
107
108 for i in child.get_children():
109 if i.kind == clang.cindex.CursorKind.CXX_ACCESS_SPEC_DECL:
110 isPublic = (i.access_specifier == clang.cindex.AccessSpecifier.PUBLIC)
111
112 elif (i.kind == clang.cindex.CursorKind.CXX_METHOD or
113 i.kind == clang.cindex.CursorKind.CONSTRUCTOR):
114 if isPublic:
115 hasImplementation = False
116 for j in i.get_children():
117 if j.kind == clang.cindex.CursorKind.COMPOUND_STMT:
118 hasImplementation = True
119
120 if hasImplementation:
121 global FILES, COUNT
122 FILES.append(str(child.location.file))
123 COUNT += 1
124
125 print('Exported public method with an implementation: %s::%s()' %
126 ('::'.join(fqn), i.spelling))
127
128 137
129 for node in tu.cursor.get_children(): 138 for node in tu.cursor.get_children():
130 if (node.kind == clang.cindex.CursorKind.NAMESPACE and 139 if (node.kind == clang.cindex.CursorKind.NAMESPACE and
131 node.spelling == 'Orthanc'): 140 node.spelling == 'Orthanc'):
132 ExploreNamespace(node, [ 'Orthanc' ]) 141 ExploreNamespace(node, [ 'Orthanc' ])