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. --- .../intern/python/BPy_UnaryFunction1D.cpp | 47 +++++++++++++++------- 1 file changed, 32 insertions(+), 15 deletions(-) (limited to 'source/blender/freestyle/intern/python/BPy_UnaryFunction1D.cpp') diff --git a/source/blender/freestyle/intern/python/BPy_UnaryFunction1D.cpp b/source/blender/freestyle/intern/python/BPy_UnaryFunction1D.cpp index f4de9edb962..91c566dc369 100644 --- a/source/blender/freestyle/intern/python/BPy_UnaryFunction1D.cpp +++ b/source/blender/freestyle/intern/python/BPy_UnaryFunction1D.cpp @@ -16,24 +16,24 @@ extern "C" { /////////////////////////////////////////////////////////////////////////////////////////// //-------------------MODULE INITIALIZATION-------------------------------- -int UnaryFunction1D_Init( PyObject *module ) +int UnaryFunction1D_Init(PyObject *module) { - if( module == NULL ) + if (module == NULL) return -1; - if( PyType_Ready( &UnaryFunction1D_Type ) < 0 ) + if (PyType_Ready(&UnaryFunction1D_Type) < 0) return -1; - Py_INCREF( &UnaryFunction1D_Type ); + Py_INCREF(&UnaryFunction1D_Type); PyModule_AddObject(module, "UnaryFunction1D", (PyObject *)&UnaryFunction1D_Type); - UnaryFunction1DDouble_Init( module ); - UnaryFunction1DEdgeNature_Init( module ); - UnaryFunction1DFloat_Init( module ); - UnaryFunction1DUnsigned_Init( module ); - UnaryFunction1DVec2f_Init( module ); - UnaryFunction1DVec3f_Init( module ); - UnaryFunction1DVectorViewShape_Init( module ); - UnaryFunction1DVoid_Init( module ); + UnaryFunction1DDouble_Init(module); + UnaryFunction1DEdgeNature_Init(module); + UnaryFunction1DFloat_Init(module); + UnaryFunction1DUnsigned_Init(module); + UnaryFunction1DVec2f_Init(module); + UnaryFunction1DVec3f_Init(module); + UnaryFunction1DVectorViewShape_Init(module); + UnaryFunction1DVoid_Init(module); return 0; } @@ -59,14 +59,31 @@ static char UnaryFunction1D___doc__[] = static void UnaryFunction1D___dealloc__(BPy_UnaryFunction1D* self) { - Py_TYPE(self)->tp_free((PyObject*)self); + Py_TYPE(self)->tp_free((PyObject*)self); } static PyObject * UnaryFunction1D___repr__(BPy_UnaryFunction1D* self) { - return PyUnicode_FromString("UnaryFunction1D"); + return PyUnicode_FromString("UnaryFunction1D"); } +/*----------------------UnaryFunction1D get/setters ----------------------------*/ + +PyDoc_STRVAR(UnaryFunction1D_name_doc, +"The name of the unary 1D function.\n" +"\n" +":type: str"); + +static PyObject *UnaryFunction1D_name_get(BPy_UnaryFunction1D *self, void *UNUSED(closure)) +{ + return PyUnicode_FromString(Py_TYPE(self)->tp_name); +} + +static PyGetSetDef BPy_UnaryFunction1D_getseters[] = { + {(char *)"name", (getter)UnaryFunction1D_name_get, (setter)NULL, (char *)UnaryFunction1D_name_doc, NULL}, + {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ +}; + /*-----------------------BPy_UnaryFunction1D type definition ------------------------------*/ PyTypeObject UnaryFunction1D_Type = { @@ -99,7 +116,7 @@ PyTypeObject UnaryFunction1D_Type = { 0, /* tp_iternext */ 0, /* tp_methods */ 0, /* tp_members */ - 0, /* tp_getset */ + BPy_UnaryFunction1D_getseters, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ -- cgit v1.2.3