From 211e7be58099445af48d5d678566794f39754ec2 Mon Sep 17 00:00:00 2001 From: Tamito Kajiyama Date: Sun, 18 Oct 2009 17:28:15 +0000 Subject: Fixed a bug in the Freestyle.Nature class that instances are always considered True even if their integer values are 0. --- source/blender/freestyle/intern/python/BPy_Nature.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'source/blender/freestyle') diff --git a/source/blender/freestyle/intern/python/BPy_Nature.cpp b/source/blender/freestyle/intern/python/BPy_Nature.cpp index 0e6a80e0feb..3769271712e 100644 --- a/source/blender/freestyle/intern/python/BPy_Nature.cpp +++ b/source/blender/freestyle/intern/python/BPy_Nature.cpp @@ -11,6 +11,7 @@ extern "C" { static PyObject *BPy_Nature___and__(PyObject *a, PyObject *b); static PyObject *BPy_Nature___xor__(PyObject *a, PyObject *b); static PyObject *BPy_Nature___or__(PyObject *a, PyObject *b); +static int BPy_Nature_bool(PyObject *v); /*-----------------------BPy_Nature number method definitions --------------------*/ @@ -24,7 +25,7 @@ PyNumberMethods nature_as_number = { 0, /* unaryfunc nb_negative */ 0, /* unaryfunc nb_positive */ 0, /* unaryfunc nb_absolute */ - 0, /* inquiry nb_bool */ + (inquiry)BPy_Nature_bool, /* inquiry nb_bool */ 0, /* unaryfunc nb_invert */ 0, /* binaryfunc nb_lshift */ 0, /* binaryfunc nb_rshift */ @@ -239,6 +240,12 @@ BPy_Nature___or__(PyObject *a, PyObject *b) return BPy_Nature_bitwise(a, '|', b); } +static int +BPy_Nature_bool(PyObject *v) +{ + return ((PyLongObject *)v)->ob_digit[0] != 0; +} + /////////////////////////////////////////////////////////////////////////////////////////// #ifdef __cplusplus -- cgit v1.2.3