# HG changeset patch # User Sebastien Jodogne # Date 1720013601 -7200 # Node ID b124c74e696857c6989528764e54a4249515f5d3 # Parent d74ed3e6423ee1f408ffb8abf64584e187396877 simplification diff -r d74ed3e6423e -r b124c74e6968 Sources/Plugin.cpp --- a/Sources/Plugin.cpp Wed Jul 03 15:29:01 2024 +0200 +++ b/Sources/Plugin.cpp Wed Jul 03 15:33:21 2024 +0200 @@ -258,64 +258,10 @@ static bool pythonEnabled_ = false; static std::string userScriptName_; -static std::vector globalFunctions_; static boost::thread displayMemoryUsageThread_; static bool displayMemoryUsageStopping_ = false; -static void SetupGlobalFunctions() -{ - if (!globalFunctions_.empty()) - { - return; -// ORTHANC_PLUGINS_THROW_EXCEPTION(BadSequenceOfCalls); - } - - /** - * Add all the manual global functions - **/ - - std::list functions; - - - /** - * Append all the global functions that were automatically generated - **/ - - const PyMethodDef* sdk = GetOrthancSdkFunctions(); - - for (size_t i = 0; sdk[i].ml_name != NULL; i++) - { - functions.push_back(sdk[i]); - } - - /** - * Flatten the list of functions into the vector - **/ - - globalFunctions_.resize(functions.size()); - std::copy(functions.begin(), functions.end(), globalFunctions_.begin()); - - PyMethodDef sentinel = { NULL }; - globalFunctions_.push_back(sentinel); -} - - -static PyMethodDef* GetGlobalFunctions() -{ - if (globalFunctions_.empty()) - { - // "SetupGlobalFunctions()" should have been called - ORTHANC_PLUGINS_THROW_EXCEPTION(BadSequenceOfCalls); - } - else - { - return &globalFunctions_[0]; - } -} - - - #if HAS_DL_ITERATE == 1 #include @@ -458,8 +404,7 @@ dl_iterate_phdr(ForceImportCallback, NULL); #endif - SetupGlobalFunctions(); - PythonLock::GlobalInitialize("orthanc", "OrthancException", GetGlobalFunctions, RegisterOrthancSdk, isVerbose); + PythonLock::GlobalInitialize("orthanc", "OrthancException", GetOrthancSdkFunctions, RegisterOrthancSdk, isVerbose); PythonLock::AddSysPath(userScriptDirectory.string()); if (pythonConfig.GetBooleanValue("DisplayMemoryUsage", false)) diff -r d74ed3e6423e -r b124c74e6968 Sources/StorageCommitmentScpCallback.cpp --- a/Sources/StorageCommitmentScpCallback.cpp Wed Jul 03 15:29:01 2024 +0200 +++ b/Sources/StorageCommitmentScpCallback.cpp Wed Jul 03 15:33:21 2024 +0200 @@ -21,6 +21,8 @@ #include "StorageCommitmentScpCallback.h" +#include "PythonHeaderWrapper.h" + #include "../Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h" #include "ICallbackRegistration.h" #include "PythonString.h" diff -r d74ed3e6423e -r b124c74e6968 Sources/StorageCommitmentScpCallback.h --- a/Sources/StorageCommitmentScpCallback.h Wed Jul 03 15:29:01 2024 +0200 +++ b/Sources/StorageCommitmentScpCallback.h Wed Jul 03 15:33:21 2024 +0200 @@ -21,8 +21,4 @@ #pragma once -#include "PythonHeaderWrapper.h" - -PyObject* RegisterStorageCommitmentScpCallback(PyObject* module, PyObject* args); - -void FinalizeStorageCommitmentScpCallback(); \ No newline at end of file +void FinalizeStorageCommitmentScpCallback();