diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2009-07-26 20:15:28 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2009-07-26 20:15:28 +0400 |
commit | 730fb1021c8b189229625866dac0f6e83db6418c (patch) | |
tree | 7985373b62cea17b3247a4e80842fbd372181058 /source/blender/freestyle/intern/python/UnaryFunction0D | |
parent | 78ce17fce88c23ba2c32b561bd9cc398a60a8278 (diff) |
Made predicate and function types callable in the sense that
callable(I, T) returns True when I is an object of a type T or
of a subtype of T. Also implemented a measure to avoid an
infinite loop when user-defined predicate and function classes
do not properly overload the __call__ method (including the
cases of directly instantiating the base classes such as
UnaryPredicate0D and BinaryPredicate1D).
Diffstat (limited to 'source/blender/freestyle/intern/python/UnaryFunction0D')
10 files changed, 111 insertions, 40 deletions
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DDouble.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DDouble.cpp index 822ad6c22bd..cfc4bb24a56 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DDouble.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DDouble.cpp @@ -28,12 +28,11 @@ static void UnaryFunction0DDouble___dealloc__(BPy_UnaryFunction0DDouble* self); static PyObject * UnaryFunction0DDouble___repr__(BPy_UnaryFunction0DDouble* self); static PyObject * UnaryFunction0DDouble_getName( BPy_UnaryFunction0DDouble *self); -static PyObject * UnaryFunction0DDouble___call__( BPy_UnaryFunction0DDouble *self, PyObject *args); +static PyObject * UnaryFunction0DDouble___call__( BPy_UnaryFunction0DDouble *self, PyObject *args, PyObject *kwds); /*----------------------UnaryFunction0DDouble instance definitions ----------------------------*/ static PyMethodDef BPy_UnaryFunction0DDouble_methods[] = { {"getName", ( PyCFunction ) UnaryFunction0DDouble_getName, METH_NOARGS, "( )Returns the string of the name of the unary 0D function."}, - {"__call__", ( PyCFunction ) UnaryFunction0DDouble___call__, METH_VARARGS, "(Interface0DIterator it )Executes the operator () on the iterator it pointing onto the point at which we wish to evaluate the function." }, {NULL, NULL, 0, NULL} }; @@ -63,7 +62,7 @@ PyTypeObject UnaryFunction0DDouble_Type = { /* More standard operations (here for binary compatibility) */ NULL, /* hashfunc tp_hash; */ - NULL, /* ternaryfunc tp_call; */ + (ternaryfunc)UnaryFunction0DDouble___call__, /* ternaryfunc tp_call; */ NULL, /* reprfunc tp_str; */ NULL, /* getattrofunc tp_getattro; */ NULL, /* setattrofunc tp_setattro; */ @@ -213,13 +212,21 @@ PyObject * UnaryFunction0DDouble_getName( BPy_UnaryFunction0DDouble *self ) return PyString_FromString( self->uf0D_double->getName().c_str() ); } -PyObject * UnaryFunction0DDouble___call__( BPy_UnaryFunction0DDouble *self, PyObject *args) +PyObject * UnaryFunction0DDouble___call__( BPy_UnaryFunction0DDouble *self, PyObject *args, PyObject *kwds) { PyObject *obj; + if( kwds != NULL ) { + PyErr_SetString(PyExc_TypeError, "keyword argument(s) not supported"); + return NULL; + } if(!PyArg_ParseTuple(args, "O!", &Interface0DIterator_Type, &obj)) return NULL; + if( typeid(*(self->uf0D_double)) == typeid(UnaryFunction0D<double>) ) { + PyErr_SetString(PyExc_TypeError, "__call__ method must be overloaded"); + return NULL; + } if (self->uf0D_double->operator()(*( ((BPy_Interface0DIterator *) obj)->if0D_it)) < 0) { if (!PyErr_Occurred()) { string msg(self->uf0D_double->getName() + " __call__ method failed"); diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.cpp index 6e3ff1fde4b..ac5b1257167 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.cpp @@ -17,12 +17,11 @@ static void UnaryFunction0DEdgeNature___dealloc__(BPy_UnaryFunction0DEdgeNature* static PyObject * UnaryFunction0DEdgeNature___repr__(BPy_UnaryFunction0DEdgeNature* self); static PyObject * UnaryFunction0DEdgeNature_getName( BPy_UnaryFunction0DEdgeNature *self); -static PyObject * UnaryFunction0DEdgeNature___call__( BPy_UnaryFunction0DEdgeNature *self, PyObject *args); +static PyObject * UnaryFunction0DEdgeNature___call__( BPy_UnaryFunction0DEdgeNature *self, PyObject *args, PyObject *kwds); /*----------------------UnaryFunction0DEdgeNature instance definitions ----------------------------*/ static PyMethodDef BPy_UnaryFunction0DEdgeNature_methods[] = { {"getName", ( PyCFunction ) UnaryFunction0DEdgeNature_getName, METH_NOARGS, "( )Returns the string of the name of the unary 0D function."}, - {"__call__", ( PyCFunction ) UnaryFunction0DEdgeNature___call__, METH_VARARGS, "(Interface0DIterator it )Executes the operator () on the iterator it pointing onto the point at which we wish to evaluate the function." }, {NULL, NULL, 0, NULL} }; @@ -52,7 +51,7 @@ PyTypeObject UnaryFunction0DEdgeNature_Type = { /* More standard operations (here for binary compatibility) */ NULL, /* hashfunc tp_hash; */ - NULL, /* ternaryfunc tp_call; */ + (ternaryfunc)UnaryFunction0DEdgeNature___call__, /* ternaryfunc tp_call; */ NULL, /* reprfunc tp_str; */ NULL, /* getattrofunc tp_getattro; */ NULL, /* setattrofunc tp_setattro; */ @@ -156,13 +155,21 @@ PyObject * UnaryFunction0DEdgeNature_getName( BPy_UnaryFunction0DEdgeNature *sel return PyString_FromString( self->uf0D_edgenature->getName().c_str() ); } -PyObject * UnaryFunction0DEdgeNature___call__( BPy_UnaryFunction0DEdgeNature *self, PyObject *args) +PyObject * UnaryFunction0DEdgeNature___call__( BPy_UnaryFunction0DEdgeNature *self, PyObject *args, PyObject *kwds) { PyObject *obj; + if( kwds != NULL ) { + PyErr_SetString(PyExc_TypeError, "keyword argument(s) not supported"); + return NULL; + } if(!PyArg_ParseTuple(args, "O!", &Interface0DIterator_Type, &obj)) return NULL; + if( typeid(*(self->uf0D_edgenature)) == typeid(UnaryFunction0D<Nature::EdgeNature>) ) { + PyErr_SetString(PyExc_TypeError, "__call__ method must be overloaded"); + return NULL; + } if (self->uf0D_edgenature->operator()(*( ((BPy_Interface0DIterator *) obj)->if0D_it )) < 0) { if (!PyErr_Occurred()) { string msg(self->uf0D_edgenature->getName() + " __call__ method failed"); diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DFloat.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DFloat.cpp index d48ae5205f8..13285bdcf88 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DFloat.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DFloat.cpp @@ -22,12 +22,11 @@ static void UnaryFunction0DFloat___dealloc__(BPy_UnaryFunction0DFloat* self); static PyObject * UnaryFunction0DFloat___repr__(BPy_UnaryFunction0DFloat* self); static PyObject * UnaryFunction0DFloat_getName( BPy_UnaryFunction0DFloat *self); -static PyObject * UnaryFunction0DFloat___call__( BPy_UnaryFunction0DFloat *self, PyObject *args); +static PyObject * UnaryFunction0DFloat___call__( BPy_UnaryFunction0DFloat *self, PyObject *args, PyObject *kwds); /*----------------------UnaryFunction0DFloat instance definitions ----------------------------*/ static PyMethodDef BPy_UnaryFunction0DFloat_methods[] = { {"getName", ( PyCFunction ) UnaryFunction0DFloat_getName, METH_NOARGS, "( )Returns the string of the name of the unary 0D function."}, - {"__call__", ( PyCFunction ) UnaryFunction0DFloat___call__, METH_VARARGS, "(Interface0DIterator it )Executes the operator () on the iterator it pointing onto the point at which we wish to evaluate the function." }, {NULL, NULL, 0, NULL} }; @@ -57,7 +56,7 @@ PyTypeObject UnaryFunction0DFloat_Type = { /* More standard operations (here for binary compatibility) */ NULL, /* hashfunc tp_hash; */ - NULL, /* ternaryfunc tp_call; */ + (ternaryfunc)UnaryFunction0DFloat___call__, /* ternaryfunc tp_call; */ NULL, /* reprfunc tp_str; */ NULL, /* getattrofunc tp_getattro; */ NULL, /* setattrofunc tp_setattro; */ @@ -185,13 +184,21 @@ PyObject * UnaryFunction0DFloat_getName( BPy_UnaryFunction0DFloat *self ) return PyString_FromString( self->uf0D_float->getName().c_str() ); } -PyObject * UnaryFunction0DFloat___call__( BPy_UnaryFunction0DFloat *self, PyObject *args) +PyObject * UnaryFunction0DFloat___call__( BPy_UnaryFunction0DFloat *self, PyObject *args, PyObject *kwds) { PyObject *obj; + if( kwds != NULL ) { + PyErr_SetString(PyExc_TypeError, "keyword argument(s) not supported"); + return NULL; + } if(!PyArg_ParseTuple(args, "O!", &Interface0DIterator_Type, &obj)) return NULL; + if( typeid(*(self->uf0D_float)) == typeid(UnaryFunction0D<float>) ) { + PyErr_SetString(PyExc_TypeError, "__call__ method must be overloaded"); + return NULL; + } if (self->uf0D_float->operator()(*( ((BPy_Interface0DIterator *) obj)->if0D_it )) < 0) { if (!PyErr_Occurred()) { string msg(self->uf0D_float->getName() + " __call__ method failed"); diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DId.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DId.cpp index cb988655825..15863eb3600 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DId.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DId.cpp @@ -17,12 +17,11 @@ static void UnaryFunction0DId___dealloc__(BPy_UnaryFunction0DId* self); static PyObject * UnaryFunction0DId___repr__(BPy_UnaryFunction0DId* self); static PyObject * UnaryFunction0DId_getName( BPy_UnaryFunction0DId *self); -static PyObject * UnaryFunction0DId___call__( BPy_UnaryFunction0DId *self, PyObject *args); +static PyObject * UnaryFunction0DId___call__( BPy_UnaryFunction0DId *self, PyObject *args, PyObject *kwds); /*----------------------UnaryFunction0DId instance definitions ----------------------------*/ static PyMethodDef BPy_UnaryFunction0DId_methods[] = { {"getName", ( PyCFunction ) UnaryFunction0DId_getName, METH_NOARGS, "( )Returns the string of the name of the unary 0D function."}, - {"__call__", ( PyCFunction ) UnaryFunction0DId___call__, METH_VARARGS, "(Interface0DIterator it )Executes the operator () on the iterator it pointing onto the point at which we wish to evaluate the function." }, {NULL, NULL, 0, NULL} }; @@ -52,7 +51,7 @@ PyTypeObject UnaryFunction0DId_Type = { /* More standard operations (here for binary compatibility) */ NULL, /* hashfunc tp_hash; */ - NULL, /* ternaryfunc tp_call; */ + (ternaryfunc)UnaryFunction0DId___call__, /* ternaryfunc tp_call; */ NULL, /* reprfunc tp_str; */ NULL, /* getattrofunc tp_getattro; */ NULL, /* setattrofunc tp_setattro; */ @@ -156,13 +155,21 @@ PyObject * UnaryFunction0DId_getName( BPy_UnaryFunction0DId *self ) return PyString_FromString( self->uf0D_id->getName().c_str() ); } -PyObject * UnaryFunction0DId___call__( BPy_UnaryFunction0DId *self, PyObject *args) +PyObject * UnaryFunction0DId___call__( BPy_UnaryFunction0DId *self, PyObject *args, PyObject *kwds) { PyObject *obj; + if( kwds != NULL ) { + PyErr_SetString(PyExc_TypeError, "keyword argument(s) not supported"); + return NULL; + } if(!PyArg_ParseTuple(args, "O!", &Interface0DIterator_Type, &obj)) return NULL; + if( typeid(*(self->uf0D_id)) == typeid(UnaryFunction0D<Id>) ) { + PyErr_SetString(PyExc_TypeError, "__call__ method must be overloaded"); + return NULL; + } if (self->uf0D_id->operator()(*( ((BPy_Interface0DIterator *) obj)->if0D_it )) < 0) { if (!PyErr_Occurred()) { string msg(self->uf0D_id->getName() + " __call__ method failed"); diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.cpp index 10f3e493244..bbb7e2d61a2 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.cpp @@ -17,12 +17,11 @@ static void UnaryFunction0DMaterial___dealloc__(BPy_UnaryFunction0DMaterial* sel static PyObject * UnaryFunction0DMaterial___repr__(BPy_UnaryFunction0DMaterial* self); static PyObject * UnaryFunction0DMaterial_getName( BPy_UnaryFunction0DMaterial *self); -static PyObject * UnaryFunction0DMaterial___call__( BPy_UnaryFunction0DMaterial *self, PyObject *args); +static PyObject * UnaryFunction0DMaterial___call__( BPy_UnaryFunction0DMaterial *self, PyObject *args, PyObject *kwds); /*----------------------UnaryFunction0DMaterial instance definitions ----------------------------*/ static PyMethodDef BPy_UnaryFunction0DMaterial_methods[] = { {"getName", ( PyCFunction ) UnaryFunction0DMaterial_getName, METH_NOARGS, "( )Returns the string of the name of the unary 0D function."}, - {"__call__", ( PyCFunction ) UnaryFunction0DMaterial___call__, METH_VARARGS, "(Interface0DIterator it )Executes the operator () on the iterator it pointing onto the point at which we wish to evaluate the function." }, {NULL, NULL, 0, NULL} }; @@ -52,7 +51,7 @@ PyTypeObject UnaryFunction0DMaterial_Type = { /* More standard operations (here for binary compatibility) */ NULL, /* hashfunc tp_hash; */ - NULL, /* ternaryfunc tp_call; */ + (ternaryfunc)UnaryFunction0DMaterial___call__, /* ternaryfunc tp_call; */ NULL, /* reprfunc tp_str; */ NULL, /* getattrofunc tp_getattro; */ NULL, /* setattrofunc tp_setattro; */ @@ -156,13 +155,21 @@ PyObject * UnaryFunction0DMaterial_getName( BPy_UnaryFunction0DMaterial *self ) return PyString_FromString( self->uf0D_material->getName().c_str() ); } -PyObject * UnaryFunction0DMaterial___call__( BPy_UnaryFunction0DMaterial *self, PyObject *args) +PyObject * UnaryFunction0DMaterial___call__( BPy_UnaryFunction0DMaterial *self, PyObject *args, PyObject *kwds) { PyObject *obj; + if( kwds != NULL ) { + PyErr_SetString(PyExc_TypeError, "keyword argument(s) not supported"); + return NULL; + } if(!PyArg_ParseTuple(args, "O!", &Interface0DIterator_Type, &obj)) return NULL; + if( typeid(*(self->uf0D_material)) == typeid(UnaryFunction0D<FrsMaterial>) ) { + PyErr_SetString(PyExc_TypeError, "__call__ method must be overloaded"); + return NULL; + } if (self->uf0D_material->operator()(*( ((BPy_Interface0DIterator *) obj)->if0D_it )) < 0) { if (!PyErr_Occurred()) { string msg(self->uf0D_material->getName() + " __call__ method failed"); diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.cpp index 754a432a336..1b8535318af 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.cpp @@ -17,12 +17,11 @@ static void UnaryFunction0DUnsigned___dealloc__(BPy_UnaryFunction0DUnsigned* sel static PyObject * UnaryFunction0DUnsigned___repr__(BPy_UnaryFunction0DUnsigned* self); static PyObject * UnaryFunction0DUnsigned_getName( BPy_UnaryFunction0DUnsigned *self); -static PyObject * UnaryFunction0DUnsigned___call__( BPy_UnaryFunction0DUnsigned *self, PyObject *args); +static PyObject * UnaryFunction0DUnsigned___call__( BPy_UnaryFunction0DUnsigned *self, PyObject *args, PyObject *kwds); /*----------------------UnaryFunction0DUnsigned instance definitions ----------------------------*/ static PyMethodDef BPy_UnaryFunction0DUnsigned_methods[] = { {"getName", ( PyCFunction ) UnaryFunction0DUnsigned_getName, METH_NOARGS, "( )Returns the string of the name of the unary 0D function."}, - {"__call__", ( PyCFunction ) UnaryFunction0DUnsigned___call__, METH_VARARGS, "(Interface0DIterator it )Executes the operator () on the iterator it pointing onto the point at which we wish to evaluate the function." }, {NULL, NULL, 0, NULL} }; @@ -52,7 +51,7 @@ PyTypeObject UnaryFunction0DUnsigned_Type = { /* More standard operations (here for binary compatibility) */ NULL, /* hashfunc tp_hash; */ - NULL, /* ternaryfunc tp_call; */ + (ternaryfunc)UnaryFunction0DUnsigned___call__, /* ternaryfunc tp_call; */ NULL, /* reprfunc tp_str; */ NULL, /* getattrofunc tp_getattro; */ NULL, /* setattrofunc tp_setattro; */ @@ -156,13 +155,21 @@ PyObject * UnaryFunction0DUnsigned_getName( BPy_UnaryFunction0DUnsigned *self ) return PyString_FromString( self->uf0D_unsigned->getName().c_str() ); } -PyObject * UnaryFunction0DUnsigned___call__( BPy_UnaryFunction0DUnsigned *self, PyObject *args) +PyObject * UnaryFunction0DUnsigned___call__( BPy_UnaryFunction0DUnsigned *self, PyObject *args, PyObject *kwds) { PyObject *obj; + if( kwds != NULL ) { + PyErr_SetString(PyExc_TypeError, "keyword argument(s) not supported"); + return NULL; + } if(!PyArg_ParseTuple(args, "O!", &Interface0DIterator_Type, &obj)) return NULL; + if( typeid(*(self->uf0D_unsigned)) == typeid(UnaryFunction0D<unsigned int>) ) { + PyErr_SetString(PyExc_TypeError, "__call__ method must be overloaded"); + return NULL; + } if (self->uf0D_unsigned->operator()(*( ((BPy_Interface0DIterator *) obj)->if0D_it )) < 0) { if (!PyErr_Occurred()) { string msg(self->uf0D_unsigned->getName() + " __call__ method failed"); diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec2f.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec2f.cpp index 9a1c0ba1fd3..a2bda09180a 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec2f.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec2f.cpp @@ -18,12 +18,11 @@ static void UnaryFunction0DVec2f___dealloc__(BPy_UnaryFunction0DVec2f* self); static PyObject * UnaryFunction0DVec2f___repr__(BPy_UnaryFunction0DVec2f* self); static PyObject * UnaryFunction0DVec2f_getName( BPy_UnaryFunction0DVec2f *self); -static PyObject * UnaryFunction0DVec2f___call__( BPy_UnaryFunction0DVec2f *self, PyObject *args); +static PyObject * UnaryFunction0DVec2f___call__( BPy_UnaryFunction0DVec2f *self, PyObject *args, PyObject *kwds); /*----------------------UnaryFunction0DVec2f instance definitions ----------------------------*/ static PyMethodDef BPy_UnaryFunction0DVec2f_methods[] = { {"getName", ( PyCFunction ) UnaryFunction0DVec2f_getName, METH_NOARGS, "( )Returns the string of the name of the unary 0D function."}, - {"__call__", ( PyCFunction ) UnaryFunction0DVec2f___call__, METH_VARARGS, "(Interface0DIterator it )Executes the operator () on the iterator it pointing onto the point at which we wish to evaluate the function." }, {NULL, NULL, 0, NULL} }; @@ -53,7 +52,7 @@ PyTypeObject UnaryFunction0DVec2f_Type = { /* More standard operations (here for binary compatibility) */ NULL, /* hashfunc tp_hash; */ - NULL, /* ternaryfunc tp_call; */ + (ternaryfunc)UnaryFunction0DVec2f___call__, /* ternaryfunc tp_call; */ NULL, /* reprfunc tp_str; */ NULL, /* getattrofunc tp_getattro; */ NULL, /* setattrofunc tp_setattro; */ @@ -162,12 +161,21 @@ PyObject * UnaryFunction0DVec2f_getName( BPy_UnaryFunction0DVec2f *self ) return PyString_FromString( self->uf0D_vec2f->getName().c_str() ); } -PyObject * UnaryFunction0DVec2f___call__( BPy_UnaryFunction0DVec2f *self, PyObject *args) +PyObject * UnaryFunction0DVec2f___call__( BPy_UnaryFunction0DVec2f *self, PyObject *args, PyObject *kwds) { PyObject *obj; + + if( kwds != NULL ) { + PyErr_SetString(PyExc_TypeError, "keyword argument(s) not supported"); + return NULL; + } if(!PyArg_ParseTuple(args, "O!", &Interface0DIterator_Type, &obj)) return NULL; + if( typeid(*(self->uf0D_vec2f)) == typeid(UnaryFunction0D<Vec2f>) ) { + PyErr_SetString(PyExc_TypeError, "__call__ method must be overloaded"); + return NULL; + } if (self->uf0D_vec2f->operator()(*( ((BPy_Interface0DIterator *) obj)->if0D_it )) < 0) { if (!PyErr_Occurred()) { string msg(self->uf0D_vec2f->getName() + " __call__ method failed"); diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec3f.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec3f.cpp index 86360293c78..b484d872627 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec3f.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec3f.cpp @@ -17,12 +17,11 @@ static void UnaryFunction0DVec3f___dealloc__(BPy_UnaryFunction0DVec3f* self); static PyObject * UnaryFunction0DVec3f___repr__(BPy_UnaryFunction0DVec3f* self); static PyObject * UnaryFunction0DVec3f_getName( BPy_UnaryFunction0DVec3f *self); -static PyObject * UnaryFunction0DVec3f___call__( BPy_UnaryFunction0DVec3f *self, PyObject *args); +static PyObject * UnaryFunction0DVec3f___call__( BPy_UnaryFunction0DVec3f *self, PyObject *args, PyObject *kwds); /*----------------------UnaryFunction0DVec3f instance definitions ----------------------------*/ static PyMethodDef BPy_UnaryFunction0DVec3f_methods[] = { {"getName", ( PyCFunction ) UnaryFunction0DVec3f_getName, METH_NOARGS, "( )Returns the string of the name of the unary 0D function."}, - {"__call__", ( PyCFunction ) UnaryFunction0DVec3f___call__, METH_VARARGS, "(Interface0DIterator it )Executes the operator () on the iterator it pointing onto the point at which we wish to evaluate the function." }, {NULL, NULL, 0, NULL} }; @@ -52,7 +51,7 @@ PyTypeObject UnaryFunction0DVec3f_Type = { /* More standard operations (here for binary compatibility) */ NULL, /* hashfunc tp_hash; */ - NULL, /* ternaryfunc tp_call; */ + (ternaryfunc)UnaryFunction0DVec3f___call__, /* ternaryfunc tp_call; */ NULL, /* reprfunc tp_str; */ NULL, /* getattrofunc tp_getattro; */ NULL, /* setattrofunc tp_setattro; */ @@ -156,13 +155,21 @@ PyObject * UnaryFunction0DVec3f_getName( BPy_UnaryFunction0DVec3f *self ) return PyString_FromString( self->uf0D_vec3f->getName().c_str() ); } -PyObject * UnaryFunction0DVec3f___call__( BPy_UnaryFunction0DVec3f *self, PyObject *args) +PyObject * UnaryFunction0DVec3f___call__( BPy_UnaryFunction0DVec3f *self, PyObject *args, PyObject *kwds) { PyObject *obj; + if( kwds != NULL ) { + PyErr_SetString(PyExc_TypeError, "keyword argument(s) not supported"); + return NULL; + } if(!PyArg_ParseTuple(args, "O!", &Interface0DIterator_Type, &obj)) return NULL; + if( typeid(*(self->uf0D_vec3f)) == typeid(UnaryFunction0D<Vec3f>) ) { + PyErr_SetString(PyExc_TypeError, "__call__ method must be overloaded"); + return NULL; + } if (self->uf0D_vec3f->operator()(*( ((BPy_Interface0DIterator *) obj)->if0D_it )) < 0) { if (!PyErr_Occurred()) { string msg(self->uf0D_vec3f->getName() + " __call__ method failed"); diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.cpp index 8a38db08e95..9640bf23e43 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.cpp @@ -17,12 +17,11 @@ static void UnaryFunction0DVectorViewShape___dealloc__(BPy_UnaryFunction0DVector static PyObject * UnaryFunction0DVectorViewShape___repr__(BPy_UnaryFunction0DVectorViewShape* self); static PyObject * UnaryFunction0DVectorViewShape_getName( BPy_UnaryFunction0DVectorViewShape *self); -static PyObject * UnaryFunction0DVectorViewShape___call__( BPy_UnaryFunction0DVectorViewShape *self, PyObject *args); +static PyObject * UnaryFunction0DVectorViewShape___call__( BPy_UnaryFunction0DVectorViewShape *self, PyObject *args, PyObject *kwds); /*----------------------UnaryFunction0DVectorViewShape instance definitions ----------------------------*/ static PyMethodDef BPy_UnaryFunction0DVectorViewShape_methods[] = { {"getName", ( PyCFunction ) UnaryFunction0DVectorViewShape_getName, METH_NOARGS, "( )Returns the string of the name of the unary 0D function."}, - {"__call__", ( PyCFunction ) UnaryFunction0DVectorViewShape___call__, METH_VARARGS, "(Interface0DIterator it )Executes the operator () on the iterator it pointing onto the point at which we wish to evaluate the function." }, {NULL, NULL, 0, NULL} }; @@ -52,7 +51,7 @@ PyTypeObject UnaryFunction0DVectorViewShape_Type = { /* More standard operations (here for binary compatibility) */ NULL, /* hashfunc tp_hash; */ - NULL, /* ternaryfunc tp_call; */ + (ternaryfunc)UnaryFunction0DVectorViewShape___call__, /* ternaryfunc tp_call; */ NULL, /* reprfunc tp_str; */ NULL, /* getattrofunc tp_getattro; */ NULL, /* setattrofunc tp_setattro; */ @@ -156,13 +155,21 @@ PyObject * UnaryFunction0DVectorViewShape_getName( BPy_UnaryFunction0DVectorView return PyString_FromString( self->uf0D_vectorviewshape->getName().c_str() ); } -PyObject * UnaryFunction0DVectorViewShape___call__( BPy_UnaryFunction0DVectorViewShape *self, PyObject *args) +PyObject * UnaryFunction0DVectorViewShape___call__( BPy_UnaryFunction0DVectorViewShape *self, PyObject *args, PyObject *kwds) { PyObject *obj; + if( kwds != NULL ) { + PyErr_SetString(PyExc_TypeError, "keyword argument(s) not supported"); + return NULL; + } if(!PyArg_ParseTuple(args, "O!", &Interface0DIterator_Type, &obj)) return NULL; + if( typeid(*(self->uf0D_vectorviewshape)) == typeid(UnaryFunction0D<std::vector<ViewShape*>>) ) { + PyErr_SetString(PyExc_TypeError, "__call__ method must be overloaded"); + return NULL; + } if (self->uf0D_vectorviewshape->operator()(*( ((BPy_Interface0DIterator *) obj)->if0D_it )) < 0) { if (!PyErr_Occurred()) { string msg(self->uf0D_vectorviewshape->getName() + " __call__ method failed"); diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DViewShape.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DViewShape.cpp index abcbdbaebab..d8be0411c9e 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DViewShape.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DViewShape.cpp @@ -18,12 +18,11 @@ static void UnaryFunction0DViewShape___dealloc__(BPy_UnaryFunction0DViewShape* s static PyObject * UnaryFunction0DViewShape___repr__(BPy_UnaryFunction0DViewShape* self); static PyObject * UnaryFunction0DViewShape_getName( BPy_UnaryFunction0DViewShape *self); -static PyObject * UnaryFunction0DViewShape___call__( BPy_UnaryFunction0DViewShape *self, PyObject *args); +static PyObject * UnaryFunction0DViewShape___call__( BPy_UnaryFunction0DViewShape *self, PyObject *args, PyObject *kwds); /*----------------------UnaryFunction0DViewShape instance definitions ----------------------------*/ static PyMethodDef BPy_UnaryFunction0DViewShape_methods[] = { {"getName", ( PyCFunction ) UnaryFunction0DViewShape_getName, METH_NOARGS, "( )Returns the string of the name of the unary 0D function."}, - {"__call__", ( PyCFunction ) UnaryFunction0DViewShape___call__, METH_VARARGS, "(Interface0DIterator it )Executes the operator () on the iterator it pointing onto the point at which we wish to evaluate the function." }, {NULL, NULL, 0, NULL} }; @@ -53,7 +52,7 @@ PyTypeObject UnaryFunction0DViewShape_Type = { /* More standard operations (here for binary compatibility) */ NULL, /* hashfunc tp_hash; */ - NULL, /* ternaryfunc tp_call; */ + (ternaryfunc)UnaryFunction0DViewShape___call__, /* ternaryfunc tp_call; */ NULL, /* reprfunc tp_str; */ NULL, /* getattrofunc tp_getattro; */ NULL, /* setattrofunc tp_setattro; */ @@ -162,13 +161,21 @@ PyObject * UnaryFunction0DViewShape_getName( BPy_UnaryFunction0DViewShape *self return PyString_FromString( self->uf0D_viewshape->getName().c_str() ); } -PyObject * UnaryFunction0DViewShape___call__( BPy_UnaryFunction0DViewShape *self, PyObject *args) +PyObject * UnaryFunction0DViewShape___call__( BPy_UnaryFunction0DViewShape *self, PyObject *args, PyObject *kwds) { PyObject *obj; + if( kwds != NULL ) { + PyErr_SetString(PyExc_TypeError, "keyword argument(s) not supported"); + return NULL; + } if(!PyArg_ParseTuple(args, "O!", &Interface0DIterator_Type, &obj)) return NULL; + if( typeid(*(self->uf0D_viewshape)) == typeid(UnaryFunction0D<ViewShape*>) ) { + PyErr_SetString(PyExc_TypeError, "__call__ method must be overloaded"); + return NULL; + } if (self->uf0D_viewshape->operator()(*( ((BPy_Interface0DIterator *) obj)->if0D_it )) < 0) { if (!PyErr_Occurred()) { string msg(self->uf0D_viewshape->getName() + " __call__ method failed"); |