diff options
Diffstat (limited to 'source/blender/python')
-rw-r--r-- | source/blender/python/SConscript | 2 | ||||
-rw-r--r-- | source/blender/python/generic/bpy_internal_import.c | 2 | ||||
-rw-r--r-- | source/blender/python/generic/idprop_py_api.c | 4 | ||||
-rw-r--r-- | source/blender/python/intern/CMakeLists.txt | 1 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_interface.c | 15 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_props.c | 2 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_rna.c | 36 |
7 files changed, 34 insertions, 28 deletions
diff --git a/source/blender/python/SConscript b/source/blender/python/SConscript index c98f347d5af..e9c8d50ef85 100644 --- a/source/blender/python/SConscript +++ b/source/blender/python/SConscript @@ -7,7 +7,7 @@ Import ('env') incs = '. ../editors/include ../makesdna ../makesrna ../blenfont ../blenlib ../blenkernel ../nodes' incs += ' ../imbuf ../blenloader ../gpu ../render/extern/include ../windowmanager' incs += ' ../freestyle/intern/python' -incs += ' #intern/guardedalloc #intern/memutil #extern/glew/include' +incs += ' #intern/guardedalloc #intern/memutil #extern/glew/include #intern/cycles/blender' incs += ' #intern/audaspace/intern ' + env['BF_PYTHON_INC'] is_debug = (env['OURPLATFORM'] in ('win32-mingw', 'win32-vc','win64-vc') and env['BF_DEBUG']) diff --git a/source/blender/python/generic/bpy_internal_import.c b/source/blender/python/generic/bpy_internal_import.c index db3519a3056..ecf65275483 100644 --- a/source/blender/python/generic/bpy_internal_import.c +++ b/source/blender/python/generic/bpy_internal_import.c @@ -101,7 +101,7 @@ void bpy_text_filename_get(char *fn, size_t fn_len, Text *text) PyObject *bpy_text_import(Text *text) { char *buf = NULL; - char modulename[24]; + char modulename[MAX_ID_NAME+2]; int len; if (!text->compiled) { diff --git a/source/blender/python/generic/idprop_py_api.c b/source/blender/python/generic/idprop_py_api.c index c058ee1d4f0..516c0afa883 100644 --- a/source/blender/python/generic/idprop_py_api.c +++ b/source/blender/python/generic/idprop_py_api.c @@ -249,7 +249,7 @@ static int BPy_IDGroup_SetName(BPy_IDProperty *self, PyObject *value, void *UNUS name = _PyUnicode_AsStringAndSize(value, &name_size); if (name_size > MAX_IDPROP_NAME) { - PyErr_SetString(PyExc_TypeError, "string length cannot exceed 31 characters!"); + PyErr_SetString(PyExc_TypeError, "string length cannot exceed 63 characters!"); return -1; } @@ -359,7 +359,7 @@ const char *BPy_IDProperty_Map_ValidateAndCreate(PyObject *name_obj, IDProperty Py_ssize_t name_size; name = _PyUnicode_AsStringAndSize(name_obj, &name_size); if (name_size > MAX_IDPROP_NAME) { - return "the length of IDProperty names is limited to 31 characters"; + return "the length of IDProperty names is limited to 63 characters"; } } diff --git a/source/blender/python/intern/CMakeLists.txt b/source/blender/python/intern/CMakeLists.txt index 76fe439027f..4b397ee1870 100644 --- a/source/blender/python/intern/CMakeLists.txt +++ b/source/blender/python/intern/CMakeLists.txt @@ -36,6 +36,7 @@ set(INC ../../gpu ../../freestyle/intern/python ../../../../intern/guardedalloc + ../../../../intern/cycles/blender ) set(INC_SYS diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index 7d91438e4f7..6c961d8e6a8 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -57,12 +57,13 @@ #include "BLI_string_utf8.h" #include "BLI_utildefines.h" - #include "BKE_context.h" #include "BKE_text.h" #include "BKE_main.h" #include "BKE_global.h" /* only for script checking */ +#include "CCL_api.h" + #include "BPY_extern.h" #include "../generic/bpy_internal_import.h" // our own imports @@ -176,8 +177,14 @@ void BPY_context_set(bContext *C) /* defined in AUD_C-API.cpp */ extern PyObject *AUD_initPython(void); -/* defined in cycles/blender */ -extern PyObject *CYCLES_initPython(void); + +#ifdef WITH_CYCLES +/* defined in cycles module */ +static PyObject *CCL_initPython(void) +{ + return (PyObject*)CCL_python_module_init(); +} +#endif static struct _inittab bpy_internal_modules[] = { {(char *)"mathutils", PyInit_mathutils}, @@ -189,7 +196,7 @@ static struct _inittab bpy_internal_modules[] = { {(char *)"aud", AUD_initPython}, #endif #ifdef WITH_CYCLES - {(char *)"_cycles", CYCLES_initPython}, + {(char *)"_cycles", CCL_initPython}, #endif {(char *)"gpu", GPU_initPython}, {NULL, NULL} diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c index 81eb81e90fa..d94ba8b9441 100644 --- a/source/blender/python/intern/bpy_props.c +++ b/source/blender/python/intern/bpy_props.c @@ -1423,7 +1423,7 @@ static PyObject *BPy_RemoveProperty(PyObject *self, PyObject *args, PyObject *kw return ret; } else if (PyTuple_GET_SIZE(args) > 1) { - PyErr_SetString(PyExc_ValueError, "all args must be keywords"); \ + PyErr_SetString(PyExc_ValueError, "all args must be keywords"); return NULL; } diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 9dfbe64e905..4940c53551e 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -743,14 +743,28 @@ int pyrna_enum_value_from_id(EnumPropertyItem *item, const char *identifier, int return 0; } +/* note on __cmp__: + * checking the 'ptr->data' matches works in almost all cases, + * however there are a few RNA properties that are fake sub-structs and + * share the pointer with the parent, in those cases this happens 'a.b == a' + * see: r43352 for example. + * + * So compare the 'ptr->type' as well to avoid this problem. + * It's highly unlikely this would happen that 'ptr->data' and 'ptr->prop' would match, + * but _not_ 'ptr->type' but include this check for completeness. + * - campbell */ + static int pyrna_struct_compare(BPy_StructRNA *a, BPy_StructRNA *b) { - return (a->ptr.data == b->ptr.data) ? 0 : -1; + return ( (a->ptr.data == b->ptr.data) && + (a->ptr.type == b->ptr.type)) ? 0 : -1; } static int pyrna_prop_compare(BPy_PropertyRNA *a, BPy_PropertyRNA *b) { - return (a->prop == b->prop && a->ptr.data == b->ptr.data) ? 0 : -1; + return ( (a->prop == b->prop) && + (a->ptr.data == b->ptr.data) && + (a->ptr.type == b->ptr.type) ) ? 0 : -1; } static PyObject *pyrna_struct_richcmp(PyObject *a, PyObject *b, int op) @@ -3055,7 +3069,6 @@ static PyObject *pyrna_struct_is_property_set(BPy_StructRNA *self, PyObject *arg { PropertyRNA *prop; const char *name; - int ret; PYRNA_STRUCT_CHECK_OBJ(self); @@ -3069,22 +3082,7 @@ static PyObject *pyrna_struct_is_property_set(BPy_StructRNA *self, PyObject *arg return NULL; } - /* double property lookup, could speed up */ - /* return PyBool_FromLong(RNA_property_is_set(&self->ptr, name)); */ - if (RNA_property_flag(prop) & PROP_IDPROPERTY) { - IDProperty *group = RNA_struct_idprops(&self->ptr, 0); - if (group) { - ret = IDP_GetPropertyFromGroup(group, name) ? 1:0; - } - else { - ret = 0; - } - } - else { - ret = 1; - } - - return PyBool_FromLong(ret); + return PyBool_FromLong(RNA_property_is_set(&self->ptr, prop)); } PyDoc_STRVAR(pyrna_struct_is_property_hidden_doc, |