Mercurial > hg > orthanc-python
changeset 215:b124c74e6968
simplification
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 03 Jul 2024 15:33:21 +0200 |
parents | d74ed3e6423e |
children | dff82fbd0a15 |
files | Sources/Plugin.cpp Sources/StorageCommitmentScpCallback.cpp Sources/StorageCommitmentScpCallback.h |
diffstat | 3 files changed, 4 insertions(+), 61 deletions(-) [+] |
line wrap: on
line diff
--- 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<PyMethodDef> 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<PyMethodDef> 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 <dlfcn.h> @@ -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))
--- 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"
--- 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();