Skip to content
Snippets Groups Projects
Commit 11e3246d authored by Pospelov, Gennady's avatar Pospelov, Gennady
Browse files

First working example of reinterpreting PyObject from embedded Python to Multilayer.

parent da3b8ef0
No related branches found
No related tags found
No related merge requests found
......@@ -20,6 +20,7 @@ include_directories(
${PYTHON_INCLUDE_DIRS} ${NUMPY_INCLUDE_DIR}
${EIGEN3_INCLUDE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/../../TestMachinery
${CMAKE_SOURCE_DIR}/auto/Wrap
)
file(GLOB source_files "*.cpp")
......
......@@ -19,6 +19,9 @@
#include "BAVersion.h"
#include "BABuild.h"
#include "SysUtils.h"
#include "swig_runtime.h"
#include "MultiLayer.h"
#include "BornAgainNamespace.h"
#include <iostream>
#include <sstream>
......@@ -282,13 +285,19 @@ bool ObjectExtract::runTest()
PyObject *instance = PyObject_CallFunctionObjArgs(ml, NULL);
// myif *inst = python2interface(instance);
// std::cout << inst->myfunc(input) << std::endl;
void *argp1 = 0;
swig_type_info * pTypeInfo = SWIG_TypeQuery("MultiLayer *");
const int res = SWIG_ConvertPtr(instance, &argp1,pTypeInfo, 0);
if (!SWIG_IsOK(res))
throw std::runtime_error("SWIG failed extract object");
MultiLayer* multilayer = reinterpret_cast<MultiLayer*>(argp1);
Py_DECREF(instance);
Py_DECREF(ml);
Py_Finalize();
return true;
return multilayer->getName() == BornAgain::MultiLayerType;
}
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