Update pybind11 to version 2.2.0

- Replace PYBIND11_PLUGIN with PYBIND11_MODULE

- Fix warnings about symbol visibility by replacing
  'namespace pybind11' with 'namespace PYBIND11_NAMESPACE'

- Pybind sets the default visibility of its namespace to 'hidden'
  Thus, our export functions like  ExportCSG(py::module &m) also are
  hidden by default. To work around that define DLL_HEADER
  '__attribute__ ((visibility ("default")))
  on GNUC platforms.
This commit is contained in:
Matthias Hochsteger 2017-09-01 09:33:57 +02:00
parent 74c8fa5cf4
commit 1430b89e39
12 changed files with 21 additions and 32 deletions

@ -1 +1 @@
Subproject commit fe0cf8b73b8e068c205e062c779eb694b194d6b4
Subproject commit 2a5a5ec0a47c245fbf1bb1a8a90b4c3278e01693

View File

@ -619,10 +619,8 @@ DLL_HEADER void ExportCSG(py::module &m)
;
}
PYBIND11_PLUGIN(libcsg) {
py::module m("csg", "pybind csg");
PYBIND11_MODULE(libcsg, m) {
ExportCSG(m);
return m.ptr();
}
#endif

View File

@ -527,10 +527,8 @@ DLL_HEADER void ExportCSGVis(py::module &m)
});
}
PYBIND11_PLUGIN(libcsgvis) {
py::module m("csg", "pybind csg");
PYBIND11_MODULE(libcsgvis, m) {
ExportCSGVis(m);
return m.ptr();
}
#endif

View File

@ -6,7 +6,8 @@ namespace py = pybind11;
#include <iostream>
#include <sstream>
namespace pybind11 {
namespace PYBIND11_NAMESPACE {
template<typename T>
bool CheckCast( py::handle obj ) {
try{

View File

@ -265,10 +265,8 @@ DLL_HEADER void ExportGeom2d(py::module &m)
}
PYBIND11_PLUGIN(libgeom2d) {
py::module m("geom2d", "pybind geom2d");
PYBIND11_MODULE(libgeom2d, m) {
ExportGeom2d(m);
return m.ptr();
}
#endif

View File

@ -21,7 +21,11 @@
#define DLL_HEADER __declspec(dllimport)
#endif
#else
#define DLL_HEADER
#if __GNUC__ >= 4
#define DLL_HEADER __attribute__ ((visibility ("default")))
#else
#define DLL_HEADER
#endif
#endif

View File

@ -23,7 +23,11 @@
#define DLL_HEADER __declspec(dllimport)
#endif
#else
#define DLL_HEADER
#if __GNUC__ >= 4
#define DLL_HEADER __attribute__ ((visibility ("default")))
#else
#define DLL_HEADER
#endif
#endif

View File

@ -816,10 +816,8 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m)
}));
}
PYBIND11_PLUGIN(libmesh) {
py::module m("mesh", "pybind mesh");
PYBIND11_MODULE(libmesh, m) {
ExportNetgenMeshing(m);
return m.ptr();
}
#endif

View File

@ -46,10 +46,8 @@ DLL_HEADER void ExportNgOCC(py::module &m)
;
}
PYBIND11_PLUGIN(libNgOCC) {
py::module m("NgOCC", "pybind NgOCC");
PYBIND11_MODULE(libNgOCC, m) {
ExportNgOCC(m);
return m.ptr();
}
#endif // OCCGEOMETRY

View File

@ -6,8 +6,6 @@
#ifdef WIN32
#define DLL_HEADER __declspec(dllexport)
#else
#define DLL_HEADER
#endif
using namespace netgen;
@ -47,10 +45,8 @@ DLL_HEADER void ExportSTL(py::module & m)
;
}
PYBIND11_PLUGIN(libstl) {
py::module m("stl", "pybind stl");
PYBIND11_MODULE(libstl, m) {
ExportSTL(m);
return m.ptr();
}
#endif

View File

@ -1218,8 +1218,6 @@ void VisualSceneSTLMeshing :: MouseDblClick (int px, int py)
#ifdef WIN32
#define DLL_HEADER __declspec(dllexport)
#else
#define DLL_HEADER
#endif
#include <../general/ngpython.hpp>
@ -1245,9 +1243,7 @@ DLL_HEADER void ExportSTLVis(py::module &m)
});
}
PYBIND11_PLUGIN(libstlvis) {
py::module m("stlvis", "pybind stl vis");
PYBIND11_MODULE(libstlvis, m) {
ExportSTLVis(m);
return m.ptr();
}
#endif

View File

@ -21,9 +21,8 @@ void DLL_HEADER ExportSTLVis(py::module &m);
void DLL_HEADER ExportNgOCC(py::module &m);
#endif // OCCGEOMETRY
PYBIND11_PLUGIN(libngpy)
PYBIND11_MODULE(libngpy, ngpy)
{
py::module ngpy("libngpy", "pybind netgen module");
py::module meshing = ngpy.def_submodule("_meshing", "pybind meshing module");
ExportNetgenMeshing(meshing);
py::module csg = ngpy.def_submodule("_csg", "pybind csg module");
@ -44,7 +43,6 @@ PYBIND11_PLUGIN(libngpy)
py::module stlvis = ngpy.def_submodule("stlvis", "pybind stlvis module");
ExportSTLVis(stlvis);
#endif // OPENGL
return ngpy.ptr();
}
// Force linking libnglib to libnetgenpy