Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2010-08-31 15:31:21 +0400
committerCampbell Barton <ideasman42@gmail.com>2010-08-31 15:31:21 +0400
commitdfb8c5974e6f937c3404d0dd59f0e6424de455db (patch)
tree736b1fce3378f7fdea6559a3dcda90f7fe368bfc /source/blender/makesrna/intern/rna_access.c
parent9a290b39c73d915d800860fa0d52ec7f036ec89e (diff)
rna support for passing dynamic sized arrays to rna functions
using this for object.vertex_groups.assign([index list ...], group, weight, mode)
Diffstat (limited to 'source/blender/makesrna/intern/rna_access.c')
-rw-r--r--source/blender/makesrna/intern/rna_access.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index ce3ace0ae1f..4be9502d79a 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -3839,7 +3839,14 @@ ParameterList *RNA_parameter_list_create(ParameterList *parms, PointerRNA *ptr,
for(parm= func->cont.properties.first; parm; parm= parm->next) {
size= rna_parameter_size(parm);
- if(!(parm->flag & PROP_REQUIRED)) {
+ /* set length to 0, these need to be set later, see bpy_array.c's py_to_array */
+ if (parm->flag & PROP_DYNAMIC) {
+ ParameterDynAlloc *data_alloc= data;
+ data_alloc->array_tot= 0;
+ data_alloc->array= NULL;
+ }
+
+ if(!(parm->flag & PROP_REQUIRED) && !(parm->flag & PROP_DYNAMIC)) {
switch(parm->type) {
case PROP_BOOLEAN:
if(parm->arraydimension) memcpy(data, &((BooleanPropertyRNA*)parm)->defaultarray, size);
@@ -3868,10 +3875,6 @@ ParameterList *RNA_parameter_list_create(ParameterList *parms, PointerRNA *ptr,
}
}
- /* set length to 0 */
- if (parm->flag & PROP_DYNAMIC)
- *((int *)(((char *)data) + size))= 0;
-
data= ((char*)data) + rna_parameter_size_alloc(parm);
}
@@ -3889,9 +3892,9 @@ void RNA_parameter_list_free(ParameterList *parms)
BLI_freelistN((ListBase*)((char*)parms->data+tot));
else if (parm->flag & PROP_DYNAMIC) {
/* for dynamic arrays and strings, data is a pointer to an array */
- char *array= *(char**)((char*)parms->data+tot);
- if(array)
- MEM_freeN(array);
+ ParameterDynAlloc *data_alloc= (void *)(((char *)parms->data) + tot);
+ if(data_alloc->array)
+ MEM_freeN(data_alloc->array);
}
tot+= rna_parameter_size_alloc(parm);
@@ -4053,12 +4056,12 @@ void RNA_parameter_length_set(ParameterList *parms, PropertyRNA *parm, int lengt
int RNA_parameter_length_get_data(ParameterList *parms, PropertyRNA *parm, void *data)
{
- return *((int *)(((char *)data) + rna_parameter_size(parm)));
+ return *((int *)((char *)data));
}
void RNA_parameter_length_set_data(ParameterList *parms, PropertyRNA *parm, void *data, int length)
{
- *((int *)(((char *)data) + rna_parameter_size(parm)))= length;
+ *((int *)data)= length;
}
int RNA_function_call(bContext *C, ReportList *reports, PointerRNA *ptr, FunctionRNA *func, ParameterList *parms)