py3: ported Points to python3

This commit is contained in:
wmayer 2016-01-23 14:04:56 +01:00
parent 5f5797ecb0
commit e90ddefbd3
2 changed files with 11 additions and 5 deletions

View File

@ -58,7 +58,7 @@ transforming and much more.
<Documentation> <Documentation>
<UserDocu>Return the number of vertices of the points object.</UserDocu> <UserDocu>Return the number of vertices of the points object.</UserDocu>
</Documentation> </Documentation>
<Parameter Name="CountPoints" Type="Int" /> <Parameter Name="CountPoints" Type="Long" />
</Attribute> </Attribute>
<Attribute Name="Points" ReadOnly="true"> <Attribute Name="Points" ReadOnly="true">
<Documentation> <Documentation>

View File

@ -67,9 +67,15 @@ int PointsPy::PyInit(PyObject* args, PyObject* /*kwd*/)
if (!addPoints(args)) if (!addPoints(args))
return -1; return -1;
} }
#if PY_MAJOR_VERSION >= 3
else if (PyUnicode_Check(pcObj)) {
getPointKernelPtr()->load(PyUnicode_AsUTF8(pcObj));
}
#else
else if (PyString_Check(pcObj)) { else if (PyString_Check(pcObj)) {
getPointKernelPtr()->load(PyString_AsString(pcObj)); getPointKernelPtr()->load(PyString_AsString(pcObj));
} }
#endif
else { else {
PyErr_SetString(PyExc_TypeError, "optional argument must be list, tuple or string"); PyErr_SetString(PyExc_TypeError, "optional argument must be list, tuple or string");
return -1; return -1;
@ -168,7 +174,7 @@ PyObject* PointsPy::addPoints(PyObject * args)
Py_Return; Py_Return;
} }
PyObject* PointsPy::fromSegment(PyObject * args) PyObject* PointsPy::fromSegment(PyObject * args)
{ {
PyObject *obj; PyObject *obj;
@ -216,10 +222,10 @@ PyObject* PointsPy::fromValid(PyObject * args)
return 0; 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 Py::List PointsPy::getPoints(void) const