From f62a6c86589eb6539f927827b0d2eaa402fb8909 Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 31 Mar 2022 15:08:48 +0200 Subject: [PATCH] Base: fix possible Python type mismatch for Base::Vector2dPy when using FreeCAD as a pure Python module. See forum topic: https://forum.freecadweb.org/viewtopic.php?f=10&t=67617 --- src/Base/GeometryPyCXX.cpp | 15 +++++++++++++++ src/Base/GeometryPyCXX.h | 4 ++++ 2 files changed, 19 insertions(+) diff --git a/src/Base/GeometryPyCXX.cpp b/src/Base/GeometryPyCXX.cpp index 032e5a8238..4e6c290519 100644 --- a/src/Base/GeometryPyCXX.cpp +++ b/src/Base/GeometryPyCXX.cpp @@ -91,6 +91,21 @@ Base::Vector3d Py::Vector::toVector() const namespace Base { +Py::PythonType& Vector2dPy::behaviors() +{ + return Py::PythonClass::behaviors(); +} + +PyTypeObject* Vector2dPy::type_object() +{ + return Py::PythonClass::type_object(); +} + +bool Vector2dPy::check( PyObject *p ) +{ + return Py::PythonClass::check(p); +} + Py::PythonClassObject Vector2dPy::create(const Vector2d& v) { return create(v.x, v.y); diff --git a/src/Base/GeometryPyCXX.h b/src/Base/GeometryPyCXX.h index 797a06f682..76ea2324cb 100644 --- a/src/Base/GeometryPyCXX.h +++ b/src/Base/GeometryPyCXX.h @@ -51,6 +51,10 @@ inline Vector3 getVectorFromTuple(PyObject* o) class BaseExport Vector2dPy : public Py::PythonClass { public: + static Py::PythonType &behaviors(); + static PyTypeObject *type_object(); + static bool check( PyObject *p ); + static Py::PythonClassObject create(const Vector2d&); static Py::PythonClassObject create(double x, double y); Vector2dPy(Py::PythonClassInstance *self, Py::Tuple &args, Py::Dict &kwds);