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