diff options
author | Campbell Barton <ideasman42@gmail.com> | 2016-05-28 15:23:39 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2016-05-28 15:30:25 +0300 |
commit | a9f7bbc9f8f745d65ebf612a6b880782320831f7 (patch) | |
tree | 8153a10f5b7da1733b27b217fb917777187968d2 /source/blender/python | |
parent | 98ad47332466b13f35de80639a54b3493786fddb (diff) |
PyRNA: Fix repr used /w arrays
RNA arrays now display their index, with support for multi-dimensional arrays.
Diffstat (limited to 'source/blender/python')
-rw-r--r-- | source/blender/python/intern/bpy_rna.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 33ac58dadb1..49b806347d6 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -973,7 +973,9 @@ static PyObject *pyrna_prop_str(BPy_PropertyRNA *self) RNA_property_identifier(self->prop)); } -static PyObject *pyrna_prop_repr(BPy_PropertyRNA *self) +static PyObject *pyrna_prop_repr_ex( + BPy_PropertyRNA *self, + const int index_dim, const int index) { ID *id = self->ptr.id.data; PyObject *tmp_str; @@ -987,7 +989,8 @@ static PyObject *pyrna_prop_repr(BPy_PropertyRNA *self) tmp_str = PyUnicode_FromString(id->name + 2); - path = RNA_path_from_ID_to_property(&self->ptr, self->prop); + path = RNA_path_from_ID_to_property_index(&self->ptr, self->prop, index_dim, index); + if (path) { const char *data_delim = (path[0] == '[') ? "" : "."; if (GS(id->name) == ID_NT) { /* nodetree paths are not accurate */ @@ -1015,6 +1018,15 @@ static PyObject *pyrna_prop_repr(BPy_PropertyRNA *self) return ret; } +static PyObject *pyrna_prop_repr(BPy_PropertyRNA *self) +{ + return pyrna_prop_repr_ex(self, 0, -1); +} + +static PyObject *pyrna_prop_array_repr(BPy_PropertyArrayRNA *self) +{ + return pyrna_prop_repr_ex((BPy_PropertyRNA *)self, self->arraydim, self->arrayoffset); +} static PyObject *pyrna_func_repr(BPy_FunctionRNA *self) { @@ -5841,7 +5853,7 @@ PyTypeObject pyrna_prop_array_Type = { NULL, /* getattrfunc tp_getattr; */ NULL, /* setattrfunc tp_setattr; */ NULL, /* tp_compare */ /* DEPRECATED in python 3.0! */ - NULL, /* subclassed */ /* tp_repr */ + (reprfunc)pyrna_prop_array_repr, /* tp_repr */ /* Method suites for standard classes */ |