changeset 261:4724fbdf46e9

using since_sdk in code model
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 12 Aug 2025 08:18:56 +0200
parents 4975b53dc688
children ed1fadb22c61
files CodeAnalysis/CustomFunctions.json CodeAnalysis/GenerateOrthancSDK.py Sources/Autogenerated/orthanc.pyi Sources/Autogenerated/sdk_GlobalFunctions.impl.h Sources/Autogenerated/sdk_OrthancPluginKeysValuesIterator.methods.h Sources/Plugin.cpp
diffstat 6 files changed, 52 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/CodeAnalysis/CustomFunctions.json	Tue Aug 12 07:59:46 2025 +0200
+++ b/CodeAnalysis/CustomFunctions.json	Tue Aug 12 08:18:56 2025 +0200
@@ -398,7 +398,8 @@
         "sdk_enumeration" : "OrthancPluginStableStatus"
       }
     ],
-    "return_sdk_type" : "Tuple"
+    "return_sdk_type" : "Tuple",
+    "since_sdk" : [ 1, 12, 9 ]
   }
 
 ]
--- a/CodeAnalysis/GenerateOrthancSDK.py	Tue Aug 12 07:59:46 2025 +0200
+++ b/CodeAnalysis/GenerateOrthancSDK.py	Tue Aug 12 08:18:56 2025 +0200
@@ -43,6 +43,29 @@
     assert(m != None)
     PLUGIN_SDK_VERSION = m.group(1)
 
+    s = PLUGIN_SDK_VERSION.split('.')
+    assert(len(s) == 3)
+    PLUGIN_SDK_VERSION_PARSED = [ int(s[0]), int(s[1]), int(s[2]) ]
+
+
+def IsPrimitiveAvailable(item):
+    since_sdk = item.get('since_sdk')
+    if since_sdk != None:
+        assert(len(since_sdk) == 3)
+        assert(len(PLUGIN_SDK_VERSION_PARSED) == 3)
+        if since_sdk[0] < PLUGIN_SDK_VERSION_PARSED[0]:
+            return True
+        elif since_sdk[0] > PLUGIN_SDK_VERSION_PARSED[0]:
+            return False
+        elif since_sdk[1] < PLUGIN_SDK_VERSION_PARSED[1]:
+            return True
+        elif since_sdk[1] > PLUGIN_SDK_VERSION_PARSED[1]:
+            return False
+        else:
+            return since_sdk[2] <= PLUGIN_SDK_VERSION_PARSED[2]
+    else:
+        return True
+
 
 ##
 ## Parse the command-line arguments
@@ -352,13 +375,15 @@
 customFunctions = []
 
 for f in model['global_functions']:
-    g = FormatFunction(f)
-    if g != None:
-        globalFunctions.append(g)
+    if IsPrimitiveAvailable(f):
+        g = FormatFunction(f)
+        if g != None:
+            globalFunctions.append(g)
 
 for f in CUSTOM_FUNCTIONS:
-    f['documentation'] = DocumentFunction(f)
-    customFunctions.append(f)
+    if IsPrimitiveAvailable(f):
+        f['documentation'] = DocumentFunction(f)
+        customFunctions.append(f)
 
 
 enumerations = []
@@ -367,13 +392,17 @@
     ENUMERATION_TEMPLATE = f.read()
 
 for e in model['enumerations']:
+    if not IsPrimitiveAvailable(e):
+        continue
+
     values = []
     for value in e['values']:
-        values.append({
-            'key' : ToUpperCase(value['key']),
-            'value' : value['value'],
-            'documentation' : value['documentation'],
-        })
+        if IsPrimitiveAvailable(value):
+            values.append({
+                'key' : ToUpperCase(value['key']),
+                'value' : value['value'],
+                'documentation' : value['documentation'],
+            })
 
     enumerations.append({
         'name' : e['name'],
@@ -398,6 +427,9 @@
 countDestructors = 0
 
 for c in model['classes']:
+    if not IsPrimitiveAvailable(c):
+        continue
+
     methods = []
 
     for m in c['methods']:
@@ -410,9 +442,10 @@
 
     if c['name'] in CUSTOM_METHODS:
         for custom_method in CUSTOM_METHODS[c['name']]:
-            custom_method['self'] = True   # Indicates that this is a method
-            custom_method['documentation'] = DocumentFunction(custom_method)
-            custom_methods.append(custom_method)
+            if IsPrimitiveAvailable(custom_method):
+                custom_method['self'] = True   # Indicates that this is a method
+                custom_method['documentation'] = DocumentFunction(custom_method)
+                custom_methods.append(custom_method)
 
     classes.append({
         'description' : classes_description[c['name']],
--- a/Sources/Autogenerated/orthanc.pyi	Tue Aug 12 07:59:46 2025 +0200
+++ b/Sources/Autogenerated/orthanc.pyi	Tue Aug 12 08:18:56 2025 +0200
@@ -2577,20 +2577,6 @@
     """
     ...
 
-# Change the Stable status of a resource
-def SetStableStatus(resource_id: str, stable_status: StableStatus) -> tuple:
-    """
-    Change the Stable status of a resource
-
-    Args:
-      resource_id (str): The id of the resource.
-      stable_status (StableStatus): The new stable status: 0 for Stable, 1 for Unstable.
-
-    Returns:
-      tuple: A tuple with (The error code, An integer indicating wheter the status has changed (1) or not (0) during the execution of this command).
-    """
-    ...
-
 
 class DicomInstance:
     """
--- a/Sources/Autogenerated/sdk_GlobalFunctions.impl.h	Tue Aug 12 07:59:46 2025 +0200
+++ b/Sources/Autogenerated/sdk_GlobalFunctions.impl.h	Tue Aug 12 08:18:56 2025 +0200
@@ -42,7 +42,6 @@
 extern PyObject *RegisterStorageArea(PyObject* module, PyObject *args);
 extern PyObject *RegisterStorageCommitmentScpCallback(PyObject* module, PyObject *args);
 extern PyObject *RegisterWorklistCallback(PyObject* module, PyObject *args);
-extern PyObject *SetStableStatus(PyObject* module, PyObject *args);
 // End of forward declarations
 
 
@@ -2262,8 +2261,6 @@
     "Implemented in C++ function RegisterStorageCommitmentScpCallback()" },
   { "RegisterWorklistCallback", RegisterWorklistCallback, METH_VARARGS,
     "Implemented in C++ function RegisterWorklistCallback()" },
-  { "SetStableStatus", SetStableStatus, METH_VARARGS,
-    "Implemented in C++ function SetStableStatus()" },
   { NULL, NULL }
 };
 
--- a/Sources/Autogenerated/sdk_OrthancPluginKeysValuesIterator.methods.h	Tue Aug 12 07:59:46 2025 +0200
+++ b/Sources/Autogenerated/sdk_OrthancPluginKeysValuesIterator.methods.h	Tue Aug 12 08:18:56 2025 +0200
@@ -80,7 +80,7 @@
   
   if (code == OrthancPluginErrorCode_Success)
   {
-    return PyBytes_FromStringAndSize(buffer.GetData(), buffer.GetSize());
+    return PyBytes_FromStringAndSize(reinterpret_cast<const char*>(buffer.GetData()), buffer.GetSize());
   }
   else
   {
--- a/Sources/Plugin.cpp	Tue Aug 12 07:59:46 2025 +0200
+++ b/Sources/Plugin.cpp	Tue Aug 12 08:18:56 2025 +0200
@@ -286,6 +286,8 @@
   }
 }
 
+
+#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 9)
 PyObject* SetStableStatus(PyObject* module, PyObject* args)
 {
   const char* resourceId = NULL;
@@ -329,6 +331,7 @@
     }
   }
 }
+#endif
 
 
 static bool pythonEnabled_ = false;