Skip to content

Commit

Permalink
cleanup bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
fraguada committed Aug 6, 2024
1 parent 96c5d61 commit e80d143
Show file tree
Hide file tree
Showing 139 changed files with 287 additions and 1,038 deletions.
2 changes: 1 addition & 1 deletion src/bindings/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ EMSCRIPTEN_BINDINGS(rhino3dm) {
#if defined(ON_PYTHON_COMPILE)
std::string ToStdString(const py::str& str)
{
std::string rc = str;
std::string rc = py::cast<std::string>(str);
return rc;
}
#endif
Expand Down
6 changes: 5 additions & 1 deletion src/bindings/bindings.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,17 @@
#define RH3DM_PYTHON_BINDING(name, variable) NB_MODULE(name, variable)
#define def_property def_prop_rw
#define def_property_readonly def_prop_ro
#define def_readonly def_ro
#define def_readwrite def_rw
#define def_property_readonly_static def_prop_ro_static
#define UNIMPLEMENTED_EXCEPTION throw std::exception()

#else
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
namespace py = pybind11;
#define RH3DM_PYTHON_BINDING(name, variable) PYBIND11_MODULE(name, variable)
typedef pybind11::module_ rh3dmpymodule;
typedef pybind11::module rh3dmpymodule;
#endif

std::string ToStdString(const py::str& str);
Expand All @@ -44,6 +47,7 @@ typedef py::tuple BND_Color;
typedef py::tuple BND_Color4f;
typedef py::tuple BND_TUPLE;
typedef py::handle BND_DateTime;
typedef py::list BND_LIST;
#endif

#if defined(ON_WASM_COMPILE)
Expand Down
10 changes: 3 additions & 7 deletions src/bindings/bnd_3dm_attributes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,8 @@ BND_TUPLE BND_3dmObjectAttributes::GetGroupList() const
//////////////////////////////////////////////////////////////////////////////////////

#if defined(ON_PYTHON_COMPILE)
#if defined(NANOBIND)
namespace py = nanobind;
void init3dmAttributesBindings(py::module_& m){}
#else
namespace py = pybind11;
void init3dmAttributesBindings(py::module& m)

void init3dmAttributesBindings(rh3dmpymodule& m)

{
py::class_<BND_3dmObjectAttributes, BND_CommonObject>(m, "ObjectAttributes")
Expand Down Expand Up @@ -155,7 +151,7 @@ void init3dmAttributesBindings(py::module& m)
.def("RemoveFromAllGroups", &BND_3dmObjectAttributes::RemoveFromAllGroups)
;
}
#endif

#endif

#if defined(ON_WASM_COMPILE)
Expand Down
11 changes: 1 addition & 10 deletions src/bindings/bnd_3dm_attributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,7 @@
#pragma once

#if defined(ON_PYTHON_COMPILE)

#if defined(NANOBIND)
namespace py = nanobind;
void init3dmAttributesBindings(py::module_& m);
#else
namespace py = pybind11;
void init3dmAttributesBindings(py::module& m);
#endif


void init3dmAttributesBindings(rh3dmpymodule& m);
#else
void init3dmAttributesBindings(void* m);
#endif
Expand Down
9 changes: 2 additions & 7 deletions src/bindings/bnd_3dm_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,8 @@ void BND_File3dmSettings::SetEarthAnchorPoint(const BND_EarthAnchorPoint& anchor
}

#if defined(ON_PYTHON_COMPILE)
#if defined(NANOBIND)
namespace py = nanobind;
void init3dmSettingsBindings(py::module_& m){}
#else
namespace py = pybind11;
void init3dmSettingsBindings(py::module& m)

void init3dmSettingsBindings(rh3dmpymodule& m)
{
py::class_<BND_ConstructionPlane>(m, "ConstructionPlane")
.def(py::init<>())
Expand Down Expand Up @@ -220,7 +215,7 @@ void init3dmSettingsBindings(py::module& m)
.def_property_readonly("RenderSettings", &BND_File3dmSettings::GetRenderSettings)
;
}
#endif

#endif

#if defined(ON_WASM_COMPILE)
Expand Down
9 changes: 1 addition & 8 deletions src/bindings/bnd_3dm_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,7 @@
#pragma once

#if defined(ON_PYTHON_COMPILE)
#if defined(NANOBIND)
namespace py = nanobind;
void init3dmSettingsBindings(py::module_& m);
#else
namespace py = pybind11;
void init3dmSettingsBindings(py::module& m);
#endif

void init3dmSettingsBindings(rh3dmpymodule& m);
#else
void init3dmSettingsBindings(void* m);
#endif
Expand Down
6 changes: 1 addition & 5 deletions src/bindings/bnd_annotationbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -630,10 +630,7 @@ std::vector<ON_Line> BND_Centermark::GetDisplayLines(const BND_DimensionStyle& d

#if defined(ON_PYTHON_COMPILE)

#if defined(NANOBIND)
void initAnnotationBaseBindings(py::module_& m){}
#else
void initAnnotationBaseBindings(py::module& m)
void initAnnotationBaseBindings(rh3dmpymodule& m)
{
py::class_<BND_AnnotationBase, BND_GeometryBase>(m, "AnnotationBase")
.def_property_readonly("DimensionStyleId", &BND_AnnotationBase::DimensionStyleId)
Expand Down Expand Up @@ -691,7 +688,6 @@ void initAnnotationBaseBindings(py::module& m)

}
#endif
#endif

#if defined(ON_WASM_COMPILE)
using namespace emscripten;
Expand Down
9 changes: 1 addition & 8 deletions src/bindings/bnd_annotationbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,7 @@
#pragma once

#if defined(ON_PYTHON_COMPILE)
#if defined(NANOBIND)
namespace py = nanobind;
void initAnnotationBaseBindings(py::module_& m);
#else
namespace py = pybind11;
void initAnnotationBaseBindings(py::module& m);
#endif

void initAnnotationBaseBindings(rh3dmpymodule& m);
#else
void initAnnotationBaseBindings(void* m);
#endif
Expand Down
9 changes: 1 addition & 8 deletions src/bindings/bnd_arc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,7 @@ BND_NurbsCurve* BND_Arc::ToNurbsCurve() const

#if defined(ON_PYTHON_COMPILE)

#if defined(NANOBIND)
namespace py = nanobind;
void initArcBindings(py::module_& m){}
#else
namespace py = pybind11;
void initArcBindings(py::module& m)

void initArcBindings(rh3dmpymodule& m)
{
py::class_<BND_Arc>(m, "Arc")
.def(py::init<const BND_Circle&, double>(), py::arg("circle"), py::arg("angleRadians"))
Expand Down Expand Up @@ -167,7 +161,6 @@ void initArcBindings(py::module& m)
.def("ToNurbsCurve", &BND_Arc::ToNurbsCurve);
}
#endif
#endif

#if defined(ON_WASM_COMPILE)
using namespace emscripten;
Expand Down
9 changes: 1 addition & 8 deletions src/bindings/bnd_arc.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,7 @@
#pragma once

#if defined(ON_PYTHON_COMPILE)
#if defined(NANOBIND)
namespace py = nanobind;
void initArcBindings(py::module_& m);
#else
namespace py = pybind11;
void initArcBindings(py::module& m);
#endif

void initArcBindings(rh3dmpymodule& m);
#else
void initArcBindings(void* m);
#endif
Expand Down
8 changes: 1 addition & 7 deletions src/bindings/bnd_arccurve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,7 @@ void BND_ArcCurve::SetTrackedPointer(ON_ArcCurve* arccurve, const ON_ModelCompon

#if defined(ON_PYTHON_COMPILE)

#if defined(NANOBIND)
namespace py = nanobind;
void initArcCurveBindings(py::module_& m){}
#else
namespace py = pybind11;
void initArcCurveBindings(py::module& m)
void initArcCurveBindings(rh3dmpymodule& m)
{
py::class_<BND_ArcCurve, BND_Curve>(m, "ArcCurve")
.def_static("CreateFromArc", &BND_ArcCurve::CreateFromArc, py::arg("arc"))
Expand All @@ -73,7 +68,6 @@ void initArcCurveBindings(py::module& m)
;
}
#endif
#endif

#if defined(ON_WASM_COMPILE)
using namespace emscripten;
Expand Down
9 changes: 1 addition & 8 deletions src/bindings/bnd_arccurve.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,7 @@
#pragma once

#if defined(ON_PYTHON_COMPILE)
#if defined(NANOBIND)
namespace py = nanobind;
void initArcCurveBindings(py::module_& m);
#else
namespace py = pybind11;
void initArcCurveBindings(py::module& m);
#endif

void initArcCurveBindings(rh3dmpymodule& m);
#else
void initArcCurveBindings(void* m);
#endif
Expand Down
8 changes: 1 addition & 7 deletions src/bindings/bnd_beam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,8 @@ BND_Extrusion::BND_Extrusion(ON_Extrusion* extrusion, const ON_ModelComponentRef
//////////////////////////////////////////////////////////////////////////////

#if defined(ON_PYTHON_COMPILE)
#if defined(NANOBIND)
namespace py = nanobind;
void initExtrusionBindings(py::module_& m){}
#else
namespace py = pybind11;
void initExtrusionBindings(py::module& m)

void initExtrusionBindings(rh3dmpymodule& m)
{
py::class_<BND_Extrusion, BND_Surface>(m, "Extrusion")
.def_static("Create", &BND_Extrusion::Create, py::arg("planarCurve"), py::arg("height"), py::arg("cap"))
Expand Down Expand Up @@ -236,7 +231,6 @@ void initExtrusionBindings(py::module& m)
;
}
#endif
#endif

#if defined(ON_WASM_COMPILE)
using namespace emscripten;
Expand Down
9 changes: 1 addition & 8 deletions src/bindings/bnd_beam.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,7 @@
#pragma once

#if defined(ON_PYTHON_COMPILE)
#if defined(NANOBIND)
namespace py = nanobind;
void initExtrusionBindings(py::module_& m);
#else
namespace py = pybind11;
void initExtrusionBindings(py::module& m);
#endif

void initExtrusionBindings(rh3dmpymodule& m);
#else
void initExtrusionBindings(void* m);
#endif
Expand Down
9 changes: 2 additions & 7 deletions src/bindings/bnd_bezier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,8 @@ BND_TUPLE BND_BezierCurve::Split(double t)


#if defined(ON_PYTHON_COMPILE)
#if defined(NANOBIND)
namespace py = nanobind;
void initBezierBindings(py::module_& m){}
#else
namespace py = pybind11;
void initBezierBindings(py::module& m)

void initBezierBindings(rh3dmpymodule& m)
{
py::class_<BND_BezierCurve>(m, "BezierCurve")
.def_property_readonly("Dimension", &BND_BezierCurve::Dimension)
Expand All @@ -56,7 +52,6 @@ void initBezierBindings(py::module& m)
;
}
#endif
#endif

#if defined(ON_WASM_COMPILE)
using namespace emscripten;
Expand Down
9 changes: 1 addition & 8 deletions src/bindings/bnd_bezier.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,7 @@
#pragma once

#if defined(ON_PYTHON_COMPILE)
#if defined(NANOBIND)
namespace py = nanobind;
void initBezierBindings(py::module_& m);
#else
namespace py = pybind11;
void initBezierBindings(py::module& m);
#endif

void initBezierBindings(rh3dmpymodule& m);
#else
void initBezierBindings(void* m);
#endif
Expand Down
9 changes: 2 additions & 7 deletions src/bindings/bnd_bitmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,8 @@ void BND_Bitmap::SetTrackedPointer(ON_Bitmap* bitmap, const ON_ModelComponentRef


#if defined(ON_PYTHON_COMPILE)
#if defined(NANOBIND)
namespace py = nanobind;
void initBitmapBindings(py::module_& m){}
#else
namespace py = pybind11;
void initBitmapBindings(py::module& m)

void initBitmapBindings(rh3dmpymodule& m)
{
py::class_<BND_Bitmap>(m, "Bitmap")
.def(py::init<>())
Expand All @@ -34,7 +30,6 @@ void initBitmapBindings(py::module& m)
;
}
#endif
#endif

#if defined(ON_WASM_COMPILE)
using namespace emscripten;
Expand Down
9 changes: 1 addition & 8 deletions src/bindings/bnd_bitmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,7 @@
#pragma once

#if defined(ON_PYTHON_COMPILE)
#if defined(NANOBIND)
namespace py = nanobind;
void initBitmapBindings(py::module_& m);
#else
namespace py = pybind11;
void initBitmapBindings(py::module& m);
#endif

void initBitmapBindings(rh3dmpymodule& m);
#else
void initBitmapBindings(void* m);
#endif
Expand Down
7 changes: 2 additions & 5 deletions src/bindings/bnd_boundingbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,8 @@ BND_BoundingBox* BND_BoundingBox::Decode(emscripten::val jsonObject)


#if defined(ON_PYTHON_COMPILE)
#if defined(NANOBIND)
void initBoundingBoxBindings(py::module_& m){}
#else
void initBoundingBoxBindings(py::module& m)

void initBoundingBoxBindings(rh3dmpymodule& m)
{
py::class_<BND_BoundingBox>(m, "BoundingBox")
.def(py::init<ON_3dPoint, ON_3dPoint>(), py::arg("minPoint"), py::arg("maxPoint"))
Expand All @@ -189,7 +187,6 @@ void initBoundingBoxBindings(py::module& m)
;
}
#endif
#endif

#if defined(ON_WASM_COMPILE)
using namespace emscripten;
Expand Down
9 changes: 1 addition & 8 deletions src/bindings/bnd_boundingbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,7 @@
#pragma once

#if defined(ON_PYTHON_COMPILE)
#if defined(NANOBIND)
namespace py = nanobind;
void initBoundingBoxBindings(py::module_& m);
#else
namespace py = pybind11;
void initBoundingBoxBindings(py::module& m);
#endif

void initBoundingBoxBindings(rh3dmpymodule& m);
#else
void initBoundingBoxBindings(void* m);
#endif
Expand Down
Loading

0 comments on commit e80d143

Please sign in to comment.