aboutsummaryrefslogtreecommitdiffstats
path: root/common/pybindings.h
diff options
context:
space:
mode:
authorMiodrag Milanovic <mmicko@gmail.com>2020-07-23 18:35:18 +0200
committerMiodrag Milanovic <mmicko@gmail.com>2020-07-23 18:35:18 +0200
commit8f2b707d026597018333ac60e707e5ab78c25a91 (patch)
treeebf5c6490a56269d674a5d1d5357c7b5e2210872 /common/pybindings.h
parent444e535f000fd7b53dadf6726d5cd29ac34cc75f (diff)
downloadnextpnr-8f2b707d026597018333ac60e707e5ab78c25a91.tar.gz
nextpnr-8f2b707d026597018333ac60e707e5ab78c25a91.tar.bz2
nextpnr-8f2b707d026597018333ac60e707e5ab78c25a91.zip
Initial conversion to pybind11
Diffstat (limited to 'common/pybindings.h')
-rw-r--r--common/pybindings.h13
1 files changed, 6 insertions, 7 deletions
diff --git a/common/pybindings.h b/common/pybindings.h
index c4d84442..4923c821 100644
--- a/common/pybindings.h
+++ b/common/pybindings.h
@@ -22,11 +22,10 @@
#define COMMON_PYBINDINGS_H
#include <Python.h>
-#include <boost/python.hpp>
-#include <boost/python/suite/indexing/map_indexing_suite.hpp>
-#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
+#include <pybind11/pybind11.h>
#include <stdexcept>
#include <utility>
+#include <iostream>
#include "pycontainers.h"
#include "pywrappers.h"
@@ -34,7 +33,7 @@
NEXTPNR_NAMESPACE_BEGIN
-using namespace boost::python;
+namespace py = pybind11;
std::string parse_python_exception();
@@ -46,9 +45,9 @@ template <typename Tn> void python_export_global(const char *name, Tn &x)
return;
d = PyModule_GetDict(m);
try {
- PyObject *p = incref(object(boost::ref(x)).ptr());
- PyDict_SetItemString(d, name, p);
- } catch (boost::python::error_already_set const &) {
+ py::object obj = py::cast(x);
+ PyDict_SetItemString(d, name, obj.ptr());
+ } catch (py::error_already_set const &) {
// Parse and output the exception
std::string perror_str = parse_python_exception();
std::cout << "Error in Python: " << perror_str << std::endl;