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>2009-03-29 21:44:14 +0400
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2009-03-29 21:44:14 +0400
commit68e088f1cf3e3b8daa4a5d17acb6f0525ca6de95 (patch)
treea7b25263104f72f16d340119a09fcbcf29f8e695 /source/blender/freestyle/intern/python
parentd79ddebaaec697e1775a6f652a1ee064eb053bf4 (diff)
Improvements on error handling in the Python API.
Diffstat (limited to 'source/blender/freestyle/intern/python')
-rw-r--r--source/blender/freestyle/intern/python/BPy_Interface0D.cpp6
-rw-r--r--source/blender/freestyle/intern/python/BPy_Interface1D.cpp18
-rw-r--r--source/blender/freestyle/intern/python/BPy_SShape.cpp30
-rw-r--r--source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp95
-rw-r--r--source/blender/freestyle/intern/python/BPy_StrokeShader.cpp6
-rw-r--r--source/blender/freestyle/intern/python/BPy_ViewMap.cpp18
-rw-r--r--source/blender/freestyle/intern/python/BPy_ViewShape.cpp48
-rw-r--r--source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.cpp20
-rw-r--r--source/blender/freestyle/intern/python/Interface1D/Curve/BPy_Chain.cpp12
9 files changed, 105 insertions, 148 deletions
diff --git a/source/blender/freestyle/intern/python/BPy_Interface0D.cpp b/source/blender/freestyle/intern/python/BPy_Interface0D.cpp
index 78bd4176658..fb8c27c4205 100644
--- a/source/blender/freestyle/intern/python/BPy_Interface0D.cpp
+++ b/source/blender/freestyle/intern/python/BPy_Interface0D.cpp
@@ -249,10 +249,8 @@ PyObject *Interface0D_getPoint2D( BPy_Interface0D *self ) {
PyObject *Interface0D_getFEdge( BPy_Interface0D *self, PyObject *args ) {
PyObject *py_if0D;
- if(!( PyArg_ParseTuple(args, "O", &py_if0D) && BPy_Interface0D_Check(py_if0D) )) {
- cout << "ERROR: Interface0D_getFEdge" << endl;
- Py_RETURN_NONE;
- }
+ if(!( PyArg_ParseTuple(args, "O!", &Interface0D_Type, &py_if0D) ))
+ return NULL;
FEdge *fe = self->if0D->getFEdge(*( ((BPy_Interface0D *) py_if0D)->if0D ));
if( fe )
diff --git a/source/blender/freestyle/intern/python/BPy_Interface1D.cpp b/source/blender/freestyle/intern/python/BPy_Interface1D.cpp
index cfa9c3066a1..b6a6501c540 100644
--- a/source/blender/freestyle/intern/python/BPy_Interface1D.cpp
+++ b/source/blender/freestyle/intern/python/BPy_Interface1D.cpp
@@ -246,10 +246,8 @@ PyObject *Interface1D_getTimeStamp( BPy_Interface1D *self ) {
PyObject *Interface1D_setTimeStamp( BPy_Interface1D *self, PyObject *args) {
int timestamp = 0 ;
- if( !PyArg_ParseTuple(args, (char *)"i", &timestamp) ) {
- cout << "ERROR: Interface1D_setTimeStamp" << endl;
- Py_RETURN_NONE;
- }
+ if( !PyArg_ParseTuple(args, "i", &timestamp) )
+ return NULL;
self->if1D->setTimeStamp( timestamp );
@@ -270,10 +268,8 @@ PyObject * Interface1D_verticesEnd( BPy_Interface1D *self ) {
PyObject * Interface1D_pointsBegin( BPy_Interface1D *self, PyObject *args ) {
float f = 0;
- if(!( PyArg_ParseTuple(args, "|f", &f) )) {
- cout << "ERROR: Interface1D_pointsBegin" << endl;
- Py_RETURN_NONE;
- }
+ if(!( PyArg_ParseTuple(args, "|f", &f) ))
+ return NULL;
Interface0DIterator if0D_it( self->if1D->pointsBegin(f) );
return BPy_Interface0DIterator_from_Interface0DIterator( if0D_it );
@@ -282,10 +278,8 @@ PyObject * Interface1D_pointsBegin( BPy_Interface1D *self, PyObject *args ) {
PyObject * Interface1D_pointsEnd( BPy_Interface1D *self, PyObject *args ) {
float f = 0;
- if(!( PyArg_ParseTuple(args, "|f", &f) )) {
- cout << "ERROR: Interface1D_pointsEnd" << endl;
- Py_RETURN_NONE;
- }
+ if(!( PyArg_ParseTuple(args, "|f", &f) ))
+ return NULL;
Interface0DIterator if0D_it( self->if1D->pointsEnd(f) );
return BPy_Interface0DIterator_from_Interface0DIterator( if0D_it );
diff --git a/source/blender/freestyle/intern/python/BPy_SShape.cpp b/source/blender/freestyle/intern/python/BPy_SShape.cpp
index 529090d5815..1ba6c6a7f48 100644
--- a/source/blender/freestyle/intern/python/BPy_SShape.cpp
+++ b/source/blender/freestyle/intern/python/BPy_SShape.cpp
@@ -144,15 +144,15 @@ PyMODINIT_FUNC SShape_Init( PyObject *module )
int SShape___init__(BPy_SShape *self, PyObject *args, PyObject *kwds)
{
- PyObject *obj;
+ PyObject *obj = NULL;
- if (! PyArg_ParseTuple(args, "|O", &obj) )
+ if (! PyArg_ParseTuple(args, "|O!", &SShape_Type, &obj) )
return -1;
if( !obj ) {
self->ss = new SShape();
- } else if( BPy_SShape_Check(obj) ) {
+ } else {
self->ss = new SShape(*( ((BPy_SShape *) obj)->ss ));
}
@@ -173,10 +173,8 @@ PyObject * SShape___repr__(BPy_SShape *self)
PyObject * SShape_AddEdge( BPy_SShape *self , PyObject *args) {
PyObject *py_fe = 0;
- if(!( PyArg_ParseTuple(args, "O", &py_fe) && BPy_FEdge_Check(py_fe) )) {
- cout << "ERROR: SShape_AddEdge" << endl;
- Py_RETURN_NONE;
- }
+ if(!( PyArg_ParseTuple(args, "O!", &FEdge_Type, &py_fe) ))
+ return NULL;
self->ss->AddEdge( ((BPy_FEdge *) py_fe)->fe );
@@ -186,10 +184,8 @@ PyObject * SShape_AddEdge( BPy_SShape *self , PyObject *args) {
PyObject * SShape_AddNewVertex( BPy_SShape *self , PyObject *args) {
PyObject *py_sv = 0;
- if(!( PyArg_ParseTuple(args, "O", &py_sv) && BPy_SVertex_Check(py_sv) )) {
- cout << "ERROR: SShape_AddNewVertex" << endl;
- Py_RETURN_NONE;
- }
+ if(!( PyArg_ParseTuple(args, "O1", &SVertex_Type, &py_sv) ))
+ return NULL;
self->ss->AddNewVertex( ((BPy_SVertex *) py_sv)->sv );
@@ -199,10 +195,8 @@ PyObject * SShape_AddNewVertex( BPy_SShape *self , PyObject *args) {
PyObject * SShape_setBBox( BPy_SShape *self , PyObject *args) {
PyObject *py_bb = 0;
- if(!( PyArg_ParseTuple(args, "O", &py_bb) && BPy_BBox_Check(py_bb) )) {
- cout << "ERROR: SShape_SetBBox" << endl;
- Py_RETURN_NONE;
- }
+ if(!( PyArg_ParseTuple(args, "O!", &BBox_Type, &py_bb) ))
+ return NULL;
self->ss->setBBox(*( ((BPy_BBox*) py_bb)->bb ));
@@ -256,10 +250,8 @@ PyObject * SShape_getId( BPy_SShape *self ) {
PyObject * SShape_setId( BPy_SShape *self , PyObject *args) {
PyObject *py_id;
- if(!( PyArg_ParseTuple(args, "O", &py_id) && BPy_Id_Check(py_id) )) {
- cout << "ERROR: SShape_setId" << endl;
- Py_RETURN_NONE;
- }
+ if(!( PyArg_ParseTuple(args, "O!", &Id_Type, &py_id) ))
+ return NULL;
self->ss->setId(*( ((BPy_Id *) py_id)->id ));
diff --git a/source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp b/source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp
index cc4c8288233..73e073256f2 100644
--- a/source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp
+++ b/source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp
@@ -196,6 +196,7 @@ int StrokeAttribute___init__(BPy_StrokeAttribute *self, PyObject *args, PyObject
PyFloat_AsDouble( obj6 ) );
} else {
+ PyErr_SetString(PyExc_TypeError, "invalid arguments");
return -1;
}
@@ -266,10 +267,8 @@ PyObject *StrokeAttribute_isVisible( BPy_StrokeAttribute *self ) {
PyObject *StrokeAttribute_getAttributeReal( BPy_StrokeAttribute *self, PyObject *args ) {
char *attr;
- if(!( PyArg_ParseTuple(args, "s", &attr) )) {
- cout << "ERROR: StrokeAttribute_getAttributeReal" << endl;
- Py_RETURN_NONE;
- }
+ if(!( PyArg_ParseTuple(args, "s", &attr) ))
+ return NULL;
double a = self->sa->getAttributeReal( attr );
return PyFloat_FromDouble( a );
@@ -278,10 +277,8 @@ PyObject *StrokeAttribute_getAttributeReal( BPy_StrokeAttribute *self, PyObject
PyObject *StrokeAttribute_getAttributeVec2f( BPy_StrokeAttribute *self, PyObject *args ) {
char *attr;
- if(!( PyArg_ParseTuple(args, "s", &attr) )) {
- cout << "ERROR: StrokeAttribute_getAttributeVec2f" << endl;
- Py_RETURN_NONE;
- }
+ if(!( PyArg_ParseTuple(args, "s", &attr) ))
+ return NULL;
Vec2f a = self->sa->getAttributeVec2f( attr );
return Vector_from_Vec2f( a );
@@ -291,10 +288,8 @@ PyObject *StrokeAttribute_getAttributeVec2f( BPy_StrokeAttribute *self, PyObject
PyObject *StrokeAttribute_getAttributeVec3f( BPy_StrokeAttribute *self, PyObject *args ) {
char *attr;
- if(!( PyArg_ParseTuple(args, "s", &attr) )) {
- cout << "ERROR: StrokeAttribute_getAttributeVec3f" << endl;
- Py_RETURN_NONE;
- }
+ if(!( PyArg_ParseTuple(args, "s", &attr) ))
+ return NULL;
Vec3f a = self->sa->getAttributeVec3f( attr );
return Vector_from_Vec3f( a );
@@ -303,10 +298,8 @@ PyObject *StrokeAttribute_getAttributeVec3f( BPy_StrokeAttribute *self, PyObject
PyObject *StrokeAttribute_isAttributeAvailableReal( BPy_StrokeAttribute *self, PyObject *args ) {
char *attr;
- if(!( PyArg_ParseTuple(args, "s", &attr) )) {
- cout << "ERROR: StrokeAttribute_isAttributeAvailableReal" << endl;
- Py_RETURN_NONE;
- }
+ if(!( PyArg_ParseTuple(args, "s", &attr) ))
+ return NULL;
return PyBool_from_bool( self->sa->isAttributeAvailableReal( attr ) );
}
@@ -314,10 +307,8 @@ PyObject *StrokeAttribute_isAttributeAvailableReal( BPy_StrokeAttribute *self, P
PyObject *StrokeAttribute_isAttributeAvailableVec2f( BPy_StrokeAttribute *self, PyObject *args ) {
char *attr;
- if(!( PyArg_ParseTuple(args, "s", &attr) )) {
- cout << "ERROR: StrokeAttribute_isAttributeAvailableVec2f" << endl;
- Py_RETURN_NONE;
- }
+ if(!( PyArg_ParseTuple(args, "s", &attr) ))
+ return NULL;
return PyBool_from_bool( self->sa->isAttributeAvailableVec2f( attr ) );
}
@@ -325,10 +316,8 @@ PyObject *StrokeAttribute_isAttributeAvailableVec2f( BPy_StrokeAttribute *self,
PyObject *StrokeAttribute_isAttributeAvailableVec3f( BPy_StrokeAttribute *self, PyObject *args ) {
char *attr;
- if(!( PyArg_ParseTuple(args, "s", &attr) )) {
- cout << "ERROR: StrokeAttribute_isAttributeAvailableVec3f" << endl;
- Py_RETURN_NONE;
- }
+ if(!( PyArg_ParseTuple(args, "s", &attr) ))
+ return NULL;
return PyBool_from_bool( self->sa->isAttributeAvailableVec3f( attr ) );
}
@@ -337,10 +326,8 @@ PyObject *StrokeAttribute_isAttributeAvailableVec3f( BPy_StrokeAttribute *self,
PyObject * StrokeAttribute_setColor( BPy_StrokeAttribute *self, PyObject *args ) {
PyObject *obj1 = 0, *obj2 = 0, *obj3 = 0 ;
- if(!( PyArg_ParseTuple(args, "O|OO", &obj1, &obj2, &obj3) )) {
- cout << "ERROR: StrokeAttribute_setColor" << endl;
- Py_RETURN_NONE;
- }
+ if(!( PyArg_ParseTuple(args, "O|OO", &obj1, &obj2, &obj3) ))
+ return NULL;
if( PyList_Check(obj1) && !obj2 && !obj3 ){
@@ -355,6 +342,10 @@ PyObject * StrokeAttribute_setColor( BPy_StrokeAttribute *self, PyObject *args )
self->sa->setColor( PyFloat_AsDouble(obj1),
PyFloat_AsDouble(obj2),
PyFloat_AsDouble(obj3) );
+
+ } else {
+ PyErr_SetString(PyExc_TypeError, "invalid arguments");
+ return NULL;
}
Py_RETURN_NONE;
@@ -363,10 +354,8 @@ PyObject * StrokeAttribute_setColor( BPy_StrokeAttribute *self, PyObject *args )
PyObject * StrokeAttribute_setAlpha( BPy_StrokeAttribute *self, PyObject *args ){
float f = 0;
- if(!( PyArg_ParseTuple(args, "f", &f) )) {
- cout << "ERROR: StrokeAttribute_setAlpha" << endl;
- Py_RETURN_NONE;
- }
+ if(!( PyArg_ParseTuple(args, "f", &f) ))
+ return NULL;
self->sa->setAlpha( f );
Py_RETURN_NONE;
@@ -375,10 +364,8 @@ PyObject * StrokeAttribute_setAlpha( BPy_StrokeAttribute *self, PyObject *args )
PyObject * StrokeAttribute_setThickness( BPy_StrokeAttribute *self, PyObject *args ) {
PyObject *obj1 = 0, *obj2 = 0;
- if(!( PyArg_ParseTuple(args, "O|O", &obj1, &obj2) )) {
- cout << "ERROR: StrokeAttribute_setThickness" << endl;
- Py_RETURN_NONE;
- }
+ if(!( PyArg_ParseTuple(args, "O|O", &obj1, &obj2) ))
+ return NULL;
if( PyList_Check(obj1) && !obj2 ){
@@ -391,6 +378,10 @@ PyObject * StrokeAttribute_setThickness( BPy_StrokeAttribute *self, PyObject *ar
self->sa->setThickness( PyFloat_AsDouble(obj1),
PyFloat_AsDouble(obj2) );
+
+ } else {
+ PyErr_SetString(PyExc_TypeError, "invalid arguments");
+ return NULL;
}
Py_RETURN_NONE;
@@ -399,10 +390,8 @@ PyObject * StrokeAttribute_setThickness( BPy_StrokeAttribute *self, PyObject *ar
PyObject * StrokeAttribute_setVisible( BPy_StrokeAttribute *self, PyObject *args ) {
PyObject *py_b;
- if(!( PyArg_ParseTuple(args, "O", &py_b) && PyBool_Check(py_b) )) {
- cout << "ERROR: StrokeAttribute_setVisible" << endl;
- Py_RETURN_NONE;
- }
+ if(!( PyArg_ParseTuple(args, "O!", &PyBool_Type, &py_b) ))
+ return NULL;
self->sa->setVisible( bool_from_PyBool(py_b) );
@@ -414,10 +403,8 @@ PyObject * StrokeAttribute_setAttributeReal( BPy_StrokeAttribute *self, PyObject
char *s = 0;
double d = 0;
- if(!( PyArg_ParseTuple(args, "sd", &s, &d) )) {
- cout << "ERROR: StrokeAttribute_setAttributeReal" << endl;
- Py_RETURN_NONE;
- }
+ if(!( PyArg_ParseTuple(args, "sd", &s, &d) ))
+ return NULL;
self->sa->setAttributeReal( s, d );
Py_RETURN_NONE;
@@ -427,10 +414,8 @@ PyObject * StrokeAttribute_setAttributeVec2f( BPy_StrokeAttribute *self, PyObjec
char *s;
PyObject *obj = 0;
- if(!( PyArg_ParseTuple(args, "sO", &s, &obj) )) {
- cout << "ERROR: StrokeAttribute_setAttributeVec2f" << endl;
- Py_RETURN_NONE;
- }
+ if(!( PyArg_ParseTuple(args, "sO", &s, &obj) ))
+ return NULL;
if( PyList_Check(obj) && PyList_Size(obj) > 1) {
@@ -438,6 +423,10 @@ PyObject * StrokeAttribute_setAttributeVec2f( BPy_StrokeAttribute *self, PyObjec
PyFloat_AsDouble( PyList_GetItem(obj, 1) ) );
self->sa->setAttributeVec2f( s, v );
+
+ } else {
+ PyErr_SetString(PyExc_TypeError, "invalid arguments");
+ return NULL;
}
Py_RETURN_NONE;
@@ -447,10 +436,8 @@ PyObject * StrokeAttribute_setAttributeVec3f( BPy_StrokeAttribute *self, PyObjec
char *s;
PyObject *obj = 0;
- if(!( PyArg_ParseTuple(args, "sO", &s, &obj) )) {
- cout << "ERROR: StrokeAttribute_setAttributeVec3f" << endl;
- Py_RETURN_NONE;
- }
+ if(!( PyArg_ParseTuple(args, "sO", &s, &obj) ))
+ return NULL;
if( PyList_Check(obj) && PyList_Size(obj) > 2 ) {
@@ -459,6 +446,10 @@ PyObject * StrokeAttribute_setAttributeVec3f( BPy_StrokeAttribute *self, PyObjec
PyFloat_AsDouble( PyList_GetItem(obj, 2) ) );
self->sa->setAttributeVec3f( s, v );
+
+ } else {
+ PyErr_SetString(PyExc_TypeError, "invalid arguments");
+ return NULL;
}
Py_RETURN_NONE;
diff --git a/source/blender/freestyle/intern/python/BPy_StrokeShader.cpp b/source/blender/freestyle/intern/python/BPy_StrokeShader.cpp
index 6560bda3167..f18620888f0 100644
--- a/source/blender/freestyle/intern/python/BPy_StrokeShader.cpp
+++ b/source/blender/freestyle/intern/python/BPy_StrokeShader.cpp
@@ -285,10 +285,8 @@ PyObject * StrokeShader_getName( BPy_StrokeShader *self, PyObject *args)
PyObject *StrokeShader_shade( BPy_StrokeShader *self , PyObject *args) {
PyObject *py_s = 0;
- if(!( PyArg_ParseTuple(args, "O", &py_s) && BPy_Stroke_Check(py_s) )) {
- cout << "ERROR: StrokeShader_shade" << endl;
- Py_RETURN_NONE;
- }
+ if(!( PyArg_ParseTuple(args, "O!", &Stroke_Type, &py_s) ))
+ return NULL;
self->ss->shade(*( ((BPy_Stroke *) py_s)->s ));
diff --git a/source/blender/freestyle/intern/python/BPy_ViewMap.cpp b/source/blender/freestyle/intern/python/BPy_ViewMap.cpp
index c010236964a..0203a093d74 100644
--- a/source/blender/freestyle/intern/python/BPy_ViewMap.cpp
+++ b/source/blender/freestyle/intern/python/BPy_ViewMap.cpp
@@ -150,10 +150,8 @@ PyObject * ViewMap___repr__(BPy_ViewMap *self)
PyObject * ViewMap_getClosestViewEdge( BPy_ViewMap *self , PyObject *args) {
double x, y;
- if(!( PyArg_ParseTuple(args, "dd", &x, &y) )) {
- cout << "ERROR: ViewMap_getClosestFEdge" << endl;
- Py_RETURN_NONE;
- }
+ if(!( PyArg_ParseTuple(args, "dd", &x, &y) ))
+ return NULL;
ViewEdge *ve = const_cast<ViewEdge *>( self->vm->getClosestViewEdge(x,y) );
if( ve )
@@ -165,10 +163,8 @@ PyObject * ViewMap_getClosestViewEdge( BPy_ViewMap *self , PyObject *args) {
PyObject * ViewMap_getClosestFEdge( BPy_ViewMap *self , PyObject *args) {
double x, y;
- if(!( PyArg_ParseTuple(args, "dd", &x, &y) )) {
- cout << "ERROR: ViewMap_getClosestFEdge" << endl;
- Py_RETURN_NONE;
- }
+ if(!( PyArg_ParseTuple(args, "dd", &x, &y) ))
+ return NULL;
FEdge *fe = const_cast<FEdge *>( self->vm->getClosestFEdge(x,y) );
if( fe )
@@ -185,10 +181,8 @@ PyObject * ViewMap_getScene3dBBox( BPy_ViewMap *self , PyObject *args) {
PyObject * ViewMap_setScene3dBBox( BPy_ViewMap *self , PyObject *args) {
PyObject *py_bb = 0;
- if(!( PyArg_ParseTuple(args, "O", &py_bb) && BPy_BBox_Check(py_bb) )) {
- cout << "ERROR: ViewMap_setScene3dBBox" << endl;
- Py_RETURN_NONE;
- }
+ if(!( PyArg_ParseTuple(args, "O!", &BBox_Type, &py_bb) ))
+ return NULL;
self->vm->setScene3dBBox(*( ((BPy_BBox *) py_bb)->bb ));
diff --git a/source/blender/freestyle/intern/python/BPy_ViewShape.cpp b/source/blender/freestyle/intern/python/BPy_ViewShape.cpp
index fd676c54c7b..09803b45aa5 100644
--- a/source/blender/freestyle/intern/python/BPy_ViewShape.cpp
+++ b/source/blender/freestyle/intern/python/BPy_ViewShape.cpp
@@ -150,11 +150,15 @@ int ViewShape___init__(BPy_ViewShape *self, PyObject *args, PyObject *kwds)
if( !obj ) {
self->vs = new ViewShape();
- } else if( BPy_ViewShape_Check(obj) ) {
+ } else if( BPy_SShape_Check(obj) ) {
self->vs = new ViewShape( ((BPy_SShape *) obj)->ss );
} else if( BPy_ViewShape_Check(obj) ) {
self->vs = new ViewShape(*( ((BPy_ViewShape *) obj)->vs ));
+
+ } else {
+ PyErr_SetString(PyExc_TypeError, "invalid argument");
+ return -1;
}
return 0;
@@ -212,10 +216,8 @@ PyObject * ViewShape_getId( BPy_ViewShape *self ) {
PyObject * ViewShape_setSShape( BPy_ViewShape *self , PyObject *args) {
PyObject *py_ss = 0;
- if(!( PyArg_ParseTuple(args, "O", &py_ss) && BPy_SShape_Check(py_ss) )) {
- cout << "ERROR: ViewShape_SetSShape" << endl;
- Py_RETURN_NONE;
- }
+ if(!( PyArg_ParseTuple(args, "O!", &SShape_Type, &py_ss) ))
+ return NULL;
self->vs->setSShape( ((BPy_SShape *) py_ss)->ss );
@@ -226,10 +228,8 @@ PyObject * ViewShape_setVertices( BPy_ViewShape *self , PyObject *args) {
PyObject *list = 0;
PyObject *tmp;
- if(!( PyArg_ParseTuple(args, "O", &list) && PyList_Check(list) )) {
- cout << "ERROR: ViewShape_SetVertices" << endl;
- Py_RETURN_NONE;
- }
+ if(!( PyArg_ParseTuple(args, "O!", &PyList_Type, &list) ))
+ return NULL;
vector< ViewVertex *> v;
@@ -237,8 +237,10 @@ PyObject * ViewShape_setVertices( BPy_ViewShape *self , PyObject *args) {
tmp = PyList_GetItem(list, i);
if( BPy_ViewVertex_Check(tmp) )
v.push_back( ((BPy_ViewVertex *) tmp)->vv );
- else
- Py_RETURN_NONE;
+ else {
+ PyErr_SetString(PyExc_TypeError, "argument must be list of ViewVertex objects");
+ return NULL;
+ }
}
self->vs->setVertices( v );
@@ -250,10 +252,8 @@ PyObject * ViewShape_setEdges( BPy_ViewShape *self , PyObject *args) {
PyObject *list = 0;
PyObject *tmp;
- if(!( PyArg_ParseTuple(args, "O", &list) && PyList_Check(list) )) {
- cout << "ERROR: ViewShape_SetVertices" << endl;
- Py_RETURN_NONE;
- }
+ if(!( PyArg_ParseTuple(args, "O!", &PyList_Type, &list) ))
+ return NULL;
vector<ViewEdge *> v;
@@ -261,8 +261,10 @@ PyObject * ViewShape_setEdges( BPy_ViewShape *self , PyObject *args) {
tmp = PyList_GetItem(list, i);
if( BPy_ViewEdge_Check(tmp) )
v.push_back( ((BPy_ViewEdge *) tmp)->ve );
- else
- Py_RETURN_NONE;
+ else {
+ PyErr_SetString(PyExc_TypeError, "argument must be list of ViewEdge objects");
+ return NULL;
+ }
}
self->vs->setEdges( v );
@@ -273,10 +275,8 @@ PyObject * ViewShape_setEdges( BPy_ViewShape *self , PyObject *args) {
PyObject * ViewShape_AddEdge( BPy_ViewShape *self , PyObject *args) {
PyObject *py_ve = 0;
- if(!( PyArg_ParseTuple(args, "O", &py_ve) && BPy_ViewEdge_Check(py_ve) )) {
- cout << "ERROR: ViewShape_AddEdge" << endl;
- Py_RETURN_NONE;
- }
+ if(!( PyArg_ParseTuple(args, "O!", &ViewEdge_Type, &py_ve) ))
+ return NULL;
self->vs->AddEdge( ((BPy_ViewEdge *) py_ve)->ve );
@@ -286,10 +286,8 @@ PyObject * ViewShape_AddEdge( BPy_ViewShape *self , PyObject *args) {
PyObject * ViewShape_AddVertex( BPy_ViewShape *self , PyObject *args) {
PyObject *py_vv = 0;
- if(!( PyArg_ParseTuple(args, "O", &py_vv) && BPy_ViewVertex_Check(py_vv) )) {
- cout << "ERROR: ViewShape_AddNewVertex" << endl;
- Py_RETURN_NONE;
- }
+ if(!( PyArg_ParseTuple(args, "O!", &ViewVertex_Type, &py_vv) ))
+ return NULL;
self->vs->AddVertex( ((BPy_ViewVertex *) py_vv)->vv );
diff --git a/source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.cpp b/source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.cpp
index cb2e30f841a..5c739f9cd29 100644
--- a/source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.cpp
+++ b/source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.cpp
@@ -143,9 +143,11 @@ int CurvePoint___init__(BPy_CurvePoint *self, PyObject *args, PyObject *kwds)
((BPy_CurvePoint *) obj2)->cp,
PyFloat_AsDouble( obj3 ) );
} else {
+ PyErr_SetString(PyExc_TypeError, "invalid argument(s)");
return -1;
}
} else {
+ PyErr_SetString(PyExc_TypeError, "invalid argument(s)");
return -1;
}
@@ -186,10 +188,8 @@ PyObject * CurvePoint_t2d( BPy_CurvePoint *self ) {
PyObject *CurvePoint_setA( BPy_CurvePoint *self , PyObject *args) {
PyObject *py_sv;
- if(!( PyArg_ParseTuple(args, "O", &py_sv) && BPy_SVertex_Check(py_sv) )) {
- cout << "ERROR: CurvePoint_setA" << endl;
- Py_RETURN_NONE;
- }
+ if(!( PyArg_ParseTuple(args, "O!", &SVertex_Type, &py_sv) ))
+ return NULL;
self->cp->setA( ((BPy_SVertex *) py_sv)->sv );
@@ -199,10 +199,8 @@ PyObject *CurvePoint_setA( BPy_CurvePoint *self , PyObject *args) {
PyObject *CurvePoint_setB( BPy_CurvePoint *self , PyObject *args) {
PyObject *py_sv;
- if(!( PyArg_ParseTuple(args, "O", &py_sv) && BPy_SVertex_Check(py_sv) )) {
- cout << "ERROR: CurvePoint_setB" << endl;
- Py_RETURN_NONE;
- }
+ if(!( PyArg_ParseTuple(args, "O!", &SVertex_Type, &py_sv) ))
+ return NULL;
self->cp->setB( ((BPy_SVertex *) py_sv)->sv );
@@ -212,10 +210,8 @@ PyObject *CurvePoint_setB( BPy_CurvePoint *self , PyObject *args) {
PyObject *CurvePoint_setT2d( BPy_CurvePoint *self , PyObject *args) {
float t;
- if( !PyArg_ParseTuple(args, "f", &t) ) {
- cout << "ERROR: CurvePoint_setT2d" << endl;
- Py_RETURN_NONE;
- }
+ if(!( PyArg_ParseTuple(args, "f", &t) ))
+ return NULL;
self->cp->setT2d( t );
diff --git a/source/blender/freestyle/intern/python/Interface1D/Curve/BPy_Chain.cpp b/source/blender/freestyle/intern/python/Interface1D/Curve/BPy_Chain.cpp
index 7116c574c76..12c79743559 100644
--- a/source/blender/freestyle/intern/python/Interface1D/Curve/BPy_Chain.cpp
+++ b/source/blender/freestyle/intern/python/Interface1D/Curve/BPy_Chain.cpp
@@ -150,10 +150,8 @@ int Chain___init__(BPy_Chain *self, PyObject *args, PyObject *kwds)
PyObject * Chain_push_viewedge_back( BPy_Chain *self, PyObject *args ) {
PyObject *obj1 = 0, *obj2 = 0;
- if(!( PyArg_ParseTuple(args, "OO", &obj1, &obj2) && BPy_ViewEdge_Check(obj1) && PyBool_Check(obj2) )) {
- cout << "ERROR: Chain_push_viewedge_back" << endl;
- Py_RETURN_NONE;
- }
+ if(!( PyArg_ParseTuple(args, "O!O!", &ViewEdge_Type, &obj1, &PyBool_Type, &obj2) ))
+ return NULL;
ViewEdge *ve = ((BPy_ViewEdge *) obj1)->ve;
bool orientation = bool_from_PyBool( obj2 );
@@ -165,10 +163,8 @@ PyObject * Chain_push_viewedge_back( BPy_Chain *self, PyObject *args ) {
PyObject * Chain_push_viewedge_front( BPy_Chain *self, PyObject *args ) {
PyObject *obj1 = 0, *obj2 = 0;
- if(!( PyArg_ParseTuple(args, "OO", &obj1, &obj2) && BPy_ViewEdge_Check(obj1) && PyBool_Check(obj2) )) {
- cout << "ERROR: Chain_push_viewedge_front" << endl;
- Py_RETURN_NONE;
- }
+ if(!( PyArg_ParseTuple(args, "O!O!", &ViewEdge_Type, &obj1, &PyBool_Type, &obj2) ))
+ return NULL;
ViewEdge *ve = ((BPy_ViewEdge *) obj1)->ve;
bool orientation = bool_from_PyBool( obj2 );