From 33f34e1a7bc08f123d76198ae0671e3da1ded401 Mon Sep 17 00:00:00 2001 From: Tamito Kajiyama Date: Fri, 22 Feb 2013 01:57:20 +0000 Subject: Freestyle Python API improvements - part 6. Fix for PyGetSetDef and proper handling of keyword arguments were done in Function0D and Function1D classes. Additional code clean-up was also made. --- .../UnaryFunction1D/BPy_UnaryFunction1DDouble.cpp | 174 +++++++++------------ .../BPy_UnaryFunction1DEdgeNature.cpp | 121 ++++++-------- .../UnaryFunction1D/BPy_UnaryFunction1DFloat.cpp | 117 ++++++-------- .../BPy_UnaryFunction1DUnsigned.cpp | 121 ++++++-------- .../UnaryFunction1D/BPy_UnaryFunction1DVec2f.cpp | 125 ++++++--------- .../UnaryFunction1D/BPy_UnaryFunction1DVec3f.cpp | 121 ++++++-------- .../BPy_UnaryFunction1DVectorViewShape.cpp | 129 +++++++-------- .../UnaryFunction1D/BPy_UnaryFunction1DVoid.cpp | 127 ++++++--------- .../BPy_CurveNatureF1D.cpp | 14 +- .../UnaryFunction1D_Vec2f/BPy_Normal2DF1D.cpp | 14 +- .../UnaryFunction1D_Vec2f/BPy_Orientation2DF1D.cpp | 16 +- .../UnaryFunction1D_Vec3f/BPy_Orientation3DF1D.cpp | 14 +- .../BPy_Curvature2DAngleF1D.cpp | 14 +- .../UnaryFunction1D_double/BPy_DensityF1D.cpp | 16 +- .../BPy_GetCompleteViewMapDensityF1D.cpp | 19 ++- .../BPy_GetDirectionalViewMapDensityF1D.cpp | 21 ++- .../BPy_GetProjectedXF1D.cpp | 14 +- .../BPy_GetProjectedYF1D.cpp | 14 +- .../BPy_GetProjectedZF1D.cpp | 14 +- .../BPy_GetSteerableViewMapDensityF1D.cpp | 17 +- .../BPy_GetViewMapGradientNormF1D.cpp | 17 +- .../UnaryFunction1D_double/BPy_GetXF1D.cpp | 14 +- .../UnaryFunction1D_double/BPy_GetYF1D.cpp | 14 +- .../UnaryFunction1D_double/BPy_GetZF1D.cpp | 14 +- .../BPy_LocalAverageDepthF1D.cpp | 15 +- .../BPy_ZDiscontinuityF1D.cpp | 14 +- .../BPy_QuantitativeInvisibilityF1D.cpp | 15 +- .../BPy_GetOccludeeF1D.cpp | 6 +- .../BPy_GetOccludersF1D.cpp | 6 +- .../BPy_GetShapeF1D.cpp | 6 +- .../BPy_ChainingTimeStampF1D.cpp | 6 +- .../BPy_IncrementChainingTimeStampF1D.cpp | 6 +- .../UnaryFunction1D_void/BPy_TimeStampF1D.cpp | 6 +- 33 files changed, 591 insertions(+), 770 deletions(-) (limited to 'source/blender/freestyle/intern/python/UnaryFunction1D') diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DDouble.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DDouble.cpp index 07fb48dd9a8..180f39c5e59 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DDouble.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DDouble.cpp @@ -28,84 +28,84 @@ extern "C" { //-------------------MODULE INITIALIZATION-------------------------------- -int UnaryFunction1DDouble_Init( PyObject *module ) { - - if( module == NULL ) +int UnaryFunction1DDouble_Init(PyObject *module) +{ + if (module == NULL) return -1; - if( PyType_Ready( &UnaryFunction1DDouble_Type ) < 0 ) + if (PyType_Ready(&UnaryFunction1DDouble_Type) < 0) return -1; - Py_INCREF( &UnaryFunction1DDouble_Type ); + Py_INCREF(&UnaryFunction1DDouble_Type); PyModule_AddObject(module, "UnaryFunction1DDouble", (PyObject *)&UnaryFunction1DDouble_Type); - if( PyType_Ready( &DensityF1D_Type ) < 0 ) + if (PyType_Ready(&DensityF1D_Type) < 0) return -1; - Py_INCREF( &DensityF1D_Type ); + Py_INCREF(&DensityF1D_Type); PyModule_AddObject(module, "DensityF1D", (PyObject *)&DensityF1D_Type); - if( PyType_Ready( &Curvature2DAngleF1D_Type ) < 0 ) + if (PyType_Ready(&Curvature2DAngleF1D_Type) < 0) return -1; - Py_INCREF( &Curvature2DAngleF1D_Type ); + Py_INCREF(&Curvature2DAngleF1D_Type); PyModule_AddObject(module, "Curvature2DAngleF1D", (PyObject *)&Curvature2DAngleF1D_Type); - if( PyType_Ready( &GetCompleteViewMapDensityF1D_Type ) < 0 ) + if (PyType_Ready(&GetCompleteViewMapDensityF1D_Type) < 0) return -1; - Py_INCREF( &GetCompleteViewMapDensityF1D_Type ); + Py_INCREF(&GetCompleteViewMapDensityF1D_Type); PyModule_AddObject(module, "GetCompleteViewMapDensityF1D", (PyObject *)&GetCompleteViewMapDensityF1D_Type); - if( PyType_Ready( &GetDirectionalViewMapDensityF1D_Type ) < 0 ) + if (PyType_Ready(&GetDirectionalViewMapDensityF1D_Type) < 0) return -1; - Py_INCREF( &GetDirectionalViewMapDensityF1D_Type ); + Py_INCREF(&GetDirectionalViewMapDensityF1D_Type); PyModule_AddObject(module, "GetDirectionalViewMapDensityF1D", (PyObject *)&GetDirectionalViewMapDensityF1D_Type); - if( PyType_Ready( &GetProjectedXF1D_Type ) < 0 ) + if (PyType_Ready(&GetProjectedXF1D_Type) < 0) return -1; - Py_INCREF( &GetProjectedXF1D_Type ); + Py_INCREF(&GetProjectedXF1D_Type); PyModule_AddObject(module, "GetProjectedXF1D", (PyObject *)&GetProjectedXF1D_Type); - if( PyType_Ready( &GetProjectedYF1D_Type ) < 0 ) + if (PyType_Ready(&GetProjectedYF1D_Type) < 0) return -1; - Py_INCREF( &GetProjectedYF1D_Type ); + Py_INCREF(&GetProjectedYF1D_Type); PyModule_AddObject(module, "GetProjectedYF1D", (PyObject *)&GetProjectedYF1D_Type); - if( PyType_Ready( &GetProjectedZF1D_Type ) < 0 ) + if (PyType_Ready(&GetProjectedZF1D_Type) < 0) return -1; - Py_INCREF( &GetProjectedZF1D_Type ); + Py_INCREF(&GetProjectedZF1D_Type); PyModule_AddObject(module, "GetProjectedZF1D", (PyObject *)&GetProjectedZF1D_Type); - if( PyType_Ready( &GetSteerableViewMapDensityF1D_Type ) < 0 ) + if (PyType_Ready(&GetSteerableViewMapDensityF1D_Type) < 0) return -1; - Py_INCREF( &GetSteerableViewMapDensityF1D_Type ); + Py_INCREF(&GetSteerableViewMapDensityF1D_Type); PyModule_AddObject(module, "GetSteerableViewMapDensityF1D", (PyObject *)&GetSteerableViewMapDensityF1D_Type); - if( PyType_Ready( &GetViewMapGradientNormF1D_Type ) < 0 ) + if (PyType_Ready(&GetViewMapGradientNormF1D_Type) < 0) return -1; - Py_INCREF( &GetViewMapGradientNormF1D_Type ); + Py_INCREF(&GetViewMapGradientNormF1D_Type); PyModule_AddObject(module, "GetViewMapGradientNormF1D", (PyObject *)&GetViewMapGradientNormF1D_Type); - if( PyType_Ready( &GetXF1D_Type ) < 0 ) + if (PyType_Ready(&GetXF1D_Type) < 0) return -1; - Py_INCREF( &GetXF1D_Type ); + Py_INCREF(&GetXF1D_Type); PyModule_AddObject(module, "GetXF1D", (PyObject *)&GetXF1D_Type); - if( PyType_Ready( &GetYF1D_Type ) < 0 ) + if (PyType_Ready(&GetYF1D_Type) < 0) return -1; - Py_INCREF( &GetYF1D_Type ); + Py_INCREF(&GetYF1D_Type); PyModule_AddObject(module, "GetYF1D", (PyObject *)&GetYF1D_Type); - if( PyType_Ready( &GetZF1D_Type ) < 0 ) + if (PyType_Ready(&GetZF1D_Type) < 0) return -1; - Py_INCREF( &GetZF1D_Type ); + Py_INCREF(&GetZF1D_Type); PyModule_AddObject(module, "GetZF1D", (PyObject *)&GetZF1D_Type); - if( PyType_Ready( &LocalAverageDepthF1D_Type ) < 0 ) + if (PyType_Ready(&LocalAverageDepthF1D_Type) < 0) return -1; - Py_INCREF( &LocalAverageDepthF1D_Type ); + Py_INCREF(&LocalAverageDepthF1D_Type); PyModule_AddObject(module, "LocalAverageDepthF1D", (PyObject *)&LocalAverageDepthF1D_Type); - if( PyType_Ready( &ZDiscontinuityF1D_Type ) < 0 ) + if (PyType_Ready(&ZDiscontinuityF1D_Type) < 0) return -1; - Py_INCREF( &ZDiscontinuityF1D_Type ); + Py_INCREF(&ZDiscontinuityF1D_Type); PyModule_AddObject(module, "ZDiscontinuityF1D", (PyObject *)&ZDiscontinuityF1D_Type); return 0; @@ -123,25 +123,26 @@ static char UnaryFunction1DDouble___doc__[] = "\n" " Default constructor.\n" "\n" -".. method:: __init__(integration)\n" +".. method:: __init__(integration_type)\n" "\n" " Builds a unary 1D function using the integration method given as\n" " argument.\n" "\n" -" :arg integration: An integration method.\n" -" :type integration: :class:`IntegrationType`\n"; +" :arg integration_type: An integration method.\n" +" :type integration_type: :class:`IntegrationType`\n"; -static int UnaryFunction1DDouble___init__(BPy_UnaryFunction1DDouble* self, PyObject *args) +static int UnaryFunction1DDouble___init__(BPy_UnaryFunction1DDouble* self, PyObject *args, PyObject *kwds) { + static const char *kwlist[] = {"integration", NULL}; PyObject *obj = 0; - if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) ) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O!", (char **)kwlist, &IntegrationType_Type, &obj)) return -1; - if( !obj ) + if (!obj) self->uf1D_double = new UnaryFunction1D(); else { - self->uf1D_double = new UnaryFunction1D( IntegrationType_from_BPy_IntegrationType(obj) ); + self->uf1D_double = new UnaryFunction1D(IntegrationType_from_BPy_IntegrationType(obj)); } self->uf1D_double->py_uf1D = (PyObject *)self; @@ -158,85 +159,60 @@ static void UnaryFunction1DDouble___dealloc__(BPy_UnaryFunction1DDouble* self) static PyObject * UnaryFunction1DDouble___repr__(BPy_UnaryFunction1DDouble* self) { - return PyUnicode_FromFormat("type: %s - address: %p", self->uf1D_double->getName().c_str(), self->uf1D_double ); -} - -static char UnaryFunction1DDouble_getName___doc__[] = -".. method:: getName()\n" -"\n" -" Returns the name of the unary 1D function.\n" -"\n" -" :return: The name of the unary 1D function.\n" -" :rtype: str\n"; - -static PyObject * UnaryFunction1DDouble_getName( BPy_UnaryFunction1DDouble *self ) -{ - return PyUnicode_FromString( self->uf1D_double->getName().c_str() ); + return PyUnicode_FromFormat("type: %s - address: %p", self->uf1D_double->getName().c_str(), self->uf1D_double); } -static PyObject * UnaryFunction1DDouble___call__( BPy_UnaryFunction1DDouble *self, PyObject *args, PyObject *kwds) +static PyObject * UnaryFunction1DDouble___call__(BPy_UnaryFunction1DDouble *self, PyObject *args, PyObject *kwds) { - PyObject *obj; + static const char *kwlist[] = {"inter", NULL}; + PyObject *obj = 0; - if( kwds != NULL ) { - PyErr_SetString(PyExc_TypeError, "keyword argument(s) not supported"); - return NULL; - } - if( !PyArg_ParseTuple(args, "O!", &Interface1D_Type, &obj) ) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &Interface1D_Type, &obj)) return NULL; - - if( typeid(*(self->uf1D_double)) == typeid(UnaryFunction1D) ) { + + if (typeid(*(self->uf1D_double)) == typeid(UnaryFunction1D)) { PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden"); return NULL; } - if (self->uf1D_double->operator()(*( ((BPy_Interface1D *) obj)->if1D )) < 0) { + if (self->uf1D_double->operator()(*(((BPy_Interface1D *) obj)->if1D)) < 0) { if (!PyErr_Occurred()) { - string msg(self->uf1D_double->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 PyFloat_FromDouble( self->uf1D_double->result ); - + return PyFloat_FromDouble(self->uf1D_double->result); } -static char UnaryFunction1DDouble_setIntegrationType___doc__[] = -".. method:: setIntegrationType(integration)\n" -"\n" -" Sets the integration method.\n" +static PyMethodDef BPy_UnaryFunction1DDouble_methods[] = { + {NULL, NULL, 0, NULL} +}; + +/*----------------------UnaryFunction1DDouble get/setters ----------------------------*/ + +PyDoc_STRVAR(integration_type_doc, +"The integration method.\n" "\n" -" :arg integration: An integration method.\n" -" :type integration: :class:`IntegrationType`\n"; +":type: :class:`IntegrationType`"); -static PyObject * UnaryFunction1DDouble_setIntegrationType(BPy_UnaryFunction1DDouble* self, PyObject *args) +static PyObject *integration_type_get(BPy_UnaryFunction1DDouble *self, void *UNUSED(closure)) { - PyObject *obj; - - if( !PyArg_ParseTuple(args, "O!", &IntegrationType_Type, &obj) ) - return NULL; - - self->uf1D_double->setIntegrationType( IntegrationType_from_BPy_IntegrationType(obj) ); - Py_RETURN_NONE; + return BPy_IntegrationType_from_IntegrationType(self->uf1D_double->getIntegrationType()); } -static char UnaryFunction1DDouble_getIntegrationType___doc__[] = -".. method:: getIntegrationType(integration)\n" -"\n" -" Returns the integration method.\n" -"\n" -" :return: The integration method.\n" -" :rtype: :class:`IntegrationType`\n"; - -static PyObject * UnaryFunction1DDouble_getIntegrationType(BPy_UnaryFunction1DDouble* self) { - return BPy_IntegrationType_from_IntegrationType( self->uf1D_double->getIntegrationType() ); +static int integration_type_set(BPy_UnaryFunction1DDouble *self, PyObject *value, void *UNUSED(closure)) +{ + if (!BPy_IntegrationType_Check(value)) { + PyErr_SetString(PyExc_TypeError, "value must be an IntegrationType"); + return -1; + } + self->uf1D_double->setIntegrationType(IntegrationType_from_BPy_IntegrationType(value)); + return 0; } -/*----------------------UnaryFunction1DDouble instance definitions ----------------------------*/ -static PyMethodDef BPy_UnaryFunction1DDouble_methods[] = { - {"getName", ( PyCFunction ) UnaryFunction1DDouble_getName, METH_NOARGS, UnaryFunction1DDouble_getName___doc__}, - {"setIntegrationType", ( PyCFunction ) UnaryFunction1DDouble_setIntegrationType, METH_VARARGS, UnaryFunction1DDouble_setIntegrationType___doc__}, - {"getIntegrationType", ( PyCFunction ) UnaryFunction1DDouble_getIntegrationType, METH_NOARGS, UnaryFunction1DDouble_getIntegrationType___doc__}, - {NULL, NULL, 0, NULL} +static PyGetSetDef BPy_UnaryFunction1DDouble_getseters[] = { + {(char *)"integration_type", (getter)integration_type_get, (setter)integration_type_set, (char *)integration_type_doc, NULL}, + {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ }; /*-----------------------BPy_UnaryFunction1DDouble type definition ------------------------------*/ @@ -271,7 +247,7 @@ PyTypeObject UnaryFunction1DDouble_Type = { 0, /* tp_iternext */ BPy_UnaryFunction1DDouble_methods, /* tp_methods */ 0, /* tp_members */ - 0, /* tp_getset */ + BPy_UnaryFunction1DDouble_getseters, /* tp_getset */ &UnaryFunction1D_Type, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DEdgeNature.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DEdgeNature.cpp index 4f6a672857a..5a7c7aebe18 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DEdgeNature.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DEdgeNature.cpp @@ -14,19 +14,19 @@ extern "C" { //-------------------MODULE INITIALIZATION-------------------------------- -int UnaryFunction1DEdgeNature_Init( PyObject *module ) { - - if( module == NULL ) +int UnaryFunction1DEdgeNature_Init(PyObject *module) +{ + if (module == NULL) return -1; - if( PyType_Ready( &UnaryFunction1DEdgeNature_Type ) < 0 ) + if (PyType_Ready(&UnaryFunction1DEdgeNature_Type) < 0) return -1; - Py_INCREF( &UnaryFunction1DEdgeNature_Type ); + Py_INCREF(&UnaryFunction1DEdgeNature_Type); PyModule_AddObject(module, "UnaryFunction1DEdgeNature", (PyObject *)&UnaryFunction1DEdgeNature_Type); - if( PyType_Ready( &CurveNatureF1D_Type ) < 0 ) + if (PyType_Ready(&CurveNatureF1D_Type) < 0) return -1; - Py_INCREF( &CurveNatureF1D_Type ); + Py_INCREF(&CurveNatureF1D_Type); PyModule_AddObject(module, "CurveNatureF1D", (PyObject *)&CurveNatureF1D_Type); return 0; @@ -44,25 +44,26 @@ static char UnaryFunction1DEdgeNature___doc__[] = "\n" " Default constructor.\n" "\n" -".. method:: __init__(integration)\n" +".. method:: __init__(integration_type)\n" "\n" " Builds a unary 1D function using the integration method given as\n" " argument.\n" "\n" -" :arg integration: An integration method.\n" -" :type integration: :class:`IntegrationType`\n"; +" :arg integration_type: An integration method.\n" +" :type integration_type: :class:`IntegrationType`\n"; -static int UnaryFunction1DEdgeNature___init__(BPy_UnaryFunction1DEdgeNature* self, PyObject *args) +static int UnaryFunction1DEdgeNature___init__(BPy_UnaryFunction1DEdgeNature* self, PyObject *args, PyObject *kwds) { + static const char *kwlist[] = {"integration", NULL}; PyObject *obj = 0; - if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) ) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O!", (char **)kwlist, &IntegrationType_Type, &obj)) return -1; - if( !obj ) + if (!obj) self->uf1D_edgenature = new UnaryFunction1D(); else { - self->uf1D_edgenature = new UnaryFunction1D( IntegrationType_from_BPy_IntegrationType(obj) ); + self->uf1D_edgenature = new UnaryFunction1D(IntegrationType_from_BPy_IntegrationType(obj)); } self->uf1D_edgenature->py_uf1D = (PyObject *)self; @@ -79,85 +80,61 @@ static void UnaryFunction1DEdgeNature___dealloc__(BPy_UnaryFunction1DEdgeNature* static PyObject * UnaryFunction1DEdgeNature___repr__(BPy_UnaryFunction1DEdgeNature* self) { - return PyUnicode_FromFormat("type: %s - address: %p", self->uf1D_edgenature->getName().c_str(), self->uf1D_edgenature ); -} - -static char UnaryFunction1DEdgeNature_getName___doc__[] = -".. method:: getName()\n" -"\n" -" Returns the name of the unary 1D function.\n" -"\n" -" :return: The name of the unary 1D function.\n" -" :rtype: str\n"; - -static PyObject * UnaryFunction1DEdgeNature_getName( BPy_UnaryFunction1DEdgeNature *self ) -{ - return PyUnicode_FromString( self->uf1D_edgenature->getName().c_str() ); + return PyUnicode_FromFormat("type: %s - address: %p", self->uf1D_edgenature->getName().c_str(), self->uf1D_edgenature); } -static PyObject * UnaryFunction1DEdgeNature___call__( BPy_UnaryFunction1DEdgeNature *self, PyObject *args, PyObject *kwds) +static PyObject * UnaryFunction1DEdgeNature___call__(BPy_UnaryFunction1DEdgeNature *self, PyObject *args, PyObject *kwds) { - PyObject *obj; + static const char *kwlist[] = {"inter", NULL}; + PyObject *obj = 0; - if( kwds != NULL ) { - PyErr_SetString(PyExc_TypeError, "keyword argument(s) not supported"); - return NULL; - } - if( !PyArg_ParseTuple(args, "O!", &Interface1D_Type, &obj) ) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &Interface1D_Type, &obj)) return NULL; - - if( typeid(*(self->uf1D_edgenature)) == typeid(UnaryFunction1D) ) { + + if (typeid(*(self->uf1D_edgenature)) == typeid(UnaryFunction1D)) { PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden"); return NULL; } - if (self->uf1D_edgenature->operator()(*( ((BPy_Interface1D *) obj)->if1D )) < 0) { + if (self->uf1D_edgenature->operator()(*(((BPy_Interface1D *) obj)->if1D)) < 0) { if (!PyErr_Occurred()) { - string msg(self->uf1D_edgenature->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 BPy_Nature_from_Nature( self->uf1D_edgenature->result ); + return BPy_Nature_from_Nature(self->uf1D_edgenature->result); } -static char UnaryFunction1DEdgeNature_setIntegrationType___doc__[] = -".. method:: setIntegrationType(integration)\n" -"\n" -" Sets the integration method.\n" +static PyMethodDef BPy_UnaryFunction1DEdgeNature_methods[] = { + {NULL, NULL, 0, NULL} +}; + +/*----------------------UnaryFunction1DEdgeNature get/setters ----------------------------*/ + +PyDoc_STRVAR(integration_type_doc, +"The integration method.\n" "\n" -" :arg integration: An integration method.\n" -" :type integration: :class:`IntegrationType`\n"; +":type: :class:`IntegrationType`"); -static PyObject * UnaryFunction1DEdgeNature_setIntegrationType(BPy_UnaryFunction1DEdgeNature* self, PyObject *args) +static PyObject *integration_type_get(BPy_UnaryFunction1DEdgeNature *self, void *UNUSED(closure)) { - PyObject *obj; - - if( !PyArg_ParseTuple(args, "O!", &IntegrationType_Type, &obj) ) - return NULL; - - self->uf1D_edgenature->setIntegrationType( IntegrationType_from_BPy_IntegrationType(obj) ); - Py_RETURN_NONE; + return BPy_IntegrationType_from_IntegrationType(self->uf1D_edgenature->getIntegrationType()); } -static char UnaryFunction1DEdgeNature_getIntegrationType___doc__[] = -".. method:: getIntegrationType(integration)\n" -"\n" -" Returns the integration method.\n" -"\n" -" :return: The integration method.\n" -" :rtype: :class:`IntegrationType`\n"; - -static PyObject * UnaryFunction1DEdgeNature_getIntegrationType(BPy_UnaryFunction1DEdgeNature* self) { - return BPy_IntegrationType_from_IntegrationType( self->uf1D_edgenature->getIntegrationType() ); +static int integration_type_set(BPy_UnaryFunction1DEdgeNature *self, PyObject *value, void *UNUSED(closure)) +{ + if (!BPy_IntegrationType_Check(value)) { + PyErr_SetString(PyExc_TypeError, "value must be an IntegrationType"); + return -1; + } + self->uf1D_edgenature->setIntegrationType(IntegrationType_from_BPy_IntegrationType(value)); + return 0; } -/*----------------------UnaryFunction1DEdgeNature instance definitions ----------------------------*/ -static PyMethodDef BPy_UnaryFunction1DEdgeNature_methods[] = { - {"getName", ( PyCFunction ) UnaryFunction1DEdgeNature_getName, METH_NOARGS, UnaryFunction1DEdgeNature_getName___doc__}, - {"setIntegrationType", ( PyCFunction ) UnaryFunction1DEdgeNature_setIntegrationType, METH_VARARGS, UnaryFunction1DEdgeNature_setIntegrationType___doc__}, - {"getIntegrationType", ( PyCFunction ) UnaryFunction1DEdgeNature_getIntegrationType, METH_NOARGS, UnaryFunction1DEdgeNature_getIntegrationType___doc__}, - {NULL, NULL, 0, NULL} +static PyGetSetDef BPy_UnaryFunction1DEdgeNature_getseters[] = { + {(char *)"integration_type", (getter)integration_type_get, (setter)integration_type_set, (char *)integration_type_doc, NULL}, + {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ }; /*-----------------------BPy_UnaryFunction1DEdgeNature type definition ------------------------------*/ @@ -192,7 +169,7 @@ PyTypeObject UnaryFunction1DEdgeNature_Type = { 0, /* tp_iternext */ BPy_UnaryFunction1DEdgeNature_methods, /* tp_methods */ 0, /* tp_members */ - 0, /* tp_getset */ + BPy_UnaryFunction1DEdgeNature_getseters, /* tp_getset */ &UnaryFunction1D_Type, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DFloat.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DFloat.cpp index 9f16ed9ce36..1898212337a 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DFloat.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DFloat.cpp @@ -12,14 +12,14 @@ extern "C" { //-------------------MODULE INITIALIZATION-------------------------------- -int UnaryFunction1DFloat_Init( PyObject *module ) { - - if( module == NULL ) +int UnaryFunction1DFloat_Init(PyObject *module) +{ + if (module == NULL) return -1; - if( PyType_Ready( &UnaryFunction1DFloat_Type ) < 0 ) + if (PyType_Ready(&UnaryFunction1DFloat_Type) < 0) return -1; - Py_INCREF( &UnaryFunction1DFloat_Type ); + Py_INCREF(&UnaryFunction1DFloat_Type); PyModule_AddObject(module, "UnaryFunction1DFloat", (PyObject *)&UnaryFunction1DFloat_Type); return 0; @@ -37,25 +37,26 @@ static char UnaryFunction1DFloat___doc__[] = "\n" " Default constructor.\n" "\n" -".. method:: __init__(integration)\n" +".. method:: __init__(integration_type)\n" "\n" " Builds a unary 1D function using the integration method given as\n" " argument.\n" "\n" -" :arg integration: An integration method.\n" -" :type integration: :class:`IntegrationType`\n"; +" :arg integration_type: An integration method.\n" +" :type integration_type: :class:`IntegrationType`\n"; -static int UnaryFunction1DFloat___init__(BPy_UnaryFunction1DFloat* self, PyObject *args) +static int UnaryFunction1DFloat___init__(BPy_UnaryFunction1DFloat* self, PyObject *args, PyObject *kwds) { + static const char *kwlist[] = {"integration", NULL}; PyObject *obj = 0; - if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) ) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O!", (char **)kwlist, &IntegrationType_Type, &obj)) return -1; - if( !obj ) + if (!obj) self->uf1D_float = new UnaryFunction1D(); else { - self->uf1D_float = new UnaryFunction1D( IntegrationType_from_BPy_IntegrationType(obj) ); + self->uf1D_float = new UnaryFunction1D(IntegrationType_from_BPy_IntegrationType(obj)); } self->uf1D_float->py_uf1D = (PyObject *)self; @@ -72,85 +73,61 @@ static void UnaryFunction1DFloat___dealloc__(BPy_UnaryFunction1DFloat* self) static PyObject * UnaryFunction1DFloat___repr__(BPy_UnaryFunction1DFloat* self) { - return PyUnicode_FromFormat("type: %s - address: %p", self->uf1D_float->getName().c_str(), self->uf1D_float ); -} - -static char UnaryFunction1DFloat_getName___doc__[] = -".. method:: getName()\n" -"\n" -" Returns the name of the unary 1D function.\n" -"\n" -" :return: The name of the unary 1D function.\n" -" :rtype: str\n"; - -static PyObject * UnaryFunction1DFloat_getName( BPy_UnaryFunction1DFloat *self ) -{ - return PyUnicode_FromString( self->uf1D_float->getName().c_str() ); + return PyUnicode_FromFormat("type: %s - address: %p", self->uf1D_float->getName().c_str(), self->uf1D_float); } -static PyObject * UnaryFunction1DFloat___call__( BPy_UnaryFunction1DFloat *self, PyObject *args, PyObject *kwds) +static PyObject * UnaryFunction1DFloat___call__(BPy_UnaryFunction1DFloat *self, PyObject *args, PyObject *kwds) { - PyObject *obj; + static const char *kwlist[] = {"inter", NULL}; + PyObject *obj = 0; - if( kwds != NULL ) { - PyErr_SetString(PyExc_TypeError, "keyword argument(s) not supported"); - return NULL; - } - if( !PyArg_ParseTuple(args, "O!", &Interface1D_Type, &obj) ) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &Interface1D_Type, &obj)) return NULL; - - if( typeid(*(self->uf1D_float)) == typeid(UnaryFunction1D) ) { + + if (typeid(*(self->uf1D_float)) == typeid(UnaryFunction1D)) { PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden"); return NULL; } - if (self->uf1D_float->operator()(*( ((BPy_Interface1D *) obj)->if1D )) < 0) { + if (self->uf1D_float->operator()(*(((BPy_Interface1D *) obj)->if1D)) < 0) { if (!PyErr_Occurred()) { - string msg(self->uf1D_float->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 PyFloat_FromDouble( self->uf1D_float->result ); + return PyFloat_FromDouble(self->uf1D_float->result); } -static char UnaryFunction1DFloat_setIntegrationType___doc__[] = -".. method:: setIntegrationType(integration)\n" -"\n" -" Sets the integration method.\n" +static PyMethodDef BPy_UnaryFunction1DFloat_methods[] = { + {NULL, NULL, 0, NULL} +}; + +/*----------------------UnaryFunction1DFloat get/setters ----------------------------*/ + +PyDoc_STRVAR(integration_type_doc, +"The integration method.\n" "\n" -" :arg integration: An integration method.\n" -" :type integration: :class:`IntegrationType`\n"; +":type: :class:`IntegrationType`"); -static PyObject * UnaryFunction1DFloat_setIntegrationType(BPy_UnaryFunction1DFloat* self, PyObject *args) +static PyObject *integration_type_get(BPy_UnaryFunction1DFloat *self, void *UNUSED(closure)) { - PyObject *obj; - - if( !PyArg_ParseTuple(args, "O!", &IntegrationType_Type, &obj) ) - return NULL; - - self->uf1D_float->setIntegrationType( IntegrationType_from_BPy_IntegrationType(obj) ); - Py_RETURN_NONE; + return BPy_IntegrationType_from_IntegrationType(self->uf1D_float->getIntegrationType()); } -static char UnaryFunction1DFloat_getIntegrationType___doc__[] = -".. method:: getIntegrationType(integration)\n" -"\n" -" Returns the integration method.\n" -"\n" -" :return: The integration method.\n" -" :rtype: :class:`IntegrationType`\n"; - -static PyObject * UnaryFunction1DFloat_getIntegrationType(BPy_UnaryFunction1DFloat* self) { - return BPy_IntegrationType_from_IntegrationType( self->uf1D_float->getIntegrationType() ); +static int integration_type_set(BPy_UnaryFunction1DFloat *self, PyObject *value, void *UNUSED(closure)) +{ + if (!BPy_IntegrationType_Check(value)) { + PyErr_SetString(PyExc_TypeError, "value must be an IntegrationType"); + return -1; + } + self->uf1D_float->setIntegrationType(IntegrationType_from_BPy_IntegrationType(value)); + return 0; } -/*----------------------UnaryFunction1DFloat instance definitions ----------------------------*/ -static PyMethodDef BPy_UnaryFunction1DFloat_methods[] = { - {"getName", ( PyCFunction ) UnaryFunction1DFloat_getName, METH_NOARGS, UnaryFunction1DFloat_getName___doc__}, - {"setIntegrationType", ( PyCFunction ) UnaryFunction1DFloat_setIntegrationType, METH_VARARGS, UnaryFunction1DFloat_setIntegrationType___doc__}, - {"getIntegrationType", ( PyCFunction ) UnaryFunction1DFloat_getIntegrationType, METH_NOARGS, UnaryFunction1DFloat_getIntegrationType___doc__}, - {NULL, NULL, 0, NULL} +static PyGetSetDef BPy_UnaryFunction1DFloat_getseters[] = { + {(char *)"integration_type", (getter)integration_type_get, (setter)integration_type_set, (char *)integration_type_doc, NULL}, + {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ }; /*-----------------------BPy_UnaryFunction1DFloat type definition ------------------------------*/ @@ -185,7 +162,7 @@ PyTypeObject UnaryFunction1DFloat_Type = { 0, /* tp_iternext */ BPy_UnaryFunction1DFloat_methods, /* tp_methods */ 0, /* tp_members */ - 0, /* tp_getset */ + BPy_UnaryFunction1DFloat_getseters, /* tp_getset */ &UnaryFunction1D_Type, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DUnsigned.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DUnsigned.cpp index 98615728c63..fc6c792b4b1 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DUnsigned.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DUnsigned.cpp @@ -14,19 +14,19 @@ extern "C" { //-------------------MODULE INITIALIZATION-------------------------------- -int UnaryFunction1DUnsigned_Init( PyObject *module ) { - - if( module == NULL ) +int UnaryFunction1DUnsigned_Init(PyObject *module) +{ + if (module == NULL) return -1; - if( PyType_Ready( &UnaryFunction1DUnsigned_Type ) < 0 ) + if (PyType_Ready(&UnaryFunction1DUnsigned_Type) < 0) return -1; - Py_INCREF( &UnaryFunction1DUnsigned_Type ); + Py_INCREF(&UnaryFunction1DUnsigned_Type); PyModule_AddObject(module, "UnaryFunction1DUnsigned", (PyObject *)&UnaryFunction1DUnsigned_Type); - if( PyType_Ready( &QuantitativeInvisibilityF1D_Type ) < 0 ) + if (PyType_Ready(&QuantitativeInvisibilityF1D_Type) < 0) return -1; - Py_INCREF( &QuantitativeInvisibilityF1D_Type ); + Py_INCREF(&QuantitativeInvisibilityF1D_Type); PyModule_AddObject(module, "QuantitativeInvisibilityF1D", (PyObject *)&QuantitativeInvisibilityF1D_Type); return 0; @@ -44,25 +44,26 @@ static char UnaryFunction1DUnsigned___doc__[] = "\n" " Default constructor.\n" "\n" -".. method:: __init__(integration)\n" +".. method:: __init__(integration_type)\n" "\n" " Builds a unary 1D function using the integration method given as\n" " argument.\n" "\n" -" :arg integration: An integration method.\n" -" :type integration: :class:`IntegrationType`\n"; +" :arg integration_type: An integration method.\n" +" :type integration_type: :class:`IntegrationType`\n"; -static int UnaryFunction1DUnsigned___init__(BPy_UnaryFunction1DUnsigned* self, PyObject *args) +static int UnaryFunction1DUnsigned___init__(BPy_UnaryFunction1DUnsigned* self, PyObject *args, PyObject *kwds) { + static const char *kwlist[] = {"integration", NULL}; PyObject *obj = 0; - if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) ) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O!", (char **)kwlist, &IntegrationType_Type, &obj)) return -1; - if( !obj ) + if (!obj) self->uf1D_unsigned = new UnaryFunction1D(); else { - self->uf1D_unsigned = new UnaryFunction1D( IntegrationType_from_BPy_IntegrationType(obj) ); + self->uf1D_unsigned = new UnaryFunction1D(IntegrationType_from_BPy_IntegrationType(obj)); } self->uf1D_unsigned->py_uf1D = (PyObject *)self; @@ -79,85 +80,61 @@ static void UnaryFunction1DUnsigned___dealloc__(BPy_UnaryFunction1DUnsigned* sel static PyObject * UnaryFunction1DUnsigned___repr__(BPy_UnaryFunction1DUnsigned* self) { - return PyUnicode_FromFormat("type: %s - address: %p", self->uf1D_unsigned->getName().c_str(), self->uf1D_unsigned ); -} - -static char UnaryFunction1DUnsigned_getName___doc__[] = -".. method:: getName()\n" -"\n" -" Returns the name of the unary 1D function.\n" -"\n" -" :return: The name of the unary 1D function.\n" -" :rtype: str\n"; - -static PyObject * UnaryFunction1DUnsigned_getName( BPy_UnaryFunction1DUnsigned *self ) -{ - return PyUnicode_FromString( self->uf1D_unsigned->getName().c_str() ); + return PyUnicode_FromFormat("type: %s - address: %p", self->uf1D_unsigned->getName().c_str(), self->uf1D_unsigned); } -static PyObject * UnaryFunction1DUnsigned___call__( BPy_UnaryFunction1DUnsigned *self, PyObject *args, PyObject *kwds) +static PyObject * UnaryFunction1DUnsigned___call__(BPy_UnaryFunction1DUnsigned *self, PyObject *args, PyObject *kwds) { - PyObject *obj; + static const char *kwlist[] = {"inter", NULL}; + PyObject *obj = 0; - if( kwds != NULL ) { - PyErr_SetString(PyExc_TypeError, "keyword argument(s) not supported"); - return NULL; - } - if( !PyArg_ParseTuple(args, "O!", &Interface1D_Type, &obj) ) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &Interface1D_Type, &obj)) return NULL; - - if( typeid(*(self->uf1D_unsigned)) == typeid(UnaryFunction1D) ) { + + if (typeid(*(self->uf1D_unsigned)) == typeid(UnaryFunction1D)) { PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden"); return NULL; } - if (self->uf1D_unsigned->operator()(*( ((BPy_Interface1D *) obj)->if1D )) < 0) { + if (self->uf1D_unsigned->operator()(*(((BPy_Interface1D *) obj)->if1D)) < 0) { if (!PyErr_Occurred()) { - string msg(self->uf1D_unsigned->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 PyLong_FromLong( self->uf1D_unsigned->result ); + return PyLong_FromLong(self->uf1D_unsigned->result); } -static char UnaryFunction1DUnsigned_setIntegrationType___doc__[] = -".. method:: setIntegrationType(integration)\n" -"\n" -" Sets the integration method.\n" +static PyMethodDef BPy_UnaryFunction1DUnsigned_methods[] = { + {NULL, NULL, 0, NULL} +}; + +/*----------------------UnaryFunction1DUnsigned get/setters ----------------------------*/ + +PyDoc_STRVAR(integration_type_doc, +"The integration method.\n" "\n" -" :arg integration: An integration method.\n" -" :type integration: :class:`IntegrationType`\n"; +":type: :class:`IntegrationType`"); -static PyObject * UnaryFunction1DUnsigned_setIntegrationType(BPy_UnaryFunction1DUnsigned* self, PyObject *args) +static PyObject *integration_type_get(BPy_UnaryFunction1DUnsigned *self, void *UNUSED(closure)) { - PyObject *obj; - - if( !PyArg_ParseTuple(args, "O!", &IntegrationType_Type, &obj) ) - return NULL; - - self->uf1D_unsigned->setIntegrationType( IntegrationType_from_BPy_IntegrationType(obj) ); - Py_RETURN_NONE; + return BPy_IntegrationType_from_IntegrationType(self->uf1D_unsigned->getIntegrationType()); } -static char UnaryFunction1DUnsigned_getIntegrationType___doc__[] = -".. method:: getIntegrationType(integration)\n" -"\n" -" Returns the integration method.\n" -"\n" -" :return: The integration method.\n" -" :rtype: :class:`IntegrationType`\n"; - -static PyObject * UnaryFunction1DUnsigned_getIntegrationType(BPy_UnaryFunction1DUnsigned* self) { - return BPy_IntegrationType_from_IntegrationType( self->uf1D_unsigned->getIntegrationType() ); +static int integration_type_set(BPy_UnaryFunction1DUnsigned *self, PyObject *value, void *UNUSED(closure)) +{ + if (!BPy_IntegrationType_Check(value)) { + PyErr_SetString(PyExc_TypeError, "value must be an IntegrationType"); + return -1; + } + self->uf1D_unsigned->setIntegrationType(IntegrationType_from_BPy_IntegrationType(value)); + return 0; } -/*----------------------UnaryFunction1DUnsigned instance definitions ----------------------------*/ -static PyMethodDef BPy_UnaryFunction1DUnsigned_methods[] = { - {"getName", ( PyCFunction ) UnaryFunction1DUnsigned_getName, METH_NOARGS, UnaryFunction1DUnsigned_getName___doc__}, - {"setIntegrationType", ( PyCFunction ) UnaryFunction1DUnsigned_setIntegrationType, METH_VARARGS, UnaryFunction1DUnsigned_setIntegrationType___doc__}, - {"getIntegrationType", ( PyCFunction ) UnaryFunction1DUnsigned_getIntegrationType, METH_NOARGS, UnaryFunction1DUnsigned_getIntegrationType___doc__}, - {NULL, NULL, 0, NULL} +static PyGetSetDef BPy_UnaryFunction1DUnsigned_getseters[] = { + {(char *)"integration_type", (getter)integration_type_get, (setter)integration_type_set, (char *)integration_type_doc, NULL}, + {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ }; /*-----------------------BPy_UnaryFunction1DUnsigned type definition ------------------------------*/ @@ -192,7 +169,7 @@ PyTypeObject UnaryFunction1DUnsigned_Type = { 0, /* tp_iternext */ BPy_UnaryFunction1DUnsigned_methods, /* tp_methods */ 0, /* tp_members */ - 0, /* tp_getset */ + BPy_UnaryFunction1DUnsigned_getseters, /* tp_getset */ &UnaryFunction1D_Type, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec2f.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec2f.cpp index 9f2c52c6f44..d67c960db8e 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec2f.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec2f.cpp @@ -15,24 +15,24 @@ extern "C" { //-------------------MODULE INITIALIZATION-------------------------------- -int UnaryFunction1DVec2f_Init( PyObject *module ) { - - if( module == NULL ) +int UnaryFunction1DVec2f_Init(PyObject *module) +{ + if (module == NULL) return -1; - if( PyType_Ready( &UnaryFunction1DVec2f_Type ) < 0 ) + if (PyType_Ready(&UnaryFunction1DVec2f_Type) < 0) return -1; - Py_INCREF( &UnaryFunction1DVec2f_Type ); + Py_INCREF(&UnaryFunction1DVec2f_Type); PyModule_AddObject(module, "UnaryFunction1DVec2f", (PyObject *)&UnaryFunction1DVec2f_Type); - if( PyType_Ready( &Normal2DF1D_Type ) < 0 ) + if (PyType_Ready(&Normal2DF1D_Type) < 0) return -1; - Py_INCREF( &Normal2DF1D_Type ); + Py_INCREF(&Normal2DF1D_Type); PyModule_AddObject(module, "Normal2DF1D", (PyObject *)&Normal2DF1D_Type); - if( PyType_Ready( &Orientation2DF1D_Type ) < 0 ) + if (PyType_Ready(&Orientation2DF1D_Type) < 0) return -1; - Py_INCREF( &Orientation2DF1D_Type ); + Py_INCREF(&Orientation2DF1D_Type); PyModule_AddObject(module, "Orientation2DF1D", (PyObject *)&Orientation2DF1D_Type); return 0; @@ -50,25 +50,26 @@ static char UnaryFunction1DVec2f___doc__[] = "\n" " Default constructor.\n" "\n" -".. method:: __init__(integration)\n" +".. method:: __init__(integration_type)\n" "\n" " Builds a unary 1D function using the integration method given as\n" " argument.\n" "\n" -" :arg integration: An integration method.\n" -" :type integration: :class:`IntegrationType`\n"; +" :arg integration_type: An integration method.\n" +" :type integration_type: :class:`IntegrationType`\n"; -static int UnaryFunction1DVec2f___init__(BPy_UnaryFunction1DVec2f* self, PyObject *args) +static int UnaryFunction1DVec2f___init__(BPy_UnaryFunction1DVec2f* self, PyObject *args, PyObject *kwds) { + static const char *kwlist[] = {"integration", NULL}; PyObject *obj = 0; - if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) ) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O!", (char **)kwlist, &IntegrationType_Type, &obj)) return -1; - if( !obj ) + if (!obj) self->uf1D_vec2f = new UnaryFunction1D(); else { - self->uf1D_vec2f = new UnaryFunction1D( IntegrationType_from_BPy_IntegrationType(obj) ); + self->uf1D_vec2f = new UnaryFunction1D(IntegrationType_from_BPy_IntegrationType(obj)); } self->uf1D_vec2f->py_uf1D = (PyObject *)self; @@ -85,85 +86,61 @@ static void UnaryFunction1DVec2f___dealloc__(BPy_UnaryFunction1DVec2f* self) static PyObject * UnaryFunction1DVec2f___repr__(BPy_UnaryFunction1DVec2f* self) { - return PyUnicode_FromFormat("type: %s - address: %p", self->uf1D_vec2f->getName().c_str(), self->uf1D_vec2f ); -} - -static char UnaryFunction1DVec2f_getName___doc__[] = -".. method:: getName()\n" -"\n" -" Returns the name of the unary 1D function.\n" -"\n" -" :return: The name of the unary 1D function.\n" -" :rtype: str\n"; - -static PyObject * UnaryFunction1DVec2f_getName( BPy_UnaryFunction1DVec2f *self ) -{ - return PyUnicode_FromString( self->uf1D_vec2f->getName().c_str() ); + return PyUnicode_FromFormat("type: %s - address: %p", self->uf1D_vec2f->getName().c_str(), self->uf1D_vec2f); } -static PyObject * UnaryFunction1DVec2f___call__( BPy_UnaryFunction1DVec2f *self, PyObject *args, PyObject *kwds) +static PyObject * UnaryFunction1DVec2f___call__(BPy_UnaryFunction1DVec2f *self, PyObject *args, PyObject *kwds) { - PyObject *obj; + static const char *kwlist[] = {"inter", NULL}; + PyObject *obj = 0; - if( kwds != NULL ) { - PyErr_SetString(PyExc_TypeError, "keyword argument(s) not supported"); - return NULL; - } - if( !PyArg_ParseTuple(args, "O!", &Interface1D_Type, &obj) ) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &Interface1D_Type, &obj)) return NULL; - - if( typeid(*(self->uf1D_vec2f)) == typeid(UnaryFunction1D) ) { + + if (typeid(*(self->uf1D_vec2f)) == typeid(UnaryFunction1D)) { PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden"); return NULL; } - if (self->uf1D_vec2f->operator()(*( ((BPy_Interface1D *) obj)->if1D )) < 0) { + if (self->uf1D_vec2f->operator()(*(((BPy_Interface1D *) obj)->if1D)) < 0) { if (!PyErr_Occurred()) { - string msg(self->uf1D_vec2f->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 Vector_from_Vec2f( self->uf1D_vec2f->result ); + return Vector_from_Vec2f(self->uf1D_vec2f->result); } -static char UnaryFunction1DVec2f_setIntegrationType___doc__[] = -".. method:: setIntegrationType(integration)\n" -"\n" -" Sets the integration method.\n" +static PyMethodDef BPy_UnaryFunction1DVec2f_methods[] = { + {NULL, NULL, 0, NULL} +}; + +/*----------------------UnaryFunction1DVec2f get/setters ----------------------------*/ + +PyDoc_STRVAR(integration_type_doc, +"The integration method.\n" "\n" -" :arg integration: An integration method.\n" -" :type integration: :class:`IntegrationType`\n"; +":type: :class:`IntegrationType`"); -static PyObject * UnaryFunction1DVec2f_setIntegrationType(BPy_UnaryFunction1DVec2f* self, PyObject *args) +static PyObject *integration_type_get(BPy_UnaryFunction1DVec2f *self, void *UNUSED(closure)) { - PyObject *obj; - - if( !PyArg_ParseTuple(args, "O!", &IntegrationType_Type, &obj) ) - return NULL; - - self->uf1D_vec2f->setIntegrationType( IntegrationType_from_BPy_IntegrationType(obj) ); - Py_RETURN_NONE; + return BPy_IntegrationType_from_IntegrationType(self->uf1D_vec2f->getIntegrationType()); } -static char UnaryFunction1DVec2f_getIntegrationType___doc__[] = -".. method:: getIntegrationType(integration)\n" -"\n" -" Returns the integration method.\n" -"\n" -" :return: The integration method.\n" -" :rtype: :class:`IntegrationType`\n"; - -static PyObject * UnaryFunction1DVec2f_getIntegrationType(BPy_UnaryFunction1DVec2f* self) { - return BPy_IntegrationType_from_IntegrationType( self->uf1D_vec2f->getIntegrationType() ); +static int integration_type_set(BPy_UnaryFunction1DVec2f *self, PyObject *value, void *UNUSED(closure)) +{ + if (!BPy_IntegrationType_Check(value)) { + PyErr_SetString(PyExc_TypeError, "value must be an IntegrationType"); + return -1; + } + self->uf1D_vec2f->setIntegrationType(IntegrationType_from_BPy_IntegrationType(value)); + return 0; } -/*----------------------UnaryFunction1DVec2f instance definitions ----------------------------*/ -static PyMethodDef BPy_UnaryFunction1DVec2f_methods[] = { - {"getName", ( PyCFunction ) UnaryFunction1DVec2f_getName, METH_NOARGS, UnaryFunction1DVec2f_getName___doc__}, - {"setIntegrationType", ( PyCFunction ) UnaryFunction1DVec2f_setIntegrationType, METH_VARARGS, UnaryFunction1DVec2f_setIntegrationType___doc__}, - {"getIntegrationType", ( PyCFunction ) UnaryFunction1DVec2f_getIntegrationType, METH_NOARGS, UnaryFunction1DVec2f_getIntegrationType___doc__}, - {NULL, NULL, 0, NULL} +static PyGetSetDef BPy_UnaryFunction1DVec2f_getseters[] = { + {(char *)"integration_type", (getter)integration_type_get, (setter)integration_type_set, (char *)integration_type_doc, NULL}, + {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ }; /*-----------------------BPy_UnaryFunction1DVec2f type definition ------------------------------*/ @@ -198,7 +175,7 @@ PyTypeObject UnaryFunction1DVec2f_Type = { 0, /* tp_iternext */ BPy_UnaryFunction1DVec2f_methods, /* tp_methods */ 0, /* tp_members */ - 0, /* tp_getset */ + BPy_UnaryFunction1DVec2f_getseters, /* tp_getset */ &UnaryFunction1D_Type, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec3f.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec3f.cpp index 6d50a1ed437..fde04cc128c 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec3f.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec3f.cpp @@ -14,19 +14,19 @@ extern "C" { //-------------------MODULE INITIALIZATION-------------------------------- -int UnaryFunction1DVec3f_Init( PyObject *module ) { - - if( module == NULL ) +int UnaryFunction1DVec3f_Init(PyObject *module) +{ + if (module == NULL) return -1; - if( PyType_Ready( &UnaryFunction1DVec3f_Type ) < 0 ) + if (PyType_Ready(&UnaryFunction1DVec3f_Type) < 0) return -1; - Py_INCREF( &UnaryFunction1DVec3f_Type ); + Py_INCREF(&UnaryFunction1DVec3f_Type); PyModule_AddObject(module, "UnaryFunction1DVec3f", (PyObject *)&UnaryFunction1DVec3f_Type); - if( PyType_Ready( &Orientation3DF1D_Type ) < 0 ) + if (PyType_Ready(&Orientation3DF1D_Type) < 0) return -1; - Py_INCREF( &Orientation3DF1D_Type ); + Py_INCREF(&Orientation3DF1D_Type); PyModule_AddObject(module, "Orientation3DF1D", (PyObject *)&Orientation3DF1D_Type); return 0; @@ -44,25 +44,26 @@ static char UnaryFunction1DVec3f___doc__[] = "\n" " Default constructor.\n" "\n" -".. method:: __init__(integration)\n" +".. method:: __init__(integration_type)\n" "\n" " Builds a unary 1D function using the integration method given as\n" " argument.\n" "\n" -" :arg integration: An integration method.\n" -" :type integration: :class:`IntegrationType`\n"; +" :arg integration_type: An integration method.\n" +" :type integration_type: :class:`IntegrationType`\n"; -static int UnaryFunction1DVec3f___init__(BPy_UnaryFunction1DVec3f* self, PyObject *args) +static int UnaryFunction1DVec3f___init__(BPy_UnaryFunction1DVec3f* self, PyObject *args, PyObject *kwds) { + static const char *kwlist[] = {"integration", NULL}; PyObject *obj = 0; - if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) ) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O!", (char **)kwlist, &IntegrationType_Type, &obj)) return -1; - if( !obj ) + if (!obj) self->uf1D_vec3f = new UnaryFunction1D(); else { - self->uf1D_vec3f = new UnaryFunction1D( IntegrationType_from_BPy_IntegrationType(obj) ); + self->uf1D_vec3f = new UnaryFunction1D(IntegrationType_from_BPy_IntegrationType(obj)); } self->uf1D_vec3f->py_uf1D = (PyObject *)self; @@ -79,85 +80,61 @@ static void UnaryFunction1DVec3f___dealloc__(BPy_UnaryFunction1DVec3f* self) static PyObject * UnaryFunction1DVec3f___repr__(BPy_UnaryFunction1DVec3f* self) { - return PyUnicode_FromFormat("type: %s - address: %p", self->uf1D_vec3f->getName().c_str(), self->uf1D_vec3f ); -} - -static char UnaryFunction1DVec3f_getName___doc__[] = -".. method:: getName()\n" -"\n" -" Returns the name of the unary 1D function.\n" -"\n" -" :return: The name of the unary 1D function.\n" -" :rtype: str\n"; - -static PyObject * UnaryFunction1DVec3f_getName( BPy_UnaryFunction1DVec3f *self ) -{ - return PyUnicode_FromString( self->uf1D_vec3f->getName().c_str() ); + return PyUnicode_FromFormat("type: %s - address: %p", self->uf1D_vec3f->getName().c_str(), self->uf1D_vec3f); } -static PyObject * UnaryFunction1DVec3f___call__( BPy_UnaryFunction1DVec3f *self, PyObject *args, PyObject *kwds) +static PyObject * UnaryFunction1DVec3f___call__(BPy_UnaryFunction1DVec3f *self, PyObject *args, PyObject *kwds) { - PyObject *obj; + static const char *kwlist[] = {"inter", NULL}; + PyObject *obj = 0; - if( kwds != NULL ) { - PyErr_SetString(PyExc_TypeError, "keyword argument(s) not supported"); - return NULL; - } - if( !PyArg_ParseTuple(args, "O!", &Interface1D_Type, &obj) ) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &Interface1D_Type, &obj)) return NULL; - - if( typeid(*(self->uf1D_vec3f)) == typeid(UnaryFunction1D) ) { + + if (typeid(*(self->uf1D_vec3f)) == typeid(UnaryFunction1D)) { PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden"); return NULL; } - if (self->uf1D_vec3f->operator()(*( ((BPy_Interface1D *) obj)->if1D )) < 0) { + if (self->uf1D_vec3f->operator()(*(((BPy_Interface1D *) obj)->if1D)) < 0) { if (!PyErr_Occurred()) { - string msg(self->uf1D_vec3f->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 Vector_from_Vec3f( self->uf1D_vec3f->result ); + return Vector_from_Vec3f(self->uf1D_vec3f->result); } -static char UnaryFunction1DVec3f_setIntegrationType___doc__[] = -".. method:: setIntegrationType(integration)\n" -"\n" -" Sets the integration method.\n" +static PyMethodDef BPy_UnaryFunction1DVec3f_methods[] = { + {NULL, NULL, 0, NULL} +}; + +/*----------------------UnaryFunction1DVec3f get/setters ----------------------------*/ + +PyDoc_STRVAR(integration_type_doc, +"The integration method.\n" "\n" -" :arg integration: An integration method.\n" -" :type integration: :class:`IntegrationType`\n"; +":type: :class:`IntegrationType`"); -static PyObject * UnaryFunction1DVec3f_setIntegrationType(BPy_UnaryFunction1DVec3f* self, PyObject *args) +static PyObject *integration_type_get(BPy_UnaryFunction1DVec3f *self, void *UNUSED(closure)) { - PyObject *obj; - - if( !PyArg_ParseTuple(args, "O!", &IntegrationType_Type, &obj) ) - return NULL; - - self->uf1D_vec3f->setIntegrationType( IntegrationType_from_BPy_IntegrationType(obj) ); - Py_RETURN_NONE; + return BPy_IntegrationType_from_IntegrationType(self->uf1D_vec3f->getIntegrationType()); } -static char UnaryFunction1DVec3f_getIntegrationType___doc__[] = -".. method:: getIntegrationType(integration)\n" -"\n" -" Returns the integration method.\n" -"\n" -" :return: The integration method.\n" -" :rtype: :class:`IntegrationType`\n"; - -static PyObject * UnaryFunction1DVec3f_getIntegrationType(BPy_UnaryFunction1DVec3f* self) { - return BPy_IntegrationType_from_IntegrationType( self->uf1D_vec3f->getIntegrationType() ); +static int integration_type_set(BPy_UnaryFunction1DVec3f *self, PyObject *value, void *UNUSED(closure)) +{ + if (!BPy_IntegrationType_Check(value)) { + PyErr_SetString(PyExc_TypeError, "value must be an IntegrationType"); + return -1; + } + self->uf1D_vec3f->setIntegrationType(IntegrationType_from_BPy_IntegrationType(value)); + return 0; } -/*----------------------UnaryFunction1DVec3f instance definitions ----------------------------*/ -static PyMethodDef BPy_UnaryFunction1DVec3f_methods[] = { - {"getName", ( PyCFunction ) UnaryFunction1DVec3f_getName, METH_NOARGS, UnaryFunction1DVec3f_getName___doc__}, - {"setIntegrationType", ( PyCFunction ) UnaryFunction1DVec3f_setIntegrationType, METH_VARARGS, UnaryFunction1DVec3f_setIntegrationType___doc__}, - {"getIntegrationType", ( PyCFunction ) UnaryFunction1DVec3f_getIntegrationType, METH_NOARGS, UnaryFunction1DVec3f_getIntegrationType___doc__}, - {NULL, NULL, 0, NULL} +static PyGetSetDef BPy_UnaryFunction1DVec3f_getseters[] = { + {(char *)"integration_type", (getter)integration_type_get, (setter)integration_type_set, (char *)integration_type_doc, NULL}, + {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ }; /*-----------------------BPy_UnaryFunction1DVec3f type definition ------------------------------*/ @@ -192,7 +169,7 @@ PyTypeObject UnaryFunction1DVec3f_Type = { 0, /* tp_iternext */ BPy_UnaryFunction1DVec3f_methods, /* tp_methods */ 0, /* tp_members */ - 0, /* tp_getset */ + BPy_UnaryFunction1DVec3f_getseters, /* tp_getset */ &UnaryFunction1D_Type, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.cpp index 5555f401cbf..bf2c882d7cd 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.cpp @@ -16,29 +16,29 @@ extern "C" { //-------------------MODULE INITIALIZATION-------------------------------- -int UnaryFunction1DVectorViewShape_Init( PyObject *module ) { - - if( module == NULL ) +int UnaryFunction1DVectorViewShape_Init(PyObject *module) +{ + if (module == NULL) return -1; - if( PyType_Ready( &UnaryFunction1DVectorViewShape_Type ) < 0 ) + if (PyType_Ready(&UnaryFunction1DVectorViewShape_Type) < 0) return -1; - Py_INCREF( &UnaryFunction1DVectorViewShape_Type ); + Py_INCREF(&UnaryFunction1DVectorViewShape_Type); PyModule_AddObject(module, "UnaryFunction1DVectorViewShape", (PyObject *)&UnaryFunction1DVectorViewShape_Type); - if( PyType_Ready( &GetOccludeeF1D_Type ) < 0 ) + if (PyType_Ready(&GetOccludeeF1D_Type) < 0) return -1; - Py_INCREF( &GetOccludeeF1D_Type ); + Py_INCREF(&GetOccludeeF1D_Type); PyModule_AddObject(module, "GetOccludeeF1D", (PyObject *)&GetOccludeeF1D_Type); - if( PyType_Ready( &GetOccludersF1D_Type ) < 0 ) + if (PyType_Ready(&GetOccludersF1D_Type) < 0) return -1; - Py_INCREF( &GetOccludersF1D_Type ); + Py_INCREF(&GetOccludersF1D_Type); PyModule_AddObject(module, "GetOccludersF1D", (PyObject *)&GetOccludersF1D_Type); - if( PyType_Ready( &GetShapeF1D_Type ) < 0 ) + if (PyType_Ready(&GetShapeF1D_Type) < 0) return -1; - Py_INCREF( &GetShapeF1D_Type ); + Py_INCREF(&GetShapeF1D_Type); PyModule_AddObject(module, "GetShapeF1D", (PyObject *)&GetShapeF1D_Type); return 0; @@ -57,25 +57,26 @@ static char UnaryFunction1DVectorViewShape___doc__[] = "\n" " Default constructor.\n" "\n" -".. method:: __init__(integration)\n" +".. method:: __init__(integration_type)\n" "\n" " Builds a unary 1D function using the integration method given as\n" " argument.\n" "\n" -" :arg integration: An integration method.\n" -" :type integration: :class:`IntegrationType`\n"; +" :arg integration_type: An integration method.\n" +" :type integration_type: :class:`IntegrationType`\n"; -static int UnaryFunction1DVectorViewShape___init__(BPy_UnaryFunction1DVectorViewShape* self, PyObject *args) +static int UnaryFunction1DVectorViewShape___init__(BPy_UnaryFunction1DVectorViewShape* self, PyObject *args, PyObject *kwds) { + static const char *kwlist[] = {"integration", NULL}; PyObject *obj = 0; - if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) ) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O!", (char **)kwlist, &IntegrationType_Type, &obj)) return -1; - if( !obj ) + if (!obj) self->uf1D_vectorviewshape = new UnaryFunction1D< std::vector >(); else { - self->uf1D_vectorviewshape = new UnaryFunction1D< std::vector >( IntegrationType_from_BPy_IntegrationType(obj) ); + self->uf1D_vectorviewshape = new UnaryFunction1D< std::vector >(IntegrationType_from_BPy_IntegrationType(obj)); } self->uf1D_vectorviewshape->py_uf1D = (PyObject *)self; @@ -92,47 +93,31 @@ static void UnaryFunction1DVectorViewShape___dealloc__(BPy_UnaryFunction1DVector static PyObject * UnaryFunction1DVectorViewShape___repr__(BPy_UnaryFunction1DVectorViewShape* self) { - return PyUnicode_FromFormat("type: %s - address: %p", self->uf1D_vectorviewshape->getName().c_str(), self->uf1D_vectorviewshape ); -} - -static char UnaryFunction1DVectorViewShape_getName___doc__[] = -".. method:: getName()\n" -"\n" -" Returns the name of the unary 1D function.\n" -"\n" -" :return: The name of the unary 1D function.\n" -" :rtype: str\n"; - -static PyObject * UnaryFunction1DVectorViewShape_getName( BPy_UnaryFunction1DVectorViewShape *self ) -{ - return PyUnicode_FromString( self->uf1D_vectorviewshape->getName().c_str() ); + return PyUnicode_FromFormat("type: %s - address: %p", self->uf1D_vectorviewshape->getName().c_str(), self->uf1D_vectorviewshape); } -static PyObject * UnaryFunction1DVectorViewShape___call__( BPy_UnaryFunction1DVectorViewShape *self, PyObject *args, PyObject *kwds) +static PyObject * UnaryFunction1DVectorViewShape___call__(BPy_UnaryFunction1DVectorViewShape *self, PyObject *args, PyObject *kwds) { - PyObject *obj; + static const char *kwlist[] = {"inter", NULL}; + PyObject *obj = 0; - if( kwds != NULL ) { - PyErr_SetString(PyExc_TypeError, "keyword argument(s) not supported"); - return NULL; - } - if( !PyArg_ParseTuple(args, "O!", &Interface1D_Type, &obj) ) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &Interface1D_Type, &obj)) return NULL; - - if( typeid(*(self->uf1D_vectorviewshape)) == typeid(UnaryFunction1D< std::vector >) ) { + + if (typeid(*(self->uf1D_vectorviewshape)) == typeid(UnaryFunction1D< std::vector >)) { PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden"); return NULL; } - if (self->uf1D_vectorviewshape->operator()(*( ((BPy_Interface1D *) obj)->if1D )) < 0) { + if (self->uf1D_vectorviewshape->operator()(*(((BPy_Interface1D *) obj)->if1D)) < 0) { if (!PyErr_Occurred()) { - string msg(self->uf1D_vectorviewshape->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; } PyObject *list = PyList_New(0); PyObject *item; - for( unsigned int i = 0; i < self->uf1D_vectorviewshape->result.size(); i++) { + for(unsigned int i = 0; i < self->uf1D_vectorviewshape->result.size(); i++) { ViewShape *v = self->uf1D_vectorviewshape->result[i]; if (v) { item = BPy_ViewShape_from_ViewShape(*v); @@ -146,43 +131,35 @@ static PyObject * UnaryFunction1DVectorViewShape___call__( BPy_UnaryFunction1DVe return list; } -static char UnaryFunction1DVectorViewShape_setIntegrationType___doc__[] = -".. method:: setIntegrationType(integration)\n" -"\n" -" Sets the integration method.\n" +static PyMethodDef BPy_UnaryFunction1DVectorViewShape_methods[] = { + {NULL, NULL, 0, NULL} +}; + +/*----------------------UnaryFunction1DVectorViewShape get/setters ----------------------------*/ + +PyDoc_STRVAR(integration_type_doc, +"The integration method.\n" "\n" -" :arg integration: An integration method.\n" -" :type integration: :class:`IntegrationType`\n"; +":type: :class:`IntegrationType`"); -static PyObject * UnaryFunction1DVectorViewShape_setIntegrationType(BPy_UnaryFunction1DVectorViewShape* self, PyObject *args) +static PyObject *integration_type_get(BPy_UnaryFunction1DVectorViewShape *self, void *UNUSED(closure)) { - PyObject *obj; - - if( !PyArg_ParseTuple(args, "O!", &IntegrationType_Type, &obj) ) - return NULL; - - self->uf1D_vectorviewshape->setIntegrationType( IntegrationType_from_BPy_IntegrationType(obj) ); - Py_RETURN_NONE; + return BPy_IntegrationType_from_IntegrationType(self->uf1D_vectorviewshape->getIntegrationType()); } -static char UnaryFunction1DVectorViewShape_getIntegrationType___doc__[] = -".. method:: getIntegrationType(integration)\n" -"\n" -" Returns the integration method.\n" -"\n" -" :return: The integration method.\n" -" :rtype: :class:`IntegrationType`\n"; - -static PyObject * UnaryFunction1DVectorViewShape_getIntegrationType(BPy_UnaryFunction1DVectorViewShape* self) { - return BPy_IntegrationType_from_IntegrationType( self->uf1D_vectorviewshape->getIntegrationType() ); +static int integration_type_set(BPy_UnaryFunction1DVectorViewShape *self, PyObject *value, void *UNUSED(closure)) +{ + if (!BPy_IntegrationType_Check(value)) { + PyErr_SetString(PyExc_TypeError, "value must be an IntegrationType"); + return -1; + } + self->uf1D_vectorviewshape->setIntegrationType(IntegrationType_from_BPy_IntegrationType(value)); + return 0; } -/*----------------------UnaryFunction1DVectorViewShape instance definitions ----------------------------*/ -static PyMethodDef BPy_UnaryFunction1DVectorViewShape_methods[] = { - {"getName", ( PyCFunction ) UnaryFunction1DVectorViewShape_getName, METH_NOARGS, UnaryFunction1DVectorViewShape_getName___doc__}, - {"setIntegrationType", ( PyCFunction ) UnaryFunction1DVectorViewShape_setIntegrationType, METH_VARARGS, UnaryFunction1DVectorViewShape_setIntegrationType___doc__}, - {"getIntegrationType", ( PyCFunction ) UnaryFunction1DVectorViewShape_getIntegrationType, METH_NOARGS, UnaryFunction1DVectorViewShape_getIntegrationType___doc__}, - {NULL, NULL, 0, NULL} +static PyGetSetDef BPy_UnaryFunction1DVectorViewShape_getseters[] = { + {(char *)"integration_type", (getter)integration_type_get, (setter)integration_type_set, (char *)integration_type_doc, NULL}, + {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ }; /*-----------------------BPy_UnaryFunction1DVectorViewShape type definition ------------------------------*/ @@ -217,7 +194,7 @@ PyTypeObject UnaryFunction1DVectorViewShape_Type = { 0, /* tp_iternext */ BPy_UnaryFunction1DVectorViewShape_methods, /* tp_methods */ 0, /* tp_members */ - 0, /* tp_getset */ + BPy_UnaryFunction1DVectorViewShape_getseters, /* tp_getset */ &UnaryFunction1D_Type, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVoid.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVoid.cpp index f18421d8754..b1dae992812 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVoid.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVoid.cpp @@ -17,29 +17,29 @@ extern "C" { //-------------------MODULE INITIALIZATION-------------------------------- -int UnaryFunction1DVoid_Init( PyObject *module ) { - - if( module == NULL ) +int UnaryFunction1DVoid_Init(PyObject *module) +{ + if (module == NULL) return -1; - if( PyType_Ready( &UnaryFunction1DVoid_Type ) < 0 ) + if (PyType_Ready(&UnaryFunction1DVoid_Type) < 0) return -1; - Py_INCREF( &UnaryFunction1DVoid_Type ); + Py_INCREF(&UnaryFunction1DVoid_Type); PyModule_AddObject(module, "UnaryFunction1DVoid", (PyObject *)&UnaryFunction1DVoid_Type); - if( PyType_Ready( &ChainingTimeStampF1D_Type ) < 0 ) + if (PyType_Ready(&ChainingTimeStampF1D_Type) < 0) return -1; - Py_INCREF( &ChainingTimeStampF1D_Type ); + Py_INCREF(&ChainingTimeStampF1D_Type); PyModule_AddObject(module, "ChainingTimeStampF1D", (PyObject *)&ChainingTimeStampF1D_Type); - if( PyType_Ready( &IncrementChainingTimeStampF1D_Type ) < 0 ) + if (PyType_Ready(&IncrementChainingTimeStampF1D_Type) < 0) return -1; - Py_INCREF( &IncrementChainingTimeStampF1D_Type ); + Py_INCREF(&IncrementChainingTimeStampF1D_Type); PyModule_AddObject(module, "IncrementChainingTimeStampF1D", (PyObject *)&IncrementChainingTimeStampF1D_Type); - if( PyType_Ready( &TimeStampF1D_Type ) < 0 ) + if (PyType_Ready(&TimeStampF1D_Type) < 0) return -1; - Py_INCREF( &TimeStampF1D_Type ); + Py_INCREF(&TimeStampF1D_Type); PyModule_AddObject(module, "TimeStampF1D", (PyObject *)&TimeStampF1D_Type); return 0; @@ -57,25 +57,26 @@ static char UnaryFunction1DVoid___doc__[] = "\n" " Default constructor.\n" "\n" -".. method:: __init__(integration)\n" +".. method:: __init__(integration_type)\n" "\n" " Builds a unary 1D function using the integration method given as\n" " argument.\n" "\n" -" :arg integration: An integration method.\n" -" :type integration: :class:`IntegrationType`\n"; +" :arg integration_type: An integration method.\n" +" :type integration_type: :class:`IntegrationType`\n"; -static int UnaryFunction1DVoid___init__(BPy_UnaryFunction1DVoid* self, PyObject *args) +static int UnaryFunction1DVoid___init__(BPy_UnaryFunction1DVoid* self, PyObject *args, PyObject *kwds) { + static const char *kwlist[] = {"integration", NULL}; PyObject *obj = 0; - if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) ) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O!", (char **)kwlist, &IntegrationType_Type, &obj)) return -1; - if( !obj ) + if (!obj) self->uf1D_void = new UnaryFunction1D_void(); else { - self->uf1D_void = new UnaryFunction1D_void( IntegrationType_from_BPy_IntegrationType(obj) ); + self->uf1D_void = new UnaryFunction1D_void(IntegrationType_from_BPy_IntegrationType(obj)); } self->uf1D_void->py_uf1D = (PyObject *)self; @@ -92,84 +93,60 @@ static void UnaryFunction1DVoid___dealloc__(BPy_UnaryFunction1DVoid* self) static PyObject * UnaryFunction1DVoid___repr__(BPy_UnaryFunction1DVoid* self) { - return PyUnicode_FromFormat("type: %s - address: %p", self->uf1D_void->getName().c_str(), self->uf1D_void ); -} - -static char UnaryFunction1DVoid_getName___doc__[] = -".. method:: getName()\n" -"\n" -" Returns the name of the unary 1D function.\n" -"\n" -" :return: The name of the unary 1D function.\n" -" :rtype: str\n"; - -static PyObject * UnaryFunction1DVoid_getName( BPy_UnaryFunction1DVoid *self ) -{ - return PyUnicode_FromString( self->uf1D_void->getName().c_str() ); + return PyUnicode_FromFormat("type: %s - address: %p", self->uf1D_void->getName().c_str(), self->uf1D_void); } -static PyObject * UnaryFunction1DVoid___call__( BPy_UnaryFunction1DVoid *self, PyObject *args, PyObject *kwds) +static PyObject * UnaryFunction1DVoid___call__(BPy_UnaryFunction1DVoid *self, PyObject *args, PyObject *kwds) { - PyObject *obj; + static const char *kwlist[] = {"inter", NULL}; + PyObject *obj = 0; - if( kwds != NULL ) { - PyErr_SetString(PyExc_TypeError, "keyword argument(s) not supported"); - return NULL; - } - if( !PyArg_ParseTuple(args, "O!", &Interface1D_Type, &obj) ) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &Interface1D_Type, &obj)) return NULL; - - if( typeid(*(self->uf1D_void)) == typeid(UnaryFunction1D_void) ) { + + if (typeid(*(self->uf1D_void)) == typeid(UnaryFunction1D_void)) { PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden"); return NULL; } - if (self->uf1D_void->operator()(*( ((BPy_Interface1D *) obj)->if1D )) < 0) { + if (self->uf1D_void->operator()(*(((BPy_Interface1D *) obj)->if1D)) < 0) { if (!PyErr_Occurred()) { - string msg(self->uf1D_void->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; } Py_RETURN_NONE; } -static char UnaryFunction1DVoid_setIntegrationType___doc__[] = -".. method:: setIntegrationType(integration)\n" -"\n" -" Sets the integration method.\n" +static PyMethodDef BPy_UnaryFunction1DVoid_methods[] = { + {NULL, NULL, 0, NULL} +}; + +/*----------------------UnaryFunction1DVoid get/setters ----------------------------*/ + +PyDoc_STRVAR(integration_type_doc, +"The integration method.\n" "\n" -" :arg integration: An integration method.\n" -" :type integration: :class:`IntegrationType`\n"; +":type: :class:`IntegrationType`"); -static PyObject * UnaryFunction1DVoid_setIntegrationType(BPy_UnaryFunction1DVoid* self, PyObject *args) +static PyObject *integration_type_get(BPy_UnaryFunction1DVoid *self, void *UNUSED(closure)) { - PyObject *obj; - - if( !PyArg_ParseTuple(args, "O!", &IntegrationType_Type, &obj) ) - return NULL; - - self->uf1D_void->setIntegrationType( IntegrationType_from_BPy_IntegrationType(obj) ); - Py_RETURN_NONE; + return BPy_IntegrationType_from_IntegrationType(self->uf1D_void->getIntegrationType()); } -static char UnaryFunction1DVoid_getIntegrationType___doc__[] = -".. method:: getIntegrationType(integration)\n" -"\n" -" Returns the integration method.\n" -"\n" -" :return: The integration method.\n" -" :rtype: :class:`IntegrationType`\n"; - -static PyObject * UnaryFunction1DVoid_getIntegrationType(BPy_UnaryFunction1DVoid* self) { - return BPy_IntegrationType_from_IntegrationType( self->uf1D_void->getIntegrationType() ); +static int integration_type_set(BPy_UnaryFunction1DVoid *self, PyObject *value, void *UNUSED(closure)) +{ + if (!BPy_IntegrationType_Check(value)) { + PyErr_SetString(PyExc_TypeError, "value must be an IntegrationType"); + return -1; + } + self->uf1D_void->setIntegrationType(IntegrationType_from_BPy_IntegrationType(value)); + return 0; } -/*----------------------UnaryFunction1DVoid instance definitions ----------------------------*/ -static PyMethodDef BPy_UnaryFunction1DVoid_methods[] = { - {"getName", ( PyCFunction ) UnaryFunction1DVoid_getName, METH_NOARGS, UnaryFunction1DVoid_getName___doc__}, - {"setIntegrationType", ( PyCFunction ) UnaryFunction1DVoid_setIntegrationType, METH_VARARGS, UnaryFunction1DVoid_setIntegrationType___doc__}, - {"getIntegrationType", ( PyCFunction ) UnaryFunction1DVoid_getIntegrationType, METH_NOARGS, UnaryFunction1DVoid_getIntegrationType___doc__}, - {NULL, NULL, 0, NULL} +static PyGetSetDef BPy_UnaryFunction1DVoid_getseters[] = { + {(char *)"integration_type", (getter)integration_type_get, (setter)integration_type_set, (char *)integration_type_doc, NULL}, + {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ }; /*-----------------------BPy_UnaryFunction1DVoid type definition ------------------------------*/ @@ -204,7 +181,7 @@ PyTypeObject UnaryFunction1DVoid_Type = { 0, /* tp_iternext */ BPy_UnaryFunction1DVoid_methods, /* tp_methods */ 0, /* tp_members */ - 0, /* tp_getset */ + BPy_UnaryFunction1DVoid_getseters, /* tp_getset */ &UnaryFunction1D_Type, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Nature_EdgeNature/BPy_CurveNatureF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Nature_EdgeNature/BPy_CurveNatureF1D.cpp index a31d96ad1a4..8bf4162c4ed 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Nature_EdgeNature/BPy_CurveNatureF1D.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Nature_EdgeNature/BPy_CurveNatureF1D.cpp @@ -15,13 +15,13 @@ extern "C" { static char CurveNatureF1D___doc__[] = "Class hierarchy: :class:`UnaryFunction1D` > :class:`UnaryFunction1DEdgeNature` > :class:`CurveNatureF1D`\n" "\n" -".. method:: __init__(iType=IntegrationType.MEAN)\n" +".. method:: __init__(integration_type=IntegrationType.MEAN)\n" "\n" " Builds a CurveNatureF1D object.\n" "\n" -" :arg iType: The integration method used to compute a single value\n" +" :arg integration_type: The integration method used to compute a single value\n" " from a set of values.\n" -" :type iType: :class:`IntegrationType`\n" +" :type integration_type: :class:`IntegrationType`\n" "\n" ".. method:: __call__(inter)\n" "\n" @@ -37,14 +37,14 @@ static char CurveNatureF1D___doc__[] = " :return: The nature of the Interface1D.\n" " :rtype: :class:`Nature`\n"; -static int CurveNatureF1D___init__( BPy_CurveNatureF1D* self, PyObject *args) +static int CurveNatureF1D___init__(BPy_CurveNatureF1D* self, PyObject *args, PyObject *kwds) { + static const char *kwlist[] = {"integration_type", NULL}; PyObject *obj = 0; - if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) ) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O!", (char **)kwlist, &IntegrationType_Type, &obj)) return -1; - - IntegrationType t = ( obj ) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; + IntegrationType t = (obj) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; self->py_uf1D_edgenature.uf1D_edgenature = new Functions1D::CurveNatureF1D(t); return 0; } diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Normal2DF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Normal2DF1D.cpp index 92ba5b05e75..b2605b67f44 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Normal2DF1D.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Normal2DF1D.cpp @@ -15,13 +15,13 @@ extern "C" { static char Normal2DF1D___doc__[] = "Class hierarchy: :class:`UnaryFunction1D` > :class:`UnaryFunction1DVec2f` > :class:`Normal2DF1D`\n" "\n" -".. method:: __init__(iType=IntegrationType.MEAN)\n" +".. method:: __init__(integration_type=IntegrationType.MEAN)\n" "\n" " Builds a Normal2DF1D object.\n" "\n" -" :arg iType: The integration method used to compute a single value\n" +" :arg integration_type: The integration method used to compute a single value\n" " from a set of values.\n" -" :type iType: :class:`IntegrationType`\n" +" :type integration_type: :class:`IntegrationType`\n" "\n" ".. method:: __call__(inter)\n" "\n" @@ -32,14 +32,14 @@ static char Normal2DF1D___doc__[] = " :return: The 2D normal for the Interface1D.\n" " :rtype: :class:`mathutils.Vector`\n"; -static int Normal2DF1D___init__( BPy_Normal2DF1D* self, PyObject *args) +static int Normal2DF1D___init__(BPy_Normal2DF1D* self, PyObject *args, PyObject *kwds) { + static const char *kwlist[] = {"integration_type", NULL}; PyObject *obj = 0; - if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) ) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O!", (char **)kwlist, &IntegrationType_Type, &obj)) return -1; - - IntegrationType t = ( obj ) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; + IntegrationType t = (obj) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; self->py_uf1D_vec2f.uf1D_vec2f = new Functions1D::Normal2DF1D(t); return 0; } diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Orientation2DF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Orientation2DF1D.cpp index a1b87b9cf17..925a407c298 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Orientation2DF1D.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Orientation2DF1D.cpp @@ -15,13 +15,13 @@ extern "C" { static char Orientation2DF1D___doc__[] = "Class hierarchy: :class:`UnaryFunction1D` > :class:`UnaryFunction1DVec2f` > :class:`Orientation2DF1D`\n" "\n" -".. method:: __init__(iType=IntegrationType.MEAN)\n" +".. method:: __init__(integration_type=IntegrationType.MEAN)\n" "\n" " Builds an Orientation2DF1D object.\n" "\n" -" :arg iType: The integration method used to compute a single value\n" +" :arg integration_type: The integration method used to compute a single value\n" " from a set of values.\n" -" :type iType: :class:`IntegrationType`\n" +" :type integration_type: :class:`IntegrationType`\n" "\n" ".. method:: __call__(inter)\n" "\n" @@ -32,20 +32,18 @@ static char Orientation2DF1D___doc__[] = " :return: The 2D orientation of the Interface1D.\n" " :rtype: :class:`mathutils.Vector`\n"; -static int Orientation2DF1D___init__( BPy_Orientation2DF1D* self, PyObject *args) +static int Orientation2DF1D___init__(BPy_Orientation2DF1D* self, PyObject *args, PyObject *kwds) { + static const char *kwlist[] = {"integration_type", NULL}; PyObject *obj = 0; - if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) ) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O!", (char **)kwlist, &IntegrationType_Type, &obj)) return -1; - - IntegrationType t = ( obj ) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; + IntegrationType t = (obj) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; self->py_uf1D_vec2f.uf1D_vec2f = new Functions1D::Orientation2DF1D(t); return 0; - } - /*-----------------------BPy_Orientation2DF1D type definition ------------------------------*/ PyTypeObject Orientation2DF1D_Type = { diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec3f/BPy_Orientation3DF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec3f/BPy_Orientation3DF1D.cpp index a55c1f7a542..4101f08e8fc 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec3f/BPy_Orientation3DF1D.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec3f/BPy_Orientation3DF1D.cpp @@ -15,13 +15,13 @@ extern "C" { static char Orientation3DF1D___doc__[] = "Class hierarchy: :class:`UnaryFunction1D` > :class:`UnaryFunction1DVec3f` > :class:`Orientation3DF1D`\n" "\n" -".. method:: __init__(iType=IntegrationType.MEAN)\n" +".. method:: __init__(integration_type=IntegrationType.MEAN)\n" "\n" " Builds an Orientation3DF1D object.\n" "\n" -" :arg iType: The integration method used to compute a single value\n" +" :arg integration_type: The integration method used to compute a single value\n" " from a set of values.\n" -" :type iType: :class:`IntegrationType`\n" +" :type integration_type: :class:`IntegrationType`\n" "\n" ".. method:: __call__(inter)\n" "\n" @@ -32,14 +32,14 @@ static char Orientation3DF1D___doc__[] = " :return: The 3D orientation of the Interface1D.\n" " :rtype: :class:`mathutils.Vector`\n"; -static int Orientation3DF1D___init__( BPy_Orientation3DF1D* self, PyObject *args) +static int Orientation3DF1D___init__(BPy_Orientation3DF1D* self, PyObject *args, PyObject *kwds) { + static const char *kwlist[] = {"integration_type", NULL}; PyObject *obj = 0; - if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) ) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O!", (char **)kwlist, &IntegrationType_Type, &obj)) return -1; - - IntegrationType t = ( obj ) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; + IntegrationType t = (obj) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; self->py_uf1D_vec3f.uf1D_vec3f = new Functions1D::Orientation3DF1D(t); return 0; } diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_Curvature2DAngleF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_Curvature2DAngleF1D.cpp index aec76c2888c..d7b50b43035 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_Curvature2DAngleF1D.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_Curvature2DAngleF1D.cpp @@ -15,13 +15,13 @@ extern "C" { static char Curvature2DAngleF1D___doc__[] = "Class hierarchy: :class:`UnaryFunction1D` > :class:`UnaryFunction1DDouble` > :class:`Curvature2DAngleF1D`\n" "\n" -".. method:: __init__(iType=IntegrationType.MEAN)\n" +".. method:: __init__(integration_type=IntegrationType.MEAN)\n" "\n" " Builds a Curvature2DAngleF1D object.\n" "\n" -" :arg iType: The integration method used to compute a single value\n" +" :arg integration_type: The integration method used to compute a single value\n" " from a set of values.\n" -" :type iType: :class:`IntegrationType`\n" +" :type integration_type: :class:`IntegrationType`\n" "\n" ".. method:: __call__(inter)\n" "\n" @@ -32,14 +32,14 @@ static char Curvature2DAngleF1D___doc__[] = " :return: The 2D curvature as an angle.\n" " :rtype: float\n"; -static int Curvature2DAngleF1D___init__( BPy_Curvature2DAngleF1D* self, PyObject *args) +static int Curvature2DAngleF1D___init__(BPy_Curvature2DAngleF1D* self, PyObject *args, PyObject *kwds) { + static const char *kwlist[] = {"integration_type", NULL}; PyObject *obj = 0; - if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) ) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O!", (char **)kwlist, &IntegrationType_Type, &obj)) return -1; - - IntegrationType t = ( obj ) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; + IntegrationType t = (obj) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; self->py_uf1D_double.uf1D_double = new Functions1D::Curvature2DAngleF1D(t); return 0; diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_DensityF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_DensityF1D.cpp index 360f98fa361..785f4a006fe 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_DensityF1D.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_DensityF1D.cpp @@ -15,20 +15,20 @@ extern "C" { static char DensityF1D___doc__[] = "Class hierarchy: :class:`UnaryFunction1D` > :class:`UnaryFunction1DDouble` > :class:`DensityF1D`\n" "\n" -".. method:: __init__(sigma=2.0, iType=IntegrationType.MEAN, sampling=2.0)\n" +".. method:: __init__(sigma=2.0, integration_type=IntegrationType.MEAN, sampling=2.0)\n" "\n" " Builds a DensityF1D object.\n" "\n" " :arg sigma: The sigma used in DensityF0D and determining the window size\n" " used in each density query.\n" " :type sigma: float\n" -" :arg iType: The integration method used to compute a single value\n" +" :arg integration_type: The integration method used to compute a single value\n" " from a set of values.\n" -" :type iType: :class:`IntegrationType`\n" +" :type integration_type: :class:`IntegrationType`\n" " :arg sampling: The resolution used to sample the chain: the\n" " corresponding 0D function 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 iType.\n" +" single one, following the method specified by integration_type.\n" " :type sampling: float\n" "\n" ".. method:: __call__(inter)\n" @@ -44,16 +44,16 @@ static char DensityF1D___doc__[] = " :return: The density evaluated for an Interface1D.\n" " :rtype: float\n"; -static int DensityF1D___init__( BPy_DensityF1D* self, PyObject *args) +static int DensityF1D___init__(BPy_DensityF1D* self, PyObject *args, PyObject *kwds) { + static const char *kwlist[] = {"sigma", "integration_type", "sampling", NULL}; PyObject *obj = 0; double d = 2.0; float f = 2.0; - if( !PyArg_ParseTuple(args, "|dO!f", &d, &IntegrationType_Type, &obj, &f) ) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|dO!f", (char **)kwlist, &d, &IntegrationType_Type, &obj, &f)) return -1; - - IntegrationType t = ( obj ) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; + IntegrationType t = (obj) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; self->py_uf1D_double.uf1D_double = new Functions1D::DensityF1D(d,t,f); return 0; diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetCompleteViewMapDensityF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetCompleteViewMapDensityF1D.cpp index b30d26c8516..b1e02ecdb64 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetCompleteViewMapDensityF1D.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetCompleteViewMapDensityF1D.cpp @@ -15,20 +15,20 @@ extern "C" { static char GetCompleteViewMapDensityF1D___doc__[] = "Class hierarchy: :class:`UnaryFunction1D` > :class:`UnaryFunction1DDouble` > :class:`GetCompleteViewMapDensityF1D`\n" "\n" -".. method:: __init__(level, iType=IntegrationType.MEAN, sampling=2.0)\n" +".. method:: __init__(level, integration_type=IntegrationType.MEAN, sampling=2.0)\n" "\n" " Builds a GetCompleteViewMapDensityF1D object.\n" "\n" " :arg level: The level of the pyramid from which the pixel must be\n" " read.\n" " :type level: int\n" -" :arg iType: The integration method used to compute a single value\n" +" :arg integration_type: The integration method used to compute a single value\n" " from a set of values.\n" -" :type iType: :class:`IntegrationType`\n" +" :type integration_type: :class:`IntegrationType`\n" " :arg sampling: The resolution used to sample the chain: the\n" " corresponding 0D function 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 iType.\n" +" single one, following the method specified by integration_type.\n" " :type sampling: float\n" "\n" ".. method:: __call__(inter)\n" @@ -45,19 +45,18 @@ static char GetCompleteViewMapDensityF1D___doc__[] = " viewmap image.\n" " :rtype: float\n"; -static int GetCompleteViewMapDensityF1D___init__( BPy_GetCompleteViewMapDensityF1D* self, PyObject *args) +static int GetCompleteViewMapDensityF1D___init__(BPy_GetCompleteViewMapDensityF1D* self, PyObject *args, PyObject *kwds) { + static const char *kwlist[] = {"level", "integration_type", "sampling", NULL}; PyObject *obj = 0; - unsigned i; + int i; 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; + IntegrationType t = (obj) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; self->py_uf1D_double.uf1D_double = new Functions1D::GetCompleteViewMapDensityF1D(i,t,f); return 0; - } /*-----------------------BPy_GetCompleteViewMapDensityF1D type definition ------------------------------*/ diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetDirectionalViewMapDensityF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetDirectionalViewMapDensityF1D.cpp index 494297d3a3b..921920088c6 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetDirectionalViewMapDensityF1D.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetDirectionalViewMapDensityF1D.cpp @@ -15,23 +15,23 @@ extern "C" { static char GetDirectionalViewMapDensityF1D___doc__[] = "Class hierarchy: :class:`UnaryFunction1D` > :class:`UnaryFunction1DDouble` > :class:`GetDirectionalViewMapDensityF1D`\n" "\n" -".. method:: __init__(iOrientation, level, iType=IntegrationType.MEAN, sampling=2.0)\n" +".. method:: __init__(orientation, level, integration_type=IntegrationType.MEAN, sampling=2.0)\n" "\n" " Builds a GetDirectionalViewMapDensityF1D object.\n" "\n" -" :arg iOrientation: The number of the directional map we must work\n" +" :arg orientation: The number of the directional map we must work\n" " with.\n" -" :type iOrientation: int\n" +" :type orientation: int\n" " :arg level: The level of the pyramid from which the pixel must be\n" " read.\n" " :type level: int\n" -" :arg iType: The integration method used to compute a single value\n" +" :arg integration_type: The integration method used to compute a single value\n" " from a set of values.\n" -" :type iType: :class:`IntegrationType`\n" +" :type integration_type: :class:`IntegrationType`\n" " :arg sampling: The resolution used to sample the chain: the\n" " corresponding 0D function 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 iType.\n" +" single one, following the method specified by integration_type.\n" " :type sampling: float\n" "\n" ".. method:: __call__(inter)\n" @@ -49,19 +49,18 @@ static char GetDirectionalViewMapDensityF1D___doc__[] = " steerable viewmaps image.\n" " :rtype: float\n"; -static int GetDirectionalViewMapDensityF1D___init__( BPy_GetDirectionalViewMapDensityF1D* self, PyObject *args) +static int GetDirectionalViewMapDensityF1D___init__(BPy_GetDirectionalViewMapDensityF1D* self, PyObject *args, PyObject *kwds) { + static const char *kwlist[] = {"orientation", "level", "integration_type", "sampling", NULL}; PyObject *obj = 0; unsigned int u1, u2; float f = 2.0; - if( !PyArg_ParseTuple(args, "II|O!f", &u1, &u2, &IntegrationType_Type, &obj, &f) ) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "II|O!f", (char **)kwlist, &u1, &u2, &IntegrationType_Type, &obj, &f)) return -1; - - IntegrationType t = ( obj ) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; + IntegrationType t = (obj) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; self->py_uf1D_double.uf1D_double = new Functions1D::GetDirectionalViewMapDensityF1D(u1, u2, t, f); return 0; - } /*-----------------------BPy_GetDirectionalViewMapDensityF1D type definition ------------------------------*/ diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedXF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedXF1D.cpp index 7b1e7193b85..20792a48151 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedXF1D.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedXF1D.cpp @@ -15,13 +15,13 @@ extern "C" { static char GetProjectedXF1D___doc__[] = "Class hierarchy: :class:`UnaryFunction1D` > :class:`UnaryFunction1DDouble` > :class:`GetProjectedXF1D`\n" "\n" -".. method:: __init__(iType=IntegrationType.MEAN)\n" +".. method:: __init__(integration_type=IntegrationType.MEAN)\n" "\n" " Builds a GetProjectedXF1D object.\n" "\n" -" :arg iType: The integration method used to compute a single value\n" +" :arg integration_type: The integration method used to compute a single value\n" " from a set of values. \n" -" :type iType: :class:`IntegrationType`\n" +" :type integration_type: :class:`IntegrationType`\n" "\n" ".. method:: __call__(inter)\n" "\n" @@ -32,14 +32,14 @@ static char GetProjectedXF1D___doc__[] = " :return: The projected X 3D coordinate of an Interface1D.\n" " :rtype: float\n"; -static int GetProjectedXF1D___init__( BPy_GetProjectedXF1D* self, PyObject *args ) +static int GetProjectedXF1D___init__(BPy_GetProjectedXF1D* self, PyObject *args, PyObject *kwds) { + static const char *kwlist[] = {"integration_type", NULL}; PyObject *obj = 0; - if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) ) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O!", (char **)kwlist, &IntegrationType_Type, &obj)) return -1; - - IntegrationType t = ( obj ) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; + IntegrationType t = (obj) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; self->py_uf1D_double.uf1D_double = new Functions1D::GetProjectedXF1D(t); return 0; } diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedYF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedYF1D.cpp index df09b32b5b9..522fefdf31b 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedYF1D.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedYF1D.cpp @@ -15,13 +15,13 @@ extern "C" { static char GetProjectedYF1D___doc__[] = "Class hierarchy: :class:`UnaryFunction1D` > :class:`UnaryFunction1DDouble` > :class:`GetProjectedYF1D`\n" "\n" -".. method:: __init__(iType=IntegrationType.MEAN)\n" +".. method:: __init__(integration_type=IntegrationType.MEAN)\n" "\n" " Builds a GetProjectedYF1D object.\n" "\n" -" :arg iType: The integration method used to compute a single value\n" +" :arg integration_type: The integration method used to compute a single value\n" " from a set of values. \n" -" :type iType: :class:`IntegrationType`\n" +" :type integration_type: :class:`IntegrationType`\n" "\n" ".. method:: __call__(inter)\n" "\n" @@ -32,14 +32,14 @@ static char GetProjectedYF1D___doc__[] = " :return: The projected Y 3D coordinate of an Interface1D.\n" " :rtype: float\n"; -static int GetProjectedYF1D___init__( BPy_GetProjectedYF1D* self, PyObject *args ) +static int GetProjectedYF1D___init__(BPy_GetProjectedYF1D* self, PyObject *args, PyObject *kwds) { + static const char *kwlist[] = {"integration_type", NULL}; PyObject *obj = 0; - if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) ) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O!", (char **)kwlist, &IntegrationType_Type, &obj)) return -1; - - IntegrationType t = ( obj ) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; + IntegrationType t = (obj) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; self->py_uf1D_double.uf1D_double = new Functions1D::GetProjectedYF1D(t); return 0; } diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedZF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedZF1D.cpp index acd03856b2c..2b224b078c0 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedZF1D.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedZF1D.cpp @@ -15,13 +15,13 @@ extern "C" { static char GetProjectedZF1D___doc__[] = "Class hierarchy: :class:`UnaryFunction1D` > :class:`UnaryFunction1DDouble` > :class:`GetProjectedZF1D`\n" "\n" -".. method:: __init__(iType=IntegrationType.MEAN)\n" +".. method:: __init__(integration_type=IntegrationType.MEAN)\n" "\n" " Builds a GetProjectedZF1D object.\n" "\n" -" :arg iType: The integration method used to compute a single value\n" +" :arg integration_type: The integration method used to compute a single value\n" " from a set of values. \n" -" :type iType: :class:`IntegrationType`\n" +" :type integration_type: :class:`IntegrationType`\n" "\n" ".. method:: __call__(inter)\n" "\n" @@ -32,14 +32,14 @@ static char GetProjectedZF1D___doc__[] = " :return: The projected Z 3D coordinate of an Interface1D.\n" " :rtype: float\n"; -static int GetProjectedZF1D___init__( BPy_GetProjectedZF1D* self, PyObject *args ) +static int GetProjectedZF1D___init__(BPy_GetProjectedZF1D* self, PyObject *args, PyObject *kwds) { + static const char *kwlist[] = {"integration_type", NULL}; PyObject *obj = 0; - if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) ) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O!", (char **)kwlist, &IntegrationType_Type, &obj)) return -1; - - IntegrationType t = ( obj ) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; + IntegrationType t = (obj) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; self->py_uf1D_double.uf1D_double = new Functions1D::GetProjectedZF1D(t); return 0; } diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetSteerableViewMapDensityF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetSteerableViewMapDensityF1D.cpp index cc3813030ac..95946439d3a 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetSteerableViewMapDensityF1D.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetSteerableViewMapDensityF1D.cpp @@ -15,20 +15,20 @@ extern "C" { static char GetSteerableViewMapDensityF1D___doc__[] = "Class hierarchy: :class:`UnaryFunction1D` > :class:`UnaryFunction1DDouble` > :class:`GetSteerableViewMapDensityF1D`\n" "\n" -".. method:: __init__(level, iType=IntegrationType.MEAN, sampling=2.0)\n" +".. method:: __init__(level, integration_type=IntegrationType.MEAN, sampling=2.0)\n" "\n" " Builds a GetSteerableViewMapDensityF1D object.\n" "\n" " :arg level: The level of the pyramid from which the pixel must be\n" " read.\n" " :type level: int\n" -" :arg iType: The integration method used to compute a single value\n" +" :arg integration_type: The integration method used to compute a single value\n" " from a set of values.\n" -" :type iType: :class:`IntegrationType`\n" +" :type integration_type: :class:`IntegrationType`\n" " :arg sampling: The resolution used to sample the chain: the\n" " corresponding 0D function 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 iType.\n" +" single one, following the method specified by integration_type.\n" " :type sampling: float\n" "\n" ".. method:: __call__(inter)\n" @@ -42,19 +42,18 @@ static char GetSteerableViewMapDensityF1D___doc__[] = " :return: The density of the ViewMap for a given Interface1D.\n" " :rtype: float\n"; -static int GetSteerableViewMapDensityF1D___init__( BPy_GetSteerableViewMapDensityF1D* self, PyObject *args) +static int GetSteerableViewMapDensityF1D___init__(BPy_GetSteerableViewMapDensityF1D* self, PyObject *args, PyObject *kwds) { + static const char *kwlist[] = {"level", "integration_type", "sampling", NULL}; PyObject *obj = 0; int i; 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; + IntegrationType t = (obj) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; self->py_uf1D_double.uf1D_double = new Functions1D::GetSteerableViewMapDensityF1D(i,t,f); return 0; - } /*-----------------------BPy_GetSteerableViewMapDensityF1D type definition ------------------------------*/ diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetViewMapGradientNormF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetViewMapGradientNormF1D.cpp index c3e12fd7792..4ef3e03fe2a 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetViewMapGradientNormF1D.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetViewMapGradientNormF1D.cpp @@ -15,20 +15,20 @@ extern "C" { static char GetViewMapGradientNormF1D___doc__[] = "Class hierarchy: :class:`UnaryFunction1D` > :class:`UnaryFunction1DDouble` > :class:`GetViewMapGradientNormF1D`\n" "\n" -".. method:: __init__()\n" +".. method:: __init__(level, integration_type=IntegrationType.MEAN, sampling=2.0)\n" "\n" " Builds a GetViewMapGradientNormF1D object.\n" "\n" " :arg level: The level of the pyramid from which the pixel must be\n" " read.\n" " :type level: int\n" -" :arg iType: The integration method used to compute a single value\n" +" :arg integration_type: The integration method used to compute a single value\n" " from a set of values.\n" -" :type iType: :class:`IntegrationType`\n" +" :type integration_type: :class:`IntegrationType`\n" " :arg sampling: The resolution used to sample the chain: the\n" " corresponding 0D function 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 iType.\n" +" single one, following the method specified by integration_type.\n" " :type sampling: float\n" "\n" ".. method:: __call__(inter)\n" @@ -42,19 +42,18 @@ static char GetViewMapGradientNormF1D___doc__[] = " :return: The density of the ViewMap for a given Interface1D.\n" " :rtype: float\n"; -static int GetViewMapGradientNormF1D___init__( BPy_GetViewMapGradientNormF1D* self, PyObject *args) +static int GetViewMapGradientNormF1D___init__(BPy_GetViewMapGradientNormF1D* self, PyObject *args, PyObject *kwds) { + static const char *kwlist[] = {"level", "integration_type", "sampling", NULL}; PyObject *obj = 0; int i; 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; + IntegrationType t = (obj) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; self->py_uf1D_double.uf1D_double = new Functions1D::GetViewMapGradientNormF1D(i,t,f); return 0; - } /*-----------------------BPy_GetViewMapGradientNormF1D type definition ------------------------------*/ diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetXF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetXF1D.cpp index a15c6f59a3b..4c785ed9689 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetXF1D.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetXF1D.cpp @@ -15,13 +15,13 @@ extern "C" { static char GetXF1D___doc__[] = "Class hierarchy: :class:`UnaryFunction1D` > :class:`UnaryFunction1DDouble` > :class:`GetXF1D`\n" "\n" -".. method:: __init__(iType)\n" +".. method:: __init__(integration_type=IntegrationType.MEAN)\n" "\n" " Builds a GetXF1D object.\n" "\n" -" :arg iType: The integration method used to compute a single value\n" +" :arg integration_type: The integration method used to compute a single value\n" " from a set of values.\n" -" :type iType: :class:`IntegrationType`\n" +" :type integration_type: :class:`IntegrationType`\n" "\n" ".. method:: __call__(inter)\n" "\n" @@ -32,14 +32,14 @@ static char GetXF1D___doc__[] = " :return: The X 3D coordinate of the Interface1D.\n" " :rtype: float\n"; -static int GetXF1D___init__( BPy_GetXF1D* self, PyObject *args ) +static int GetXF1D___init__(BPy_GetXF1D* self, PyObject *args, PyObject *kwds) { + static const char *kwlist[] = {"integration_type", NULL}; PyObject *obj = 0; - if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) ) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O!", (char **)kwlist, &IntegrationType_Type, &obj)) return -1; - - IntegrationType t = ( obj ) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; + IntegrationType t = (obj) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; self->py_uf1D_double.uf1D_double = new Functions1D::GetXF1D(t); return 0; } diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetYF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetYF1D.cpp index b8ee3d8be27..1f858c1d49c 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetYF1D.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetYF1D.cpp @@ -15,13 +15,13 @@ extern "C" { static char GetYF1D___doc__[] = "Class hierarchy: :class:`UnaryFunction1D` > :class:`UnaryFunction1DDouble` > :class:`GetYF1D`\n" "\n" -".. method:: __init__(iType)\n" +".. method:: __init__(integration_type=IntegrationType.MEAN)\n" "\n" " Builds a GetYF1D object.\n" "\n" -" :arg iType: The integration method used to compute a single value\n" +" :arg integration_type: The integration method used to compute a single value\n" " from a set of values.\n" -" :type iType: :class:`IntegrationType`\n" +" :type integration_type: :class:`IntegrationType`\n" "\n" ".. method:: __call__(inter)\n" "\n" @@ -32,14 +32,14 @@ static char GetYF1D___doc__[] = " :return: The Y 3D coordinate of the Interface1D.\n" " :rtype: float\n"; -static int GetYF1D___init__( BPy_GetYF1D* self, PyObject *args ) +static int GetYF1D___init__(BPy_GetYF1D* self, PyObject *args, PyObject *kwds) { + static const char *kwlist[] = {"integration_type", NULL}; PyObject *obj = 0; - if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) ) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O!", (char **)kwlist, &IntegrationType_Type, &obj)) return -1; - - IntegrationType t = ( obj ) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; + IntegrationType t = (obj) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; self->py_uf1D_double.uf1D_double = new Functions1D::GetYF1D(t); return 0; } diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetZF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetZF1D.cpp index af275c906c4..4866ced23d8 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetZF1D.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetZF1D.cpp @@ -15,13 +15,13 @@ extern "C" { static char GetZF1D___doc__[] = "Class hierarchy: :class:`UnaryFunction1D` > :class:`UnaryFunction1DDouble` > :class:`GetZF1D`\n" "\n" -".. method:: __init__(iType)\n" +".. method:: __init__(integration_type=IntegrationType.MEAN)\n" "\n" " Builds a GetZF1D object.\n" "\n" -" :arg iType: The integration method used to compute a single value\n" +" :arg integration_type: The integration method used to compute a single value\n" " from a set of values.\n" -" :type iType: :class:`IntegrationType`\n" +" :type integration_type: :class:`IntegrationType`\n" "\n" ".. method:: __call__(inter)\n" "\n" @@ -32,14 +32,14 @@ static char GetZF1D___doc__[] = " :return: The Z 3D coordinate of the Interface1D.\n" " :rtype: float\n"; -static int GetZF1D___init__( BPy_GetZF1D* self, PyObject *args ) +static int GetZF1D___init__(BPy_GetZF1D* self, PyObject *args, PyObject *kwds) { + static const char *kwlist[] = {"integration_type", NULL}; PyObject *obj = 0; - if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) ) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O!", (char **)kwlist, &IntegrationType_Type, &obj)) return -1; - - IntegrationType t = ( obj ) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; + IntegrationType t = (obj) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; self->py_uf1D_double.uf1D_double = new Functions1D::GetZF1D(t); return 0; } diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_LocalAverageDepthF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_LocalAverageDepthF1D.cpp index a3b15e6b5f7..7af96a2e0a8 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_LocalAverageDepthF1D.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_LocalAverageDepthF1D.cpp @@ -15,16 +15,16 @@ extern "C" { static char LocalAverageDepthF1D___doc__[] = "Class hierarchy: :class:`UnaryFunction1D` > :class:`UnaryFunction1DDouble` > :class:`LocalAverageDepthF1D`\n" "\n" -".. method:: __init__(sigma, iType=IntegrationType.MEAN)\n" +".. method:: __init__(sigma, integration_type=IntegrationType.MEAN)\n" "\n" " Builds a LocalAverageDepthF1D object.\n" "\n" " :arg sigma: The sigma used in DensityF0D and determining the window\n" " size used in each density query.\n" " :type sigma: float\n" -" :arg iType: The integration method used to compute a single value\n" +" :arg integration_type: The integration method used to compute a single value\n" " from a set of values.\n" -" :type iType: :class:`IntegrationType`\n" +" :type integration_type: :class:`IntegrationType`\n" "\n" ".. method:: __call__(inter)\n" "\n" @@ -39,18 +39,19 @@ static char LocalAverageDepthF1D___doc__[] = " :return: The average depth evaluated for the Interface1D.\n" " :rtype: float\n"; -static int LocalAverageDepthF1D___init__( BPy_LocalAverageDepthF1D* self, PyObject *args) +static int LocalAverageDepthF1D___init__(BPy_LocalAverageDepthF1D* self, PyObject *args, PyObject *kwds) { + static const char *kwlist[] = {"sigma", "integration_type", NULL}; PyObject *obj = 0; double d; - if( !PyArg_ParseTuple(args, "d|O!", &d, &IntegrationType_Type, &obj) ) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "d|O!", (char **)kwlist, &d, &IntegrationType_Type, &obj)) return -1; - - IntegrationType t = ( obj ) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; + IntegrationType t = (obj) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; self->py_uf1D_double.uf1D_double = new Functions1D::LocalAverageDepthF1D(d,t); return 0; } + /*-----------------------BPy_LocalAverageDepthF1D type definition ------------------------------*/ PyTypeObject LocalAverageDepthF1D_Type = { diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_ZDiscontinuityF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_ZDiscontinuityF1D.cpp index 32a5106b380..c7bbdefccdc 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_ZDiscontinuityF1D.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_ZDiscontinuityF1D.cpp @@ -15,13 +15,13 @@ extern "C" { static char ZDiscontinuityF1D___doc__[] = "Class hierarchy: :class:`UnaryFunction1D` > :class:`UnaryFunction1DDouble` > :class:`ZDiscontinuityF1D`\n" "\n" -".. method:: __init__(iType=IntegrationType.MEAN)\n" +".. method:: __init__(integration_type=IntegrationType.MEAN)\n" "\n" " Builds a ZDiscontinuityF1D object.\n" "\n" -" :arg iType: The integration method used to compute a single value\n" +" :arg integration_type: The integration method used to compute a single value\n" " from a set of values.\n" -" :type iType: :class:`IntegrationType`\n" +" :type integration_type: :class:`IntegrationType`\n" "\n" ".. method:: __call__(inter)\n" "\n" @@ -36,14 +36,14 @@ static char ZDiscontinuityF1D___doc__[] = " :return: The normalized distance between the Interface1D and the occludee.\n" " :rtype: float\n"; -static int ZDiscontinuityF1D___init__( BPy_ZDiscontinuityF1D* self, PyObject *args ) +static int ZDiscontinuityF1D___init__(BPy_ZDiscontinuityF1D* self, PyObject *args, PyObject *kwds) { + static const char *kwlist[] = {"integration_type", NULL}; PyObject *obj = 0; - if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) ) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O!", (char **)kwlist, &IntegrationType_Type, &obj)) return -1; - - IntegrationType t = ( obj ) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; + IntegrationType t = (obj) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; self->py_uf1D_double.uf1D_double = new Functions1D::ZDiscontinuityF1D(t); return 0; } diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_unsigned_int/BPy_QuantitativeInvisibilityF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_unsigned_int/BPy_QuantitativeInvisibilityF1D.cpp index a7379c4f769..a2402135455 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_unsigned_int/BPy_QuantitativeInvisibilityF1D.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_unsigned_int/BPy_QuantitativeInvisibilityF1D.cpp @@ -15,13 +15,13 @@ extern "C" { static char QuantitativeInvisibilityF1D___doc__[] = "Class hierarchy: :class:`UnaryFunction1D` > :class:`UnaryFunction1DUnsigned` > :class:`QuantitativeInvisibilityF1D`\n" "\n" -".. method:: __init__(iType=IntegrationType.MEAN)\n" +".. method:: __init__(integration_type=IntegrationType.MEAN)\n" "\n" " Builds a QuantitativeInvisibilityF1D object.\n" "\n" -" :arg iType: The integration method used to compute a single value\n" +" :arg integration_type: The integration method used to compute a single value\n" " from a set of values.\n" -" :type iType: :class:`IntegrationType`\n" +" :type integration_type: :class:`IntegrationType`\n" "\n" ".. method:: __call__(inter)\n" "\n" @@ -36,17 +36,16 @@ static char QuantitativeInvisibilityF1D___doc__[] = " :return: The Quantitative Invisibility of the Interface1D.\n" " :rtype: int\n"; -static int QuantitativeInvisibilityF1D___init__( BPy_QuantitativeInvisibilityF1D* self, PyObject *args) +static int QuantitativeInvisibilityF1D___init__(BPy_QuantitativeInvisibilityF1D* self, PyObject *args, PyObject *kwds) { + static const char *kwlist[] = {"integration_type", NULL}; PyObject *obj = 0; - if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) ) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O!", (char **)kwlist, &IntegrationType_Type, &obj)) return -1; - - IntegrationType t = ( obj ) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; + IntegrationType t = (obj) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; self->py_uf1D_unsigned.uf1D_unsigned = new Functions1D::QuantitativeInvisibilityF1D(t); return 0; - } /*-----------------------BPy_QuantitativeInvisibilityF1D type definition ------------------------------*/ diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludeeF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludeeF1D.cpp index 4bd03f8fe75..d6a50d8ad87 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludeeF1D.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludeeF1D.cpp @@ -28,9 +28,11 @@ static char GetOccludeeF1D___doc__[] = " :return: A list of occluded shapes covered by the Interface1D.\n" " :rtype: list of :class:`ViewShape` objects\n"; -static int GetOccludeeF1D___init__( BPy_GetOccludeeF1D* self, PyObject *args ) +static int GetOccludeeF1D___init__(BPy_GetOccludeeF1D* 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_uf1D_vectorviewshape.uf1D_vectorviewshape = new Functions1D::GetOccludeeF1D(); return 0; diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludersF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludersF1D.cpp index d37102a8447..1d67ee2f916 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludersF1D.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludersF1D.cpp @@ -28,9 +28,11 @@ static char GetOccludersF1D___doc__[] = " :return: A list of occluding shapes that cover the Interface1D.\n" " :rtype: list of :class:`ViewShape` objects\n"; -static int GetOccludersF1D___init__( BPy_GetOccludersF1D* self, PyObject *args ) +static int GetOccludersF1D___init__(BPy_GetOccludersF1D* 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_uf1D_vectorviewshape.uf1D_vectorviewshape = new Functions1D::GetOccludersF1D(); return 0; diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetShapeF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetShapeF1D.cpp index 9b2007296f9..1ba19502de6 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetShapeF1D.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetShapeF1D.cpp @@ -28,9 +28,11 @@ static char GetShapeF1D___doc__[] = " :return: A list of shapes covered by the Interface1D.\n" " :rtype: list of :class:`ViewShape` objects\n"; -static int GetShapeF1D___init__( BPy_GetShapeF1D* self, PyObject *args ) +static int GetShapeF1D___init__(BPy_GetShapeF1D* 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_uf1D_vectorviewshape.uf1D_vectorviewshape = new Functions1D::GetShapeF1D(); return 0; diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_ChainingTimeStampF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_ChainingTimeStampF1D.cpp index be774a09d99..9b2d71a8c80 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_ChainingTimeStampF1D.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_ChainingTimeStampF1D.cpp @@ -26,9 +26,11 @@ static char ChainingTimeStampF1D___doc__[] = " :arg inter: An Interface1D object.\n" " :type inter: :class:`Interface1D`\n"; -static int ChainingTimeStampF1D___init__( BPy_ChainingTimeStampF1D* self, PyObject *args ) +static int ChainingTimeStampF1D___init__(BPy_ChainingTimeStampF1D* 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_uf1D_void.uf1D_void = new Functions1D::ChainingTimeStampF1D(); return 0; diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_IncrementChainingTimeStampF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_IncrementChainingTimeStampF1D.cpp index 2d1a1344c4b..a034e0ace48 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_IncrementChainingTimeStampF1D.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_IncrementChainingTimeStampF1D.cpp @@ -26,9 +26,11 @@ static char IncrementChainingTimeStampF1D___doc__[] = " :arg inter: An Interface1D object.\n" " :type inter: :class:`Interface1D`\n"; -static int IncrementChainingTimeStampF1D___init__( BPy_IncrementChainingTimeStampF1D* self, PyObject *args ) +static int IncrementChainingTimeStampF1D___init__(BPy_IncrementChainingTimeStampF1D* 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_uf1D_void.uf1D_void = new Functions1D::IncrementChainingTimeStampF1D(); return 0; diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_TimeStampF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_TimeStampF1D.cpp index c5311501098..a680dd01f11 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_TimeStampF1D.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_TimeStampF1D.cpp @@ -26,9 +26,11 @@ static char TimeStampF1D___doc__[] = " :arg inter: An Interface1D object.\n" " :type inter: :class:`Interface1D`\n"; -static int TimeStampF1D___init__( BPy_TimeStampF1D* self, PyObject *args ) +static int TimeStampF1D___init__(BPy_TimeStampF1D* 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_uf1D_void.uf1D_void = new Functions1D::TimeStampF1D(); return 0; -- cgit v1.2.3