diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2009-08-01 02:13:48 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2009-08-01 02:13:48 +0400 |
commit | ba9943e4a7a6c671e427c08fc11845168a30e86a (patch) | |
tree | 99310397139b528b4ba46012389aea490597a78f /source/blender/freestyle/intern/stroke | |
parent | 6134a41270ab7629bb6e09de5462ba386861ede3 (diff) |
* Implemented Python's iterator protocol in Interface0DIterator and
orientedViewEdgeIterator.
* Simplified Python-related error handling in C++ class definitions.
The definitions of the following C++ methods were simplified and most
code segments using the C/Python API were moved to Director.cpp.
ChainingIterator::init()
ChainingIterator::traverse()
UnaryPredicate0D::operator()()
UnaryPredicate1D::operator()()
BinaryPredicate0D::operator()()
BinaryPredicate1D::operator()()
UnaryFunction0D::operator()()
UnaryFunction1D::operator()()
StrokeShader.shade()
* Moved part of the introspection-based automatic type conversion code
from BPy_Interface0DIterator.cpp and Director.cpp to BPy_Convert.cpp
for the sake of better code organization.
* Fixed an uninitialized member in StrokeVertexIterator___init__().
Diffstat (limited to 'source/blender/freestyle/intern/stroke')
4 files changed, 7 insertions, 78 deletions
diff --git a/source/blender/freestyle/intern/stroke/ChainingIterators.h b/source/blender/freestyle/intern/stroke/ChainingIterators.h index fb04be93b4d..ec093888aea 100755 --- a/source/blender/freestyle/intern/stroke/ChainingIterators.h +++ b/source/blender/freestyle/intern/stroke/ChainingIterators.h @@ -186,16 +186,7 @@ public: * might want to keep. */ virtual int init() { - string name( py_c_it ? PyString_AsString(PyObject_CallMethod(py_c_it, "getExactTypeName", "")) : getExactTypeName() ); - - if( py_c_it && PyObject_HasAttrString(py_c_it, "init") ) { - if (Director_BPy_ChainingIterator_init( py_c_it ) < 0) { - return -1; - } - } else { - cerr << "Warning: " << name << " init() method not implemented" << endl; - } - return 0; + return Director_BPy_ChainingIterator_init( this ); } /*! This method iterates over the potential next @@ -210,16 +201,7 @@ public: * rules by only iterating over the valid ViewEdges. */ virtual int traverse(const AdjacencyIterator &it){ - string name( py_c_it ? PyString_AsString(PyObject_CallMethod(py_c_it, "getExactTypeName", "")) : getExactTypeName() ); - - if( py_c_it && PyObject_HasAttrString(py_c_it, "traverse") ) { - if (Director_BPy_ChainingIterator_traverse(py_c_it, const_cast<AdjacencyIterator &>(it), &result ) < 0) { - return -1; - } - } else { - cerr << "Warning: the " << name << " traverse() method not defined" << endl; - } - return 0; + return Director_BPy_ChainingIterator_traverse( this, const_cast<AdjacencyIterator &>(it) ); } /* accessors */ diff --git a/source/blender/freestyle/intern/stroke/Predicates0D.h b/source/blender/freestyle/intern/stroke/Predicates0D.h index 58aa3e5c86c..2f5d9551b3a 100755 --- a/source/blender/freestyle/intern/stroke/Predicates0D.h +++ b/source/blender/freestyle/intern/stroke/Predicates0D.h @@ -74,18 +74,7 @@ public: * false otherwise. */ virtual int operator()(Interface0DIterator& it) { - string name( py_up0D ? PyString_AsString(PyObject_CallMethod(py_up0D, "getName", "")) : getName() ); - - if( py_up0D && PyObject_HasAttrString(py_up0D, "__call__") ) { - int res = Director_BPy_UnaryPredicate0D___call__(py_up0D, it); - if (res < 0) - return -1; - result = (res == 1); - } else { - cerr << "Warning: " << name << " operator() not implemented" << endl; - result = false; - } - return 0; + return Director_BPy_UnaryPredicate0D___call__(this, it); } }; @@ -129,18 +118,7 @@ public: * \return true or false. */ virtual int operator()(Interface0D& inter1, Interface0D& inter2) { - string name( py_bp0D ? PyString_AsString(PyObject_CallMethod(py_bp0D, "getName", "")) : getName() ); - - if( py_bp0D && PyObject_HasAttrString(py_bp0D, "__call__") ) { - int res = Director_BPy_BinaryPredicate0D___call__(py_bp0D, inter1, inter2); - if (res < 0) - return -1; - result = (res == 1); - } else { - cerr << "Warning: " << name << " operator() not implemented" << endl; - result = false; - } - return 0; + return Director_BPy_BinaryPredicate0D___call__(this, inter1, inter2); } }; diff --git a/source/blender/freestyle/intern/stroke/Predicates1D.h b/source/blender/freestyle/intern/stroke/Predicates1D.h index 6e7ab04783b..6461f6428ab 100755 --- a/source/blender/freestyle/intern/stroke/Predicates1D.h +++ b/source/blender/freestyle/intern/stroke/Predicates1D.h @@ -77,18 +77,7 @@ public: * false otherwise. */ virtual int operator()(Interface1D& inter) { - string name( py_up1D ? PyString_AsString(PyObject_CallMethod(py_up1D, "getName", "")) : getName() ); - - if( py_up1D && PyObject_HasAttrString(py_up1D, "__call__")) { - int res = Director_BPy_UnaryPredicate1D___call__(py_up1D, inter); - if (res < 0) - return -1; - result = (res == 1); - } else { - cerr << "Warning: " << name << " operator() not implemented" << endl; - result = false; - } - return 0; + return Director_BPy_UnaryPredicate1D___call__(this, inter); } }; @@ -131,18 +120,7 @@ public: * \return true or false. */ virtual int operator()(Interface1D& inter1, Interface1D& inter2) { - string name( py_bp1D ? PyString_AsString(PyObject_CallMethod(py_bp1D, "getName", "")) : getName() ); - - if( py_bp1D && PyObject_HasAttrString(py_bp1D, "__call__") ) { - int res = Director_BPy_BinaryPredicate1D___call__(py_bp1D, inter1, inter2); - if (res < 0) - return -1; - result = (res == 1); - } else { - cerr << "Warning: " << name << " operator() not implemented" << endl; - result = false; - } - return 0; + return Director_BPy_BinaryPredicate1D___call__(this, inter1, inter2); } }; diff --git a/source/blender/freestyle/intern/stroke/StrokeShader.h b/source/blender/freestyle/intern/stroke/StrokeShader.h index 031b7cc8acb..63185438e91 100755 --- a/source/blender/freestyle/intern/stroke/StrokeShader.h +++ b/source/blender/freestyle/intern/stroke/StrokeShader.h @@ -116,16 +116,7 @@ public: * as Color, Thickness, Geometry...) */ virtual int shade(Stroke& ioStroke) const { - string name( py_ss ? PyString_AsString(PyObject_CallMethod(py_ss, "getName", "")) : getName() ); - - if( py_ss && PyObject_HasAttrString(py_ss, "shade") ) { - if (Director_BPy_StrokeShader_shade(py_ss, ioStroke) < 0) { - return -1; - } - } else { - cerr << "Warning: " << name << " shade() method not implemented" << endl; - } - return 0; + return Director_BPy_StrokeShader_shade( const_cast<StrokeShader *>(this), ioStroke ); } }; |