comparison CodeAnalysis/GenerateOrthancSDK.py @ 182:20b004998fc2 java-code-model

documentation of custom methods
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 02 Jul 2024 14:06:56 +0200
parents faaa3fec799a
children d31f216c9462
comparison
equal deleted inserted replaced
181:faaa3fec799a 182:20b004998fc2
76 76
77 77
78 CUSTOM_METHODS = { 78 CUSTOM_METHODS = {
79 'OrthancPluginFindQuery' : [ 79 'OrthancPluginFindQuery' : [
80 { 80 {
81 'method_name' : 'GetFindQueryTagGroup', 81 'short_name' : 'GetFindQueryTagGroup',
82 'implementation' : 'GetFindQueryTagGroup', 82 'implementation' : 'GetFindQueryTagGroup',
83 'sdk_function' : 'OrthancPluginGetFindQueryTag', 83 'sdk_function' : 'OrthancPluginGetFindQueryTag',
84 'documentation' : { 84 'documentation' : {
85 'description' : [ ], 85 'description' : [ 'This function returns the group of one DICOM tag in the given C-Find query.' ],
86 'args' : {
87 'index' : 'The index of the tag of interest.',
88 },
89 'return' : 'The value of the group.',
86 }, 90 },
87 'args' : [ 91 'args' : [
92 {
93 'sdk_name' : 'index',
94 'sdk_type' : 'uint32_t',
95 }
88 ], 96 ],
89 'return_sdk_type' : 'void', 97 'return_sdk_type' : 'uint16_t',
90 }, 98 },
99
91 { 100 {
92 'method_name' : 'GetFindQueryTagElement', 101 'short_name' : 'GetFindQueryTagElement',
93 'implementation' : 'GetFindQueryTagElement', 102 'implementation' : 'GetFindQueryTagElement',
94 'sdk_function' : 'OrthancPluginGetFindQueryTag', 103 'sdk_function' : 'OrthancPluginGetFindQueryTag',
95 'documentation' : { 104 'documentation' : {
96 'description' : [ ], 105 'description' : [ 'This function returns the element of one DICOM tag in the given C-Find query.' ],
106 'args' : {
107 'index' : 'The index of the tag of interest.',
108 },
109 'return' : 'The value of the element.',
97 }, 110 },
98 'args' : [ 111 'args' : [
112 {
113 'sdk_name' : 'index',
114 'sdk_type' : 'uint32_t',
115 }
99 ], 116 ],
100 'return_sdk_type' : 'void', 117 'return_sdk_type' : 'uint16_t',
101 }, 118 },
102 ], 119 ],
103 120
104 'OrthancPluginDicomInstance' : [ 121 'OrthancPluginDicomInstance' : [
105 { 122 {
106 'method_name' : 'GetInstanceData', 123 'short_name' : 'GetInstanceData',
107 'implementation' : 'GetInstanceData', 124 'implementation' : 'GetInstanceData',
108 'sdk_function' : 'OrthancPluginGetInstanceData', 125 'sdk_function' : 'OrthancPluginGetInstanceData',
109 'documentation' : { 126 'documentation' : {
110 'description' : [ ] 127 'description' : [ 'Get the content of the DICOM instance.' ],
128 'return' : 'The DICOM data.',
111 }, 129 },
112 'args' : [ 130 'args' : [
113 ], 131 ],
114 'return_sdk_type' : 'OrthancPluginMemoryBuffer *', 132 'return_sdk_type' : 'OrthancPluginMemoryBuffer *',
115 }, 133 },
116 ], 134 ],
117 135
118 'OrthancPluginImage' : [ 136 'OrthancPluginImage' : [
119 { 137 {
120 'method_name' : 'GetImageBuffer', 138 'short_name' : 'GetImageBuffer',
121 'implementation' : 'GetImageBuffer', 139 'implementation' : 'GetImageBuffer',
122 'sdk_function' : 'OrthancPluginGetImageBuffer', 140 'sdk_function' : 'OrthancPluginGetImageBuffer',
123 'documentation' : { 141 'documentation' : {
124 'description' : [ ], 142 'description' : [ 'This function returns a pointer to the memory buffer that contains the pixels of the image.' ],
143 'return' : 'The pixel data.',
125 }, 144 },
126 'args' : [ 145 'args' : [
127 ], 146 ],
128 'return_sdk_type' : 'void', 147 'return_sdk_type' : 'OrthancPluginMemoryBuffer *',
129 } 148 }
130 ], 149 ],
131 } 150 }
132 151
133 152
255 274
256 documentation['args_declaration'] = ', '.join(args_declaration) 275 documentation['args_declaration'] = ', '.join(args_declaration)
257 documentation['args'] = args_documentation 276 documentation['args'] = args_documentation
258 documentation['has_args'] = len(args_documentation) > 0 277 documentation['has_args'] = len(args_documentation) > 0
259 documentation['has_return'] = True 278 documentation['has_return'] = True
260 documentation['return_text'] = f['documentation'].get('return', None)
261 279
262 if f['return_sdk_type'] == 'enumeration': 280 if f['return_sdk_type'] == 'enumeration':
263 if f['return_sdk_enumeration'] == 'OrthancPluginErrorCode': 281 if f['return_sdk_enumeration'] == 'OrthancPluginErrorCode':
264 documentation['has_return'] = False 282 documentation['has_return'] = False
265 documentation['return_type'] = 'None' 283 documentation['return_type'] = 'None'
272 documentation['return_type'] = 'None' 290 documentation['return_type'] = 'None'
273 elif f['return_sdk_type'] == 'OrthancPluginMemoryBuffer *': 291 elif f['return_sdk_type'] == 'OrthancPluginMemoryBuffer *':
274 documentation['return_type'] = 'bytes' 292 documentation['return_type'] = 'bytes'
275 elif f['return_sdk_type'] in [ 'char *', 'const char *' ]: 293 elif f['return_sdk_type'] in [ 'char *', 'const char *' ]:
276 documentation['return_type'] = 'str' 294 documentation['return_type'] = 'str'
277 elif f['return_sdk_type'] in [ 'int32_t', 'uint32_t', 'int64_t' ]: 295 elif f['return_sdk_type'] in [ 'int32_t', 'uint32_t', 'uint16_t', 'int64_t' ]:
278 documentation['return_type'] = 'int' 296 documentation['return_type'] = 'int'
279 else: 297 else:
280 raise Exception('Return type not implemented: %s' % f['return_sdk_type']) 298 raise Exception('Return type not implemented: %s' % f['return_sdk_type'])
299
300 if documentation['has_return']:
301 documentation['return_text'] = f['documentation']['return']
281 302
282 return documentation 303 return documentation
283 304
284 305
285 def FormatFunction(f): 306 def FormatFunction(f):
453 if g != None: 474 if g != None:
454 g['self'] = ', self->object_' 475 g['self'] = ', self->object_'
455 g['is_method'] = True 476 g['is_method'] = True
456 methods.append(g) 477 methods.append(g)
457 478
479 custom_methods = []
480
481 if c['name'] in CUSTOM_METHODS:
482 for custom_method in CUSTOM_METHODS[c['name']]:
483 custom_method['is_method'] = True
484 custom_method['documentation'] = DocumentFunction(custom_method)
485 custom_methods.append(custom_method)
486
458 classes.append({ 487 classes.append({
459 'class_name' : c['name'], 488 'class_name' : c['name'],
460 'short_name' : GetShortName(c['name']), 489 'short_name' : GetShortName(c['name']),
461 'methods' : methods, 490 'methods' : methods,
491 'custom_methods' : custom_methods,
462 }) 492 })
463
464 if c['name'] in CUSTOM_METHODS:
465 classes[-1]['custom_methods'] = CUSTOM_METHODS[c['name']]
466 493
467 if 'destructor' in c: 494 if 'destructor' in c:
468 classes[-1]['destructor'] = c['destructor'] 495 classes[-1]['destructor'] = c['destructor']
469 496
470 497