comparison CodeAnalysis/ParseOrthancSDK.py @ 65:4da5ce3468b4

new wrapped functions: CreateImageFromBuffer(), DicomInstance.GetInstanceData() and Image.GetImageBuffer()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 11 Jun 2021 12:47:18 +0200
parents 091fb1903bfc
children 6fc445793796
comparison
equal deleted inserted replaced
64:091fb1903bfc 65:4da5ce3468b4
33 ## 33 ##
34 ## Configuration of the custom primitives that are manually 34 ## Configuration of the custom primitives that are manually
35 ## implemented (not autogenerated) 35 ## implemented (not autogenerated)
36 ## 36 ##
37 37
38 CUSTOM_FUNCTIONS = { 38 CUSTOM_FUNCTIONS = set([
39 'OrthancPluginCreateDicom', 39 'OrthancPluginCreateDicom',
40 'OrthancPluginCreateImageAccessor', # Replaced by "orthanc.CreateImageFromBuffer()"
40 'OrthancPluginFreeMemoryBuffer', 41 'OrthancPluginFreeMemoryBuffer',
41 'OrthancPluginFreeString', 42 'OrthancPluginFreeString',
42 'OrthancPluginGetFindQueryTag',
43 'OrthancPluginRegisterFindCallback', 43 'OrthancPluginRegisterFindCallback',
44 'OrthancPluginRegisterIncomingHttpRequestFilter', # Implemented through v2 44 'OrthancPluginRegisterIncomingHttpRequestFilter', # Implemented through v2
45 'OrthancPluginRegisterIncomingHttpRequestFilter2', 45 'OrthancPluginRegisterIncomingHttpRequestFilter2',
46 'OrthancPluginRegisterMoveCallback', 46 'OrthancPluginRegisterMoveCallback',
47 'OrthancPluginRegisterOnChangeCallback', 47 'OrthancPluginRegisterOnChangeCallback',
48 'OrthancPluginRegisterOnStoredInstanceCallback', 48 'OrthancPluginRegisterOnStoredInstanceCallback',
49 'OrthancPluginRegisterRestCallback', # Implemented using OrthancPlugins::RegisterRestCallback 49 'OrthancPluginRegisterRestCallback', # Implemented using OrthancPlugins::RegisterRestCallback
50 'OrthancPluginRegisterRestCallbackNoLock', # Implemented using OrthancPlugins::RegisterRestCallback 50 'OrthancPluginRegisterRestCallbackNoLock', # Implemented using OrthancPlugins::RegisterRestCallback
51 'OrthancPluginRegisterWorklistCallback', 51 'OrthancPluginRegisterWorklistCallback',
52 'OrthancPluginWorklistAddAnswer', 52 ])
53 }
54 53
55 CUSTOM_METHODS = [ 54 CUSTOM_METHODS = [
56 { 55 {
57 'class_name' : 'OrthancPluginFindQuery', 56 'class_name' : 'OrthancPluginFindQuery',
58 'method_name' : 'GetFindQueryTagGroup', 57 'method_name' : 'GetFindQueryTagGroup',
69 'class_name' : 'OrthancPluginWorklistAnswers', 68 'class_name' : 'OrthancPluginWorklistAnswers',
70 'method_name' : 'WorklistAddAnswer', 69 'method_name' : 'WorklistAddAnswer',
71 'implementation' : 'WorklistAddAnswer', 70 'implementation' : 'WorklistAddAnswer',
72 'sdk_function' : 'OrthancPluginWorklistAddAnswer', 71 'sdk_function' : 'OrthancPluginWorklistAddAnswer',
73 }, 72 },
73 {
74 'class_name' : 'OrthancPluginDicomInstance',
75 'method_name' : 'GetInstanceData',
76 'implementation' : 'GetInstanceData',
77 'sdk_function' : 'OrthancPluginGetInstanceData',
78 },
79 {
80 'class_name' : 'OrthancPluginImage',
81 'method_name' : 'GetImageBuffer',
82 'implementation' : 'GetImageBuffer',
83 'sdk_function' : 'OrthancPluginGetImageBuffer',
84 },
74 ] 85 ]
86
87 for method in CUSTOM_METHODS:
88 CUSTOM_FUNCTIONS.add(method['sdk_function'])
75 89
76 90
77 ## 91 ##
78 ## Parse the command-line arguments 92 ## Parse the command-line arguments
79 ## 93 ##
391 405
392 # Discard the context from the arguments 406 # Discard the context from the arguments
393 countAllFunctions += 1 407 countAllFunctions += 1
394 args = args[1:] 408 args = args[1:]
395 409
396 if not IsSupportedTargetType(node.result_type): 410 if node.spelling in CUSTOM_FUNCTIONS:
411 print('Ignoring custom function that is manually implemented: %s()' % node.spelling)
412 countSupportedFunctions += 1
413
414 elif not IsSupportedTargetType(node.result_type):
397 print('*** UNSUPPORTED OUTPUT: %s' % node.spelling) 415 print('*** UNSUPPORTED OUTPUT: %s' % node.spelling)
398 416
399 elif (len(args) == 1 and 417 elif (len(args) == 1 and
400 IsClassType(args[0].type) and 418 IsClassType(args[0].type) and
401 node.spelling.startswith('OrthancPluginFree')): 419 node.spelling.startswith('OrthancPluginFree')):
455 method = GenerateFunctionBodyTemplate(node.spelling, args[0].type, args[2:]) 473 method = GenerateFunctionBodyTemplate(node.spelling, args[0].type, args[2:])
456 method['self'] = ', self->object_' 474 method['self'] = ', self->object_'
457 classes[className]['methods'].append(method) 475 classes[className]['methods'].append(method)
458 countSupportedFunctions += 1 476 countSupportedFunctions += 1
459 477
460 elif node.spelling in CUSTOM_FUNCTIONS:
461 print('Ignoring custom function that is manually implemented: %s()' % node.spelling)
462 countSupportedFunctions += 1
463
464 else: 478 else:
465 print('*** UNSUPPORTED INPUT: %s' % node.spelling) 479 print('*** UNSUPPORTED INPUT: %s' % node.spelling)
466 480
467 481
468 482