[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [22188] branches/soc-2008-mxcurioni/source /blender/freestyle/intern/python: Fixed argument checking in __init__ methods of Interface1D, Predicates,

Tamito Kajiyama rd6t-kjym at asahi-net.or.jp
Mon Aug 3 17:19:52 CEST 2009


Revision: 22188
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=22188
Author:   kjym3
Date:     2009-08-03 17:19:51 +0200 (Mon, 03 Aug 2009)

Log Message:
-----------
Fixed argument checking in __init__ methods of Interface1D, Predicates,
Functions, and StrokeShader types.

Modified Paths:
--------------
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_BinaryPredicate0D.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_BinaryPredicate1D.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_Interface1D.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_StrokeShader.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_UnaryPredicate0D.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_UnaryPredicate1D.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Interface1D/BPy_ViewEdge.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DDouble.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DFloat.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DId.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec2f.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec3f.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DViewShape.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludeeF1D.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludersF1D.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetShapeF1D.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_ChainingTimeStampF1D.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_IncrementChainingTimeStampF1D.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_TimeStampF1D.cpp

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_BinaryPredicate0D.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_BinaryPredicate0D.cpp	2009-08-03 15:06:56 UTC (rev 22187)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_BinaryPredicate0D.cpp	2009-08-03 15:19:51 UTC (rev 22188)
@@ -125,6 +125,8 @@
 
 int BinaryPredicate0D___init__(BPy_BinaryPredicate0D *self, PyObject *args, PyObject *kwds)
 {
+    if ( !PyArg_ParseTuple(args, "") )
+        return -1;
 	self->bp0D = new BinaryPredicate0D();
 	self->bp0D->py_bp0D = (PyObject *) self;
 	

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_BinaryPredicate1D.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_BinaryPredicate1D.cpp	2009-08-03 15:06:56 UTC (rev 22187)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_BinaryPredicate1D.cpp	2009-08-03 15:19:51 UTC (rev 22188)
@@ -157,6 +157,8 @@
 
 int BinaryPredicate1D___init__(BPy_BinaryPredicate1D *self, PyObject *args, PyObject *kwds)
 {
+    if ( !PyArg_ParseTuple(args, "") )
+        return -1;
 	self->bp1D = new BinaryPredicate1D();
 	self->bp1D->py_bp1D = (PyObject *) self;	
 	return 0;

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_Interface1D.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_Interface1D.cpp	2009-08-03 15:06:56 UTC (rev 22187)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_Interface1D.cpp	2009-08-03 15:19:51 UTC (rev 22188)
@@ -197,6 +197,8 @@
 
 int Interface1D___init__(BPy_Interface1D *self, PyObject *args, PyObject *kwds)
 {
+    if ( !PyArg_ParseTuple(args, "") )
+        return -1;
 	self->if1D = new Interface1D();
 	self->borrowed = 0;
 	return 0;

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_StrokeShader.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_StrokeShader.cpp	2009-08-03 15:06:56 UTC (rev 22187)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_StrokeShader.cpp	2009-08-03 15:19:51 UTC (rev 22188)
@@ -259,6 +259,8 @@
 
 int StrokeShader___init__(BPy_StrokeShader *self, PyObject *args, PyObject *kwds)
 {
+    if ( !PyArg_ParseTuple(args, "") )
+        return -1;
 	self->ss = new StrokeShader();
 	self->ss->py_ss = (PyObject *) self;
 	return 0;

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_UnaryPredicate0D.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_UnaryPredicate0D.cpp	2009-08-03 15:06:56 UTC (rev 22187)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_UnaryPredicate0D.cpp	2009-08-03 15:19:51 UTC (rev 22188)
@@ -137,6 +137,8 @@
 
 int UnaryPredicate0D___init__(BPy_UnaryPredicate0D *self, PyObject *args, PyObject *kwds)
 {
+    if ( !PyArg_ParseTuple(args, "") )
+        return -1;
 	self->up0D = new UnaryPredicate0D();
 	self->up0D->py_up0D = (PyObject *) self;
 	return 0;

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_UnaryPredicate1D.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_UnaryPredicate1D.cpp	2009-08-03 15:06:56 UTC (rev 22187)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_UnaryPredicate1D.cpp	2009-08-03 15:19:51 UTC (rev 22188)
@@ -179,6 +179,8 @@
 
 int UnaryPredicate1D___init__(BPy_UnaryPredicate1D *self, PyObject *args, PyObject *kwds)
 {
+	if( !PyArg_ParseTuple(args, "") )	
+		return -1;
 	self->up1D = new UnaryPredicate1D();
 	self->up1D->py_up1D = (PyObject *) self;
 	return 0;

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.cpp	2009-08-03 15:06:56 UTC (rev 22187)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.cpp	2009-08-03 15:19:51 UTC (rev 22188)
@@ -152,16 +152,20 @@
 	
 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;

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp	2009-08-03 15:06:56 UTC (rev 22187)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp	2009-08-03 15:19:51 UTC (rev 22188)
@@ -183,18 +183,19 @@
 	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;

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Interface1D/BPy_ViewEdge.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Interface1D/BPy_ViewEdge.cpp	2009-08-03 15:06:56 UTC (rev 22187)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Interface1D/BPy_ViewEdge.cpp	2009-08-03 15:19:51 UTC (rev 22188)
@@ -161,6 +161,8 @@
 	
 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;

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.cpp	2009-08-03 15:06:56 UTC (rev 22187)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.cpp	2009-08-03 15:19:51 UTC (rev 22188)
@@ -135,10 +135,10 @@
 	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 {

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.cpp	2009-08-03 15:06:56 UTC (rev 22187)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.cpp	2009-08-03 15:19:51 UTC (rev 22188)
@@ -127,10 +127,10 @@
 	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 {

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DDouble.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DDouble.cpp	2009-08-03 15:06:56 UTC (rev 22187)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DDouble.cpp	2009-08-03 15:19:51 UTC (rev 22188)
@@ -23,7 +23,7 @@
 ///////////////////////////////////////////////////////////////////////////////////////////
 
 /*---------------  Python API function prototypes for UnaryFunction0DDouble instance  -----------*/
-static int UnaryFunction0DDouble___init__(BPy_UnaryFunction0DDouble* self);
+static int UnaryFunction0DDouble___init__(BPy_UnaryFunction0DDouble* self, PyObject *args, PyObject *kwds);
 static void UnaryFunction0DDouble___dealloc__(BPy_UnaryFunction0DDouble* self);
 static PyObject * UnaryFunction0DDouble___repr__(BPy_UnaryFunction0DDouble* self);
 
@@ -188,8 +188,10 @@
 
 //------------------------INSTANCE METHODS ----------------------------------
 
-int UnaryFunction0DDouble___init__(BPy_UnaryFunction0DDouble* self)

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list