From 5e3110af059b328e8ddcffbc07e403cd7817fa5f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 28 Sep 2011 09:18:20 +0000 Subject: add support for a 4th item for rna property enums in python so the numeric value can be passed, this is so you can animate the enum and keep the values even if you add items in the middle of the enum. - request from ZanQdo. --- source/blender/python/intern/bpy_props.c | 35 ++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) (limited to 'source/blender/python') diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c index 04c64bcbd3c..88383ce84d5 100644 --- a/source/blender/python/intern/bpy_props.c +++ b/source/blender/python/intern/bpy_props.c @@ -267,6 +267,18 @@ static int bpy_prop_callback_assign(struct PropertyRNA *prop, PyObject *update_c return 0; } +/* utility function we need for parsing int's in an if statement */ +static int py_long_as_int(PyObject *py_long, int *r_int) +{ + if(PyLong_CheckExact(py_long)) { + *r_int= (int)PyLong_AS_LONG(py_long); + return 0; + } + else { + return -1; + } +} + /* this define runs at the start of each function and deals with * returning a deferred property (to be registered later) */ #define BPY_PROPDEF_HEAD(_func) \ @@ -914,6 +926,7 @@ static EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, PyObject *def, i for(i=0; i