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>2018-06-09 15:42:01 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-06-09 15:43:01 +0300
commit2ca8230f67db3d6c4693d0a2e0997dfd5de43091 (patch)
treed8d7e5c7a15a68f7b27fde0dc7939cbfcf71cf4a /source/blender/makesrna/intern/rna_access.c
parent09ce794dc8c6cf5e406532651576e6b86dfd9232 (diff)
parentfb565ddb681f39cbe47e91d11e5b728bb4314a7b (diff)
Merge branch 'master' into blender2.8
Diffstat (limited to 'source/blender/makesrna/intern/rna_access.c')
-rw-r--r--source/blender/makesrna/intern/rna_access.c182
1 files changed, 91 insertions, 91 deletions
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index df09e5c68b5..0532aac1bc3 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -107,9 +107,9 @@ void RNA_init(void)
void RNA_exit(void)
{
StructRNA *srna;
-
+
RNA_property_update_cache_free();
-
+
for (srna = BLENDER_RNA.structs.first; srna; srna = srna->cont.next) {
if (srna->cont.prophash) {
BLI_ghash_free(srna->cont.prophash, NULL, NULL);
@@ -137,7 +137,7 @@ void RNA_id_pointer_create(ID *id, PointerRNA *r_ptr)
PointerRNA tmp = {{NULL}};
tmp.data = id;
idtype = rna_ID_refine(&tmp);
-
+
while (idtype->refine) {
type = idtype->refine(&tmp);
@@ -147,7 +147,7 @@ void RNA_id_pointer_create(ID *id, PointerRNA *r_ptr)
idtype = type;
}
}
-
+
r_ptr->id.data = id;
r_ptr->type = idtype;
r_ptr->data = id;
@@ -289,7 +289,7 @@ IDProperty *RNA_struct_idprops(PointerRNA *ptr, bool create)
if (type && type->idproperties) {
return type->idproperties(ptr, create);
}
-
+
return NULL;
}
@@ -380,7 +380,7 @@ static bool rna_idproperty_verify_valid(PointerRNA *ptr, PropertyRNA *prop, IDPr
* description and otherwise removes it. this is to ensure that
* rna property access is type safe, e.g. if you defined the rna
* to have a certain array length you can count on that staying so */
-
+
switch (idprop->type) {
case IDP_IDPARRAY:
if (prop->type != PROP_COLLECTION)
@@ -693,7 +693,7 @@ bool RNA_struct_is_a(const StructRNA *type, const StructRNA *srna)
for (base = type; base; base = base->base)
if (base == srna)
return true;
-
+
return false;
}
@@ -718,7 +718,7 @@ PropertyRNA *RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
if (RNA_property_collection_lookup_string(ptr, iterprop, identifier, &propptr))
return propptr.data;
}
-
+
return NULL;
}
@@ -1180,7 +1180,7 @@ void RNA_property_int_ui_range(PointerRNA *ptr, PropertyRNA *prop, int *softmin,
{
IntPropertyRNA *iprop = (IntPropertyRNA *)rna_ensure_property(prop);
int hardmin, hardmax;
-
+
if (prop->magic != RNA_MAGIC) {
/* attempt to get the local ID values */
IDProperty *idp_ui = rna_idproperty_ui(prop);
@@ -1693,7 +1693,7 @@ bool RNA_property_enum_identifier(bContext *C, PointerRNA *ptr, PropertyRNA *pro
{
const EnumPropertyItem *item = NULL;
bool free;
-
+
RNA_property_enum_items(C, ptr, prop, &item, NULL, &free);
if (item) {
bool result;
@@ -1710,7 +1710,7 @@ bool RNA_property_enum_name(bContext *C, PointerRNA *ptr, PropertyRNA *prop, con
{
const EnumPropertyItem *item = NULL;
bool free;
-
+
RNA_property_enum_items(C, ptr, prop, &item, NULL, &free);
if (item) {
bool result;
@@ -1718,7 +1718,7 @@ bool RNA_property_enum_name(bContext *C, PointerRNA *ptr, PropertyRNA *prop, con
if (free) {
MEM_freeN((void *)item);
}
-
+
return result;
}
return false;
@@ -1932,7 +1932,7 @@ bool RNA_property_animateable(PointerRNA *ptr, PropertyRNA *prop)
/* check that base ID-block can support animation data */
if (!id_can_have_animdata(ptr->id.data))
return false;
-
+
prop = rna_ensure_property(prop);
if (!(prop->flag & PROP_ANIMATABLE))
@@ -2147,7 +2147,7 @@ void RNA_property_update_main(Main *bmain, Scene *scene, PointerRNA *ptr, Proper
/* cache element */
typedef struct tRnaUpdateCacheElem {
struct tRnaUpdateCacheElem *next, *prev;
-
+
PointerRNA ptr; /* L1 key - id as primary, data secondary/ignored? */
ListBase L2Funcs; /* L2 functions (LinkData<RnaUpdateFuncRef>) */
} tRnaUpdateCacheElem;
@@ -2163,18 +2163,18 @@ void RNA_property_update_cache_add(PointerRNA *ptr, PropertyRNA *prop)
tRnaUpdateCacheElem *uce = NULL;
UpdateFunc fn = NULL;
LinkData *ld;
-
+
/* sanity check */
if (NULL == ptr)
return;
-
+
prop = rna_ensure_property(prop);
-
+
/* we can only handle update calls with no context args for now (makes animsys updates easier) */
if ((is_rna == false) || (prop->update == NULL) || (prop->flag & PROP_CONTEXT_UPDATE))
return;
fn = prop->update;
-
+
/* find cache element for which key matches... */
for (uce = rna_updates_cache.first; uce; uce = uce->next) {
/* just match by id only for now, since most update calls that we'll encounter only really care about this */
@@ -2187,11 +2187,11 @@ void RNA_property_update_cache_add(PointerRNA *ptr, PropertyRNA *prop)
/* create new instance */
uce = MEM_callocN(sizeof(tRnaUpdateCacheElem), "tRnaUpdateCacheElem");
BLI_addtail(&rna_updates_cache, uce);
-
+
/* copy pointer */
RNA_pointer_create(ptr->id.data, ptr->type, ptr->data, &uce->ptr);
}
-
+
/* check on the update func */
for (ld = uce->L2Funcs.first; ld; ld = ld->next) {
/* stop on match - function already cached */
@@ -2205,13 +2205,13 @@ void RNA_property_update_cache_add(PointerRNA *ptr, PropertyRNA *prop)
void RNA_property_update_cache_flush(Main *bmain, Scene *scene)
{
tRnaUpdateCacheElem *uce;
-
+
/* TODO: should we check that bmain and scene are valid? The above stuff doesn't! */
-
+
/* execute the cached updates */
for (uce = rna_updates_cache.first; uce; uce = uce->next) {
LinkData *ld;
-
+
for (ld = uce->L2Funcs.first; ld; ld = ld->next) {
UpdateFunc fn = (UpdateFunc)ld->data;
fn(bmain, scene, &uce->ptr);
@@ -2222,13 +2222,13 @@ void RNA_property_update_cache_flush(Main *bmain, Scene *scene)
void RNA_property_update_cache_free(void)
{
tRnaUpdateCacheElem *uce, *ucn;
-
+
for (uce = rna_updates_cache.first; uce; uce = ucn) {
ucn = uce->next;
-
+
/* free L2 cache */
BLI_freelistN(&uce->L2Funcs);
-
+
/* remove self */
BLI_freelinkN(&rna_updates_cache, uce);
}
@@ -2429,7 +2429,7 @@ int RNA_property_boolean_get_default(PointerRNA *UNUSED(ptr), PropertyRNA *prop)
void RNA_property_boolean_get_default_array(PointerRNA *UNUSED(ptr), PropertyRNA *prop, int *values)
{
BoolPropertyRNA *bprop = (BoolPropertyRNA *)rna_ensure_property(prop);
-
+
BLI_assert(RNA_property_type(prop) == PROP_BOOLEAN);
BLI_assert(RNA_property_array_check(prop) != false);
@@ -2684,7 +2684,7 @@ int RNA_property_int_get_default(PointerRNA *UNUSED(ptr), PropertyRNA *prop)
void RNA_property_int_get_default_array(PointerRNA *UNUSED(ptr), PropertyRNA *prop, int *values)
{
IntPropertyRNA *iprop = (IntPropertyRNA *)rna_ensure_property(prop);
-
+
BLI_assert(RNA_property_type(prop) == PROP_INT);
BLI_assert(RNA_property_array_check(prop) != false);
@@ -2971,7 +2971,7 @@ float RNA_property_float_get_default(PointerRNA *UNUSED(ptr), PropertyRNA *prop)
void RNA_property_float_get_default_array(PointerRNA *UNUSED(ptr), PropertyRNA *prop, float *values)
{
FloatPropertyRNA *fprop = (FloatPropertyRNA *)rna_ensure_property(prop);
-
+
BLI_assert(RNA_property_type(prop) == PROP_FLOAT);
BLI_assert(RNA_property_array_check(prop) != false);
@@ -3407,7 +3407,7 @@ void RNA_property_pointer_remove(PointerRNA *ptr, PropertyRNA *prop)
if ((idprop = rna_idproperty_check(&prop, ptr))) {
group = RNA_struct_idprops(ptr, 0);
-
+
if (group) {
IDP_FreeFromGroup(group, idprop);
}
@@ -3688,7 +3688,7 @@ int RNA_property_collection_lookup_index(PointerRNA *ptr, PropertyRNA *prop, Poi
{
CollectionPropertyIterator iter;
int index = 0;
-
+
BLI_assert(RNA_property_type(prop) == PROP_COLLECTION);
RNA_property_collection_begin(ptr, prop, &iter);
@@ -3697,7 +3697,7 @@ int RNA_property_collection_lookup_index(PointerRNA *ptr, PropertyRNA *prop, Poi
break;
}
RNA_property_collection_end(&iter);
-
+
/* did we find it? */
if (iter.valid)
return index;
@@ -3890,7 +3890,7 @@ static int rna_property_array_length_all_dimensions(PointerRNA *ptr, PropertyRNA
for (size = 1, i = 0; i < dim; i++)
size *= len[i];
-
+
return size;
}
@@ -3943,7 +3943,7 @@ static int rna_raw_access(ReportList *reports, PointerRNA *ptr, PropertyRNA *pro
out.len * arraylen, in.len);
return 0;
}
-
+
/* matching raw types */
if (out.type == in.type) {
void *inp = in.array;
@@ -4301,7 +4301,7 @@ void rna_iterator_array_begin(CollectionPropertyIterator *iter, void *ptr, int i
internal->itemsize = itemsize;
internal->skip = skip;
internal->length = length;
-
+
iter->valid = (internal->ptr != internal->endptr);
if (skip && iter->valid && skip(iter, internal->ptr))
@@ -4342,7 +4342,7 @@ void *rna_iterator_array_dereference_get(CollectionPropertyIterator *iter)
void rna_iterator_array_end(CollectionPropertyIterator *iter)
{
ArrayIterator *internal = &iter->internal.array;
-
+
if (internal->free_ptr) {
MEM_freeN(internal->free_ptr);
internal->free_ptr = NULL;
@@ -4397,7 +4397,7 @@ static char *rna_path_token(const char **path, char *fixedbuf, int fixedlen, int
len++;
p++;
}
-
+
/* skip the last quoted char to get the ']' */
len++;
p++;
@@ -4414,11 +4414,11 @@ static char *rna_path_token(const char **path, char *fixedbuf, int fixedlen, int
p++;
}
}
-
+
/* empty, return */
if (len == 0)
return NULL;
-
+
/* try to use fixed buffer if possible */
if (len + 1 < fixedlen)
buf = fixedbuf;
@@ -4464,22 +4464,22 @@ static bool rna_path_parse_collection_key(const char **path, PointerRNA *ptr, Pr
{
char fixedbuf[256];
int intkey;
-
+
*r_nextptr = *ptr;
/* end of path, ok */
if (!(**path))
return true;
-
+
if (**path == '[') {
char *token;
/* resolve the lookup with [] brackets */
token = rna_path_token(path, fixedbuf, sizeof(fixedbuf), 1);
-
+
if (!token)
return false;
-
+
/* check for "" to see if it is a string */
if (rna_token_strip_quotes(token)) {
if (RNA_property_collection_lookup_string(ptr, prop, token + 1, r_nextptr)) {
@@ -4502,7 +4502,7 @@ static bool rna_path_parse_collection_key(const char **path, PointerRNA *ptr, Pr
r_nextptr->data = NULL;
}
}
-
+
if (token != fixedbuf) {
MEM_freeN(token);
}
@@ -4516,7 +4516,7 @@ static bool rna_path_parse_collection_key(const char **path, PointerRNA *ptr, Pr
r_nextptr->data = NULL;
}
}
-
+
return true;
}
@@ -4527,21 +4527,21 @@ static bool rna_path_parse_array_index(const char **path, PointerRNA *ptr, Prope
int len[RNA_MAX_ARRAY_DIMENSION];
const int dim = RNA_property_array_dimension(ptr, prop, len);
int i;
-
+
*r_index = -1;
-
+
/* end of path, ok */
if (!(**path))
return true;
-
+
for (i = 0; i < dim; i++) {
int temp_index = -1;
char *token;
-
+
/* multi index resolve */
if (**path == '[') {
token = rna_path_token(path, fixedbuf, sizeof(fixedbuf), 1);
-
+
if (token == NULL) {
/* invalid syntax blah[] */
return false;
@@ -4553,12 +4553,12 @@ static bool rna_path_parse_array_index(const char **path, PointerRNA *ptr, Prope
else {
/* otherwise do int lookup */
temp_index = atoi(token);
-
+
if (temp_index == 0 && (token[0] != '0' || token[1] != '\0')) {
if (token != fixedbuf) {
MEM_freeN(token);
}
-
+
return false;
}
}
@@ -4576,33 +4576,33 @@ static bool rna_path_parse_array_index(const char **path, PointerRNA *ptr, Prope
/* just to avoid uninitialized pointer use */
token = fixedbuf;
}
-
+
if (token != fixedbuf) {
MEM_freeN(token);
}
-
+
/* out of range */
if (temp_index < 0 || temp_index >= len[i])
return false;
-
+
index_arr[i] = temp_index;
/* end multi index resolve */
}
-
+
/* arrays always contain numbers so further values are not valid */
if (**path)
return false;
-
+
/* flatten index over all dimensions */
{
int totdim = 1;
int flat_index = 0;
-
+
for (i = dim - 1; i >= 0; i--) {
flat_index += index_arr[i] * totdim;
totdim *= len[i];
}
-
+
*r_index = flat_index;
}
return true;
@@ -4678,7 +4678,7 @@ static bool rna_path_parse(PointerRNA *ptr, const char *path,
*/
if (eval_pointer || *path) {
PointerRNA nextptr = RNA_property_pointer_get(&curptr, prop);
-
+
curptr = nextptr;
prop = NULL; /* now we have a PointerRNA, the prop is our parent so forget it */
index = -1;
@@ -4695,7 +4695,7 @@ static bool rna_path_parse(PointerRNA *ptr, const char *path,
PointerRNA nextptr;
if (!rna_path_parse_collection_key(&path, &curptr, prop, &nextptr))
return false;
-
+
curptr = nextptr;
prop = NULL; /* now we have a PointerRNA, the prop is our parent so forget it */
index = -1;
@@ -4812,7 +4812,7 @@ char *RNA_path_append(const char *path, PointerRNA *UNUSED(ptr), PropertyRNA *pr
DynStr *dynstr;
const char *s;
char appendstr[128], *result;
-
+
dynstr = BLI_dynstr_new();
/* add .identifier */
@@ -4887,7 +4887,7 @@ char *RNA_path_back(const char *path)
token = rna_path_token(&current, fixedbuf, sizeof(fixedbuf), 1);
if (token && token != fixedbuf)
MEM_freeN(token);
-
+
if (!*current)
break;
@@ -5058,7 +5058,7 @@ char *RNA_path_from_ID_to_struct(PointerRNA *ptr)
if (!ptr->id.data || !ptr->data)
return NULL;
-
+
if (!RNA_struct_is_ID(ptr->type)) {
if (ptr->type->path) {
/* if type has a path to some ID, use it */
@@ -5067,13 +5067,13 @@ char *RNA_path_from_ID_to_struct(PointerRNA *ptr)
else if (ptr->type->nested && RNA_struct_is_ID(ptr->type->nested)) {
PointerRNA parentptr;
PropertyRNA *userprop;
-
+
/* find the property in the struct we're nested in that references this struct, and
* use its identifier as the first part of the path used...
*/
RNA_id_pointer_create(ptr->id.data, &parentptr);
userprop = RNA_struct_find_nested(&parentptr, ptr->type);
-
+
if (userprop)
ptrpath = BLI_strdup(RNA_property_identifier(userprop));
else
@@ -5086,7 +5086,7 @@ char *RNA_path_from_ID_to_struct(PointerRNA *ptr)
else
return NULL;
}
-
+
return ptrpath;
}
@@ -5138,7 +5138,7 @@ char *RNA_path_from_ID_to_property_index(PointerRNA *ptr, PropertyRNA *prop, int
if (!ptr->id.data || !ptr->data)
return NULL;
-
+
/* path from ID to the struct holding this property */
ptrpath = RNA_path_from_ID_to_struct(ptr);
@@ -5868,23 +5868,23 @@ char *RNA_pointer_as_string_id(bContext *C, PointerRNA *ptr)
{
DynStr *dynstr = BLI_dynstr_new();
char *cstring;
-
+
const char *propname;
int first_time = 1;
-
+
BLI_dynstr_append(dynstr, "{");
-
+
RNA_STRUCT_BEGIN (ptr, prop)
{
propname = RNA_property_identifier(prop);
-
+
if (STREQ(propname, "rna_type"))
continue;
-
+
if (first_time == 0)
BLI_dynstr_append(dynstr, ", ");
first_time = 0;
-
+
cstring = RNA_property_as_string(C, ptr, prop, -1, INT_MAX);
BLI_dynstr_appendf(dynstr, "\"%s\":%s", propname, cstring);
MEM_freeN(cstring);
@@ -5892,8 +5892,8 @@ char *RNA_pointer_as_string_id(bContext *C, PointerRNA *ptr)
RNA_STRUCT_END;
BLI_dynstr_append(dynstr, "}");
-
-
+
+
cstring = BLI_dynstr_get_cstring(dynstr);
BLI_dynstr_free(dynstr);
return cstring;
@@ -6046,7 +6046,7 @@ char *RNA_property_as_string(bContext *C, PointerRNA *ptr, PropertyRNA *prop, in
DynStr *dynstr = BLI_dynstr_new();
char *cstring;
-
+
/* see if we can coerce into a python type - PropertyType */
switch (type) {
@@ -6217,7 +6217,7 @@ char *RNA_property_as_string(bContext *C, PointerRNA *ptr, PropertyRNA *prop, in
BLI_dynstr_append(dynstr, cstring);
MEM_freeN(cstring);
}
-
+
RNA_property_collection_end(&collect_iter);
BLI_dynstr_append(dynstr, "]");
break;
@@ -6323,7 +6323,7 @@ ParameterList *RNA_parameter_list_create(ParameterList *parms, PointerRNA *UNUSE
data_alloc->array_tot = 0;
data_alloc->array = NULL;
}
-
+
if (!(parm->flag_parameter & PARM_REQUIRED) && !(parm->flag & PROP_DYNAMIC)) {
switch (parm->type) {
case PROP_BOOLEAN:
@@ -6752,7 +6752,7 @@ static int rna_function_parameter_parse(PointerRNA *ptr, PropertyRNA *prop, Prop
*((PointerRNA *)dest) = *((PointerRNA *)src);
break;
}
-
+
if (ptype != srna && !RNA_struct_is_a(srna, ptype)) {
fprintf(stderr, "%s.%s: wrong type for parameter %s, "
"an object of type %s was expected, passed an object of type %s\n",
@@ -6779,7 +6779,7 @@ static int rna_function_parameter_parse(PointerRNA *ptr, PropertyRNA *prop, Prop
lb = (ListBase *)src;
clb = (ListBase *)dest;
ptype = RNA_property_pointer_type(ptr, prop);
-
+
if (ptype != srna && !RNA_struct_is_a(srna, ptype)) {
fprintf(stderr, "%s.%s: wrong type for parameter %s, "
"a collection of objects of type %s was expected, "
@@ -7025,17 +7025,17 @@ bool RNA_property_reset(PointerRNA *ptr, PropertyRNA *prop, int index)
/* get the length of the array to work with */
len = RNA_property_array_length(ptr, prop);
-
+
/* get and set the default values as appropriate for the various types */
switch (RNA_property_type(prop)) {
case PROP_BOOLEAN:
if (len) {
if (index == -1) {
int *tmparray = MEM_callocN(sizeof(int) * len, "reset_defaults - boolean");
-
+
RNA_property_boolean_get_default_array(ptr, prop, tmparray);
RNA_property_boolean_set_array(ptr, prop, tmparray);
-
+
MEM_freeN(tmparray);
}
else {
@@ -7052,10 +7052,10 @@ bool RNA_property_reset(PointerRNA *ptr, PropertyRNA *prop, int index)
if (len) {
if (index == -1) {
int *tmparray = MEM_callocN(sizeof(int) * len, "reset_defaults - int");
-
+
RNA_property_int_get_default_array(ptr, prop, tmparray);
RNA_property_int_set_array(ptr, prop, tmparray);
-
+
MEM_freeN(tmparray);
}
else {
@@ -7072,10 +7072,10 @@ bool RNA_property_reset(PointerRNA *ptr, PropertyRNA *prop, int index)
if (len) {
if (index == -1) {
float *tmparray = MEM_callocN(sizeof(float) * len, "reset_defaults - float");
-
+
RNA_property_float_get_default_array(ptr, prop, tmparray);
RNA_property_float_set_array(ptr, prop, tmparray);
-
+
MEM_freeN(tmparray);
}
else {
@@ -7094,7 +7094,7 @@ bool RNA_property_reset(PointerRNA *ptr, PropertyRNA *prop, int index)
RNA_property_enum_set(ptr, prop, value);
return true;
}
-
+
case PROP_STRING:
{
char *value = RNA_property_string_get_default_alloc(ptr, prop, NULL, 0);
@@ -7102,14 +7102,14 @@ bool RNA_property_reset(PointerRNA *ptr, PropertyRNA *prop, int index)
MEM_freeN(value);
return true;
}
-
+
case PROP_POINTER:
{
PointerRNA value = RNA_property_pointer_get_default(ptr, prop);
RNA_property_pointer_set(ptr, prop, value);
return true;
}
-
+
default:
/* FIXME: are there still any cases that haven't been handled? comment out "default" block to check :) */
return false;