Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2013-02-22 06:48:41 +0400
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2013-02-22 06:48:41 +0400
commita4a7341aef2e772b7a233ade5dbccfbb959fd8e4 (patch)
tree0011931ebb83858aeb53b15f1b3ddc69bd4f71dd /source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec3f.cpp
parent33f34e1a7bc08f123d76198ae0671e3da1ded401 (diff)
Missing code updates in the previous commit.
Also improved __repr__() so that the .getName() is no longer necessary in user-defined Function0D and Function1D subclasses.
Diffstat (limited to 'source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec3f.cpp')
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec3f.cpp53
1 files changed, 18 insertions, 35 deletions
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec3f.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec3f.cpp
index 2f3c5d0f7e9..3474860a067 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec3f.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec3f.cpp
@@ -13,19 +13,19 @@ extern "C" {
//-------------------MODULE INITIALIZATION--------------------------------
-int UnaryFunction0DVec3f_Init( PyObject *module ) {
+int UnaryFunction0DVec3f_Init(PyObject *module) {
- if( module == NULL )
+ if (module == NULL)
return -1;
- if( PyType_Ready( &UnaryFunction0DVec3f_Type ) < 0 )
+ if (PyType_Ready(&UnaryFunction0DVec3f_Type) < 0)
return -1;
- Py_INCREF( &UnaryFunction0DVec3f_Type );
+ Py_INCREF(&UnaryFunction0DVec3f_Type);
PyModule_AddObject(module, "UnaryFunction0DVec3f", (PyObject *)&UnaryFunction0DVec3f_Type);
- if( PyType_Ready( &VertexOrientation3DF0D_Type ) < 0 )
+ if (PyType_Ready(&VertexOrientation3DF0D_Type) < 0)
return -1;
- Py_INCREF( &VertexOrientation3DF0D_Type );
+ Py_INCREF(&VertexOrientation3DF0D_Type);
PyModule_AddObject(module, "VertexOrientation3DF0D", (PyObject *)&VertexOrientation3DF0D_Type);
return 0;
@@ -45,8 +45,10 @@ static char UnaryFunction0DVec3f___doc__[] =
static int UnaryFunction0DVec3f___init__(BPy_UnaryFunction0DVec3f* self, PyObject *args, PyObject *kwds)
{
- if ( !PyArg_ParseTuple(args, "") )
- return -1;
+ static const char *kwlist[] = {NULL};
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist))
+ return -1;
self->uf0D_vec3f = new UnaryFunction0D<Vec3f>();
self->uf0D_vec3f->py_uf0D = (PyObject *)self;
return 0;
@@ -61,51 +63,32 @@ static void UnaryFunction0DVec3f___dealloc__(BPy_UnaryFunction0DVec3f* self)
static PyObject * UnaryFunction0DVec3f___repr__(BPy_UnaryFunction0DVec3f* self)
{
- return PyUnicode_FromFormat("type: %s - address: %p", self->uf0D_vec3f->getName().c_str(), self->uf0D_vec3f );
+ return PyUnicode_FromFormat("type: %s - address: %p", Py_TYPE(self)->tp_name, self->uf0D_vec3f);
}
-static char UnaryFunction0DVec3f_getName___doc__[] =
-".. method:: getName()\n"
-"\n"
-" Returns the name of the unary 0D predicate.\n"
-"\n"
-" :return: The name of the unary 0D predicate.\n"
-" :rtype: str\n";
-
-static PyObject * UnaryFunction0DVec3f_getName( BPy_UnaryFunction0DVec3f *self )
-{
- return PyUnicode_FromString( self->uf0D_vec3f->getName().c_str() );
-}
-
-static PyObject * UnaryFunction0DVec3f___call__( BPy_UnaryFunction0DVec3f *self, PyObject *args, PyObject *kwds)
+static PyObject * UnaryFunction0DVec3f___call__(BPy_UnaryFunction0DVec3f *self, PyObject *args, PyObject *kwds)
{
+ static const char *kwlist[] = {"it", NULL};
PyObject *obj;
- if( kwds != NULL ) {
- PyErr_SetString(PyExc_TypeError, "keyword argument(s) not supported");
- return NULL;
- }
- if(!PyArg_ParseTuple(args, "O!", &Interface0DIterator_Type, &obj))
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &Interface0DIterator_Type, &obj))
return NULL;
-
- if( typeid(*(self->uf0D_vec3f)) == typeid(UnaryFunction0D<Vec3f>) ) {
+
+ if (typeid(*(self->uf0D_vec3f)) == typeid(UnaryFunction0D<Vec3f>)) {
PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden");
return NULL;
}
- if (self->uf0D_vec3f->operator()(*( ((BPy_Interface0DIterator *) obj)->if0D_it )) < 0) {
+ if (self->uf0D_vec3f->operator()(*(((BPy_Interface0DIterator *)obj)->if0D_it)) < 0) {
if (!PyErr_Occurred()) {
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->uf0D_vec3f->result );
-
+ return Vector_from_Vec3f(self->uf0D_vec3f->result);
}
-/*----------------------UnaryFunction0DVec3f instance definitions ----------------------------*/
static PyMethodDef BPy_UnaryFunction0DVec3f_methods[] = {
- {"getName", ( PyCFunction ) UnaryFunction0DVec3f_getName, METH_NOARGS, UnaryFunction0DVec3f_getName___doc__},
{NULL, NULL, 0, NULL}
};