From 0ea01da4ba0e370c966a73a797cb8fd96edbae1a Mon Sep 17 00:00:00 2001 From: Tamito Kajiyama Date: Sun, 2 Aug 2009 18:25:26 +0000 Subject: Fixed the argument parsing in CurvePoint.__init__(). --- .../intern/python/Interface0D/BPy_CurvePoint.cpp | 39 +++++++++++++--------- 1 file changed, 24 insertions(+), 15 deletions(-) (limited to 'source/blender/freestyle/intern/python') diff --git a/source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.cpp b/source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.cpp index 85ccae1c247..2858091b07a 100644 --- a/source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.cpp +++ b/source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.cpp @@ -128,24 +128,33 @@ int CurvePoint___init__(BPy_CurvePoint *self, PyObject *args, PyObject *kwds) PyObject *obj1 = 0, *obj2 = 0 , *obj3 = 0; - if (! PyArg_ParseTuple(args, "|OOO", &obj1, &obj2, &obj3) ) + if (! PyArg_ParseTuple(args, "|OOO!", &obj1, &obj2, &PyFloat_Type, &obj3) ) return -1; - if( !obj1 && !obj2 && !obj3 ){ + if( !obj1 ){ self->cp = new CurvePoint(); - } else if( PyFloat_Check(obj3) ) { - if( BPy_SVertex_Check(obj1) && BPy_SVertex_Check(obj2) ) { - self->cp = new CurvePoint( ((BPy_SVertex *) obj1)->sv, - ((BPy_SVertex *) obj2)->sv, - PyFloat_AsDouble( obj3 ) ); - } else if( BPy_CurvePoint_Check(obj1) && BPy_CurvePoint_Check(obj2) ) { - self->cp = new CurvePoint( ((BPy_CurvePoint *) obj1)->cp, - ((BPy_CurvePoint *) obj2)->cp, - PyFloat_AsDouble( obj3 ) ); - } else { - PyErr_SetString(PyExc_TypeError, "invalid argument(s)"); - return -1; - } + + } else if( !obj2 && BPy_CurvePoint_Check(obj1) ) { + self->cp = new CurvePoint( *(((BPy_CurvePoint *) obj1)->cp) ); + + } else if( obj3 && BPy_SVertex_Check(obj1) && BPy_SVertex_Check(obj2) ) { + self->cp = new CurvePoint( ((BPy_SVertex *) obj1)->sv, + ((BPy_SVertex *) obj2)->sv, + PyFloat_AsDouble( obj3 ) ); + + } else if( obj3 && BPy_CurvePoint_Check(obj1) && BPy_CurvePoint_Check(obj2) ) { + CurvePoint *cp1 = ((BPy_CurvePoint *) obj1)->cp; + CurvePoint *cp2 = ((BPy_CurvePoint *) obj2)->cp; + if( !cp1 || cp1->A() == 0 || cp1->B() == 0 ) { + PyErr_SetString(PyExc_TypeError, "argument 1 is an invalid CurvePoint object"); + return -1; + } + if( !cp2 || cp2->A() == 0 || cp2->B() == 0 ) { + PyErr_SetString(PyExc_TypeError, "argument 2 is an invalid CurvePoint object"); + return -1; + } + self->cp = new CurvePoint( cp1, cp2, PyFloat_AsDouble( obj3 ) ); + } else { PyErr_SetString(PyExc_TypeError, "invalid argument(s)"); return -1; -- cgit v1.2.3