[Bf-blender-cvs] [77b37fa] master: Freestyle: Fix for VC++ warnings about 'hypot' macro redefinitions (Part 3).

Tamito Kajiyama noreply at git.blender.org
Thu Apr 17 07:37:37 CEST 2014


Commit: 77b37fa4615dc1e8d5656259744f0e8a1634e258
Author: Tamito Kajiyama
Date:   Thu Apr 17 12:37:08 2014 +0900
https://developer.blender.org/rB77b37fa4615dc1e8d5656259744f0e8a1634e258

Freestyle: Fix for VC++ warnings about 'hypot' macro redefinitions (Part 3).

(See commit e1771e72fbbf828dbf5bed871b814288389f3611 for more detail of
the problem).

Made changes to intern/view_map/Interface0D.h and intern/python/Director.h to
avoid #include <Python.h> and keep non-Python header files independent of it.

===================================================================

M	source/blender/freestyle/intern/application/Controller.cpp
M	source/blender/freestyle/intern/python/Director.cpp
M	source/blender/freestyle/intern/python/Director.h
M	source/blender/freestyle/intern/stroke/ChainingIterators.cpp
M	source/blender/freestyle/intern/stroke/ChainingIterators.h
A	source/blender/freestyle/intern/stroke/Predicates0D.cpp
M	source/blender/freestyle/intern/stroke/Predicates0D.h
A	source/blender/freestyle/intern/stroke/Predicates1D.cpp
M	source/blender/freestyle/intern/stroke/Predicates1D.h
A	source/blender/freestyle/intern/stroke/StrokeShader.cpp
M	source/blender/freestyle/intern/stroke/StrokeShader.h
M	source/blender/freestyle/intern/view_map/Functions0D.h
M	source/blender/freestyle/intern/view_map/Functions1D.h
A	source/blender/freestyle/intern/view_map/Interface0D.cpp
M	source/blender/freestyle/intern/view_map/Interface0D.h
A	source/blender/freestyle/intern/view_map/Interface1D.cpp
M	source/blender/freestyle/intern/view_map/Interface1D.h

===================================================================

diff --git a/source/blender/freestyle/intern/application/Controller.cpp b/source/blender/freestyle/intern/application/Controller.cpp
index 81ce162..91a7547 100644
--- a/source/blender/freestyle/intern/application/Controller.cpp
+++ b/source/blender/freestyle/intern/application/Controller.cpp
@@ -22,6 +22,10 @@
  *  \ingroup freestyle
  */
 
+extern "C" {
+#include <Python.h>
+}
+
 #include <string>
 #include <fstream>
 #include <float.h>
diff --git a/source/blender/freestyle/intern/python/Director.cpp b/source/blender/freestyle/intern/python/Director.cpp
index ed98bfe..f03aa0b 100644
--- a/source/blender/freestyle/intern/python/Director.cpp
+++ b/source/blender/freestyle/intern/python/Director.cpp
@@ -74,7 +74,7 @@ int Director_BPy_BinaryPredicate0D___call__(BinaryPredicate0D *bp0D, Interface0D
 		Py_XDECREF(arg2);
 		return -1;
 	}
-	PyObject *result = PyObject_CallMethod(bp0D->py_bp0D, (char *)"__call__", (char *)"OO", arg1, arg2);
+	PyObject *result = PyObject_CallMethod((PyObject *)bp0D->py_bp0D, (char *)"__call__", (char *)"OO", arg1, arg2);
 	Py_DECREF(arg1);
 	Py_DECREF(arg2);
 	if (!result)
@@ -101,7 +101,7 @@ int Director_BPy_BinaryPredicate1D___call__(BinaryPredicate1D *bp1D, Interface1D
 		Py_XDECREF(arg2);
 		return -1;
 	}
-	PyObject *result = PyObject_CallMethod(bp1D->py_bp1D, (char *)"__call__", (char *)"OO", arg1, arg2);
+	PyObject *result = PyObject_CallMethod((PyObject *)bp1D->py_bp1D, (char *)"__call__", (char *)"OO", arg1, arg2);
 	Py_DECREF(arg1);
 	Py_DECREF(arg2);
 	if (!result)
@@ -124,7 +124,7 @@ int Director_BPy_UnaryPredicate0D___call__(UnaryPredicate0D *up0D, Interface0DIt
 	PyObject *arg = BPy_Interface0DIterator_from_Interface0DIterator(if0D_it, 0);
 	if (!arg)
 		return -1;
-	PyObject *result = PyObject_CallMethod(up0D->py_up0D, (char *)"__call__", (char *)"O", arg);
+	PyObject *result = PyObject_CallMethod((PyObject *)up0D->py_up0D, (char *)"__call__", (char *)"O", arg);
 	Py_DECREF(arg);
 	if (!result)
 		return -1;
@@ -146,7 +146,7 @@ int Director_BPy_UnaryPredicate1D___call__(UnaryPredicate1D *up1D, Interface1D&
 	PyObject *arg = Any_BPy_Interface1D_from_Interface1D(if1D);
 	if (!arg)
 		return -1;
-	PyObject *result = PyObject_CallMethod(up1D->py_up1D, (char *)"__call__", (char *)"O", arg);
+	PyObject *result = PyObject_CallMethod((PyObject *)up1D->py_up1D, (char *)"__call__", (char *)"O", arg);
 	Py_DECREF(arg);
 	if (!result)
 		return -1;
@@ -168,7 +168,7 @@ int Director_BPy_StrokeShader_shade(StrokeShader *ss, Stroke& s)
 	PyObject *arg = BPy_Stroke_from_Stroke(s);
 	if (!arg)
 		return -1;
-	PyObject *result = PyObject_CallMethod(ss->py_ss, (char *)"shade", (char *)"O", arg);
+	PyObject *result = PyObject_CallMethod((PyObject *)ss->py_ss, (char *)"shade", (char *)"O", arg);
 	Py_DECREF(arg);
 	if (!result)
 		return -1;
@@ -183,7 +183,7 @@ int Director_BPy_ChainingIterator_init(ChainingIterator *c_it)
 		PyErr_SetString(PyExc_RuntimeError, "Reference to Python object (py_c_it) not initialized");
 		return -1;
 	}
-	PyObject *result = PyObject_CallMethod(c_it->py_c_it, (char *)"init", NULL);
+	PyObject *result = PyObject_CallMethod((PyObject *)c_it->py_c_it, (char *)"init", NULL);
 	if (!result)
 		return -1;
 	Py_DECREF(result);
@@ -199,7 +199,7 @@ int Director_BPy_ChainingIterator_traverse(ChainingIterator *c_it, AdjacencyIter
 	PyObject *arg = BPy_AdjacencyIterator_from_AdjacencyIterator(a_it);
 	if (!arg)
 		return -1;
-	PyObject *result = PyObject_CallMethod(c_it->py_c_it, (char *)"traverse", (char *)"O", arg);
+	PyObject *result = PyObject_CallMethod((PyObject *)c_it->py_c_it, (char *)"traverse", (char *)"O", arg);
 	Py_DECREF(arg);
 	if (!result)
 		return -1;
@@ -219,12 +219,13 @@ int Director_BPy_ChainingIterator_traverse(ChainingIterator *c_it, AdjacencyIter
 }
 
 // BPy_UnaryFunction{0D,1D}: __call__
-int Director_BPy_UnaryFunction0D___call__(void *uf0D, PyObject *obj, Interface0DIterator& if0D_it)
+int Director_BPy_UnaryFunction0D___call__(void *uf0D, void *py_uf0D, Interface0DIterator& if0D_it)
 {
-	if (!obj) { // internal error
+	if (!py_uf0D) { // internal error
 		PyErr_SetString(PyExc_RuntimeError, "Reference to Python object (py_uf0D) not initialized");
 		return -1;
 	}
+	PyObject *obj = (PyObject *)py_uf0D;
 	PyObject *arg = BPy_Interface0DIterator_from_Interface0DIterator(if0D_it, 0);
 	if (!arg)
 		return -1;
@@ -277,12 +278,13 @@ int Director_BPy_UnaryFunction0D___call__(void *uf0D, PyObject *obj, Interface0D
 	return 0;
 }
 
-int Director_BPy_UnaryFunction1D___call__(void *uf1D, PyObject *obj, Interface1D& if1D)
+int Director_BPy_UnaryFunction1D___call__(void *uf1D, void *py_uf1D, Interface1D& if1D)
 {
-	if (!obj) { // internal error
+	if (!py_uf1D) { // internal error
 		PyErr_SetString(PyExc_RuntimeError, "Reference to Python object (py_uf1D) not initialized");
 		return -1;
 	}
+	PyObject *obj = (PyObject *)py_uf1D;
 	PyObject *arg = Any_BPy_Interface1D_from_Interface1D(if1D);
 	if (!arg)
 		return -1;
diff --git a/source/blender/freestyle/intern/python/Director.h b/source/blender/freestyle/intern/python/Director.h
index d58a51b..40576c0 100644
--- a/source/blender/freestyle/intern/python/Director.h
+++ b/source/blender/freestyle/intern/python/Director.h
@@ -41,16 +41,6 @@ class StrokeShader;
 
 using namespace Freestyle;
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <Python.h>
-
-#ifdef __cplusplus
-}
-#endif
-
 // BinaryPredicate0D: __call__
 int Director_BPy_BinaryPredicate0D___call__(BinaryPredicate0D *bp0D, Interface0D& i1, Interface0D& i2);
 
@@ -58,8 +48,8 @@ int Director_BPy_BinaryPredicate0D___call__(BinaryPredicate0D *bp0D, Interface0D
 int Director_BPy_BinaryPredicate1D___call__(BinaryPredicate1D *bp1D, Interface1D& i1, Interface1D& i2);
 
 // UnaryFunction{0D,1D}: __call__
-int Director_BPy_UnaryFunction0D___call__(void *uf0D, PyObject *obj, Interface0DIterator& if0D_it);
-int Director_BPy_UnaryFunction1D___call__(void *uf1D, PyObject *obj, Interface1D& if1D);
+int Director_BPy_UnaryFunction0D___call__(void *uf0D, void *py_uf0D, Interface0DIterator& if0D_it);
+int Director_BPy_UnaryFunction1D___call__(void *uf1D, void *py_uf1D, Interface1D& if1D);
 
 // UnaryPredicate0D: __call__
 int Director_BPy_UnaryPredicate0D___call__(UnaryPredicate0D *up0D, Interface0DIterator& if0D_it);
diff --git a/source/blender/freestyle/intern/stroke/ChainingIterators.cpp b/source/blender/freestyle/intern/stroke/ChainingIterators.cpp
index 66575fd..25fdc04 100644
--- a/source/blender/freestyle/intern/stroke/ChainingIterators.cpp
+++ b/source/blender/freestyle/intern/stroke/ChainingIterators.cpp
@@ -25,6 +25,8 @@
  *  \date 01/07/2003
  */
 
+#include "../python/Director.h"
+
 #include "ChainingIterators.h"
 
 #include "../system/TimeStamp.h"
@@ -62,6 +64,16 @@ bool AdjacencyIterator::isValid(ViewEdge *edge)
 	return true;
 }
 
+int ChainingIterator::init()
+{
+	return Director_BPy_ChainingIterator_init(this);
+}
+
+int ChainingIterator::traverse(const AdjacencyIterator &it)
+{
+	return Director_BPy_ChainingIterator_traverse(this, const_cast<AdjacencyIterator &>(it));
+}
+
 int ChainingIterator::increment()
 {
 	_increment = true;
diff --git a/source/blender/freestyle/intern/stroke/ChainingIterators.h b/source/blender/freestyle/intern/stroke/ChainingIterators.h
index 8d01cea..5a8d4b6 100644
--- a/source/blender/freestyle/intern/stroke/ChainingIterators.h
+++ b/source/blender/freestyle/intern/stroke/ChainingIterators.h
@@ -32,7 +32,6 @@
 
 #include "Predicates1D.h"
 
-#include  "../python/Director.h"
 
 #include "../system/Iterator.h" //soc 
 
@@ -161,7 +160,7 @@ protected:
 
 public:
 	ViewEdge *result;
-	PyObject *py_c_it;
+	void *py_c_it;
 
 	/*! Builds a Chaining Iterator from the first ViewEdge used for iteration and its orientation.
 	 *  \param iRestrictToSelection
@@ -203,10 +202,7 @@ public:
 	 *  This method is called each time a new chain is started.
 	 *  It can be used to reset some history information that you might want to keep.
 	 */
-	virtual int init()
-	{
-		return Director_BPy_ChainingIterator_init(this);
-	}
+	virtual int init();
 
 	/*! This method iterates over the potential next ViewEdges and returns the one that will be followed next.
 	 *  returns the next ViewEdge to follow or 0 when the end of the chain is reached.
@@ -214,10 +210,7 @@ public:
 	 *    The iterator over the ViewEdges adjacent to the end vertex of the current ViewEdge.
 	 *    The Adjacency iterator reflects the restriction rules by only iterating over the valid ViewEdges.
 	 */
-	virtual int traverse(const AdjacencyIterator &it)
-	{
-		return Director_BPy_ChainingIterator_traverse(this, const_cast<AdjacencyIterator &>(it));
-	}
+	virtual int traverse(const AdjacencyIterator &it);
 
 	/* accessors */
 	/*! Returns true if the orientation of the current ViewEdge corresponds to its natural orientation */
diff --git a/source/blender/freestyle/intern/stroke/Predicates0D.cpp b/source/blender/freestyle/intern/stroke/Predicates0D.cpp
new file mode 100644
index 0000000..f189b2e
--- /dev/null
+++ b/source/blender/freestyle/intern/stroke/Predicates0D.cpp
@@ -0,0 +1,41 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/freestyle/intern/stroke/Predicates0D.cpp
+ *  \ingroup freestyle
+ */
+
+#include "Predicates0D.h"
+
+#include "../python/Director.h"
+
+namespace Freestyle {
+
+int UnaryPredicate0D::operator()(Interface0DIterator& it)
+{
+	return Director_BPy_UnaryPredicate0D___call__(this, it);
+}
+
+int BinaryPredi

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list