annotate OrthancFramework/Resources/CheckOrthancFrameworkSymbols.py @ 4411:1d93700f5e23

typo
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sun, 27 Dec 2020 11:31:50 +0100
parents 85237ae3a076
children d9473bd5ed43
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4277
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 #!/usr/bin/env python
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 # Orthanc - A Lightweight, RESTful DICOM Store
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 # Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 # Department, University Hospital of Liege, Belgium
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 # Copyright (C) 2017-2020 Osimis S.A., Belgium
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 #
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 # This program is free software: you can redistribute it and/or
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 # modify it under the terms of the GNU Lesser General Public License
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 # as published by the Free Software Foundation, either version 3 of
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 # the License, or (at your option) any later version.
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 #
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 # This program is distributed in the hope that it will be useful, but
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 # Lesser General Public License for more details.
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 #
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 # You should have received a copy of the GNU Lesser General Public
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 # License along with this program. If not, see
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 # <http://www.gnu.org/licenses/>.
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 ##
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 ## This maintenance script detects all the public methods in the
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 ## Orthanc framework that come with an inlined implementation in the
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 ## header file. Such methods can break the ABI of the shared library,
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 ## as the actual implementation might change over versions.
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 ##
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 # Ubuntu 20.04:
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 # sudo apt-get install python-clang-6.0
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 # ./ParseWebAssemblyExports.py --libclang=libclang-6.0.so.1 ./Test.cpp
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 # Ubuntu 18.04:
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 # sudo apt-get install python-clang-4.0
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 # ./ParseWebAssemblyExports.py --libclang=libclang-4.0.so.1 ./Test.cpp
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 # Ubuntu 14.04:
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 # ./ParseWebAssemblyExports.py --libclang=libclang-3.6.so.1 ./Test.cpp
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 import os
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 import sys
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 import clang.cindex
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 import argparse
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 ##
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 ## Parse the command-line arguments
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 ##
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 parser = argparse.ArgumentParser(description = 'Parse WebAssembly C++ source file, and create a basic JavaScript wrapper.')
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 parser.add_argument('--libclang',
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 default = '',
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 help = 'manually provides the path to the libclang shared library')
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 args = parser.parse_args()
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 if len(args.libclang) != 0:
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 clang.cindex.Config.set_library_file(args.libclang)
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 index = clang.cindex.Index.create()
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 ROOT = os.path.abspath(os.path.dirname(sys.argv[0]))
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 SOURCES = []
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 for root, dirs, files in os.walk(os.path.join(ROOT, '..', 'Sources')):
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 for name in files:
4305
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4304
diff changeset
71 if (os.path.splitext(name)[1] == '.h' and
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4304
diff changeset
72 name != 'Enumerations_TransferSyntaxes.impl.h'):
4277
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 SOURCES.append(os.path.join(root, name))
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 AMALGAMATION = '/tmp/CheckOrthancFrameworkSymbols.cpp'
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 with open(AMALGAMATION, 'w') as f:
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 f.write('#include "%s"\n' % os.path.join(ROOT, '..', 'Sources', 'OrthancFramework.h'))
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 for source in SOURCES:
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 f.write('#include "%s"\n' % source)
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82
4303
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
83 tu = index.parse(AMALGAMATION, [
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
84 '-DORTHANC_BUILDING_FRAMEWORK_LIBRARY=1',
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
85 '-DORTHANC_BUILD_UNIT_TESTS=0',
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
86 '-DORTHANC_ENABLE_BASE64=1',
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
87 '-DORTHANC_ENABLE_CIVETWEB=1',
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
88 '-DORTHANC_ENABLE_CURL=1',
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
89 '-DORTHANC_ENABLE_DCMTK=1',
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
90 '-DORTHANC_ENABLE_DCMTK_JPEG=1',
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
91 '-DORTHANC_ENABLE_DCMTK_NETWORKING=1',
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
92 '-DORTHANC_ENABLE_DCMTK_TRANSCODING=1',
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
93 '-DORTHANC_ENABLE_JPEG=1',
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
94 '-DORTHANC_ENABLE_LOCALE=1',
4305
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4304
diff changeset
95 '-DORTHANC_ENABLE_LOGGING=1',
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4304
diff changeset
96 '-DORTHANC_ENABLE_LOGGING_STDIO=0',
4303
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
97 '-DORTHANC_ENABLE_LUA=1',
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
98 '-DORTHANC_ENABLE_MD5=1',
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
99 '-DORTHANC_ENABLE_PKCS11=1',
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
100 '-DORTHANC_ENABLE_PNG=1',
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
101 '-DORTHANC_ENABLE_PUGIXML=1',
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
102 '-DORTHANC_ENABLE_SSL=1',
4305
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4304
diff changeset
103 '-DORTHANC_SANDBOXED=0',
4303
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
104 '-DORTHANC_SQLITE_STANDALONE=0',
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
105 ])
4277
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107
4279
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4277
diff changeset
108 FILES = []
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4277
diff changeset
109 COUNT = 0
4277
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110
4303
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
111 def ReportProblem(message, fqn, cursor):
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
112 global FILES, COUNT
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
113 FILES.append(os.path.normpath(str(cursor.location.file)))
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
114 COUNT += 1
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
115
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
116 print('%s: %s::%s()' % (message, '::'.join(fqn), cursor.spelling))
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
117
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
118
4300
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4279
diff changeset
119 def ExploreClass(child, fqn):
4303
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
120 # Safety check
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
121 if (child.kind != clang.cindex.CursorKind.CLASS_DECL and
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
122 child.kind != clang.cindex.CursorKind.STRUCT_DECL):
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
123 raise Exception()
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
124
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
125 # Ignore forward declaration of classes
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
126 if not child.is_definition():
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
127 return
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
128
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
129
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
130 ##
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
131 ## Verify that the class is publicly exported (its visibility must
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
132 ## be "default")
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
133 ##
4300
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4279
diff changeset
134 visible = False
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4279
diff changeset
135
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4279
diff changeset
136 for i in child.get_children():
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4279
diff changeset
137 if (i.kind == clang.cindex.CursorKind.VISIBILITY_ATTR and
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4279
diff changeset
138 i.spelling == 'default'):
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4279
diff changeset
139 visible = True
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4279
diff changeset
140
4303
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
141 if not visible:
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
142 return
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
143
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
144
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
145 ##
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
146 ## Ignore pure abstract interfaces, by checking the following
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
147 ## criteria:
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
148 ## - It must be a C++ class (not a struct)
4310
2ae905070221 renaming pure interface JobOperationValue as IJobOperationValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4305
diff changeset
149 ## - It must start with "I"
4303
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
150 ## - All its methods must be pure virtual (abstract) and public
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
151 ## - Its destructor must be public, virtual, and must do nothing
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
152 ##
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
153
4310
2ae905070221 renaming pure interface JobOperationValue as IJobOperationValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4305
diff changeset
154 if (child.kind == clang.cindex.CursorKind.CLASS_DECL and
2ae905070221 renaming pure interface JobOperationValue as IJobOperationValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4305
diff changeset
155 child.spelling[0] == 'I' and
2ae905070221 renaming pure interface JobOperationValue as IJobOperationValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4305
diff changeset
156 child.spelling[1].isupper()):
4303
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
157 abstract = True
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
158 isPublic = False
4300
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4279
diff changeset
159
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4279
diff changeset
160 for i in child.get_children():
4303
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
161 if i.kind == clang.cindex.CursorKind.VISIBILITY_ATTR: # "default"
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
162 pass
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
163 elif i.kind == clang.cindex.CursorKind.CXX_ACCESS_SPEC_DECL:
4300
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4279
diff changeset
164 isPublic = (i.access_specifier == clang.cindex.AccessSpecifier.PUBLIC)
4303
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
165 elif i.kind == clang.cindex.CursorKind.CXX_BASE_SPECIFIER:
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
166 if i.spelling != 'boost::noncopyable':
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
167 abstract = False
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
168 elif isPublic:
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
169 if i.kind == clang.cindex.CursorKind.CXX_METHOD:
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
170 if i.is_pure_virtual_method():
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
171 pass # pure virtual is ok
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
172 elif i.is_static_method():
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
173 # static method without an inline implementation is ok
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
174 for j in i.get_children():
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
175 if j.kind == clang.cindex.CursorKind.COMPOUND_STMT:
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
176 abstract = False
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
177 else:
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
178 abstract = False
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
179 elif (i.kind == clang.cindex.CursorKind.DESTRUCTOR and
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
180 i.is_virtual_method()):
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
181 # The destructor must be virtual, and must do nothing
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
182 c = list(i.get_children())
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
183 if (len(c) != 1 or
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
184 c[0].kind != clang.cindex.CursorKind.COMPOUND_STMT or
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
185 len(list(c[0].get_children())) != 0):
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
186 abstract = False
4310
2ae905070221 renaming pure interface JobOperationValue as IJobOperationValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4305
diff changeset
187 elif i.kind == clang.cindex.CursorKind.CLASS_DECL:
4303
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
188 ExploreClass(i, fqn + [ i.spelling ])
4304
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4303
diff changeset
189 elif (i.kind == clang.cindex.CursorKind.TYPEDEF_DECL or # Allow "typedef"
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4303
diff changeset
190 i.kind == clang.cindex.CursorKind.ENUM_DECL): # Allow enums
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4303
diff changeset
191 pass
4303
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
192 else:
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
193 abstract = False
4300
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4279
diff changeset
194
4303
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
195 if abstract:
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
196 print('Detected a pure interface (this is fine): %s' % ('::'.join(fqn)))
4310
2ae905070221 renaming pure interface JobOperationValue as IJobOperationValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4305
diff changeset
197 else:
2ae905070221 renaming pure interface JobOperationValue as IJobOperationValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4305
diff changeset
198 ReportProblem('Not a pure interface', fqn, child)
4303
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
199
4310
2ae905070221 renaming pure interface JobOperationValue as IJobOperationValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4305
diff changeset
200 return
2ae905070221 renaming pure interface JobOperationValue as IJobOperationValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4305
diff changeset
201
4303
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
202
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
203 ##
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
204 ## We are facing a standard C++ class or struct
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
205 ##
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
206
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
207 isPublic = (child.kind == clang.cindex.CursorKind.STRUCT_DECL)
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
208
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
209 for i in child.get_children():
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
210 if (i.kind == clang.cindex.CursorKind.VISIBILITY_ATTR or # "default"
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
211 i.kind == clang.cindex.CursorKind.CXX_BASE_SPECIFIER): # base class
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
212 pass
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
213
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
214 elif i.kind == clang.cindex.CursorKind.CXX_ACCESS_SPEC_DECL:
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
215 isPublic = (i.access_specifier == clang.cindex.AccessSpecifier.PUBLIC)
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
216
4310
2ae905070221 renaming pure interface JobOperationValue as IJobOperationValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4305
diff changeset
217 elif i.kind == clang.cindex.CursorKind.CLASS_DECL:
4303
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
218 # This is a subclass
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
219 if isPublic:
4300
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4279
diff changeset
220 ExploreClass(i, fqn + [ i.spelling ])
4303
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
221
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
222 elif (i.kind == clang.cindex.CursorKind.CXX_METHOD or
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
223 i.kind == clang.cindex.CursorKind.CONSTRUCTOR or
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
224 i.kind == clang.cindex.CursorKind.DESTRUCTOR):
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
225 if isPublic:
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
226 hasImplementation = False
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
227 for j in i.get_children():
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
228 if j.kind == clang.cindex.CursorKind.COMPOUND_STMT:
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
229 hasImplementation = True
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
230
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
231 if hasImplementation:
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
232 ReportProblem('Exported public method with an implementation', fqn, i)
4300
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4279
diff changeset
233
4303
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
234 elif i.kind == clang.cindex.CursorKind.VAR_DECL:
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
235 if isPublic:
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
236 ReportProblem('Exported public member variable', fqn, i)
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
237
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
238 elif i.kind == clang.cindex.CursorKind.FUNCTION_TEMPLATE:
4313
91554aecff9a removed a friend method for better abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4310
diff changeset
239 # An inline function template is OK, as it is not added to
91554aecff9a removed a friend method for better abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4310
diff changeset
240 # a shared library, but compiled by the client of the library
4303
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
241 if isPublic:
4313
91554aecff9a removed a friend method for better abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4310
diff changeset
242 print('Detected a template function (this is fine, but avoid it as much as possible): %s' % ('::'.join(fqn + [ i.spelling ])))
91554aecff9a removed a friend method for better abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4310
diff changeset
243 hasImplementation = False
91554aecff9a removed a friend method for better abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4310
diff changeset
244 for j in i.get_children():
91554aecff9a removed a friend method for better abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4310
diff changeset
245 if j.kind == clang.cindex.CursorKind.COMPOUND_STMT:
91554aecff9a removed a friend method for better abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4310
diff changeset
246 hasImplementation = True
4300
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4279
diff changeset
247
4313
91554aecff9a removed a friend method for better abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4310
diff changeset
248 if not hasImplementation:
91554aecff9a removed a friend method for better abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4310
diff changeset
249 ReportProblem('Exported template function without an inline implementation', fqn, i)
91554aecff9a removed a friend method for better abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4310
diff changeset
250
4303
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
251 elif (i.kind == clang.cindex.CursorKind.TYPEDEF_DECL or # Allow "typedef"
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
252 i.kind == clang.cindex.CursorKind.ENUM_DECL): # Allow enums
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
253 pass
4349
85237ae3a076 relax CheckOrthancFrameworkSymbols.py about one friend stream function
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4313
diff changeset
254
85237ae3a076 relax CheckOrthancFrameworkSymbols.py about one friend stream function
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4313
diff changeset
255 elif i.kind == clang.cindex.CursorKind.FRIEND_DECL:
85237ae3a076 relax CheckOrthancFrameworkSymbols.py about one friend stream function
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4313
diff changeset
256 children = list(i.get_children())
85237ae3a076 relax CheckOrthancFrameworkSymbols.py about one friend stream function
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4313
diff changeset
257 if (isPublic and
85237ae3a076 relax CheckOrthancFrameworkSymbols.py about one friend stream function
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4313
diff changeset
258 (len(children) != 1 or
85237ae3a076 relax CheckOrthancFrameworkSymbols.py about one friend stream function
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4313
diff changeset
259 not children[0].displayname in [
85237ae3a076 relax CheckOrthancFrameworkSymbols.py about one friend stream function
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4313
diff changeset
260 # This is supported for ABI compatibility with Orthanc <= 1.8.0
85237ae3a076 relax CheckOrthancFrameworkSymbols.py about one friend stream function
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4313
diff changeset
261 'operator<<(std::ostream &, const Orthanc::DicomTag &)',
85237ae3a076 relax CheckOrthancFrameworkSymbols.py about one friend stream function
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4313
diff changeset
262 ])):
85237ae3a076 relax CheckOrthancFrameworkSymbols.py about one friend stream function
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4313
diff changeset
263 raise Exception('Unsupported: %s, %s' % (i.kind, i.location))
4303
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
264
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
265 else:
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
266 if isPublic:
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
267 raise Exception('Unsupported: %s, %s' % (i.kind, i.location))
4300
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4279
diff changeset
268
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4279
diff changeset
269
4277
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
270 def ExploreNamespace(node, namespace):
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
271 for child in node.get_children():
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
272 fqn = namespace + [ child.spelling ]
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
273
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
274 if child.kind == clang.cindex.CursorKind.NAMESPACE:
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
275 ExploreNamespace(child, fqn)
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
276
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
277 elif (child.kind == clang.cindex.CursorKind.CLASS_DECL or
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
278 child.kind == clang.cindex.CursorKind.STRUCT_DECL):
4300
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4279
diff changeset
279 ExploreClass(child, fqn)
4277
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
280
4305
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4304
diff changeset
281 elif child.kind == clang.cindex.CursorKind.FUNCTION_DECL:
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4304
diff changeset
282 visible = False
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4304
diff changeset
283 hasImplementation = False
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4304
diff changeset
284 for i in child.get_children():
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4304
diff changeset
285 if (i.kind == clang.cindex.CursorKind.VISIBILITY_ATTR and
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4304
diff changeset
286 i.spelling == 'default'):
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4304
diff changeset
287 visible = True
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4304
diff changeset
288 elif i.kind == clang.cindex.CursorKind.COMPOUND_STMT:
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4304
diff changeset
289 hasImplementation = True
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4304
diff changeset
290
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4304
diff changeset
291 if visible and hasImplementation:
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4304
diff changeset
292 ReportProblem('Exported public function with an implementation', fqn, i)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4304
diff changeset
293
4303
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
294
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
295
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
296 print('')
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
297
4277
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
298 for node in tu.cursor.get_children():
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
299 if (node.kind == clang.cindex.CursorKind.NAMESPACE and
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
300 node.spelling == 'Orthanc'):
c5ca798b158a CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
301 ExploreNamespace(node, [ 'Orthanc' ])
4279
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4277
diff changeset
302
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4277
diff changeset
303
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4277
diff changeset
304 print('\nTotal of possibly problematic methods: %d' % COUNT)
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4277
diff changeset
305
4303
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
306 print('\nProblematic files:\n')
4279
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4277
diff changeset
307 for i in sorted(list(set(FILES))):
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4277
diff changeset
308 print(i)
4303
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
309
44b53a2c0a13 improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4300
diff changeset
310 print('')