Implementation of RNA side of foreach_get/foreach_set,
Campbell will do python code.

Three functions for efficiently setting some property for all
items in a collection. RNA_property_collection_raw_array gives
access to the properties as an array with length, stride, and
type specified, if this is possible, i.e. not when it uses a
ListBase, or if a manual get/set function is implemented.

Two other functions take a C array pointer and get/set it
using the a collection + property name, using efficient array
access if possible, and otherwise using slower RNA iterator.

RNA_property_collection_raw_get
RNA_property_collection_raw_set

The number of type conversion required here got a bit out of
hand, it could be more efficient still if checking for more
cases, but function is already long enough.


Example: http://www.pasteall.org/6362/c
This commit is contained in:
Brecht Van Lommel 2009-06-29 19:15:51 +00:00
parent 9a7ea9664e
commit e7928dd4b4
8 changed files with 426 additions and 27 deletions

View File

@ -600,6 +600,11 @@ int RNA_property_collection_length(PointerRNA *ptr, PropertyRNA *prop);
int RNA_property_collection_lookup_int(PointerRNA *ptr, PropertyRNA *prop, int key, PointerRNA *r_ptr);
int RNA_property_collection_lookup_string(PointerRNA *ptr, PropertyRNA *prop, const char *key, PointerRNA *r_ptr);
/* efficient functions to set properties for arrays */
int RNA_property_collection_raw_array(PointerRNA *ptr, PropertyRNA *prop, PropertyRNA *itemprop, RawArray *array);
int RNA_property_collection_raw_get(struct ReportList *reports, PointerRNA *ptr, PropertyRNA *prop, char *propname, void *array, RawPropertyType type, int len);
int RNA_property_collection_raw_set(struct ReportList *reports, PointerRNA *ptr, PropertyRNA *prop, char *propname, void *array, RawPropertyType type, int len);
/* to create ID property groups */
void RNA_property_pointer_add(PointerRNA *ptr, PropertyRNA *prop);
void RNA_property_pointer_remove(PointerRNA *ptr, PropertyRNA *prop);

View File

@ -110,7 +110,9 @@ typedef enum PropertyFlag {
PROP_BUILTIN = 128,
PROP_EXPORT = 256,
PROP_RUNTIME = 512,
PROP_IDPROPERTY = 1024
PROP_IDPROPERTY = 1024,
PROP_RAW_ACCESS = 8192,
PROP_RAW_ARRAY = 16384,
} PropertyFlag;
typedef struct CollectionPropertyIterator {
@ -132,6 +134,21 @@ typedef struct CollectionPointerLink {
PointerRNA ptr;
} CollectionPointerLink;
typedef enum RawPropertyType {
PROP_RAW_CHAR,
PROP_RAW_SHORT,
PROP_RAW_INT,
PROP_RAW_FLOAT,
PROP_RAW_DOUBLE
} RawPropertyType;
typedef struct RawArray {
void *array;
RawPropertyType type;
int len;
int stride;
} RawArray;
/* Iterator Utility */
typedef struct EnumPropertyItem {

View File

@ -762,6 +762,42 @@ static char *rna_def_property_end_func(FILE *f, StructRNA *srna, PropertyRNA *pr
return func;
}
static void rna_set_raw_property(PropertyDefRNA *dp, PropertyRNA *prop)
{
if(dp->dnapointerlevel != 0)
return;
if(!dp->dnatype || !dp->dnaname || !dp->dnastructname)
return;
if(strcmp(dp->dnatype, "char") == 0) {
prop->rawtype= PROP_RAW_CHAR;
prop->flag |= PROP_RAW_ACCESS;
}
else if(strcmp(dp->dnatype, "short") == 0) {
prop->rawtype= PROP_RAW_SHORT;
prop->flag |= PROP_RAW_ACCESS;
}
else if(strcmp(dp->dnatype, "int") == 0) {
prop->rawtype= PROP_RAW_INT;
prop->flag |= PROP_RAW_ACCESS;
}
else if(strcmp(dp->dnatype, "float") == 0) {
prop->rawtype= PROP_RAW_FLOAT;
prop->flag |= PROP_RAW_ACCESS;
}
else if(strcmp(dp->dnatype, "double") == 0) {
prop->rawtype= PROP_RAW_DOUBLE;
prop->flag |= PROP_RAW_ACCESS;
}
}
static void rna_set_raw_offset(FILE *f, StructRNA *srna, PropertyRNA *prop)
{
PropertyDefRNA *dp= rna_find_struct_property_def(srna, prop);
fprintf(f, "\toffsetof(%s, %s), %d", dp->dnastructname, dp->dnaname, prop->rawtype);
}
static void rna_def_property_funcs(FILE *f, StructRNA *srna, PropertyDefRNA *dp)
{
PropertyRNA *prop;
@ -773,6 +809,9 @@ static void rna_def_property_funcs(FILE *f, StructRNA *srna, PropertyDefRNA *dp)
BooleanPropertyRNA *bprop= (BooleanPropertyRNA*)prop;
if(!prop->arraylength) {
if(!bprop->get && !bprop->set && !dp->booleanbit)
rna_set_raw_property(dp, prop);
bprop->get= (void*)rna_def_property_get_func(f, srna, prop, dp, (char*)bprop->get);
bprop->set= (void*)rna_def_property_set_func(f, srna, prop, dp, (char*)bprop->set);
}
@ -786,10 +825,16 @@ static void rna_def_property_funcs(FILE *f, StructRNA *srna, PropertyDefRNA *dp)
IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
if(!prop->arraylength) {
if(!iprop->get && !iprop->set)
rna_set_raw_property(dp, prop);
iprop->get= (void*)rna_def_property_get_func(f, srna, prop, dp, (char*)iprop->get);
iprop->set= (void*)rna_def_property_set_func(f, srna, prop, dp, (char*)iprop->set);
}
else {
if(!iprop->getarray && !iprop->setarray)
rna_set_raw_property(dp, prop);
iprop->getarray= (void*)rna_def_property_get_func(f, srna, prop, dp, (char*)iprop->getarray);
iprop->setarray= (void*)rna_def_property_set_func(f, srna, prop, dp, (char*)iprop->setarray);
}
@ -799,10 +844,16 @@ static void rna_def_property_funcs(FILE *f, StructRNA *srna, PropertyDefRNA *dp)
FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop;
if(!prop->arraylength) {
if(!fprop->get && !fprop->set)
rna_set_raw_property(dp, prop);
fprop->get= (void*)rna_def_property_get_func(f, srna, prop, dp, (char*)fprop->get);
fprop->set= (void*)rna_def_property_set_func(f, srna, prop, dp, (char*)fprop->set);
}
else {
if(!fprop->getarray && !fprop->setarray)
rna_set_raw_property(dp, prop);
fprop->getarray= (void*)rna_def_property_get_func(f, srna, prop, dp, (char*)fprop->getarray);
fprop->setarray= (void*)rna_def_property_set_func(f, srna, prop, dp, (char*)fprop->setarray);
}
@ -841,6 +892,13 @@ static void rna_def_property_funcs(FILE *f, StructRNA *srna, PropertyDefRNA *dp)
else if(dp->dnalengthname || dp->dnalengthfixed)
cprop->length= (void*)rna_def_property_length_func(f, srna, prop, dp, (char*)cprop->length);
/* test if we can allow raw array access, if it is using our standard
* array get/next function, we can be sure it is an actual array */
if(cprop->next && cprop->get)
if(strcmp((char*)cprop->next, "rna_iterator_array_next") == 0 &&
strcmp((char*)cprop->get, "rna_iterator_array_get") == 0)
prop->flag |= PROP_RAW_ARRAY;
cprop->get= (void*)rna_def_property_get_func(f, srna, prop, dp, (char*)cprop->get);
cprop->begin= (void*)rna_def_property_begin_func(f, srna, prop, dp, (char*)cprop->begin);
cprop->next= (void*)rna_def_property_next_func(f, srna, prop, dp, (char*)cprop->next);
@ -1538,7 +1596,7 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr
DefRNA.error= 1;
}
break;
}
}
case PROP_BOOLEAN: {
BooleanPropertyRNA *bprop= (BooleanPropertyRNA*)prop;
unsigned int i;
@ -1558,7 +1616,7 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr
fprintf(f, "};\n\n");
}
break;
}
}
case PROP_INT: {
IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
unsigned int i;
@ -1578,7 +1636,7 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr
fprintf(f, "};\n\n");
}
break;
}
}
case PROP_FLOAT: {
FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop;
unsigned int i;
@ -1598,7 +1656,7 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr
fprintf(f, "};\n\n");
}
break;
}
}
default:
break;
}
@ -1613,10 +1671,14 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr
rna_print_c_string(f, prop->identifier);
fprintf(f, ", %d, ", prop->flag);
rna_print_c_string(f, prop->name); fprintf(f, ",\n\t");
rna_print_c_string(f, prop->description); fprintf(f, ",\n");
fprintf(f, "%d, ", prop->icon);
rna_print_c_string(f, prop->description); fprintf(f, ",\n\t");
fprintf(f, "%d,\n", prop->icon);
fprintf(f, "\t%s, %s, %d,\n", rna_property_typename(prop->type), rna_property_subtypename(prop->subtype), prop->arraylength);
fprintf(f, "\t%s, %d, %s},\n", rna_function_string(prop->update), prop->noteflag, rna_function_string(prop->editable));
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);
else fprintf(f, "\t0, 0");
fprintf(f, "},\n");
switch(prop->type) {
case PROP_BOOLEAN: {
@ -1625,7 +1687,7 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr
if(prop->arraylength) fprintf(f, "rna_%s%s_%s_default\n", srna->identifier, strnest, prop->identifier);
else fprintf(f, "NULL\n");
break;
}
}
case PROP_INT: {
IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
fprintf(f, "\t%s, %s, %s, %s, %s,\n\t", rna_function_string(iprop->get), rna_function_string(iprop->set), rna_function_string(iprop->getarray), rna_function_string(iprop->setarray), rna_function_string(iprop->range));
@ -1638,7 +1700,7 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr
if(prop->arraylength) fprintf(f, "rna_%s%s_%s_default\n", srna->identifier, strnest, prop->identifier);
else fprintf(f, "NULL\n");
break;
}
}
case PROP_FLOAT: {
FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop;
fprintf(f, "\t%s, %s, %s, %s, %s, ", rna_function_string(fprop->get), rna_function_string(fprop->set), rna_function_string(fprop->getarray), rna_function_string(fprop->setarray), rna_function_string(fprop->range));
@ -1652,13 +1714,13 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr
if(prop->arraylength) fprintf(f, "rna_%s%s_%s_default\n", srna->identifier, strnest, prop->identifier);
else fprintf(f, "NULL\n");
break;
}
}
case PROP_STRING: {
StringPropertyRNA *sprop= (StringPropertyRNA*)prop;
fprintf(f, "\t%s, %s, %s, %d, ", rna_function_string(sprop->get), rna_function_string(sprop->length), rna_function_string(sprop->set), sprop->maxlength);
rna_print_c_string(f, sprop->defaultvalue); fprintf(f, "\n");
break;
}
}
case PROP_ENUM: {
EnumPropertyRNA *eprop= (EnumPropertyRNA*)prop;
fprintf(f, "\t%s, %s, %s, ", rna_function_string(eprop->get), rna_function_string(eprop->set), rna_function_string(eprop->itemf));
@ -1668,14 +1730,14 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr
fprintf(f, "NULL, ");
fprintf(f, "%d, %d\n", eprop->totitem, eprop->defaultvalue);
break;
}
}
case PROP_POINTER: {
PointerPropertyRNA *pprop= (PointerPropertyRNA*)prop;
fprintf(f, "\t%s, %s, %s, ", rna_function_string(pprop->get), rna_function_string(pprop->set), rna_function_string(pprop->typef));
if(pprop->type) fprintf(f, "&RNA_%s\n", (char*)pprop->type);
else fprintf(f, "NULL\n");
break;
}
}
case PROP_COLLECTION: {
CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
fprintf(f, "\t%s, %s, %s, %s, %s, %s, %s, ", rna_function_string(cprop->begin), rna_function_string(cprop->next), rna_function_string(cprop->end), rna_function_string(cprop->get), rna_function_string(cprop->length), rna_function_string(cprop->lookupint), rna_function_string(cprop->lookupstring));
@ -1890,6 +1952,7 @@ static void rna_generate(BlenderRNA *brna, FILE *f, char *filename, char *api_fi
fprintf(f, "#include <float.h>\n");
fprintf(f, "#include <limits.h>\n");
fprintf(f, "#include <string.h>\n\n");
fprintf(f, "#include <stddef.h>\n\n");
fprintf(f, "#include \"DNA_ID.h\"\n");

View File

@ -1522,6 +1522,313 @@ int RNA_property_collection_lookup_string(PointerRNA *ptr, PropertyRNA *prop, co
}
}
int RNA_property_collection_raw_array(PointerRNA *ptr, PropertyRNA *prop, PropertyRNA *itemprop, RawArray *array)
{
CollectionPropertyIterator iter;
ArrayIterator *internal;
char *arrayp;
if(!(prop->flag & PROP_RAW_ARRAY) || !(itemprop->flag & PROP_RAW_ACCESS))
return 0;
RNA_property_collection_begin(ptr, prop, &iter);
if(iter.valid) {
/* get data from array iterator and item property */
internal= iter.internal;
arrayp= (iter.valid)? iter.ptr.data: NULL;
if(internal->skip || !RNA_property_editable(&iter.ptr, itemprop)) {
/* we might skip some items, so it's not a proper array */
RNA_property_collection_end(&iter);
return 0;
}
array->array= arrayp + itemprop->rawoffset;
array->stride= internal->itemsize;
array->len= ((char*)internal->endptr - arrayp)/internal->itemsize;
array->type= itemprop->rawtype;
}
else
memset(array, 0, sizeof(RawArray));
RNA_property_collection_end(&iter);
return 1;
}
#define RAW_GET(dtype, var, raw, a) \
{ \
switch(raw.type) { \
case PROP_RAW_CHAR: var = (dtype)((char*)raw.array)[a]; break; \
case PROP_RAW_SHORT: var = (dtype)((short*)raw.array)[a]; break; \
case PROP_RAW_INT: var = (dtype)((int*)raw.array)[a]; break; \
case PROP_RAW_FLOAT: var = (dtype)((float*)raw.array)[a]; break; \
case PROP_RAW_DOUBLE: var = (dtype)((double*)raw.array)[a]; break; \
default: var = (dtype)0; \
} \
}
#define RAW_SET(dtype, raw, a, var) \
{ \
switch(raw.type) { \
case PROP_RAW_CHAR: ((char*)raw.array)[a] = (char)var; break; \
case PROP_RAW_SHORT: ((short*)raw.array)[a] = (short)var; break; \
case PROP_RAW_INT: ((int*)raw.array)[a] = (int)var; break; \
case PROP_RAW_FLOAT: ((float*)raw.array)[a] = (float)var; break; \
case PROP_RAW_DOUBLE: ((double*)raw.array)[a] = (double)var; break; \
} \
}
static int rna_raw_access(ReportList *reports, PointerRNA *ptr, PropertyRNA *prop, char *propname, void *inarray, RawPropertyType intype, int inlen, int set)
{
StructRNA *ptype;
PointerRNA itemptr;
PropertyRNA *itemprop, *iprop;
PropertyType itemtype;
RawArray in;
int itemlen= 0;
/* initialize in array, stride assumed 0 in following code */
in.array= inarray;
in.type= intype;
in.len= inlen;
in.stride= 0;
ptype= RNA_property_pointer_type(ptr, prop);
/* try to get item property pointer */
RNA_pointer_create(NULL, ptype, NULL, &itemptr);
itemprop= RNA_struct_find_property(&itemptr, propname);
if(itemprop) {
/* we have item property pointer */
RawArray out;
/* check type */
itemtype= RNA_property_type(itemprop);
if(!ELEM3(itemtype, PROP_BOOLEAN, PROP_INT, PROP_FLOAT)) {
BKE_report(reports, RPT_ERROR, "Only boolean, int and float properties supported.");
return 0;
}
/* check item array */
itemlen= RNA_property_array_length(itemprop);
/* try to access as raw array */
if(RNA_property_collection_raw_array(ptr, prop, itemprop, &out)) {
if(in.len != itemlen*out.len) {
BKE_reportf(reports, RPT_ERROR, "Array length mismatch (expected %d, got %d).", out.len*itemlen, in.len);
return 0;
}
/* matching raw types */
if(out.type == in.type) {
void *inp= in.array;
void *outp= out.array;
int a, size;
itemlen= (itemlen == 0)? 1: itemlen;
switch(out.type) {
case PROP_RAW_CHAR: size= sizeof(char)*itemlen; break;
case PROP_RAW_SHORT: size= sizeof(short)*itemlen; break;
case PROP_RAW_INT: size= sizeof(int)*itemlen; break;
case PROP_RAW_FLOAT: size= sizeof(float)*itemlen; break;
case PROP_RAW_DOUBLE: size= sizeof(double)*itemlen; break;
}
for(a=0; a<out.len; a++) {
if(set) memcpy(outp, inp, size);
else memcpy(inp, outp, size);
inp= (char*)inp + size;
outp= (char*)outp + out.stride;
}
return 1;
}
/* could also be faster with non-matching types,
* for now we just do slower loop .. */
}
}
{
void *tmparray= NULL;
int tmplen= 0;
int err= 0, j, a= 0;
/* no item property pointer, can still be id property, or
* property of a type derived from the collection pointer type */
RNA_PROP_BEGIN(ptr, itemptr, prop) {
if(itemptr.data) {
if(itemprop) {
/* we got the property already */
iprop= itemprop;
}
else {
/* not yet, look it up and verify if it is valid */
iprop= RNA_struct_find_property(&itemptr, propname);
if(iprop) {
itemlen= RNA_property_array_length(iprop);
itemtype= RNA_property_type(iprop);
}
else {
BKE_reportf(reports, RPT_ERROR, "Property named %s not found.", propname);
err= 1;
break;
}
if(!ELEM3(itemtype, PROP_BOOLEAN, PROP_INT, PROP_FLOAT)) {
BKE_report(reports, RPT_ERROR, "Only boolean, int and float properties supported.");
err= 1;
break;
}
}
/* editable check */
if(RNA_property_editable(&itemptr, iprop)) {
if(a+itemlen > in.len) {
BKE_reportf(reports, RPT_ERROR, "Array length mismatch (got %d, expected more).", in.len);
err= 1;
break;
}
if(itemlen == 0) {
/* handle conversions */
if(set) {
switch(itemtype) {
case PROP_BOOLEAN: {
int b;
RAW_GET(int, b, in, a);
RNA_property_boolean_set(&itemptr, iprop, b);
break;
}
case PROP_INT: {
int i;
RAW_GET(int, i, in, a);
RNA_property_int_set(&itemptr, iprop, i);
break;
}
case PROP_FLOAT: {
float f;
RAW_GET(float, f, in, a);
RNA_property_float_set(&itemptr, iprop, f);
break;
}
default:
break;
}
}
else {
switch(itemtype) {
case PROP_BOOLEAN: {
int b= RNA_property_boolean_get(&itemptr, iprop);
RAW_SET(int, in, a, b);
break;
}
case PROP_INT: {
int i= RNA_property_int_get(&itemptr, iprop);
RAW_SET(int, in, a, i);
break;
}
case PROP_FLOAT: {
float f= RNA_property_float_get(&itemptr, iprop);
RAW_SET(float, in, a, f);
break;
}
default:
break;
}
}
a++;
}
else {
/* allocate temporary array if needed */
if(tmparray && tmplen != itemlen) {
MEM_freeN(tmparray);
tmparray= NULL;
}
if(!tmparray) {
tmparray= MEM_callocN(sizeof(float)*itemlen, "RNA tmparray\n");
tmplen= itemlen;
}
/* handle conversions */
if(set) {
switch(itemtype) {
case PROP_BOOLEAN: {
for(j=0; j<itemlen; j++, a++)
RAW_GET(int, ((int*)tmparray)[j], in, a);
RNA_property_boolean_set_array(&itemptr, iprop, tmparray);
break;
}
case PROP_INT: {
for(j=0; j<itemlen; j++, a++)
RAW_GET(int, ((int*)tmparray)[j], in, a);
RNA_property_int_set_array(&itemptr, iprop, tmparray);
break;
}
case PROP_FLOAT: {
for(j=0; j<itemlen; j++, a++)
RAW_GET(float, ((float*)tmparray)[j], in, a);
RNA_property_float_set_array(&itemptr, iprop, tmparray);
break;
}
default:
break;
}
}
else {
switch(itemtype) {
case PROP_BOOLEAN: {
RNA_property_boolean_get_array(&itemptr, iprop, tmparray);
for(j=0; j<itemlen; j++, a++)
RAW_SET(int, in, a, ((int*)tmparray)[j]);
break;
}
case PROP_INT: {
RNA_property_int_get_array(&itemptr, iprop, tmparray);
for(j=0; j<itemlen; j++, a++)
RAW_SET(int, in, a, ((int*)tmparray)[j]);
break;
}
case PROP_FLOAT: {
RNA_property_float_get_array(&itemptr, iprop, tmparray);
for(j=0; j<itemlen; j++, a++)
RAW_SET(float, in, a, ((float*)tmparray)[j]);
break;
}
default:
break;
}
}
}
}
}
}
RNA_PROP_END;
if(tmparray)
MEM_freeN(tmparray);
return !err;
}
}
int RNA_property_collection_raw_get(ReportList *reports, PointerRNA *ptr, PropertyRNA *prop, char *propname, void *array, RawPropertyType type, int len)
{
return rna_raw_access(reports, ptr, prop, propname, array, type, len, 0);
}
int RNA_property_collection_raw_set(ReportList *reports, PointerRNA *ptr, PropertyRNA *prop, char *propname, void *array, RawPropertyType type, int len)
{
return rna_raw_access(reports, ptr, prop, propname, array, type, len, 1);
}
/* Standard iterator functions */
void rna_iterator_listbase_begin(CollectionPropertyIterator *iter, ListBase *lb, IteratorSkipFunc skip)

View File

@ -112,7 +112,7 @@ StructDefRNA *rna_find_struct_def(StructRNA *srna)
return NULL;
}
PropertyDefRNA *rna_find_struct_property_def(PropertyRNA *prop)
PropertyDefRNA *rna_find_struct_property_def(StructRNA *srna, PropertyRNA *prop)
{
StructDefRNA *dsrna;
PropertyDefRNA *dprop;
@ -123,7 +123,7 @@ PropertyDefRNA *rna_find_struct_property_def(PropertyRNA *prop)
return NULL;
}
dsrna= rna_find_struct_def(DefRNA.laststruct);
dsrna= rna_find_struct_def(srna);
dprop= dsrna->cont.properties.last;
for (; dprop; dprop= dprop->prev)
if (dprop->prop==prop)
@ -150,7 +150,7 @@ PropertyDefRNA *rna_find_property_def(PropertyRNA *prop)
return NULL;
}
dprop= rna_find_struct_property_def(prop);
dprop= rna_find_struct_property_def(DefRNA.laststruct, prop);
if (dprop)
return dprop;
@ -1311,7 +1311,7 @@ static PropertyDefRNA *rna_def_property_sdna(PropertyRNA *prop, const char *stru
StructDefRNA *ds;
PropertyDefRNA *dp;
dp= rna_find_struct_property_def(prop);
dp= rna_find_struct_property_def(DefRNA.laststruct, prop);
if (dp==NULL) return NULL;
ds= rna_find_struct_def((StructRNA*)dp->cont);
@ -1371,7 +1371,7 @@ void RNA_def_property_boolean_negative_sdna(PropertyRNA *prop, const char *struc
RNA_def_property_boolean_sdna(prop, structname, propname, booleanbit);
dp= rna_find_struct_property_def(prop);
dp= rna_find_struct_property_def(DefRNA.laststruct, prop);
if(dp)
dp->booleannegative= 1;
@ -1468,7 +1468,7 @@ void RNA_def_property_enum_bitflag_sdna(PropertyRNA *prop, const char *structnam
RNA_def_property_enum_sdna(prop, structname, propname);
dp= rna_find_struct_property_def(prop);
dp= rna_find_struct_property_def(DefRNA.laststruct, prop);
if(dp)
dp->enumbitflags= 1;

View File

@ -255,6 +255,7 @@ void rna_freelistN(struct ListBase *listbase);
StructDefRNA *rna_find_struct_def(StructRNA *srna);
FunctionDefRNA *rna_find_function_def(FunctionRNA *func);
PropertyDefRNA *rna_find_parameter_def(PropertyRNA *parm);
PropertyDefRNA *rna_find_struct_property_def(StructRNA *srna, PropertyRNA *prop);
/* Pointer Handling */

View File

@ -146,6 +146,10 @@ struct PropertyRNA {
/* callback for testing if editable/evaluated */
EditableFunc editable;
/* raw access */
int rawoffset;
RawPropertyType rawtype;
};
/* Property Types */

View File

@ -309,14 +309,16 @@ PointerRNA rna_builtin_properties_lookup_string(PointerRNA *ptr, const char *key
}
} while((srna=srna->base));
group= RNA_struct_idproperties(ptr, 0);
if(ptr->data) {
group= RNA_struct_idproperties(ptr, 0);
if(group) {
for(idp=group->data.group.first; idp; idp=idp->next) {
if(strcmp(idp->name, key) == 0) {
propptr.type= &RNA_Property;
propptr.data= idp;
return propptr;
if(group) {
for(idp=group->data.group.first; idp; idp=idp->next) {
if(strcmp(idp->name, key) == 0) {
propptr.type= &RNA_Property;
propptr.data= idp;
return propptr;
}
}
}
}