Mercurial > hg > orthanc
annotate OrthancFramework/Resources/CheckOrthancFrameworkSymbols.py @ 5625:d9824edad40a tls-ignore-unexpected-tls
back to BSP195 TLS profile + don't request client certificate if we are not checking it
author | Alain Mazy <am@orthanc.team> |
---|---|
date | Thu, 16 May 2024 15:24:03 +0200 |
parents | 48b8dae6dc77 |
children | f7adfb22e20e |
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 |
5485
48b8dae6dc77
upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
6 # Copyright (C) 2017-2024 Osimis S.A., Belgium |
48b8dae6dc77
upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
7 # Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
4277
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 # |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 # This program is free software: you can redistribute it and/or |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 # modify it under the terms of the GNU Lesser General Public License |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 # as published by the Free Software Foundation, either version 3 of |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 # the License, or (at your option) any later version. |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 # |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 # 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
|
15 # WITHOUT ANY WARRANTY; without even the implied warranty of |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 # Lesser General Public License for more details. |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 # |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 # You should have received a copy of the GNU Lesser General Public |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 # License along with this program. If not, see |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 # <http://www.gnu.org/licenses/>. |
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 ## |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 ## This maintenance script detects all the public methods in the |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 ## Orthanc framework that come with an inlined implementation in the |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 ## header file. Such methods can break the ABI of the shared library, |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 ## as the actual implementation might change over versions. |
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 |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 # Ubuntu 20.04: |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 # sudo apt-get install python-clang-6.0 |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 # ./ParseWebAssemblyExports.py --libclang=libclang-6.0.so.1 ./Test.cpp |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 # Ubuntu 18.04: |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 # sudo apt-get install python-clang-4.0 |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 # ./ParseWebAssemblyExports.py --libclang=libclang-4.0.so.1 ./Test.cpp |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 # Ubuntu 14.04: |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 # ./ParseWebAssemblyExports.py --libclang=libclang-3.6.so.1 ./Test.cpp |
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 |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 import os |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 import sys |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 import clang.cindex |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 import argparse |
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 ## |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 ## Parse the command-line arguments |
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 |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 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
|
54 parser.add_argument('--libclang', |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
55 default = '', |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
56 help = 'manually provides the path to the libclang shared library') |
4520
f5cb0c0ffbed
added unit test OrthancFramework.SizeOf to dump sizeof all the public classes in the Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
57 parser.add_argument('--target-cpp-size', |
f5cb0c0ffbed
added unit test OrthancFramework.SizeOf to dump sizeof all the public classes in the Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
58 default = '', |
f5cb0c0ffbed
added unit test OrthancFramework.SizeOf to dump sizeof all the public classes in the Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
59 help = 'where to store C++ source to display the size of each public class') |
4277
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
61 args = parser.parse_args() |
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 |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
64 if len(args.libclang) != 0: |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
65 clang.cindex.Config.set_library_file(args.libclang) |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
66 |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
67 index = clang.cindex.Index.create() |
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 |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
70 ROOT = os.path.abspath(os.path.dirname(sys.argv[0])) |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
71 SOURCES = [] |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
72 |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
73 for root, dirs, files in os.walk(os.path.join(ROOT, '..', 'Sources')): |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
74 for name in files: |
4305 | 75 if (os.path.splitext(name)[1] == '.h' and |
4537
1de2fc0363cb
sanity checks in CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4520
diff
changeset
|
76 not name.endswith('.impl.h')): |
4277
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
77 SOURCES.append(os.path.join(root, name)) |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
78 |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
79 AMALGAMATION = '/tmp/CheckOrthancFrameworkSymbols.cpp' |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
80 |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
81 with open(AMALGAMATION, 'w') as f: |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
82 f.write('#include "%s"\n' % os.path.join(ROOT, '..', 'Sources', 'OrthancFramework.h')) |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
83 for source in SOURCES: |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
84 f.write('#include "%s"\n' % source) |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
85 |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
86 |
4303
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
87 tu = index.parse(AMALGAMATION, [ |
4537
1de2fc0363cb
sanity checks in CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4520
diff
changeset
|
88 '--std=c++11', |
4303
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
89 '-DORTHANC_BUILDING_FRAMEWORK_LIBRARY=1', |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
90 '-DORTHANC_BUILD_UNIT_TESTS=0', |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
91 '-DORTHANC_ENABLE_BASE64=1', |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
92 '-DORTHANC_ENABLE_CIVETWEB=1', |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
93 '-DORTHANC_ENABLE_CURL=1', |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
94 '-DORTHANC_ENABLE_DCMTK=1', |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
95 '-DORTHANC_ENABLE_DCMTK_JPEG=1', |
4537
1de2fc0363cb
sanity checks in CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4520
diff
changeset
|
96 '-DORTHANC_ENABLE_DCMTK_JPEG_LOSSLESS=1', |
4303
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
97 '-DORTHANC_ENABLE_DCMTK_NETWORKING=1', |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
98 '-DORTHANC_ENABLE_DCMTK_TRANSCODING=1', |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
99 '-DORTHANC_ENABLE_JPEG=1', |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
100 '-DORTHANC_ENABLE_LOCALE=1', |
4305 | 101 '-DORTHANC_ENABLE_LOGGING=1', |
102 '-DORTHANC_ENABLE_LOGGING_STDIO=0', | |
4303
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
103 '-DORTHANC_ENABLE_LUA=1', |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
104 '-DORTHANC_ENABLE_MD5=1', |
4537
1de2fc0363cb
sanity checks in CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4520
diff
changeset
|
105 '-DORTHANC_ENABLE_MONGOOSE=1', |
4303
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
106 '-DORTHANC_ENABLE_PKCS11=1', |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
107 '-DORTHANC_ENABLE_PNG=1', |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
108 '-DORTHANC_ENABLE_PUGIXML=1', |
4537
1de2fc0363cb
sanity checks in CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4520
diff
changeset
|
109 '-DORTHANC_ENABLE_SQLITE=1', |
4303
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
110 '-DORTHANC_ENABLE_SSL=1', |
4537
1de2fc0363cb
sanity checks in CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4520
diff
changeset
|
111 '-DORTHANC_ENABLE_ZLIB=1', |
4305 | 112 '-DORTHANC_SANDBOXED=0', |
4303
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
113 '-DORTHANC_SQLITE_STANDALONE=0', |
4537
1de2fc0363cb
sanity checks in CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4520
diff
changeset
|
114 '-DORTHANC_SQLITE_VERSION=3027001', |
1de2fc0363cb
sanity checks in CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4520
diff
changeset
|
115 '-I/usr/include/jsoncpp', # On Ubuntu 18.04 |
1de2fc0363cb
sanity checks in CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4520
diff
changeset
|
116 '-I/usr/include/lua5.3', # On Ubuntu 18.04 |
4303
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
117 ]) |
4277
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
118 |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
119 |
4537
1de2fc0363cb
sanity checks in CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4520
diff
changeset
|
120 if len(tu.diagnostics) != 0: |
1de2fc0363cb
sanity checks in CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4520
diff
changeset
|
121 for d in tu.diagnostics: |
1de2fc0363cb
sanity checks in CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4520
diff
changeset
|
122 print(' ** %s' % d) |
1de2fc0363cb
sanity checks in CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4520
diff
changeset
|
123 print('') |
1de2fc0363cb
sanity checks in CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4520
diff
changeset
|
124 raise Exception('Error') |
1de2fc0363cb
sanity checks in CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4520
diff
changeset
|
125 |
1de2fc0363cb
sanity checks in CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4520
diff
changeset
|
126 |
1de2fc0363cb
sanity checks in CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4520
diff
changeset
|
127 |
4279
ab4d015af660
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4277
diff
changeset
|
128 FILES = [] |
ab4d015af660
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4277
diff
changeset
|
129 COUNT = 0 |
4520
f5cb0c0ffbed
added unit test OrthancFramework.SizeOf to dump sizeof all the public classes in the Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
130 ALL_TYPES = [] |
4277
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
131 |
4303
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
132 def ReportProblem(message, fqn, cursor): |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
133 global FILES, COUNT |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
134 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
|
135 COUNT += 1 |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
136 |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
137 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
|
138 |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
139 |
4300 | 140 def ExploreClass(child, fqn): |
4303
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
141 # Safety check |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
142 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
|
143 child.kind != clang.cindex.CursorKind.STRUCT_DECL): |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
144 raise Exception() |
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 forward declaration of classes |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
147 if not child.is_definition(): |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
148 return |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
149 |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
150 |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
151 ## |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
152 ## 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
|
153 ## be "default") |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
154 ## |
4300 | 155 visible = False |
156 | |
157 for i in child.get_children(): | |
158 if (i.kind == clang.cindex.CursorKind.VISIBILITY_ATTR and | |
159 i.spelling == 'default'): | |
160 visible = True | |
161 | |
4303
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
162 if not visible: |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
163 return |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
164 |
4520
f5cb0c0ffbed
added unit test OrthancFramework.SizeOf to dump sizeof all the public classes in the Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
165 global ALL_TYPES |
f5cb0c0ffbed
added unit test OrthancFramework.SizeOf to dump sizeof all the public classes in the Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
166 ALL_TYPES.append('::'.join(fqn)) |
f5cb0c0ffbed
added unit test OrthancFramework.SizeOf to dump sizeof all the public classes in the Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
167 |
4303
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
168 |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
169 ## |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
170 ## Ignore pure abstract interfaces, by checking the following |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
171 ## criteria: |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
172 ## - 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
|
173 ## - It must start with "I" |
4303
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
174 ## - 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
|
175 ## - 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
|
176 ## |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
177 |
4310
2ae905070221
renaming pure interface JobOperationValue as IJobOperationValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4305
diff
changeset
|
178 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
|
179 child.spelling[0] == 'I' and |
2ae905070221
renaming pure interface JobOperationValue as IJobOperationValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4305
diff
changeset
|
180 child.spelling[1].isupper()): |
4303
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
181 abstract = True |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
182 isPublic = False |
4300 | 183 |
184 for i in child.get_children(): | |
4303
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
185 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
|
186 pass |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
187 elif i.kind == clang.cindex.CursorKind.CXX_ACCESS_SPEC_DECL: |
4300 | 188 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
|
189 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
|
190 if i.spelling != 'boost::noncopyable': |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
191 abstract = False |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
192 elif isPublic: |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
193 if i.kind == clang.cindex.CursorKind.CXX_METHOD: |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
194 if i.is_pure_virtual_method(): |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
195 pass # pure virtual is ok |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
196 elif i.is_static_method(): |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
197 # static method without an inline implementation is ok |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
198 for j in i.get_children(): |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
199 if j.kind == clang.cindex.CursorKind.COMPOUND_STMT: |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
200 abstract = False |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
201 else: |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
202 abstract = False |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
203 elif (i.kind == clang.cindex.CursorKind.DESTRUCTOR and |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
204 i.is_virtual_method()): |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
205 # 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
|
206 c = list(i.get_children()) |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
207 if (len(c) != 1 or |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
208 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
|
209 len(list(c[0].get_children())) != 0): |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
210 abstract = False |
4310
2ae905070221
renaming pure interface JobOperationValue as IJobOperationValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4305
diff
changeset
|
211 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
|
212 ExploreClass(i, fqn + [ i.spelling ]) |
4304 | 213 elif (i.kind == clang.cindex.CursorKind.TYPEDEF_DECL or # Allow "typedef" |
214 i.kind == clang.cindex.CursorKind.ENUM_DECL): # Allow enums | |
215 pass | |
4303
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
216 else: |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
217 abstract = False |
4300 | 218 |
4303
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
219 if abstract: |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
220 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
|
221 else: |
2ae905070221
renaming pure interface JobOperationValue as IJobOperationValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4305
diff
changeset
|
222 ReportProblem('Not a pure interface', fqn, child) |
4303
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
223 |
4310
2ae905070221
renaming pure interface JobOperationValue as IJobOperationValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4305
diff
changeset
|
224 return |
2ae905070221
renaming pure interface JobOperationValue as IJobOperationValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4305
diff
changeset
|
225 |
4303
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
226 |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
227 ## |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
228 ## 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
|
229 ## |
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 isPublic = (child.kind == clang.cindex.CursorKind.STRUCT_DECL) |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
232 |
4520
f5cb0c0ffbed
added unit test OrthancFramework.SizeOf to dump sizeof all the public classes in the Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
233 membersCount = 0 |
f5cb0c0ffbed
added unit test OrthancFramework.SizeOf to dump sizeof all the public classes in the Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
234 membersSize = 0 |
f5cb0c0ffbed
added unit test OrthancFramework.SizeOf to dump sizeof all the public classes in the Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
235 |
4303
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
236 for i in child.get_children(): |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
237 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
|
238 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
|
239 pass |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
240 |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
241 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
|
242 isPublic = (i.access_specifier == clang.cindex.AccessSpecifier.PUBLIC) |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
243 |
4310
2ae905070221
renaming pure interface JobOperationValue as IJobOperationValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4305
diff
changeset
|
244 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
|
245 # This is a subclass |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
246 if isPublic: |
4300 | 247 ExploreClass(i, fqn + [ i.spelling ]) |
4303
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
248 |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
249 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
|
250 i.kind == clang.cindex.CursorKind.CONSTRUCTOR or |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
251 i.kind == clang.cindex.CursorKind.DESTRUCTOR): |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
252 if isPublic: |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
253 hasImplementation = False |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
254 for j in i.get_children(): |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
255 if j.kind == clang.cindex.CursorKind.COMPOUND_STMT: |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
256 hasImplementation = True |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
257 |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
258 if hasImplementation: |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
259 ReportProblem('Exported public method with an implementation', fqn, i) |
4300 | 260 |
4303
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
261 elif i.kind == clang.cindex.CursorKind.VAR_DECL: |
4520
f5cb0c0ffbed
added unit test OrthancFramework.SizeOf to dump sizeof all the public classes in the Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
262 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
|
263 |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
264 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
|
265 # 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
|
266 # 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
|
267 if isPublic: |
4313
91554aecff9a
removed a friend method for better abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4310
diff
changeset
|
268 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
|
269 hasImplementation = False |
91554aecff9a
removed a friend method for better abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4310
diff
changeset
|
270 for j in i.get_children(): |
91554aecff9a
removed a friend method for better abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4310
diff
changeset
|
271 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
|
272 hasImplementation = True |
4300 | 273 |
4313
91554aecff9a
removed a friend method for better abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4310
diff
changeset
|
274 if not hasImplementation: |
91554aecff9a
removed a friend method for better abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4310
diff
changeset
|
275 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
|
276 |
4303
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
277 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
|
278 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
|
279 pass |
4349
85237ae3a076
relax CheckOrthancFrameworkSymbols.py about one friend stream function
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4313
diff
changeset
|
280 |
85237ae3a076
relax CheckOrthancFrameworkSymbols.py about one friend stream function
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4313
diff
changeset
|
281 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
|
282 children = list(i.get_children()) |
85237ae3a076
relax CheckOrthancFrameworkSymbols.py about one friend stream function
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4313
diff
changeset
|
283 if (isPublic and |
85237ae3a076
relax CheckOrthancFrameworkSymbols.py about one friend stream function
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4313
diff
changeset
|
284 (len(children) != 1 or |
85237ae3a076
relax CheckOrthancFrameworkSymbols.py about one friend stream function
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4313
diff
changeset
|
285 not children[0].displayname in [ |
85237ae3a076
relax CheckOrthancFrameworkSymbols.py about one friend stream function
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4313
diff
changeset
|
286 # 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
|
287 '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
|
288 ])): |
85237ae3a076
relax CheckOrthancFrameworkSymbols.py about one friend stream function
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4313
diff
changeset
|
289 raise Exception('Unsupported: %s, %s' % (i.kind, i.location)) |
4520
f5cb0c0ffbed
added unit test OrthancFramework.SizeOf to dump sizeof all the public classes in the Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
290 |
f5cb0c0ffbed
added unit test OrthancFramework.SizeOf to dump sizeof all the public classes in the Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
291 elif i.kind == clang.cindex.CursorKind.FIELD_DECL: |
f5cb0c0ffbed
added unit test OrthancFramework.SizeOf to dump sizeof all the public classes in the Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
292 # TODO |
f5cb0c0ffbed
added unit test OrthancFramework.SizeOf to dump sizeof all the public classes in the Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
293 if i.type.get_size() > 0: |
f5cb0c0ffbed
added unit test OrthancFramework.SizeOf to dump sizeof all the public classes in the Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
294 membersSize += i.type.get_size() |
f5cb0c0ffbed
added unit test OrthancFramework.SizeOf to dump sizeof all the public classes in the Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
295 membersCount += 1 |
4303
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
296 |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
297 else: |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
298 if isPublic: |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
299 raise Exception('Unsupported: %s, %s' % (i.kind, i.location)) |
4300 | 300 |
4520
f5cb0c0ffbed
added unit test OrthancFramework.SizeOf to dump sizeof all the public classes in the Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
301 #print('Size of %s => (%d,%d)' % ('::'.join(fqn), membersCount, membersSize)) |
f5cb0c0ffbed
added unit test OrthancFramework.SizeOf to dump sizeof all the public classes in the Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
302 |
4300 | 303 |
4277
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
304 def ExploreNamespace(node, namespace): |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
305 for child in node.get_children(): |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
306 fqn = namespace + [ child.spelling ] |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
307 |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
308 if child.kind == clang.cindex.CursorKind.NAMESPACE: |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
309 ExploreNamespace(child, fqn) |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
310 |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
311 elif (child.kind == clang.cindex.CursorKind.CLASS_DECL or |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
312 child.kind == clang.cindex.CursorKind.STRUCT_DECL): |
4300 | 313 ExploreClass(child, fqn) |
4277
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
314 |
4305 | 315 elif child.kind == clang.cindex.CursorKind.FUNCTION_DECL: |
316 visible = False | |
317 hasImplementation = False | |
318 for i in child.get_children(): | |
319 if (i.kind == clang.cindex.CursorKind.VISIBILITY_ATTR and | |
320 i.spelling == 'default'): | |
321 visible = True | |
322 elif i.kind == clang.cindex.CursorKind.COMPOUND_STMT: | |
323 hasImplementation = True | |
324 | |
325 if visible and hasImplementation: | |
326 ReportProblem('Exported public function with an implementation', fqn, i) | |
327 | |
4303
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
328 |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
329 |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
330 print('') |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
331 |
4277
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
332 for node in tu.cursor.get_children(): |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
333 if (node.kind == clang.cindex.CursorKind.NAMESPACE and |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
334 node.spelling == 'Orthanc'): |
c5ca798b158a
CheckOrthancFrameworkSymbols.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
335 ExploreNamespace(node, [ 'Orthanc' ]) |
4279
ab4d015af660
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4277
diff
changeset
|
336 |
ab4d015af660
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4277
diff
changeset
|
337 |
4520
f5cb0c0ffbed
added unit test OrthancFramework.SizeOf to dump sizeof all the public classes in the Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
338 if args.target_cpp_size != '': |
f5cb0c0ffbed
added unit test OrthancFramework.SizeOf to dump sizeof all the public classes in the Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
339 with open(args.target_cpp_size, 'w') as f: |
f5cb0c0ffbed
added unit test OrthancFramework.SizeOf to dump sizeof all the public classes in the Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
340 for t in sorted(ALL_TYPES): |
f5cb0c0ffbed
added unit test OrthancFramework.SizeOf to dump sizeof all the public classes in the Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
341 f.write(' printf("sizeof(::%s) == %%d\\n", static_cast<int>(sizeof(::%s)));\n' % (t, t)) |
f5cb0c0ffbed
added unit test OrthancFramework.SizeOf to dump sizeof all the public classes in the Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
342 |
f5cb0c0ffbed
added unit test OrthancFramework.SizeOf to dump sizeof all the public classes in the Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
343 |
4279
ab4d015af660
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4277
diff
changeset
|
344 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
|
345 |
4303
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
346 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
|
347 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
|
348 print(i) |
4303
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
349 |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
350 print('') |