Skip to content
Snippets Groups Projects
Commit 7c62ff14 authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

ImportMultilayer: add/simplify file header

parent 9ee78637
No related branches found
No related tags found
1 merge request!1636PyCore: Re-implementation of embedded Python as a separate module (Major change)
// ************************************************************************************************
//
// 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:
......
......@@ -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>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment