diff options
author | Arystanbek Dyussenov <arystan.d@gmail.com> | 2009-09-06 19:13:57 +0400 |
---|---|---|
committer | Arystanbek Dyussenov <arystan.d@gmail.com> | 2009-09-06 19:13:57 +0400 |
commit | 62138aaa5a7f931fa2ddb4815f755413111cceb0 (patch) | |
tree | d675dc3decf8f86ec0dd60a659976723784dd5f4 /source/blender/python/intern/bpy_rna.h | |
parent | 3d64d65ad9c43f82bd4b9241b4a7fdde0fd12000 (diff) |
Python part of multidim. array support for RNA complete.
Multidim. arrays can now be modified at any level, for example:
struc.arrayprop = x
struc.arrayprop[i] = x
struc.arrayprop[i][j] = x
struc.arrayprop[i][j][k] = x
etc...
Approriate rvalue type/length checking is done.
To ensure all works correctly, I wrote automated tests in release/test/rna_array.py.
These tests cover: array/item access, assignment on different levels, tests that proper exceptions are thrown on invalid item access/assignment.
The tests use properties of the RNA Test struct defined in rna_test.c. This struct is only compiled when building with BF_UNIT_TEST=1 scons arg.
Currently unit tests are run manually by loading the script in the Text Editor.
Here's the output I have: http://www.pasteall.org/7644
Things to improve here:
- better exception messages when multidim. array assignment fails. Those we have currently are not very useful for multidim.
- add tests for slice assignment
Diffstat (limited to 'source/blender/python/intern/bpy_rna.h')
-rw-r--r-- | source/blender/python/intern/bpy_rna.h | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/source/blender/python/intern/bpy_rna.h b/source/blender/python/intern/bpy_rna.h index d65849ad8a4..d006b168f45 100644 --- a/source/blender/python/intern/bpy_rna.h +++ b/source/blender/python/intern/bpy_rna.h @@ -55,6 +55,10 @@ typedef struct { PyObject_HEAD /* required python macro */ PointerRNA ptr; PropertyRNA *prop; + + /* Arystan: this is a hack to allow sub-item r/w access like: face.uv[n][m] */ + int arraydim; /* array dimension, e.g: 0 for face.uv, 2 for face.uv[n][m], etc. */ + int arrayoffset; /* array first item offset, e.g. if face.uv is [4][2], arrayoffset for face.uv[n] is 2n */ } BPy_PropertyRNA; /* cheap trick */ @@ -92,8 +96,11 @@ void pyrna_alloc_types(void); void pyrna_free_types(void); /* primitive type conversion */ -int pyrna_py_to_boolean_array(PyObject *py, PointerRNA *ptr, PropertyRNA *prop, char *param_data, char *error_str, int error_str_size); -int pyrna_py_to_int_array(PyObject *py, PointerRNA *ptr, PropertyRNA *prop, char *param_data, char *error_str, int error_str_size); -int pyrna_py_to_float_array(PyObject *py, PointerRNA *ptr, PropertyRNA *prop, char *param_data, char *error_str, int error_str_size); +int pyrna_py_to_array(PointerRNA *ptr, PropertyRNA *prop, char *param_data, PyObject *py, const char *error_prefix); +int pyrna_py_to_array_index(PointerRNA *ptr, PropertyRNA *prop, int arraydim, int arrayoffset, int index, PyObject *py, const char *error_prefix); + +PyObject *pyrna_py_from_array(PointerRNA *ptr, PropertyRNA *prop); +PyObject *pyrna_py_from_array_index(BPy_PropertyRNA *self, int index); +PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop); #endif |