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/Predicates0D.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/Predicates0D.h')
-rwxr-xr-xsource/blender/freestyle/intern/stroke/Predicates0D.h34
1 files changed, 28 insertions, 6 deletions
diff --git a/source/blender/freestyle/intern/stroke/Predicates0D.h b/source/blender/freestyle/intern/stroke/Predicates0D.h
index 4c2dfacdf98..0318c1742ec 100755
--- a/source/blender/freestyle/intern/stroke/Predicates0D.h
+++ b/source/blender/freestyle/intern/stroke/Predicates0D.h
@@ -32,6 +32,8 @@
# include "../view_map/Functions0D.h"
+# include "../python/Director.h"
+
//
// UnaryPredicate0D (base class for predicates in 0D)
//
@@ -48,8 +50,11 @@
class UnaryPredicate0D
{
public:
+
+ PyObject *py_up0D;
+
/*! Default constructor. */
- UnaryPredicate0D() {}
+ UnaryPredicate0D() { py_up0D = 0; }
/*! Destructor. */
virtual ~UnaryPredicate0D() {}
/*! Returns the string of the name
@@ -68,9 +73,16 @@ public:
* false otherwise.
*/
virtual bool operator()(Interface0DIterator& it) {
- cerr << "Warning: operator() not implemented" << endl;
- return false;
+ string name( py_up0D ? PyString_AsString(PyObject_CallMethod(py_up0D, "getName", "")) : getName() );
+
+ if( py_up0D && PyObject_HasAttrString(py_up0D, "__call__") ) {
+ return Director_BPy_UnaryPredicate0D___call__(py_up0D, it);
+ } else {
+ cerr << "Warning: " << name << " operator() not implemented" << endl;
+ return false;
+ }
}
+
};
@@ -88,8 +100,11 @@ public:
class BinaryPredicate0D
{
public:
+
+ PyObject *py_bp0D;
+
/*! Default constructor. */
- BinaryPredicate0D() {}
+ BinaryPredicate0D() { py_bp0D = 0; }
/*! Destructor. */
virtual ~BinaryPredicate0D() {}
/*! Returns the string of the name of the
@@ -108,9 +123,16 @@ public:
* \return true or false.
*/
virtual bool operator()(Interface0D& inter1, Interface0D& inter2) {
- cerr << "Warning: operator() not implemented" << endl;
- return false;
+ string name( py_bp0D ? PyString_AsString(PyObject_CallMethod(py_bp0D, "getName", "")) : getName() );
+
+ if( py_bp0D && PyObject_HasAttrString(py_bp0D, "__call__") ) {
+ return Director_BPy_BinaryPredicate0D___call__(py_bp0D, inter1, inter2);
+ } else {
+ cerr << "Warning: " << name << " operator() not implemented" << endl;
+ return false;
+ }
}
+
};