From e90ddefbd3d77f11665d7269c6a81fbedf307dc6 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sat, 23 Jan 2016 14:04:56 +0100 Subject: [PATCH] py3: ported Points to python3 --- src/Mod/Points/App/PointsPy.xml | 2 +- src/Mod/Points/App/PointsPyImp.cpp | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/Mod/Points/App/PointsPy.xml b/src/Mod/Points/App/PointsPy.xml index af555c8b398b..5508183d6477 100644 --- a/src/Mod/Points/App/PointsPy.xml +++ b/src/Mod/Points/App/PointsPy.xml @@ -58,7 +58,7 @@ transforming and much more. Return the number of vertices of the points object. - + diff --git a/src/Mod/Points/App/PointsPyImp.cpp b/src/Mod/Points/App/PointsPyImp.cpp index 4b22b6ffa1e3..f4f21d04e8b6 100644 --- a/src/Mod/Points/App/PointsPyImp.cpp +++ b/src/Mod/Points/App/PointsPyImp.cpp @@ -67,9 +67,15 @@ int PointsPy::PyInit(PyObject* args, PyObject* /*kwd*/) if (!addPoints(args)) return -1; } +#if PY_MAJOR_VERSION >= 3 + else if (PyUnicode_Check(pcObj)) { + getPointKernelPtr()->load(PyUnicode_AsUTF8(pcObj)); + } +#else else if (PyString_Check(pcObj)) { getPointKernelPtr()->load(PyString_AsString(pcObj)); } +#endif else { PyErr_SetString(PyExc_TypeError, "optional argument must be list, tuple or string"); return -1; @@ -168,7 +174,7 @@ PyObject* PointsPy::addPoints(PyObject * args) Py_Return; } - + PyObject* PointsPy::fromSegment(PyObject * args) { PyObject *obj; @@ -216,10 +222,10 @@ PyObject* PointsPy::fromValid(PyObject * args) return 0; } } - -Py::Int PointsPy::getCountPoints(void) const + +Py::Long PointsPy::getCountPoints(void) const { - return Py::Int((long)getPointKernelPtr()->size()); + return Py::Long((long)getPointKernelPtr()->size()); } Py::List PointsPy::getPoints(void) const