diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2009-03-21 01:41:27 +0300 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2009-03-21 01:41:27 +0300 |
commit | 0c7e5323e891e5b32b4bfae58115137e805adfeb (patch) | |
tree | a92d0320b3bef22e80683cf38d4b241a9e35806e /source/blender/freestyle/intern/python/UnaryFunction0D | |
parent | 6ba34d18b55bedbddb750e5231a2aec9a1fbbac0 (diff) |
Improvements in error handling at Python-C++ boundaries.
Diffstat (limited to 'source/blender/freestyle/intern/python/UnaryFunction0D')
10 files changed, 91 insertions, 53 deletions
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DDouble.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DDouble.cpp index 06de17f87e8..822ad6c22bd 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DDouble.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DDouble.cpp @@ -217,14 +217,17 @@ PyObject * UnaryFunction0DDouble___call__( BPy_UnaryFunction0DDouble *self, PyOb { PyObject *obj; - if(!PyArg_ParseTuple(args, "O!", &Interface0DIterator_Type, &obj)) { - cout << "ERROR: UnaryFunction0DDouble___call__ " << endl; + if(!PyArg_ParseTuple(args, "O!", &Interface0DIterator_Type, &obj)) return NULL; - } - double d = self->uf0D_double->operator()(*( ((BPy_Interface0DIterator *) obj)->if0D_it)); - - return PyFloat_FromDouble( d ); + if (self->uf0D_double->operator()(*( ((BPy_Interface0DIterator *) obj)->if0D_it)) < 0) { + if (!PyErr_Occurred()) { + string msg(self->uf0D_double->getName() + " __call__ method failed"); + PyErr_SetString(PyExc_RuntimeError, msg.c_str()); + } + return NULL; + } + return PyFloat_FromDouble( self->uf0D_double->result ); } diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.cpp index 3796cf64875..6e3ff1fde4b 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.cpp @@ -160,13 +160,17 @@ PyObject * UnaryFunction0DEdgeNature___call__( BPy_UnaryFunction0DEdgeNature *se { PyObject *obj; - if(!PyArg_ParseTuple(args, "O!", &Interface0DIterator_Type, &obj)) { - cout << "ERROR: UnaryFunction0DEdgeNature___call__ " << endl; + if(!PyArg_ParseTuple(args, "O!", &Interface0DIterator_Type, &obj)) return NULL; - } - Nature::EdgeNature n = self->uf0D_edgenature->operator()(*( ((BPy_Interface0DIterator *) obj)->if0D_it )); - return BPy_Nature_from_Nature( n ); + if (self->uf0D_edgenature->operator()(*( ((BPy_Interface0DIterator *) obj)->if0D_it )) < 0) { + if (!PyErr_Occurred()) { + string msg(self->uf0D_edgenature->getName() + " __call__ method failed"); + PyErr_SetString(PyExc_RuntimeError, msg.c_str()); + } + return NULL; + } + return BPy_Nature_from_Nature( self->uf0D_edgenature->result ); } diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DFloat.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DFloat.cpp index 8cb5d3832cc..d48ae5205f8 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DFloat.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DFloat.cpp @@ -189,13 +189,17 @@ PyObject * UnaryFunction0DFloat___call__( BPy_UnaryFunction0DFloat *self, PyObje { PyObject *obj; - if(!PyArg_ParseTuple(args, "O!", &Interface0DIterator_Type, &obj)) { - cout << "ERROR: UnaryFunction0DFloat___call__ " << endl; + if(!PyArg_ParseTuple(args, "O!", &Interface0DIterator_Type, &obj)) return NULL; - } - float f = self->uf0D_float->operator()(*( ((BPy_Interface0DIterator *) obj)->if0D_it )); - return PyFloat_FromDouble( f ); + if (self->uf0D_float->operator()(*( ((BPy_Interface0DIterator *) obj)->if0D_it )) < 0) { + if (!PyErr_Occurred()) { + string msg(self->uf0D_float->getName() + " __call__ method failed"); + PyErr_SetString(PyExc_RuntimeError, msg.c_str()); + } + return NULL; + } + return PyFloat_FromDouble( self->uf0D_float->result ); } diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DId.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DId.cpp index 0582329b8b0..cb988655825 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DId.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DId.cpp @@ -160,13 +160,17 @@ PyObject * UnaryFunction0DId___call__( BPy_UnaryFunction0DId *self, PyObject *ar { PyObject *obj; - if(!PyArg_ParseTuple(args, "O!", &Interface0DIterator_Type, &obj)) { - cout << "ERROR: UnaryFunction0DId___call__ " << endl; + if(!PyArg_ParseTuple(args, "O!", &Interface0DIterator_Type, &obj)) return NULL; - } - Id id( self->uf0D_id->operator()(*( ((BPy_Interface0DIterator *) obj)->if0D_it )) ); - return BPy_Id_from_Id( id ); + if (self->uf0D_id->operator()(*( ((BPy_Interface0DIterator *) obj)->if0D_it )) < 0) { + if (!PyErr_Occurred()) { + string msg(self->uf0D_id->getName() + " __call__ method failed"); + PyErr_SetString(PyExc_RuntimeError, msg.c_str()); + } + return NULL; + } + return BPy_Id_from_Id( self->uf0D_id->result ); } /////////////////////////////////////////////////////////////////////////////////////////// diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.cpp index 0006aa80d9d..10f3e493244 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.cpp @@ -160,13 +160,17 @@ PyObject * UnaryFunction0DMaterial___call__( BPy_UnaryFunction0DMaterial *self, { PyObject *obj; - if(!PyArg_ParseTuple(args, "O!", &Interface0DIterator_Type, &obj)) { - cout << "ERROR: UnaryFunction0DMaterial___call__ " << endl; + if(!PyArg_ParseTuple(args, "O!", &Interface0DIterator_Type, &obj)) return NULL; - } - FrsMaterial m( self->uf0D_material->operator()(*( ((BPy_Interface0DIterator *) obj)->if0D_it )) ); - return BPy_FrsMaterial_from_FrsMaterial( m ); + if (self->uf0D_material->operator()(*( ((BPy_Interface0DIterator *) obj)->if0D_it )) < 0) { + if (!PyErr_Occurred()) { + string msg(self->uf0D_material->getName() + " __call__ method failed"); + PyErr_SetString(PyExc_RuntimeError, msg.c_str()); + } + return NULL; + } + return BPy_FrsMaterial_from_FrsMaterial( self->uf0D_material->result ); } diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.cpp index 98cecfa1e77..754a432a336 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.cpp @@ -160,13 +160,17 @@ PyObject * UnaryFunction0DUnsigned___call__( BPy_UnaryFunction0DUnsigned *self, { PyObject *obj; - if(!PyArg_ParseTuple(args, "O!", &Interface0DIterator_Type, &obj)) { - cout << "ERROR: UnaryFunction0DUnsigned___call__ " << endl; + if(!PyArg_ParseTuple(args, "O!", &Interface0DIterator_Type, &obj)) return NULL; - } - unsigned int i = self->uf0D_unsigned->operator()(*( ((BPy_Interface0DIterator *) obj)->if0D_it )); - return PyInt_FromLong( i ); + if (self->uf0D_unsigned->operator()(*( ((BPy_Interface0DIterator *) obj)->if0D_it )) < 0) { + if (!PyErr_Occurred()) { + string msg(self->uf0D_unsigned->getName() + " __call__ method failed"); + PyErr_SetString(PyExc_RuntimeError, msg.c_str()); + } + return NULL; + } + return PyInt_FromLong( self->uf0D_unsigned->result ); } diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec2f.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec2f.cpp index 7efb3ff02fb..9a1c0ba1fd3 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec2f.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec2f.cpp @@ -165,13 +165,17 @@ PyObject * UnaryFunction0DVec2f_getName( BPy_UnaryFunction0DVec2f *self ) PyObject * UnaryFunction0DVec2f___call__( BPy_UnaryFunction0DVec2f *self, PyObject *args) { PyObject *obj; - if(!PyArg_ParseTuple(args, "O!", &Interface0DIterator_Type, &obj)) { - cout << "ERROR: UnaryFunction0DVec2f___call__ " << endl; + if(!PyArg_ParseTuple(args, "O!", &Interface0DIterator_Type, &obj)) return NULL; - } - Vec2f v( self->uf0D_vec2f->operator()(*( ((BPy_Interface0DIterator *) obj)->if0D_it )) ); - return Vector_from_Vec2f( v ); + if (self->uf0D_vec2f->operator()(*( ((BPy_Interface0DIterator *) obj)->if0D_it )) < 0) { + if (!PyErr_Occurred()) { + string msg(self->uf0D_vec2f->getName() + " __call__ method failed"); + PyErr_SetString(PyExc_RuntimeError, msg.c_str()); + } + return NULL; + } + return Vector_from_Vec2f( self->uf0D_vec2f->result ); } diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec3f.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec3f.cpp index 5f8f21208de..86360293c78 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec3f.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec3f.cpp @@ -160,13 +160,17 @@ PyObject * UnaryFunction0DVec3f___call__( BPy_UnaryFunction0DVec3f *self, PyObje { PyObject *obj; - if(!PyArg_ParseTuple(args, "O!", &Interface0DIterator_Type, &obj)) { - cout << "ERROR: UnaryFunction0DVec3f___call__ " << endl; + if(!PyArg_ParseTuple(args, "O!", &Interface0DIterator_Type, &obj)) return NULL; - } - Vec3f v( self->uf0D_vec3f->operator()(*( ((BPy_Interface0DIterator *) obj)->if0D_it )) ); - return Vector_from_Vec3f( v ); + if (self->uf0D_vec3f->operator()(*( ((BPy_Interface0DIterator *) obj)->if0D_it )) < 0) { + if (!PyErr_Occurred()) { + string msg(self->uf0D_vec3f->getName() + " __call__ method failed"); + PyErr_SetString(PyExc_RuntimeError, msg.c_str()); + } + return NULL; + } + return Vector_from_Vec3f( self->uf0D_vec3f->result ); } diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.cpp index 5620559ddc7..8a38db08e95 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.cpp @@ -160,17 +160,20 @@ PyObject * UnaryFunction0DVectorViewShape___call__( BPy_UnaryFunction0DVectorVie { PyObject *obj; - if(!PyArg_ParseTuple(args, "O!", &Interface0DIterator_Type, &obj)) { - cout << "ERROR: UnaryFunction0DVectorViewShape___call__ " << endl; + if(!PyArg_ParseTuple(args, "O!", &Interface0DIterator_Type, &obj)) + 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"); + PyErr_SetString(PyExc_RuntimeError, msg.c_str()); + } return NULL; } - - - std::vector<ViewShape*> vs( self->uf0D_vectorviewshape->operator()(*( ((BPy_Interface0DIterator *) obj)->if0D_it )) ); PyObject *list = PyList_New(NULL); - for( unsigned int i = 0; i < vs.size(); i++) - PyList_Append(list, BPy_ViewShape_from_ViewShape(*( vs[i] )) ); + for( unsigned int i = 0; i < self->uf0D_vectorviewshape->result.size(); i++) + PyList_Append(list, BPy_ViewShape_from_ViewShape(*( self->uf0D_vectorviewshape->result[i] )) ); return list; } diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DViewShape.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DViewShape.cpp index e636e554e21..abcbdbaebab 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DViewShape.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DViewShape.cpp @@ -166,13 +166,17 @@ PyObject * UnaryFunction0DViewShape___call__( BPy_UnaryFunction0DViewShape *self { PyObject *obj; - if(!PyArg_ParseTuple(args, "O!", &Interface0DIterator_Type, &obj)) { - cout << "ERROR: UnaryFunction0DViewShape___call__ " << endl; + if(!PyArg_ParseTuple(args, "O!", &Interface0DIterator_Type, &obj)) + 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"); + PyErr_SetString(PyExc_RuntimeError, msg.c_str()); + } return NULL; } - - ViewShape *vs = self->uf0D_viewshape->operator()(*( ((BPy_Interface0DIterator *) obj)->if0D_it )); - return BPy_ViewShape_from_ViewShape( *vs ); + return BPy_ViewShape_from_ViewShape( *(self->uf0D_viewshape->result) ); } |