diff --git a/PyCore/Sample/ImportMultiLayer.cpp b/PyCore/Sample/ImportMultiLayer.cpp index 8eedcb35e8db1928cfc649f087c7f6ed2b6a300a..271cc81d46d575c44b6f68445e658aa3b0648bd6 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 bac5057da4875f160580842c1f9ac683115f4710..76c06749c313aa983de18c0c58c976b222f5d462 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>