From 5fed0560d9184d9dd64625ce6af70f67e0ad0960 Mon Sep 17 00:00:00 2001 From: Tamito Kajiyama Date: Sun, 19 Jul 2009 23:17:30 +0000 Subject: * Introspection-based automatic type conversion from a generic C++ object to a specific Python object. The conversion takes place in the following places. - Interface0DIterator_getObject (BPy_Interface0DIterator.cpp) - Director_BPy_BinaryPredicate1D___call__ (Director.cpp) - Director_BPy_UnaryPredicate1D___call__ (Director.cpp) - SVertex_viewvertex (BPy_SVertex.cpp) - BPy_FEdge_from_FEdge (BPy_Convert.cpp) This is a tentative list and more conversions are expected to be added. * Added the following two converter functions to BPy_Convert.{cpp,h}: - BPy_NonTVertex_from_NonTVertex_ptr - BPy_TVertex_from_TVertex_ptr --- .../blender/freestyle/intern/python/Director.cpp | 29 +++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'source/blender/freestyle/intern/python/Director.cpp') diff --git a/source/blender/freestyle/intern/python/Director.cpp b/source/blender/freestyle/intern/python/Director.cpp index 84560de67a8..dd4688515a7 100644 --- a/source/blender/freestyle/intern/python/Director.cpp +++ b/source/blender/freestyle/intern/python/Director.cpp @@ -59,8 +59,21 @@ int Director_BPy_BinaryPredicate0D___call__( PyObject *obj, Interface0D& i1, Int // BinaryPredicate1D: __call__ int Director_BPy_BinaryPredicate1D___call__( PyObject *obj, Interface1D& i1, Interface1D& i2) { - PyObject *arg1 = BPy_Interface1D_from_Interface1D(i1); - PyObject *arg2 = BPy_Interface1D_from_Interface1D(i2); + PyObject *arg1, *arg2; + if (typeid(i1) == typeid(ViewEdge)) { + arg1 = BPy_ViewEdge_from_ViewEdge_ptr(dynamic_cast(&i1)); + arg2 = BPy_ViewEdge_from_ViewEdge_ptr(dynamic_cast(&i2)); + } else if (typeid(i1) == typeid(Chain)) { + arg1 = BPy_Chain_from_Chain_ptr(dynamic_cast(&i1)); + arg2 = BPy_Chain_from_Chain_ptr(dynamic_cast(&i2)); + } else if (typeid(i1) == typeid(Stroke)) { + arg1 = BPy_Stroke_from_Stroke_ptr(dynamic_cast(&i1)); + arg2 = BPy_Stroke_from_Stroke_ptr(dynamic_cast(&i2)); + } else { + cerr << "Warning: cast to " + i1.getExactTypeName() + " not implemented" << endl; + arg1 = BPy_Interface1D_from_Interface1D(i1); + arg2 = BPy_Interface1D_from_Interface1D(i2); + } PyObject *result = PyObject_CallMethod( obj, "__call__", "OO", arg1, arg2 ); Py_DECREF(arg1); Py_DECREF(arg2); @@ -87,7 +100,17 @@ int Director_BPy_UnaryPredicate0D___call__( PyObject *obj, Interface0DIterator& // UnaryPredicate1D: __call__ int Director_BPy_UnaryPredicate1D___call__( PyObject *obj, Interface1D& if1D) { - PyObject *arg = BPy_Interface1D_from_Interface1D(if1D); + PyObject *arg; + if (typeid(if1D) == typeid(ViewEdge)) { + arg = BPy_ViewEdge_from_ViewEdge_ptr(dynamic_cast(&if1D)); + } else if (typeid(if1D) == typeid(Chain)) { + arg = BPy_Chain_from_Chain_ptr(dynamic_cast(&if1D)); + } else if (typeid(if1D) == typeid(Stroke)) { + arg = BPy_Stroke_from_Stroke_ptr(dynamic_cast(&if1D)); + } else { + cerr << "Warning: cast to " + if1D.getExactTypeName() + " not implemented" << endl; + arg = BPy_Interface1D_from_Interface1D(if1D); + } PyObject *result = PyObject_CallMethod( obj, "__call__", "O", arg ); Py_DECREF(arg); if (!result) -- cgit v1.2.3