diff CodeAnalysis/ParseOrthancSDK.py @ 131:c55b0583084b

integration fix-leak->mainline
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 30 Aug 2023 11:52:45 +0200
parents 65ec5597ec70 5643e97d9367
children 3e89d1c4f721
line wrap: on
line diff
--- a/CodeAnalysis/ParseOrthancSDK.py	Wed Aug 30 11:49:59 2023 +0200
+++ b/CodeAnalysis/ParseOrthancSDK.py	Wed Aug 30 11:52:45 2023 +0200
@@ -509,14 +509,18 @@
 )
 
 with open(os.path.join(ROOT, 'Class.mustache'), 'r') as f:
-    template = f.read()
+    with open(os.path.join(ROOT, 'ClassMethods.mustache'), 'r') as g:
+        classDefinition = f.read()
+        classMethods = g.read()
 
-    for method in CUSTOM_METHODS:
-        classes[method['class_name']]['custom_methods'].append(method)
-    
-    for (key, value) in classes.items():
-        with open(os.path.join(TARGET, 'sdk_%s.impl.h' % value['class_name']), 'w') as h:
-            h.write(renderer.render(template, value))
+        for method in CUSTOM_METHODS:
+            classes[method['class_name']]['custom_methods'].append(method)
+
+        for (key, value) in classes.items():
+            with open(os.path.join(TARGET, 'sdk_%s.impl.h' % value['class_name']), 'w') as h:
+                h.write(renderer.render(classDefinition, value))
+            with open(os.path.join(TARGET, 'sdk_%s.methods.h' % value['class_name']), 'w') as h:
+                h.write(renderer.render(classMethods, value))
         
 
 def FlattenDictionary(source):
@@ -525,7 +529,11 @@
         result.append(value)
     return result
 
-            
+
+sortedClasses = sorted(FlattenDictionary(classes), key = lambda x: x['class_name'])
+sortedEnumerations = sorted(FlattenDictionary(enumerations), key = lambda x: x['name'])
+sortedGlobalFunctions = sorted(globalFunctions, key = lambda x: x['c_function'])
+
 with open(os.path.join(ROOT, 'GlobalFunctions.mustache'), 'r') as f:
     with open(os.path.join(TARGET, 'sdk_GlobalFunctions.impl.h'), 'w') as h:
         h.write(renderer.render(f.read(), {
@@ -535,15 +543,15 @@
 with open(os.path.join(ROOT, 'sdk.cpp.mustache'), 'r') as f:
     with open(os.path.join(TARGET, 'sdk.cpp'), 'w') as h:
         h.write(renderer.render(f.read(), {
-            'classes' : FlattenDictionary(classes),
-            'enumerations' : FlattenDictionary(enumerations),
+            'classes' : sortedClasses,
+            'enumerations' : sortedEnumerations,
             'global_functions' : globalFunctions,
         }))
             
 with open(os.path.join(ROOT, 'sdk.h.mustache'), 'r') as f:
     with open(os.path.join(TARGET, 'sdk.h'), 'w') as h:
         h.write(renderer.render(f.read(), {
-            'classes' : FlattenDictionary(classes),
+            'classes' : sortedClasses,
         }))