Mercurial > hg > orthanc-python
annotate CodeAnalysis/ParseOrthancSDK.py @ 158:5adf2e1186ab OrthancPython-4.2
4.2
author | Alain Mazy <am@orthanc.team> |
---|---|
date | Thu, 16 May 2024 12:21:18 +0200 |
parents | 71d305c29cfa |
children | 6fada29b6759 |
rev | line source |
---|---|
140
b6835b7a7c0a
code generation on Ubuntu 22.04
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
1 #!/usr/bin/env python3 |
0 | 2 |
3 ## | |
4 ## Python plugin for Orthanc | |
155
71d305c29cfa
updated year to 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
141
diff
changeset
|
5 ## Copyright (C) 2020-2024 Osimis S.A., Belgium |
71d305c29cfa
updated year to 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
141
diff
changeset
|
6 ## Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
0 | 7 ## |
8 ## This program is free software: you can redistribute it and/or | |
9 ## modify it under the terms of the GNU Affero General Public License | |
10 ## as published by the Free Software Foundation, either version 3 of | |
11 ## the License, or (at your option) any later version. | |
12 ## | |
13 ## This program is distributed in the hope that it will be useful, but | |
14 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 ## Affero General Public License for more details. | |
17 ## | |
18 ## You should have received a copy of the GNU Affero General Public License | |
19 ## along with this program. If not, see <http://www.gnu.org/licenses/>. | |
20 ## | |
21 | |
22 | |
23 import argparse | |
24 import clang.cindex | |
138
3e89d1c4f721
export the code model as json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
25 import json |
0 | 26 import os |
27 import pprint | |
28 import pystache | |
29 import sys | |
30 | |
31 | |
32 ROOT = os.path.dirname(os.path.realpath(sys.argv[0])) | |
33 | |
34 | |
35 ## | |
63
32de70a1e4c7
New functions from the SDK wrapped in Python: CreateDicom, RegisterFindCallback, RegisterMoveCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
56
diff
changeset
|
36 ## Configuration of the custom primitives that are manually |
32de70a1e4c7
New functions from the SDK wrapped in Python: CreateDicom, RegisterFindCallback, RegisterMoveCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
56
diff
changeset
|
37 ## implemented (not autogenerated) |
32de70a1e4c7
New functions from the SDK wrapped in Python: CreateDicom, RegisterFindCallback, RegisterMoveCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
56
diff
changeset
|
38 ## |
32de70a1e4c7
New functions from the SDK wrapped in Python: CreateDicom, RegisterFindCallback, RegisterMoveCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
56
diff
changeset
|
39 |
65
4da5ce3468b4
new wrapped functions: CreateImageFromBuffer(), DicomInstance.GetInstanceData() and Image.GetImageBuffer()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
64
diff
changeset
|
40 CUSTOM_FUNCTIONS = set([ |
63
32de70a1e4c7
New functions from the SDK wrapped in Python: CreateDicom, RegisterFindCallback, RegisterMoveCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
56
diff
changeset
|
41 'OrthancPluginCreateDicom', |
65
4da5ce3468b4
new wrapped functions: CreateImageFromBuffer(), DicomInstance.GetInstanceData() and Image.GetImageBuffer()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
64
diff
changeset
|
42 'OrthancPluginCreateImageAccessor', # Replaced by "orthanc.CreateImageFromBuffer()" |
63
32de70a1e4c7
New functions from the SDK wrapped in Python: CreateDicom, RegisterFindCallback, RegisterMoveCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
56
diff
changeset
|
43 'OrthancPluginFreeMemoryBuffer', |
32de70a1e4c7
New functions from the SDK wrapped in Python: CreateDicom, RegisterFindCallback, RegisterMoveCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
56
diff
changeset
|
44 'OrthancPluginFreeString', |
66
6fc445793796
new wrapped function: orthanc.LookupDictionary()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
65
diff
changeset
|
45 'OrthancPluginLookupDictionary', |
63
32de70a1e4c7
New functions from the SDK wrapped in Python: CreateDicom, RegisterFindCallback, RegisterMoveCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
56
diff
changeset
|
46 'OrthancPluginRegisterFindCallback', |
32de70a1e4c7
New functions from the SDK wrapped in Python: CreateDicom, RegisterFindCallback, RegisterMoveCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
56
diff
changeset
|
47 'OrthancPluginRegisterIncomingHttpRequestFilter', # Implemented through v2 |
32de70a1e4c7
New functions from the SDK wrapped in Python: CreateDicom, RegisterFindCallback, RegisterMoveCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
56
diff
changeset
|
48 'OrthancPluginRegisterIncomingHttpRequestFilter2', |
32de70a1e4c7
New functions from the SDK wrapped in Python: CreateDicom, RegisterFindCallback, RegisterMoveCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
56
diff
changeset
|
49 'OrthancPluginRegisterMoveCallback', |
32de70a1e4c7
New functions from the SDK wrapped in Python: CreateDicom, RegisterFindCallback, RegisterMoveCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
56
diff
changeset
|
50 'OrthancPluginRegisterOnChangeCallback', |
32de70a1e4c7
New functions from the SDK wrapped in Python: CreateDicom, RegisterFindCallback, RegisterMoveCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
56
diff
changeset
|
51 'OrthancPluginRegisterOnStoredInstanceCallback', |
32de70a1e4c7
New functions from the SDK wrapped in Python: CreateDicom, RegisterFindCallback, RegisterMoveCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
56
diff
changeset
|
52 'OrthancPluginRegisterRestCallback', # Implemented using OrthancPlugins::RegisterRestCallback |
32de70a1e4c7
New functions from the SDK wrapped in Python: CreateDicom, RegisterFindCallback, RegisterMoveCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
56
diff
changeset
|
53 'OrthancPluginRegisterRestCallbackNoLock', # Implemented using OrthancPlugins::RegisterRestCallback |
64
091fb1903bfc
new wrapped function: orthanc.RegisterWorklistCallback() and orthanc.WorklistAnswers.WorklistAddAnswer()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
54 'OrthancPluginRegisterWorklistCallback', |
96
627b8a19fb9f
orthanc.RegisterIncomingCStoreInstanceFilter()
Alain Mazy <am@osimis.io>
parents:
66
diff
changeset
|
55 'OrthancPluginRegisterIncomingCStoreInstanceFilter', |
65
4da5ce3468b4
new wrapped functions: CreateImageFromBuffer(), DicomInstance.GetInstanceData() and Image.GetImageBuffer()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
64
diff
changeset
|
56 ]) |
63
32de70a1e4c7
New functions from the SDK wrapped in Python: CreateDicom, RegisterFindCallback, RegisterMoveCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
56
diff
changeset
|
57 |
32de70a1e4c7
New functions from the SDK wrapped in Python: CreateDicom, RegisterFindCallback, RegisterMoveCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
56
diff
changeset
|
58 CUSTOM_METHODS = [ |
32de70a1e4c7
New functions from the SDK wrapped in Python: CreateDicom, RegisterFindCallback, RegisterMoveCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
56
diff
changeset
|
59 { |
32de70a1e4c7
New functions from the SDK wrapped in Python: CreateDicom, RegisterFindCallback, RegisterMoveCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
56
diff
changeset
|
60 'class_name' : 'OrthancPluginFindQuery', |
32de70a1e4c7
New functions from the SDK wrapped in Python: CreateDicom, RegisterFindCallback, RegisterMoveCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
56
diff
changeset
|
61 'method_name' : 'GetFindQueryTagGroup', |
32de70a1e4c7
New functions from the SDK wrapped in Python: CreateDicom, RegisterFindCallback, RegisterMoveCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
56
diff
changeset
|
62 'implementation' : 'GetFindQueryTagGroup', |
32de70a1e4c7
New functions from the SDK wrapped in Python: CreateDicom, RegisterFindCallback, RegisterMoveCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
56
diff
changeset
|
63 'sdk_function' : 'OrthancPluginGetFindQueryTag', |
32de70a1e4c7
New functions from the SDK wrapped in Python: CreateDicom, RegisterFindCallback, RegisterMoveCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
56
diff
changeset
|
64 }, |
32de70a1e4c7
New functions from the SDK wrapped in Python: CreateDicom, RegisterFindCallback, RegisterMoveCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
56
diff
changeset
|
65 { |
32de70a1e4c7
New functions from the SDK wrapped in Python: CreateDicom, RegisterFindCallback, RegisterMoveCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
56
diff
changeset
|
66 'class_name' : 'OrthancPluginFindQuery', |
32de70a1e4c7
New functions from the SDK wrapped in Python: CreateDicom, RegisterFindCallback, RegisterMoveCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
56
diff
changeset
|
67 'method_name' : 'GetFindQueryTagElement', |
32de70a1e4c7
New functions from the SDK wrapped in Python: CreateDicom, RegisterFindCallback, RegisterMoveCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
56
diff
changeset
|
68 'implementation' : 'GetFindQueryTagElement', |
32de70a1e4c7
New functions from the SDK wrapped in Python: CreateDicom, RegisterFindCallback, RegisterMoveCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
56
diff
changeset
|
69 'sdk_function' : 'OrthancPluginGetFindQueryTag', |
32de70a1e4c7
New functions from the SDK wrapped in Python: CreateDicom, RegisterFindCallback, RegisterMoveCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
56
diff
changeset
|
70 }, |
64
091fb1903bfc
new wrapped function: orthanc.RegisterWorklistCallback() and orthanc.WorklistAnswers.WorklistAddAnswer()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
71 { |
091fb1903bfc
new wrapped function: orthanc.RegisterWorklistCallback() and orthanc.WorklistAnswers.WorklistAddAnswer()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
72 'class_name' : 'OrthancPluginWorklistAnswers', |
091fb1903bfc
new wrapped function: orthanc.RegisterWorklistCallback() and orthanc.WorklistAnswers.WorklistAddAnswer()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
73 'method_name' : 'WorklistAddAnswer', |
091fb1903bfc
new wrapped function: orthanc.RegisterWorklistCallback() and orthanc.WorklistAnswers.WorklistAddAnswer()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
74 'implementation' : 'WorklistAddAnswer', |
091fb1903bfc
new wrapped function: orthanc.RegisterWorklistCallback() and orthanc.WorklistAnswers.WorklistAddAnswer()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
75 'sdk_function' : 'OrthancPluginWorklistAddAnswer', |
091fb1903bfc
new wrapped function: orthanc.RegisterWorklistCallback() and orthanc.WorklistAnswers.WorklistAddAnswer()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
76 }, |
65
4da5ce3468b4
new wrapped functions: CreateImageFromBuffer(), DicomInstance.GetInstanceData() and Image.GetImageBuffer()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
64
diff
changeset
|
77 { |
4da5ce3468b4
new wrapped functions: CreateImageFromBuffer(), DicomInstance.GetInstanceData() and Image.GetImageBuffer()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
64
diff
changeset
|
78 'class_name' : 'OrthancPluginDicomInstance', |
4da5ce3468b4
new wrapped functions: CreateImageFromBuffer(), DicomInstance.GetInstanceData() and Image.GetImageBuffer()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
64
diff
changeset
|
79 'method_name' : 'GetInstanceData', |
4da5ce3468b4
new wrapped functions: CreateImageFromBuffer(), DicomInstance.GetInstanceData() and Image.GetImageBuffer()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
64
diff
changeset
|
80 'implementation' : 'GetInstanceData', |
4da5ce3468b4
new wrapped functions: CreateImageFromBuffer(), DicomInstance.GetInstanceData() and Image.GetImageBuffer()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
64
diff
changeset
|
81 'sdk_function' : 'OrthancPluginGetInstanceData', |
4da5ce3468b4
new wrapped functions: CreateImageFromBuffer(), DicomInstance.GetInstanceData() and Image.GetImageBuffer()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
64
diff
changeset
|
82 }, |
4da5ce3468b4
new wrapped functions: CreateImageFromBuffer(), DicomInstance.GetInstanceData() and Image.GetImageBuffer()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
64
diff
changeset
|
83 { |
4da5ce3468b4
new wrapped functions: CreateImageFromBuffer(), DicomInstance.GetInstanceData() and Image.GetImageBuffer()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
64
diff
changeset
|
84 'class_name' : 'OrthancPluginImage', |
4da5ce3468b4
new wrapped functions: CreateImageFromBuffer(), DicomInstance.GetInstanceData() and Image.GetImageBuffer()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
64
diff
changeset
|
85 'method_name' : 'GetImageBuffer', |
4da5ce3468b4
new wrapped functions: CreateImageFromBuffer(), DicomInstance.GetInstanceData() and Image.GetImageBuffer()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
64
diff
changeset
|
86 'implementation' : 'GetImageBuffer', |
4da5ce3468b4
new wrapped functions: CreateImageFromBuffer(), DicomInstance.GetInstanceData() and Image.GetImageBuffer()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
64
diff
changeset
|
87 'sdk_function' : 'OrthancPluginGetImageBuffer', |
4da5ce3468b4
new wrapped functions: CreateImageFromBuffer(), DicomInstance.GetInstanceData() and Image.GetImageBuffer()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
64
diff
changeset
|
88 }, |
63
32de70a1e4c7
New functions from the SDK wrapped in Python: CreateDicom, RegisterFindCallback, RegisterMoveCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
56
diff
changeset
|
89 ] |
32de70a1e4c7
New functions from the SDK wrapped in Python: CreateDicom, RegisterFindCallback, RegisterMoveCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
56
diff
changeset
|
90 |
65
4da5ce3468b4
new wrapped functions: CreateImageFromBuffer(), DicomInstance.GetInstanceData() and Image.GetImageBuffer()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
64
diff
changeset
|
91 for method in CUSTOM_METHODS: |
4da5ce3468b4
new wrapped functions: CreateImageFromBuffer(), DicomInstance.GetInstanceData() and Image.GetImageBuffer()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
64
diff
changeset
|
92 CUSTOM_FUNCTIONS.add(method['sdk_function']) |
4da5ce3468b4
new wrapped functions: CreateImageFromBuffer(), DicomInstance.GetInstanceData() and Image.GetImageBuffer()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
64
diff
changeset
|
93 |
63
32de70a1e4c7
New functions from the SDK wrapped in Python: CreateDicom, RegisterFindCallback, RegisterMoveCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
56
diff
changeset
|
94 |
32de70a1e4c7
New functions from the SDK wrapped in Python: CreateDicom, RegisterFindCallback, RegisterMoveCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
56
diff
changeset
|
95 ## |
0 | 96 ## Parse the command-line arguments |
97 ## | |
98 | |
99 parser = argparse.ArgumentParser(description = 'Parse the Orthanc SDK.') | |
100 parser.add_argument('--libclang', | |
101 default = 'libclang-4.0.so.1', | |
102 help = 'manually provides the path to the libclang shared library') | |
103 parser.add_argument('--source', | |
104 default = os.path.join(os.path.dirname(__file__), | |
108
2389ec6ec803
preparing for release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
101
diff
changeset
|
105 '../Resources/Orthanc/Sdk-1.10.0/orthanc/OrthancCPlugin.h'), |
0 | 106 help = 'Input C++ file') |
107 parser.add_argument('--target', | |
108 default = os.path.join(os.path.dirname(__file__), | |
109 '../Sources/Autogenerated'), | |
110 help = 'Target folder') | |
111 | |
112 args = parser.parse_args() | |
113 | |
114 | |
115 | |
116 if len(args.libclang) != 0: | |
117 clang.cindex.Config.set_library_file(args.libclang) | |
118 | |
119 index = clang.cindex.Index.create() | |
120 | |
121 tu = index.parse(args.source, [ ]) | |
122 | |
123 TARGET = os.path.realpath(args.target) | |
124 | |
125 | |
126 | |
127 def ToUpperCase(name): | |
128 s = '' | |
129 for i in range(len(name)): | |
130 if name[i].isupper(): | |
131 if len(s) == 0: | |
132 s += name[i] | |
133 elif name[i - 1].islower(): | |
134 s += '_' + name[i] | |
135 elif (i + 1 < len(name) and | |
136 name[i - 1].islower() and | |
137 name[i + 1].isupper()): | |
138 s += '_' + name[i] | |
139 else: | |
140 s += name[i] | |
141 else: | |
142 s += name[i].upper() | |
143 return s | |
144 | |
145 | |
146 | |
147 with open(os.path.join(ROOT, 'Enumeration.mustache'), 'r') as f: | |
148 TEMPLATE = f.read() | |
149 | |
150 | |
151 classes = {} | |
152 enumerations = {} | |
153 globalFunctions = [] | |
2 | 154 countAllFunctions = 0 |
155 countSupportedFunctions = 0 | |
0 | 156 |
157 def IsSourceStringType(t): | |
158 return (t.kind == clang.cindex.TypeKind.POINTER and | |
159 t.get_pointee().kind == clang.cindex.TypeKind.CHAR_S and | |
160 t.get_pointee().is_const_qualified()) | |
161 | |
162 def IsTargetStaticStringType(t): | |
163 return (t.kind == clang.cindex.TypeKind.POINTER and | |
164 t.get_pointee().kind == clang.cindex.TypeKind.CHAR_S and | |
165 t.get_pointee().is_const_qualified()) | |
166 | |
167 def IsTargetDynamicStringType(t): | |
168 return (t.kind == clang.cindex.TypeKind.POINTER and | |
169 t.get_pointee().kind == clang.cindex.TypeKind.CHAR_S and | |
170 not t.get_pointee().is_const_qualified()) | |
171 | |
172 def IsIntegerType(t): | |
173 return (t.kind == clang.cindex.TypeKind.INT or | |
174 t.spelling in [ 'int8_t', 'int16_t', 'int32_t', 'int64_t', | |
175 'uint8_t', 'uint16_t', 'uint32_t', 'uint64_t']) | |
176 | |
177 def IsFloatType(t): | |
178 return t.kind == clang.cindex.TypeKind.FLOAT | |
179 | |
180 def IsEnumerationType(t): | |
181 return (t.kind == clang.cindex.TypeKind.TYPEDEF and | |
182 t.spelling in enumerations) | |
183 | |
184 def IsTargetMemoryBufferType(t): | |
185 return (t.kind == clang.cindex.TypeKind.POINTER and | |
186 not t.get_pointee().is_const_qualified() and | |
187 t.get_pointee().spelling == 'OrthancPluginMemoryBuffer') | |
188 | |
189 def IsSourceMemoryBufferType(t): | |
190 return (t.kind == clang.cindex.TypeKind.POINTER and | |
191 t.get_pointee().kind == clang.cindex.TypeKind.VOID and | |
192 t.get_pointee().is_const_qualified()) | |
193 | |
194 def IsClassType(t): | |
195 return (t.kind == clang.cindex.TypeKind.POINTER and | |
196 ((t.get_pointee().is_const_qualified() and | |
197 t.get_pointee().spelling.startswith('const ') and | |
198 t.get_pointee().spelling[len('const '):] in classes) or | |
199 (not t.get_pointee().is_const_qualified() and | |
200 t.get_pointee().spelling in classes))) | |
201 | |
202 def IsSimpleSourceType(t): | |
203 return (IsSourceStringType(t) or | |
204 IsFloatType(t) or | |
205 IsIntegerType(t) or | |
206 IsEnumerationType(t) or | |
207 IsSourceMemoryBufferType(t)) | |
208 | |
209 def IsVoidType(t): | |
210 return t.kind == clang.cindex.TypeKind.VOID | |
211 | |
212 def IsSupportedTargetType(t): | |
213 return (IsVoidType(t) or | |
214 IsIntegerType(t) or | |
215 IsEnumerationType(t) or | |
216 # Constructor of a class | |
217 (t.kind == clang.cindex.TypeKind.POINTER and | |
218 not t.get_pointee().is_const_qualified() and | |
219 t.get_pointee().spelling in classes) or | |
220 # "const char*" or "char*" outputs | |
221 (t.kind == clang.cindex.TypeKind.POINTER and | |
222 #not t.get_pointee().is_const_qualified() and | |
223 t.get_pointee().kind == clang.cindex.TypeKind.CHAR_S)) | |
224 | |
225 def IsBytesArgument(args, index): | |
226 return (index + 1 < len(args) and | |
227 args[index].type.kind == clang.cindex.TypeKind.POINTER and | |
228 args[index].type.get_pointee().kind == clang.cindex.TypeKind.VOID and | |
229 args[index].type.get_pointee().is_const_qualified() and | |
230 args[index + 1].type.spelling == 'uint32_t') | |
231 | |
232 def CheckOnlySupportedArguments(args): | |
233 j = 0 | |
234 while j < len(args): | |
235 if IsBytesArgument(args, j): | |
236 j += 2 | |
237 elif IsSimpleSourceType(args[j].type): | |
238 j += 1 | |
239 else: | |
240 return False | |
241 return True | |
242 | |
243 | |
244 ORTHANC_TO_PYTHON_NUMERIC_TYPES = { | |
245 # https://docs.python.org/3/c-api/arg.html#numbers | |
246 'int' : { | |
247 'type' : 'int', | |
248 'format' : 'i', | |
249 }, | |
250 'uint8_t' : { | |
251 'type' : 'unsigned char', | |
252 'format' : 'b', | |
253 }, | |
254 'int32_t' : { | |
255 'type' : 'long int', | |
256 'format' : 'l', | |
257 }, | |
258 'uint16_t' : { | |
259 'type' : 'unsigned short', | |
260 'format' : 'H', | |
261 }, | |
262 'uint32_t' : { | |
263 'type' : 'unsigned long', | |
264 'format' : 'k', | |
265 }, | |
266 'uint64_t' : { | |
267 'type' : 'unsigned long long', | |
268 'format' : 'K', | |
269 }, | |
270 'float' : { | |
271 'type' : 'float', | |
272 'format' : 'f', | |
273 } | |
274 } | |
275 | |
276 | |
277 def GenerateFunctionBodyTemplate(cFunction, result_type, args): | |
278 if not cFunction.startswith('OrthancPlugin'): | |
279 raise Exception() | |
140
b6835b7a7c0a
code generation on Ubuntu 22.04
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
280 |
0 | 281 func = { |
282 'c_function' : cFunction, | |
283 'short_name' : cFunction[len('OrthancPlugin'):], | |
284 'args' : [], | |
140
b6835b7a7c0a
code generation on Ubuntu 22.04
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
285 'return_sdk_type' : result_type.spelling, |
0 | 286 } |
287 | |
288 if IsIntegerType(result_type): | |
289 func['return_long'] = True | |
290 elif IsTargetDynamicStringType(result_type): | |
291 func['return_dynamic_string'] = True | |
292 elif IsTargetStaticStringType(result_type): | |
293 func['return_static_string'] = True | |
294 elif IsVoidType(result_type): | |
295 func['return_void'] = True | |
296 elif result_type.spelling == 'OrthancPluginErrorCode': | |
297 func['return_error'] = True | |
141
3867cb23991d
added information in the code model
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
140
diff
changeset
|
298 func['return_sdk_type'] = 'enumeration' |
3867cb23991d
added information in the code model
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
140
diff
changeset
|
299 func['return_sdk_enumeration'] = result_type.spelling |
0 | 300 elif IsClassType(result_type): |
301 func['return_object'] = result_type.get_pointee().spelling | |
141
3867cb23991d
added information in the code model
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
140
diff
changeset
|
302 func['return_sdk_type'] = 'object' |
3867cb23991d
added information in the code model
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
140
diff
changeset
|
303 func['return_sdk_class'] = result_type.get_pointee().spelling |
0 | 304 elif IsTargetMemoryBufferType(result_type): |
305 func['return_bytes'] = True | |
306 elif IsEnumerationType(result_type): | |
307 func['return_enumeration'] = result_type.spelling | |
141
3867cb23991d
added information in the code model
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
140
diff
changeset
|
308 func['return_sdk_type'] = 'enumeration' |
3867cb23991d
added information in the code model
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
140
diff
changeset
|
309 func['return_sdk_enumeration'] = result_type.spelling |
0 | 310 else: |
311 raise Exception('Not supported: %s' % result_type.spelling) | |
312 | |
313 i = 0 | |
314 while i < len(args): | |
315 a = { | |
316 'name' : 'arg%d' % i, | |
140
b6835b7a7c0a
code generation on Ubuntu 22.04
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
317 'sdk_type' : args[i].type.spelling, |
141
3867cb23991d
added information in the code model
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
140
diff
changeset
|
318 'sdk_name' : args[i].spelling, |
0 | 319 } |
320 | |
321 if (IsIntegerType(args[i].type) or | |
322 IsFloatType(args[i].type)): | |
323 t = ORTHANC_TO_PYTHON_NUMERIC_TYPES[args[i].type.spelling] | |
324 a['python_type'] = t['type'] | |
325 a['python_format'] = t['format'] | |
326 a['initialization'] = ' = 0' | |
327 a['orthanc_cast'] = 'arg%d' % i | |
328 func['args'].append(a) | |
329 elif IsSourceStringType(args[i].type): | |
330 a['python_type'] = 'const char*' | |
331 a['python_format'] = 's' | |
332 a['initialization'] = ' = NULL' | |
333 a['orthanc_cast'] = 'arg%d' % i | |
334 func['args'].append(a) | |
335 elif IsEnumerationType(args[i].type): | |
336 a['python_type'] = 'long int' | |
337 a['python_format'] = 'l' | |
338 a['initialization'] = ' = 0' | |
339 a['orthanc_cast'] = 'static_cast<%s>(arg%d)' % (args[i].type.spelling, i) | |
141
3867cb23991d
added information in the code model
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
140
diff
changeset
|
340 a['sdk_type'] = 'enumeration' |
3867cb23991d
added information in the code model
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
140
diff
changeset
|
341 a['sdk_enumeration'] = args[i].type.spelling |
0 | 342 func['args'].append(a) |
343 elif IsBytesArgument(args, i): | |
344 a['python_type'] = 'Py_buffer' | |
345 # In theory, one should use "y*" (this is the recommended | |
346 # way to accept binary data). However, this is not | |
347 # available in Python 2.7 | |
348 a['python_format'] = 's*' | |
349 a['orthanc_cast'] = 'arg%d.buf, arg%d.len' % (i, i) | |
350 a['release'] = 'PyBuffer_Release(&arg%d);' % i | |
141
3867cb23991d
added information in the code model
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
140
diff
changeset
|
351 a['sdk_type'] = 'const_void_pointer_with_size' |
0 | 352 func['args'].append(a) |
140
b6835b7a7c0a
code generation on Ubuntu 22.04
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
353 i += 1 # Skip the size argument |
0 | 354 elif IsSourceMemoryBufferType(args[i].type): |
355 a['python_type'] = 'Py_buffer' | |
356 a['python_format'] = 's*' | |
357 a['orthanc_cast'] = 'arg%d.buf' % i | |
358 a['release'] = 'PyBuffer_Release(&arg%d);' % i | |
359 func['args'].append(a) | |
360 else: | |
361 raise Exception('Not supported: %s, %s' % (cFunction, args[i].spelling)) | |
362 | |
363 i += 1 | |
364 | |
365 func['tuple_format'] = '"%s", %s' % ( | |
366 ''.join(map(lambda x: x['python_format'], func['args'])), | |
367 ', '.join(map(lambda x: '&' + x['name'], func['args']))) | |
368 | |
369 if len(func['args']) > 0: | |
370 func['count_args'] = len(func['args']) | |
371 func['has_args'] = True | |
372 func['call_args'] = ', ' + ', '.join(map(lambda x: x['orthanc_cast'], func['args'])) | |
373 | |
374 return func | |
375 | |
376 | |
377 for node in tu.cursor.get_children(): | |
378 if node.kind == clang.cindex.CursorKind.ENUM_DECL: | |
379 if node.type.spelling.startswith('OrthancPlugin'): | |
380 name = node.type.spelling | |
381 | |
382 values = [] | |
383 for item in node.get_children(): | |
384 if (item.kind == clang.cindex.CursorKind.ENUM_CONSTANT_DECL and | |
385 item.spelling.startswith(name + '_')): | |
386 values.append({ | |
387 'key' : ToUpperCase(item.spelling[len(name)+1:]), | |
388 'value' : item.enum_value | |
389 }) | |
390 | |
391 path = 'sdk_%s.impl.h' % name | |
392 shortName = name[len('OrthancPlugin'):] | |
393 | |
394 with open(os.path.join(TARGET, path), 'w') as f: | |
395 f.write(pystache.render(TEMPLATE, { | |
396 'name' : name, | |
397 'short_name' : shortName, | |
398 'values' : values, | |
399 })) | |
400 | |
401 enumerations[name] = { | |
402 'name' : name, | |
403 'path' : path, | |
138
3e89d1c4f721
export the code model as json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
404 'values' : values, |
0 | 405 } |
406 | |
407 elif node.kind == clang.cindex.CursorKind.FUNCTION_DECL: | |
408 if node.spelling.startswith('OrthancPlugin'): | |
409 #if node.spelling != 'OrthancPluginWorklistGetDicomQuery': | |
410 # continue | |
411 shortName = node.spelling[len('OrthancPlugin'):] | |
412 | |
413 # Check that the first argument is the Orthanc context | |
414 args = list(filter(lambda x: x.kind == clang.cindex.CursorKind.PARM_DECL, | |
415 node.get_children())) | |
416 | |
417 if (len(args) == 0 or | |
418 args[0].type.kind != clang.cindex.TypeKind.POINTER or | |
419 args[0].type.get_pointee().spelling != 'OrthancPluginContext'): | |
420 print('Not in the Orthanc SDK: %s()' % node.spelling) | |
421 continue | |
422 | |
423 # Discard the context from the arguments | |
2 | 424 countAllFunctions += 1 |
0 | 425 args = args[1:] |
426 | |
65
4da5ce3468b4
new wrapped functions: CreateImageFromBuffer(), DicomInstance.GetInstanceData() and Image.GetImageBuffer()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
64
diff
changeset
|
427 if node.spelling in CUSTOM_FUNCTIONS: |
4da5ce3468b4
new wrapped functions: CreateImageFromBuffer(), DicomInstance.GetInstanceData() and Image.GetImageBuffer()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
64
diff
changeset
|
428 print('Ignoring custom function that is manually implemented: %s()' % node.spelling) |
4da5ce3468b4
new wrapped functions: CreateImageFromBuffer(), DicomInstance.GetInstanceData() and Image.GetImageBuffer()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
64
diff
changeset
|
429 countSupportedFunctions += 1 |
4da5ce3468b4
new wrapped functions: CreateImageFromBuffer(), DicomInstance.GetInstanceData() and Image.GetImageBuffer()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
64
diff
changeset
|
430 |
4da5ce3468b4
new wrapped functions: CreateImageFromBuffer(), DicomInstance.GetInstanceData() and Image.GetImageBuffer()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
64
diff
changeset
|
431 elif not IsSupportedTargetType(node.result_type): |
0 | 432 print('*** UNSUPPORTED OUTPUT: %s' % node.spelling) |
433 | |
434 elif (len(args) == 1 and | |
435 IsClassType(args[0].type) and | |
436 node.spelling.startswith('OrthancPluginFree')): | |
437 print('Destructor: %s' % node.spelling) | |
438 className = args[0].type.get_pointee().spelling | |
439 classes[className]['destructor'] = node.spelling | |
2 | 440 countSupportedFunctions += 1 |
0 | 441 |
442 elif CheckOnlySupportedArguments(args): | |
443 if IsClassType(node.result_type): | |
444 print('Constructor: %s' % node.spelling) | |
445 else: | |
446 print('Simple global function: %s => %s' % (node.spelling, node.result_type.spelling)) | |
447 | |
448 body = GenerateFunctionBodyTemplate(node.spelling, node.result_type, args) | |
449 globalFunctions.append(body) | |
2 | 450 countSupportedFunctions += 1 |
0 | 451 |
452 elif (len(args) >= 2 and | |
453 IsTargetMemoryBufferType(args[0].type) and | |
454 CheckOnlySupportedArguments(args[1:])): | |
455 print('Simple global function, returning bytes: %s' % node.spelling) | |
456 | |
457 body = GenerateFunctionBodyTemplate(node.spelling, args[0].type, args[1:]) | |
458 globalFunctions.append(body) | |
2 | 459 countSupportedFunctions += 1 |
0 | 460 |
461 elif (IsClassType(args[0].type) and | |
462 CheckOnlySupportedArguments(args[1:])): | |
463 className = args[0].type.get_pointee().spelling | |
464 | |
63
32de70a1e4c7
New functions from the SDK wrapped in Python: CreateDicom, RegisterFindCallback, RegisterMoveCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
56
diff
changeset
|
465 print('Simple method of class %s: %s' % (className, node.spelling)) |
32de70a1e4c7
New functions from the SDK wrapped in Python: CreateDicom, RegisterFindCallback, RegisterMoveCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
56
diff
changeset
|
466 if node.spelling in CUSTOM_FUNCTIONS: |
32de70a1e4c7
New functions from the SDK wrapped in Python: CreateDicom, RegisterFindCallback, RegisterMoveCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
56
diff
changeset
|
467 raise Exception('Cannot overwrite an autogenerated method: %s()' % node.spelling) |
32de70a1e4c7
New functions from the SDK wrapped in Python: CreateDicom, RegisterFindCallback, RegisterMoveCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
56
diff
changeset
|
468 |
0 | 469 if className.startswith('const '): |
470 className = className[len('const '):] | |
471 | |
472 method = GenerateFunctionBodyTemplate(node.spelling, node.result_type, args[1:]) | |
473 method['self'] = ', self->object_' | |
474 classes[className]['methods'].append(method) | |
2 | 475 countSupportedFunctions += 1 |
0 | 476 |
477 elif (len(args) >= 2 and | |
478 IsTargetMemoryBufferType(args[0].type) and | |
479 IsClassType(args[1].type) and | |
480 CheckOnlySupportedArguments(args[2:])): | |
31 | 481 className = args[1].type.get_pointee().spelling |
482 | |
63
32de70a1e4c7
New functions from the SDK wrapped in Python: CreateDicom, RegisterFindCallback, RegisterMoveCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
56
diff
changeset
|
483 print('Simple method of class %s, returning bytes: %s' % (className, node.spelling)) |
32de70a1e4c7
New functions from the SDK wrapped in Python: CreateDicom, RegisterFindCallback, RegisterMoveCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
56
diff
changeset
|
484 if node.spelling in CUSTOM_FUNCTIONS: |
32de70a1e4c7
New functions from the SDK wrapped in Python: CreateDicom, RegisterFindCallback, RegisterMoveCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
56
diff
changeset
|
485 raise Exception('Cannot overwrite an autogenerated method: %s()' % node.spelling) |
32de70a1e4c7
New functions from the SDK wrapped in Python: CreateDicom, RegisterFindCallback, RegisterMoveCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
56
diff
changeset
|
486 |
31 | 487 if className.startswith('const '): |
488 className = className[len('const '):] | |
489 | |
0 | 490 method = GenerateFunctionBodyTemplate(node.spelling, args[0].type, args[2:]) |
491 method['self'] = ', self->object_' | |
492 classes[className]['methods'].append(method) | |
2 | 493 countSupportedFunctions += 1 |
63
32de70a1e4c7
New functions from the SDK wrapped in Python: CreateDicom, RegisterFindCallback, RegisterMoveCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
56
diff
changeset
|
494 |
0 | 495 else: |
496 print('*** UNSUPPORTED INPUT: %s' % node.spelling) | |
497 | |
498 | |
499 | |
500 elif node.kind == clang.cindex.CursorKind.STRUCT_DECL: | |
501 if (node.spelling.startswith('_OrthancPlugin') and | |
502 node.spelling.endswith('_t') and | |
503 node.spelling != '_OrthancPluginContext_t'): | |
504 name = node.spelling[len('_') : -len('_t')] | |
505 classes[name] = { | |
506 'class_name' : name, | |
507 'short_name' : name[len('OrthancPlugin'):], | |
63
32de70a1e4c7
New functions from the SDK wrapped in Python: CreateDicom, RegisterFindCallback, RegisterMoveCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
56
diff
changeset
|
508 'methods' : [ ], |
32de70a1e4c7
New functions from the SDK wrapped in Python: CreateDicom, RegisterFindCallback, RegisterMoveCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
56
diff
changeset
|
509 'custom_methods' : [ ], |
0 | 510 } |
511 | |
512 | |
513 | |
514 | |
515 partials = {} | |
516 | |
517 with open(os.path.join(ROOT, 'FunctionBody.mustache'), 'r') as f: | |
518 partials['function_body'] = f.read() | |
519 | |
520 renderer = pystache.Renderer( | |
521 escape = lambda u: u, # No escaping | |
522 partials = partials, | |
523 ) | |
524 | |
525 with open(os.path.join(ROOT, 'Class.mustache'), 'r') as f: | |
129
5643e97d9367
reproducible code generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
108
diff
changeset
|
526 with open(os.path.join(ROOT, 'ClassMethods.mustache'), 'r') as g: |
5643e97d9367
reproducible code generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
108
diff
changeset
|
527 classDefinition = f.read() |
5643e97d9367
reproducible code generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
108
diff
changeset
|
528 classMethods = g.read() |
0 | 529 |
129
5643e97d9367
reproducible code generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
108
diff
changeset
|
530 for method in CUSTOM_METHODS: |
5643e97d9367
reproducible code generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
108
diff
changeset
|
531 classes[method['class_name']]['custom_methods'].append(method) |
5643e97d9367
reproducible code generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
108
diff
changeset
|
532 |
5643e97d9367
reproducible code generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
108
diff
changeset
|
533 for (key, value) in classes.items(): |
5643e97d9367
reproducible code generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
108
diff
changeset
|
534 with open(os.path.join(TARGET, 'sdk_%s.impl.h' % value['class_name']), 'w') as h: |
5643e97d9367
reproducible code generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
108
diff
changeset
|
535 h.write(renderer.render(classDefinition, value)) |
5643e97d9367
reproducible code generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
108
diff
changeset
|
536 with open(os.path.join(TARGET, 'sdk_%s.methods.h' % value['class_name']), 'w') as h: |
5643e97d9367
reproducible code generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
108
diff
changeset
|
537 h.write(renderer.render(classMethods, value)) |
0 | 538 |
539 | |
540 def FlattenDictionary(source): | |
541 result = [] | |
542 for (key, value) in source.items(): | |
543 result.append(value) | |
544 return result | |
545 | |
129
5643e97d9367
reproducible code generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
108
diff
changeset
|
546 |
5643e97d9367
reproducible code generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
108
diff
changeset
|
547 sortedClasses = sorted(FlattenDictionary(classes), key = lambda x: x['class_name']) |
5643e97d9367
reproducible code generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
108
diff
changeset
|
548 sortedEnumerations = sorted(FlattenDictionary(enumerations), key = lambda x: x['name']) |
5643e97d9367
reproducible code generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
108
diff
changeset
|
549 sortedGlobalFunctions = sorted(globalFunctions, key = lambda x: x['c_function']) |
5643e97d9367
reproducible code generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
108
diff
changeset
|
550 |
0 | 551 with open(os.path.join(ROOT, 'GlobalFunctions.mustache'), 'r') as f: |
552 with open(os.path.join(TARGET, 'sdk_GlobalFunctions.impl.h'), 'w') as h: | |
553 h.write(renderer.render(f.read(), { | |
554 'global_functions' : globalFunctions, | |
555 })) | |
556 | |
557 with open(os.path.join(ROOT, 'sdk.cpp.mustache'), 'r') as f: | |
558 with open(os.path.join(TARGET, 'sdk.cpp'), 'w') as h: | |
559 h.write(renderer.render(f.read(), { | |
129
5643e97d9367
reproducible code generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
108
diff
changeset
|
560 'classes' : sortedClasses, |
5643e97d9367
reproducible code generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
108
diff
changeset
|
561 'enumerations' : sortedEnumerations, |
0 | 562 'global_functions' : globalFunctions, |
563 })) | |
564 | |
565 with open(os.path.join(ROOT, 'sdk.h.mustache'), 'r') as f: | |
566 with open(os.path.join(TARGET, 'sdk.h'), 'w') as h: | |
567 h.write(renderer.render(f.read(), { | |
129
5643e97d9367
reproducible code generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
108
diff
changeset
|
568 'classes' : sortedClasses, |
0 | 569 })) |
2 | 570 |
571 | |
138
3e89d1c4f721
export the code model as json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
572 with open(os.path.join(TARGET, 'CodeModel.json'), 'w') as f: |
3e89d1c4f721
export the code model as json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
573 f.write(json.dumps({ |
3e89d1c4f721
export the code model as json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
574 'global_functions' : globalFunctions, |
3e89d1c4f721
export the code model as json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
575 'classes' : sortedClasses, |
3e89d1c4f721
export the code model as json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
576 'enumerations' : sortedEnumerations, |
3e89d1c4f721
export the code model as json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
577 }, ensure_ascii = True, indent = 4, sort_keys = True)) |
3e89d1c4f721
export the code model as json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
578 |
3e89d1c4f721
export the code model as json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
579 |
2 | 580 print('') |
581 print('Total functions in the SDK: %d' % countAllFunctions) | |
582 print('Total supported functions: %d' % countSupportedFunctions) | |
583 print('Coverage: %.0f%%' % (float(countSupportedFunctions) / | |
584 float(countAllFunctions) * 100.0)) |