From 7c62ff14d770d76cdb14195383c43fcd9defd701 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Mon, 15 May 2023 10:19:59 +0200 Subject: [PATCH] ImportMultilayer: add/simplify file header --- PyCore/Sample/ImportMultiLayer.cpp | 20 ++++++++++++++++---- PyCore/Sample/ImportMultiLayer.h | 7 +++---- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/PyCore/Sample/ImportMultiLayer.cpp b/PyCore/Sample/ImportMultiLayer.cpp index 8eedcb35e8d..271cc81d46d 100644 --- a/PyCore/Sample/ImportMultiLayer.cpp +++ b/PyCore/Sample/ImportMultiLayer.cpp @@ -1,3 +1,17 @@ +// ************************************************************************************************ +// +// BornAgain: simulate and fit reflection and scattering +// +//! @file PyCore/Sample/ImportMultiLayer.h +//! @brief Implements createMultiLayerFromPython. +//! +//! @homepage http://www.bornagainproject.org +//! @license GNU General Public License v3 or higher (see COPYING) +//! @copyright Forschungszentrum Jülich GmbH 2018 +//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) +// +// ************************************************************************************************ + #ifdef BORNAGAIN_PYTHON #include "ImportMultiLayer.h" @@ -18,11 +32,10 @@ PyObjectPtr createMultiLayerFromPython(void*& multilayer_ptr, const std::string& // locate the `get_simulation` function (it is an attribute of the module) PyObject* pAddFn = PyObject_GetAttrString(tmpModule.get(), functionName.c_str()); - if (!pAddFn) { + if (!pAddFn) throw std::runtime_error(errorDescription("PyInterpreter::BornAgain: " "Cannot locate the compiled function '" + functionName + "'")); - } // create a `MultiLayer` Python object via calling the function PyObject* instance = PyObject_CallFunctionObjArgs(pAddFn, NULL); @@ -30,10 +43,9 @@ PyObjectPtr createMultiLayerFromPython(void*& multilayer_ptr, const std::string& // clean up Py_DecRef(pAddFn); - if (!instance) { + if (!instance) throw std::runtime_error(errorDescription( "PyInterpreter::BornAgain: Cannot call the function '" + functionName + "'")); - } // Construct a C++ object from the Python object /* NOTE: diff --git a/PyCore/Sample/ImportMultiLayer.h b/PyCore/Sample/ImportMultiLayer.h index bac5057da48..76c06749c31 100644 --- a/PyCore/Sample/ImportMultiLayer.h +++ b/PyCore/Sample/ImportMultiLayer.h @@ -3,7 +3,7 @@ // BornAgain: simulate and fit reflection and scattering // //! @file PyCore/Sample/ImportMultiLayer.h -//! @brief Forward declaration for createMultiLayerFromPython. +//! @brief Declares createMultiLayerFromPython. //! //! @homepage http://www.bornagainproject.org //! @license GNU General Public License v3 or higher (see COPYING) @@ -12,12 +12,11 @@ // // ************************************************************************************************ -#ifndef BORNAGAIN_PYCORE_SAMPLE_IMPORTMULTILAYER_H -#define BORNAGAIN_PYCORE_SAMPLE_IMPORTMULTILAYER_H - #ifdef SWIG #error no need to expose this header to Swig #endif +#ifndef BORNAGAIN_PYCORE_SAMPLE_IMPORTMULTILAYER_H +#define BORNAGAIN_PYCORE_SAMPLE_IMPORTMULTILAYER_H #include "PyCore/Embed/PyObjectPtr.h" #include <string> -- GitLab