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
This commit is contained in:
wmayer
2022-03-31 15:08:48 +02:00
parent 19feabd072
commit f62a6c8658
2 changed files with 19 additions and 0 deletions

View File

@@ -91,6 +91,21 @@ Base::Vector3d Py::Vector::toVector() const
namespace Base {
Py::PythonType& Vector2dPy::behaviors()
{
return Py::PythonClass<Vector2dPy>::behaviors();
}
PyTypeObject* Vector2dPy::type_object()
{
return Py::PythonClass<Vector2dPy>::type_object();
}
bool Vector2dPy::check( PyObject *p )
{
return Py::PythonClass<Vector2dPy>::check(p);
}
Py::PythonClassObject<Vector2dPy> Vector2dPy::create(const Vector2d& v)
{
return create(v.x, v.y);

View File

@@ -51,6 +51,10 @@ inline Vector3<T> getVectorFromTuple(PyObject* o)
class BaseExport Vector2dPy : public Py::PythonClass<Vector2dPy>
{
public:
static Py::PythonType &behaviors();
static PyTypeObject *type_object();
static bool check( PyObject *p );
static Py::PythonClassObject<Vector2dPy> create(const Vector2d&);
static Py::PythonClassObject<Vector2dPy> create(double x, double y);
Vector2dPy(Py::PythonClassInstance *self, Py::Tuple &args, Py::Dict &kwds);