diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2013-02-23 05:12:23 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2013-02-23 05:12:23 +0400 |
commit | 68b0a8e39026ea2b391751406dc4bdb0a4ed958c (patch) | |
tree | cdf8a143a6cf2b832f49a31c2d3b7003f92eaa43 | |
parent | 0fb83d78faa99a8ea3fd396887b2b31a6a36a8cd (diff) |
Freestyle Python API improvements - part 7.
Fix for PyGetSetDef and proper handling of keyword arguments were done in
UnaryPredicate0D, UnaryPredicate1D, BinaryPredicate1D, and StrokeShader classes.
Style modules were updated accordingly. Additional code clean-up was also made.
51 files changed, 652 insertions, 613 deletions
diff --git a/release/scripts/freestyle/style_modules/anisotropic_diffusion.py b/release/scripts/freestyle/style_modules/anisotropic_diffusion.py index 83cc9991d8b..44a820a1048 100644 --- a/release/scripts/freestyle/style_modules/anisotropic_diffusion.py +++ b/release/scripts/freestyle/style_modules/anisotropic_diffusion.py @@ -39,7 +39,7 @@ bpred = TrueBP1D() Operators.bidirectionalChain(ChainPredicateIterator(upred, bpred), NotUP1D(upred) ) shaders_list = [ ConstantThicknessShader(4), - StrokeTextureShader("smoothAlpha.bmp", Stroke.OPAQUE_MEDIUM, 0), + StrokeTextureShader("smoothAlpha.bmp", Stroke.OPAQUE_MEDIUM, False), SamplingShader(2), pyDiffusion2Shader(offset, nbIter), IncreasingColorShader(1, 0, 0, 1, 0, 1, 0, 1) diff --git a/release/scripts/freestyle/style_modules/curvature2d.py b/release/scripts/freestyle/style_modules/curvature2d.py index 0c013997a16..ca84bf21b83 100644 --- a/release/scripts/freestyle/style_modules/curvature2d.py +++ b/release/scripts/freestyle/style_modules/curvature2d.py @@ -33,7 +33,7 @@ from shaders import * Operators.select(QuantitativeInvisibilityUP1D(0)) Operators.bidirectionalChain(ChainSilhouetteIterator(), NotUP1D(QuantitativeInvisibilityUP1D(0))) shaders_list = [ - StrokeTextureShader("smoothAlpha.bmp", Stroke.OPAQUE_MEDIUM, 0), + StrokeTextureShader("smoothAlpha.bmp", Stroke.OPAQUE_MEDIUM, False), ConstantThicknessShader(5), py2DCurvatureColorShader() ] diff --git a/release/scripts/freestyle/style_modules/sketchy_multiple_parameterization.py b/release/scripts/freestyle/style_modules/sketchy_multiple_parameterization.py index 163c891fa90..76ab4343316 100644 --- a/release/scripts/freestyle/style_modules/sketchy_multiple_parameterization.py +++ b/release/scripts/freestyle/style_modules/sketchy_multiple_parameterization.py @@ -38,7 +38,7 @@ Operators.select(QuantitativeInvisibilityUP1D(0)) Operators.bidirectionalChain(pySketchyChainSilhouetteIterator(3,0)) shaders_list = [ SamplingShader(2), - SpatialNoiseShader(15, 120, 2, 1, 1), + SpatialNoiseShader(15, 120, 2, True, True), IncreasingThicknessShader(5, 30), SmoothingShader(100, 0.05, 0, 0.2, 0, 0, 0, 1), IncreasingColorShader(0,0.2,0,1,0.2,0.7,0.2,1), diff --git a/release/scripts/freestyle/style_modules/sketchy_topology_broken.py b/release/scripts/freestyle/style_modules/sketchy_topology_broken.py index e51acb93fbc..eb600e62af7 100644 --- a/release/scripts/freestyle/style_modules/sketchy_topology_broken.py +++ b/release/scripts/freestyle/style_modules/sketchy_topology_broken.py @@ -38,7 +38,7 @@ Operators.select(QuantitativeInvisibilityUP1D(0)) Operators.bidirectionalChain(pySketchyChainingIterator(3)) shaders_list = [ SamplingShader(4), - SpatialNoiseShader(6, 120, 2, 1, 1), + SpatialNoiseShader(6, 120, 2, True, True), IncreasingThicknessShader(4, 10), SmoothingShader(100, 0.1, 0, 0.2, 0, 0, 0, 1), pyBackboneStretcherNoCuspShader(20), diff --git a/release/scripts/freestyle/style_modules/sketchy_topology_preserved.py b/release/scripts/freestyle/style_modules/sketchy_topology_preserved.py index 85e11af38b9..0c2d9d759a6 100644 --- a/release/scripts/freestyle/style_modules/sketchy_topology_preserved.py +++ b/release/scripts/freestyle/style_modules/sketchy_topology_preserved.py @@ -38,7 +38,7 @@ Operators.select(upred) Operators.bidirectionalChain(pySketchyChainSilhouetteIterator(3,1)) shaders_list = [ SamplingShader(4), - SpatialNoiseShader(20, 220, 2, 1, 1), + SpatialNoiseShader(20, 220, 2, True, True), IncreasingThicknessShader(4, 8), SmoothingShader(300, 0.05, 0, 0.2, 0, 0, 0, 0.5), ConstantColorShader(0.6,0.2,0.0), diff --git a/release/scripts/freestyle/style_modules/stroke_texture.py b/release/scripts/freestyle/style_modules/stroke_texture.py index afebbe30a90..035967dc39c 100644 --- a/release/scripts/freestyle/style_modules/stroke_texture.py +++ b/release/scripts/freestyle/style_modules/stroke_texture.py @@ -36,7 +36,7 @@ Operators.bidirectionalChain(ChainSilhouetteIterator(), NotUP1D(QuantitativeInvi shaders_list = [ SamplingShader(3), BezierCurveShader(4), - StrokeTextureShader("washbrushAlpha.bmp", Stroke.DRY_MEDIUM, 1), + StrokeTextureShader("washbrushAlpha.bmp", Stroke.DRY_MEDIUM, True), ConstantThicknessShader(40), ConstantColorShader(0,0,0,1), ] diff --git a/release/scripts/freestyle/style_modules/uniformpruning_zsort.py b/release/scripts/freestyle/style_modules/uniformpruning_zsort.py index 9a8ba0d12f8..c8537cd4241 100644 --- a/release/scripts/freestyle/style_modules/uniformpruning_zsort.py +++ b/release/scripts/freestyle/style_modules/uniformpruning_zsort.py @@ -12,7 +12,7 @@ Operators.bidirectionalChain(ChainSilhouetteIterator()) #Operators.sequentialSplit(pyVertexNatureUP0D(Nature.VIEW_VERTEX), 2) Operators.sort(pyZBP1D()) shaders_list = [ - StrokeTextureShader("smoothAlpha.bmp", Stroke.OPAQUE_MEDIUM, 0), + StrokeTextureShader("smoothAlpha.bmp", Stroke.OPAQUE_MEDIUM, False), ConstantThicknessShader(3), SamplingShader(5.0), ConstantColorShader(0,0,0,1) diff --git a/source/blender/freestyle/intern/python/BPy_BinaryPredicate0D.cpp b/source/blender/freestyle/intern/python/BPy_BinaryPredicate0D.cpp index 693d35b1f60..b85b2ed6308 100644 --- a/source/blender/freestyle/intern/python/BPy_BinaryPredicate0D.cpp +++ b/source/blender/freestyle/intern/python/BPy_BinaryPredicate0D.cpp @@ -10,15 +10,15 @@ extern "C" { /////////////////////////////////////////////////////////////////////////////////////////// //-------------------MODULE INITIALIZATION-------------------------------- -int BinaryPredicate0D_Init( PyObject *module ) +int BinaryPredicate0D_Init(PyObject *module) { - if( module == NULL ) + if (module == NULL) return -1; - if( PyType_Ready( &BinaryPredicate0D_Type ) < 0 ) + if (PyType_Ready(&BinaryPredicate0D_Type) < 0) return -1; - Py_INCREF( &BinaryPredicate0D_Type ); + Py_INCREF(&BinaryPredicate0D_Type); PyModule_AddObject(module, "BinaryPredicate0D", (PyObject *)&BinaryPredicate0D_Type); return 0; } @@ -50,11 +50,12 @@ static char BinaryPredicate0D___doc__[] = static int BinaryPredicate0D___init__(BPy_BinaryPredicate0D *self, PyObject *args, PyObject *kwds) { - if ( !PyArg_ParseTuple(args, "") ) - return -1; + static const char *kwlist[] = {NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) + return -1; self->bp0D = new BinaryPredicate0D(); - self->bp0D->py_bp0D = (PyObject *) self; - + self->bp0D->py_bp0D = (PyObject *)self; return 0; } @@ -62,58 +63,53 @@ static void BinaryPredicate0D___dealloc__(BPy_BinaryPredicate0D* self) { if (self->bp0D) delete self->bp0D; - Py_TYPE(self)->tp_free((PyObject*)self); + Py_TYPE(self)->tp_free((PyObject*)self); } - static PyObject * BinaryPredicate0D___repr__(BPy_BinaryPredicate0D* self) { - return PyUnicode_FromFormat("type: %s - address: %p", self->bp0D->getName().c_str(), self->bp0D ); + return PyUnicode_FromFormat("type: %s - address: %p", Py_TYPE(self)->tp_name, self->bp0D); } -static char BinaryPredicate0D_getName___doc__[] = -".. method:: getName()\n" -"\n" -" Returns the name of the binary 0D predicate.\n" -"\n" -" :return: The name of the binary 0D predicate.\n" -" :rtype: str\n"; - -static PyObject * BinaryPredicate0D_getName( BPy_BinaryPredicate0D *self, PyObject *args) -{ - return PyUnicode_FromString( self->bp0D->getName().c_str() ); -} - -static PyObject * BinaryPredicate0D___call__( BPy_BinaryPredicate0D *self, PyObject *args, PyObject *kwds) +static PyObject * BinaryPredicate0D___call__(BPy_BinaryPredicate0D *self, PyObject *args, PyObject *kwds) { + static const char *kwlist[] = {"inter1", "inter2", NULL}; BPy_Interface0D *obj1, *obj2; - if( kwds != NULL ) { - PyErr_SetString(PyExc_TypeError, "keyword argument(s) not supported"); + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!O!", (char **)kwlist, + &Interface0D_Type, &obj1, &Interface0D_Type, &obj2)) + { return NULL; } - if( !PyArg_ParseTuple(args, "O!O!", &Interface0D_Type, &obj1, &Interface0D_Type, &obj2) ) - return NULL; - - if( typeid(*(self->bp0D)) == typeid(BinaryPredicate0D) ) { + if (typeid(*(self->bp0D)) == typeid(BinaryPredicate0D)) { PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden"); return NULL; } - if (self->bp0D->operator()( *(obj1->if0D) , *(obj2->if0D) ) < 0) { + if (self->bp0D->operator()(*(obj1->if0D) , *(obj2->if0D)) < 0) { if (!PyErr_Occurred()) { - string msg(self->bp0D->getName() + " __call__ method failed"); - PyErr_SetString(PyExc_RuntimeError, msg.c_str()); + string class_name(Py_TYPE(self)->tp_name); + PyErr_SetString(PyExc_RuntimeError, (class_name + " __call__ method failed").c_str()); } return NULL; } - return PyBool_from_bool( self->bp0D->result ); + return PyBool_from_bool(self->bp0D->result); +} + +/*----------------------BinaryPredicate0D get/setters ----------------------------*/ +PyDoc_STRVAR(BinaryPredicate0D_name_doc, +"The name of the binary 0D predicate.\n" +"\n" +":type: str"); + +static PyObject *BinaryPredicate0D_name_get(BPy_BinaryPredicate0D *self, void *UNUSED(closure)) +{ + return PyUnicode_FromString(Py_TYPE(self)->tp_name); } -/*----------------------BinaryPredicate0D instance definitions ----------------------------*/ -static PyMethodDef BPy_BinaryPredicate0D_methods[] = { - {"getName", ( PyCFunction ) BinaryPredicate0D_getName, METH_NOARGS, BinaryPredicate0D_getName___doc__}, - {NULL, NULL, 0, NULL} +static PyGetSetDef BPy_BinaryPredicate0D_getseters[] = { + {(char *)"name", (getter)BinaryPredicate0D_name_get, (setter)NULL, (char *)BinaryPredicate0D_name_doc, NULL}, + {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ }; /*-----------------------BPy_BinaryPredicate0D type definition ------------------------------*/ @@ -146,9 +142,9 @@ PyTypeObject BinaryPredicate0D_Type = { 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ - BPy_BinaryPredicate0D_methods, /* tp_methods */ + 0, /* tp_methods */ 0, /* tp_members */ - 0, /* tp_getset */ + BPy_BinaryPredicate0D_getseters, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ diff --git a/source/blender/freestyle/intern/python/BPy_BinaryPredicate1D.cpp b/source/blender/freestyle/intern/python/BPy_BinaryPredicate1D.cpp index e690a6d51c1..c2e8a3fbfd5 100644 --- a/source/blender/freestyle/intern/python/BPy_BinaryPredicate1D.cpp +++ b/source/blender/freestyle/intern/python/BPy_BinaryPredicate1D.cpp @@ -16,39 +16,39 @@ extern "C" { /////////////////////////////////////////////////////////////////////////////////////////// //-------------------MODULE INITIALIZATION-------------------------------- -int BinaryPredicate1D_Init( PyObject *module ) +int BinaryPredicate1D_Init(PyObject *module) { - if( module == NULL ) + if (module == NULL) return -1; - if( PyType_Ready( &BinaryPredicate1D_Type ) < 0 ) + if (PyType_Ready(&BinaryPredicate1D_Type) < 0) return -1; - Py_INCREF( &BinaryPredicate1D_Type ); + Py_INCREF(&BinaryPredicate1D_Type); PyModule_AddObject(module, "BinaryPredicate1D", (PyObject *)&BinaryPredicate1D_Type); - if( PyType_Ready( &FalseBP1D_Type ) < 0 ) + if (PyType_Ready(&FalseBP1D_Type) < 0) return -1; - Py_INCREF( &FalseBP1D_Type ); + Py_INCREF(&FalseBP1D_Type); PyModule_AddObject(module, "FalseBP1D", (PyObject *)&FalseBP1D_Type); - if( PyType_Ready( &Length2DBP1D_Type ) < 0 ) + if (PyType_Ready(&Length2DBP1D_Type) < 0) return -1; - Py_INCREF( &Length2DBP1D_Type ); + Py_INCREF(&Length2DBP1D_Type); PyModule_AddObject(module, "Length2DBP1D", (PyObject *)&Length2DBP1D_Type); - if( PyType_Ready( &SameShapeIdBP1D_Type ) < 0 ) + if (PyType_Ready(&SameShapeIdBP1D_Type) < 0) return -1; - Py_INCREF( &SameShapeIdBP1D_Type ); + Py_INCREF(&SameShapeIdBP1D_Type); PyModule_AddObject(module, "SameShapeIdBP1D", (PyObject *)&SameShapeIdBP1D_Type); - if( PyType_Ready( &TrueBP1D_Type ) < 0 ) + if (PyType_Ready(&TrueBP1D_Type) < 0) return -1; - Py_INCREF( &TrueBP1D_Type ); + Py_INCREF(&TrueBP1D_Type); PyModule_AddObject(module, "TrueBP1D", (PyObject *)&TrueBP1D_Type); - if( PyType_Ready( &ViewMapGradientNormBP1D_Type ) < 0 ) + if (PyType_Ready(&ViewMapGradientNormBP1D_Type) < 0) return -1; - Py_INCREF( &ViewMapGradientNormBP1D_Type ); + Py_INCREF(&ViewMapGradientNormBP1D_Type); PyModule_AddObject(module, "ViewMapGradientNormBP1D", (PyObject *)&ViewMapGradientNormBP1D_Type); return 0; @@ -81,10 +81,12 @@ static char BinaryPredicate1D___doc__[] = static int BinaryPredicate1D___init__(BPy_BinaryPredicate1D *self, PyObject *args, PyObject *kwds) { - if ( !PyArg_ParseTuple(args, "") ) - return -1; + static const char *kwlist[] = {NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) + return -1; self->bp1D = new BinaryPredicate1D(); - self->bp1D->py_bp1D = (PyObject *) self; + self->bp1D->py_bp1D = (PyObject *)self; return 0; } @@ -92,56 +94,53 @@ static void BinaryPredicate1D___dealloc__(BPy_BinaryPredicate1D* self) { if (self->bp1D) delete self->bp1D; - Py_TYPE(self)->tp_free((PyObject*)self); + Py_TYPE(self)->tp_free((PyObject*)self); } static PyObject * BinaryPredicate1D___repr__(BPy_BinaryPredicate1D* self) { - return PyUnicode_FromFormat("type: %s - address: %p", self->bp1D->getName().c_str(), self->bp1D ); + return PyUnicode_FromFormat("type: %s - address: %p", Py_TYPE(self)->tp_name, self->bp1D); } -static char BinaryPredicate1D_getName___doc__[] = -".. method:: getName()\n" -"\n" -" Returns the name of the binary 1D predicate.\n" -"\n" -" :return: The name of the binary 1D predicate.\n" -" :rtype: str\n"; - -static PyObject *BinaryPredicate1D_getName( BPy_BinaryPredicate1D *self, PyObject *args) -{ - return PyUnicode_FromString( self->bp1D->getName().c_str() ); -} - -static PyObject *BinaryPredicate1D___call__( BPy_BinaryPredicate1D *self, PyObject *args, PyObject *kwds) +static PyObject *BinaryPredicate1D___call__(BPy_BinaryPredicate1D *self, PyObject *args, PyObject *kwds) { + static const char *kwlist[] = {"inter1", "inter2", NULL}; BPy_Interface1D *obj1, *obj2; - - if( kwds != NULL ) { - PyErr_SetString(PyExc_TypeError, "keyword argument(s) not supported"); + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!O!", (char **)kwlist, + &Interface1D_Type, &obj1, &Interface1D_Type, &obj2)) + { return NULL; } - if( !PyArg_ParseTuple(args, "O!O!", &Interface1D_Type, &obj1, &Interface1D_Type, &obj2) ) - return NULL; - - if( typeid(*(self->bp1D)) == typeid(BinaryPredicate1D) ) { + if (typeid(*(self->bp1D)) == typeid(BinaryPredicate1D)) { PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden"); return NULL; } - if (self->bp1D->operator()( *(obj1->if1D) , *(obj2->if1D) ) < 0) { + if (self->bp1D->operator()(*(obj1->if1D) , *(obj2->if1D)) < 0) { if (!PyErr_Occurred()) { - string msg(self->bp1D->getName() + " __call__ method failed"); - PyErr_SetString(PyExc_RuntimeError, msg.c_str()); + string class_name(Py_TYPE(self)->tp_name); + PyErr_SetString(PyExc_RuntimeError, (class_name + " __call__ method failed").c_str()); } return NULL; } - return PyBool_from_bool( self->bp1D->result ); + return PyBool_from_bool(self->bp1D->result); +} + +/*----------------------BinaryPredicate0D get/setters ----------------------------*/ + +PyDoc_STRVAR(BinaryPredicate1D_name_doc, +"The name of the binary 1D predicate.\n" +"\n" +":type: str"); + +static PyObject *BinaryPredicate1D_name_get(BPy_BinaryPredicate1D *self, void *UNUSED(closure)) +{ + return PyUnicode_FromString(Py_TYPE(self)->tp_name); } -/*----------------------BinaryPredicate1D instance definitions ----------------------------*/ -static PyMethodDef BPy_BinaryPredicate1D_methods[] = { - {"getName", ( PyCFunction ) BinaryPredicate1D_getName, METH_NOARGS, BinaryPredicate1D_getName___doc__}, - {NULL, NULL, 0, NULL} +static PyGetSetDef BPy_BinaryPredicate1D_getseters[] = { + {(char *)"name", (getter)BinaryPredicate1D_name_get, (setter)NULL, (char *)BinaryPredicate1D_name_doc, NULL}, + {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ }; /*-----------------------BPy_BinaryPredicate1D type definition ------------------------------*/ @@ -173,9 +172,9 @@ PyTypeObject BinaryPredicate1D_Type = { 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ - BPy_BinaryPredicate1D_methods, /* tp_methods */ + 0, /* tp_methods */ 0, /* tp_members */ - 0, /* tp_getset */ + BPy_BinaryPredicate1D_getseters, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ diff --git a/source/blender/freestyle/intern/python/BPy_StrokeShader.cpp b/source/blender/freestyle/intern/python/BPy_StrokeShader.cpp index 202e33c3231..f4a2501547b 100644 --- a/source/blender/freestyle/intern/python/BPy_StrokeShader.cpp +++ b/source/blender/freestyle/intern/python/BPy_StrokeShader.cpp @@ -33,124 +33,124 @@ extern "C" { /////////////////////////////////////////////////////////////////////////////////////////// //-------------------MODULE INITIALIZATION-------------------------------- -int StrokeShader_Init( PyObject *module ) +int StrokeShader_Init(PyObject *module) { - if( module == NULL ) + if (module == NULL) return -1; - if( PyType_Ready( &StrokeShader_Type ) < 0 ) + if (PyType_Ready(&StrokeShader_Type) < 0) return -1; - Py_INCREF( &StrokeShader_Type ); + Py_INCREF(&StrokeShader_Type); PyModule_AddObject(module, "StrokeShader", (PyObject *)&StrokeShader_Type); - if( PyType_Ready( &BackboneStretcherShader_Type ) < 0 ) + if (PyType_Ready(&BackboneStretcherShader_Type) < 0) return -1; - Py_INCREF( &BackboneStretcherShader_Type ); + Py_INCREF(&BackboneStretcherShader_Type); PyModule_AddObject(module, "BackboneStretcherShader", (PyObject *)&BackboneStretcherShader_Type); - if( PyType_Ready( &BezierCurveShader_Type ) < 0 ) + if (PyType_Ready(&BezierCurveShader_Type) < 0) return -1; - Py_INCREF( &BezierCurveShader_Type ); + Py_INCREF(&BezierCurveShader_Type); PyModule_AddObject(module, "BezierCurveShader", (PyObject *)&BezierCurveShader_Type); - if( PyType_Ready( &CalligraphicShader_Type ) < 0 ) + if (PyType_Ready(&CalligraphicShader_Type) < 0) return -1; - Py_INCREF( &CalligraphicShader_Type ); + Py_INCREF(&CalligraphicShader_Type); PyModule_AddObject(module, "CalligraphicShader", (PyObject *)&CalligraphicShader_Type); - if( PyType_Ready( &ColorNoiseShader_Type ) < 0 ) + if (PyType_Ready(&ColorNoiseShader_Type) < 0) return -1; - Py_INCREF( &ColorNoiseShader_Type ); + Py_INCREF(&ColorNoiseShader_Type); PyModule_AddObject(module, "ColorNoiseShader", (PyObject *)&ColorNoiseShader_Type); - if( PyType_Ready( &ColorVariationPatternShader_Type ) < 0 ) + if (PyType_Ready(&ColorVariationPatternShader_Type) < 0) return -1; - Py_INCREF( &ColorVariationPatternShader_Type ); + Py_INCREF(&ColorVariationPatternShader_Type); PyModule_AddObject(module, "ColorVariationPatternShader", (PyObject *)&ColorVariationPatternShader_Type); - if( PyType_Ready( &ConstantColorShader_Type ) < 0 ) + if (PyType_Ready(&ConstantColorShader_Type) < 0) return -1; - Py_INCREF( &ConstantColorShader_Type ); + Py_INCREF(&ConstantColorShader_Type); PyModule_AddObject(module, "ConstantColorShader", (PyObject *)&ConstantColorShader_Type); - if( PyType_Ready( &ConstantThicknessShader_Type ) < 0 ) + if (PyType_Ready(&ConstantThicknessShader_Type) < 0) return -1; - Py_INCREF( &ConstantThicknessShader_Type ); + Py_INCREF(&ConstantThicknessShader_Type); PyModule_AddObject(module, "ConstantThicknessShader", (PyObject *)&ConstantThicknessShader_Type); - if( PyType_Ready( &ConstrainedIncreasingThicknessShader_Type ) < 0 ) + if (PyType_Ready(&ConstrainedIncreasingThicknessShader_Type) < 0) return -1; - Py_INCREF( &ConstrainedIncreasingThicknessShader_Type ); + Py_INCREF(&ConstrainedIncreasingThicknessShader_Type); PyModule_AddObject(module, "ConstrainedIncreasingThicknessShader", (PyObject *)&ConstrainedIncreasingThicknessShader_Type); - if( PyType_Ready( &fstreamShader_Type ) < 0 ) + if (PyType_Ready(&fstreamShader_Type) < 0) return -1; - Py_INCREF( &fstreamShader_Type ); + Py_INCREF(&fstreamShader_Type); PyModule_AddObject(module, "fstreamShader", (PyObject *)&fstreamShader_Type); - if( PyType_Ready( &GuidingLinesShader_Type ) < 0 ) + if (PyType_Ready(&GuidingLinesShader_Type) < 0) return -1; - Py_INCREF( &GuidingLinesShader_Type ); + Py_INCREF(&GuidingLinesShader_Type); PyModule_AddObject(module, "GuidingLinesShader", (PyObject *)&GuidingLinesShader_Type); - if( PyType_Ready( &IncreasingColorShader_Type ) < 0 ) + if (PyType_Ready(&IncreasingColorShader_Type) < 0) return -1; - Py_INCREF( &IncreasingColorShader_Type ); + Py_INCREF(&IncreasingColorShader_Type); PyModule_AddObject(module, "IncreasingColorShader", (PyObject *)&IncreasingColorShader_Type); - if( PyType_Ready( &IncreasingThicknessShader_Type ) < 0 ) + if (PyType_Ready(&IncreasingThicknessShader_Type) < 0) return -1; - Py_INCREF( &IncreasingThicknessShader_Type ); + Py_INCREF(&IncreasingThicknessShader_Type); PyModule_AddObject(module, "IncreasingThicknessShader", (PyObject *)&IncreasingThicknessShader_Type); - if( PyType_Ready( &PolygonalizationShader_Type ) < 0 ) + if (PyType_Ready(&PolygonalizationShader_Type) < 0) return -1; - Py_INCREF( &PolygonalizationShader_Type ); + Py_INCREF(&PolygonalizationShader_Type); PyModule_AddObject(module, "PolygonalizationShader", (PyObject *)&PolygonalizationShader_Type); - if( PyType_Ready( &SamplingShader_Type ) < 0 ) + if (PyType_Ready(&SamplingShader_Type) < 0) return -1; - Py_INCREF( &SamplingShader_Type ); + Py_INCREF(&SamplingShader_Type); PyModule_AddObject(module, "SamplingShader", (PyObject *)&SamplingShader_Type); - if( PyType_Ready( &SmoothingShader_Type ) < 0 ) + if (PyType_Ready(&SmoothingShader_Type) < 0) return -1; - Py_INCREF( &SmoothingShader_Type ); + Py_INCREF(&SmoothingShader_Type); PyModule_AddObject(module, "SmoothingShader", (PyObject *)&SmoothingShader_Type); - if( PyType_Ready( &SpatialNoiseShader_Type ) < 0 ) + if (PyType_Ready(&SpatialNoiseShader_Type) < 0) return -1; - Py_INCREF( &SpatialNoiseShader_Type ); + Py_INCREF(&SpatialNoiseShader_Type); PyModule_AddObject(module, "SpatialNoiseShader", (PyObject *)&SpatialNoiseShader_Type); - if( PyType_Ready( &streamShader_Type ) < 0 ) + if (PyType_Ready(&streamShader_Type) < 0) return -1; - Py_INCREF( &streamShader_Type ); + Py_INCREF(&streamShader_Type); PyModule_AddObject(module, "streamShader", (PyObject *)&streamShader_Type); - if( PyType_Ready( &StrokeTextureShader_Type ) < 0 ) + if (PyType_Ready(&StrokeTextureShader_Type) < 0) return -1; - Py_INCREF( &StrokeTextureShader_Type ); + Py_INCREF(&StrokeTextureShader_Type); PyModule_AddObject(module, "StrokeTextureShader", (PyObject *)&StrokeTextureShader_Type); - if( PyType_Ready( &TextureAssignerShader_Type ) < 0 ) + if (PyType_Ready(&TextureAssignerShader_Type) < 0) return -1; - Py_INCREF( &TextureAssignerShader_Type ); + Py_INCREF(&TextureAssignerShader_Type); PyModule_AddObject(module, "TextureAssignerShader", (PyObject *)&TextureAssignerShader_Type); - if( PyType_Ready( &ThicknessNoiseShader_Type ) < 0 ) + if (PyType_Ready(&ThicknessNoiseShader_Type) < 0) return -1; - Py_INCREF( &ThicknessNoiseShader_Type ); + Py_INCREF(&ThicknessNoiseShader_Type); PyModule_AddObject(module, "ThicknessNoiseShader", (PyObject *)&ThicknessNoiseShader_Type); - if( PyType_Ready( &ThicknessVariationPatternShader_Type ) < 0 ) + if (PyType_Ready(&ThicknessVariationPatternShader_Type) < 0) return -1; - Py_INCREF( &ThicknessVariationPatternShader_Type ); + Py_INCREF(&ThicknessVariationPatternShader_Type); PyModule_AddObject(module, "ThicknessVariationPatternShader", (PyObject *)&ThicknessVariationPatternShader_Type); - if( PyType_Ready( &TipRemoverShader_Type ) < 0 ) + if (PyType_Ready(&TipRemoverShader_Type) < 0) return -1; - Py_INCREF( &TipRemoverShader_Type ); + Py_INCREF(&TipRemoverShader_Type); PyModule_AddObject(module, "TipRemoverShader", (PyObject *)&TipRemoverShader_Type); return 0; @@ -168,8 +168,8 @@ static char StrokeShader___doc__[] = "code example of such an iteration::\n" "\n" " it = ioStroke.strokeVerticesBegin()\n" -" while it.isEnd() == 0:\n" -" att = it.getObject().attribute()\n" +" while not it.is_end:\n" +" att = it.object.attribute\n" " ## perform here any attribute modification\n" " it.increment()\n" "\n" @@ -179,10 +179,12 @@ static char StrokeShader___doc__[] = static int StrokeShader___init__(BPy_StrokeShader *self, PyObject *args, PyObject *kwds) { - if ( !PyArg_ParseTuple(args, "") ) - return -1; + static const char *kwlist[] = {NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) + return -1; self->ss = new StrokeShader(); - self->ss->py_ss = (PyObject *) self; + self->ss->py_ss = (PyObject *)self; return 0; } @@ -190,63 +192,66 @@ static void StrokeShader___dealloc__(BPy_StrokeShader* self) { if (self->ss) delete self->ss; - Py_TYPE(self)->tp_free((PyObject*)self); + Py_TYPE(self)->tp_free((PyObject*)self); } - static PyObject * StrokeShader___repr__(BPy_StrokeShader* self) { - return PyUnicode_FromFormat("type: %s - address: %p", self->ss->getName().c_str(), self->ss ); -} - -static char StrokeShader_getName___doc__[] = -".. method:: getName()\n" -"\n" -" Returns the name of this stroke shader.\n" -"\n" -" :return: The name of this stroke shader.\n" -" :rtype: str\n"; - -static PyObject * StrokeShader_getName( BPy_StrokeShader *self, PyObject *args) -{ - return PyUnicode_FromString( self->ss->getName().c_str() ); + return PyUnicode_FromFormat("type: %s - address: %p", self->ss->getName().c_str(), self->ss); } static char StrokeShader_shade___doc__[] = -".. method:: shade(s)\n" +".. method:: shade(stroke)\n" "\n" " The shading method. Must be overloaded by inherited classes.\n" "\n" -" :arg s: A Stroke object.\n" -" :type s: :class:`Stroke`\n"; +" :arg stroke: A Stroke object.\n" +" :type stroke: :class:`Stroke`\n"; -static PyObject *StrokeShader_shade( BPy_StrokeShader *self , PyObject *args) { +static PyObject *StrokeShader_shade(BPy_StrokeShader *self, PyObject *args, PyObject *kwds) +{ + static const char *kwlist[] = {"stroke", NULL}; PyObject *py_s = 0; - if(!( PyArg_ParseTuple(args, "O!", &Stroke_Type, &py_s) )) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &Stroke_Type, &py_s)) return NULL; - if( typeid(*(self->ss)) == typeid(StrokeShader) ) { + if (typeid(*(self->ss)) == typeid(StrokeShader)) { PyErr_SetString(PyExc_TypeError, "shade method not properly overridden"); return NULL; } - if (self->ss->shade(*( ((BPy_Stroke *) py_s)->s )) < 0) { + if (self->ss->shade(*(((BPy_Stroke *)py_s)->s)) < 0) { if (!PyErr_Occurred()) { - string msg(self->ss->getName() + " shade method failed"); - PyErr_SetString(PyExc_RuntimeError, msg.c_str()); + string class_name(Py_TYPE(self)->tp_name); + PyErr_SetString(PyExc_RuntimeError, (class_name + " shade method failed").c_str()); } return NULL; } Py_RETURN_NONE; } -/*----------------------StrokeShader instance definitions ----------------------------*/ static PyMethodDef BPy_StrokeShader_methods[] = { - {"getName", ( PyCFunction ) StrokeShader_getName, METH_NOARGS, StrokeShader_getName___doc__}, - {"shade", ( PyCFunction ) StrokeShader_shade, METH_VARARGS, StrokeShader_shade___doc__}, + {"shade", (PyCFunction)StrokeShader_shade, METH_VARARGS | METH_KEYWORDS, StrokeShader_shade___doc__}, {NULL, NULL, 0, NULL} }; +/*----------------------StrokeShader get/setters ----------------------------*/ + +PyDoc_STRVAR(StrokeShader_name_doc, +"The name of the stroke shader.\n" +"\n" +":type: str"); + +static PyObject *StrokeShader_name_get(BPy_StrokeShader *self, void *UNUSED(closure)) +{ + return PyUnicode_FromString(Py_TYPE(self)->tp_name); +} + +static PyGetSetDef BPy_StrokeShader_getseters[] = { + {(char *)"name", (getter)StrokeShader_name_get, (setter)NULL, (char *)StrokeShader_name_doc, NULL}, + {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ +}; + /*-----------------------BPy_StrokeShader type definition ------------------------------*/ PyTypeObject StrokeShader_Type = { @@ -279,7 +284,7 @@ PyTypeObject StrokeShader_Type = { 0, /* tp_iternext */ BPy_StrokeShader_methods, /* tp_methods */ 0, /* tp_members */ - 0, /* tp_getset */ + BPy_StrokeShader_getseters, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ diff --git a/source/blender/freestyle/intern/python/BPy_UnaryPredicate0D.cpp b/source/blender/freestyle/intern/python/BPy_UnaryPredicate0D.cpp index 81f39ef7ab7..add32897740 100644 --- a/source/blender/freestyle/intern/python/BPy_UnaryPredicate0D.cpp +++ b/source/blender/freestyle/intern/python/BPy_UnaryPredicate0D.cpp @@ -12,24 +12,24 @@ extern "C" { /////////////////////////////////////////////////////////////////////////////////////////// //-------------------MODULE INITIALIZATION-------------------------------- -int UnaryPredicate0D_Init( PyObject *module ) +int UnaryPredicate0D_Init(PyObject *module) { - if( module == NULL ) + if (module == NULL) return -1; - if( PyType_Ready( &UnaryPredicate0D_Type ) < 0 ) + if (PyType_Ready(&UnaryPredicate0D_Type) < 0) return -1; - Py_INCREF( &UnaryPredicate0D_Type ); + Py_INCREF(&UnaryPredicate0D_Type); PyModule_AddObject(module, "UnaryPredicate0D", (PyObject *)&UnaryPredicate0D_Type); - if( PyType_Ready( &FalseUP0D_Type ) < 0 ) + if (PyType_Ready(&FalseUP0D_Type) < 0) return -1; - Py_INCREF( &FalseUP0D_Type ); + Py_INCREF(&FalseUP0D_Type); PyModule_AddObject(module, "FalseUP0D", (PyObject *)&FalseUP0D_Type); - if( PyType_Ready( &TrueUP0D_Type ) < 0 ) + if (PyType_Ready(&TrueUP0D_Type) < 0) return -1; - Py_INCREF( &TrueUP0D_Type ); + Py_INCREF(&TrueUP0D_Type); PyModule_AddObject(module, "TrueUP0D", (PyObject *)&TrueUP0D_Type); return 0; @@ -61,10 +61,12 @@ static char UnaryPredicate0D___doc__[] = static int UnaryPredicate0D___init__(BPy_UnaryPredicate0D *self, PyObject *args, PyObject *kwds) { - if ( !PyArg_ParseTuple(args, "") ) - return -1; + static const char *kwlist[] = {NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) + return -1; self->up0D = new UnaryPredicate0D(); - self->up0D->py_up0D = (PyObject *) self; + self->up0D->py_up0D = (PyObject *)self; return 0; } @@ -72,63 +74,58 @@ static void UnaryPredicate0D___dealloc__(BPy_UnaryPredicate0D* self) { if (self->up0D) delete self->up0D; - Py_TYPE(self)->tp_free((PyObject*)self); + Py_TYPE(self)->tp_free((PyObject*)self); } static PyObject * UnaryPredicate0D___repr__(BPy_UnaryPredicate0D* self) { - return PyUnicode_FromFormat("type: %s - address: %p", self->up0D->getName().c_str(), self->up0D ); -} - -static char UnaryPredicate0D_getName___doc__[] = -".. method:: getName()\n" -"\n" -" Returns the name of the UnaryPredicate0D.\n" -"\n" -" :return: The name of the UnaryPredicate0D.\n" -" :rtype: str\n"; - -static PyObject * UnaryPredicate0D_getName( BPy_UnaryPredicate0D *self ) -{ - return PyUnicode_FromString( self->up0D->getName().c_str() ); + return PyUnicode_FromFormat("type: %s - address: %p", Py_TYPE(self)->tp_name, self->up0D); } -static PyObject * UnaryPredicate0D___call__( BPy_UnaryPredicate0D *self, PyObject *args, PyObject *kwds) +static PyObject * UnaryPredicate0D___call__(BPy_UnaryPredicate0D *self, PyObject *args, PyObject *kwds) { + static const char *kwlist[] = {"it", NULL}; PyObject *py_if0D_it; - if( kwds != NULL ) { - PyErr_SetString(PyExc_TypeError, "keyword argument(s) not supported"); - return NULL; - } - if( !PyArg_ParseTuple(args, "O!", &Interface0DIterator_Type, &py_if0D_it) ) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &Interface0DIterator_Type, &py_if0D_it)) return NULL; - Interface0DIterator *if0D_it = ((BPy_Interface0DIterator *) py_if0D_it)->if0D_it; + Interface0DIterator *if0D_it = ((BPy_Interface0DIterator *)py_if0D_it)->if0D_it; - if( !if0D_it ) { + if (!if0D_it) { string msg(self->up0D->getName() + " has no Interface0DIterator"); PyErr_SetString(PyExc_RuntimeError, msg.c_str()); return NULL; } - if( typeid(*(self->up0D)) == typeid(UnaryPredicate0D) ) { + if (typeid(*(self->up0D)) == typeid(UnaryPredicate0D)) { PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden"); return NULL; } if (self->up0D->operator()(*if0D_it) < 0) { if (!PyErr_Occurred()) { - string msg(self->up0D->getName() + " __call__ method failed"); - PyErr_SetString(PyExc_RuntimeError, msg.c_str()); + string class_name(Py_TYPE(self)->tp_name); + PyErr_SetString(PyExc_RuntimeError, (class_name + " __call__ method failed").c_str()); } return NULL; } - return PyBool_from_bool( self->up0D->result ); + return PyBool_from_bool(self->up0D->result); } -/*----------------------UnaryPredicate0D instance definitions ----------------------------*/ -static PyMethodDef BPy_UnaryPredicate0D_methods[] = { - {"getName", ( PyCFunction ) UnaryPredicate0D_getName, METH_NOARGS, UnaryPredicate0D_getName___doc__}, - {NULL, NULL, 0, NULL} +/*----------------------UnaryPredicate0D get/setters ----------------------------*/ + +PyDoc_STRVAR(UnaryPredicate0D_name_doc, +"The name of the unary 0D predicate.\n" +"\n" +":type: str"); + +static PyObject *UnaryPredicate0D_name_get(BPy_UnaryPredicate0D *self, void *UNUSED(closure)) +{ + return PyUnicode_FromString(Py_TYPE(self)->tp_name); +} + +static PyGetSetDef BPy_UnaryPredicate0D_getseters[] = { + {(char *)"name", (getter)UnaryPredicate0D_name_get, (setter)NULL, (char *)UnaryPredicate0D_name_doc, NULL}, + {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ }; /*-----------------------BPy_UnaryPredicate0D type definition ------------------------------*/ @@ -161,9 +158,9 @@ PyTypeObject UnaryPredicate0D_Type = { 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ - BPy_UnaryPredicate0D_methods, /* tp_methods */ + 0, /* tp_methods */ 0, /* tp_members */ - 0, /* tp_getset */ + BPy_UnaryPredicate0D_getseters, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ @@ -179,6 +176,3 @@ PyTypeObject UnaryPredicate0D_Type = { #ifdef __cplusplus } #endif - - - diff --git a/source/blender/freestyle/intern/python/BPy_UnaryPredicate1D.cpp b/source/blender/freestyle/intern/python/BPy_UnaryPredicate1D.cpp index a0c59484486..75577246c44 100644 --- a/source/blender/freestyle/intern/python/BPy_UnaryPredicate1D.cpp +++ b/source/blender/freestyle/intern/python/BPy_UnaryPredicate1D.cpp @@ -21,64 +21,64 @@ extern "C" { /////////////////////////////////////////////////////////////////////////////////////////// //-------------------MODULE INITIALIZATION-------------------------------- -int UnaryPredicate1D_Init( PyObject *module ) +int UnaryPredicate1D_Init(PyObject *module) { - if( module == NULL ) + if (module == NULL) return -1; - if( PyType_Ready( &UnaryPredicate1D_Type ) < 0 ) + if (PyType_Ready(&UnaryPredicate1D_Type) < 0) return -1; - Py_INCREF( &UnaryPredicate1D_Type ); + Py_INCREF(&UnaryPredicate1D_Type); PyModule_AddObject(module, "UnaryPredicate1D", (PyObject *)&UnaryPredicate1D_Type); - if( PyType_Ready( &ContourUP1D_Type ) < 0 ) + if (PyType_Ready(&ContourUP1D_Type) < 0) return -1; - Py_INCREF( &ContourUP1D_Type ); + Py_INCREF(&ContourUP1D_Type); PyModule_AddObject(module, "ContourUP1D", (PyObject *)&ContourUP1D_Type); - if( PyType_Ready( &DensityLowerThanUP1D_Type ) < 0 ) + if (PyType_Ready(&DensityLowerThanUP1D_Type) < 0) return -1; - Py_INCREF( &DensityLowerThanUP1D_Type ); + Py_INCREF(&DensityLowerThanUP1D_Type); PyModule_AddObject(module, "DensityLowerThanUP1D", (PyObject *)&DensityLowerThanUP1D_Type); - if( PyType_Ready( &EqualToChainingTimeStampUP1D_Type ) < 0 ) + if (PyType_Ready(&EqualToChainingTimeStampUP1D_Type) < 0) return -1; - Py_INCREF( &EqualToChainingTimeStampUP1D_Type ); + Py_INCREF(&EqualToChainingTimeStampUP1D_Type); PyModule_AddObject(module, "EqualToChainingTimeStampUP1D", (PyObject *)&EqualToChainingTimeStampUP1D_Type); - if( PyType_Ready( &EqualToTimeStampUP1D_Type ) < 0 ) + if (PyType_Ready(&EqualToTimeStampUP1D_Type) < 0) return -1; - Py_INCREF( &EqualToTimeStampUP1D_Type ); + Py_INCREF(&EqualToTimeStampUP1D_Type); PyModule_AddObject(module, "EqualToTimeStampUP1D", (PyObject *)&EqualToTimeStampUP1D_Type); - if( PyType_Ready( &ExternalContourUP1D_Type ) < 0 ) + if (PyType_Ready(&ExternalContourUP1D_Type) < 0) return -1; - Py_INCREF( &ExternalContourUP1D_Type ); + Py_INCREF(&ExternalContourUP1D_Type); PyModule_AddObject(module, "ExternalContourUP1D", (PyObject *)&ExternalContourUP1D_Type); - if( PyType_Ready( &FalseUP1D_Type ) < 0 ) + if (PyType_Ready(&FalseUP1D_Type) < 0) return -1; - Py_INCREF( &FalseUP1D_Type ); + Py_INCREF(&FalseUP1D_Type); PyModule_AddObject(module, "FalseUP1D", (PyObject *)&FalseUP1D_Type); - if( PyType_Ready( &QuantitativeInvisibilityUP1D_Type ) < 0 ) + if (PyType_Ready(&QuantitativeInvisibilityUP1D_Type) < 0) return -1; - Py_INCREF( &QuantitativeInvisibilityUP1D_Type ); + Py_INCREF(&QuantitativeInvisibilityUP1D_Type); PyModule_AddObject(module, "QuantitativeInvisibilityUP1D", (PyObject *)&QuantitativeInvisibilityUP1D_Type); - if( PyType_Ready( &ShapeUP1D_Type ) < 0 ) + if (PyType_Ready(&ShapeUP1D_Type) < 0) return -1; - Py_INCREF( &ShapeUP1D_Type ); + Py_INCREF(&ShapeUP1D_Type); PyModule_AddObject(module, "ShapeUP1D", (PyObject *)&ShapeUP1D_Type); - if( PyType_Ready( &TrueUP1D_Type ) < 0 ) + if (PyType_Ready(&TrueUP1D_Type) < 0) return -1; - Py_INCREF( &TrueUP1D_Type ); + Py_INCREF(&TrueUP1D_Type); PyModule_AddObject(module, "TrueUP1D", (PyObject *)&TrueUP1D_Type); - if( PyType_Ready( &WithinImageBoundaryUP1D_Type ) < 0 ) + if (PyType_Ready(&WithinImageBoundaryUP1D_Type) < 0) return -1; - Py_INCREF( &WithinImageBoundaryUP1D_Type ); + Py_INCREF(&WithinImageBoundaryUP1D_Type); PyModule_AddObject(module, "WithinImageBoundaryUP1D", (PyObject *)&WithinImageBoundaryUP1D_Type); return 0; @@ -109,10 +109,12 @@ static char UnaryPredicate1D___doc__[] = static int UnaryPredicate1D___init__(BPy_UnaryPredicate1D *self, PyObject *args, PyObject *kwds) { - if( !PyArg_ParseTuple(args, "") ) + static const char *kwlist[] = {NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) return -1; self->up1D = new UnaryPredicate1D(); - self->up1D->py_up1D = (PyObject *) self; + self->up1D->py_up1D = (PyObject *)self; return 0; } @@ -120,67 +122,58 @@ static void UnaryPredicate1D___dealloc__(BPy_UnaryPredicate1D* self) { if (self->up1D) delete self->up1D; - Py_TYPE(self)->tp_free((PyObject*)self); + Py_TYPE(self)->tp_free((PyObject*)self); } static PyObject * UnaryPredicate1D___repr__(BPy_UnaryPredicate1D* self) { - return PyUnicode_FromFormat("type: %s - address: %p", self->up1D->getName().c_str(), self->up1D ); -} - -static char UnaryPredicate1D_getName___doc__[] = -".. method:: getName()\n" -"\n" -" Returns the string of the name of the UnaryPredicate1D.\n" -"\n" -" Reimplemented in TrueUP1D, FalseUP1D, QuantitativeInvisibilityUP1D,\n" -" ContourUP1D, ExternalContourUP1D, EqualToTimeStampUP1D,\n" -" EqualToChainingTimeStampUP1D, ShapeUP1D, and DensityLowerThanUP1D.\n" -"\n" -" :return: \n" -" :rtype: str\n"; - -static PyObject * UnaryPredicate1D_getName( BPy_UnaryPredicate1D *self, PyObject *args) -{ - return PyUnicode_FromString( self->up1D->getName().c_str() ); + return PyUnicode_FromFormat("type: %s - address: %p", Py_TYPE(self)->tp_name, self->up1D); } -static PyObject * UnaryPredicate1D___call__( BPy_UnaryPredicate1D *self, PyObject *args, PyObject *kwds) +static PyObject * UnaryPredicate1D___call__(BPy_UnaryPredicate1D *self, PyObject *args, PyObject *kwds) { + static const char *kwlist[] = {"inter", NULL}; PyObject *py_if1D; - if( kwds != NULL ) { - PyErr_SetString(PyExc_TypeError, "keyword argument(s) not supported"); - return NULL; - } - if( !PyArg_ParseTuple(args, "O!", &Interface1D_Type, &py_if1D) ) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &Interface1D_Type, &py_if1D)) return NULL; - Interface1D *if1D = ((BPy_Interface1D *) py_if1D)->if1D; + Interface1D *if1D = ((BPy_Interface1D *)py_if1D)->if1D; - if( !if1D ) { + if (!if1D) { string msg(self->up1D->getName() + " has no Interface0DIterator"); PyErr_SetString(PyExc_RuntimeError, msg.c_str()); return NULL; } - if( typeid(*(self->up1D)) == typeid(UnaryPredicate1D) ) { + if (typeid(*(self->up1D)) == typeid(UnaryPredicate1D)) { PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden"); return NULL; } - if( self->up1D->operator()(*if1D) < 0 ) { + if (self->up1D->operator()(*if1D) < 0) { if (!PyErr_Occurred()) { - string msg(self->up1D->getName() + " __call__ method failed"); - PyErr_SetString(PyExc_RuntimeError, msg.c_str()); + string class_name(Py_TYPE(self)->tp_name); + PyErr_SetString(PyExc_RuntimeError, (class_name + " __call__ method failed").c_str()); } return NULL; } - return PyBool_from_bool( self->up1D->result ); + return PyBool_from_bool(self->up1D->result); } -/*----------------------UnaryPredicate1D instance definitions ----------------------------*/ -static PyMethodDef BPy_UnaryPredicate1D_methods[] = { - {"getName", ( PyCFunction ) UnaryPredicate1D_getName, METH_NOARGS, UnaryPredicate1D_getName___doc__}, - {NULL, NULL, 0, NULL} +/*----------------------UnaryPredicate1D get/setters ----------------------------*/ + +PyDoc_STRVAR(UnaryPredicate1D_name_doc, +"The name of the unary 1D predicate.\n" +"\n" +":type: str"); + +static PyObject *UnaryPredicate1D_name_get(BPy_UnaryPredicate1D *self, void *UNUSED(closure)) +{ + return PyUnicode_FromString(Py_TYPE(self)->tp_name); +} + +static PyGetSetDef BPy_UnaryPredicate1D_getseters[] = { + {(char *)"name", (getter)UnaryPredicate1D_name_get, (setter)NULL, (char *)UnaryPredicate1D_name_doc, NULL}, + {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ }; /*-----------------------BPy_UnaryPredicate1D type definition ------------------------------*/ @@ -213,9 +206,9 @@ PyTypeObject UnaryPredicate1D_Type = { 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ - BPy_UnaryPredicate1D_methods, /* tp_methods */ + 0, /* tp_methods */ 0, /* tp_members */ - 0, /* tp_getset */ + BPy_UnaryPredicate1D_getseters, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ @@ -231,6 +224,3 @@ PyTypeObject UnaryPredicate1D_Type = { #ifdef __cplusplus } #endif - - - diff --git a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_FalseBP1D.cpp b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_FalseBP1D.cpp index ad2885fb95a..a784e953270 100644 --- a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_FalseBP1D.cpp +++ b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_FalseBP1D.cpp @@ -22,9 +22,11 @@ static char FalseBP1D___doc__[] = " :return: False.\n" " :rtype: bool\n"; -static int FalseBP1D___init__( BPy_FalseBP1D* self, PyObject *args ) +static int FalseBP1D___init__(BPy_FalseBP1D* self, PyObject *args, PyObject *kwds) { - if(!( PyArg_ParseTuple(args, "") )) + static const char *kwlist[] = {NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) return -1; self->py_bp1D.bp1D = new Predicates1D::FalseBP1D(); return 0; diff --git a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_Length2DBP1D.cpp b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_Length2DBP1D.cpp index 1a59091c453..d30b164298f 100644 --- a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_Length2DBP1D.cpp +++ b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_Length2DBP1D.cpp @@ -23,9 +23,11 @@ static char Length2DBP1D___doc__[] = " :return: True or false.\n" " :rtype: bool\n"; -static int Length2DBP1D___init__( BPy_Length2DBP1D* self, PyObject *args ) +static int Length2DBP1D___init__(BPy_Length2DBP1D* self, PyObject *args, PyObject *kwds) { - if(!( PyArg_ParseTuple(args, "") )) + static const char *kwlist[] = {NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) return -1; self->py_bp1D.bp1D = new Predicates1D::Length2DBP1D(); return 0; diff --git a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_SameShapeIdBP1D.cpp b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_SameShapeIdBP1D.cpp index 2b479a49fc0..115f9e03b1f 100644 --- a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_SameShapeIdBP1D.cpp +++ b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_SameShapeIdBP1D.cpp @@ -22,9 +22,11 @@ static char SameShapeIdBP1D___doc__[] = " :return: True or false.\n" " :rtype: bool\n"; -static int SameShapeIdBP1D___init__( BPy_SameShapeIdBP1D* self, PyObject *args ) +static int SameShapeIdBP1D___init__(BPy_SameShapeIdBP1D* self, PyObject *args, PyObject *kwds) { - if(!( PyArg_ParseTuple(args, "") )) + static const char *kwlist[] = {NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) return -1; self->py_bp1D.bp1D = new Predicates1D::SameShapeIdBP1D(); return 0; diff --git a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_TrueBP1D.cpp b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_TrueBP1D.cpp index 090a8232794..37c39ed6cd9 100644 --- a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_TrueBP1D.cpp +++ b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_TrueBP1D.cpp @@ -22,9 +22,11 @@ static char TrueBP1D___doc__[] = " :return: True.\n" " :rtype: bool\n"; -static int TrueBP1D___init__( BPy_TrueBP1D* self, PyObject *args ) +static int TrueBP1D___init__(BPy_TrueBP1D* self, PyObject *args, PyObject *kwds) { - if(!( PyArg_ParseTuple(args, "") )) + static const char *kwlist[] = {NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) return -1; self->py_bp1D.bp1D = new Predicates1D::TrueBP1D(); return 0; diff --git a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_ViewMapGradientNormBP1D.cpp b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_ViewMapGradientNormBP1D.cpp index f5ba9d58d72..06e01dea826 100644 --- a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_ViewMapGradientNormBP1D.cpp +++ b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_ViewMapGradientNormBP1D.cpp @@ -16,6 +16,22 @@ extern "C" { static char ViewMapGradientNormBP1D___doc__[] = "Class hierarchy: :class:`BinaryPredicate1D` > :class:`ViewMapGradientNormBP1D`\n" "\n" +".. method:: __init__(level, integration_type=IntegrationType.MEAN, sampling=2.0)\n" +"\n" +" Builds a ViewMapGradientNormBP1D object.\n" +"\n" +" :arg level: The level of the pyramid from which the pixel must be\n" +" read.\n" +" :type level: int\n" +" :arg integration_type: The integration method used to compute a single value\n" +" from a set of values.\n" +" :type integration_type: :class:`IntegrationType`\n" +" :arg sampling: The resolution used to sample the chain:\n" +" GetViewMapGradientNormF0D is evaluated at each sample point and\n" +" the result is obtained by combining the resulting values into a\n" +" single one, following the method specified by integration_type.\n" +" :type sampling: float\n" +"\n" ".. method:: __call__(inter1, inter2)\n" "\n" " Returns true if the evaluation of the Gradient norm Function is\n" @@ -28,17 +44,17 @@ static char ViewMapGradientNormBP1D___doc__[] = " :return: True or false.\n" " :rtype: bool\n"; -static int ViewMapGradientNormBP1D___init__( BPy_ViewMapGradientNormBP1D* self, PyObject *args ) +static int ViewMapGradientNormBP1D___init__(BPy_ViewMapGradientNormBP1D* self, PyObject *args, PyObject *kwds) { + static const char *kwlist[] = {"level", "integration_type", "sampling", NULL}; + PyObject *obj = 0; int i; - PyObject *obj; float f = 2.0; - if(!( PyArg_ParseTuple(args, "i|O!f", &i, &IntegrationType_Type, &obj, &f) )) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "i|O!f", (char **)kwlist, &i, &IntegrationType_Type, &obj, &f)) return -1; - - IntegrationType t = ( obj ) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; - self->py_bp1D.bp1D = new Predicates1D::ViewMapGradientNormBP1D(i,t,f); + IntegrationType t = (obj) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; + self->py_bp1D.bp1D = new Predicates1D::ViewMapGradientNormBP1D(i, t, f); return 0; } diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_BackboneStretcherShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_BackboneStretcherShader.cpp index cdab4b38b95..a0da18ddb37 100644 --- a/source/blender/freestyle/intern/python/StrokeShader/BPy_BackboneStretcherShader.cpp +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_BackboneStretcherShader.cpp @@ -15,28 +15,28 @@ static char BackboneStretcherShader___doc__[] = "\n" "[Geometry shader]\n" "\n" -".. method:: __init__(iAmount=2.0)\n" +".. method:: __init__(amount=2.0)\n" "\n" " Builds a BackboneStretcherShader object.\n" "\n" -" :arg iAmount: The stretching amount value.\n" -" :type iAmount: float\n" +" :arg amount: The stretching amount value.\n" +" :type amount: float\n" "\n" -".. method:: shade(s)\n" +".. method:: shade(stroke)\n" "\n" " Stretches the stroke at its two extremities and following the\n" " respective directions: v(1)v(0) and v(n-1)v(n).\n" "\n" -" :arg s: A Stroke object.\n" -" :type s: :class:`Stroke`\n"; +" :arg stroke: A Stroke object.\n" +" :type stroke: :class:`Stroke`\n"; -static int BackboneStretcherShader___init__( BPy_BackboneStretcherShader* self, PyObject *args) +static int BackboneStretcherShader___init__(BPy_BackboneStretcherShader* self, PyObject *args, PyObject *kwds) { + static const char *kwlist[] = {"amount", NULL}; float f = 2.0; - if(!( PyArg_ParseTuple(args, "|f", &f) )) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|f", (char **)kwlist, &f)) return -1; - self->py_ss.ss = new StrokeShaders::BackboneStretcherShader(f); return 0; } diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_BezierCurveShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_BezierCurveShader.cpp index f3d3bfafd08..05c533d631a 100644 --- a/source/blender/freestyle/intern/python/StrokeShader/BPy_BezierCurveShader.cpp +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_BezierCurveShader.cpp @@ -24,21 +24,21 @@ static char BezierCurveShader___doc__[] = " original geometry.\n" " :type error: float\n" "\n" -".. method:: shade(s)\n" +".. method:: shade(stroke)\n" "\n" " Transforms the stroke backbone geometry so that it corresponds to a\n" " Bezier Curve approximation of the original backbone geometry.\n" "\n" -" :arg s: A Stroke object.\n" -" :type s: :class:`Stroke`\n"; +" :arg stroke: A Stroke object.\n" +" :type stroke: :class:`Stroke`\n"; -static int BezierCurveShader___init__( BPy_BezierCurveShader* self, PyObject *args) +static int BezierCurveShader___init__(BPy_BezierCurveShader* self, PyObject *args, PyObject *kwds) { + static const char *kwlist[] = {"error", NULL}; float f = 4.0; - if(!( PyArg_ParseTuple(args, "|f", &f) )) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|f", (char **)kwlist, &f)) return -1; - self->py_ss.ss = new StrokeShaders::BezierCurveShader(f); return 0; } diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_CalligraphicShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_CalligraphicShader.cpp index bb77d0ba5be..c1d9ccc8599 100644 --- a/source/blender/freestyle/intern/python/StrokeShader/BPy_CalligraphicShader.cpp +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_CalligraphicShader.cpp @@ -16,51 +16,53 @@ static char CalligraphicShader___doc__[] = "\n" "[Thickness Shader]\n" "\n" -".. method:: __init__(iMinThickness, iMaxThickness, iOrientation, iClamp)\n" +".. method:: __init__(thickness_min, thickness_max, orientation, clamp)\n" "\n" " Builds a CalligraphicShader object.\n" "\n" -" :arg iMinThickness: The minimum thickness in the direction\n" +" :arg thickness_min: The minimum thickness in the direction\n" " perpendicular to the main direction.\n" -" :type iMinThickness: float\n" -" :arg iMaxThickness: The maximum thickness in the main direction.\n" -" :type iMaxThickness: float\n" -" :arg iOrientation: The 2D vector giving the main direction.\n" -" :type iOrientation: :class:`mathutils.Vector`\n" -" :arg iClamp: If true, the strokes are drawn in black when the stroke\n" +" :type thickness_min: float\n" +" :arg thickness_max: The maximum thickness in the main direction.\n" +" :type thickness_max: float\n" +" :arg orientation: The 2D vector giving the main direction.\n" +" :type orientation: :class:`mathutils.Vector`\n" +" :arg clamp: If true, the strokes are drawn in black when the stroke\n" " direction is between -90 and 90 degrees with respect to the main\n" " direction and drawn in white otherwise. If false, the strokes\n" " are always drawn in black.\n" -" :type iClamp: bool\n" +" :type clamp: bool\n" "\n" -".. method:: shade(s)\n" +".. method:: shade(stroke)\n" "\n" " Assigns thicknesses to the stroke vertices so that the stroke looks\n" " like made with a calligraphic tool, i.e. the stroke will be the\n" " thickest in a main direction, and the thinest in the direction\n" " perpendicular to this one, and an interpolation inbetween.\n" "\n" -" :arg s: A Stroke object.\n" -" :type s: :class:`Stroke`\n"; +" :arg stroke: A Stroke object.\n" +" :type stroke: :class:`Stroke`\n"; -static int CalligraphicShader___init__( BPy_CalligraphicShader* self, PyObject *args) +static int convert_v2(PyObject *obj, void *v) { + return float_array_from_PyObject(obj, (float *)v, 2); +} + +static int CalligraphicShader___init__(BPy_CalligraphicShader* self, PyObject *args, PyObject *kwds) +{ + static const char *kwlist[] = {"thickness_min", "thickness_max", "orientation", "clamp", NULL}; double d1, d2; - PyObject *obj3 = 0, *obj4 = 0; - + float f3[2]; + PyObject *obj4 = 0; - if(!( PyArg_ParseTuple(args, "ddOO", &d1, &d2, &obj3, &obj4) )) - return -1; - Vec2f *v = Vec2f_ptr_from_PyObject(obj3); - if( !v ) { - PyErr_SetString(PyExc_TypeError, "argument 3 must be a 2D vector (either a list of 2 elements or Vector)"); + if (!PyArg_ParseTupleAndKeywords(args, kwds, "ddO&O!", (char **)kwlist, + &d1, &d2, convert_v2, f3, &PyBool_Type, &obj4)) + { return -1; } - self->py_ss.ss = new CalligraphicShader(d1, d2, *v, bool_from_PyBool(obj4) ); - delete v; - + Vec2f v(f3[0], f3[1]); + self->py_ss.ss = new CalligraphicShader(d1, d2, v, bool_from_PyBool(obj4)); return 0; - } /*-----------------------BPy_CalligraphicShader type definition ------------------------------*/ diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_ColorNoiseShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_ColorNoiseShader.cpp index d005e8ccfe8..3e0f864f468 100644 --- a/source/blender/freestyle/intern/python/StrokeShader/BPy_ColorNoiseShader.cpp +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_ColorNoiseShader.cpp @@ -15,29 +15,29 @@ static char ColorNoiseShader___doc__[] = "\n" "[Color shader]\n" "\n" -".. method:: __init__(iAmplitude, iPeriod)\n" +".. method:: __init__(amplitude, period)\n" "\n" " Builds a ColorNoiseShader object.\n" "\n" -" :arg iAmplitude: The amplitude of the noise signal.\n" -" :type iAmplitude: float\n" -" :arg iPeriod: The period of the noise signal.\n" -" :type iPeriod: float\n" +" :arg amplitude: The amplitude of the noise signal.\n" +" :type amplitude: float\n" +" :arg period: The period of the noise signal.\n" +" :type period: float\n" "\n" -".. method:: shade(s)\n" +".. method:: shade(stroke)\n" "\n" " Shader to add noise to the stroke colors.\n" "\n" -" :arg s: A Stroke object.\n" -" :type s: :class:`Stroke`\n"; +" :arg stroke: A Stroke object.\n" +" :type stroke: :class:`Stroke`\n"; -static int ColorNoiseShader___init__( BPy_ColorNoiseShader* self, PyObject *args) +static int ColorNoiseShader___init__(BPy_ColorNoiseShader* self, PyObject *args, PyObject *kwds) { + static const char *kwlist[] = {"amplitude", "period", NULL}; float f1, f2; - if(!( PyArg_ParseTuple(args, "ff", &f1, &f2) )) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "ff", (char **)kwlist, &f1, &f2)) return -1; - self->py_ss.ss = new StrokeShaders::ColorNoiseShader(f1, f2); return 0; } diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_ColorVariationPatternShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_ColorVariationPatternShader.cpp index 2d48df78da1..d0451578f87 100644 --- a/source/blender/freestyle/intern/python/StrokeShader/BPy_ColorVariationPatternShader.cpp +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_ColorVariationPatternShader.cpp @@ -27,24 +27,24 @@ static char ColorVariationPatternShader___doc__[] = " repeted to fit the stroke.\n" " :type stretch: bool\n" "\n" -".. method:: shade(s)\n" +".. method:: shade(stroke)\n" "\n" " Applies a pattern to vary the original color. The new color is the\n" " result of the multiplication of the pattern and the original color.\n" "\n" -" :arg s: A Stroke object.\n" -" :type s: :class:`Stroke`\n"; +" :arg stroke: A Stroke object.\n" +" :type stroke: :class:`Stroke`\n"; -static int ColorVariationPatternShader___init__( BPy_ColorVariationPatternShader* self, PyObject *args) +static int ColorVariationPatternShader___init__(BPy_ColorVariationPatternShader* self, PyObject *args, PyObject *kwds) { + static const char *kwlist[] = {"pattern_name", "stretch", NULL}; const char *s; PyObject *obj = 0; - - if(!( PyArg_ParseTuple(args, "s|O", &s, &obj) )) - return -1; - bool b = (obj) ? bool_from_PyBool(obj) : true; - self->py_ss.ss = new StrokeShaders::ColorVariationPatternShader(s,b); + if (!PyArg_ParseTupleAndKeywords(args, kwds, "s|O!", (char **)kwlist, &s, &PyBool_Type, &obj)) + return -1; + bool b = (!obj) ? true : bool_from_PyBool(obj); + self->py_ss.ss = new StrokeShaders::ColorVariationPatternShader(s, b); return 0; } diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantColorShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantColorShader.cpp index d0f4c365a80..61d46f58f26 100644 --- a/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantColorShader.cpp +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantColorShader.cpp @@ -15,33 +15,33 @@ static char ConstantColorShader___doc__[] = "\n" "[Color shader]\n" "\n" -".. method:: __init__(iR, iG, iB, iAlpha=1.0)\n" +".. method:: __init__(red, green, blue, alpha=1.0)\n" "\n" " Builds a ConstantColorShader object.\n" "\n" -" :arg iR: The red component.\n" -" :type iR: float\n" -" :arg iG: The green component.\n" -" :type iG: float\n" -" :arg iB: The blue component.\n" -" :type iB: float\n" -" :arg iAlpha: The alpha value.\n" -" :type iAlpha: float\n" +" :arg red: The red component.\n" +" :type red: float\n" +" :arg green: The green component.\n" +" :type green: float\n" +" :arg blue: The blue component.\n" +" :type blue: float\n" +" :arg alpha: The alpha value.\n" +" :type alpha: float\n" "\n" -".. method:: shade(s)\n" +".. method:: shade(stroke)\n" "\n" " Assigns a constant color to every vertex of the Stroke.\n" "\n" -" :arg s: A Stroke object.\n" -" :type s: :class:`Stroke`\n"; +" :arg stroke: A Stroke object.\n" +" :type stroke: :class:`Stroke`\n"; -static int ConstantColorShader___init__( BPy_ConstantColorShader* self, PyObject *args) +static int ConstantColorShader___init__(BPy_ConstantColorShader* self, PyObject *args, PyObject *kwds) { + static const char *kwlist[] = {"red", "green", "blue", "alpha", NULL}; float f1, f2, f3, f4 = 1.0; - if(!( PyArg_ParseTuple(args, "fff|f", &f1, &f2, &f3, &f4) )) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "fff|f", (char **)kwlist, &f1, &f2, &f3, &f4)) return -1; - self->py_ss.ss = new StrokeShaders::ConstantColorShader(f1, f2, f3, f4); return 0; } diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantThicknessShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantThicknessShader.cpp index 60d3e696675..656cec8f651 100644 --- a/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantThicknessShader.cpp +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantThicknessShader.cpp @@ -22,20 +22,20 @@ static char ConstantThicknessShader___doc__[] = " :arg thickness: The thickness that must be assigned to the stroke.\n" " :type thickness: float\n" "\n" -".. method:: shade(s)\n" +".. method:: shade(stroke)\n" "\n" " Assigns an absolute constant thickness to every vertex of the Stroke.\n" "\n" -" :arg s: A Stroke object.\n" -" :type s: :class:`Stroke`\n"; +" :arg stroke: A Stroke object.\n" +" :type stroke: :class:`Stroke`\n"; -static int ConstantThicknessShader___init__( BPy_ConstantThicknessShader* self, PyObject *args) +static int ConstantThicknessShader___init__(BPy_ConstantThicknessShader* self, PyObject *args, PyObject *kwds) { + static const char *kwlist[] = {"thickness", NULL}; float f; - if(!( PyArg_ParseTuple(args, "f", &f) )) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "f", (char **)kwlist, &f)) return -1; - self->py_ss.ss = new StrokeShaders::ConstantThicknessShader(f); return 0; } diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstrainedIncreasingThicknessShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstrainedIncreasingThicknessShader.cpp index 3892ccca37b..3abf2716695 100644 --- a/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstrainedIncreasingThicknessShader.cpp +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstrainedIncreasingThicknessShader.cpp @@ -15,33 +15,33 @@ static char ConstrainedIncreasingThicknessShader___doc__[] = "\n" "[Thickness shader]\n" "\n" -".. method:: __init__(iThicknessMin, iThicknessMax, iRatio)\n" +".. method:: __init__(thickness_min, thickness_max, ratio)\n" "\n" " Builds a ConstrainedIncreasingThicknessShader object.\n" "\n" -" :arg iThicknessMin: The minimum thickness.\n" -" :type iThicknessMin: float\n" -" :arg iThicknessMax: The maximum thickness.\n" -" :type iThicknessMax: float\n" -" :arg iRatio: The thickness/length ratio that we don't want to exceed. \n" -" :type iRatio: float\n" +" :arg thickness_min: The minimum thickness.\n" +" :type thickness_min: float\n" +" :arg thickness_max: The maximum thickness.\n" +" :type thickness_max: float\n" +" :arg ratio: The thickness/length ratio that we don't want to exceed. \n" +" :type ratio: float\n" "\n" -".. method:: shade(s)\n" +".. method:: shade(stroke)\n" "\n" " Same as the :class:`IncreasingThicknessShader`, but here we allow\n" " the user to control the thickness/length ratio so that we don't get\n" " fat short lines.\n" "\n" -" :arg s: A Stroke object.\n" -" :type s: :class:`Stroke`\n"; +" :arg stroke: A Stroke object.\n" +" :type stroke: :class:`Stroke`\n"; -static int ConstrainedIncreasingThicknessShader___init__( BPy_ConstrainedIncreasingThicknessShader* self, PyObject *args) +static int ConstrainedIncreasingThicknessShader___init__(BPy_ConstrainedIncreasingThicknessShader* self, PyObject *args, PyObject *kwds) { + static const char *kwlist[] = {"thickness_min", "thickness_max", "ratio", NULL}; float f1, f2, f3; - if(!( PyArg_ParseTuple(args, "fff", &f1, &f2, &f3) )) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "fff", (char **)kwlist, &f1, &f2, &f3)) return -1; - self->py_ss.ss = new StrokeShaders::ConstrainedIncreasingThicknessShader(f1, f2, f3); return 0; } diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_GuidingLinesShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_GuidingLinesShader.cpp index 79af155b728..f2dace8b4d5 100644 --- a/source/blender/freestyle/intern/python/StrokeShader/BPy_GuidingLinesShader.cpp +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_GuidingLinesShader.cpp @@ -15,17 +15,17 @@ static char GuidingLinesShader___doc__[] = "\n" "[Geometry shader]\n" "\n" -".. method:: __init__(iOffset)\n" +".. method:: __init__(offset)\n" "\n" " Builds a GuidingLinesShader object.\n" "\n" -" :arg iOffset: The line that replaces the stroke is initially in the\n" -" middle of the initial stroke bounding box. iOffset is the value\n" +" :arg offset: The line that replaces the stroke is initially in the\n" +" middle of the initial stroke bounding box. offset is the value\n" " of the displacement which is applied to this line along its\n" " normal.\n" -" :type iOffset: float\n" +" :type offset: float\n" "\n" -".. method:: shade(s)\n" +".. method:: shade(stroke)\n" "\n" " Shader to modify the Stroke geometry so that it corresponds to its\n" " main direction line. This shader must be used together with the\n" @@ -34,16 +34,16 @@ static char GuidingLinesShader___doc__[] = " stroke's pieces. The bigger the pieces are, the rougher the\n" " approximation is.\n" "\n" -" :arg s: A Stroke object.\n" -" :type s: :class:`Stroke`\n"; +" :arg stroke: A Stroke object.\n" +" :type stroke: :class:`Stroke`\n"; -static int GuidingLinesShader___init__( BPy_GuidingLinesShader* self, PyObject *args) +static int GuidingLinesShader___init__(BPy_GuidingLinesShader* self, PyObject *args, PyObject *kwds) { + static const char *kwlist[] = {"offset", NULL}; float f; - if(!( PyArg_ParseTuple(args, "f", &f) )) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "f", (char **)kwlist, &f)) return -1; - self->py_ss.ss = new StrokeShaders::GuidingLinesShader(f); return 0; } diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingColorShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingColorShader.cpp index 063e5cd587d..3cf5800e77d 100644 --- a/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingColorShader.cpp +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingColorShader.cpp @@ -15,43 +15,44 @@ static char IncreasingColorShader___doc__[] = "\n" "[Color shader]\n" "\n" -".. method:: __init__(iRm, iGm, iBm, iAlpham, iRM, iGM, iBM, iAlphaM)\n" +".. method:: __init__(red_min, green_min, blue_min, alpha_min, red_max, green_max, blue_max, alpha_max)\n" "\n" " Builds an IncreasingColorShader object.\n" "\n" -" :arg iRm: The first color red component.\n" -" :type iRm: float\n" -" :arg iGm: The first color green component.\n" -" :type iGm: float\n" -" :arg iBm: The first color blue component.\n" -" :type iBm: float\n" -" :arg iAlpham: The first color alpha value.\n" -" :type iAlpham: float\n" -" :arg iRM: The second color red component.\n" -" :type iRM: float\n" -" :arg iGM: The second color green component.\n" -" :type iGM: float\n" -" :arg iBM: The second color blue component.\n" -" :type iBM: float\n" -" :arg iAlphaM: The second color alpha value.\n" -" :type iAlphaM: float\n" +" :arg red_min: The first color red component.\n" +" :type red_min: float\n" +" :arg green_min: The first color green component.\n" +" :type green_min: float\n" +" :arg blue_min: The first color blue component.\n" +" :type blue_min: float\n" +" :arg alpha_min: The first color alpha value.\n" +" :type alpha_min: float\n" +" :arg red_max: The second color red component.\n" +" :type red_max: float\n" +" :arg green_max: The second color green component.\n" +" :type green_max: float\n" +" :arg blue_max: The second color blue component.\n" +" :type blue_max: float\n" +" :arg alpha_max: The second color alpha value.\n" +" :type alpha_max: float\n" "\n" -".. method:: shade(s)\n" +".. method:: shade(stroke)\n" "\n" " Assigns a varying color to the stroke. The user specifies two\n" " colors A and B. The stroke color will change linearly from A to B\n" " between the first and the last vertex.\n" "\n" -" :arg s: A Stroke object.\n" -" :type s: :class:`Stroke`\n"; +" :arg stroke: A Stroke object.\n" +" :type stroke: :class:`Stroke`\n"; -static int IncreasingColorShader___init__( BPy_IncreasingColorShader* self, PyObject *args) +static int IncreasingColorShader___init__(BPy_IncreasingColorShader* self, PyObject *args, PyObject *kwds) { + static const char *kwlist[] = {"red_min", "green_min", "blue_min", "alpha_min", + "red_max", "green_max", "blue_max", "alpha_max", NULL}; float f1, f2, f3, f4, f5, f6, f7, f8; - if(!( PyArg_ParseTuple(args, "ffffffff", &f1, &f2, &f3, &f4, &f5, &f6, &f7, &f8) )) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "ffffffff", (char **)kwlist, &f1, &f2, &f3, &f4, &f5, &f6, &f7, &f8)) return -1; - self->py_ss.ss = new StrokeShaders::IncreasingColorShader(f1, f2, f3, f4, f5, f6, f7, f8); return 0; } diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingThicknessShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingThicknessShader.cpp index 398587df23e..fe051ebaed4 100644 --- a/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingThicknessShader.cpp +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingThicknessShader.cpp @@ -15,16 +15,16 @@ static char IncreasingThicknessShader___doc__[] = "\n" "[Thickness shader]\n" "\n" -".. method:: __init__(iThicknessA, iThicknessB)\n" +".. method:: __init__(thickness_A, thickness_B)\n" "\n" " Builds an IncreasingThicknessShader object.\n" "\n" -" :arg iThicknessA: The first thickness value.\n" -" :type iThicknessA: float\n" -" :arg iThicknessB: The second thickness value.\n" -" :type iThicknessB: float\n" +" :arg thickness_A: The first thickness value.\n" +" :type thickness_A: float\n" +" :arg thickness_B: The second thickness value.\n" +" :type thickness_B: float\n" "\n" -".. method:: shade(s)\n" +".. method:: shade(stroke)\n" "\n" " Assigns thicknesses values such as the thickness increases from a\n" " thickness value A to a thickness value B between the first vertex\n" @@ -32,16 +32,16 @@ static char IncreasingThicknessShader___doc__[] = " this midpoint vertex and the last vertex. The thickness is\n" " linearly interpolated from A to B.\n" "\n" -" :arg s: A Stroke object.\n" -" :type s: :class:`Stroke`\n"; +" :arg stroke: A Stroke object.\n" +" :type stroke: :class:`Stroke`\n"; -static int IncreasingThicknessShader___init__( BPy_IncreasingThicknessShader* self, PyObject *args) +static int IncreasingThicknessShader___init__(BPy_IncreasingThicknessShader* self, PyObject *args, PyObject *kwds) { + static const char *kwlist[] = {"thickness_A", "thickness_B", NULL}; float f1, f2; - if(!( PyArg_ParseTuple(args, "ff", &f1, &f2) )) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "ff", (char **)kwlist, &f1, &f2)) return -1; - self->py_ss.ss = new StrokeShaders::IncreasingThicknessShader(f1, f2); return 0; } diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_PolygonalizationShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_PolygonalizationShader.cpp index 2ea4bf14941..367d0004995 100644 --- a/source/blender/freestyle/intern/python/StrokeShader/BPy_PolygonalizationShader.cpp +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_PolygonalizationShader.cpp @@ -15,17 +15,17 @@ static char PolygonalizationShader___doc__[] = "\n" "[Geometry shader]\n" "\n" -".. method:: __init__(iError)\n" +".. method:: __init__(error)\n" "\n" " Builds a PolygonalizationShader object.\n" "\n" -" :arg iError: The error we want our polygonal approximation to have\n" +" :arg error: The error we want our polygonal approximation to have\n" " with respect to the original geometry. The smaller, the closer\n" " the new stroke is to the orinal one. This error corresponds to\n" " the maximum distance between the new stroke and the old one.\n" -" :type iError: float\n" +" :type error: float\n" "\n" -".. method:: shade(s)\n" +".. method:: shade(stroke)\n" "\n" " Modifies the Stroke geometry so that it looks more \"polygonal\".\n" " The basic idea is to start from the minimal stroke approximation\n" @@ -33,16 +33,16 @@ static char PolygonalizationShader___doc__[] = " to subdivide using the original stroke vertices until a certain\n" " error is reached.\n" "\n" -" :arg s: A Stroke object.\n" -" :type s: :class:`Stroke`\n"; +" :arg stroke: A Stroke object.\n" +" :type stroke: :class:`Stroke`\n"; -static int PolygonalizationShader___init__( BPy_PolygonalizationShader* self, PyObject *args) +static int PolygonalizationShader___init__(BPy_PolygonalizationShader* self, PyObject *args, PyObject *kwds) { + static const char *kwlist[] = {"error", NULL}; float f; - if(!( PyArg_ParseTuple(args, "f", &f) )) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "f", (char **)kwlist, &f)) return -1; - self->py_ss.ss = new StrokeShaders::PolygonalizationShader(f); return 0; } diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_SamplingShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_SamplingShader.cpp index 08b1e64f7a5..a33ad8dd9c4 100644 --- a/source/blender/freestyle/intern/python/StrokeShader/BPy_SamplingShader.cpp +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_SamplingShader.cpp @@ -22,20 +22,20 @@ static char SamplingShader___doc__[] = " :arg sampling: The sampling to use for the stroke resampling.\n" " :type sampling: float\n" "\n" -".. method:: shade(s)\n" +".. method:: shade(stroke)\n" "\n" " Resamples the stroke.\n" "\n" -" :arg s: A Stroke object.\n" -" :type s: :class:`Stroke`\n"; +" :arg stroke: A Stroke object.\n" +" :type stroke: :class:`Stroke`\n"; -static int SamplingShader___init__( BPy_SamplingShader* self, PyObject *args) +static int SamplingShader___init__(BPy_SamplingShader* self, PyObject *args, PyObject *kwds) { + static const char *kwlist[] = {"sampling", NULL}; float f; - if(!( PyArg_ParseTuple(args, "f", &f) )) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "f", (char **)kwlist, &f)) return -1; - self->py_ss.ss = new StrokeShaders::SamplingShader(f); return 0; } diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_SmoothingShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_SmoothingShader.cpp index 6f62865f99a..a041449db4b 100644 --- a/source/blender/freestyle/intern/python/StrokeShader/BPy_SmoothingShader.cpp +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_SmoothingShader.cpp @@ -15,45 +15,53 @@ static char SmoothingShader___doc__[] = "\n" "[Geometry shader]\n" "\n" -".. method:: __init__(iNbIteration, iFactorPoint, ifactorCurvature, iFactorCurvatureDifference, iAnisoPoint, iAnisNormal, iAnisoCurvature, icarricatureFactor)\n" +".. method:: __init__(num_iterations=100, factor_point=0.1,\n" +" factor_curvature=0.0, factor_curvature_difference=0.2,\n" +" aniso_point=0.0, aniso_normal=0.0, aniso_curvature=0.0,\n" +" carricature_factor=1.0)\n" "\n" " Builds a SmoothingShader object.\n" "\n" -" :arg iNbIteration: The number of iterations (400).\n" -" :type iNbIteration: int\n" -" :arg iFactorPoint: 0.0\n" -" :type iFactorPoint: float\n" -" :arg ifactorCurvature: 0.0\n" -" :type ifactorCurvature: float\n" -" :arg iFactorCurvatureDifference: 0.2\n" -" :type iFactorCurvatureDifference: float\n" -" :arg iAnisoPoint: \n" -" :type iAnisoPoint: float\n" -" :arg iAnisNormal: 0.0\n" -" :type iAnisNormal: float\n" -" :arg iAnisoCurvature: 0.0\n" -" :type iAnisoCurvature: float\n" -" :arg icarricatureFactor: 1.0\n" -" :type icarricatureFactor: float\n" +" :arg num_iterations: The number of iterations.\n" +" :type num_iterations: int\n" +" :arg factor_point: 0.1\n" +" :type factor_point: float\n" +" :arg factor_curvature: 0.0\n" +" :type factor_curvature: float\n" +" :arg factor_curvature_difference: 0.2\n" +" :type factor_curvature_difference: float\n" +" :arg aniso_point: 0.0\n" +" :type aniso_point: float\n" +" :arg aniso_normal: 0.0\n" +" :type aniso_normal: float\n" +" :arg aniso_curvature: 0.0\n" +" :type aniso_curvature: float\n" +" :arg carricature_factor: 1.0\n" +" :type carricature_factor: float\n" "\n" -".. method:: shade(s)\n" +".. method:: shade(stroke)\n" "\n" " Smoothes the stroke by moving the vertices to make the stroke\n" " smoother. Uses curvature flow to converge towards a curve of\n" " constant curvature. The diffusion method we use is anisotropic to\n" " prevent the diffusion accross corners.\n" "\n" -" :arg s: A Stroke object.\n" -" :type s: :class:`Stroke`\n"; +" :arg stroke: A Stroke object.\n" +" :type stroke: :class:`Stroke`\n"; -static int SmoothingShader___init__( BPy_SmoothingShader* self, PyObject *args) +static int SmoothingShader___init__(BPy_SmoothingShader* self, PyObject *args, PyObject *kwds) { - int i1; - double d2, d3, d4, d5, d6, d7, d8; + static const char *kwlist[] = {"num_iterations", "factor_point", "factor_curvature", + "factor_curvature_difference", "aniso_point", "aniso_normal", + "aniso_curvature", "carricature_factor", NULL}; + int i1 = 100; + double d2 = 0.1, d3 = 0.0, d4 = 0.2, d5 = 0.0, d6 = 0.0, d7 = 0.0, d8 = 1.0; - if(!( PyArg_ParseTuple(args, "iddddddd", &i1, &d2, &d3, &d4, &d5, &d6, &d7, &d8) )) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|iddddddd", (char **)kwlist, + &i1, &d2, &d3, &d4, &d5, &d6, &d7, &d8)) + { return -1; - + } self->py_ss.ss = new SmoothingShader(i1, d2, d3, d4, d5, d6, d7, d8); return 0; } diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_SpatialNoiseShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_SpatialNoiseShader.cpp index 245212c3950..89991ff43f5 100644 --- a/source/blender/freestyle/intern/python/StrokeShader/BPy_SpatialNoiseShader.cpp +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_SpatialNoiseShader.cpp @@ -16,39 +16,42 @@ static char SpatialNoiseShader___doc__[] = "\n" "[Geometry shader]\n" "\n" -".. method:: __init__(iAmount, ixScale, nbOctave, smooth, pureRandom)\n" +".. method:: __init__(amount, scale, num_octaves, smooth, pure_random)\n" "\n" " Builds a SpatialNoiseShader object.\n" "\n" -" :arg iAmount: The amplitude of the noise.\n" -" :type iAmount: float\n" -" :arg ixScale: The noise frequency.\n" -" :type ixScale: float\n" -" :arg nbOctave: The number of octaves\n" -" :type nbOctave: int\n" +" :arg amount: The amplitude of the noise.\n" +" :type amount: float\n" +" :arg scale: The noise frequency.\n" +" :type scale: float\n" +" :arg num_octaves: The number of octaves\n" +" :type num_octaves: int\n" " :arg smooth: True if you want the noise to be smooth.\n" " :type smooth: bool\n" -" :arg pureRandom: True if you don't want any coherence.\n" -" :type pureRandom: bool\n" +" :arg pure_random: True if you don't want any coherence.\n" +" :type pure_random: bool\n" "\n" -".. method:: shade(s)\n" +".. method:: shade(stroke)\n" "\n" " Spatial Noise stroke shader. Moves the vertices to make the stroke\n" " more noisy.\n" "\n" -" :arg s: A Stroke object.\n" -" :type s: :class:`Stroke`\n"; +" :arg stroke: A Stroke object.\n" +" :type stroke: :class:`Stroke`\n"; -static int SpatialNoiseShader___init__( BPy_SpatialNoiseShader* self, PyObject *args) +static int SpatialNoiseShader___init__(BPy_SpatialNoiseShader* self, PyObject *args, PyObject *kwds) { + static const char *kwlist[] = {"amount", "scale", "num_octaves", "smooth", "pure_random", NULL}; float f1, f2; int i3; PyObject *obj4 = 0, *obj5 = 0; - - if(!( PyArg_ParseTuple(args, "ffiOO", &f1, &f2, &i3, &obj4, &obj5) )) - return -1; - self->py_ss.ss = new SpatialNoiseShader(f1, f2, i3, bool_from_PyBool(obj4), bool_from_PyBool(obj5) ); + if (!PyArg_ParseTupleAndKeywords(args, kwds, "ffiO!O!", (char **)kwlist, + &f1, &f2, &i3, &PyBool_Type, &obj4, &PyBool_Type, &obj5)) + { + return -1; + } + self->py_ss.ss = new SpatialNoiseShader(f1, f2, i3, bool_from_PyBool(obj4), bool_from_PyBool(obj5)); return 0; } diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_StrokeTextureShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_StrokeTextureShader.cpp index a6e2d9f71e0..8ea2eac552d 100644 --- a/source/blender/freestyle/intern/python/StrokeShader/BPy_StrokeTextureShader.cpp +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_StrokeTextureShader.cpp @@ -17,18 +17,18 @@ static char StrokeTextureShader___doc__[] = "\n" "[Texture shader]\n" "\n" -".. method:: __init__(textureFile, mediumType=MediumType.OPAQUE_MEDIUM, iTips=False)\n" +".. method:: __init__(texture_file, medium_type=MediumType.OPAQUE_MEDIUM, tips=False)\n" "\n" " Builds a StrokeTextureShader object.\n" "\n" -" :arg textureFile: \n" -" :type textureFile: str\n" -" :arg mediumType: The medium type and therefore, the blending mode\n" +" :arg texture_file: \n" +" :type texture_file: str\n" +" :arg medium_type: The medium type and therefore, the blending mode\n" " that must be used for the rendering of this stroke.\n" -" :type mediumType: :class:`MediumType`\n" -" :arg iTips: Tells whether the texture includes tips or not. If it\n" +" :type medium_type: :class:`MediumType`\n" +" :arg tips: Tells whether the texture includes tips or not. If it\n" " is the case, the texture image must respect the following format.\n" -" :type iTips: bool\n" +" :type tips: bool\n" "\n" " The format of a texture image including tips::\n" "\n" @@ -44,26 +44,28 @@ static char StrokeTextureShader___doc__[] = " * B : The stroke's left extremity texture.\n" " * C : The stroke's right extremity texture.\n" "\n" -".. method:: shade(s)\n" +".. method:: shade(stroke)\n" "\n" " Assigns a texture and a blending mode to the stroke in order to\n" " simulate its marks system.\n" "\n" -" :arg s: A Stroke object.\n" -" :type s: :class:`Stroke`\n"; +" :arg stroke: A Stroke object.\n" +" :type stroke: :class:`Stroke`\n"; -static int StrokeTextureShader___init__( BPy_StrokeTextureShader* self, PyObject *args) +static int StrokeTextureShader___init__(BPy_StrokeTextureShader* self, PyObject *args, PyObject *kwds) { + static const char *kwlist[] = {"texture_file", "medium_type", "tips", NULL}; const char *s1; PyObject *obj2 = 0, *obj3 = 0; - - if(!( PyArg_ParseTuple(args, "s|O!O", &s1, &MediumType_Type, &obj2, &obj3) )) - return -1; - Stroke::MediumType mt = (obj2) ? MediumType_from_BPy_MediumType(obj2) : Stroke::OPAQUE_MEDIUM; - bool b = (obj3) ? bool_from_PyBool(obj3) : true; - - self->py_ss.ss = new StrokeShaders::StrokeTextureShader(s1,mt,b); + if (!PyArg_ParseTupleAndKeywords(args, kwds, "s|O!O!", (char **)kwlist, + &s1, &MediumType_Type, &obj2, &PyBool_Type, &obj3)) + { + return -1; + } + Stroke::MediumType mt = (!obj2) ? Stroke::OPAQUE_MEDIUM : MediumType_from_BPy_MediumType(obj2); + bool b = (!obj3) ? false : bool_from_PyBool(obj3); + self->py_ss.ss = new StrokeShaders::StrokeTextureShader(s1, mt, b); return 0; } diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_TextureAssignerShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_TextureAssignerShader.cpp index 7fbb3462fb4..ea0b0e26f87 100644 --- a/source/blender/freestyle/intern/python/StrokeShader/BPy_TextureAssignerShader.cpp +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_TextureAssignerShader.cpp @@ -15,14 +15,14 @@ static char TextureAssignerShader___doc__[] = "\n" "[Texture shader]\n" "\n" -".. method:: __init__(id)\n" +".. method:: __init__(preset)\n" "\n" " Builds a TextureAssignerShader object.\n" "\n" -" :arg id: The preset number to use.\n" -" :type id: int\n" +" :arg preset: The preset number to use.\n" +" :type preset: int\n" "\n" -".. method:: shade(s)\n" +".. method:: shade(stroke)\n" "\n" " Assigns a texture to the stroke in order to simulate its marks\n" " system. This shader takes as input an integer value telling which\n" @@ -42,16 +42,16 @@ static char TextureAssignerShader___doc__[] = "\n" " * Default: `/brushes/smoothAlpha.bmp`, `MediumType.OPAQUE_MEDIUM`\n" "\n" -" :arg s: A Stroke object.\n" -" :type s: :class:`Stroke`\n"; +" :arg stroke: A Stroke object.\n" +" :type stroke: :class:`Stroke`\n"; -static int TextureAssignerShader___init__( BPy_TextureAssignerShader* self, PyObject *args) +static int TextureAssignerShader___init__(BPy_TextureAssignerShader* self, PyObject *args, PyObject *kwds) { + static const char *kwlist[] = {"preset", NULL}; int i; - if(!( PyArg_ParseTuple(args, "i", &i) )) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "i", (char **)kwlist, &i)) return -1; - self->py_ss.ss = new StrokeShaders::TextureAssignerShader(i); return 0; } diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_ThicknessNoiseShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_ThicknessNoiseShader.cpp index c0cf2176b52..d0f476a4e10 100644 --- a/source/blender/freestyle/intern/python/StrokeShader/BPy_ThicknessNoiseShader.cpp +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_ThicknessNoiseShader.cpp @@ -15,29 +15,29 @@ static char ThicknessNoiseShader___doc__[] = "\n" "[Thickness shader]\n" "\n" -".. method:: __init__(iAmplitude, iPeriod)\n" +".. method:: __init__(amplitude, period)\n" "\n" " Builds a ThicknessNoiseShader object.\n" "\n" -" :arg iAmplitude: The amplitude of the noise signal.\n" -" :type iAmplitude: float\n" -" :arg iPeriod: The period of the noise signal.\n" -" :type iPeriod: float\n" +" :arg amplitude: The amplitude of the noise signal.\n" +" :type amplitude: float\n" +" :arg period: The period of the noise signal.\n" +" :type period: float\n" "\n" -".. method:: shade(s)\n" +".. method:: shade(stroke)\n" "\n" " Adds some noise to the stroke thickness.\n" "\n" -" :arg s: A Stroke object.\n" -" :type s: :class:`Stroke`\n"; +" :arg stroke: A Stroke object.\n" +" :type stroke: :class:`Stroke`\n"; -static int ThicknessNoiseShader___init__( BPy_ThicknessNoiseShader* self, PyObject *args) +static int ThicknessNoiseShader___init__(BPy_ThicknessNoiseShader* self, PyObject *args, PyObject *kwds) { + static const char *kwlist[] = {"amplitude", "period", NULL}; float f1, f2; - - if(!( PyArg_ParseTuple(args, "ff", &f1, &f2) )) - return -1; + if (!PyArg_ParseTupleAndKeywords(args, kwds, "ff", (char **)kwlist, &f1, &f2)) + return -1; self->py_ss.ss = new StrokeShaders::ThicknessNoiseShader(f1, f2); return 0; } diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_ThicknessVariationPatternShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_ThicknessVariationPatternShader.cpp index afcfd68fcec..70c76dd22d3 100644 --- a/source/blender/freestyle/intern/python/StrokeShader/BPy_ThicknessVariationPatternShader.cpp +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_ThicknessVariationPatternShader.cpp @@ -16,39 +16,39 @@ static char ThicknessVariationPatternShader___doc__[] = "\n" "[Thickness shader]\n" "\n" -".. method:: __init__(pattern_name, iMinThickness, iMaxThickness, stretch)\n" +".. method:: __init__(pattern_name, thickness_min=1.0, thickness_max=5.0, stretch=True)\n" "\n" " Builds a ThicknessVariationPatternShader object.\n" "\n" " :arg pattern_name: The texture file name.\n" " :type pattern_name: str\n" -" :arg iMinThickness: The minimum thickness we don't want to exceed.\n" -" :type iMinThickness: float\n" -" :arg iMaxThickness: The maximum thickness we don't want to exceed.\n" -" :type iMaxThickness: float\n" +" :arg thickness_min: The minimum thickness we don't want to exceed.\n" +" :type thickness_min: float\n" +" :arg thickness_max: The maximum thickness we don't want to exceed.\n" +" :type thickness_max: float\n" " :arg stretch: Tells whether the pattern texture must be stretched\n" -" or repeted to fit the stroke.\n" +" or repeated to fit the stroke.\n" " :type stretch: bool\n" "\n" -".. method:: shade(s)\n" +".. method:: shade(stroke)\n" "\n" " Applies a pattern (texture) to vary thickness. The new thicknesses\n" " are the result of the multiplication of the pattern and the\n" " original thickness.\n" "\n" -" :arg s: A Stroke object.\n" -" :type s: :class:`Stroke`\n"; +" :arg stroke: A Stroke object.\n" +" :type stroke: :class:`Stroke`\n"; -static int ThicknessVariationPatternShader___init__( BPy_ThicknessVariationPatternShader* self, PyObject *args) +static int ThicknessVariationPatternShader___init__(BPy_ThicknessVariationPatternShader* self, PyObject *args, PyObject *kwds) { + static const char *kwlist[] = {"pattern_name", "thickness_min", "thickness_max", "stretch", NULL}; const char *s1; float f2 = 1.0, f3 = 5.0; PyObject *obj4 = 0; - if(!( PyArg_ParseTuple(args, "s|ffO", &s1, &f2, &f3, &obj4) )) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "s|ffO!", (char **)kwlist, &s1, &f2, &f3, &PyBool_Type, &obj4)) return -1; - - bool b = (obj4) ? bool_from_PyBool(obj4) : true; + bool b = (!obj4) ? true : bool_from_PyBool(obj4); self->py_ss.ss = new StrokeShaders::ThicknessVariationPatternShader(s1, f2, f3, b); return 0; } diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_TipRemoverShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_TipRemoverShader.cpp index 8241a03892c..34ab23687bb 100644 --- a/source/blender/freestyle/intern/python/StrokeShader/BPy_TipRemoverShader.cpp +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_TipRemoverShader.cpp @@ -15,28 +15,28 @@ static char TipRemoverShader___doc__[] = "\n" "[Geometry shader]\n" "\n" -".. method:: __init__(tipLength)\n" +".. method:: __init__(tip_length)\n" "\n" " Builds a TipRemoverShader object.\n" "\n" -" :arg tipLength: The length of the piece of stroke we want to remove\n" +" :arg tip_length: The length of the piece of stroke we want to remove\n" " at each extremity.\n" -" :type tipLength: float\n" +" :type tip_length: float\n" "\n" -".. method:: shade(s)\n" +".. method:: shade(stroke)\n" "\n" " Removes the stroke's extremities.\n" "\n" -" :arg s: A Stroke object.\n" -" :type s: :class:`Stroke`\n"; +" :arg stroke: A Stroke object.\n" +" :type stroke: :class:`Stroke`\n"; -static int TipRemoverShader___init__( BPy_TipRemoverShader* self, PyObject *args) +static int TipRemoverShader___init__(BPy_TipRemoverShader* self, PyObject *args, PyObject *kwds) { + static const char *kwlist[] = {"tip_length", NULL}; double d; - if(!( PyArg_ParseTuple(args, "d", &d) )) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "d", (char **)kwlist, &d)) return -1; - self->py_ss.ss = new StrokeShaders::TipRemoverShader(d); return 0; } diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_fstreamShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_fstreamShader.cpp index 2d9828c232c..765465cac6c 100644 --- a/source/blender/freestyle/intern/python/StrokeShader/BPy_fstreamShader.cpp +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_fstreamShader.cpp @@ -15,27 +15,27 @@ static char fstreamShader___doc__[] = "\n" "[Output shader]\n" "\n" -".. method:: __init__(iFileName)\n" +".. method:: __init__(filename)\n" "\n" " Builds a fstreamShader object.\n" "\n" -" :arg iFileName: The output file name.\n" -" :type iFileName: str\n" +" :arg filename: The output file name.\n" +" :type filename: str\n" "\n" -".. method:: shade(s)\n" +".. method:: shade(stroke)\n" "\n" " Streams the Stroke in a file.\n" "\n" -" :arg s: A Stroke object.\n" -" :type s: :class:`Stroke`\n"; +" :arg stroke: A Stroke object.\n" +" :type stroke: :class:`Stroke`\n"; -static int fstreamShader___init__( BPy_fstreamShader* self, PyObject *args) +static int fstreamShader___init__(BPy_fstreamShader* self, PyObject *args, PyObject *kwds) { + static const char *kwlist[] = {"filename", NULL}; const char *s; - if(!( PyArg_ParseTuple(args, "s", &s) )) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "s", (char **)kwlist, &s)) return -1; - self->py_ss.ss = new StrokeShaders::fstreamShader(s); return 0; } diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_streamShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_streamShader.cpp index 722c51c440e..a37cfc68d44 100644 --- a/source/blender/freestyle/intern/python/StrokeShader/BPy_streamShader.cpp +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_streamShader.cpp @@ -19,16 +19,18 @@ static char streamShader___doc__[] = "\n" " Builds a streamShader object.\n" "\n" -".. method:: shade(s)\n" +".. method:: shade(stroke)\n" "\n" " Streams the Stroke into stdout.\n" "\n" -" :arg s: A Stroke object.\n" -" :type s: :class:`Stroke`\n"; +" :arg stroke: A Stroke object.\n" +" :type stroke: :class:`Stroke`\n"; -static int streamShader___init__( BPy_streamShader* self, PyObject *args) +static int streamShader___init__(BPy_streamShader* self, PyObject *args, PyObject *kwds) { - if(!( PyArg_ParseTuple(args, "") )) + static const char *kwlist[] = {NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) return -1; self->py_ss.ss = new StrokeShaders::streamShader(); return 0; diff --git a/source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_FalseUP0D.cpp b/source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_FalseUP0D.cpp index afefa703d14..837535cd098 100644 --- a/source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_FalseUP0D.cpp +++ b/source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_FalseUP0D.cpp @@ -20,9 +20,11 @@ static char FalseUP0D___doc__[] = " :return: False.\n" " :rtype: bool\n"; -static int FalseUP0D___init__( BPy_FalseUP0D* self, PyObject *args) +static int FalseUP0D___init__(BPy_FalseUP0D* self, PyObject *args, PyObject *kwds) { - if(!( PyArg_ParseTuple(args, "") )) + static const char *kwlist[] = {NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) return -1; self->py_up0D.up0D = new Predicates0D::FalseUP0D(); return 0; diff --git a/source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_TrueUP0D.cpp b/source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_TrueUP0D.cpp index 2efc9ed6f74..ff40d1ccddc 100644 --- a/source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_TrueUP0D.cpp +++ b/source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_TrueUP0D.cpp @@ -20,9 +20,11 @@ static char TrueUP0D___doc__[] = " :return: True.\n" " :rtype: bool\n"; -static int TrueUP0D___init__( BPy_TrueUP0D* self, PyObject *args ) +static int TrueUP0D___init__(BPy_TrueUP0D* self, PyObject *args, PyObject *kwds) { - if(!( PyArg_ParseTuple(args, "") )) + static const char *kwlist[] = {NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) return -1; self->py_up0D.up0D = new Predicates0D::TrueUP0D(); return 0; diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ContourUP1D.cpp b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ContourUP1D.cpp index dbbcc4255cf..f9461033f23 100644 --- a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ContourUP1D.cpp +++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ContourUP1D.cpp @@ -21,9 +21,11 @@ static char ContourUP1D___doc__[] = " :return: True if the Interface1D is a contour, false otherwise.\n" " :rtype: bool\n"; -static int ContourUP1D___init__( BPy_ContourUP1D* self, PyObject *args ) +static int ContourUP1D___init__(BPy_ContourUP1D* self, PyObject *args, PyObject *kwds) { - if(!( PyArg_ParseTuple(args, "") )) + static const char *kwlist[] = {NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) return -1; self->py_up1D.up1D = new Predicates1D::ContourUP1D(); return 0; diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_DensityLowerThanUP1D.cpp b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_DensityLowerThanUP1D.cpp index c88f077c23b..0d49f6be6c9 100644 --- a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_DensityLowerThanUP1D.cpp +++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_DensityLowerThanUP1D.cpp @@ -34,14 +34,14 @@ static char DensityLowerThanUP1D___doc__[] = " :return: True if the density is lower than a threshold.\n" " :rtype: bool\n"; -static int DensityLowerThanUP1D___init__( BPy_DensityLowerThanUP1D* self, PyObject *args ) +static int DensityLowerThanUP1D___init__(BPy_DensityLowerThanUP1D* self, PyObject *args, PyObject *kwds) { + static const char *kwlist[] = {"threshold", "sigma", NULL}; double d1, d2 = 2.0; - if( !PyArg_ParseTuple(args, "d|d", &d1, &d2) ) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "d|d", (char **)kwlist, &d1, &d2)) return -1; - - self->py_up1D.up1D = new Predicates1D::DensityLowerThanUP1D(d1,d2); + self->py_up1D.up1D = new Predicates1D::DensityLowerThanUP1D(d1, d2); return 0; } diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToChainingTimeStampUP1D.cpp b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToChainingTimeStampUP1D.cpp index 2310f5792c5..861702d31be 100644 --- a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToChainingTimeStampUP1D.cpp +++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToChainingTimeStampUP1D.cpp @@ -28,13 +28,13 @@ static char EqualToChainingTimeStampUP1D___doc__[] = " :return: True if the time stamp is equal to a user-defined value.\n" " :rtype: bool\n"; -static int EqualToChainingTimeStampUP1D___init__( BPy_EqualToChainingTimeStampUP1D* self, PyObject *args ) +static int EqualToChainingTimeStampUP1D___init__(BPy_EqualToChainingTimeStampUP1D* self, PyObject *args, PyObject *kwds) { + static const char *kwlist[] = {"ts", NULL}; unsigned u; - if( !PyArg_ParseTuple(args, "I", &u) ) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "I", (char **)kwlist, &u)) return -1; - self->py_up1D.up1D = new Predicates1D::EqualToChainingTimeStampUP1D(u); return 0; } diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToTimeStampUP1D.cpp b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToTimeStampUP1D.cpp index 97415b2b28f..9a2b0baa026 100644 --- a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToTimeStampUP1D.cpp +++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToTimeStampUP1D.cpp @@ -28,13 +28,13 @@ static char EqualToTimeStampUP1D___doc__[] = " :return: True if the time stamp is equal to a user-defined value.\n" " :rtype: bool\n"; -static int EqualToTimeStampUP1D___init__( BPy_EqualToTimeStampUP1D* self, PyObject *args ) +static int EqualToTimeStampUP1D___init__(BPy_EqualToTimeStampUP1D* self, PyObject *args, PyObject *kwds) { + static const char *kwlist[] = {"ts", NULL}; unsigned u; - if( !PyArg_ParseTuple(args, "I", &u) ) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "I", (char **)kwlist, &u)) return -1; - self->py_up1D.up1D = new Predicates1D::EqualToTimeStampUP1D(u); return 0; } diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ExternalContourUP1D.cpp b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ExternalContourUP1D.cpp index 3c9156f3a89..168ab7e254f 100644 --- a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ExternalContourUP1D.cpp +++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ExternalContourUP1D.cpp @@ -23,9 +23,11 @@ static char ExternalContourUP1D___doc__[] = " otherwise.\n" " :rtype: bool\n"; -static int ExternalContourUP1D___init__( BPy_ExternalContourUP1D* self, PyObject *args ) +static int ExternalContourUP1D___init__(BPy_ExternalContourUP1D* self, PyObject *args, PyObject *kwds) { - if(!( PyArg_ParseTuple(args, "") )) + static const char *kwlist[] = {NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) return -1; self->py_up1D.up1D = new Predicates1D::ExternalContourUP1D(); return 0; diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_FalseUP1D.cpp b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_FalseUP1D.cpp index ac878a7770b..d3b399f49a7 100644 --- a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_FalseUP1D.cpp +++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_FalseUP1D.cpp @@ -20,9 +20,11 @@ static char FalseUP1D___doc__[] = " :return: False.\n" " :rtype: bool\n"; -static int FalseUP1D___init__( BPy_FalseUP1D* self, PyObject *args ) +static int FalseUP1D___init__(BPy_FalseUP1D* self, PyObject *args, PyObject *kwds) { - if(!( PyArg_ParseTuple(args, "") )) + static const char *kwlist[] = {NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) return -1; self->py_up1D.up1D = new Predicates1D::FalseUP1D(); return 0; diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_QuantitativeInvisibilityUP1D.cpp b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_QuantitativeInvisibilityUP1D.cpp index cabc4689a03..c333a6742a7 100644 --- a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_QuantitativeInvisibilityUP1D.cpp +++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_QuantitativeInvisibilityUP1D.cpp @@ -31,13 +31,13 @@ static char QuantitativeInvisibilityUP1D___doc__[] = " value.\n" " :rtype: bool\n"; -static int QuantitativeInvisibilityUP1D___init__( BPy_QuantitativeInvisibilityUP1D* self, PyObject *args ) +static int QuantitativeInvisibilityUP1D___init__(BPy_QuantitativeInvisibilityUP1D* self, PyObject *args, PyObject *kwds) { + static const char *kwlist[] = {"qi", NULL}; int i = 0; - if( !PyArg_ParseTuple(args, "|i", &i) ) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|i", (char **)kwlist, &i)) return -1; - self->py_up1D.up1D = new Predicates1D::QuantitativeInvisibilityUP1D(i); return 0; } diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ShapeUP1D.cpp b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ShapeUP1D.cpp index 9e6e57c8d94..8af592b8923 100644 --- a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ShapeUP1D.cpp +++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ShapeUP1D.cpp @@ -11,14 +11,14 @@ extern "C" { static char ShapeUP1D___doc__[] = "Class hierarchy: :class:`UnaryPredicate1D` > :class:`ShapeUP1D`\n" "\n" -".. method:: __init__(idFirst, idSecond=0)\n" +".. method:: __init__(first, second=0)\n" "\n" " Builds a ShapeUP1D object.\n" "\n" -" :arg idFirst: The first Id component.\n" -" :type idFirst: int\n" -" :arg idSecond: The second Id component.\n" -" :type idSecond: int\n" +" :arg first: The first Id component.\n" +" :type first: int\n" +" :arg second: The second Id component.\n" +" :type second: int\n" "\n" ".. method:: __call__(inter)\n" "\n" @@ -31,14 +31,14 @@ static char ShapeUP1D___doc__[] = " user-specified Id.\n" " :rtype: bool\n"; -static int ShapeUP1D___init__( BPy_ShapeUP1D* self, PyObject *args ) +static int ShapeUP1D___init__(BPy_ShapeUP1D* self, PyObject *args, PyObject *kwds) { + static const char *kwlist[] = {"first", "second", NULL}; unsigned u1, u2 = 0; - if( !PyArg_ParseTuple(args, "I|I", &u1, &u2) ) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "I|I", (char **)kwlist, &u1, &u2)) return -1; - - self->py_up1D.up1D = new Predicates1D::ShapeUP1D(u1,u2); + self->py_up1D.up1D = new Predicates1D::ShapeUP1D(u1, u2); return 0; } diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_TrueUP1D.cpp b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_TrueUP1D.cpp index 01da1a44453..630f302a31b 100644 --- a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_TrueUP1D.cpp +++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_TrueUP1D.cpp @@ -20,9 +20,11 @@ static char TrueUP1D___doc__[] = " :return: True.\n" " :rtype: bool\n"; -static int TrueUP1D___init__( BPy_TrueUP1D* self, PyObject *args ) +static int TrueUP1D___init__(BPy_TrueUP1D* self, PyObject *args, PyObject *kwds) { - if(!( PyArg_ParseTuple(args, "") )) + static const char *kwlist[] = {NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) return -1; self->py_up1D.up1D = new Predicates1D::TrueUP1D(); return 0; diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_WithinImageBoundaryUP1D.cpp b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_WithinImageBoundaryUP1D.cpp index 9beae103113..14cc70917df 100644 --- a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_WithinImageBoundaryUP1D.cpp +++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_WithinImageBoundaryUP1D.cpp @@ -28,11 +28,12 @@ static char WithinImageBoundaryUP1D___doc__[] = "\n" " Returns true if the Interface1D intersects with image boundary.\n"; -static int WithinImageBoundaryUP1D___init__( BPy_WithinImageBoundaryUP1D* self, PyObject *args ) +static int WithinImageBoundaryUP1D___init__(BPy_WithinImageBoundaryUP1D* self, PyObject *args, PyObject *kwds) { + static const char *kwlist[] = {"xmin", "ymin", "xmax", "ymax", NULL}; double xmin, ymin, xmax, ymax; - if(!( PyArg_ParseTuple(args, "dddd", &xmin, &ymin, &xmax, &ymax) )) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "dddd", (char **)kwlist, &xmin, &ymin, &xmax, &ymax)) return -1; self->py_up1D.up1D = new Predicates1D::WithinImageBoundaryUP1D(xmin, ymin, xmax, ymax); return 0; |