diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2013-02-24 06:39:38 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2013-02-24 06:39:38 +0400 |
commit | 3df023ae82eef0ea105dc61c9730af87b59a07d1 (patch) | |
tree | 2d2a4e753c1129fc91f360f0457d30859cd38737 /source/blender/freestyle/intern/python/Interface0D | |
parent | d38a335d47f1632000db5172877499ff0184d114 (diff) |
Freestyle Python API improvements - part 8.
* Proper handling of keyword arguments was implemented in Operators and ContextFunctions,
as well as in methods of Interface0D, Interface1D, Iterator, their subclasses, Noise and
IntegrationType.
* Operators' methods and functions in the ContextFunctions module were renamed from
CamelCase to lower cases + underscores. Style modules were updated accordingly.
* Additional code clean-up was also made.
Diffstat (limited to 'source/blender/freestyle/intern/python/Interface0D')
3 files changed, 37 insertions, 39 deletions
diff --git a/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp b/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp index 6cc16494b87..072a602cf29 100644 --- a/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp +++ b/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp @@ -102,18 +102,20 @@ static int SVertex_init(BPy_SVertex *self, PyObject *args, PyObject *kwds) } PyDoc_STRVAR(SVertex_add_normal_doc, -".. method:: add_normal(n)\n" +".. method:: add_normal(normal)\n" "\n" " Adds a normal to the SVertex's set of normals. If the same normal\n" " is already in the set, nothing changes.\n" "\n" -" :arg n: A three-dimensional vector.\n" -" :type n: :class:`mathutils.Vector`, list or tuple of 3 real numbers"); +" :arg normal: A three-dimensional vector.\n" +" :type normal: :class:`mathutils.Vector`, list or tuple of 3 real numbers"); -static PyObject *SVertex_add_normal( BPy_SVertex *self , PyObject *args) { +static PyObject *SVertex_add_normal(BPy_SVertex *self , PyObject *args, PyObject *kwds) +{ + static const char *kwlist[] = {"normal", NULL}; PyObject *py_normal; - if (!PyArg_ParseTuple(args, "O", &py_normal)) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O", (char **)kwlist, &py_normal)) return NULL; Vec3r *n = Vec3r_ptr_from_PyObject(py_normal); if (!n) { @@ -127,29 +129,29 @@ static PyObject *SVertex_add_normal( BPy_SVertex *self , PyObject *args) { } PyDoc_STRVAR(SVertex_add_fedge_doc, -".. method:: add_fedge(fe)\n" +".. method:: add_fedge(fedge)\n" "\n" " Add an FEdge to the list of edges emanating from this SVertex.\n" "\n" -" :arg fe: An FEdge.\n" -" :type fe: :class:`FEdge`"); +" :arg fedge: An FEdge.\n" +" :type fedge: :class:`FEdge`"); -static PyObject *SVertex_add_fedge( BPy_SVertex *self , PyObject *args) { +static PyObject *SVertex_add_fedge(BPy_SVertex *self , PyObject *args, PyObject *kwds) +{ + static const char *kwlist[] = {"fedge", NULL}; PyObject *py_fe; - if (!PyArg_ParseTuple(args, "O!", &FEdge_Type, &py_fe)) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &FEdge_Type, &py_fe)) return NULL; - self->sv->AddFEdge(((BPy_FEdge *)py_fe)->fe); - Py_RETURN_NONE; } // virtual bool operator== (const SVertex &brother) static PyMethodDef BPy_SVertex_methods[] = { - {"add_normal", (PyCFunction)SVertex_add_normal, METH_VARARGS, SVertex_add_normal_doc}, - {"add_fedge", (PyCFunction)SVertex_add_fedge, METH_VARARGS, SVertex_add_fedge_doc}, + {"add_normal", (PyCFunction)SVertex_add_normal, METH_VARARGS | METH_KEYWORDS, SVertex_add_normal_doc}, + {"add_fedge", (PyCFunction)SVertex_add_fedge, METH_VARARGS | METH_KEYWORDS, SVertex_add_fedge_doc}, {NULL, NULL, 0, NULL} }; diff --git a/source/blender/freestyle/intern/python/Interface0D/BPy_ViewVertex.cpp b/source/blender/freestyle/intern/python/Interface0D/BPy_ViewVertex.cpp index 696ab102270..1e5f70144c1 100644 --- a/source/blender/freestyle/intern/python/Interface0D/BPy_ViewVertex.cpp +++ b/source/blender/freestyle/intern/python/Interface0D/BPy_ViewVertex.cpp @@ -76,8 +76,6 @@ PyDoc_STRVAR(ViewVertex_edges_begin_doc, static PyObject * ViewVertex_edges_begin(BPy_ViewVertex *self) { - if (!self->vv) - Py_RETURN_NONE; ViewVertexInternal::orientedViewEdgeIterator ove_it(self->vv->edgesBegin()); return BPy_orientedViewEdgeIterator_from_orientedViewEdgeIterator(ove_it, 0); } @@ -94,8 +92,6 @@ PyDoc_STRVAR(ViewVertex_edges_end_doc, static PyObject * ViewVertex_edges_end(BPy_ViewVertex *self) { #if 0 - if (!self->vv) - Py_RETURN_NONE; ViewVertexInternal::orientedViewEdgeIterator ove_it(self->vv->edgesEnd()); return BPy_orientedViewEdgeIterator_from_orientedViewEdgeIterator(ove_it, 1); #else @@ -105,23 +101,22 @@ static PyObject * ViewVertex_edges_end(BPy_ViewVertex *self) } PyDoc_STRVAR(ViewVertex_edges_iterator_doc, -".. method:: edges_iterator(iEdge)\n" +".. method:: edges_iterator(edge)\n" "\n" " Returns an orientedViewEdgeIterator pointing to the ViewEdge given\n" " as argument.\n" "\n" -" :arg iEdge: A ViewEdge object.\n" -" :type iEdge: :class:`ViewEdge`\n" +" :arg edge: A ViewEdge object.\n" +" :type edge: :class:`ViewEdge`\n" " :return: An orientedViewEdgeIterator pointing to the given ViewEdge.\n" " :rtype: :class:`orientedViewEdgeIterator`"); -static PyObject * ViewVertex_edges_iterator(BPy_ViewVertex *self, PyObject *args) +static PyObject * ViewVertex_edges_iterator(BPy_ViewVertex *self, PyObject *args, PyObject *kwds) { + static const char *kwlist[] = {"edge", NULL}; PyObject *py_ve; - if (!self->vv) - Py_RETURN_NONE; - if (!PyArg_ParseTuple(args, "O!", &ViewEdge_Type, &py_ve)) + if (PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &ViewEdge_Type, &py_ve)) return NULL; ViewEdge *ve = ((BPy_ViewEdge *)py_ve)->ve; ViewVertexInternal::orientedViewEdgeIterator ove_it(self->vv->edgesIterator(ve)); @@ -131,7 +126,7 @@ static PyObject * ViewVertex_edges_iterator(BPy_ViewVertex *self, PyObject *args static PyMethodDef BPy_ViewVertex_methods[] = { {"edges_begin", (PyCFunction)ViewVertex_edges_begin, METH_NOARGS, ViewVertex_edges_begin_doc}, {"edges_end", (PyCFunction)ViewVertex_edges_end, METH_NOARGS, ViewVertex_edges_end_doc}, - {"edges_iterator", (PyCFunction)ViewVertex_edges_iterator, METH_VARARGS, ViewVertex_edges_iterator_doc}, + {"edges_iterator", (PyCFunction)ViewVertex_edges_iterator, METH_VARARGS | METH_KEYWORDS, ViewVertex_edges_iterator_doc}, {NULL, NULL, 0, NULL} }; @@ -212,4 +207,3 @@ PyTypeObject ViewVertex_Type = { #ifdef __cplusplus } #endif - diff --git a/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_TVertex.cpp b/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_TVertex.cpp index 7cf6e0571d5..e6285371c77 100644 --- a/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_TVertex.cpp +++ b/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_TVertex.cpp @@ -74,20 +74,21 @@ static int TVertex_init(BPy_TVertex *self, PyObject *args, PyObject *kwds) } PyDoc_STRVAR(TVertex_get_svertex_doc, -".. method:: get_svertex(iFEdge)\n" +".. method:: get_svertex(fedge)\n" "\n" " Returns the SVertex (among the 2) belonging to the given FEdge.\n" "\n" -" :arg iFEdge: An FEdge object.\n" -" :type iFEdge: :class:`FEdge`\n" +" :arg fedge: An FEdge object.\n" +" :type fedge: :class:`FEdge`\n" " :return: The SVertex belonging to the given FEdge.\n" " :rtype: :class:`SVertex`"); -static PyObject * TVertex_get_svertex( BPy_TVertex *self, PyObject *args) +static PyObject * TVertex_get_svertex( BPy_TVertex *self, PyObject *args, PyObject *kwds) { + static const char *kwlist[] = {"fedge", NULL}; PyObject *py_fe; - if (!PyArg_ParseTuple(args, "O!", &FEdge_Type, &py_fe)) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &FEdge_Type, &py_fe)) return NULL; SVertex *sv = self->tv->getSVertex(((BPy_FEdge *)py_fe)->fe); if (sv) @@ -96,22 +97,23 @@ static PyObject * TVertex_get_svertex( BPy_TVertex *self, PyObject *args) } PyDoc_STRVAR(TVertex_get_mate_doc, -".. method:: get_mate(iEdgeA)\n" +".. method:: get_mate(viewedge)\n" "\n" " Returns the mate edge of the ViewEdge given as argument. If the\n" " ViewEdge is frontEdgeA, frontEdgeB is returned. If the ViewEdge is\n" " frontEdgeB, frontEdgeA is returned. Same for back edges.\n" "\n" -" :arg iEdgeA: A ViewEdge object.\n" -" :type iEdgeA: :class:`ViewEdge`\n" +" :arg viewedge: A ViewEdge object.\n" +" :type viewedge: :class:`ViewEdge`\n" " :return: The mate edge of the given ViewEdge.\n" " :rtype: :class:`ViewEdge`"); -static PyObject * TVertex_get_mate( BPy_TVertex *self, PyObject *args) +static PyObject * TVertex_get_mate( BPy_TVertex *self, PyObject *args, PyObject *kwds) { + static const char *kwlist[] = {"viewedge", NULL}; PyObject *py_ve; - if (!PyArg_ParseTuple(args, "O!", &ViewEdge_Type, &py_ve)) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &ViewEdge_Type, &py_ve)) return NULL; ViewEdge *ve = self->tv->mate(((BPy_ViewEdge *)py_ve)->ve); if (ve) @@ -120,8 +122,8 @@ static PyObject * TVertex_get_mate( BPy_TVertex *self, PyObject *args) } static PyMethodDef BPy_TVertex_methods[] = { - {"get_svertex", (PyCFunction)TVertex_get_svertex, METH_VARARGS, TVertex_get_svertex_doc}, - {"get_mate", (PyCFunction)TVertex_get_mate, METH_VARARGS, TVertex_get_mate_doc}, + {"get_svertex", (PyCFunction)TVertex_get_svertex, METH_VARARGS | METH_KEYWORDS, TVertex_get_svertex_doc}, + {"get_mate", (PyCFunction)TVertex_get_mate, METH_VARARGS | METH_KEYWORDS, TVertex_get_mate_doc}, {NULL, NULL, 0, NULL} }; |