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