Fixed argument checking in __init__ methods of Interface1D, Predicates,

Functions, and StrokeShader types.
This commit is contained in:
2009-08-03 15:19:51 +00:00
parent d4ff63fe20
commit ff110c17f7
27 changed files with 99 additions and 48 deletions

View File

@@ -152,16 +152,20 @@ PyTypeObject FEdge_Type = {
int FEdge___init__(BPy_FEdge *self, PyObject *args, PyObject *kwds)
{
PyObject *obj1 = 0, *obj2 = 0;
if (! PyArg_ParseTuple(args, "|O!O!", &SVertex_Type, &obj1, &SVertex_Type, &obj2) )
if (! PyArg_ParseTuple(args, "|OO", &obj1, &obj2) )
return -1;
if( !obj1 && !obj2 ){
if( !obj1 ){
self->fe = new FEdge();
} else if( obj1 && obj2 ) {
} else if( !obj2 && BPy_FEdge_Check(obj1) ) {
self->fe = new FEdge(*( ((BPy_FEdge *) obj1)->fe ));
} else if( obj2 && BPy_SVertex_Check(obj1) && BPy_SVertex_Check(obj2) ) {
self->fe = new FEdge( ((BPy_SVertex *) obj1)->sv, ((BPy_SVertex *) obj2)->sv );
} else {
PyErr_SetString(PyExc_TypeError, "invalid argument(s)");
return -1;

View File

@@ -183,18 +183,19 @@ int Stroke___init__(BPy_Stroke *self, PyObject *args, PyObject *kwds)
if (! PyArg_ParseTuple(args, "|OO", &obj1, &obj2) )
return -1;
if( !obj1 && !obj2 ){
if( !obj1 ){
self->s = new Stroke();
} else if ( obj1 && !obj2 ) {
if (! BPy_Stroke_Check(obj1) ) {
PyErr_SetString(PyExc_TypeError, "not a Stroke object");
return -1;
}
} else if ( !obj2 && BPy_Stroke_Check(obj1) ) {
self->s = new Stroke(*( ((BPy_Stroke *)obj1)->s ));
} else {
PyErr_SetString(PyExc_NotImplementedError,
} else if ( obj2 ) {
PyErr_SetString(PyExc_TypeError,
"Stroke(InputVertexIterator iBegin, InputVertexIterator iEnd) not implemented");
return -1;
} else {
PyErr_SetString(PyExc_TypeError, "invalid argument(s)");
return -1;
}
self->py_if1D.if1D = self->s;

View File

@@ -161,6 +161,8 @@ PyTypeObject ViewEdge_Type = {
int ViewEdge___init__(BPy_ViewEdge *self, PyObject *args, PyObject *kwds)
{
if ( !PyArg_ParseTuple(args, "") )
return -1;
self->ve = new ViewEdge();
self->py_if1D.if1D = self->ve;
self->py_if1D.borrowed = 0;

View File

@@ -135,10 +135,10 @@ int FEdgeSharp___init__(BPy_FEdgeSharp *self, PyObject *args, PyObject *kwds)
if( !obj1 ){
self->fes = new FEdgeSharp();
} else if( BPy_FEdgeSharp_Check(obj1) ) {
} else if( !obj2 && BPy_FEdgeSharp_Check(obj1) ) {
self->fes = new FEdgeSharp(*( ((BPy_FEdgeSharp *) obj1)->fes ));
} else if( BPy_SVertex_Check(obj1) && BPy_SVertex_Check(obj2) ) {
} else if( obj2 && BPy_SVertex_Check(obj1) && BPy_SVertex_Check(obj2) ) {
self->fes = new FEdgeSharp( ((BPy_SVertex *) obj1)->sv, ((BPy_SVertex *) obj2)->sv );
} else {

View File

@@ -127,10 +127,10 @@ int FEdgeSmooth___init__(BPy_FEdgeSmooth *self, PyObject *args, PyObject *kwds)
if( !obj1 ){
self->fes = new FEdgeSmooth();
} else if( BPy_FEdgeSmooth_Check(obj1) ) {
} else if( !obj2 && BPy_FEdgeSmooth_Check(obj1) ) {
self->fes = new FEdgeSmooth(*( ((BPy_FEdgeSmooth *) obj1)->fes ));
} else if( BPy_SVertex_Check(obj1) && BPy_SVertex_Check(obj2) ) {
} else if( obj2 && BPy_SVertex_Check(obj1) && BPy_SVertex_Check(obj2) ) {
self->fes = new FEdgeSmooth( ((BPy_SVertex *) obj1)->sv, ((BPy_SVertex *) obj2)->sv );
} else {