Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime Curioni <maxime.curioni@gmail.com>2008-07-31 12:50:12 +0400
committerMaxime Curioni <maxime.curioni@gmail.com>2008-07-31 12:50:12 +0400
commit3010f2b753f2397256861816504b8e7d697632db (patch)
treecee975b7fc574c43be0d462447c87056c4bdfc6b /source/blender/freestyle/intern/stroke/Predicates1D.h
parenta482f644242456ad6ddf0306e1b37d8855342103 (diff)
soc-2008-mxcurioni: the native Python system now supports cross-language polymorphism for the following classes: BinaryPredicate0D (__call__), BinaryPredicate1D (__call__), UnaryPredicate0D (__call__), UnaryPredicate1D (__call__), StrokeShader (shade), ChainingIterator (init, traverse).
Other methods could easily be supported in the future. The method now works as planned for the contour style. For style modules with Python shaders, there still is a problem that I will fix right away.
Diffstat (limited to 'source/blender/freestyle/intern/stroke/Predicates1D.h')
-rwxr-xr-xsource/blender/freestyle/intern/stroke/Predicates1D.h31
1 files changed, 19 insertions, 12 deletions
diff --git a/source/blender/freestyle/intern/stroke/Predicates1D.h b/source/blender/freestyle/intern/stroke/Predicates1D.h
index 98148361bb7..8c6f5a9bfa4 100755
--- a/source/blender/freestyle/intern/stroke/Predicates1D.h
+++ b/source/blender/freestyle/intern/stroke/Predicates1D.h
@@ -58,9 +58,7 @@ public:
PyObject *py_up1D;
/*! Default constructor. */
- UnaryPredicate1D() {
- py_up1D = 0;
- }
+ UnaryPredicate1D() { py_up1D = 0; }
/*! Destructor. */
virtual ~UnaryPredicate1D() {}
/*! Returns the string of the name
@@ -78,17 +76,16 @@ public:
* false otherwise.
*/
virtual bool operator()(Interface1D& inter) {
+ string name( py_up1D ? PyString_AsString(PyObject_CallMethod(py_up1D, "getName", "")) : getName() );
- if( py_up1D ) {
- return director_BPy_UnaryPredicate1D___call__(py_up1D, inter);
+ if( py_up1D && PyObject_HasAttrString(py_up1D, "__call__")) {
+ return Director_BPy_UnaryPredicate1D___call__(py_up1D, inter);
} else {
- cerr << "Warning: operator() not implemented" << endl;
- return false;
+ cerr << "Warning: " << name << " operator() not implemented" << endl;
+ return false;
}
}
- inline void setPythonObject(PyObject *_py_up1D) { py_up1D = _py_up1D; }
-
};
@@ -106,8 +103,11 @@ public:
class BinaryPredicate1D
{
public:
+
+ PyObject *py_bp1D;
+
/*! Default constructor. */
- BinaryPredicate1D() {}
+ BinaryPredicate1D() { py_bp1D = 0; }
/*! Destructor. */
virtual ~BinaryPredicate1D() {}
/*! Returns the string of the name of the
@@ -125,9 +125,16 @@ public:
* \return true or false.
*/
virtual bool operator()(Interface1D& inter1, Interface1D& inter2) {
- cerr << "Warning: operator() not implemented" << endl;
- return false;
+ string name( py_bp1D ? PyString_AsString(PyObject_CallMethod(py_bp1D, "getName", "")) : getName() );
+
+ if( py_bp1D && py_bp1D && PyObject_HasAttrString(py_bp1D, "__call__") ) {
+ return Director_BPy_BinaryPredicate1D___call__(py_bp1D, inter1, inter2);
+ } else {
+ cerr << "Warning: " << name << " operator() not implemented" << endl;
+ return false;
+ }
}
+
};