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:
-rw-r--r--source/blender/makesrna/RNA_access.h5
-rw-r--r--source/blender/makesrna/RNA_define.h8
-rw-r--r--source/blender/makesrna/intern/makesrna.c234
-rw-r--r--source/blender/makesrna/intern/rna_access.c273
-rw-r--r--source/blender/makesrna/intern/rna_define.c116
-rw-r--r--source/blender/makesrna/intern/rna_internal_types.h19
-rw-r--r--source/blender/makesrna/intern/rna_mesh.c52
-rw-r--r--source/blender/makesrna/intern/rna_object.c4
-rw-r--r--source/blender/makesrna/intern/rna_render.c62
-rw-r--r--source/blender/makesrna/intern/rna_rna.c2
-rw-r--r--source/blender/python/intern/bpy_array.c69
-rw-r--r--source/blender/python/intern/bpy_rna.c8
12 files changed, 475 insertions, 377 deletions
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h
index 4107c1346e5..05f39d73842 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -586,10 +586,9 @@ PropertyUnit RNA_property_unit(PropertyRNA *prop);
int RNA_property_flag(PropertyRNA *prop);
int RNA_property_array_length(PointerRNA *ptr, PropertyRNA *prop);
-int RNA_property_multidimensional_array_length(PointerRNA *ptr, PropertyRNA *prop, int dimension);
-int RNA_property_dynamic_array_set_length(PointerRNA *ptr, PropertyRNA *prop, int length);
+int RNA_property_multi_array_length(PointerRNA *ptr, PropertyRNA *prop, int dimension);
+int RNA_property_array_dimension(PointerRNA *ptr, PropertyRNA *prop, int length[]);
char RNA_property_array_item_char(PropertyRNA *prop, int index);
-unsigned short RNA_property_array_dimension(PropertyRNA *prop, unsigned short dim_size[]);
int RNA_property_string_maxlength(PropertyRNA *prop);
diff --git a/source/blender/makesrna/RNA_define.h b/source/blender/makesrna/RNA_define.h
index 03b12da1629..42c5343dbff 100644
--- a/source/blender/makesrna/RNA_define.h
+++ b/source/blender/makesrna/RNA_define.h
@@ -90,7 +90,7 @@ void RNA_def_enum_funcs(PropertyRNA *prop, EnumPropertyItemFunc itemfunc);
PropertyRNA *RNA_def_float(StructOrFunctionRNA *cont, const char *identifier, float default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax);
PropertyRNA *RNA_def_float_vector(StructOrFunctionRNA *cont, const char *identifier, int len, const float *default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax);
PropertyRNA *RNA_def_float_color(StructOrFunctionRNA *cont, const char *identifier, int len, const float *default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax);
-PropertyRNA *RNA_def_float_matrix(StructOrFunctionRNA *cont, const char *identifier, int len, int rowsize, const float *default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax);
+PropertyRNA *RNA_def_float_matrix(StructOrFunctionRNA *cont, const char *identifier, int rows, int columns, const float *default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax);
PropertyRNA *RNA_def_float_rotation(StructOrFunctionRNA *cont, const char *identifier, int len, const float *default_value,
float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax);
PropertyRNA *RNA_def_float_array(StructOrFunctionRNA *cont, const char *identifier, int len, const float *default_value,
@@ -128,8 +128,8 @@ void RNA_def_property_collection_sdna(PropertyRNA *prop, const char *structname,
void RNA_def_property_flag(PropertyRNA *prop, int flag);
void RNA_def_property_clear_flag(PropertyRNA *prop, int flag);
-void RNA_def_property_array(PropertyRNA *prop, int arraylength);
-void RNA_def_property_multidimensional_array(PropertyRNA *prop, int arraylength, unsigned short arraydimension, unsigned short dimsize[]);
+void RNA_def_property_array(PropertyRNA *prop, int length);
+void RNA_def_property_multi_array(PropertyRNA *prop, int dimension, int length[]);
void RNA_def_property_range(PropertyRNA *prop, double min, double max);
void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item);
@@ -153,7 +153,7 @@ void RNA_def_property_ui_icon(PropertyRNA *prop, int icon, int consecutive);
void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *updatefunc);
void RNA_def_property_editable_func(PropertyRNA *prop, const char *editable);
-void RNA_def_property_dynamic_array_funcs(PropertyRNA *prop, const char *getlength, const char *setlength);
+void RNA_def_property_dynamic_array_funcs(PropertyRNA *prop, const char *getlength);
void RNA_def_property_boolean_funcs(PropertyRNA *prop, const char *get, const char *set);
void RNA_def_property_int_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range);
void RNA_def_property_float_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range);
diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c
index cbfd7d326de..a3c4af26478 100644
--- a/source/blender/makesrna/intern/makesrna.c
+++ b/source/blender/makesrna/intern/makesrna.c
@@ -306,11 +306,10 @@ static void rna_int_print(FILE *f, int num)
static char *rna_def_property_get_func(FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA *dp, const char *manualfunc)
{
char *func;
- int i;
if(prop->flag & PROP_IDPROPERTY)
return NULL;
-
+
if(!manualfunc) {
if(!dp->dnastructname || !dp->dnaname) {
fprintf(stderr, "rna_def_property_get_func: %s.%s has no valid dna info.\n", srna->identifier, prop->identifier);
@@ -373,8 +372,11 @@ static char *rna_def_property_get_func(FILE *f, StructRNA *srna, PropertyRNA *pr
break;
}
default:
- if(prop->arraylength) {
- fprintf(f, "void %s(PointerRNA *ptr, %s values[%d])\n", func, rna_type_type(prop), prop->arraylength);
+ if(prop->arraydimension) {
+ if(prop->flag & PROP_DYNAMIC)
+ fprintf(f, "void %s(PointerRNA *ptr, %s values[])\n", func, rna_type_type(prop));
+ else
+ fprintf(f, "void %s(PointerRNA *ptr, %s values[%d])\n", func, rna_type_type(prop), prop->totarraylength);
fprintf(f, "{\n");
if(manualfunc) {
@@ -383,27 +385,38 @@ static char *rna_def_property_get_func(FILE *f, StructRNA *srna, PropertyRNA *pr
else {
rna_print_data_get(f, dp);
- for(i=0; i<prop->arraylength; i++) {
- if(dp->dnaarraylength == 1) {
- if(prop->type == PROP_BOOLEAN && dp->booleanbit)
- fprintf(f, " values[%d]= (%s(data->%s & (%d<<%d)) != 0);\n", i, (dp->booleannegative)? "!": "", dp->dnaname, dp->booleanbit, i);
- else
- fprintf(f, " values[%d]= (%s)%s((&data->%s)[%d]);\n", i, rna_type_type(prop), (dp->booleannegative)? "!": "", dp->dnaname, i);
- }
- else {
- if(prop->type == PROP_BOOLEAN && dp->booleanbit) {
- fprintf(f, " values[%d]= (%s(data->%s[%d] & ", i, (dp->booleannegative)? "!": "", dp->dnaname, i);
- rna_int_print(f, dp->booleanbit);
- fprintf(f, ") != 0);\n");
- }
- else if(rna_color_quantize(prop, dp))
- fprintf(f, " values[%d]= (%s)(data->%s[%d]*(1.0f/255.0f));\n", i, rna_type_type(prop), dp->dnaname, i);
- else if(dp->dnatype)
- fprintf(f, " values[%d]= (%s)%s(((%s*)data->%s)[%d]);\n", i, rna_type_type(prop), (dp->booleannegative)? "!": "", dp->dnatype, dp->dnaname, i);
- else
- fprintf(f, " values[%d]= (%s)%s((data->%s)[%d]);\n", i, rna_type_type(prop), (dp->booleannegative)? "!": "", dp->dnaname, i);
+ if(prop->flag & PROP_DYNAMIC) {
+ char *lenfunc= rna_alloc_function_name(srna->identifier, prop->identifier, "get_length");
+ fprintf(f, " int i, arraylen[RNA_MAX_ARRAY_DIMENSION];\n");
+ fprintf(f, " int len= %s(ptr, arraylen);\n\n", lenfunc);
+ fprintf(f, " for(i=0; i<len; i++) {\n");
+ MEM_freeN(lenfunc);
+ }
+ else {
+ fprintf(f, " int i;\n\n");
+ fprintf(f, " for(i=0; i<%d; i++) {\n", prop->totarraylength);
+ }
+
+ if(dp->dnaarraylength == 1) {
+ if(prop->type == PROP_BOOLEAN && dp->booleanbit)
+ fprintf(f, " values[i]= (%s(data->%s & (%d<<i)) != 0);\n", (dp->booleannegative)? "!": "", dp->dnaname, dp->booleanbit);
+ else
+ fprintf(f, " values[i]= (%s)%s((&data->%s)[i]);\n", rna_type_type(prop), (dp->booleannegative)? "!": "", dp->dnaname);
+ }
+ else {
+ if(prop->type == PROP_BOOLEAN && dp->booleanbit) {
+ fprintf(f, " values[i]= (%s(data->%s[i] & ", (dp->booleannegative)? "!": "", dp->dnaname);
+ rna_int_print(f, dp->booleanbit);
+ fprintf(f, ") != 0);\n");
}
+ else if(rna_color_quantize(prop, dp))
+ fprintf(f, " values[i]= (%s)(data->%s[i]*(1.0f/255.0f));\n", rna_type_type(prop), dp->dnaname);
+ else if(dp->dnatype)
+ fprintf(f, " values[i]= (%s)%s(((%s*)data->%s)[i]);\n", rna_type_type(prop), (dp->booleannegative)? "!": "", dp->dnatype, dp->dnaname);
+ else
+ fprintf(f, " values[i]= (%s)%s((data->%s)[i]);\n", rna_type_type(prop), (dp->booleannegative)? "!": "", dp->dnaname);
}
+ fprintf(f, " }\n");
}
fprintf(f, "}\n\n");
}
@@ -438,13 +451,13 @@ static char *rna_def_property_get_func(FILE *f, StructRNA *srna, PropertyRNA *pr
return func;
}
-static void rna_clamp_value(FILE *f, PropertyRNA *prop, int array, int i)
+static void rna_clamp_value(FILE *f, PropertyRNA *prop, int array)
{
if(prop->type == PROP_INT) {
IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
if(iprop->hardmin != INT_MIN || iprop->hardmax != INT_MAX) {
- if(array) fprintf(f, "CLAMPIS(values[%d], ", i);
+ if(array) fprintf(f, "CLAMPIS(values[i], ");
else fprintf(f, "CLAMPIS(value, ");
rna_int_print(f, iprop->hardmin); fprintf(f, ", ");
rna_int_print(f, iprop->hardmax); fprintf(f, ");\n");
@@ -455,7 +468,7 @@ static void rna_clamp_value(FILE *f, PropertyRNA *prop, int array, int i)
FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop;
if(fprop->hardmin != -FLT_MAX || fprop->hardmax != FLT_MAX) {
- if(array) fprintf(f, "CLAMPIS(values[%d], ", i);
+ if(array) fprintf(f, "CLAMPIS(values[i], ");
else fprintf(f, "CLAMPIS(value, ");
rna_float_print(f, fprop->hardmin); fprintf(f, ", ");
rna_float_print(f, fprop->hardmax); fprintf(f, ");\n");
@@ -464,7 +477,7 @@ static void rna_clamp_value(FILE *f, PropertyRNA *prop, int array, int i)
}
if(array)
- fprintf(f, "values[%d];\n", i);
+ fprintf(f, "values[i];\n");
else
fprintf(f, "value;\n");
}
@@ -472,7 +485,6 @@ static void rna_clamp_value(FILE *f, PropertyRNA *prop, int array, int i)
static char *rna_def_property_set_func(FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA *dp, char *manualfunc)
{
char *func;
- int i;
if(!(prop->flag & PROP_EDITABLE))
return NULL;
@@ -532,8 +544,11 @@ static char *rna_def_property_set_func(FILE *f, StructRNA *srna, PropertyRNA *pr
break;
}
default:
- if(prop->arraylength) {
- fprintf(f, "void %s(PointerRNA *ptr, const %s values[%d])\n", func, rna_type_type(prop), prop->arraylength);
+ if(prop->arraydimension) {
+ if(prop->flag & PROP_DYNAMIC)
+ fprintf(f, "void %s(PointerRNA *ptr, const %s values[])\n", func, rna_type_type(prop));
+ else
+ fprintf(f, "void %s(PointerRNA *ptr, const %s values[%d])\n", func, rna_type_type(prop), prop->totarraylength);
fprintf(f, "{\n");
if(manualfunc) {
@@ -542,38 +557,49 @@ static char *rna_def_property_set_func(FILE *f, StructRNA *srna, PropertyRNA *pr
else {
rna_print_data_get(f, dp);
- for(i=0; i<prop->arraylength; i++) {
- if(dp->dnaarraylength == 1) {
- if(prop->type == PROP_BOOLEAN && dp->booleanbit) {
- fprintf(f, " if(%svalues[%d]) data->%s |= (%d<<%d);\n", (dp->booleannegative)? "!": "", i, dp->dnaname, dp->booleanbit, i);
- fprintf(f, " else data->%s &= ~(%d<<%d);\n", dp->dnaname, dp->booleanbit, i);
- }
- else {
- fprintf(f, " (&data->%s)[%d]= %s", dp->dnaname, i, (dp->booleannegative)? "!": "");
- rna_clamp_value(f, prop, 1, i);
- }
+ if(prop->flag & PROP_DYNAMIC) {
+ char *lenfunc= rna_alloc_function_name(srna->identifier, prop->identifier, "set_length");
+ fprintf(f, " int i, arraylen[RNA_MAX_ARRAY_DIMENSION];\n");
+ fprintf(f, " int len= %s(ptr, arraylen);\n\n", lenfunc);
+ fprintf(f, " for(i=0; i<len; i++) {\n");
+ MEM_freeN(lenfunc);
+ }
+ else {
+ fprintf(f, " int i;\n\n");
+ fprintf(f, " for(i=0; i<%d; i++) {\n", prop->totarraylength);
+ }
+
+ if(dp->dnaarraylength == 1) {
+ if(prop->type == PROP_BOOLEAN && dp->booleanbit) {
+ fprintf(f, " if(%svalues[i]) data->%s |= (%d<<i);\n", (dp->booleannegative)? "!": "", dp->dnaname, dp->booleanbit);
+ fprintf(f, " else data->%s &= ~(%d<<i);\n", dp->dnaname, dp->booleanbit);
+ }
+ else {
+ fprintf(f, " (&data->%s)[i]= %s", dp->dnaname, (dp->booleannegative)? "!": "");
+ rna_clamp_value(f, prop, 1);
+ }
+ }
+ else {
+ if(prop->type == PROP_BOOLEAN && dp->booleanbit) {
+ fprintf(f, " if(%svalues[i]) data->%s[i] |= ", (dp->booleannegative)? "!": "", dp->dnaname);
+ rna_int_print(f, dp->booleanbit);
+ fprintf(f, ";\n");
+ fprintf(f, " else data->%s[i] &= ~", dp->dnaname);
+ rna_int_print(f, dp->booleanbit);
+ fprintf(f, ";\n");
+ }
+ else if(rna_color_quantize(prop, dp)) {
+ fprintf(f, " data->%s[i]= FTOCHAR(values[i]);\n", dp->dnaname);
}
else {
- if(prop->type == PROP_BOOLEAN && dp->booleanbit) {
- fprintf(f, " if(%svalues[%d]) data->%s[%d] |= ", (dp->booleannegative)? "!": "", i, dp->dnaname, i);
- rna_int_print(f, dp->booleanbit);
- fprintf(f, ";\n");
- fprintf(f, " else data->%s[%d] &= ~", dp->dnaname, i);
- rna_int_print(f, dp->booleanbit);
- fprintf(f, ";\n");
- }
- else if(rna_color_quantize(prop, dp)) {
- fprintf(f, " data->%s[%d]= FTOCHAR(values[%d]);\n", dp->dnaname, i, i);
- }
- else {
- if(dp->dnatype)
- fprintf(f, " ((%s*)data->%s)[%d]= %s", dp->dnatype, dp->dnaname, i, (dp->booleannegative)? "!": "");
- else
- fprintf(f, " (data->%s)[%d]= %s", dp->dnaname, i, (dp->booleannegative)? "!": "");
- rna_clamp_value(f, prop, 1, i);
- }
+ if(dp->dnatype)
+ fprintf(f, " ((%s*)data->%s)[i]= %s", dp->dnatype, dp->dnaname, (dp->booleannegative)? "!": "");
+ else
+ fprintf(f, " (data->%s)[i]= %s", dp->dnaname, (dp->booleannegative)? "!": "");
+ rna_clamp_value(f, prop, 1);
}
}
+ fprintf(f, " }\n");
}
fprintf(f, "}\n\n");
}
@@ -602,7 +628,7 @@ static char *rna_def_property_set_func(FILE *f, StructRNA *srna, PropertyRNA *pr
}
else {
fprintf(f, " data->%s= %s", dp->dnaname, (dp->booleannegative)? "!": "");
- rna_clamp_value(f, prop, 0, 0);
+ rna_clamp_value(f, prop, 0);
}
}
fprintf(f, "}\n\n");
@@ -819,7 +845,7 @@ static void rna_def_property_funcs(FILE *f, StructRNA *srna, PropertyDefRNA *dp)
case PROP_BOOLEAN: {
BooleanPropertyRNA *bprop= (BooleanPropertyRNA*)prop;
- if(!prop->arraylength) {
+ if(!prop->arraydimension) {
if(!bprop->get && !bprop->set && !dp->booleanbit)
rna_set_raw_property(dp, prop);
@@ -835,7 +861,7 @@ static void rna_def_property_funcs(FILE *f, StructRNA *srna, PropertyDefRNA *dp)
case PROP_INT: {
IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
- if(!prop->arraylength) {
+ if(!prop->arraydimension) {
if(!iprop->get && !iprop->set)
rna_set_raw_property(dp, prop);
@@ -854,7 +880,7 @@ static void rna_def_property_funcs(FILE *f, StructRNA *srna, PropertyDefRNA *dp)
case PROP_FLOAT: {
FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop;
- if(!prop->arraylength) {
+ if(!prop->arraydimension) {
if(!fprop->get && !fprop->set)
rna_set_raw_property(dp, prop);
@@ -953,23 +979,23 @@ static void rna_def_property_funcs_header(FILE *f, StructRNA *srna, PropertyDefR
switch(prop->type) {
case PROP_BOOLEAN:
case PROP_INT: {
- if(!prop->arraylength) {
+ if(!prop->arraydimension) {
fprintf(f, "int %sget(PointerRNA *ptr);\n", func);
//fprintf(f, "void %sset(PointerRNA *ptr, int value);\n", func);
}
else {
- fprintf(f, "void %sget(PointerRNA *ptr, int values[%d]);\n", func, prop->arraylength);
+ fprintf(f, "void %sget(PointerRNA *ptr, int values[%d]);\n", func, prop->totarraylength);
//fprintf(f, "void %sset(PointerRNA *ptr, const int values[%d]);\n", func, prop->arraylength);
}
break;
}
case PROP_FLOAT: {
- if(!prop->arraylength) {
+ if(!prop->arraydimension) {
fprintf(f, "float %sget(PointerRNA *ptr);\n", func);
//fprintf(f, "void %sset(PointerRNA *ptr, float value);\n", func);
}
else {
- fprintf(f, "void %sget(PointerRNA *ptr, float values[%d]);\n", func, prop->arraylength);
+ fprintf(f, "void %sget(PointerRNA *ptr, float values[%d]);\n", func, prop->totarraylength);
//fprintf(f, "void %sset(PointerRNA *ptr, const float values[%d]);\n", func, prop->arraylength);
}
break;
@@ -1043,24 +1069,24 @@ static void rna_def_property_funcs_header_cpp(FILE *f, StructRNA *srna, Property
switch(prop->type) {
case PROP_BOOLEAN: {
- if(!prop->arraylength)
+ if(!prop->arraydimension)
fprintf(f, "\tbool %s(void);", prop->identifier);
else
- fprintf(f, "\tArray<int, %d> %s(void);", prop->arraylength, prop->identifier);
+ fprintf(f, "\tArray<int, %d> %s(void);", prop->totarraylength, prop->identifier);
break;
}
case PROP_INT: {
- if(!prop->arraylength)
+ if(!prop->arraydimension)
fprintf(f, "\tint %s(void);", prop->identifier);
else
- fprintf(f, "\tArray<int, %d> %s(void);", prop->arraylength, prop->identifier);
+ fprintf(f, "\tArray<int, %d> %s(void);", prop->totarraylength, prop->identifier);
break;
}
case PROP_FLOAT: {
- if(!prop->arraylength)
+ if(!prop->arraydimension)
fprintf(f, "\tfloat %s(void);", prop->identifier);
else
- fprintf(f, "\tArray<float, %d> %s(void);", prop->arraylength, prop->identifier);
+ fprintf(f, "\tArray<float, %d> %s(void);", prop->totarraylength, prop->identifier);
break;
}
case PROP_ENUM: {
@@ -1118,24 +1144,24 @@ static void rna_def_property_funcs_impl_cpp(FILE *f, StructRNA *srna, PropertyDe
switch(prop->type) {
case PROP_BOOLEAN: {
- if(!prop->arraylength)
+ if(!prop->arraydimension)
fprintf(f, "\tBOOLEAN_PROPERTY(%s, %s)", srna->identifier, prop->identifier);
else
- fprintf(f, "\tBOOLEAN_ARRAY_PROPERTY(%s, %d, %s)", srna->identifier, prop->arraylength, prop->identifier);
+ fprintf(f, "\tBOOLEAN_ARRAY_PROPERTY(%s, %d, %s)", srna->identifier, prop->totarraylength, prop->identifier);
break;
}
case PROP_INT: {
- if(!prop->arraylength)
+ if(!prop->arraydimension)
fprintf(f, "\tINT_PROPERTY(%s, %s)", srna->identifier, prop->identifier);
else
- fprintf(f, "\tINT_ARRAY_PROPERTY(%s, %d, %s)", srna->identifier, prop->arraylength, prop->identifier);
+ fprintf(f, "\tINT_ARRAY_PROPERTY(%s, %d, %s)", srna->identifier, prop->totarraylength, prop->identifier);
break;
}
case PROP_FLOAT: {
- if(!prop->arraylength)
+ if(!prop->arraydimension)
fprintf(f, "\tFLOAT_PROPERTY(%s, %s)", srna->identifier, prop->identifier);
else
- fprintf(f, "\tFLOAT_ARRAY_PROPERTY(%s, %d, %s)", srna->identifier, prop->arraylength, prop->identifier);
+ fprintf(f, "\tFLOAT_ARRAY_PROPERTY(%s, %d, %s)", srna->identifier, prop->totarraylength, prop->identifier);
break;
}
case PROP_ENUM: {
@@ -1198,7 +1224,7 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA
dparm= dfunc->cont.properties.first;
for(; dparm; dparm= dparm->next) {
- if(dparm->prop->arraylength > 0)
+ if(dparm->prop->arraydimension)
ptrstr= "*";
else if(dparm->prop==func->ret)
ptrstr= ((dparm->prop->type == PROP_POINTER) && !(dparm->prop->flag & PROP_RNAPTR))? "*": "";
@@ -1225,7 +1251,7 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA
for(; dparm; dparm= dparm->next) {
if(dparm->prop==func->ret)
fprintf(f, "\t_retdata= _data;\n");
- else if(dparm->prop->arraylength)
+ else if(dparm->prop->arraydimension)
fprintf(f, "\t%s= ((%s%s*)_data);\n", dparm->prop->identifier, rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop));
else if(dparm->prop->type == PROP_POINTER) {
if(dparm->prop->flag & PROP_RNAPTR)
@@ -1280,7 +1306,7 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA
if(func->ret) {
dparm= rna_find_parameter_def(func->ret);
- ptrstr= (((dparm->prop->type == PROP_POINTER) && !(dparm->prop->flag & PROP_RNAPTR)) || (dparm->prop->arraylength > 0))? "*": "";
+ ptrstr= (((dparm->prop->type == PROP_POINTER) && !(dparm->prop->flag & PROP_RNAPTR)) || (dparm->prop->arraydimension))? "*": "";
fprintf(f, "\t*((%s%s%s*)_retdata)= %s;\n", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop), ptrstr, func->ret->identifier);
}
}
@@ -1522,7 +1548,7 @@ static void rna_generate_static_parameter_prototypes(BlenderRNA *brna, StructRNA
/* return type */
for(dparm= dfunc->cont.properties.first; dparm; dparm= dparm->next) {
if(dparm->prop==func->ret) {
- if(dparm->prop->arraylength)
+ if(dparm->prop->arraydimension)
fprintf(f, "XXX no array return types yet"); /* XXX not supported */
else if(dparm->prop->type == PROP_POINTER && !(dparm->prop->flag & PROP_RNAPTR))
fprintf(f, "%s%s *", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop));
@@ -1569,8 +1595,8 @@ static void rna_generate_static_parameter_prototypes(BlenderRNA *brna, StructRNA
if(!first) fprintf(f, ", ");
first= 0;
- if(dparm->prop->arraylength)
- fprintf(f, "%s%s %s[%d]", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop), dparm->prop->identifier, dparm->prop->arraylength);
+ if(dparm->prop->arraydimension)
+ fprintf(f, "%s%s %s[%d]", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop), dparm->prop->identifier, dparm->prop->totarraylength);
else if(dparm->prop->type == PROP_POINTER)
fprintf(f, "%s%s *%s", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop), dparm->prop->identifier);
else
@@ -1653,15 +1679,15 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr
BooleanPropertyRNA *bprop= (BooleanPropertyRNA*)prop;
unsigned int i;
- if(prop->arraylength) {
- fprintf(f, "static int rna_%s%s_%s_default[%d] = {", srna->identifier, strnest, prop->identifier, prop->arraylength);
+ if(prop->arraydimension) {
+ fprintf(f, "static int rna_%s%s_%s_default[%d] = {", srna->identifier, strnest, prop->identifier, prop->totarraylength);
- for(i=0; i<prop->arraylength; i++) {
+ for(i=0; i<prop->totarraylength; i++) {
if(bprop->defaultarray)
fprintf(f, "%d", bprop->defaultarray[i]);
else
fprintf(f, "%d", bprop->defaultvalue);
- if(i != prop->arraylength-1)
+ if(i != prop->totarraylength-1)
fprintf(f, ", ");
}
@@ -1673,15 +1699,15 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr
IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
unsigned int i;
- if(prop->arraylength) {
- fprintf(f, "static int rna_%s%s_%s_default[%d] = {", srna->identifier, strnest, prop->identifier, prop->arraylength);
+ if(prop->arraydimension) {
+ fprintf(f, "static int rna_%s%s_%s_default[%d] = {", srna->identifier, strnest, prop->identifier, prop->totarraylength);
- for(i=0; i<prop->arraylength; i++) {
+ for(i=0; i<prop->totarraylength; i++) {
if(iprop->defaultarray)
fprintf(f, "%d", iprop->defaultarray[i]);
else
fprintf(f, "%d", iprop->defaultvalue);
- if(i != prop->arraylength-1)
+ if(i != prop->totarraylength-1)
fprintf(f, ", ");
}
@@ -1693,15 +1719,15 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr
FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop;
unsigned int i;
- if(prop->arraylength) {
- fprintf(f, "static float rna_%s%s_%s_default[%d] = {", srna->identifier, strnest, prop->identifier, prop->arraylength);
+ if(prop->arraydimension) {
+ fprintf(f, "static float rna_%s%s_%s_default[%d] = {", srna->identifier, strnest, prop->identifier, prop->totarraylength);
- for(i=0; i<prop->arraylength; i++) {
+ for(i=0; i<prop->totarraylength; i++) {
if(fprop->defaultarray)
rna_float_print(f, fprop->defaultarray[i]);
else
rna_float_print(f, fprop->defaultvalue);
- if(i != prop->arraylength-1)
+ if(i != prop->totarraylength-1)
fprintf(f, ", ");
}
@@ -1725,15 +1751,7 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr
rna_print_c_string(f, prop->name); fprintf(f, ",\n\t");
rna_print_c_string(f, prop->description); fprintf(f, ",\n\t");
fprintf(f, "%d,\n", prop->icon);
- fprintf(f, "\t%s, %s|%s, %d,\n", rna_property_typename(prop->type), rna_property_subtypename(prop->subtype), rna_property_subtype_unit(prop->subtype), prop->arraylength);
- {
- int i;
- int tot= sizeof(prop->dimsize) / sizeof(prop->dimsize[0]);
- fprintf(f, "\t%s, %s, %d, {", rna_function_string(prop->getlength), rna_function_string(prop->setlength), (int)prop->arraydimension);
- for(i= 0; i < tot; i++) {
- fprintf(f, i == tot - 1 ? "%d},\n" : "%d, ", (int)prop->dimsize[i]);
- }
- }
+ fprintf(f, "\t%s, %s|%s, %s, %d, {%d, %d, %d}, %d,\n", rna_property_typename(prop->type), rna_property_subtypename(prop->subtype), rna_property_subtype_unit(prop->subtype), rna_function_string(prop->getlength), prop->arraydimension, prop->arraylength[0], prop->arraylength[1], prop->arraylength[2], prop->totarraylength);
fprintf(f, "\t%s, %d, %s,\n", rna_function_string(prop->update), prop->noteflag, rna_function_string(prop->editable));
if(prop->flag & PROP_RAW_ACCESS) rna_set_raw_offset(f, srna, prop);
@@ -1744,7 +1762,7 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr
case PROP_BOOLEAN: {
BooleanPropertyRNA *bprop= (BooleanPropertyRNA*)prop;
fprintf(f, "\t%s, %s, %s, %s, %d, ", rna_function_string(bprop->get), rna_function_string(bprop->set), rna_function_string(bprop->getarray), rna_function_string(bprop->setarray), bprop->defaultvalue);
- if(prop->arraylength) fprintf(f, "rna_%s%s_%s_default\n", srna->identifier, strnest, prop->identifier);
+ if(prop->arraydimension) fprintf(f, "rna_%s%s_%s_default\n", srna->identifier, strnest, prop->identifier);
else fprintf(f, "NULL\n");
break;
}
@@ -1757,7 +1775,7 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr
rna_int_print(f, iprop->hardmax); fprintf(f, ", ");
rna_int_print(f, iprop->step); fprintf(f, ", ");
rna_int_print(f, iprop->defaultvalue); fprintf(f, ", ");
- if(prop->arraylength) fprintf(f, "rna_%s%s_%s_default\n", srna->identifier, strnest, prop->identifier);
+ if(prop->arraydimension) fprintf(f, "rna_%s%s_%s_default\n", srna->identifier, strnest, prop->identifier);
else fprintf(f, "NULL\n");
break;
}
@@ -1771,7 +1789,7 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr
rna_float_print(f, fprop->step); fprintf(f, ", ");
rna_int_print(f, (int)fprop->precision); fprintf(f, ", ");
rna_float_print(f, fprop->defaultvalue); fprintf(f, ", ");
- if(prop->arraylength) fprintf(f, "rna_%s%s_%s_default\n", srna->identifier, strnest, prop->identifier);
+ if(prop->arraydimension) fprintf(f, "rna_%s%s_%s_default\n", srna->identifier, strnest, prop->identifier);
else fprintf(f, "NULL\n");
break;
}
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index f37fa01480c..417ace6a455 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -209,7 +209,41 @@ static IDProperty *rna_idproperty_find(PointerRNA *ptr, const char *name)
return NULL;
}
-static int rna_idproperty_verify_valid(PropertyRNA *prop, IDProperty *idprop)
+static int rna_ensure_property_array_length(PointerRNA *ptr, PropertyRNA *prop)
+{
+ if(prop->magic == RNA_MAGIC) {
+ int arraylen[RNA_MAX_ARRAY_DIMENSION];
+ return (prop->getlength)? prop->getlength(ptr, arraylen): prop->totarraylength;
+ }
+ else {
+ IDProperty *idprop= (IDProperty*)prop;
+
+ if(idprop->type == IDP_ARRAY)
+ return idprop->len;
+ else
+ return 0;
+ }
+}
+
+static void rna_ensure_property_multi_array_length(PointerRNA *ptr, PropertyRNA *prop, int length[])
+{
+ if(prop->magic == RNA_MAGIC) {
+ if(prop->getlength)
+ prop->getlength(ptr, length);
+ else
+ memcpy(length, prop->arraylength, prop->arraydimension*sizeof(int));
+ }
+ else {
+ IDProperty *idprop= (IDProperty*)prop;
+
+ if(idprop->type == IDP_ARRAY)
+ length[0]= idprop->len;
+ else
+ length[0]= 0;
+ }
+}
+
+static int rna_idproperty_verify_valid(PointerRNA *ptr, PropertyRNA *prop, IDProperty *idprop)
{
/* this verifies if the idproperty actually matches the property
* description and otherwise removes it. this is to ensure that
@@ -222,7 +256,7 @@ static int rna_idproperty_verify_valid(PropertyRNA *prop, IDProperty *idprop)
return 0;
break;
case IDP_ARRAY:
- if(prop->arraylength != idprop->len)
+ if(rna_ensure_property_array_length(ptr, prop) != idprop->len)
return 0;
if(idprop->subtype == IDP_FLOAT && prop->type != PROP_FLOAT)
@@ -283,7 +317,7 @@ IDProperty *rna_idproperty_check(PropertyRNA **prop, PointerRNA *ptr)
if((*prop)->flag & PROP_IDPROPERTY) {
IDProperty *idprop= rna_idproperty_find(ptr, (*prop)->identifier);
- if(idprop && !rna_idproperty_verify_valid(*prop, idprop)) {
+ if(idprop && !rna_idproperty_verify_valid(ptr, *prop, idprop)) {
IDProperty *group= RNA_struct_idproperties(ptr, 0);
IDP_RemFromGroup(group, idprop);
@@ -310,7 +344,7 @@ IDProperty *rna_idproperty_check(PropertyRNA **prop, PointerRNA *ptr)
}
}
-PropertyRNA *rna_ensure_property(PropertyRNA *prop)
+static PropertyRNA *rna_ensure_property(PropertyRNA *prop)
{
/* the quick version if we don't need the idproperty */
@@ -327,7 +361,7 @@ PropertyRNA *rna_ensure_property(PropertyRNA *prop)
}
}
-const char *rna_ensure_property_identifier(PropertyRNA *prop)
+static const char *rna_ensure_property_identifier(PropertyRNA *prop)
{
if(prop->magic == RNA_MAGIC)
return prop->identifier;
@@ -335,7 +369,7 @@ const char *rna_ensure_property_identifier(PropertyRNA *prop)
return ((IDProperty*)prop)->name;
}
-const char *rna_ensure_property_name(PropertyRNA *prop)
+static const char *rna_ensure_property_name(PropertyRNA *prop)
{
if(prop->magic == RNA_MAGIC)
return prop->name;
@@ -343,21 +377,6 @@ const char *rna_ensure_property_name(PropertyRNA *prop)
return ((IDProperty*)prop)->name;
}
-int rna_ensure_property_array_length(PointerRNA *ptr, PropertyRNA *prop)
-{
- if(prop->magic == RNA_MAGIC) {
- return prop->getlength ? prop->getlength(ptr) : prop->arraylength;
- }
- else {
- IDProperty *idprop= (IDProperty*)prop;
-
- if(idprop->type == IDP_ARRAY)
- return idprop->len;
- else
- return 0;
- }
-}
-
/* Structs */
const char *RNA_struct_identifier(StructRNA *type)
@@ -555,51 +574,25 @@ int RNA_property_array_length(PointerRNA *ptr, PropertyRNA *prop)
return rna_ensure_property_array_length(ptr, prop);
}
-int RNA_property_dynamic_array_set_length(PointerRNA *ptr, PropertyRNA *prop, int length)
+/* used by BPY to make an array from the python object */
+int RNA_property_array_dimension(PointerRNA *ptr, PropertyRNA *prop, int length[])
{
- /* length 0 is not allowed */
- if (!length)
- return 0;
-
- if (prop->getlength) {
- if (prop->setlength)
- return prop->setlength(ptr, length);
- else
- /* length cannot be changed */
- return 0;
- }
- else
- prop->arraylength= length; /* function parameters only? */
+ PropertyRNA *rprop= rna_ensure_property(prop);
- return 1;
-}
+ if(length && rprop->arraydimension > 1)
+ rna_ensure_property_multi_array_length(ptr, prop, length);
-/* used by BPY to make an array from the python object */
-unsigned short RNA_property_array_dimension(PropertyRNA *prop, unsigned short dimsize[])
-{
- if (dimsize && prop->arraydimension > 1) {
- memcpy(dimsize, prop->dimsize, sizeof(prop->dimsize[0]) * (prop->arraydimension - 1));
- }
- return prop->arraydimension;
+ return rprop->arraydimension;
}
/* Return the size of Nth dimension. */
-int RNA_property_multidimensional_array_length(PointerRNA *ptr, PropertyRNA *prop, int dim)
+int RNA_property_multi_array_length(PointerRNA *ptr, PropertyRNA *prop, int dim)
{
- unsigned short i;
- int len;
+ int len[RNA_MAX_ARRAY_DIMENSION];
- if (dim == 0) {
- len= RNA_property_array_length(ptr, prop);
+ rna_ensure_property_multi_array_length(ptr, prop, len);
- for (i= 0; i < prop->arraydimension - 1; i++)
- len /= prop->dimsize[i];
- }
- else {
- len= prop->dimsize[dim - 1];
- }
-
- return len;
+ return len[dim];
}
char RNA_property_array_item_char(PropertyRNA *prop, int index)
@@ -902,27 +895,40 @@ void RNA_property_boolean_get_array(PointerRNA *ptr, PropertyRNA *prop, int *val
IDProperty *idprop;
if((idprop=rna_idproperty_check(&prop, ptr))) {
- if(prop->arraylength == 0)
+ if(prop->arraydimension == 0)
values[0]= RNA_property_boolean_get(ptr, prop);
else
memcpy(values, IDP_Array(idprop), sizeof(int)*idprop->len);
}
- else if(prop->arraylength == 0)
+ else if(prop->arraydimension == 0)
values[0]= RNA_property_boolean_get(ptr, prop);
else if(bprop->getarray)
bprop->getarray(ptr, values);
else if(bprop->defaultarray)
- memcpy(values, bprop->defaultarray, sizeof(int)*prop->arraylength);
+ memcpy(values, bprop->defaultarray, sizeof(int)*prop->totarraylength);
else
- memset(values, 0, sizeof(int)*prop->arraylength);
+ memset(values, 0, sizeof(int)*prop->totarraylength);
}
int RNA_property_boolean_get_index(PointerRNA *ptr, PropertyRNA *prop, int index)
{
- int tmp[RNA_MAX_ARRAY];
+ int tmp[RNA_MAX_ARRAY_LENGTH];
+ int len= rna_ensure_property_array_length(ptr, prop);
+
+ if(len <= RNA_MAX_ARRAY_LENGTH) {
+ RNA_property_boolean_get_array(ptr, prop, tmp);
+ return tmp[index];
+ }
+ else {
+ int *tmparray, value;
- RNA_property_boolean_get_array(ptr, prop, tmp);
- return tmp[index];
+ tmparray= MEM_callocN(sizeof(int)*len, "RNA_property_boolean_get_index");
+ RNA_property_boolean_get_array(ptr, prop, tmparray);
+ value= tmparray[index];
+ MEM_freeN(tmparray);
+
+ return value;
+ }
}
void RNA_property_boolean_set_array(PointerRNA *ptr, PropertyRNA *prop, const int *values)
@@ -931,12 +937,12 @@ void RNA_property_boolean_set_array(PointerRNA *ptr, PropertyRNA *prop, const in
IDProperty *idprop;
if((idprop=rna_idproperty_check(&prop, ptr))) {
- if(prop->arraylength == 0)
+ if(prop->arraydimension == 0)
IDP_Int(idprop)= values[0];
else
memcpy(IDP_Array(idprop), values, sizeof(int)*idprop->len);
}
- else if(prop->arraylength == 0)
+ else if(prop->arraydimension == 0)
RNA_property_boolean_set(ptr, prop, values[0]);
else if(bprop->setarray)
bprop->setarray(ptr, values);
@@ -944,7 +950,7 @@ void RNA_property_boolean_set_array(PointerRNA *ptr, PropertyRNA *prop, const in
IDPropertyTemplate val = {0};
IDProperty *group;
- val.array.len= prop->arraylength;
+ val.array.len= prop->totarraylength;
val.array.type= IDP_INT;
group= RNA_struct_idproperties(ptr, 1);
@@ -958,11 +964,23 @@ void RNA_property_boolean_set_array(PointerRNA *ptr, PropertyRNA *prop, const in
void RNA_property_boolean_set_index(PointerRNA *ptr, PropertyRNA *prop, int index, int value)
{
- int tmp[RNA_MAX_ARRAY];
+ int tmp[RNA_MAX_ARRAY_LENGTH];
+ int len= rna_ensure_property_array_length(ptr, prop);
+
+ if(len <= RNA_MAX_ARRAY_LENGTH) {
+ RNA_property_boolean_get_array(ptr, prop, tmp);
+ tmp[index]= value;
+ RNA_property_boolean_set_array(ptr, prop, tmp);
+ }
+ else {
+ int *tmparray;
- RNA_property_boolean_get_array(ptr, prop, tmp);
- tmp[index]= value;
- RNA_property_boolean_set_array(ptr, prop, tmp);
+ tmparray= MEM_callocN(sizeof(int)*len, "RNA_property_boolean_get_index");
+ RNA_property_boolean_get_array(ptr, prop, tmparray);
+ tmparray[index]= value;
+ RNA_property_boolean_set_array(ptr, prop, tmparray);
+ MEM_freeN(tmparray);
+ }
}
int RNA_property_int_get(PointerRNA *ptr, PropertyRNA *prop)
@@ -1005,27 +1023,40 @@ void RNA_property_int_get_array(PointerRNA *ptr, PropertyRNA *prop, int *values)
IDProperty *idprop;
if((idprop=rna_idproperty_check(&prop, ptr))) {
- if(prop->arraylength == 0)
+ if(prop->arraydimension == 0)
values[0]= RNA_property_int_get(ptr, prop);
else
memcpy(values, IDP_Array(idprop), sizeof(int)*idprop->len);
}
- else if(prop->arraylength == 0)
+ else if(prop->arraydimension == 0)
values[0]= RNA_property_int_get(ptr, prop);
else if(iprop->getarray)
iprop->getarray(ptr, values);
else if(iprop->defaultarray)
- memcpy(values, iprop->defaultarray, sizeof(int)*prop->arraylength);
+ memcpy(values, iprop->defaultarray, sizeof(int)*prop->totarraylength);
else
- memset(values, 0, sizeof(int)*prop->arraylength);
+ memset(values, 0, sizeof(int)*prop->totarraylength);
}
int RNA_property_int_get_index(PointerRNA *ptr, PropertyRNA *prop, int index)
{
- int tmp[RNA_MAX_ARRAY];
+ int tmp[RNA_MAX_ARRAY_LENGTH];
+ int len= rna_ensure_property_array_length(ptr, prop);
+
+ if(len <= RNA_MAX_ARRAY_LENGTH) {
+ RNA_property_int_get_array(ptr, prop, tmp);
+ return tmp[index];
+ }
+ else {
+ int *tmparray, value;
+
+ tmparray= MEM_callocN(sizeof(int)*len, "RNA_property_int_get_index");
+ RNA_property_int_get_array(ptr, prop, tmparray);
+ value= tmparray[index];
+ MEM_freeN(tmparray);
- RNA_property_int_get_array(ptr, prop, tmp);
- return tmp[index];
+ return value;
+ }
}
void RNA_property_int_set_array(PointerRNA *ptr, PropertyRNA *prop, const int *values)
@@ -1034,12 +1065,12 @@ void RNA_property_int_set_array(PointerRNA *ptr, PropertyRNA *prop, const int *v
IDProperty *idprop;
if((idprop=rna_idproperty_check(&prop, ptr))) {
- if(prop->arraylength == 0)
+ if(prop->arraydimension == 0)
IDP_Int(idprop)= values[0];
else
memcpy(IDP_Array(idprop), values, sizeof(int)*idprop->len);\
}
- else if(prop->arraylength == 0)
+ else if(prop->arraydimension == 0)
RNA_property_int_set(ptr, prop, values[0]);
else if(iprop->setarray)
iprop->setarray(ptr, values);
@@ -1047,7 +1078,7 @@ void RNA_property_int_set_array(PointerRNA *ptr, PropertyRNA *prop, const int *v
IDPropertyTemplate val = {0};
IDProperty *group;
- val.array.len= prop->arraylength;
+ val.array.len= prop->totarraylength;
val.array.type= IDP_INT;
group= RNA_struct_idproperties(ptr, 1);
@@ -1061,11 +1092,23 @@ void RNA_property_int_set_array(PointerRNA *ptr, PropertyRNA *prop, const int *v
void RNA_property_int_set_index(PointerRNA *ptr, PropertyRNA *prop, int index, int value)
{
- int tmp[RNA_MAX_ARRAY];
+ int tmp[RNA_MAX_ARRAY_LENGTH];
+ int len= rna_ensure_property_array_length(ptr, prop);
- RNA_property_int_get_array(ptr, prop, tmp);
- tmp[index]= value;
- RNA_property_int_set_array(ptr, prop, tmp);
+ if(len <= RNA_MAX_ARRAY_LENGTH) {
+ RNA_property_int_get_array(ptr, prop, tmp);
+ tmp[index]= value;
+ RNA_property_int_set_array(ptr, prop, tmp);
+ }
+ else {
+ int *tmparray;
+
+ tmparray= MEM_callocN(sizeof(int)*len, "RNA_property_int_get_index");
+ RNA_property_int_get_array(ptr, prop, tmparray);
+ tmparray[index]= value;
+ RNA_property_int_set_array(ptr, prop, tmparray);
+ MEM_freeN(tmparray);
+ }
}
float RNA_property_float_get(PointerRNA *ptr, PropertyRNA *prop)
@@ -1118,7 +1161,7 @@ void RNA_property_float_get_array(PointerRNA *ptr, PropertyRNA *prop, float *val
int i;
if((idprop=rna_idproperty_check(&prop, ptr))) {
- if(prop->arraylength == 0)
+ if(prop->arraydimension == 0)
values[0]= RNA_property_float_get(ptr, prop);
else if(idprop->subtype == IDP_FLOAT) {
memcpy(values, IDP_Array(idprop), sizeof(float)*idprop->len);
@@ -1128,22 +1171,36 @@ void RNA_property_float_get_array(PointerRNA *ptr, PropertyRNA *prop, float *val
values[i]= (float)(((double*)IDP_Array(idprop))[i]);
}
}
- else if(prop->arraylength == 0)
+ else if(prop->arraydimension == 0)
values[0]= RNA_property_float_get(ptr, prop);
else if(fprop->getarray)
fprop->getarray(ptr, values);
else if(fprop->defaultarray)
- memcpy(values, fprop->defaultarray, sizeof(float)*prop->arraylength);
+ memcpy(values, fprop->defaultarray, sizeof(float)*prop->totarraylength);
else
- memset(values, 0, sizeof(float)*prop->arraylength);
+ memset(values, 0, sizeof(float)*prop->totarraylength);
}
float RNA_property_float_get_index(PointerRNA *ptr, PropertyRNA *prop, int index)
{
- float tmp[RNA_MAX_ARRAY];
+ float tmp[RNA_MAX_ARRAY_LENGTH];
+ int len= rna_ensure_property_array_length(ptr, prop);
+
+ if(len <= RNA_MAX_ARRAY_LENGTH) {
+ RNA_property_float_get_array(ptr, prop, tmp);
+ return tmp[index];
+ }
+ else {
+ float *tmparray, value;
+
+ tmparray= MEM_callocN(sizeof(float)*len, "RNA_property_float_get_index");
+ RNA_property_float_get_array(ptr, prop, tmparray);
+ value= tmparray[index];
+ MEM_freeN(tmparray);
+
+ return value;
+ }
- RNA_property_float_get_array(ptr, prop, tmp);
- return tmp[index];
}
void RNA_property_float_set_array(PointerRNA *ptr, PropertyRNA *prop, const float *values)
@@ -1153,7 +1210,7 @@ void RNA_property_float_set_array(PointerRNA *ptr, PropertyRNA *prop, const floa
int i;
if((idprop=rna_idproperty_check(&prop, ptr))) {
- if(prop->arraylength == 0)
+ if(prop->arraydimension == 0)
IDP_Double(idprop)= values[0];
else if(idprop->subtype == IDP_FLOAT) {
memcpy(IDP_Array(idprop), values, sizeof(float)*idprop->len);
@@ -1163,7 +1220,7 @@ void RNA_property_float_set_array(PointerRNA *ptr, PropertyRNA *prop, const floa
((double*)IDP_Array(idprop))[i]= values[i];
}
}
- else if(prop->arraylength == 0)
+ else if(prop->arraydimension == 0)
RNA_property_float_set(ptr, prop, values[0]);
else if(fprop->setarray) {
fprop->setarray(ptr, values);
@@ -1172,7 +1229,7 @@ void RNA_property_float_set_array(PointerRNA *ptr, PropertyRNA *prop, const floa
IDPropertyTemplate val = {0};
IDProperty *group;
- val.array.len= prop->arraylength;
+ val.array.len= prop->totarraylength;
val.array.type= IDP_FLOAT;
group= RNA_struct_idproperties(ptr, 1);
@@ -1186,11 +1243,23 @@ void RNA_property_float_set_array(PointerRNA *ptr, PropertyRNA *prop, const floa
void RNA_property_float_set_index(PointerRNA *ptr, PropertyRNA *prop, int index, float value)
{
- float tmp[RNA_MAX_ARRAY];
+ float tmp[RNA_MAX_ARRAY_LENGTH];
+ int len= rna_ensure_property_array_length(ptr, prop);
- RNA_property_float_get_array(ptr, prop, tmp);
- tmp[index]= value;
- RNA_property_float_set_array(ptr, prop, tmp);
+ if(len <= RNA_MAX_ARRAY_LENGTH) {
+ RNA_property_float_get_array(ptr, prop, tmp);
+ tmp[index]= value;
+ RNA_property_float_set_array(ptr, prop, tmp);
+ }
+ else {
+ float *tmparray;
+
+ tmparray= MEM_callocN(sizeof(float)*len, "RNA_property_float_get_index");
+ RNA_property_float_get_array(ptr, prop, tmparray);
+ tmparray[index]= value;
+ RNA_property_float_set_array(ptr, prop, tmparray);
+ MEM_freeN(tmparray);
+ }
}
void RNA_property_string_get(PointerRNA *ptr, PropertyRNA *prop, char *value)
@@ -2912,15 +2981,15 @@ ParameterList *RNA_parameter_list_create(ParameterList *parms, PointerRNA *ptr,
if(!(parm->flag & PROP_REQUIRED)) {
switch(parm->type) {
case PROP_BOOLEAN:
- if(parm->arraylength) memcpy(data, &((BooleanPropertyRNA*)parm)->defaultarray, size);
+ if(parm->arraydimension) memcpy(data, &((BooleanPropertyRNA*)parm)->defaultarray, size);
else memcpy(data, &((BooleanPropertyRNA*)parm)->defaultvalue, size);
break;
case PROP_INT:
- if(parm->arraylength) memcpy(data, &((IntPropertyRNA*)parm)->defaultarray, size);
+ if(parm->arraydimension) memcpy(data, &((IntPropertyRNA*)parm)->defaultarray, size);
else memcpy(data, &((IntPropertyRNA*)parm)->defaultvalue, size);
break;
case PROP_FLOAT:
- if(parm->arraylength) memcpy(data, &((FloatPropertyRNA*)parm)->defaultarray, size);
+ if(parm->arraydimension) memcpy(data, &((FloatPropertyRNA*)parm)->defaultarray, size);
else memcpy(data, &((FloatPropertyRNA*)parm)->defaultvalue, size);
break;
case PROP_ENUM:
diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c
index 00cfb17dc84..8d05cbde74c 100644
--- a/source/blender/makesrna/intern/rna_define.c
+++ b/source/blender/makesrna/intern/rna_define.c
@@ -1001,18 +1001,18 @@ void RNA_def_property_clear_flag(PropertyRNA *prop, int flag)
prop->flag &= ~flag;
}
-void RNA_def_property_array(PropertyRNA *prop, int arraylength)
+void RNA_def_property_array(PropertyRNA *prop, int length)
{
StructRNA *srna= DefRNA.laststruct;
- if(arraylength<0) {
+ if(length<0) {
fprintf(stderr, "RNA_def_property_array: %s.%s, array length must be zero of greater.\n", srna->identifier, prop->identifier);
DefRNA.error= 1;
return;
}
- if(arraylength>RNA_MAX_ARRAY) {
- fprintf(stderr, "RNA_def_property_array: %s.%s, array length must be smaller than %d.\n", srna->identifier, prop->identifier, RNA_MAX_ARRAY);
+ if(length>RNA_MAX_ARRAY_LENGTH) {
+ fprintf(stderr, "RNA_def_property_array: %s.%s, array length must be smaller than %d.\n", srna->identifier, prop->identifier, RNA_MAX_ARRAY_LENGTH);
DefRNA.error= 1;
return;
}
@@ -1021,35 +1021,53 @@ void RNA_def_property_array(PropertyRNA *prop, int arraylength)
case PROP_BOOLEAN:
case PROP_INT:
case PROP_FLOAT:
- prop->arraylength= arraylength;
+ prop->arraylength[0]= length;
+ prop->totarraylength= length;
+ prop->arraydimension= 1;
break;
default:
fprintf(stderr, "RNA_def_property_array: %s.%s, only boolean/int/float can be array.\n", srna->identifier, prop->identifier);
DefRNA.error= 1;
break;
}
-
- prop->arraydimension= 1;
}
-void RNA_def_property_multidimensional_array(PropertyRNA *prop, int arraylength, unsigned short dimension, unsigned short dimsize[])
+void RNA_def_property_multi_array(PropertyRNA *prop, int dimension, int length[])
{
StructRNA *srna= DefRNA.laststruct;
+ int i;
if (dimension < 1 || dimension > RNA_MAX_ARRAY_DIMENSION) {
- fprintf(stderr, "RNA_def_property_multidimensional_array: %s.%s, array dimension must be between 1 and %d.\n", srna->identifier, prop->identifier, RNA_MAX_ARRAY_DIMENSION);
+ fprintf(stderr, "RNA_def_property_multi_array: %s.%s, array dimension must be between 1 and %d.\n", srna->identifier, prop->identifier, RNA_MAX_ARRAY_DIMENSION);
DefRNA.error= 1;
return;
}
- RNA_def_property_array(prop, arraylength);
+ switch(prop->type) {
+ case PROP_BOOLEAN:
+ case PROP_INT:
+ case PROP_FLOAT:
+ break;
+ default:
+ fprintf(stderr, "RNA_def_property_multi_array: %s.%s, only boolean/int/float can be array.\n", srna->identifier, prop->identifier);
+ DefRNA.error= 1;
+ break;
+ }
prop->arraydimension= dimension;
+ prop->totarraylength= 0;
- /* TODO make sure dimsize values are sane */
+ if(length) {
+ memcpy(prop->arraylength, length, sizeof(int)*dimension);
- if (dimension > 1)
- memcpy(prop->dimsize, dimsize, sizeof(dimsize[0]) * (dimension - 1));
+ prop->totarraylength= length[0];
+ for(i=1; i<dimension; i++)
+ prop->totarraylength *= length[i];
+ }
+ else
+ memset(prop->arraylength, 0, sizeof(prop->arraylength));
+
+ /* TODO make sure arraylength values are sane */
}
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
@@ -1422,10 +1440,15 @@ static PropertyDefRNA *rna_def_property_sdna(PropertyRNA *prop, const char *stru
}
}
- if(smember.arraylength > 1)
- prop->arraylength= smember.arraylength;
- else
- prop->arraylength= 0;
+ if(smember.arraylength > 1) {
+ prop->arraylength[0]= smember.arraylength;
+ prop->totarraylength= smember.arraylength;
+ prop->arraydimension= 1;
+ }
+ else {
+ prop->arraydimension= 0;
+ prop->totarraylength= 0;
+ }
dp->dnastructname= structname;
dp->dnastructfromname= ds->dnafromname;
@@ -1545,8 +1568,10 @@ void RNA_def_property_enum_sdna(PropertyRNA *prop, const char *structname, const
}
if((dp=rna_def_property_sdna(prop, structname, propname))) {
- if(prop->arraylength) {
- prop->arraylength= 0;
+ if(prop->arraydimension) {
+ prop->arraydimension= 0;
+ prop->totarraylength= 0;
+
if(!DefRNA.silent) {
fprintf(stderr, "RNA_def_property_enum_sdna: %s.%s, array not supported for enum type.\n", structname, propname);
DefRNA.error= 1;
@@ -1585,9 +1610,10 @@ void RNA_def_property_string_sdna(PropertyRNA *prop, const char *structname, con
}
if((dp=rna_def_property_sdna(prop, structname, propname))) {
- if(prop->arraylength) {
- sprop->maxlength= prop->arraylength;
- prop->arraylength= 0;
+ if(prop->arraydimension) {
+ sprop->maxlength= prop->totarraylength;
+ prop->arraydimension= 0;
+ prop->totarraylength= 0;
}
}
}
@@ -1609,8 +1635,10 @@ void RNA_def_property_pointer_sdna(PropertyRNA *prop, const char *structname, co
}
if((dp=rna_def_property_sdna(prop, structname, propname))) {
- if(prop->arraylength) {
- prop->arraylength= 0;
+ if(prop->arraydimension) {
+ prop->arraydimension= 0;
+ prop->totarraylength= 0;
+
if(!DefRNA.silent) {
fprintf(stderr, "RNA_def_property_pointer_sdna: %s.%s, array not supported for pointer type.\n", structname, propname);
DefRNA.error= 1;
@@ -1637,8 +1665,9 @@ void RNA_def_property_collection_sdna(PropertyRNA *prop, const char *structname,
}
if((dp=rna_def_property_sdna(prop, structname, propname))) {
- if(prop->arraylength && !lengthpropname) {
- prop->arraylength= 0;
+ if(prop->arraydimension && !lengthpropname) {
+ prop->arraydimension= 0;
+ prop->totarraylength= 0;
if(!DefRNA.silent) {
fprintf(stderr, "RNA_def_property_collection_sdna: %s.%s, array of collections not supported.\n", structname, propname);
@@ -1662,8 +1691,9 @@ void RNA_def_property_collection_sdna(PropertyRNA *prop, const char *structname,
if(lengthpropname[0] == 0 || rna_find_sdna_member(DefRNA.sdna, structname, lengthpropname, &smember)) {
if(lengthpropname[0] == 0) {
- dp->dnalengthfixed= prop->arraylength;
- prop->arraylength= 0;
+ dp->dnalengthfixed= prop->totarraylength;
+ prop->arraydimension= 0;
+ prop->totarraylength= 0;
}
else {
dp->dnalengthstructname= structname;
@@ -1710,7 +1740,7 @@ void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *func)
prop->update= (UpdateFunc)func;
}
-void RNA_def_property_dynamic_array_funcs(PropertyRNA *prop, const char *getlength, const char *setlength)
+void RNA_def_property_dynamic_array_funcs(PropertyRNA *prop, const char *getlength)
{
if(!DefRNA.preprocess) {
fprintf(stderr, "RNA_def_property_*_funcs: only during preprocessing.\n");
@@ -1724,7 +1754,6 @@ void RNA_def_property_dynamic_array_funcs(PropertyRNA *prop, const char *getleng
}
if(getlength) prop->getlength= (PropArrayLengthGetFunc)getlength;
- if(setlength) prop->setlength= (PropArrayLengthSetFunc)setlength;
}
void RNA_def_property_boolean_funcs(PropertyRNA *prop, const char *get, const char *set)
@@ -1740,7 +1769,7 @@ void RNA_def_property_boolean_funcs(PropertyRNA *prop, const char *get, const ch
case PROP_BOOLEAN: {
BooleanPropertyRNA *bprop= (BooleanPropertyRNA*)prop;
- if(prop->arraylength) {
+ if(prop->arraydimension) {
if(get) bprop->getarray= (PropBooleanArrayGetFunc)get;
if(set) bprop->setarray= (PropBooleanArraySetFunc)set;
}
@@ -1770,7 +1799,7 @@ void RNA_def_property_int_funcs(PropertyRNA *prop, const char *get, const char *
case PROP_INT: {
IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
- if(prop->arraylength) {
+ if(prop->arraydimension) {
if(get) iprop->getarray= (PropIntArrayGetFunc)get;
if(set) iprop->setarray= (PropIntArraySetFunc)set;
}
@@ -1801,7 +1830,7 @@ void RNA_def_property_float_funcs(PropertyRNA *prop, const char *get, const char
case PROP_FLOAT: {
FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop;
- if(prop->arraylength) {
+ if(prop->arraydimension) {
if(get) fprop->getarray= (PropFloatArrayGetFunc)get;
if(set) fprop->setarray= (PropFloatArraySetFunc)set;
}
@@ -2152,15 +2181,15 @@ PropertyRNA *RNA_def_float_color(StructOrFunctionRNA *cont_, const char *identif
}
-PropertyRNA *RNA_def_float_matrix(StructOrFunctionRNA *cont_, const char *identifier, int len, int rowsize, const float *default_value,
+PropertyRNA *RNA_def_float_matrix(StructOrFunctionRNA *cont_, const char *identifier, int rows, int columns, const float *default_value,
float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
{
ContainerRNA *cont= cont_;
PropertyRNA *prop;
- unsigned short dimsize[1]= {rowsize};
+ int length[2]= {rows, columns};
prop= RNA_def_property(cont, identifier, PROP_FLOAT, PROP_MATRIX);
- if(len != 0) RNA_def_property_multidimensional_array(prop, len, 2, dimsize);
+ RNA_def_property_multi_array(prop, 2, length);
if(default_value) RNA_def_property_float_array_default(prop, default_value);
if(hardmin != hardmax) RNA_def_property_range(prop, hardmin, hardmax);
RNA_def_property_ui_text(prop, ui_name, ui_description);
@@ -2357,10 +2386,9 @@ void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
int rna_parameter_size(PropertyRNA *parm)
{
PropertyType ptype= parm->type;
- int len= parm->arraylength;
+ int len= parm->totarraylength; /* only supports fixed length at the moment */
if(len > 0) {
-
if (parm->flag & PROP_DYNAMIC)
return sizeof(void *);
@@ -2508,8 +2536,8 @@ void RNA_def_property_duplicate_pointers(PropertyRNA *prop)
BooleanPropertyRNA *bprop= (BooleanPropertyRNA*)prop;
if(bprop->defaultarray) {
- iarray= MEM_callocN(sizeof(int)*prop->arraylength, "RNA_def_property_store");
- memcpy(iarray, bprop->defaultarray, sizeof(int)*prop->arraylength);
+ iarray= MEM_callocN(sizeof(int)*prop->totarraylength, "RNA_def_property_store");
+ memcpy(iarray, bprop->defaultarray, sizeof(int)*prop->totarraylength);
bprop->defaultarray= iarray;
}
break;
@@ -2518,8 +2546,8 @@ void RNA_def_property_duplicate_pointers(PropertyRNA *prop)
IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
if(iprop->defaultarray) {
- iarray= MEM_callocN(sizeof(int)*prop->arraylength, "RNA_def_property_store");
- memcpy(iarray, iprop->defaultarray, sizeof(int)*prop->arraylength);
+ iarray= MEM_callocN(sizeof(int)*prop->totarraylength, "RNA_def_property_store");
+ memcpy(iarray, iprop->defaultarray, sizeof(int)*prop->totarraylength);
iprop->defaultarray= iarray;
}
break;
@@ -2544,8 +2572,8 @@ void RNA_def_property_duplicate_pointers(PropertyRNA *prop)
FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop;
if(fprop->defaultarray) {
- farray= MEM_callocN(sizeof(float)*prop->arraylength, "RNA_def_property_store");
- memcpy(farray, fprop->defaultarray, sizeof(float)*prop->arraylength);
+ farray= MEM_callocN(sizeof(float)*prop->totarraylength, "RNA_def_property_store");
+ memcpy(farray, fprop->defaultarray, sizeof(float)*prop->totarraylength);
fprop->defaultarray= farray;
}
break;
diff --git a/source/blender/makesrna/intern/rna_internal_types.h b/source/blender/makesrna/intern/rna_internal_types.h
index 2bd89dbd3bf..645bc50ed89 100644
--- a/source/blender/makesrna/intern/rna_internal_types.h
+++ b/source/blender/makesrna/intern/rna_internal_types.h
@@ -40,9 +40,9 @@ struct IDProperty;
struct GHash;
#ifdef UNIT_TEST
-#define RNA_MAX_ARRAY 64
+#define RNA_MAX_ARRAY_LENGTH 64
#else
-#define RNA_MAX_ARRAY 32
+#define RNA_MAX_ARRAY_LENGTH 32
#endif
#define RNA_MAX_ARRAY_DIMENSION 3
@@ -55,8 +55,7 @@ typedef struct IDProperty* (*IDPropertiesFunc)(struct PointerRNA *ptr, int creat
typedef struct StructRNA *(*StructRefineFunc)(struct PointerRNA *ptr);
typedef char *(*StructPathFunc)(struct PointerRNA *ptr);
-typedef int (*PropArrayLengthGetFunc)(struct PointerRNA *ptr);
-typedef int (*PropArrayLengthSetFunc)(struct PointerRNA *ptr, int length);
+typedef int (*PropArrayLengthGetFunc)(struct PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION]);
typedef int (*PropBooleanGetFunc)(struct PointerRNA *ptr);
typedef void (*PropBooleanSetFunc)(struct PointerRNA *ptr, int value);
typedef void (*PropBooleanArrayGetFunc)(struct PointerRNA *ptr, int *values);
@@ -137,15 +136,13 @@ struct PropertyRNA {
PropertyType type;
/* subtype, 'interpretation' of the property */
PropertySubType subtype;
- /* if an array this is > 0, specifying the length */
- unsigned int arraylength;
/* if non-NULL, overrides arraylength. Must not return 0? */
PropArrayLengthGetFunc getlength;
- /* if NULL, length cannot be changed by a user */
- PropArrayLengthSetFunc setlength;
- unsigned short arraydimension;
- /* dimension sizes for dimensions greater than 1, first dimension size is not specified */
- unsigned short dimsize[RNA_MAX_ARRAY_DIMENSION - 1];
+ /* dimension of array */
+ unsigned int arraydimension;
+ /* array lengths lengths for all dimensions (when arraydimension > 0) */
+ unsigned int arraylength[RNA_MAX_ARRAY_DIMENSION];
+ unsigned int totarraylength;
/* callback for updates on change */
UpdateFunc update;
diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c
index efd0046d827..78fb8ede3ee 100644
--- a/source/blender/makesrna/intern/rna_mesh.c
+++ b/source/blender/makesrna/intern/rna_mesh.c
@@ -423,14 +423,11 @@ static int rna_CustomDataData_numverts(PointerRNA *ptr, int type)
return 0;
}
-static int rna_MeshTextureFace_uv_get_length(PointerRNA *ptr)
+static int rna_MeshTextureFace_uv_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION])
{
- return rna_CustomDataData_numverts(ptr, CD_MTFACE) * 2;
-}
-
-static int rna_MeshTextureFace_uv_set_length(PointerRNA *ptr, int length)
-{
- return length == rna_MeshTextureFace_uv_get_length(ptr);
+ length[0]= rna_CustomDataData_numverts(ptr, CD_MTFACE);
+ length[1]= 2;
+ return length[0]*length[1];
}
static void rna_MeshTextureFace_uv_get(PointerRNA *ptr, float *values)
@@ -711,35 +708,22 @@ static void rna_TextureFace_image_set(PointerRNA *ptr, PointerRNA value)
tf->tpage= (struct Image*)id;
}
-static int rna_MeshFace_verts_get_length(PointerRNA *ptr)
+static int rna_MeshFace_verts_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION])
{
MFace *face= (MFace*)ptr->data;
+
if(face)
- return face->v4 ? 4 : 3;
+ length[0]= (face->v4)? 4: 3;
else
- return 4; // XXX rna_raw_access wants the length of a dummy face. this needs fixing. - Campbell
-}
+ length[0]= 4; // XXX rna_raw_access wants the length of a dummy face. this needs fixing. - Campbell
-static int rna_MeshFace_verts_set_length(PointerRNA *ptr, int length)
-{
- MFace *face= (MFace*)ptr->data;
- if (length == 3) {
- face->v4= 0;
- }
- else if(length == 4) {
- face->v4= 1;
- }
- else
- return 0;
-
- return 1;
+ return length[0];
}
static void rna_MeshFace_verts_get(PointerRNA *ptr, int *values)
{
MFace *face= (MFace*)ptr->data;
- int verts[4] = {face->v1, face->v2, face->v3, face->v4};
- memcpy(values, verts, (face->v4 ? 4 : 3) * sizeof(int));
+ memcpy(values, &face->v1, (face->v4 ? 4 : 3) * sizeof(int));
}
static void rna_MeshFace_verts_set(PointerRNA *ptr, const int *values)
@@ -982,19 +966,11 @@ static void rna_def_mface(BlenderRNA *brna)
RNA_def_struct_path_func(srna, "rna_MeshFace_path");
RNA_def_struct_ui_icon(srna, ICON_FACESEL);
- /*
- // XXX allows creating invalid meshes
- prop= RNA_def_property(srna, "verts", PROP_INT, PROP_UNSIGNED);
- RNA_def_property_int_sdna(prop, NULL, "v1");
- RNA_def_property_array(prop, 4);
- RNA_def_property_ui_text(prop, "Vertices", "Vertex indices");
- */
-
// XXX allows creating invalid meshes
prop= RNA_def_property(srna, "verts", PROP_INT, PROP_UNSIGNED);
RNA_def_property_array(prop, 4);
RNA_def_property_flag(prop, PROP_DYNAMIC);
- RNA_def_property_dynamic_array_funcs(prop, "rna_MeshFace_verts_get_length", "rna_MeshFace_verts_set_length");
+ RNA_def_property_dynamic_array_funcs(prop, "rna_MeshFace_verts_get_length");
RNA_def_property_int_funcs(prop, "rna_MeshFace_verts_get", "rna_MeshFace_verts_set", NULL);
RNA_def_property_ui_text(prop, "Vertices", "Vertex indices");
@@ -1037,7 +1013,7 @@ static void rna_def_mtface(BlenderRNA *brna)
{TF_ALPHA, "ALPHA", 0, "Alpha", "Render polygon transparent, depending on alpha channel of the texture"},
{TF_CLIP, "CLIPALPHA", 0, "Clip Alpha", "Use the images alpha values clipped with no blending (binary alpha)"},
{0, NULL, 0, NULL, NULL}};
- unsigned short uv_dim[1]= {2};
+ int uv_dim[]= {4, 2};
srna= RNA_def_struct(brna, "MeshTextureFaceLayer", NULL);
RNA_def_struct_ui_text(srna, "Mesh Texture Face Layer", "Layer of texture faces in a Mesh datablock.");
@@ -1183,9 +1159,9 @@ static void rna_def_mtface(BlenderRNA *brna)
RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
prop= RNA_def_property(srna, "uv", PROP_FLOAT, PROP_NONE);
- RNA_def_property_multidimensional_array(prop, 4 * 2, 2, uv_dim);
+ RNA_def_property_multi_array(prop, 2, uv_dim);
RNA_def_property_flag(prop, PROP_DYNAMIC);
- RNA_def_property_dynamic_array_funcs(prop, "rna_MeshTextureFace_uv_get_length", "rna_MeshTextureFace_uv_set_length");
+ RNA_def_property_dynamic_array_funcs(prop, "rna_MeshTextureFace_uv_get_length");
RNA_def_property_float_funcs(prop, "rna_MeshTextureFace_uv_get", "rna_MeshTextureFace_uv_set", NULL);
RNA_def_property_ui_text(prop, "UV", "");
RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c
index ce65ef4d450..3d43dfdfc2c 100644
--- a/source/blender/makesrna/intern/rna_object.c
+++ b/source/blender/makesrna/intern/rna_object.c
@@ -1046,7 +1046,7 @@ static void rna_def_object(BlenderRNA *brna)
{OB_DUPLIGROUP, "GROUP", 0, "Group", "Enable group instancing."},
{0, NULL, 0, NULL, NULL}};
- unsigned short matrix_dimsize[]= {4};
+ int matrix_dimsize[]= {4, 4};
srna= RNA_def_struct(brna, "Object", "ID");
RNA_def_struct_ui_text(srna, "Object", "Object datablock defining an object in a scene..");
@@ -1210,7 +1210,7 @@ static void rna_def_object(BlenderRNA *brna)
/* matrix */
prop= RNA_def_property(srna, "matrix", PROP_FLOAT, PROP_MATRIX);
RNA_def_property_float_sdna(prop, NULL, "obmat");
- RNA_def_property_multidimensional_array(prop, 16, 2, matrix_dimsize);
+ RNA_def_property_multi_array(prop, 2, matrix_dimsize);
RNA_def_property_ui_text(prop, "Matrix", "Transformation matrix.");
/* collections */
diff --git a/source/blender/makesrna/intern/rna_render.c b/source/blender/makesrna/intern/rna_render.c
index 9137e596da1..a67831715a2 100644
--- a/source/blender/makesrna/intern/rna_render.c
+++ b/source/blender/makesrna/intern/rna_render.c
@@ -170,40 +170,51 @@ static void rna_RenderLayer_passes_begin(CollectionPropertyIterator *iter, Point
rna_iterator_listbase_begin(iter, &rl->passes, NULL);
}
-static float rna_RenderValue_value_get(PointerRNA *ptr)
+static int rna_RenderLayer_rect_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION])
{
- return *(float*)ptr->data;
-}
+ RenderLayer *rl= (RenderLayer*)ptr->data;
-static void rna_RenderValue_value_set(PointerRNA *ptr, float value)
-{
- *(float*)ptr->data= value;
+ length[0]= rl->rectx*rl->recty;
+ length[1]= 4;
+
+ return length[0]*length[1];
}
-static void rna_RenderLayer_rect_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
+static void rna_RenderLayer_rect_get(PointerRNA *ptr, float *values)
{
RenderLayer *rl= (RenderLayer*)ptr->data;
- rna_iterator_array_begin(iter, (void*)rl->rectf, sizeof(float), rl->rectx*rl->recty*4, 0, NULL);
+ memcpy(values, rl->rectf, sizeof(float)*rl->rectx*rl->recty*4);
}
-static int rna_RenderLayer_rect_length(PointerRNA *ptr)
+static void rna_RenderLayer_rect_set(PointerRNA *ptr, const float *values)
{
RenderLayer *rl= (RenderLayer*)ptr->data;
- return rl->rectx*rl->recty*4;
+ memcpy(rl->rectf, values, sizeof(float)*rl->rectx*rl->recty*4);
}
-static void rna_RenderPass_rect_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
+static int rna_RenderPass_rect_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION])
{
RenderPass *rpass= (RenderPass*)ptr->data;
- rna_iterator_array_begin(iter, (void*)rpass->rect, sizeof(float), rpass->rectx*rpass->recty*rpass->channels, 0, NULL);
+
+ length[0]= rpass->rectx*rpass->recty;
+ length[1]= rpass->channels;
+
+ return length[0]*length[1];
}
-static int rna_RenderPass_rect_length(PointerRNA *ptr)
+static void rna_RenderPass_rect_get(PointerRNA *ptr, float *values)
{
RenderPass *rpass= (RenderPass*)ptr->data;
- return rpass->rectx*rpass->recty*rpass->channels;
+ printf("rect get\n");
+ memcpy(values, rpass->rect, sizeof(float)*rpass->rectx*rpass->recty*rpass->channels);
}
+static void rna_RenderPass_rect_set(PointerRNA *ptr, const float *values)
+{
+ RenderPass *rpass= (RenderPass*)ptr->data;
+ printf("rect set\n");
+ memcpy(rpass->rect, values, sizeof(float)*rpass->rectx*rpass->recty*rpass->channels);
+}
#else // RNA_RUNTIME
@@ -324,16 +335,11 @@ static void rna_def_render_layer(BlenderRNA *brna)
RNA_def_property_struct_type(prop, "RenderPass");
RNA_def_property_collection_funcs(prop, "rna_RenderLayer_passes_begin", "rna_iterator_listbase_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get", 0, 0, 0, 0, 0);
- prop= RNA_def_property(srna, "rect", PROP_COLLECTION, PROP_NONE);
- RNA_def_property_struct_type(prop, "RenderValue");
- RNA_def_property_collection_funcs(prop, "rna_RenderLayer_rect_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_RenderLayer_rect_length", 0, 0, 0, 0);
-
- /* value */
- srna= RNA_def_struct(brna, "RenderValue", NULL);
- RNA_def_struct_ui_text(srna, "Render Value", "");
-
- prop= RNA_def_property(srna, "value", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_funcs(prop, "rna_RenderValue_value_get", "rna_RenderValue_value_set", NULL);
+ prop= RNA_def_property(srna, "rect", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_flag(prop, PROP_DYNAMIC);
+ RNA_def_property_multi_array(prop, 2, NULL);
+ RNA_def_property_dynamic_array_funcs(prop, "rna_RenderLayer_rect_get_length");
+ RNA_def_property_float_funcs(prop, "rna_RenderLayer_rect_get", "rna_RenderLayer_rect_set", NULL);
RNA_define_verify_sdna(1);
}
@@ -383,9 +389,11 @@ static void rna_def_render_pass(BlenderRNA *brna)
RNA_def_property_enum_items(prop, pass_type_items);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- prop= RNA_def_property(srna, "rect", PROP_COLLECTION, PROP_NONE);
- RNA_def_property_struct_type(prop, "RenderValue");
- RNA_def_property_collection_funcs(prop, "rna_RenderPass_rect_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_RenderPass_rect_length", 0, 0, 0, 0);
+ prop= RNA_def_property(srna, "rect", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_flag(prop, PROP_DYNAMIC);
+ RNA_def_property_multi_array(prop, 2, NULL);
+ RNA_def_property_dynamic_array_funcs(prop, "rna_RenderPass_rect_get_length");
+ RNA_def_property_float_funcs(prop, "rna_RenderPass_rect_get", "rna_RenderPass_rect_set", NULL);
RNA_define_verify_sdna(1);
}
diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c
index b1644405ff3..8df6398f1f4 100644
--- a/source/blender/makesrna/intern/rna_rna.c
+++ b/source/blender/makesrna/intern/rna_rna.c
@@ -430,7 +430,7 @@ static int rna_Property_array_length_get(PointerRNA *ptr)
{
PropertyRNA *prop= (PropertyRNA*)ptr->data;
rna_idproperty_check(&prop, ptr);
- return prop->arraylength;
+ return prop->totarraylength;
}
static int rna_Property_registered_get(PointerRNA *ptr)
diff --git a/source/blender/python/intern/bpy_array.c b/source/blender/python/intern/bpy_array.c
index 9db4b20d011..f11c95e7ed5 100644
--- a/source/blender/python/intern/bpy_array.c
+++ b/source/blender/python/intern/bpy_array.c
@@ -36,9 +36,6 @@
#define MAX_ARRAY_DIMENSION 10
-/* convenient way to access array dimension size */
-#define DIMSIZE(a) (dimsize[a - 1])
-
typedef void (*ItemConvertFunc)(PyObject *, char *);
typedef int (*ItemTypeCheckFunc)(PyObject *);
typedef void (*RNA_SetArrayFunc)(PointerRNA *, PropertyRNA *, const char *);
@@ -59,7 +56,7 @@ typedef void (*RNA_SetIndexFunc)(PointerRNA *, PropertyRNA *, int index, void *)
/* arr[3]=x, self->arraydim is 0, lvalue_dim is 1 */
/* Ensures that a python sequence has expected number of items/sub-items and items are of desired type. */
-static int validate_array_type(PyObject *seq, unsigned short dim, unsigned short totdim, unsigned short dimsize[],
+static int validate_array_type(PyObject *seq, int dim, int totdim, int dimsize[],
ItemTypeCheckFunc check_item_type, const char *item_type_str, const char *error_prefix)
{
int i;
@@ -79,13 +76,13 @@ static int validate_array_type(PyObject *seq, unsigned short dim, unsigned short
ok= 0;
}
/* arr[3][4][5]
- DIMSIZE(1)=4
- DIMSIZE(2)=5
+ dimsize[1]=4
+ dimsize[2]=5
dim=0 */
- else if (PySequence_Length(item) != DIMSIZE(dim + 1)) {
- /* BLI_snprintf(error_str, error_str_size, "sequences of dimension %d should contain %d items", (int)dim + 1, (int)DIMSIZE(dim + 1)); */
- PyErr_Format(PyExc_ValueError, "%s sequences of dimension %d should contain %d items", error_prefix, (int)dim + 1, (int)DIMSIZE(dim + 1));
+ else if (PySequence_Length(item) != dimsize[dim + 1]) {
+ /* BLI_snprintf(error_str, error_str_size, "sequences of dimension %d should contain %d items", (int)dim + 1, (int)dimsize[dim + 1]); */
+ PyErr_Format(PyExc_ValueError, "%s sequences of dimension %d should contain %d items", error_prefix, (int)dim + 1, (int)dimsize[dim + 1]);
ok= 0;
}
else if (!validate_array_type(item, dim + 1, totdim, dimsize, check_item_type, item_type_str, error_prefix)) {
@@ -140,23 +137,28 @@ static int count_items(PyObject *seq)
/* Modifies property array length if needed and PROP_DYNAMIC flag is set. */
static int validate_array_length(PyObject *rvalue, PointerRNA *ptr, PropertyRNA *prop, int lvalue_dim, int *totitem, const char *error_prefix)
{
- unsigned short dimsize[MAX_ARRAY_DIMENSION];
+ int dimsize[MAX_ARRAY_DIMENSION];
int tot, totdim, len;
tot= count_items(rvalue);
- totdim= RNA_property_array_dimension(prop, dimsize);
+ totdim= RNA_property_array_dimension(ptr, prop, dimsize);
if ((RNA_property_flag(prop) & PROP_DYNAMIC) && lvalue_dim == 0) {
- /* length is flexible */
if (RNA_property_array_length(ptr, prop) != tot) {
+#if 0
+ /* length is flexible */
if (!RNA_property_dynamic_array_set_length(ptr, prop, tot)) {
/* BLI_snprintf(error_str, error_str_size, "%s.%s: array length cannot be changed to %d", RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), tot); */
PyErr_Format(PyExc_ValueError, "%s %s.%s: array length cannot be changed to %d", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), tot);
return 0;
}
-
- len= tot;
+#else
+ PyErr_Format(PyExc_ValueError, "%s %s.%s: array length cannot be changed to %d", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), tot);
+ return 0;
+#endif
}
+
+ len= tot;
}
else {
/* length is a constraint */
@@ -173,8 +175,8 @@ static int validate_array_length(PyObject *rvalue, PointerRNA *ptr, PropertyRNA
arr[2] = x
dimsize={4, 5}
- DIMSIZE(1) = 4
- DIMSIZE(2) = 5
+ dimsize[1] = 4
+ dimsize[2] = 5
lvalue_dim=0, totdim=3
arr[2][3] = x
@@ -183,7 +185,7 @@ static int validate_array_length(PyObject *rvalue, PointerRNA *ptr, PropertyRNA
arr[2][3][4] = x
lvalue_dim=2 */
for (i= lvalue_dim; i < totdim; i++)
- len *= DIMSIZE(i);
+ len *= dimsize[i];
}
if (tot != len) {
@@ -200,8 +202,8 @@ static int validate_array_length(PyObject *rvalue, PointerRNA *ptr, PropertyRNA
static int validate_array(PyObject *rvalue, PointerRNA *ptr, PropertyRNA *prop, int lvalue_dim, ItemTypeCheckFunc check_item_type, const char *item_type_str, int *totitem, const char *error_prefix)
{
- unsigned short dimsize[MAX_ARRAY_DIMENSION];
- int totdim= RNA_property_array_dimension(prop, dimsize);
+ int dimsize[MAX_ARRAY_DIMENSION];
+ int totdim= RNA_property_array_dimension(ptr, prop, dimsize);
/* validate type first because length validation may modify property array length */
@@ -211,10 +213,10 @@ static int validate_array(PyObject *rvalue, PointerRNA *ptr, PropertyRNA *prop,
return validate_array_length(rvalue, ptr, prop, lvalue_dim, totitem, error_prefix);
}
-static char *copy_values(PyObject *seq, PointerRNA *ptr, PropertyRNA *prop, unsigned short dim, char *data, unsigned int item_size, int *index, ItemConvertFunc convert_item, RNA_SetIndexFunc rna_set_index)
+static char *copy_values(PyObject *seq, PointerRNA *ptr, PropertyRNA *prop, int dim, char *data, unsigned int item_size, int *index, ItemConvertFunc convert_item, RNA_SetIndexFunc rna_set_index)
{
unsigned int i;
- int totdim= RNA_property_array_dimension(prop, NULL);
+ int totdim= RNA_property_array_dimension(ptr, prop, NULL);
for (i= 0; i < PySequence_Length(seq); i++) {
PyObject *item= PySequence_GetItem(seq, i);
@@ -244,14 +246,15 @@ static char *copy_values(PyObject *seq, PointerRNA *ptr, PropertyRNA *prop, unsi
static int py_to_array(PyObject *py, PointerRNA *ptr, PropertyRNA *prop, char *param_data, ItemTypeCheckFunc check_item_type, const char *item_type_str, int item_size, ItemConvertFunc convert_item, RNA_SetArrayFunc rna_set_array, const char *error_prefix)
{
- unsigned short totdim, dim_size[MAX_ARRAY_DIMENSION];
+ int totdim, dim_size[MAX_ARRAY_DIMENSION];
int totitem;
char *data= NULL;
- totdim= RNA_property_array_dimension(prop, dim_size);
+ totdim= RNA_property_array_dimension(ptr, prop, dim_size);
- if (!validate_array(py, ptr, prop, 0, check_item_type, item_type_str, &totitem, error_prefix))
+ if (!validate_array(py, ptr, prop, 0, check_item_type, item_type_str, &totitem, error_prefix)) {
return 0;
+ }
if (totitem) {
if (!param_data || RNA_property_flag(prop) & PROP_DYNAMIC)
@@ -279,10 +282,10 @@ static int py_to_array(PyObject *py, PointerRNA *ptr, PropertyRNA *prop, char *p
static int py_to_array_index(PyObject *py, PointerRNA *ptr, PropertyRNA *prop, int lvalue_dim, int arrayoffset, int index, ItemTypeCheckFunc check_item_type, const char *item_type_str, ItemConvertFunc convert_item, RNA_SetIndexFunc rna_set_index, const char *error_prefix)
{
- unsigned short totdim, dimsize[MAX_ARRAY_DIMENSION];
+ int totdim, dimsize[MAX_ARRAY_DIMENSION];
int totitem, i;
- totdim= RNA_property_array_dimension(prop, dimsize);
+ totdim= RNA_property_array_dimension(ptr, prop, dimsize);
/* convert index */
@@ -297,7 +300,7 @@ static int py_to_array_index(PyObject *py, PointerRNA *ptr, PropertyRNA *prop, i
lvalue_dim++;
for (i= lvalue_dim; i < totdim; i++)
- index *= DIMSIZE(i);
+ index *= dimsize[i];
index += arrayoffset;
@@ -428,9 +431,9 @@ static PyObject *pyrna_py_from_array_internal(PointerRNA *ptr, PropertyRNA *prop
{
PyObject *tuple;
int i, len;
- int totdim= RNA_property_array_dimension(prop, NULL);
+ int totdim= RNA_property_array_dimension(ptr, prop, NULL);
- len= RNA_property_multidimensional_array_length(ptr, prop, dim);
+ len= RNA_property_multi_array_length(ptr, prop, dim);
tuple= PyTuple_New(len);
@@ -459,11 +462,11 @@ static PyObject *pyrna_py_from_array_internal(PointerRNA *ptr, PropertyRNA *prop
PyObject *pyrna_py_from_array_index(BPy_PropertyRNA *self, int index)
{
int totdim, i, len;
- unsigned short dimsize[MAX_ARRAY_DIMENSION];
+ int dimsize[MAX_ARRAY_DIMENSION];
BPy_PropertyRNA *ret= NULL;
/* just in case check */
- len= RNA_property_multidimensional_array_length(&self->ptr, self->prop, self->arraydim);
+ len= RNA_property_multi_array_length(&self->ptr, self->prop, self->arraydim);
if (index >= len || index < 0) {
/* this shouldn't happen because higher level funcs must check for invalid index */
if (G.f & G_DEBUG) printf("pyrna_py_from_array_index: invalid index %d for array with length=%d\n", index, len);
@@ -472,7 +475,7 @@ PyObject *pyrna_py_from_array_index(BPy_PropertyRNA *self, int index)
return NULL;
}
- totdim= RNA_property_array_dimension(self->prop, dimsize);
+ totdim= RNA_property_array_dimension(&self->ptr, self->prop, dimsize);
if (self->arraydim + 1 < totdim) {
ret= (BPy_PropertyRNA*)pyrna_prop_CreatePyObject(&self->ptr, self->prop);
@@ -487,7 +490,7 @@ PyObject *pyrna_py_from_array_index(BPy_PropertyRNA *self, int index)
index = offset + 3 * 5 */
for (i= self->arraydim + 1; i < totdim; i++)
- index *= DIMSIZE(i);
+ index *= dimsize[i];
ret->arrayoffset= self->arrayoffset + index;
}
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index f2ffd5e0358..dd6bc35fc0a 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -141,7 +141,7 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop)
len= RNA_property_array_length(ptr, prop);
type= RNA_property_type(prop);
subtype= RNA_property_subtype(prop);
- totdim= RNA_property_array_dimension(prop, NULL);
+ totdim= RNA_property_array_dimension(ptr, prop, NULL);
if (type != PROP_FLOAT) return NULL;
@@ -748,7 +748,7 @@ static int pyrna_py_to_prop_index(BPy_PropertyRNA *self, int index, PyObject *va
PropertyRNA *prop= self->prop;
int type = RNA_property_type(prop);
- totdim= RNA_property_array_dimension(prop, NULL);
+ totdim= RNA_property_array_dimension(ptr, prop, NULL);
if (totdim > 1) {
/* char error_str[512]; */
@@ -807,8 +807,8 @@ static int pyrna_py_to_prop_index(BPy_PropertyRNA *self, int index, PyObject *va
//---------------sequence-------------------------------------------
static int pyrna_prop_array_length(BPy_PropertyRNA *self)
{
- if (RNA_property_array_dimension(self->prop, NULL) > 1)
- return RNA_property_multidimensional_array_length(&self->ptr, self->prop, self->arraydim);
+ if (RNA_property_array_dimension(&self->ptr, self->prop, NULL) > 1)
+ return RNA_property_multi_array_length(&self->ptr, self->prop, self->arraydim);
else
return RNA_property_array_length(&self->ptr, self->prop);
}