Mercurial > hg > orthanc-python
comparison CodeAnalysis/GenerateOrthancSDK.py @ 179:f49864df6f1f java-code-model
trying Py_BEGIN_ALLOW_THREADS
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 27 Jun 2024 21:53:03 +0200 |
parents | e9be3c9294d4 |
children | ddf3e987827f |
comparison
equal
deleted
inserted
replaced
178:194ba7d6e0f4 | 179:f49864df6f1f |
---|---|
182 'short_name' : GetShortName(f['c_function']), | 182 'short_name' : GetShortName(f['c_function']), |
183 'has_args' : len(f['args']) > 0, | 183 'has_args' : len(f['args']) > 0, |
184 'count_args' : len(f['args']), | 184 'count_args' : len(f['args']), |
185 } | 185 } |
186 | 186 |
187 allow_threads = True | |
187 tuple_format = '' | 188 tuple_format = '' |
188 tuple_target = [] | 189 tuple_target = [] |
189 call_args = [] | 190 call_args = [] |
190 args = [] | 191 args = [] |
191 | 192 |
196 'name' : arg['name'], | 197 'name' : arg['name'], |
197 'python_type' : 'Py_buffer', | 198 'python_type' : 'Py_buffer', |
198 'release' : 'PyBuffer_Release(&%s);' % arg['name'], | 199 'release' : 'PyBuffer_Release(&%s);' % arg['name'], |
199 }) | 200 }) |
200 tuple_format += 's*' | 201 tuple_format += 's*' |
202 allow_threads = False | |
201 elif arg['sdk_type'] == 'const char *': | 203 elif arg['sdk_type'] == 'const char *': |
202 args.append({ | 204 args.append({ |
203 'name' : arg['name'], | 205 'name' : arg['name'], |
204 'python_type' : 'const char*', | 206 'python_type' : 'const char*', |
205 'initialization' : ' = NULL', | 207 'initialization' : ' = NULL', |
206 }) | 208 }) |
207 tuple_format += 's' | 209 tuple_format += 's' |
210 allow_threads = False | |
208 elif arg['sdk_type'] == 'enumeration': | 211 elif arg['sdk_type'] == 'enumeration': |
209 args.append({ | 212 args.append({ |
210 'name' : arg['name'], | 213 'name' : arg['name'], |
211 'python_type' : 'long int', | 214 'python_type' : 'long int', |
212 'initialization' : ' = 0', | 215 'initialization' : ' = 0', |
218 'python_type' : 'PyObject*', | 221 'python_type' : 'PyObject*', |
219 'initialization' : ' = NULL', | 222 'initialization' : ' = NULL', |
220 'check_object_type' : arg['sdk_class'], | 223 'check_object_type' : arg['sdk_class'], |
221 }) | 224 }) |
222 tuple_format += 'O' | 225 tuple_format += 'O' |
226 allow_threads = False | |
223 elif arg['sdk_type'] in ORTHANC_TO_PYTHON_NUMERIC_TYPES: | 227 elif arg['sdk_type'] in ORTHANC_TO_PYTHON_NUMERIC_TYPES: |
224 t = ORTHANC_TO_PYTHON_NUMERIC_TYPES[arg['sdk_type']] | 228 t = ORTHANC_TO_PYTHON_NUMERIC_TYPES[arg['sdk_type']] |
225 args.append({ | 229 args.append({ |
226 'name' : arg['name'], | 230 'name' : arg['name'], |
227 'python_type' : t['type'], | 231 'python_type' : t['type'], |
268 answer['return_object'] = f['return_sdk_class'] | 272 answer['return_object'] = f['return_sdk_class'] |
269 else: | 273 else: |
270 print('Ignoring function with unsupported return type: %s(), type = %s' % (f['c_function'], f['return_sdk_type'])) | 274 print('Ignoring function with unsupported return type: %s(), type = %s' % (f['c_function'], f['return_sdk_type'])) |
271 return None | 275 return None |
272 | 276 |
277 allow_threads = False # TODO | |
278 | |
273 answer['tuple_format'] = ', '.join([ '"' + tuple_format + '"' ] + tuple_target) | 279 answer['tuple_format'] = ', '.join([ '"' + tuple_format + '"' ] + tuple_target) |
280 answer['allow_threads'] = allow_threads | |
274 | 281 |
275 if len(call_args) > 0: | 282 if len(call_args) > 0: |
276 answer['call_args'] = ', ' + ', '.join(call_args) | 283 answer['call_args'] = ', ' + ', '.join(call_args) |
284 | |
285 if not allow_threads: | |
286 print('Threads are not allowed in function: %s()' % f['c_function']) | |
277 | 287 |
278 return answer | 288 return answer |
279 | 289 |
280 | 290 |
281 | 291 |