RNA: C API

* RNA_blender.h is now generated along with the other files. It is not
  used anywhere yet, and still located quite hidden next to the other
  rna_*_gen.c files. Read only access for now.
* Inherited properties are not copied from the base anymore but
  iterated over. Patch by Vekoon, thanks!
* Array get/set callbacks now do the whole array instead of getting an
  index. This is needed for some layers for example so python can set
  the array as a whole, otherwise the check that one layer has to be
  enabled at all times gets in the way. Also nicer for the C API.
* Also some changes to returning pointers to make the API cleaner, got
  rid of the type() callback and instead let get() return PointerRNA
  with the type included.

The C API looks like this currently:
http://users.pandora.be/blendix/RNA_blender.h
This commit is contained in:
Brecht Van Lommel 2009-02-02 19:57:57 +00:00
parent eb00687cde
commit 284db61572
39 changed files with 1277 additions and 761 deletions

View File

@ -200,19 +200,19 @@ static short animsys_write_rna_setting (PointerRNA *ptr, char *path, int array_i
{
case PROP_BOOLEAN:
if (RNA_property_array_length(&new_ptr, prop))
RNA_property_boolean_set_array(&new_ptr, prop, array_index, (int)value);
RNA_property_boolean_set_index(&new_ptr, prop, array_index, (int)value);
else
RNA_property_boolean_set(&new_ptr, prop, (int)value);
break;
case PROP_INT:
if (RNA_property_array_length(&new_ptr, prop))
RNA_property_int_set_array(&new_ptr, prop, array_index, (int)value);
RNA_property_int_set_index(&new_ptr, prop, array_index, (int)value);
else
RNA_property_int_set(&new_ptr, prop, (int)value);
break;
case PROP_FLOAT:
if (RNA_property_array_length(&new_ptr, prop))
RNA_property_float_set_array(&new_ptr, prop, array_index, value);
RNA_property_float_set_index(&new_ptr, prop, array_index, value);
else
RNA_property_float_set(&new_ptr, prop, value);
break;

View File

@ -500,19 +500,19 @@ static float driver_get_driver_value (ChannelDriver *driver, short target)
switch (RNA_property_type(&ptr, prop)) {
case PROP_BOOLEAN:
if (RNA_property_array_length(&ptr, prop))
value= (float)RNA_property_boolean_get_array(&ptr, prop, index);
value= (float)RNA_property_boolean_get_index(&ptr, prop, index);
else
value= (float)RNA_property_boolean_get(&ptr, prop);
break;
case PROP_INT:
if (RNA_property_array_length(&ptr, prop))
value= (float)RNA_property_int_get_array(&ptr, prop, index);
value= (float)RNA_property_int_get_index(&ptr, prop, index);
else
value= (float)RNA_property_int_get(&ptr, prop);
break;
case PROP_FLOAT:
if (RNA_property_array_length(&ptr, prop))
value= RNA_property_float_get_array(&ptr, prop, index);
value= RNA_property_float_get_index(&ptr, prop, index);
else
value= RNA_property_float_get(&ptr, prop);
break;

View File

@ -485,19 +485,19 @@ static float setting_get_rna_value (PointerRNA *ptr, PropertyRNA *prop, int inde
switch (RNA_property_type(ptr, prop)) {
case PROP_BOOLEAN:
if (RNA_property_array_length(ptr, prop))
value= (float)RNA_property_boolean_get_array(ptr, prop, index);
value= (float)RNA_property_boolean_get_index(ptr, prop, index);
else
value= (float)RNA_property_boolean_get(ptr, prop);
break;
case PROP_INT:
if (RNA_property_array_length(ptr, prop))
value= (float)RNA_property_int_get_array(ptr, prop, index);
value= (float)RNA_property_int_get_index(ptr, prop, index);
else
value= (float)RNA_property_int_get(ptr, prop);
break;
case PROP_FLOAT:
if (RNA_property_array_length(ptr, prop))
value= RNA_property_float_get_array(ptr, prop, index);
value= RNA_property_float_get_index(ptr, prop, index);
else
value= RNA_property_float_get(ptr, prop);
break;

View File

@ -1144,7 +1144,7 @@ void ui_get_but_vectorf(uiBut *but, float *vec)
tot= MIN2(tot, 3);
for(a=0; a<tot; a++)
vec[a]= RNA_property_float_get_array(&but->rnapoin, prop, a);
vec[a]= RNA_property_float_get_index(&but->rnapoin, prop, a);
}
}
else if(but->pointype == CHA) {
@ -1178,7 +1178,7 @@ void ui_set_but_vectorf(uiBut *but, float *vec)
tot= MIN2(tot, 3);
for(a=0; a<tot; a++)
RNA_property_float_set_array(&but->rnapoin, prop, a, vec[a]);
RNA_property_float_set_index(&but->rnapoin, prop, a, vec[a]);
}
}
else if(but->pointype == CHA) {
@ -1218,19 +1218,19 @@ double ui_get_but_val(uiBut *but)
switch(RNA_property_type(&but->rnapoin, prop)) {
case PROP_BOOLEAN:
if(RNA_property_array_length(&but->rnapoin, prop))
value= RNA_property_boolean_get_array(&but->rnapoin, prop, but->rnaindex);
value= RNA_property_boolean_get_index(&but->rnapoin, prop, but->rnaindex);
else
value= RNA_property_boolean_get(&but->rnapoin, prop);
break;
case PROP_INT:
if(RNA_property_array_length(&but->rnapoin, prop))
value= RNA_property_int_get_array(&but->rnapoin, prop, but->rnaindex);
value= RNA_property_int_get_index(&but->rnapoin, prop, but->rnaindex);
else
value= RNA_property_int_get(&but->rnapoin, prop);
break;
case PROP_FLOAT:
if(RNA_property_array_length(&but->rnapoin, prop))
value= RNA_property_float_get_array(&but->rnapoin, prop, but->rnaindex);
value= RNA_property_float_get_index(&but->rnapoin, prop, but->rnaindex);
else
value= RNA_property_float_get(&but->rnapoin, prop);
break;
@ -1282,19 +1282,19 @@ void ui_set_but_val(uiBut *but, double value)
switch(RNA_property_type(&but->rnapoin, prop)) {
case PROP_BOOLEAN:
if(RNA_property_array_length(&but->rnapoin, prop))
RNA_property_boolean_set_array(&but->rnapoin, prop, but->rnaindex, value);
RNA_property_boolean_set_index(&but->rnapoin, prop, but->rnaindex, value);
else
RNA_property_boolean_set(&but->rnapoin, prop, value);
break;
case PROP_INT:
if(RNA_property_array_length(&but->rnapoin, prop))
RNA_property_int_set_array(&but->rnapoin, prop, but->rnaindex, value);
RNA_property_int_set_index(&but->rnapoin, prop, but->rnaindex, value);
else
RNA_property_int_set(&but->rnapoin, prop, value);
break;
case PROP_FLOAT:
if(RNA_property_array_length(&but->rnapoin, prop))
RNA_property_float_set_array(&but->rnapoin, prop, but->rnaindex, value);
RNA_property_float_set_index(&but->rnapoin, prop, but->rnaindex, value);
else
RNA_property_float_set(&but->rnapoin, prop, value);
break;

View File

@ -1080,7 +1080,7 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
te->rnaptr= *ptr;
if(proptype == PROP_POINTER) {
RNA_property_pointer_get(ptr, prop, &pptr);
pptr= RNA_property_pointer_get(ptr, prop);
if(pptr.data) {
if(!(tselem->flag & TSE_CLOSED))
@ -4105,7 +4105,7 @@ static uiBut *outliner_draw_rnabut(uiBlock *block, PointerRNA *ptr, PropertyRNA
length= RNA_property_array_length(ptr, prop);
if(length)
value= RNA_property_boolean_get_array(ptr, prop, index);
value= RNA_property_boolean_get_index(ptr, prop, index);
else
value= RNA_property_boolean_get(ptr, prop);
@ -4133,7 +4133,7 @@ static uiBut *outliner_draw_rnabut(uiBlock *block, PointerRNA *ptr, PropertyRNA
char *text, *descr, textbuf[256];
int icon;
RNA_property_pointer_get(ptr, prop, &pptr);
pptr= RNA_property_pointer_get(ptr, prop);
if(!pptr.data)
return NULL;

View File

@ -341,18 +341,24 @@ void RNA_property_update(struct bContext *C, PointerRNA *ptr, PropertyRNA *prop)
int RNA_property_boolean_get(PointerRNA *ptr, PropertyRNA *prop);
void RNA_property_boolean_set(PointerRNA *ptr, PropertyRNA *prop, int value);
int RNA_property_boolean_get_array(PointerRNA *ptr, PropertyRNA *prop, int index);
void RNA_property_boolean_set_array(PointerRNA *ptr, PropertyRNA *prop, int index, int value);
void RNA_property_boolean_get_array(PointerRNA *ptr, PropertyRNA *prop, int *values);
int RNA_property_boolean_get_index(PointerRNA *ptr, PropertyRNA *prop, int index);
void RNA_property_boolean_set_array(PointerRNA *ptr, PropertyRNA *prop, const int *values);
void RNA_property_boolean_set_index(PointerRNA *ptr, PropertyRNA *prop, int index, int value);
int RNA_property_int_get(PointerRNA *ptr, PropertyRNA *prop);
void RNA_property_int_set(PointerRNA *ptr, PropertyRNA *prop, int value);
int RNA_property_int_get_array(PointerRNA *ptr, PropertyRNA *prop, int index);
void RNA_property_int_set_array(PointerRNA *ptr, PropertyRNA *prop, int index, int value);
void RNA_property_int_get_array(PointerRNA *ptr, PropertyRNA *prop, int *values);
int RNA_property_int_get_index(PointerRNA *ptr, PropertyRNA *prop, int index);
void RNA_property_int_set_array(PointerRNA *ptr, PropertyRNA *prop, const int *values);
void RNA_property_int_set_index(PointerRNA *ptr, PropertyRNA *prop, int index, int value);
float RNA_property_float_get(PointerRNA *ptr, PropertyRNA *prop);
void RNA_property_float_set(PointerRNA *ptr, PropertyRNA *prop, float value);
float RNA_property_float_get_array(PointerRNA *ptr, PropertyRNA *prop, int index);
void RNA_property_float_set_array(PointerRNA *ptr, PropertyRNA *prop, int index, float value);
void RNA_property_float_get_array(PointerRNA *ptr, PropertyRNA *prop, float *values);
float RNA_property_float_get_index(PointerRNA *ptr, PropertyRNA *prop, int index);
void RNA_property_float_set_array(PointerRNA *ptr, PropertyRNA *prop, const float *values);
void RNA_property_float_set_index(PointerRNA *ptr, PropertyRNA *prop, int index, float value);
void RNA_property_string_get(PointerRNA *ptr, PropertyRNA *prop, char *value);
char *RNA_property_string_get_alloc(PointerRNA *ptr, PropertyRNA *prop, char *fixedbuf, int fixedlen);
@ -362,8 +368,8 @@ void RNA_property_string_set(PointerRNA *ptr, PropertyRNA *prop, const char *val
int RNA_property_enum_get(PointerRNA *ptr, PropertyRNA *prop);
void RNA_property_enum_set(PointerRNA *ptr, PropertyRNA *prop, int value);
void RNA_property_pointer_get(PointerRNA *ptr, PropertyRNA *prop, PointerRNA *r_ptr);
void RNA_property_pointer_set(PointerRNA *ptr, PropertyRNA *prop, PointerRNA *ptr_value);
PointerRNA RNA_property_pointer_get(PointerRNA *ptr, PropertyRNA *prop);
void RNA_property_pointer_set(PointerRNA *ptr, PropertyRNA *prop, PointerRNA ptr_value);
void RNA_property_collection_begin(PointerRNA *ptr, PropertyRNA *prop, CollectionPropertyIterator *iter);
void RNA_property_collection_next(CollectionPropertyIterator *iter);
@ -440,7 +446,7 @@ char *RNA_string_get_alloc(PointerRNA *ptr, const char *name, char *fixedbuf, in
int RNA_string_length(PointerRNA *ptr, const char *name);
void RNA_string_set(PointerRNA *ptr, const char *name, const char *value);
void RNA_pointer_get(PointerRNA *ptr, const char *name, PointerRNA *r_value);
PointerRNA RNA_pointer_get(PointerRNA *ptr, const char *name);
void RNA_pointer_add(PointerRNA *ptr, const char *name);
void RNA_collection_begin(PointerRNA *ptr, const char *name, CollectionPropertyIterator *iter);

View File

@ -137,8 +137,8 @@ void RNA_def_property_int_funcs(PropertyRNA *prop, const char *get, const char *
void RNA_def_property_float_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range);
void RNA_def_property_enum_funcs(PropertyRNA *prop, const char *get, const char *set);
void RNA_def_property_string_funcs(PropertyRNA *prop, const char *get, const char *length, const char *set);
void RNA_def_property_pointer_funcs(PropertyRNA *prop, const char *get, const char *type, const char *set);
void RNA_def_property_collection_funcs(PropertyRNA *prop, const char *begin, const char *next, const char *end, const char *get, const char *type, const char *length, const char *lookupint, const char *lookupstring);
void RNA_def_property_pointer_funcs(PropertyRNA *prop, const char *get, const char *set);
void RNA_def_property_collection_funcs(PropertyRNA *prop, const char *begin, const char *next, const char *end, const char *get, const char *length, const char *lookupint, const char *lookupstring);
#endif /* RNA_DEFINE_H */

View File

@ -105,15 +105,20 @@ typedef enum PropertyFlag {
} PropertyFlag;
typedef struct CollectionPropertyIterator {
/* internal */
PointerRNA parent;
struct PropertyRNA *prop;
void *internal;
int idprop;
int level;
/* external */
int valid;
PointerRNA ptr;
} CollectionPropertyIterator;
/* Iterator Utility */
typedef struct EnumPropertyItem {
int value;
const char *identifier;

File diff suppressed because it is too large Load Diff

View File

@ -581,30 +581,38 @@ void RNA_property_boolean_set(PointerRNA *ptr, PropertyRNA *prop, int value)
}
}
int RNA_property_boolean_get_array(PointerRNA *ptr, PropertyRNA *prop, int index)
void RNA_property_boolean_get_array(PointerRNA *ptr, PropertyRNA *prop, int *values)
{
BooleanPropertyRNA *bprop= (BooleanPropertyRNA*)prop;
IDProperty *idprop;
if((idprop=rna_idproperty_check(&prop, ptr)))
return ((int*)IDP_Array(idprop))[index];
memcpy(values, IDP_Array(idprop), sizeof(int)*idprop->len);
else if(bprop->getarray)
return bprop->getarray(ptr, index);
bprop->getarray(ptr, values);
else if(bprop->defaultarray)
return bprop->defaultarray[index];
memcpy(values, bprop->defaultarray, sizeof(int)*prop->arraylength);
else
return 0;
memset(values, 0, sizeof(int)*prop->arraylength);
}
void RNA_property_boolean_set_array(PointerRNA *ptr, PropertyRNA *prop, int index, int value)
int RNA_property_boolean_get_index(PointerRNA *ptr, PropertyRNA *prop, int index)
{
int tmp[RNA_MAX_ARRAY];
RNA_property_boolean_get_array(ptr, prop, tmp);
return tmp[index];
}
void RNA_property_boolean_set_array(PointerRNA *ptr, PropertyRNA *prop, const int *values)
{
BooleanPropertyRNA *bprop= (BooleanPropertyRNA*)prop;
IDProperty *idprop;
if((idprop=rna_idproperty_check(&prop, ptr)))
((int*)IDP_Array(idprop))[index]= value;
memcpy(IDP_Array(idprop), values, sizeof(int)*idprop->len);
else if(bprop->setarray)
bprop->setarray(ptr, index, value);
bprop->setarray(ptr, values);
else if(!(prop->flag & PROP_NOT_EDITABLE)) {
IDPropertyTemplate val;
IDProperty *group;
@ -616,15 +624,20 @@ void RNA_property_boolean_set_array(PointerRNA *ptr, PropertyRNA *prop, int inde
if(group) {
idprop= IDP_New(IDP_ARRAY, val, (char*)prop->identifier);
IDP_AddToGroup(group, idprop);
if(bprop->defaultarray)
memcpy(idprop->data.pointer, bprop->defaultarray, sizeof(int)*prop->arraylength);
else
memset(idprop->data.pointer, 0, sizeof(int)*prop->arraylength);
((int*)idprop->data.pointer)[index]= value;
memcpy(IDP_Array(idprop), values, sizeof(int)*idprop->len);
}
}
}
void RNA_property_boolean_set_index(PointerRNA *ptr, PropertyRNA *prop, int index, int value)
{
int tmp[RNA_MAX_ARRAY];
RNA_property_boolean_get_array(ptr, prop, tmp);
tmp[index]= value;
RNA_property_boolean_set_array(ptr, prop, tmp);
}
int RNA_property_int_get(PointerRNA *ptr, PropertyRNA *prop)
{
IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
@ -659,30 +672,38 @@ void RNA_property_int_set(PointerRNA *ptr, PropertyRNA *prop, int value)
}
}
int RNA_property_int_get_array(PointerRNA *ptr, PropertyRNA *prop, int index)
void RNA_property_int_get_array(PointerRNA *ptr, PropertyRNA *prop, int *values)
{
IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
IDProperty *idprop;
if((idprop=rna_idproperty_check(&prop, ptr)))
return ((int*)IDP_Array(idprop))[index];
memcpy(values, IDP_Array(idprop), sizeof(int)*idprop->len);
else if(iprop->getarray)
return iprop->getarray(ptr, index);
iprop->getarray(ptr, values);
else if(iprop->defaultarray)
return iprop->defaultarray[index];
memcpy(values, iprop->defaultarray, sizeof(int)*prop->arraylength);
else
return 0.0f;
memset(values, 0, sizeof(int)*prop->arraylength);
}
void RNA_property_int_set_array(PointerRNA *ptr, PropertyRNA *prop, int index, int value)
int RNA_property_int_get_index(PointerRNA *ptr, PropertyRNA *prop, int index)
{
int tmp[RNA_MAX_ARRAY];
RNA_property_int_get_array(ptr, prop, tmp);
return tmp[index];
}
void RNA_property_int_set_array(PointerRNA *ptr, PropertyRNA *prop, const int *values)
{
IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
IDProperty *idprop;
if((idprop=rna_idproperty_check(&prop, ptr)))
((int*)IDP_Array(idprop))[index]= value;
memcpy(IDP_Array(idprop), values, sizeof(int)*idprop->len);
else if(iprop->setarray)
iprop->setarray(ptr, index, value);
iprop->setarray(ptr, values);
else if(!(prop->flag & PROP_NOT_EDITABLE)) {
IDPropertyTemplate val;
IDProperty *group;
@ -694,15 +715,20 @@ void RNA_property_int_set_array(PointerRNA *ptr, PropertyRNA *prop, int index, i
if(group) {
idprop= IDP_New(IDP_ARRAY, val, (char*)prop->identifier);
IDP_AddToGroup(group, idprop);
if(iprop->defaultarray)
memcpy(idprop->data.pointer, iprop->defaultarray, sizeof(int)*prop->arraylength);
else
memset(idprop->data.pointer, 0, sizeof(int)*prop->arraylength);
((int*)idprop->data.pointer)[index]= value;
memcpy(IDP_Array(idprop), values, sizeof(int)*idprop->len);
}
}
}
void RNA_property_int_set_index(PointerRNA *ptr, PropertyRNA *prop, int index, int value)
{
int tmp[RNA_MAX_ARRAY];
RNA_property_int_get_array(ptr, prop, tmp);
tmp[index]= value;
RNA_property_int_set_array(ptr, prop, tmp);
}
float RNA_property_float_get(PointerRNA *ptr, PropertyRNA *prop)
{
FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop;
@ -746,38 +772,55 @@ void RNA_property_float_set(PointerRNA *ptr, PropertyRNA *prop, float value)
}
}
float RNA_property_float_get_array(PointerRNA *ptr, PropertyRNA *prop, int index)
void RNA_property_float_get_array(PointerRNA *ptr, PropertyRNA *prop, float *values)
{
FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop;
IDProperty *idprop;
int i;
if((idprop=rna_idproperty_check(&prop, ptr))) {
if(idprop->subtype == IDP_FLOAT)
return ((float*)IDP_Array(idprop))[index];
else
return (float)(((double*)IDP_Array(idprop))[index]);
if(idprop->subtype == IDP_FLOAT) {
memcpy(values, IDP_Array(idprop), sizeof(float)*idprop->len);
}
else {
for(i=0; i<idprop->len; i++)
values[i]= (float)(((double*)IDP_Array(idprop))[i]);
}
}
else if(fprop->getarray)
return fprop->getarray(ptr, index);
fprop->getarray(ptr, values);
else if(fprop->defaultarray)
return fprop->defaultarray[index];
memcpy(values, fprop->defaultarray, sizeof(float)*prop->arraylength);
else
return 0.0f;
memset(values, 0, sizeof(float)*prop->arraylength);
}
void RNA_property_float_set_array(PointerRNA *ptr, PropertyRNA *prop, int index, float value)
float RNA_property_float_get_index(PointerRNA *ptr, PropertyRNA *prop, int index)
{
float tmp[RNA_MAX_ARRAY];
RNA_property_float_get_array(ptr, prop, tmp);
return tmp[index];
}
void RNA_property_float_set_array(PointerRNA *ptr, PropertyRNA *prop, const float *values)
{
FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop;
IDProperty *idprop;
int i;
if((idprop=rna_idproperty_check(&prop, ptr))) {
if(idprop->subtype == IDP_FLOAT)
((float*)IDP_Array(idprop))[index]= value;
else
((double*)IDP_Array(idprop))[index]= value;
if(idprop->subtype == IDP_FLOAT) {
memcpy(IDP_Array(idprop), values, sizeof(float)*idprop->len);
}
else {
for(i=0; i<idprop->len; i++)
((double*)IDP_Array(idprop))[i]= values[i];
}
}
else if(fprop->setarray) {
fprop->setarray(ptr, index, value);
fprop->setarray(ptr, values);
}
else if(!(prop->flag & PROP_NOT_EDITABLE)) {
IDPropertyTemplate val;
@ -790,15 +833,20 @@ void RNA_property_float_set_array(PointerRNA *ptr, PropertyRNA *prop, int index,
if(group) {
idprop= IDP_New(IDP_ARRAY, val, (char*)prop->identifier);
IDP_AddToGroup(group, idprop);
if(fprop->defaultarray)
memcpy(idprop->data.pointer, fprop->defaultarray, sizeof(float)*prop->arraylength);
else
memset(idprop->data.pointer, 0, sizeof(float)*prop->arraylength);
((float*)IDP_Array(idprop))[index]= value;
memcpy(IDP_Array(idprop), values, sizeof(float)*idprop->len);
}
}
}
void RNA_property_float_set_index(PointerRNA *ptr, PropertyRNA *prop, int index, float value)
{
float tmp[RNA_MAX_ARRAY];
RNA_property_float_get_array(ptr, prop, tmp);
tmp[index]= value;
RNA_property_float_set_array(ptr, prop, tmp);
}
void RNA_property_string_get(PointerRNA *ptr, PropertyRNA *prop, char *value)
{
StringPropertyRNA *sprop= (StringPropertyRNA*)prop;
@ -899,49 +947,33 @@ void RNA_property_enum_set(PointerRNA *ptr, PropertyRNA *prop, int value)
}
}
static StructRNA *rna_property_pointer_type(PointerRNA *ptr, PropertyRNA *prop, PointerRNA *r_ptr)
{
PointerPropertyRNA *pprop= (PointerPropertyRNA*)prop;
StructRNA *type;
if(pprop->type)
type= pprop->type(ptr);
else
type= pprop->structtype;
if(type) {
rna_pointer_inherit_id(type, ptr, r_ptr);
if(type->refine)
type= type->refine(r_ptr);
}
r_ptr->type= type;
return type;
}
void RNA_property_pointer_get(PointerRNA *ptr, PropertyRNA *prop, PointerRNA *r_ptr)
PointerRNA RNA_property_pointer_get(PointerRNA *ptr, PropertyRNA *prop)
{
PointerPropertyRNA *pprop= (PointerPropertyRNA*)prop;
IDProperty *idprop;
if((idprop=rna_idproperty_check(&prop, ptr)))
r_ptr->data= idprop; /* for groups, data is idprop itself */
else if(pprop->get)
r_ptr->data= pprop->get(ptr);
else
r_ptr->data= NULL;
if((idprop=rna_idproperty_check(&prop, ptr))) {
pprop= (PointerPropertyRNA*)prop;
if(!(r_ptr->data && rna_property_pointer_type(ptr, prop, r_ptr)))
memset(r_ptr, 0, sizeof(*r_ptr));
/* for groups, data is idprop itself */
return rna_pointer_inherit_refine(ptr, pprop->structtype, idprop);
}
else if(pprop->get) {
return pprop->get(ptr);
}
else {
PointerRNA result;
memset(&result, 0, sizeof(result));
return result;
}
}
void RNA_property_pointer_set(PointerRNA *ptr, PropertyRNA *prop, PointerRNA *ptr_value)
void RNA_property_pointer_set(PointerRNA *ptr, PropertyRNA *prop, PointerRNA ptr_value)
{
PointerPropertyRNA *pprop= (PointerPropertyRNA*)prop;
if(pprop->set)
pprop->set(ptr, ptr_value->data);
pprop->set(ptr, ptr_value);
}
void RNA_property_pointer_add(PointerRNA *ptr, PropertyRNA *prop)
@ -965,37 +997,6 @@ void RNA_property_pointer_add(PointerRNA *ptr, PropertyRNA *prop)
printf("RNA_property_pointer_add %s.%s: only supported for id properties.\n", ptr->type->identifier, prop->identifier);
}
static StructRNA *rna_property_collection_type(CollectionPropertyIterator *iter)
{
CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)iter->prop;
StructRNA *type;
if(cprop->type)
type= cprop->type(iter);
else
type= cprop->structtype;
if(type) {
rna_pointer_inherit_id(type, &iter->parent, &iter->ptr);
if(type->refine)
type= type->refine(&iter->ptr);
}
iter->ptr.type= type;
return type;
}
static void rna_property_collection_get(CollectionPropertyIterator *iter)
{
CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)iter->prop;
iter->ptr.data= cprop->get(iter);
if(!(iter->ptr.data && rna_property_collection_type(iter)))
memset(&iter->ptr, 0, sizeof(iter->ptr));
}
static void rna_property_collection_get_idp(CollectionPropertyIterator *iter)
{
CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)iter->prop;
@ -1009,6 +1010,8 @@ void RNA_property_collection_begin(PointerRNA *ptr, PropertyRNA *prop, Collectio
{
IDProperty *idprop;
memset(iter, 0, sizeof(*iter));
if((idprop=rna_idproperty_check(&prop, ptr)) || (prop->flag & PROP_IDPROPERTY)) {
iter->parent= *ptr;
iter->prop= prop;
@ -1020,27 +1023,12 @@ void RNA_property_collection_begin(PointerRNA *ptr, PropertyRNA *prop, Collectio
if(iter->valid)
rna_property_collection_get_idp(iter);
else
memset(&iter->ptr, 0, sizeof(iter->ptr));
iter->idprop= 1;
}
else {
CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
if(cprop->begin) {
iter->parent= *ptr;
iter->prop= prop;
iter->idprop= 0;
cprop->begin(iter, ptr);
if(iter->valid)
rna_property_collection_get(iter);
else
memset(&iter->ptr, 0, sizeof(iter->ptr));
}
else
memset(iter, 0, sizeof(*iter));
cprop->begin(iter, ptr);
}
}
@ -1053,17 +1041,9 @@ void RNA_property_collection_next(CollectionPropertyIterator *iter)
if(iter->valid)
rna_property_collection_get_idp(iter);
else
memset(&iter->ptr, 0, sizeof(iter->ptr));
}
else {
else
cprop->next(iter);
if(iter->valid)
rna_property_collection_get(iter);
else
memset(&iter->ptr, 0, sizeof(iter->ptr));
}
}
void RNA_property_collection_end(CollectionPropertyIterator *iter)
@ -1072,7 +1052,7 @@ void RNA_property_collection_end(CollectionPropertyIterator *iter)
if(iter->idprop)
rna_iterator_array_end(iter);
else if(cprop->end)
else
cprop->end(iter);
}
@ -1160,19 +1140,8 @@ int RNA_property_collection_lookup_int(PointerRNA *ptr, PropertyRNA *prop, int k
if(cprop->lookupint) {
/* we have a callback defined, use it */
r_ptr->data= cprop->lookupint(ptr, key, &r_ptr->type);
if(r_ptr->data) {
if(!r_ptr->type)
r_ptr->type= cprop->structtype;
rna_pointer_inherit_id(r_ptr->type, ptr, r_ptr);
return 1;
}
else {
memset(r_ptr, 0, sizeof(*r_ptr));
return 0;
}
*r_ptr= cprop->lookupint(ptr, key);
return (r_ptr->data != NULL);
}
else {
/* no callback defined, just iterate and find the nth item */
@ -1201,19 +1170,8 @@ int RNA_property_collection_lookup_string(PointerRNA *ptr, PropertyRNA *prop, co
if(cprop->lookupstring) {
/* we have a callback defined, use it */
r_ptr->data= cprop->lookupstring(ptr, key, &r_ptr->type);
if(r_ptr->data) {
if(!r_ptr->type)
r_ptr->type= cprop->structtype;
rna_pointer_inherit_id(r_ptr->type, ptr, r_ptr);
return 1;
}
else {
memset(r_ptr, 0, sizeof(*r_ptr));
return 0;
}
*r_ptr= cprop->lookupstring(ptr, key);
return (r_ptr->data != NULL);
}
else {
/* no callback defined, compare with name properties if they exist */
@ -1351,6 +1309,26 @@ void rna_iterator_array_end(CollectionPropertyIterator *iter)
MEM_freeN(iter->internal);
}
/* Pointer Handling */
PointerRNA rna_pointer_inherit_refine(PointerRNA *ptr, StructRNA *type, void *data)
{
PointerRNA result;
if(data) {
result.data= data;
result.type= type;
rna_pointer_inherit_id(type, ptr, &result);
if(type->refine)
result.type= type->refine(&result);
}
else
memset(&result, 0, sizeof(result));
return result;
}
/* RNA Path - Experiment */
static char *rna_path_token(const char **path, char *fixedbuf, int fixedlen, int bracket)
@ -1454,7 +1432,7 @@ int RNA_path_resolve(PointerRNA *ptr, const char *path, PointerRNA *r_ptr, Prope
* collection, otherwise return the property rna so that the
* caller can read the value of the property itself */
if(RNA_property_type(&curptr, prop) == PROP_POINTER) {
RNA_property_pointer_get(&curptr, prop, &nextptr);
nextptr= RNA_property_pointer_get(&curptr, prop);
if(nextptr.data)
curptr= nextptr;
@ -1624,13 +1602,9 @@ void RNA_boolean_set(PointerRNA *ptr, const char *name, int value)
void RNA_boolean_get_array(PointerRNA *ptr, const char *name, int *values)
{
PropertyRNA *prop= RNA_struct_find_property(ptr, name);
int i, length;
if(prop) {
length= RNA_property_array_length(ptr, prop);
for(i=0; i<length; i++)
values[i]= RNA_property_boolean_get_array(ptr, prop, i);
}
if(prop)
RNA_property_boolean_get_array(ptr, prop, values);
else
printf("RNA_boolean_get_array: %s.%s not found.\n", ptr->type->identifier, name);
}
@ -1638,13 +1612,9 @@ void RNA_boolean_get_array(PointerRNA *ptr, const char *name, int *values)
void RNA_boolean_set_array(PointerRNA *ptr, const char *name, const int *values)
{
PropertyRNA *prop= RNA_struct_find_property(ptr, name);
int i, length;
if(prop) {
length= RNA_property_array_length(ptr, prop);
for(i=0; i<length; i++)
RNA_property_boolean_set_array(ptr, prop, i, values[i]);
}
if(prop)
RNA_property_boolean_set_array(ptr, prop, values);
else
printf("RNA_boolean_set_array: %s.%s not found.\n", ptr->type->identifier, name);
}
@ -1675,13 +1645,9 @@ void RNA_int_set(PointerRNA *ptr, const char *name, int value)
void RNA_int_get_array(PointerRNA *ptr, const char *name, int *values)
{
PropertyRNA *prop= RNA_struct_find_property(ptr, name);
int i, length;
if(prop) {
length= RNA_property_array_length(ptr, prop);
for(i=0; i<length; i++)
values[i]= RNA_property_int_get_array(ptr, prop, i);
}
if(prop)
RNA_property_int_get_array(ptr, prop, values);
else
printf("RNA_int_get_array: %s.%s not found.\n", ptr->type->identifier, name);
}
@ -1689,13 +1655,9 @@ void RNA_int_get_array(PointerRNA *ptr, const char *name, int *values)
void RNA_int_set_array(PointerRNA *ptr, const char *name, const int *values)
{
PropertyRNA *prop= RNA_struct_find_property(ptr, name);
int i, length;
if(prop) {
length= RNA_property_array_length(ptr, prop);
for(i=0; i<length; i++)
RNA_property_int_set_array(ptr, prop, i, values[i]);
}
if(prop)
RNA_property_int_set_array(ptr, prop, values);
else
printf("RNA_int_set_array: %s.%s not found.\n", ptr->type->identifier, name);
}
@ -1726,13 +1688,9 @@ void RNA_float_set(PointerRNA *ptr, const char *name, float value)
void RNA_float_get_array(PointerRNA *ptr, const char *name, float *values)
{
PropertyRNA *prop= RNA_struct_find_property(ptr, name);
int i, length;
if(prop) {
length= RNA_property_array_length(ptr, prop);
for(i=0; i<length; i++)
values[i]= RNA_property_float_get_array(ptr, prop, i);
}
if(prop)
RNA_property_float_get_array(ptr, prop, values);
else
printf("RNA_float_get_array: %s.%s not found.\n", ptr->type->identifier, name);
}
@ -1740,13 +1698,9 @@ void RNA_float_get_array(PointerRNA *ptr, const char *name, float *values)
void RNA_float_set_array(PointerRNA *ptr, const char *name, const float *values)
{
PropertyRNA *prop= RNA_struct_find_property(ptr, name);
int i, length;
if(prop) {
length= RNA_property_array_length(ptr, prop);
for(i=0; i<length; i++)
RNA_property_float_set_array(ptr, prop, i, values[i]);
}
if(prop)
RNA_property_float_set_array(ptr, prop, values);
else
printf("RNA_float_set_array: %s.%s not found.\n", ptr->type->identifier, name);
}
@ -1842,14 +1796,21 @@ void RNA_string_set(PointerRNA *ptr, const char *name, const char *value)
printf("RNA_string_set: %s.%s not found.\n", ptr->type->identifier, name);
}
void RNA_pointer_get(PointerRNA *ptr, const char *name, PointerRNA *r_value)
PointerRNA RNA_pointer_get(PointerRNA *ptr, const char *name)
{
PropertyRNA *prop= RNA_struct_find_property(ptr, name);
if(prop)
RNA_property_pointer_get(ptr, prop, r_value);
else
if(prop) {
return RNA_property_pointer_get(ptr, prop);
}
else {
PointerRNA result;
printf("RNA_pointer_get: %s.%s not found.\n", ptr->type->identifier, name);
memset(&result, 0, sizeof(result));
return result;
}
}
void RNA_pointer_add(PointerRNA *ptr, const char *name)
@ -1939,7 +1900,7 @@ char *RNA_property_as_string(PointerRNA *ptr, PropertyRNA *prop)
else {
BLI_dynstr_append(dynstr, "(");
for(i=0; i<len; i++) {
BLI_dynstr_appendf(dynstr, i?", %s":"%s", RNA_property_boolean_get_array(ptr, prop, i) ? "True" : "False");
BLI_dynstr_appendf(dynstr, i?", %s":"%s", RNA_property_boolean_get_index(ptr, prop, i) ? "True" : "False");
}
BLI_dynstr_append(dynstr, ")");
}
@ -1951,7 +1912,7 @@ char *RNA_property_as_string(PointerRNA *ptr, PropertyRNA *prop)
else {
BLI_dynstr_append(dynstr, "(");
for(i=0; i<len; i++) {
BLI_dynstr_appendf(dynstr, i?", %d":"%d", RNA_property_int_get_array(ptr, prop, i));
BLI_dynstr_appendf(dynstr, i?", %d":"%d", RNA_property_int_get_index(ptr, prop, i));
}
BLI_dynstr_append(dynstr, ")");
}
@ -1963,7 +1924,7 @@ char *RNA_property_as_string(PointerRNA *ptr, PropertyRNA *prop)
else {
BLI_dynstr_append(dynstr, "(");
for(i=0; i<len; i++) {
BLI_dynstr_appendf(dynstr, i?", %g":"%g", RNA_property_float_get_array(ptr, prop, i));
BLI_dynstr_appendf(dynstr, i?", %g":"%g", RNA_property_float_get_index(ptr, prop, i));
}
BLI_dynstr_append(dynstr, ")");
}

View File

@ -34,29 +34,41 @@
#ifdef RNA_RUNTIME
static void rna_Bone_layer_set(PointerRNA *ptr, int index, int value)
static void rna_Bone_layer_set(PointerRNA *ptr, const int *values)
{
Bone *bone= (Bone*)ptr->data;
int i, tot;
if(value) bone->layer |= (1<<index);
else {
bone->layer &= ~(1<<index);
if(bone->layer == 0)
bone->layer |= (1<<index);
/* ensure we always have some layer selected */
for(i=0; i<20; i++)
if(values[i])
tot++;
if(tot==0)
return;
for(i=0; i<20; i++) {
if(values[i]) bone->layer |= (1<<i);
else bone->layer &= ~(1<<i);
}
}
static void rna_Armature_layer_set(PointerRNA *ptr, int index, int value)
static void rna_Armature_layer_set(PointerRNA *ptr, const int *values)
{
bArmature *arm= (bArmature*)ptr->data;
int i, tot;
if(value) arm->layer |= (1<<index);
else {
arm->layer &= ~(1<<index);
if(arm->layer == 0)
arm->layer |= (1<<index);
/* ensure we always have some layer selected */
for(i=0; i<20; i++)
if(values[i])
tot++;
if(tot==0)
return;
for(i=0; i<20; i++) {
if(values[i]) arm->layer |= (1<<i);
else arm->layer &= ~(1<<i);
}
}

View File

@ -40,10 +40,10 @@ static void rna_Brush_mtex_begin(CollectionPropertyIterator *iter, PointerRNA *p
rna_iterator_array_begin(iter, (void*)brush->mtex, sizeof(MTex*), MAX_MTEX, NULL);
}
static void *rna_Brush_active_texture_get(PointerRNA *ptr)
static PointerRNA rna_Brush_active_texture_get(PointerRNA *ptr)
{
Brush *brush= (Brush*)ptr->data;
return brush->mtex[(int)brush->texact];
return rna_pointer_inherit_refine(ptr, &RNA_TextureSlot, brush->mtex[(int)brush->texact]);
}
static float rna_Brush_rotation_get(PointerRNA *ptr)

View File

@ -111,16 +111,22 @@ static void rna_ClothSettings_bend_vgroup_set(PointerRNA *ptr, const char *value
rna_object_vgroup_name_index_set(ptr, value, &sim->vgroup_bend);
}
static float rna_ClothSettings_gravity_get(PointerRNA *ptr, int index)
static void rna_ClothSettings_gravity_get(PointerRNA *ptr, float *values)
{
ClothSimSettings *sim= (ClothSimSettings*)ptr->data;
return sim->gravity[index];
values[0]= sim->gravity[0];
values[1]= sim->gravity[1];
values[2]= sim->gravity[2];
}
static void rna_ClothSettings_gravity_set(PointerRNA *ptr, int index, float value)
static void rna_ClothSettings_gravity_set(PointerRNA *ptr, const float *values)
{
ClothSimSettings *sim= (ClothSimSettings*)ptr->data;
sim->gravity[index]= value;
sim->gravity[0]= values[0];
sim->gravity[1]= values[1];
sim->gravity[2]= values[2];
}
#else

View File

@ -63,17 +63,21 @@ static void rna_CurveMapping_clip_set(PointerRNA *ptr, int value)
curvemapping_changed(cumap, 0);
}
static void rna_CurveMapping_black_level_set(PointerRNA *ptr, int index, float value)
static void rna_CurveMapping_black_level_set(PointerRNA *ptr, const float *values)
{
CurveMapping *cumap= (CurveMapping*)ptr->data;
cumap->black[index]= value;
cumap->black[0]= values[0];
cumap->black[1]= values[1];
cumap->black[2]= values[2];
curvemapping_set_black_white(cumap, NULL, NULL);
}
static void rna_CurveMapping_white_level_set(PointerRNA *ptr, int index, float value)
static void rna_CurveMapping_white_level_set(PointerRNA *ptr, const float *values)
{
CurveMapping *cumap= (CurveMapping*)ptr->data;
cumap->white[index]= value;
cumap->white[0]= values[0];
cumap->white[1]= values[1];
cumap->white[2]= values[2];
curvemapping_set_black_white(cumap, NULL, NULL);
}
@ -208,7 +212,7 @@ static void rna_def_curvemapping(BlenderRNA *brna)
RNA_def_property_float_funcs(prop, NULL, NULL, "rna_CurveMapping_clipmaxy_range");
prop= RNA_def_property(srna, "curves", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_funcs(prop, "rna_CurveMapping_curves_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", 0, "rna_CurveMapping_curves_length", 0, 0);
RNA_def_property_collection_funcs(prop, "rna_CurveMapping_curves_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_CurveMapping_curves_length", 0, 0);
RNA_def_property_struct_type(prop, "CurveMap");
RNA_def_property_ui_text(prop, "Curves", "");

View File

@ -33,41 +33,58 @@
#ifdef RNA_RUNTIME
static float rna_BezTriple_handle1_get(PointerRNA *ptr, int index)
static void rna_BezTriple_handle1_get(PointerRNA *ptr, float *values)
{
BezTriple *bt= (BezTriple*)ptr->data;
return bt->vec[0][index];
values[0]= bt->vec[0][0];
values[1]= bt->vec[0][1];
values[2]= bt->vec[0][2];
}
static void rna_BezTriple_handle1_set(PointerRNA *ptr, int index, float value)
static void rna_BezTriple_handle1_set(PointerRNA *ptr, const float *values)
{
BezTriple *bt= (BezTriple*)ptr->data;
bt->vec[0][index]= value;
bt->vec[0][0]= values[0];
bt->vec[0][1]= values[1];
bt->vec[0][2]= values[2];
}
static float rna_BezTriple_handle2_get(PointerRNA *ptr, int index)
static void rna_BezTriple_handle2_get(PointerRNA *ptr, float *values)
{
BezTriple *bt= (BezTriple*)ptr->data;
return bt->vec[2][index];
values[0]= bt->vec[2][0];
values[1]= bt->vec[2][1];
values[2]= bt->vec[2][2];
}
static void rna_BezTriple_handle2_set(PointerRNA *ptr, int index, float value)
static void rna_BezTriple_handle2_set(PointerRNA *ptr, const float *values)
{
BezTriple *bt= (BezTriple*)ptr->data;
bt->vec[2][index]= value;
bt->vec[2][0]= values[0];
bt->vec[2][1]= values[1];
bt->vec[2][2]= values[2];
}
static float rna_BezTriple_ctrlpoint_get(PointerRNA *ptr, int index)
static void rna_BezTriple_ctrlpoint_get(PointerRNA *ptr, float *values)
{
BezTriple *bt= (BezTriple*)ptr->data;
return bt->vec[1][index];
values[0]= bt->vec[1][0];
values[1]= bt->vec[1][1];
values[2]= bt->vec[1][2];
}
static void rna_BezTriple_ctrlpoint_set(PointerRNA *ptr, int index, float value)
static void rna_BezTriple_ctrlpoint_set(PointerRNA *ptr, const float *values)
{
BezTriple *bt= (BezTriple*)ptr->data;
bt->vec[1][index]= value;
bt->vec[1][0]= values[0];
bt->vec[1][1]= values[1];
bt->vec[1][2]= values[2];
}
static int rna_Curve_texspace_editable(PointerRNA *ptr)
@ -78,8 +95,7 @@ static int rna_Curve_texspace_editable(PointerRNA *ptr)
#else
void rna_def_bpoint(BlenderRNA *brna)
static void rna_def_bpoint(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
@ -120,7 +136,7 @@ void rna_def_bpoint(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Bevel Radius", "Radius for bevelling");
}
void rna_def_beztriple(BlenderRNA *brna)
static void rna_def_beztriple(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;

View File

@ -316,26 +316,13 @@ static StructDefRNA *rna_find_def_struct(StructRNA *srna)
return NULL;
}
static PropertyDefRNA *rna_find_def_property(StructRNA *srna, PropertyRNA *prop)
{
StructDefRNA *ds= rna_find_def_struct(srna);
PropertyDefRNA *dp;
if(ds)
for(dp=ds->properties.first; dp; dp=dp->next)
if(dp->prop == prop)
return dp;
return NULL;
}
/* Struct Definition */
StructRNA *RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
{
StructRNA *srna, *srnafrom= NULL;
StructDefRNA *ds= NULL, *dsfrom= NULL;
PropertyRNA *prop, *propfrom;
PropertyRNA *prop;
if(DefRNA.preprocess) {
char error[512];
@ -397,40 +384,8 @@ StructRNA *RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *
srna->flag |= STRUCT_RUNTIME;
if(srnafrom) {
/* copy from struct to derive stuff, a bit clumsy since we can't
* use MEM_dupallocN, data structs may not be alloced but builtin */
for(propfrom= srnafrom->properties.first; propfrom; propfrom=propfrom->next) {
prop= RNA_def_property(srna, propfrom->identifier, propfrom->type, propfrom->subtype);
rna_remlink(&srna->properties, prop);
memcpy(prop, propfrom, rna_property_type_sizeof(propfrom->type));
if(!DefRNA.preprocess)
prop->flag |= PROP_RUNTIME;
prop->next= prop->prev= NULL;
rna_addtail(&srna->properties, prop);
if(propfrom == srnafrom->nameproperty)
srna->nameproperty= prop;
if(propfrom == srnafrom->iteratorproperty)
srna->iteratorproperty= prop;
if(DefRNA.preprocess) {
PropertyDefRNA *dp, *dpfrom;
dp= ds->properties.last;
dpfrom= rna_find_def_property(srnafrom, propfrom);
rna_remlink(&ds->properties, dp);
memcpy(dp, dpfrom, sizeof(*dp));
dp->srna= srna;
dp->prop= prop;
dp->next= dp->prev= NULL;
rna_addtail(&ds->properties, dp);
}
}
srna->nameproperty= srnafrom->nameproperty;
srna->iteratorproperty= srnafrom->iteratorproperty;
}
else {
/* define some builtin properties */
@ -440,14 +395,13 @@ StructRNA *RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *
if(DefRNA.preprocess) {
RNA_def_property_struct_type(prop, "Property");
RNA_def_property_collection_funcs(prop, "rna_builtin_properties_begin", "rna_builtin_properties_next", "rna_iterator_listbase_end", "rna_builtin_properties_get", 0, 0, 0, 0);
RNA_def_property_collection_funcs(prop, "rna_builtin_properties_begin", "rna_builtin_properties_next", "rna_iterator_listbase_end", "rna_builtin_properties_get", 0, 0, 0);
}
else {
#ifdef RNA_RUNTIME
CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
cprop->begin= rna_builtin_properties_begin;
cprop->next= rna_builtin_properties_next;
cprop->next= rna_iterator_listbase_end;
cprop->get= rna_builtin_properties_get;
cprop->structtype= &RNA_Property;
#endif
@ -459,7 +413,7 @@ StructRNA *RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *
if(DefRNA.preprocess) {
RNA_def_property_struct_type(prop, "Struct");
RNA_def_property_pointer_funcs(prop, "rna_builtin_type_get", NULL, NULL);
RNA_def_property_pointer_funcs(prop, "rna_builtin_type_get", NULL);
}
else {
#ifdef RNA_RUNTIME
@ -748,6 +702,12 @@ void RNA_def_property_array(PropertyRNA *prop, int arraylength)
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);
DefRNA.error= 1;
return;
}
switch(prop->type) {
case PROP_BOOLEAN:
case PROP_INT:
@ -1499,7 +1459,7 @@ void RNA_def_property_string_funcs(PropertyRNA *prop, const char *get, const cha
}
}
void RNA_def_property_pointer_funcs(PropertyRNA *prop, const char *get, const char *type, const char *set)
void RNA_def_property_pointer_funcs(PropertyRNA *prop, const char *get, const char *set)
{
StructRNA *srna= DefRNA.laststruct;
@ -1513,7 +1473,6 @@ void RNA_def_property_pointer_funcs(PropertyRNA *prop, const char *get, const ch
PointerPropertyRNA *pprop= (PointerPropertyRNA*)prop;
if(get) pprop->get= (PropPointerGetFunc)get;
if(type) pprop->type= (PropPointerTypeFunc)type;
if(set) pprop->set= (PropPointerSetFunc)set;
break;
}
@ -1524,7 +1483,7 @@ void RNA_def_property_pointer_funcs(PropertyRNA *prop, const char *get, const ch
}
}
void RNA_def_property_collection_funcs(PropertyRNA *prop, const char *begin, const char *next, const char *end, const char *get, const char *type, const char *length, const char *lookupint, const char *lookupstring)
void RNA_def_property_collection_funcs(PropertyRNA *prop, const char *begin, const char *next, const char *end, const char *get, const char *length, const char *lookupint, const char *lookupstring)
{
StructRNA *srna= DefRNA.laststruct;
@ -1541,7 +1500,6 @@ void RNA_def_property_collection_funcs(PropertyRNA *prop, const char *begin, con
if(next) cprop->next= (PropCollectionNextFunc)next;
if(end) cprop->end= (PropCollectionEndFunc)end;
if(get) cprop->get= (PropCollectionGetFunc)get;
if(type) cprop->type= (PropCollectionTypeFunc)type;
if(length) cprop->length= (PropCollectionLengthFunc)length;
if(lookupint) cprop->lookupint= (PropCollectionLookupIntFunc)lookupint;
if(lookupstring) cprop->lookupstring= (PropCollectionLookupStringFunc)lookupstring;

View File

@ -33,12 +33,12 @@
#ifdef RNA_RUNTIME
void *rna_Group_objects_get(CollectionPropertyIterator *iter)
PointerRNA rna_Group_objects_get(CollectionPropertyIterator *iter)
{
ListBaseIterator *internal= iter->internal;
/* we are actually iterating a GroupObject list, so override get */
return ((GroupObject *)internal->link)->ob;
return rna_pointer_inherit_refine(&iter->parent, &RNA_Object, ((GroupObject*)internal->link)->ob);
}
#else
@ -60,7 +60,7 @@ void RNA_def_group(BlenderRNA *brna)
RNA_def_property_collection_sdna(prop, NULL, "gobject", NULL);
RNA_def_property_struct_type(prop, "Object");
RNA_def_property_ui_text(prop, "Objects", "A collection of this groups objects.");
RNA_def_property_collection_funcs(prop, 0, 0, 0, "rna_Group_objects_get", 0, 0, 0, 0);
RNA_def_property_collection_funcs(prop, 0, 0, 0, "rna_Group_objects_get", 0, 0, 0);
prop= RNA_def_property(srna, "layer", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "layer", 1);

View File

@ -181,8 +181,8 @@ struct IDProperty *rna_idproperty_check(struct PropertyRNA **prop, struct Pointe
void rna_builtin_properties_begin(struct CollectionPropertyIterator *iter, struct PointerRNA *ptr);
void rna_builtin_properties_next(struct CollectionPropertyIterator *iter);
void *rna_builtin_properties_get(struct CollectionPropertyIterator *iter);
void *rna_builtin_type_get(struct PointerRNA *ptr);
PointerRNA rna_builtin_properties_get(struct CollectionPropertyIterator *iter);
PointerRNA rna_builtin_type_get(struct PointerRNA *ptr);
/* Iterators */
@ -218,6 +218,10 @@ void rna_addtail(struct ListBase *listbase, void *vlink);
void rna_freelinkN(struct ListBase *listbase, void *vlink);
void rna_freelistN(struct ListBase *listbase);
/* Pointer Handling */
PointerRNA rna_pointer_inherit_refine(struct PointerRNA *ptr, struct StructRNA *type, void *data);
#endif /* RNA_INTERNAL_H */

View File

@ -34,6 +34,8 @@ struct PointerRNA;
struct CollectionPropertyIterator;
struct bContext;
#define RNA_MAX_ARRAY 32
/* Function Callbacks */
typedef void (*UpdateFunc)(struct bContext *C, struct PointerRNA *ptr);
@ -42,34 +44,32 @@ typedef struct StructRNA *(*StructRefineFunc)(struct PointerRNA *ptr);
typedef int (*PropBooleanGetFunc)(struct PointerRNA *ptr);
typedef void (*PropBooleanSetFunc)(struct PointerRNA *ptr, int value);
typedef int (*PropBooleanArrayGetFunc)(struct PointerRNA *ptr, int index);
typedef void (*PropBooleanArraySetFunc)(struct PointerRNA *ptr, int index, int value);
typedef void (*PropBooleanArrayGetFunc)(struct PointerRNA *ptr, int *values);
typedef void (*PropBooleanArraySetFunc)(struct PointerRNA *ptr, const int *values);
typedef int (*PropIntGetFunc)(struct PointerRNA *ptr);
typedef void (*PropIntSetFunc)(struct PointerRNA *ptr, int value);
typedef int (*PropIntArrayGetFunc)(struct PointerRNA *ptr, int index);
typedef void (*PropIntArraySetFunc)(struct PointerRNA *ptr, int index, int value);
typedef void (*PropIntArrayGetFunc)(struct PointerRNA *ptr, int *values);
typedef void (*PropIntArraySetFunc)(struct PointerRNA *ptr, const int *values);
typedef void (*PropIntRangeFunc)(struct PointerRNA *ptr, int *min, int *max);
typedef float (*PropFloatGetFunc)(struct PointerRNA *ptr);
typedef void (*PropFloatSetFunc)(struct PointerRNA *ptr, float value);
typedef float (*PropFloatArrayGetFunc)(struct PointerRNA *ptr, int index);
typedef void (*PropFloatArraySetFunc)(struct PointerRNA *ptr, int index, float value);
typedef void (*PropFloatArrayGetFunc)(struct PointerRNA *ptr, float *values);
typedef void (*PropFloatArraySetFunc)(struct PointerRNA *ptr, const float *values);
typedef void (*PropFloatRangeFunc)(struct PointerRNA *ptr, float *min, float *max);
typedef void (*PropStringGetFunc)(struct PointerRNA *ptr, char *value);
typedef int (*PropStringLengthFunc)(struct PointerRNA *ptr);
typedef void (*PropStringSetFunc)(struct PointerRNA *ptr, const char *value);
typedef int (*PropEnumGetFunc)(struct PointerRNA *ptr);
typedef void (*PropEnumSetFunc)(struct PointerRNA *ptr, int value);
typedef void* (*PropPointerGetFunc)(struct PointerRNA *ptr);
typedef void (*PropPointerSetFunc)(struct PointerRNA *ptr, void *value);
typedef struct StructRNA* (*PropPointerTypeFunc)(struct PointerRNA *ptr);
typedef PointerRNA (*PropPointerGetFunc)(struct PointerRNA *ptr);
typedef void (*PropPointerSetFunc)(struct PointerRNA *ptr, const PointerRNA value);
typedef void (*PropCollectionBeginFunc)(struct CollectionPropertyIterator *iter, struct PointerRNA *ptr);
typedef void (*PropCollectionNextFunc)(struct CollectionPropertyIterator *iter);
typedef void (*PropCollectionEndFunc)(struct CollectionPropertyIterator *iter);
typedef void* (*PropCollectionGetFunc)(struct CollectionPropertyIterator *iter);
typedef struct StructRNA* (*PropCollectionTypeFunc)(struct CollectionPropertyIterator *iter);
typedef PointerRNA (*PropCollectionGetFunc)(struct CollectionPropertyIterator *iter);
typedef int (*PropCollectionLengthFunc)(struct PointerRNA *ptr);
typedef void* (*PropCollectionLookupIntFunc)(struct PointerRNA *ptr, int key, struct StructRNA **type);
typedef void* (*PropCollectionLookupStringFunc)(struct PointerRNA *ptr, const char *key, struct StructRNA **type);
typedef PointerRNA (*PropCollectionLookupIntFunc)(struct PointerRNA *ptr, int key);
typedef PointerRNA (*PropCollectionLookupStringFunc)(struct PointerRNA *ptr, const char *key);
struct PropertyRNA {
struct PropertyRNA *next, *prev;
@ -185,7 +185,6 @@ typedef struct PointerPropertyRNA {
PropPointerGetFunc get;
PropPointerSetFunc set;
PropPointerTypeFunc type; /* optional */
struct StructRNA *structtype;
} PointerPropertyRNA;
@ -197,7 +196,6 @@ typedef struct CollectionPropertyRNA {
PropCollectionNextFunc next;
PropCollectionEndFunc end; /* optional */
PropCollectionGetFunc get;
PropCollectionTypeFunc type; /* optional */
PropCollectionLengthFunc length; /* optional */
PropCollectionLookupIntFunc lookupint; /* optional */
PropCollectionLookupStringFunc lookupstring; /* optional */

View File

@ -48,7 +48,7 @@ static Key *rna_ShapeKey_find_key(ID *id)
}
}
static void *rna_ShapeKey_relative_key_get(PointerRNA *ptr)
static PointerRNA rna_ShapeKey_relative_key_get(PointerRNA *ptr)
{
Key *key= rna_ShapeKey_find_key(ptr->id.data);
KeyBlock *kb= (KeyBlock*)ptr->data, *kbrel;
@ -57,21 +57,27 @@ static void *rna_ShapeKey_relative_key_get(PointerRNA *ptr)
if(key && kb->relative < key->totkey)
for(a=0, kbrel=key->block.first; kbrel; kbrel=kbrel->next, a++)
if(a == kb->relative)
return kbrel;
return rna_pointer_inherit_refine(ptr, &RNA_ShapeKey, kbrel);
return NULL;
return rna_pointer_inherit_refine(ptr, NULL, NULL);
}
static float rna_ShapeKeyPoint_co_get(PointerRNA *ptr, int index)
static void rna_ShapeKeyPoint_co_get(PointerRNA *ptr, float *values)
{
float *vec= (float*)ptr->data;
return vec[index];
values[0]= vec[0];
values[1]= vec[1];
values[2]= vec[2];
}
static void rna_ShapeKeyPoint_co_set(PointerRNA *ptr, int index, float value)
static void rna_ShapeKeyPoint_co_set(PointerRNA *ptr, const float *values)
{
float *vec= (float*)ptr->data;
vec[index]= value;
vec[0]= values[0];
vec[1]= values[1];
vec[2]= values[2];
}
static float rna_ShapeKeyCurvePoint_tilt_get(PointerRNA *ptr)
@ -86,40 +92,58 @@ static void rna_ShapeKeyCurvePoint_tilt_set(PointerRNA *ptr, float value)
vec[3]= value;
}
static float rna_ShapeKeyBezierPoint_co_get(PointerRNA *ptr, int index)
static void rna_ShapeKeyBezierPoint_co_get(PointerRNA *ptr, float *values)
{
float *vec= (float*)ptr->data;
return vec[index+3];
values[0]= vec[0+3];
values[1]= vec[1+3];
values[2]= vec[2+3];
}
static void rna_ShapeKeyBezierPoint_co_set(PointerRNA *ptr, int index, float value)
static void rna_ShapeKeyBezierPoint_co_set(PointerRNA *ptr, const float *values)
{
float *vec= (float*)ptr->data;
vec[index+3]= value;
vec[0+3]= values[0];
vec[1+3]= values[1];
vec[2+3]= values[2];
}
static float rna_ShapeKeyBezierPoint_handle_1_co_get(PointerRNA *ptr, int index)
static void rna_ShapeKeyBezierPoint_handle_1_co_get(PointerRNA *ptr, float *values)
{
float *vec= (float*)ptr->data;
return vec[index];
values[0]= vec[0];
values[1]= vec[1];
values[2]= vec[2];
}
static void rna_ShapeKeyBezierPoint_handle_1_co_set(PointerRNA *ptr, int index, float value)
static void rna_ShapeKeyBezierPoint_handle_1_co_set(PointerRNA *ptr, const float *values)
{
float *vec= (float*)ptr->data;
vec[index]= value;
vec[0]= values[0];
vec[1]= values[1];
vec[2]= values[2];
}
static float rna_ShapeKeyBezierPoint_handle_2_co_get(PointerRNA *ptr, int index)
static void rna_ShapeKeyBezierPoint_handle_2_co_get(PointerRNA *ptr, float *values)
{
float *vec= (float*)ptr->data;
return vec[6+index];
values[0]= vec[6+0];
values[1]= vec[6+1];
values[2]= vec[6+2];
}
static void rna_ShapeKeyBezierPoint_handle_2_co_set(PointerRNA *ptr, int index, float value)
static void rna_ShapeKeyBezierPoint_handle_2_co_set(PointerRNA *ptr, const float *values)
{
float *vec= (float*)ptr->data;
vec[6+index]= value;
vec[6+0]= values[0];
vec[6+1]= values[1];
vec[6+2]= values[2];
}
/*static float rna_ShapeKeyBezierPoint_tilt_get(PointerRNA *ptr)
@ -174,9 +198,10 @@ static int rna_ShapeKey_data_length(PointerRNA *ptr)
return tot;
}
static StructRNA *rna_ShapeKey_data_type(CollectionPropertyIterator *iter)
static PointerRNA rna_ShapeKey_data_get(CollectionPropertyIterator *iter)
{
Key *key= rna_ShapeKey_find_key(iter->parent.id.data);
StructRNA *type;
Curve *cu;
Nurb *nu;
@ -185,12 +210,14 @@ static StructRNA *rna_ShapeKey_data_type(CollectionPropertyIterator *iter)
nu= cu->nurb.first;
if(nu->bezt)
return &RNA_ShapeKeyBezierPoint;
type= &RNA_ShapeKeyBezierPoint;
else
return &RNA_ShapeKeyCurvePoint;
type= &RNA_ShapeKeyCurvePoint;
}
else
return &RNA_ShapeKeyPoint;
type= &RNA_ShapeKeyPoint;
return rna_pointer_inherit_refine(&iter->parent, type, rna_iterator_array_get(iter));
}
#else
@ -287,7 +314,7 @@ static void rna_def_keyblock(BlenderRNA *brna)
RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
RNA_def_property_struct_type(prop, "ShapeKey");
RNA_def_property_ui_text(prop, "Relative Key", "Shape used as a relative key.");
RNA_def_property_pointer_funcs(prop, "rna_ShapeKey_relative_key_get", NULL, NULL);
RNA_def_property_pointer_funcs(prop, "rna_ShapeKey_relative_key_get", NULL);
prop= RNA_def_property(srna, "mute", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", KEYBLOCK_MUTE);
@ -306,7 +333,7 @@ static void rna_def_keyblock(BlenderRNA *brna)
prop= RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "data", "totelem");
RNA_def_property_ui_text(prop, "Data", "");
RNA_def_property_collection_funcs(prop, "rna_ShapeKey_data_begin", 0, 0, 0, "rna_ShapeKey_data_type", "rna_ShapeKey_data_length", 0, 0);
RNA_def_property_collection_funcs(prop, "rna_ShapeKey_data_begin", 0, 0, "rna_ShapeKey_data_get", "rna_ShapeKey_data_length", 0, 0);
}
static void rna_def_key(BlenderRNA *brna)

View File

@ -46,9 +46,9 @@ static void rna_Lamp_buffer_size_set(PointerRNA *ptr, int value)
la->bufsize &= (~15); /* round to multiple of 16 */
}
static void *rna_Lamp_sky_settings_get(PointerRNA *ptr)
static PointerRNA rna_Lamp_sky_settings_get(PointerRNA *ptr)
{
return ptr->id.data;
return rna_pointer_inherit_refine(ptr, &RNA_LampSkySettings, ptr->id.data);
}
static void rna_Lamp_mtex_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
@ -57,10 +57,10 @@ static void rna_Lamp_mtex_begin(CollectionPropertyIterator *iter, PointerRNA *pt
rna_iterator_array_begin(iter, (void*)la->mtex, sizeof(MTex*), MAX_MTEX, NULL);
}
static void *rna_Lamp_active_texture_get(PointerRNA *ptr)
static PointerRNA rna_Lamp_active_texture_get(PointerRNA *ptr)
{
Lamp *la= (Lamp*)ptr->data;
return la->mtex[(int)la->texact];
return rna_pointer_inherit_refine(ptr, &RNA_TextureSlot, la->mtex[(int)la->texact]);
}
static StructRNA* rna_Lamp_refine(struct PointerRNA *ptr)
@ -645,7 +645,7 @@ static void rna_def_sun_lamp(BlenderRNA *brna)
/* sky */
prop= RNA_def_property(srna, "sky", PROP_POINTER, PROP_NEVER_NULL);
RNA_def_property_struct_type(prop, "LampSkySettings");
RNA_def_property_pointer_funcs(prop, "rna_Lamp_sky_settings_get", NULL, NULL);
RNA_def_property_pointer_funcs(prop, "rna_Lamp_sky_settings_get", NULL);
RNA_def_property_ui_text(prop, "Sky Settings", "Sky related settings for sun lamps.");
}

View File

@ -36,24 +36,18 @@
#ifdef RNA_RUNTIME
static float rna_LatticePoint_co_get(PointerRNA *ptr, int index)
static void rna_LatticePoint_co_get(PointerRNA *ptr, float *values)
{
Lattice *lt= (Lattice*)ptr->id.data;
BPoint *bp= (BPoint*)ptr->data;
int a= bp - lt->def;
int x= a % lt->pntsu;
int y= (a/lt->pntsu) % lt->pntsv;
int z= (a/(lt->pntsu*lt->pntsv));
if(index == 0) {
int x= a % lt->pntsu;
return lt->fu + x*lt->du;
}
else if(index == 1) {
int y= (a/lt->pntsu) % lt->pntsv;
return lt->fv + y*lt->dv;
}
else {
int z= (a/(lt->pntsu*lt->pntsv));
return lt->fw + z*lt->dw;
}
values[0]= lt->fu + x*lt->du;
values[1]= lt->fv + y*lt->dv;
values[2]= lt->fw + z*lt->dw;
}
static void rna_LatticePoint_groups_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
@ -105,7 +99,7 @@ static void rna_def_latticepoint(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Deformed Location", "");
prop= RNA_def_property(srna, "groups", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_funcs(prop, "rna_LatticePoint_groups_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", 0, 0, 0, 0);
RNA_def_property_collection_funcs(prop, "rna_LatticePoint_groups_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", 0, 0, 0);
RNA_def_property_struct_type(prop, "VertexGroupElement");
RNA_def_property_ui_text(prop, "Groups", "Weights for the vertex groups this point is member of.");
}
@ -164,7 +158,7 @@ static void rna_def_lattice(BlenderRNA *brna)
prop= RNA_def_property(srna, "points", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_type(prop, "LatticePoint");
RNA_def_property_collection_funcs(prop, "rna_Lattice_points_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", 0, 0, 0, 0);
RNA_def_property_collection_funcs(prop, "rna_Lattice_points_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", 0, 0, 0);
RNA_def_property_ui_text(prop, "Points", "Points of the lattice.");
}

View File

@ -46,11 +46,13 @@ static int rna_Main_filename_length(PointerRNA *ptr)
return strlen(bmain->name);
}
#if 0
static void rna_Main_filename_set(PointerRNA *ptr, const char *value)
{
Main *bmain= (Main*)ptr->data;
BLI_strncpy(bmain->name, value, sizeof(bmain->name));
}
#endif
static void rna_Main_scene_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
@ -257,7 +259,7 @@ void RNA_def_main(BlenderRNA *brna)
{
prop= RNA_def_property(srna, lists[i][0], PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_type(prop, lists[i][1]);
RNA_def_property_collection_funcs(prop, lists[i][2], "rna_iterator_listbase_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get", 0, 0, 0, 0);
RNA_def_property_collection_funcs(prop, lists[i][2], "rna_iterator_listbase_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get", 0, 0, 0);
RNA_def_property_ui_text(prop, lists[i][3], lists[i][4]);
}
}

View File

@ -37,9 +37,29 @@
#ifdef RNA_RUNTIME
static void *rna_Material_self_get(PointerRNA *ptr)
static PointerRNA rna_Material_mirror_get(PointerRNA *ptr)
{
return ptr->id.data;
return rna_pointer_inherit_refine(ptr, &RNA_MaterialRaytraceMirror, ptr->id.data);
}
static PointerRNA rna_Material_transp_get(PointerRNA *ptr)
{
return rna_pointer_inherit_refine(ptr, &RNA_MaterialRaytraceTransparency, ptr->id.data);
}
static PointerRNA rna_Material_halo_get(PointerRNA *ptr)
{
return rna_pointer_inherit_refine(ptr, &RNA_MaterialHalo, ptr->id.data);
}
static PointerRNA rna_Material_sss_get(PointerRNA *ptr)
{
return rna_pointer_inherit_refine(ptr, &RNA_MaterialSubsurfaceScattering, ptr->id.data);
}
static PointerRNA rna_Material_strand_get(PointerRNA *ptr)
{
return rna_pointer_inherit_refine(ptr, &RNA_MaterialStrand, ptr->id.data);
}
static void rna_Material_mode_halo_set(PointerRNA *ptr, int value)
@ -58,10 +78,10 @@ static void rna_Material_mtex_begin(CollectionPropertyIterator *iter, PointerRNA
rna_iterator_array_begin(iter, (void*)ma->mtex, sizeof(MTex*), MAX_MTEX, NULL);
}
static void *rna_Material_active_texture_get(PointerRNA *ptr)
static PointerRNA rna_Material_active_texture_get(PointerRNA *ptr)
{
Material *ma= (Material*)ptr->data;
return ma->mtex[(int)ma->texact];
return rna_pointer_inherit_refine(ptr, &RNA_TextureSlot, ma->mtex[(int)ma->texact]);
}
static void rna_MaterialStrand_start_size_range(PointerRNA *ptr, float *min, float *max)
@ -762,27 +782,27 @@ void RNA_def_material(BlenderRNA *brna)
/* nested structs */
prop= RNA_def_property(srna, "raytrace_mirror", PROP_POINTER, PROP_NEVER_NULL);
RNA_def_property_struct_type(prop, "MaterialRaytraceMirror");
RNA_def_property_pointer_funcs(prop, "rna_Material_self_get", NULL, NULL);
RNA_def_property_pointer_funcs(prop, "rna_Material_mirror_get", NULL);
RNA_def_property_ui_text(prop, "Raytrace Mirror", "Raytraced reflection settings for the material.");
prop= RNA_def_property(srna, "raytrace_transparency", PROP_POINTER, PROP_NEVER_NULL);
RNA_def_property_struct_type(prop, "MaterialRaytraceTransparency");
RNA_def_property_pointer_funcs(prop, "rna_Material_self_get", NULL, NULL);
RNA_def_property_pointer_funcs(prop, "rna_Material_transp_get", NULL);
RNA_def_property_ui_text(prop, "Raytrace Transparency", "Raytraced reflection settings for the material.");
prop= RNA_def_property(srna, "halo", PROP_POINTER, PROP_NEVER_NULL);
RNA_def_property_struct_type(prop, "MaterialHalo");
RNA_def_property_pointer_funcs(prop, "rna_Material_self_get", NULL, NULL);
RNA_def_property_pointer_funcs(prop, "rna_Material_halo_get", NULL);
RNA_def_property_ui_text(prop, "Halo", "Halo settings for the material.");
prop= RNA_def_property(srna, "subsurface_scattering", PROP_POINTER, PROP_NEVER_NULL);
RNA_def_property_struct_type(prop, "MaterialSubsurfaceScattering");
RNA_def_property_pointer_funcs(prop, "rna_Material_self_get", NULL, NULL);
RNA_def_property_pointer_funcs(prop, "rna_Material_sss_get", NULL);
RNA_def_property_ui_text(prop, "Subsurface Scattering", "Subsurface scattering settings for the material.");
prop= RNA_def_property(srna, "strand", PROP_POINTER, PROP_NEVER_NULL);
RNA_def_property_struct_type(prop, "MaterialStrand");
RNA_def_property_pointer_funcs(prop, "rna_Material_self_get", NULL, NULL);
RNA_def_property_pointer_funcs(prop, "rna_Material_strand_get", NULL);
RNA_def_property_ui_text(prop, "Strand", "Strand settings for the material.");
/* nodetree */
@ -821,13 +841,13 @@ void rna_def_mtex_common(StructRNA *srna, const char *begin, const char *activeg
/* mtex */
prop= RNA_def_property(srna, "textures", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_type(prop, structname);
RNA_def_property_collection_funcs(prop, begin, "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_dereference_get", 0, 0, 0, 0);
RNA_def_property_collection_funcs(prop, begin, "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_dereference_get", 0, 0, 0);
RNA_def_property_ui_text(prop, "Textures", "Texture slots defining the mapping and influence of textures.");
prop= RNA_def_property(srna, "active_texture", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
RNA_def_property_struct_type(prop, structname);
RNA_def_property_pointer_funcs(prop, activeget, NULL, NULL);
RNA_def_property_pointer_funcs(prop, activeget, NULL);
RNA_def_property_ui_text(prop, "Active Texture", "Active texture slot being displayed.");
prop= RNA_def_property(srna, "active_texture_index", PROP_INT, PROP_UNSIGNED);

View File

@ -80,52 +80,76 @@ static void rna_MEdge_crease_set(PointerRNA *ptr, float value)
medge->crease= (char)(CLAMPIS(value*255.0f, 0, 255));
}
static float rna_MeshColor_color1_get(PointerRNA *ptr, int index)
static void rna_MeshColor_color1_get(PointerRNA *ptr, float *values)
{
MCol *mcol= (MCol*)ptr->data;
return (&mcol[0].r)[index]/255.0f;
values[0]= (&mcol[0].r)[0]/255.0f;
values[1]= (&mcol[0].r)[1]/255.0f;
values[2]= (&mcol[0].r)[2]/255.0f;
}
static void rna_MeshColor_color1_set(PointerRNA *ptr, int index, float value)
static void rna_MeshColor_color1_set(PointerRNA *ptr, const float *values)
{
MCol *mcol= (MCol*)ptr->data;
(&mcol[0].r)[index]= (char)(CLAMPIS(value*255.0f, 0, 255));
(&mcol[0].r)[0]= (char)(CLAMPIS(values[0]*255.0f, 0, 255));
(&mcol[0].r)[1]= (char)(CLAMPIS(values[1]*255.0f, 0, 255));
(&mcol[0].r)[2]= (char)(CLAMPIS(values[2]*255.0f, 0, 255));
}
static float rna_MeshColor_color2_get(PointerRNA *ptr, int index)
static void rna_MeshColor_color2_get(PointerRNA *ptr, float *values)
{
MCol *mcol= (MCol*)ptr->data;
return (&mcol[1].r)[index]/255.0f;
values[0]= (&mcol[1].r)[0]/255.0f;
values[1]= (&mcol[1].r)[1]/255.0f;
values[2]= (&mcol[1].r)[2]/255.0f;
}
static void rna_MeshColor_color2_set(PointerRNA *ptr, int index, float value)
static void rna_MeshColor_color2_set(PointerRNA *ptr, const float *values)
{
MCol *mcol= (MCol*)ptr->data;
(&mcol[1].r)[index]= (char)(CLAMPIS(value*255.0f, 0, 255));
(&mcol[1].r)[0]= (char)(CLAMPIS(values[0]*255.0f, 0, 255));
(&mcol[1].r)[1]= (char)(CLAMPIS(values[1]*255.0f, 0, 255));
(&mcol[1].r)[2]= (char)(CLAMPIS(values[2]*255.0f, 0, 255));
}
static float rna_MeshColor_color3_get(PointerRNA *ptr, int index)
static void rna_MeshColor_color3_get(PointerRNA *ptr, float *values)
{
MCol *mcol= (MCol*)ptr->data;
return (&mcol[2].r)[index]/255.0f;
values[0]= (&mcol[2].r)[0]/255.0f;
values[1]= (&mcol[2].r)[1]/255.0f;
values[2]= (&mcol[2].r)[2]/255.0f;
}
static void rna_MeshColor_color3_set(PointerRNA *ptr, int index, float value)
static void rna_MeshColor_color3_set(PointerRNA *ptr, const float *values)
{
MCol *mcol= (MCol*)ptr->data;
(&mcol[2].r)[index]= (char)(CLAMPIS(value*255.0f, 0, 255));
(&mcol[2].r)[0]= (char)(CLAMPIS(values[0]*255.0f, 0, 255));
(&mcol[2].r)[1]= (char)(CLAMPIS(values[1]*255.0f, 0, 255));
(&mcol[2].r)[2]= (char)(CLAMPIS(values[2]*255.0f, 0, 255));
}
static float rna_MeshColor_color4_get(PointerRNA *ptr, int index)
static void rna_MeshColor_color4_get(PointerRNA *ptr, float *values)
{
MCol *mcol= (MCol*)ptr->data;
return (&mcol[2].r)[index]/255.0f;
values[0]= (&mcol[3].r)[0]/255.0f;
values[1]= (&mcol[3].r)[1]/255.0f;
values[2]= (&mcol[3].r)[2]/255.0f;
}
static void rna_MeshColor_color4_set(PointerRNA *ptr, int index, float value)
static void rna_MeshColor_color4_set(PointerRNA *ptr, const float *values)
{
MCol *mcol= (MCol*)ptr->data;
(&mcol[3].r)[index]= (char)(CLAMPIS(value*255.0f, 0, 255));
(&mcol[3].r)[0]= (char)(CLAMPIS(values[0]*255.0f, 0, 255));
(&mcol[3].r)[1]= (char)(CLAMPIS(values[1]*255.0f, 0, 255));
(&mcol[3].r)[2]= (char)(CLAMPIS(values[2]*255.0f, 0, 255));
}
static int rna_Mesh_texspace_editable(PointerRNA *ptr)
@ -213,52 +237,68 @@ static int rna_Mesh_uv_layers_length(PointerRNA *ptr)
return rna_CustomDataLayer_length(ptr, CD_MTFACE);
}
static float rna_MeshTextureFace_uv1_get(PointerRNA *ptr, int index)
static void rna_MeshTextureFace_uv1_get(PointerRNA *ptr, float *values)
{
MTFace *mtface= (MTFace*)ptr->data;
return mtface->uv[0][index];
values[0]= mtface->uv[0][0];
values[1]= mtface->uv[0][1];
}
static void rna_MeshTextureFace_uv1_set(PointerRNA *ptr, int index, float value)
static void rna_MeshTextureFace_uv1_set(PointerRNA *ptr, const float *values)
{
MTFace *mtface= (MTFace*)ptr->data;
mtface->uv[0][index]= value;
mtface->uv[0][0]= values[0];
mtface->uv[0][1]= values[1];
}
static float rna_MeshTextureFace_uv2_get(PointerRNA *ptr, int index)
static void rna_MeshTextureFace_uv2_get(PointerRNA *ptr, float *values)
{
MTFace *mtface= (MTFace*)ptr->data;
return mtface->uv[1][index];
values[0]= mtface->uv[1][0];
values[1]= mtface->uv[1][1];
}
static void rna_MeshTextureFace_uv2_set(PointerRNA *ptr, int index, float value)
static void rna_MeshTextureFace_uv2_set(PointerRNA *ptr, const float *values)
{
MTFace *mtface= (MTFace*)ptr->data;
mtface->uv[1][index]= value;
mtface->uv[1][0]= values[0];
mtface->uv[1][1]= values[1];
}
static float rna_MeshTextureFace_uv3_get(PointerRNA *ptr, int index)
static void rna_MeshTextureFace_uv3_get(PointerRNA *ptr, float *values)
{
MTFace *mtface= (MTFace*)ptr->data;
return mtface->uv[2][index];
values[0]= mtface->uv[2][0];
values[1]= mtface->uv[2][1];
}
static void rna_MeshTextureFace_uv3_set(PointerRNA *ptr, int index, float value)
static void rna_MeshTextureFace_uv3_set(PointerRNA *ptr, const float *values)
{
MTFace *mtface= (MTFace*)ptr->data;
mtface->uv[2][index]= value;
mtface->uv[2][0]= values[0];
mtface->uv[2][1]= values[1];
}
static float rna_MeshTextureFace_uv4_get(PointerRNA *ptr, int index)
static void rna_MeshTextureFace_uv4_get(PointerRNA *ptr, float *values)
{
MTFace *mtface= (MTFace*)ptr->data;
return mtface->uv[3][index];
values[0]= mtface->uv[3][0];
values[1]= mtface->uv[3][1];
}
static void rna_MeshTextureFace_uv4_set(PointerRNA *ptr, int index, float value)
static void rna_MeshTextureFace_uv4_set(PointerRNA *ptr, const float *values)
{
MTFace *mtface= (MTFace*)ptr->data;
mtface->uv[3][index]= value;
mtface->uv[3][0]= values[0];
mtface->uv[3][1]= values[1];
}
static void rna_MeshTextureFaceLayer_data_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
@ -487,7 +527,7 @@ static void rna_def_mvert(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Bevel Weight", "Weight used by the Bevel modifier 'Only Vertices' option");
prop= RNA_def_property(srna, "groups", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_funcs(prop, "rna_MeshVertex_groups_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", 0, 0, 0, 0);
RNA_def_property_collection_funcs(prop, "rna_MeshVertex_groups_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", 0, 0, 0);
RNA_def_property_struct_type(prop, "VertexGroupElement");
RNA_def_property_ui_text(prop, "Groups", "Weights for the vertex groups this vertex is member of.");
}
@ -597,7 +637,7 @@ static void rna_def_mtface(BlenderRNA *brna)
prop= RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_type(prop, "MeshTextureFace");
RNA_def_property_ui_text(prop, "Data", "");
RNA_def_property_collection_funcs(prop, "rna_MeshTextureFaceLayer_data_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", 0, "rna_MeshTextureFaceLayer_data_length", 0, 0);
RNA_def_property_collection_funcs(prop, "rna_MeshTextureFaceLayer_data_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_MeshTextureFaceLayer_data_length", 0, 0);
srna= RNA_def_struct(brna, "MeshTextureFace", NULL);
RNA_def_struct_sdna(srna, "MTFace");
@ -732,7 +772,7 @@ static void rna_def_mcol(BlenderRNA *brna)
prop= RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_type(prop, "MeshColor");
RNA_def_property_ui_text(prop, "Data", "");
RNA_def_property_collection_funcs(prop, "rna_MeshColorLayer_data_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", 0, "rna_MeshColorLayer_data_length", 0, 0);
RNA_def_property_collection_funcs(prop, "rna_MeshColorLayer_data_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_MeshColorLayer_data_length", 0, 0);
srna= RNA_def_struct(brna, "MeshColor", NULL);
RNA_def_struct_sdna(srna, "MCol");
@ -776,7 +816,7 @@ static void rna_def_mproperties(BlenderRNA *brna)
prop= RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_type(prop, "MeshFloatProperty");
RNA_def_property_ui_text(prop, "Data", "");
RNA_def_property_collection_funcs(prop, "rna_MeshFloatPropertyLayer_data_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", 0, "rna_MeshFloatPropertyLayer_data_length", 0, 0);
RNA_def_property_collection_funcs(prop, "rna_MeshFloatPropertyLayer_data_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_MeshFloatPropertyLayer_data_length", 0, 0);
srna= RNA_def_struct(brna, "MeshFloatProperty", NULL);
RNA_def_struct_sdna(srna, "MFloatProperty");
@ -798,7 +838,7 @@ static void rna_def_mproperties(BlenderRNA *brna)
prop= RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_type(prop, "MeshIntProperty");
RNA_def_property_ui_text(prop, "Data", "");
RNA_def_property_collection_funcs(prop, "rna_MeshIntPropertyLayer_data_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", 0, "rna_MeshIntPropertyLayer_data_length", 0, 0);
RNA_def_property_collection_funcs(prop, "rna_MeshIntPropertyLayer_data_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_MeshIntPropertyLayer_data_length", 0, 0);
srna= RNA_def_struct(brna, "MeshIntProperty", NULL);
RNA_def_struct_sdna(srna, "MIntProperty");
@ -820,7 +860,7 @@ static void rna_def_mproperties(BlenderRNA *brna)
prop= RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_type(prop, "MeshStringProperty");
RNA_def_property_ui_text(prop, "Data", "");
RNA_def_property_collection_funcs(prop, "rna_MeshStringPropertyLayer_data_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", 0, "rna_MeshStringPropertyLayer_data_length", 0, 0);
RNA_def_property_collection_funcs(prop, "rna_MeshStringPropertyLayer_data_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_MeshStringPropertyLayer_data_length", 0, 0);
srna= RNA_def_struct(brna, "MeshStringProperty", NULL);
RNA_def_struct_sdna(srna, "MStringProperty");
@ -924,31 +964,31 @@ static void rna_def_mesh(BlenderRNA *brna)
prop= RNA_def_property(srna, "uv_layers", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "fdata.layers", "fdata.totlayer");
RNA_def_property_collection_funcs(prop, "rna_Mesh_uv_layers_begin", 0, 0, 0, 0, "rna_Mesh_uv_layers_length", 0, 0);
RNA_def_property_collection_funcs(prop, "rna_Mesh_uv_layers_begin", 0, 0, 0, "rna_Mesh_uv_layers_length", 0, 0);
RNA_def_property_struct_type(prop, "MeshTextureFaceLayer");
RNA_def_property_ui_text(prop, "UV Layers", "");
prop= RNA_def_property(srna, "vcol_layers", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "fdata.layers", "fdata.totlayer");
RNA_def_property_collection_funcs(prop, "rna_Mesh_vcol_layers_begin", 0, 0, 0, 0, "rna_Mesh_vcol_layers_length", 0, 0);
RNA_def_property_collection_funcs(prop, "rna_Mesh_vcol_layers_begin", 0, 0, 0, "rna_Mesh_vcol_layers_length", 0, 0);
RNA_def_property_struct_type(prop, "MeshColorLayer");
RNA_def_property_ui_text(prop, "Vertex Color Layers", "");
prop= RNA_def_property(srna, "float_layers", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "fdata.layers", "fdata.totlayer");
RNA_def_property_collection_funcs(prop, "rna_Mesh_float_layers_begin", 0, 0, 0, 0, "rna_Mesh_float_layers_length", 0, 0);
RNA_def_property_collection_funcs(prop, "rna_Mesh_float_layers_begin", 0, 0, 0, "rna_Mesh_float_layers_length", 0, 0);
RNA_def_property_struct_type(prop, "MeshFloatPropertyLayer");
RNA_def_property_ui_text(prop, "Float Property Layers", "");
prop= RNA_def_property(srna, "int_layers", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "fdata.layers", "fdata.totlayer");
RNA_def_property_collection_funcs(prop, "rna_Mesh_int_layers_begin", 0, 0, 0, 0, "rna_Mesh_int_layers_length", 0, 0);
RNA_def_property_collection_funcs(prop, "rna_Mesh_int_layers_begin", 0, 0, 0, "rna_Mesh_int_layers_length", 0, 0);
RNA_def_property_struct_type(prop, "MeshIntPropertyLayer");
RNA_def_property_ui_text(prop, "Int Property Layers", "");
prop= RNA_def_property(srna, "string_layers", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "fdata.layers", "fdata.totlayer");
RNA_def_property_collection_funcs(prop, "rna_Mesh_string_layers_begin", 0, 0, 0, 0, "rna_Mesh_string_layers_length", 0, 0);
RNA_def_property_collection_funcs(prop, "rna_Mesh_string_layers_begin", 0, 0, 0, "rna_Mesh_string_layers_length", 0, 0);
RNA_def_property_struct_type(prop, "MeshStringPropertyLayer");
RNA_def_property_ui_text(prop, "String Property Layers", "");

View File

@ -940,7 +940,7 @@ static void rna_def_modifier_uvproject(BlenderRNA *brna)
prop= RNA_def_property(srna, "projectors", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_type(prop, "Object");
RNA_def_property_collection_funcs(prop, "rna_UVProject_projectors_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_dereference_get", 0, 0, 0, 0);
RNA_def_property_collection_funcs(prop, "rna_UVProject_projectors_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_dereference_get", 0, 0, 0);
RNA_def_property_ui_text(prop, "Projectors", "");
prop= RNA_def_property(srna, "image", PROP_POINTER, PROP_NONE);

View File

@ -103,7 +103,7 @@ void RNA_def_nodetree(BlenderRNA *brna)
prop= RNA_def_property(srna, "nodes", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "nodes", NULL);
RNA_def_property_collection_funcs(prop, "rna_Nodetree_nodes_begin", "rna_iterator_listbase_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get", 0, 0, 0, 0);
RNA_def_property_collection_funcs(prop, "rna_Nodetree_nodes_begin", "rna_iterator_listbase_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get", 0, 0, 0);
RNA_def_property_struct_type(prop, "Node");
RNA_def_property_ui_text(prop, "Nodes", "");

View File

@ -55,10 +55,10 @@ static int rna_VertexGroup_index_get(PointerRNA *ptr)
return BLI_findindex(&ob->defbase, ptr->data);
}
static void *rna_Object_active_vertex_group_get(PointerRNA *ptr)
static PointerRNA rna_Object_active_vertex_group_get(PointerRNA *ptr)
{
Object *ob= (Object*)ptr->id.data;
return BLI_findlink(&ob->defbase, ob->actdef);
return rna_pointer_inherit_refine(ptr, &RNA_VertexGroup, BLI_findlink(&ob->defbase, ob->actdef));
}
void rna_object_vgroup_name_index_get(PointerRNA *ptr, char *value, int index)
@ -165,19 +165,18 @@ static void rna_Object_active_material_index_range(PointerRNA *ptr, int *min, in
*max= ob->totcol-1;
}
static void *rna_Object_active_material_get(PointerRNA *ptr)
static PointerRNA rna_Object_active_material_get(PointerRNA *ptr)
{
Object *ob= (Object*)ptr->id.data;
return give_current_material(ob, ob->actcol);
return rna_pointer_inherit_refine(ptr, &RNA_Material, give_current_material(ob, ob->actcol));
}
#if 0
static void rna_Object_active_material_set(PointerRNA *ptr, void *value)
static void rna_Object_active_material_set(PointerRNA *ptr, PointerRNA value)
{
Object *ob= (Object*)ptr->id.data;
assign_material(ob, value, ob->actcol);
assign_material(ob, value.data, ob->actcol);
}
#endif
@ -197,32 +196,46 @@ static void rna_Object_active_material_link_set(PointerRNA *ptr, int value)
ob->colbits &= ~(1<<(ob->actcol));
}
static void *rna_Object_game_settings_get(PointerRNA *ptr)
static PointerRNA rna_Object_game_settings_get(PointerRNA *ptr)
{
return ptr->id.data;
return rna_pointer_inherit_refine(ptr, &RNA_GameObjectSettings, ptr->id.data);
}
static void rna_Object_layer_set(PointerRNA *ptr, int index, int value)
static void rna_Object_layer_set(PointerRNA *ptr, const int *values)
{
Object *ob= (Object*)ptr->data;
int i, tot;
if(value) ob->lay |= (1<<index);
else {
ob->lay &= ~(1<<index);
if(ob->lay == 0)
ob->lay |= (1<<index);
/* ensure we always have some layer selected */
for(i=0; i<20; i++)
if(values[i])
tot++;
if(tot==0)
return;
for(i=0; i<20; i++) {
if(values[i]) ob->lay |= (1<<i);
else ob->lay &= ~(1<<i);
}
}
static void rna_GameObjectSettings_state_set(PointerRNA *ptr, int index, int value)
static void rna_GameObjectSettings_state_set(PointerRNA *ptr, const int *values)
{
Object *ob= (Object*)ptr->data;
int i, tot;
if(value) ob->state |= (1<<index);
else {
ob->state &= ~(1<<index);
if(ob->state == 0)
ob->state |= (1<<index);
/* ensure we always have some stateer selected */
for(i=0; i<20; i++)
if(values[i])
tot++;
if(tot==0)
return;
for(i=0; i<20; i++) {
if(values[i]) ob->state |= (1<<i);
else ob->state &= ~(1<<i);
}
}
@ -539,7 +552,7 @@ static StructRNA *rna_def_object(BlenderRNA *brna)
prop= RNA_def_property(srna, "active_material", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
RNA_def_property_struct_type(prop, "Material");
RNA_def_property_pointer_funcs(prop, "rna_Object_active_material_get", NULL, NULL);
RNA_def_property_pointer_funcs(prop, "rna_Object_active_material_get", NULL);
RNA_def_property_ui_text(prop, "Active Material", "Active material being displayed.");
prop= RNA_def_property(srna, "active_material_index", PROP_INT, PROP_UNSIGNED);
@ -612,7 +625,7 @@ static StructRNA *rna_def_object(BlenderRNA *brna)
prop= RNA_def_property(srna, "game", PROP_POINTER, PROP_NEVER_NULL);
RNA_def_property_struct_type(prop, "GameObjectSettings");
RNA_def_property_pointer_funcs(prop, "rna_Object_game_settings_get", NULL, NULL);
RNA_def_property_pointer_funcs(prop, "rna_Object_game_settings_get", NULL);
RNA_def_property_ui_text(prop, "Game Settings", "Game engine related settings for the object.");
/* vertex groups */
@ -624,7 +637,7 @@ static StructRNA *rna_def_object(BlenderRNA *brna)
prop= RNA_def_property(srna, "active_vertex_group", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "VertexGroup");
RNA_def_property_pointer_funcs(prop, "rna_Object_active_vertex_group_get", NULL, NULL);
RNA_def_property_pointer_funcs(prop, "rna_Object_active_vertex_group_get", NULL);
RNA_def_property_ui_text(prop, "Active Vertex Group", "Vertex groups of the object.");
/* empty */

View File

@ -64,26 +64,33 @@ static int rna_Struct_name_length(PointerRNA *ptr)
return strlen(((StructRNA*)ptr->data)->name);
}
static void *rna_Struct_base_get(PointerRNA *ptr)
static PointerRNA rna_Struct_base_get(PointerRNA *ptr)
{
return ((StructRNA*)ptr->data)->base;
return rna_pointer_inherit_refine(ptr, &RNA_Struct, ((StructRNA*)ptr->data)->base);
}
static void *rna_Struct_nested_get(PointerRNA *ptr)
static PointerRNA rna_Struct_nested_get(PointerRNA *ptr)
{
return ((StructRNA*)ptr->data)->nested;
return rna_pointer_inherit_refine(ptr, &RNA_Struct, ((StructRNA*)ptr->data)->nested);
}
static void *rna_Struct_name_property_get(PointerRNA *ptr)
static PointerRNA rna_Struct_name_property_get(PointerRNA *ptr)
{
return ((StructRNA*)ptr->data)->nameproperty;
return rna_pointer_inherit_refine(ptr, &RNA_Property, ((StructRNA*)ptr->data)->nameproperty);
}
/* Struct property iteration. This is quite complicated, the purpose is to
* iterate over properties of all inheritance levels, and for each struct to
* also iterator over id properties not known by RNA. */
static int rna_idproperty_known(CollectionPropertyIterator *iter, void *data)
{
IDProperty *idprop= (IDProperty*)data;
PropertyRNA *prop;
/* function to skip any id properties that are already known by RNA,
* for the second loop where we go over unknown id properties */
for(prop= iter->parent.type->properties.first; prop; prop=prop->next)
if(strcmp(prop->identifier, idprop->name) == 0)
return 1;
@ -94,9 +101,41 @@ static int rna_idproperty_known(CollectionPropertyIterator *iter, void *data)
static int rna_property_builtin(CollectionPropertyIterator *iter, void *data)
{
PropertyRNA *prop= (PropertyRNA*)data;
/* function to skip builtin rna properties */
return (prop->flag & PROP_BUILTIN);
}
static void rna_inheritance_next_level_restart(CollectionPropertyIterator *iter, IteratorSkipFunc skip)
{
/* RNA struct inheritance */
while(!iter->valid && iter->level > 0) {
StructRNA *srna;
int i;
srna= (StructRNA*)iter->parent.data;
iter->level--;
for(i=iter->level; i>0; i--)
srna= srna->base;
rna_iterator_listbase_end(iter);
rna_iterator_listbase_begin(iter, &srna->properties, skip);
}
}
static void rna_inheritance_listbase_begin(CollectionPropertyIterator *iter, ListBase *lb, IteratorSkipFunc skip)
{
rna_iterator_listbase_begin(iter, lb, skip);
rna_inheritance_next_level_restart(iter, skip);
}
static void rna_inheritance_listbase_next(CollectionPropertyIterator *iter, IteratorSkipFunc skip)
{
rna_iterator_listbase_next(iter);
rna_inheritance_next_level_restart(iter, skip);
}
static void rna_Struct_properties_next(CollectionPropertyIterator *iter)
{
ListBaseIterator *internal= iter->internal;
@ -108,7 +147,7 @@ static void rna_Struct_properties_next(CollectionPropertyIterator *iter)
}
else {
/* regular properties */
rna_iterator_listbase_next(iter);
rna_inheritance_listbase_next(iter, rna_property_builtin);
/* try id properties */
if(!iter->valid) {
@ -126,23 +165,37 @@ static void rna_Struct_properties_next(CollectionPropertyIterator *iter)
static void rna_Struct_properties_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
rna_iterator_listbase_begin(iter, &((StructRNA*)ptr->data)->properties, rna_property_builtin);
StructRNA *srna;
/* here ptr->data should always be the same as iter->parent.type */
srna= (StructRNA *)ptr->data;
while(srna->base) {
iter->level++;
srna= srna->base;
}
rna_inheritance_listbase_begin(iter, &srna->properties, rna_property_builtin);
}
static void *rna_Struct_properties_get(CollectionPropertyIterator *iter)
static PointerRNA rna_Struct_properties_get(CollectionPropertyIterator *iter)
{
ListBaseIterator *internal= iter->internal;
/* we return either PropertyRNA* or IDProperty*, the rna_access.c
* functions can handle both as PropertyRNA* with some tricks */
return internal->link;
return rna_pointer_inherit_refine(&iter->parent, &RNA_Property, internal->link);
}
/* Builtin properties iterator re-uses the Struct properties iterator, only
* difference is that we need to see the ptr data to the type of the struct
* whose properties we want to iterate over. */
void rna_builtin_properties_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
PointerRNA newptr;
/* we create a new with the type as the data */
/* we create a new pointer with the type as the data */
newptr.type= &RNA_Struct;
newptr.data= ptr->type;
@ -155,6 +208,8 @@ void rna_builtin_properties_begin(CollectionPropertyIterator *iter, PointerRNA *
newptr.id.data= NULL;
}
iter->parent= newptr;
rna_Struct_properties_begin(iter, &newptr);
}
@ -163,14 +218,14 @@ void rna_builtin_properties_next(CollectionPropertyIterator *iter)
rna_Struct_properties_next(iter);
}
void *rna_builtin_properties_get(CollectionPropertyIterator *iter)
PointerRNA rna_builtin_properties_get(CollectionPropertyIterator *iter)
{
return rna_Struct_properties_get(iter);
}
void *rna_builtin_type_get(PointerRNA *ptr)
PointerRNA rna_builtin_type_get(PointerRNA *ptr)
{
return ptr->type;
return rna_pointer_inherit_refine(ptr, &RNA_Struct, ptr->type);
}
/* Property */
@ -382,18 +437,18 @@ static int rna_EnumPropertyItem_value_get(PointerRNA *ptr)
return ((EnumPropertyItem*)ptr->data)->value;
}
static void *rna_PointerProperty_fixed_type_get(PointerRNA *ptr)
static PointerRNA rna_PointerProperty_fixed_type_get(PointerRNA *ptr)
{
PropertyRNA *prop= (PropertyRNA*)ptr->data;
rna_idproperty_check(&prop, ptr);
return ((PointerPropertyRNA*)prop)->structtype;
return rna_pointer_inherit_refine(ptr, &RNA_Struct, ((PointerPropertyRNA*)prop)->structtype);
}
static void *rna_CollectionProperty_fixed_type_get(PointerRNA *ptr)
static PointerRNA rna_CollectionProperty_fixed_type_get(PointerRNA *ptr)
{
PropertyRNA *prop= (PropertyRNA*)ptr->data;
rna_idproperty_check(&prop, ptr);
return ((CollectionPropertyRNA*)prop)->structtype;
return rna_pointer_inherit_refine(ptr, &RNA_Struct, ((CollectionPropertyRNA*)prop)->structtype);
}
/* Blender RNA */
@ -432,25 +487,25 @@ static void rna_def_struct(BlenderRNA *brna)
prop= RNA_def_property(srna, "base", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
RNA_def_property_struct_type(prop, "Struct");
RNA_def_property_pointer_funcs(prop, "rna_Struct_base_get", NULL, NULL);
RNA_def_property_pointer_funcs(prop, "rna_Struct_base_get", NULL);
RNA_def_property_ui_text(prop, "Base", "Struct definition this is derived from.");
prop= RNA_def_property(srna, "nested", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
RNA_def_property_struct_type(prop, "Struct");
RNA_def_property_pointer_funcs(prop, "rna_Struct_nested_get", NULL, NULL);
RNA_def_property_pointer_funcs(prop, "rna_Struct_nested_get", NULL);
RNA_def_property_ui_text(prop, "Nested", "Struct in which this struct is always nested, and to which it logically belongs.");
prop= RNA_def_property(srna, "name_property", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
RNA_def_property_struct_type(prop, "StringProperty");
RNA_def_property_pointer_funcs(prop, "rna_Struct_name_property_get", NULL, NULL);
RNA_def_property_pointer_funcs(prop, "rna_Struct_name_property_get", NULL);
RNA_def_property_ui_text(prop, "Name Property", "Property that gives the name of the struct.");
prop= RNA_def_property(srna, "properties", PROP_COLLECTION, PROP_NONE);
RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
RNA_def_property_struct_type(prop, "Property");
RNA_def_property_collection_funcs(prop, "rna_Struct_properties_begin", "rna_Struct_properties_next", "rna_iterator_listbase_end", "rna_Struct_properties_get", 0, 0, 0, 0);
RNA_def_property_collection_funcs(prop, "rna_Struct_properties_begin", "rna_Struct_properties_next", "rna_iterator_listbase_end", "rna_Struct_properties_get", 0, 0, 0);
RNA_def_property_ui_text(prop, "Properties", "Properties in the struct.");
}
@ -584,7 +639,7 @@ static void rna_def_enum_property(BlenderRNA *brna, StructRNA *srna)
prop= RNA_def_property(srna, "items", PROP_COLLECTION, PROP_NONE);
RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
RNA_def_property_struct_type(prop, "EnumPropertyItem");
RNA_def_property_collection_funcs(prop, "rna_EnumProperty_items_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", 0, 0, 0, 0);
RNA_def_property_collection_funcs(prop, "rna_EnumProperty_items_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", 0, 0, 0);
RNA_def_property_ui_text(prop, "Items", "Possible values for the property.");
srna= RNA_def_struct(brna, "EnumPropertyItem", NULL);
@ -615,9 +670,9 @@ static void rna_def_pointer_property(StructRNA *srna, PropertyType type)
RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
RNA_def_property_struct_type(prop, "Struct");
if(type == PROP_POINTER)
RNA_def_property_pointer_funcs(prop, "rna_PointerProperty_fixed_type_get", NULL, NULL);
RNA_def_property_pointer_funcs(prop, "rna_PointerProperty_fixed_type_get", NULL);
else
RNA_def_property_pointer_funcs(prop, "rna_CollectionProperty_fixed_type_get", NULL, NULL);
RNA_def_property_pointer_funcs(prop, "rna_CollectionProperty_fixed_type_get", NULL);
RNA_def_property_ui_text(prop, "Pointer Type", "Fixed pointer type, empty if variable type.");
}
@ -674,7 +729,7 @@ void RNA_def_rna(BlenderRNA *brna)
prop= RNA_def_property(srna, "structs", PROP_COLLECTION, PROP_NONE);
RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
RNA_def_property_struct_type(prop, "Struct");
RNA_def_property_collection_funcs(prop, "rna_BlenderRNA_structs_begin", "rna_iterator_listbase_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get", 0, 0, 0, 0);
RNA_def_property_collection_funcs(prop, "rna_BlenderRNA_structs_begin", "rna_iterator_listbase_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get", 0, 0, 0);
RNA_def_property_ui_text(prop, "Structs", "");
}

View File

@ -38,23 +38,30 @@
#include "BKE_context.h"
#include "BKE_global.h"
void *rna_Scene_objects_get(CollectionPropertyIterator *iter)
PointerRNA rna_Scene_objects_get(CollectionPropertyIterator *iter)
{
ListBaseIterator *internal= iter->internal;
/* we are actually iterating a Base list, so override get */
return ((Base*)internal->link)->object;
return rna_pointer_inherit_refine(&iter->parent, &RNA_Object, ((Base*)internal->link)->object);
}
static void rna_Scene_layer_set(PointerRNA *ptr, int index, int value)
static void rna_Scene_layer_set(PointerRNA *ptr, const int *values)
{
Scene *scene= (Scene*)ptr->data;
int i, tot;
if(value) scene->lay |= (1<<index);
else {
scene->lay &= ~(1<<index);
if(scene->lay == 0)
scene->lay |= (1<<index);
/* ensure we always have some layer selected */
for(i=0; i<20; i++)
if(values[i])
tot++;
if(tot==0)
return;
for(i=0; i<20; i++) {
if(values[i]) scene->lay |= (1<<i);
else scene->lay &= ~(1<<i);
}
}
@ -175,7 +182,7 @@ void RNA_def_scene(BlenderRNA *brna)
RNA_def_property_collection_sdna(prop, NULL, "base", NULL);
RNA_def_property_struct_type(prop, "Object");
RNA_def_property_ui_text(prop, "Objects", "");
RNA_def_property_collection_funcs(prop, 0, 0, 0, "rna_Scene_objects_get", 0, 0, 0, 0);
RNA_def_property_collection_funcs(prop, 0, 0, 0, "rna_Scene_objects_get", 0, 0, 0);
prop= RNA_def_property(srna, "visible_layers", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "lay", 1);

View File

@ -75,7 +75,7 @@ static void rna_def_region(BlenderRNA *brna)
StructRNA *srna;
srna= RNA_def_struct(brna, "Region", NULL);
RNA_def_struct_ui_text(srna, "Region", "Region in a subdivid screen area.");
RNA_def_struct_ui_text(srna, "Region", "Region in a subdivided screen area.");
RNA_def_struct_sdna(srna, "ARegion");
}

View File

@ -98,12 +98,12 @@ static StructRNA* rna_Sequence_refine(struct PointerRNA *ptr)
}
}
static void *rna_SequenceEdtior_meta_stack_get(CollectionPropertyIterator *iter)
static PointerRNA rna_SequenceEdtior_meta_stack_get(CollectionPropertyIterator *iter)
{
ListBaseIterator *internal= iter->internal;
MetaStack *ms= (MetaStack*)internal->link;
return (Sequence*)ms->parseq;
return rna_pointer_inherit_refine(&iter->parent, &RNA_Sequence, ms->parseq);
}
#else
@ -154,7 +154,7 @@ static void rna_def_strip_transform(BlenderRNA *brna)
PropertyRNA *prop;
srna = RNA_def_struct(brna, "SequenceTransform", NULL);
RNA_def_struct_ui_text(srna, "Sequence Transform", "Transform paramaters for a sequence strip.");
RNA_def_struct_ui_text(srna, "Sequence Transform", "Transform parameters for a sequence strip.");
RNA_def_struct_sdna(srna, "StripTransform");
prop= RNA_def_property(srna, "offset_x", PROP_INT, PROP_NONE);
@ -188,7 +188,7 @@ static void rna_def_strip_color_balance(BlenderRNA *brna)
PropertyRNA *prop;
srna = RNA_def_struct(brna, "SequenceColorBalance", NULL);
RNA_def_struct_ui_text(srna, "Sequence Color Balance", "Color balance paramaters for a sequence strip.");
RNA_def_struct_ui_text(srna, "Sequence Color Balance", "Color balance parameters for a sequence strip.");
RNA_def_struct_sdna(srna, "StripColorBalance");
prop= RNA_def_property(srna, "lift", PROP_FLOAT, PROP_COLOR);
@ -384,7 +384,7 @@ void rna_def_editor(BlenderRNA *brna)
RNA_def_property_collection_sdna(prop, NULL, "metastack", NULL);
RNA_def_property_struct_type(prop, "Sequence");
RNA_def_property_ui_text(prop, "Meta Stack", "Meta strip stack, last is currently edited meta strip.");
RNA_def_property_collection_funcs(prop, 0, 0, 0, "rna_SequenceEdtior_meta_stack_get", 0, 0, 0, 0);
RNA_def_property_collection_funcs(prop, 0, 0, 0, "rna_SequenceEdtior_meta_stack_get", 0, 0, 0);
}
static void rna_def_filter_video(StructRNA *srna)

View File

@ -98,7 +98,7 @@ static void rna_def_soundlistener(BlenderRNA *brna)
srna= RNA_def_struct(brna, "SoundListener", "ID");
RNA_def_struct_sdna(srna, "bSoundListener");
RNA_def_struct_ui_text(srna, "Sound Listener", "Sound listener defining paramaters about how sounds are played.");
RNA_def_struct_ui_text(srna, "Sound Listener", "Sound listener defining parameters about how sounds are played.");
prop= RNA_def_property(srna, "gain", PROP_FLOAT, PROP_NONE);
RNA_def_property_ui_text(prop, "Gain", "Overall volume for Game Engine sound.");

View File

@ -75,9 +75,9 @@ static StructRNA* rna_Space_refine(struct PointerRNA *ptr)
}
}
static void *rna_SpaceImage_self_get(PointerRNA *ptr)
static PointerRNA rna_SpaceImage_uvedit_get(PointerRNA *ptr)
{
return ptr->id.data;
return rna_pointer_inherit_refine(ptr, &RNA_SpaceUVEditor, ptr->data);
}
#else
@ -264,7 +264,7 @@ static void rna_def_space_image(BlenderRNA *brna)
/* uv */
prop= RNA_def_property(srna, "uv_editor", PROP_POINTER, PROP_NEVER_NULL);
RNA_def_property_struct_type(prop, "SpaceUVEditor");
RNA_def_property_pointer_funcs(prop, "rna_SpaceImage_self_get", NULL, NULL);
RNA_def_property_pointer_funcs(prop, "rna_SpaceImage_uvedit_get", NULL);
RNA_def_property_ui_text(prop, "UV Editor", "UV editor settings.");
/* paint */

View File

@ -83,6 +83,7 @@ static int rna_TextLine_line_length(PointerRNA *ptr)
return line->len;
}
#if 0
static void rna_TextLine_line_set(PointerRNA *ptr, const char *value)
{
TextLine *line= (TextLine*)ptr->data;
@ -99,6 +100,7 @@ static void rna_TextLine_line_set(PointerRNA *ptr, const char *value)
line->len= 0;
}
}
#endif
#else

View File

@ -86,11 +86,35 @@ static void rna_userdef_autokeymode_set(struct PointerRNA *ptr,int value)
}
}
static void *rna_UserDef_self_get(PointerRNA *ptr)
static PointerRNA rna_UserDef_view_get(PointerRNA *ptr)
{
return ptr->data;
return rna_pointer_inherit_refine(ptr, &RNA_UserPreferencesView, ptr->data);
}
static PointerRNA rna_UserDef_edit_get(PointerRNA *ptr)
{
return rna_pointer_inherit_refine(ptr, &RNA_UserPreferencesEdit, ptr->data);
}
static PointerRNA rna_UserDef_autosave_get(PointerRNA *ptr)
{
return rna_pointer_inherit_refine(ptr, &RNA_UserPreferencesAutosave, ptr->data);
}
static PointerRNA rna_UserDef_language_get(PointerRNA *ptr)
{
return rna_pointer_inherit_refine(ptr, &RNA_UserPreferencesLanguage, ptr->data);
}
static PointerRNA rna_UserDef_filepaths_get(PointerRNA *ptr)
{
return rna_pointer_inherit_refine(ptr, &RNA_UserPreferencesFilePaths, ptr->data);
}
static PointerRNA rna_UserDef_system_get(PointerRNA *ptr)
{
return rna_pointer_inherit_refine(ptr, &RNA_UserPreferencesSystem, ptr->data);
}
#else
@ -1753,34 +1777,34 @@ void RNA_def_userdef(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Themes", "");
/* nested structs */
prop= RNA_def_property(srna, "userpreferences_view", PROP_POINTER, PROP_NEVER_NULL);
prop= RNA_def_property(srna, "view", PROP_POINTER, PROP_NEVER_NULL);
RNA_def_property_struct_type(prop, "UserPreferencesView");
RNA_def_property_pointer_funcs(prop, "rna_UserDef_self_get", NULL, NULL);
RNA_def_property_pointer_funcs(prop, "rna_UserDef_view_get", NULL);
RNA_def_property_ui_text(prop, "View & Controls", "Preferences related to viewing data.");
prop= RNA_def_property(srna, "userpreferences_edit", PROP_POINTER, PROP_NEVER_NULL);
prop= RNA_def_property(srna, "edit", PROP_POINTER, PROP_NEVER_NULL);
RNA_def_property_struct_type(prop, "UserPreferencesEdit");
RNA_def_property_pointer_funcs(prop, "rna_UserDef_self_get", NULL, NULL);
RNA_def_property_pointer_funcs(prop, "rna_UserDef_edit_get", NULL);
RNA_def_property_ui_text(prop, "Edit Methods", "Settings for interacting with Blender data.");
prop= RNA_def_property(srna, "userpreferences_autosave", PROP_POINTER, PROP_NEVER_NULL);
prop= RNA_def_property(srna, "autosave", PROP_POINTER, PROP_NEVER_NULL);
RNA_def_property_struct_type(prop, "UserPreferencesAutosave");
RNA_def_property_pointer_funcs(prop, "rna_UserDef_self_get", NULL, NULL);
RNA_def_property_pointer_funcs(prop, "rna_UserDef_autosave_get", NULL);
RNA_def_property_ui_text(prop, "Auto Save", "Automatic backup file settings.");
prop= RNA_def_property(srna, "userpreferences_language", PROP_POINTER, PROP_NEVER_NULL);
prop= RNA_def_property(srna, "language", PROP_POINTER, PROP_NEVER_NULL);
RNA_def_property_struct_type(prop, "UserPreferencesLanguage");
RNA_def_property_pointer_funcs(prop, "rna_UserDef_self_get", NULL, NULL);
RNA_def_property_pointer_funcs(prop, "rna_UserDef_language_get", NULL);
RNA_def_property_ui_text(prop, "Language & Font", "User interface translation settings.");
prop= RNA_def_property(srna, "userpreferences_filepaths", PROP_POINTER, PROP_NEVER_NULL);
prop= RNA_def_property(srna, "filepaths", PROP_POINTER, PROP_NEVER_NULL);
RNA_def_property_struct_type(prop, "UserPreferencesFilePaths");
RNA_def_property_pointer_funcs(prop, "rna_UserDef_self_get", NULL, NULL);
RNA_def_property_pointer_funcs(prop, "rna_UserDef_filepaths_get", NULL);
RNA_def_property_ui_text(prop, "File Paths", "Default paths for external files.");
prop= RNA_def_property(srna, "userpreferences_system", PROP_POINTER, PROP_NEVER_NULL);
prop= RNA_def_property(srna, "system", PROP_POINTER, PROP_NEVER_NULL);
RNA_def_property_struct_type(prop, "UserPreferencesSystem");
RNA_def_property_pointer_funcs(prop, "rna_UserDef_self_get", NULL, NULL);
RNA_def_property_pointer_funcs(prop, "rna_UserDef_system_get", NULL);
RNA_def_property_ui_text(prop, "System & OpenGL", "Graphics driver and operating system settings.");
rna_def_userdef_view(brna);

View File

@ -69,10 +69,10 @@ static int rna_Operator_name_length(PointerRNA *ptr)
return strlen(op->type->name);
}
static void *rna_Operator_properties_get(PointerRNA *ptr)
static PointerRNA rna_Operator_properties_get(PointerRNA *ptr)
{
wmOperator *op= (wmOperator*)ptr->data;
return op->properties;
return rna_pointer_inherit_refine(ptr, &RNA_OperatorProperties, op->properties);
}
#else
@ -83,7 +83,7 @@ static void rna_def_operator(BlenderRNA *brna)
PropertyRNA *prop;
srna= RNA_def_struct(brna, "Operator", NULL);
RNA_def_struct_ui_text(srna, "Operator", "Storage of an operator being or executed, or registered after execution.");
RNA_def_struct_ui_text(srna, "Operator", "Storage of an operator being executed, or registered after execution.");
RNA_def_struct_sdna(srna, "wmOperator");
prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
@ -95,7 +95,7 @@ static void rna_def_operator(BlenderRNA *brna)
prop= RNA_def_property(srna, "properties", PROP_POINTER, PROP_NEVER_NULL);
RNA_def_property_struct_type(prop, "OperatorProperties");
RNA_def_property_ui_text(prop, "Properties", "");
RNA_def_property_pointer_funcs(prop, "rna_Operator_properties_get", NULL, NULL);
RNA_def_property_pointer_funcs(prop, "rna_Operator_properties_get", NULL);
srna= RNA_def_struct(brna, "OperatorProperties", NULL);
RNA_def_struct_ui_text(srna, "Operator Properties", "Input properties of an Operator.");

View File

@ -36,19 +36,19 @@
#ifdef RNA_RUNTIME
static void *rna_World_ambient_occlusion_get(PointerRNA *ptr)
static PointerRNA rna_World_ambient_occlusion_get(PointerRNA *ptr)
{
return ptr->id.data;
return rna_pointer_inherit_refine(ptr, &RNA_WorldAmbientOcclusion, ptr->id.data);
}
static void *rna_World_stars_get(PointerRNA *ptr)
static PointerRNA rna_World_stars_get(PointerRNA *ptr)
{
return ptr->id.data;
return rna_pointer_inherit_refine(ptr, &RNA_WorldStarsSettings, ptr->id.data);
}
static void *rna_World_mist_get(PointerRNA *ptr)
static PointerRNA rna_World_mist_get(PointerRNA *ptr)
{
return ptr->id.data;
return rna_pointer_inherit_refine(ptr, &RNA_WorldMistSettings, ptr->id.data);
}
static void rna_World_mtex_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
@ -57,11 +57,11 @@ static void rna_World_mtex_begin(CollectionPropertyIterator *iter, PointerRNA *p
rna_iterator_array_begin(iter, (void*)wo->mtex, sizeof(MTex*), MAX_MTEX, NULL);
}
static void *rna_World_active_texture_get(PointerRNA *ptr)
static PointerRNA rna_World_active_texture_get(PointerRNA *ptr)
{
World *wo= (World*)ptr->data;
return wo->mtex[(int)wo->texact];
return rna_pointer_inherit_refine(ptr, &RNA_TextureSlot, wo->mtex[(int)wo->texact]);
}
#else
@ -137,7 +137,7 @@ static void rna_def_ambient_occlusion(BlenderRNA *brna)
static EnumPropertyItem prop_sample_method_items[] = {
{WO_AOSAMP_CONSTANT, "CONSTANT_JITTERED", "Constant Jittered", ""},
{WO_AOSAMP_HALTON, "ADAPTIVE_QMC", "Adaptive QMC", "Fast in high-contrast areas."},
{WO_AOSAMP_HAMMERSLEY, "ADAPTIVE_QMC", "Constant QMC", "Best quality."},
{WO_AOSAMP_HAMMERSLEY, "CONSTANT_QMC", "Constant QMC", "Best quality."},
{0, NULL, NULL, NULL}};
static EnumPropertyItem prop_gather_method_items[] = {
@ -396,17 +396,17 @@ void RNA_def_world(BlenderRNA *brna)
/* nested structs */
prop= RNA_def_property(srna, "ambient_occlusion", PROP_POINTER, PROP_NEVER_NULL);
RNA_def_property_struct_type(prop, "WorldAmbientOcclusion");
RNA_def_property_pointer_funcs(prop, "rna_World_ambient_occlusion_get", NULL, NULL);
RNA_def_property_pointer_funcs(prop, "rna_World_ambient_occlusion_get", NULL);
RNA_def_property_ui_text(prop, "Ambient Occlusion", "World ambient occlusion settings.");
prop= RNA_def_property(srna, "mist", PROP_POINTER, PROP_NEVER_NULL);
RNA_def_property_struct_type(prop, "WorldMistSettings");
RNA_def_property_pointer_funcs(prop, "rna_World_mist_get", NULL, NULL);
RNA_def_property_pointer_funcs(prop, "rna_World_mist_get", NULL);
RNA_def_property_ui_text(prop, "Mist", "World mist settings.");
prop= RNA_def_property(srna, "stars", PROP_POINTER, PROP_NEVER_NULL);
RNA_def_property_struct_type(prop, "WorldStarsSettings");
RNA_def_property_pointer_funcs(prop, "rna_World_stars_get", NULL, NULL);
RNA_def_property_pointer_funcs(prop, "rna_World_stars_get", NULL);
RNA_def_property_ui_text(prop, "Stars", "World stars settings.");
prop= RNA_def_property(srna, "script_link", PROP_POINTER, PROP_NEVER_NULL);

View File

@ -163,7 +163,7 @@ PyObject * pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop)
case PROP_POINTER:
{
PointerRNA newptr;
RNA_property_pointer_get(ptr, prop, &newptr);
newptr= RNA_property_pointer_get(ptr, prop);
if (newptr.data) {
ret = pyrna_struct_CreatePyObject(&newptr);
} else {
@ -209,7 +209,7 @@ int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, PyObject *value)
switch (type) {
case PROP_BOOLEAN:
{
signed char *param_arr = MEM_mallocN(sizeof(char) * len, "pyrna bool array");
int *param_arr = MEM_mallocN(sizeof(char) * len, "pyrna bool array");
/* collect the variables before assigning, incase one of them is incorrect */
for (i=0; i<len; i++) {
@ -224,9 +224,7 @@ int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, PyObject *value)
}
}
for (i=0; i<len; i++) {
RNA_property_boolean_set_array(ptr, prop, i, param_arr[i]);
}
RNA_property_boolean_set_array(ptr, prop, param_arr);
MEM_freeN(param_arr);
break;
@ -248,9 +246,7 @@ int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, PyObject *value)
return -1;
}
for (i=0; i<len; i++) {
RNA_property_int_set_array(ptr, prop, i, param_arr[i]);
}
RNA_property_int_set_array(ptr, prop, param_arr);
MEM_freeN(param_arr);
break;
@ -272,9 +268,7 @@ int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, PyObject *value)
return -1;
}
for (i=0; i<len; i++) {
RNA_property_float_set_array(ptr, prop, i, param_arr[i]);
}
RNA_property_float_set_array(ptr, prop, param_arr);
MEM_freeN(param_arr);
break;
@ -385,13 +379,13 @@ static PyObject * pyrna_prop_to_py_index(PointerRNA *ptr, PropertyRNA *prop, int
/* see if we can coorce into a python type - PropertyType */
switch (type) {
case PROP_BOOLEAN:
ret = PyBool_FromLong( RNA_property_boolean_get_array(ptr, prop, index) );
ret = PyBool_FromLong( RNA_property_boolean_get_index(ptr, prop, index) );
break;
case PROP_INT:
ret = PyLong_FromSize_t( (size_t)RNA_property_int_get_array(ptr, prop, index) );
ret = PyLong_FromSize_t( (size_t)RNA_property_int_get_index(ptr, prop, index) );
break;
case PROP_FLOAT:
ret = PyFloat_FromDouble( RNA_property_float_get_array(ptr, prop, index) );
ret = PyFloat_FromDouble( RNA_property_float_get_index(ptr, prop, index) );
break;
default:
PyErr_SetString(PyExc_AttributeError, "not an array type");
@ -419,7 +413,7 @@ static int pyrna_py_to_prop_index(PointerRNA *ptr, PropertyRNA *prop, int index,
PyErr_SetString(PyExc_TypeError, "expected True/False or 0/1");
ret = -1;
} else {
RNA_property_boolean_set_array(ptr, prop, index, param);
RNA_property_boolean_set_index(ptr, prop, index, param);
}
break;
}
@ -430,7 +424,7 @@ static int pyrna_py_to_prop_index(PointerRNA *ptr, PropertyRNA *prop, int index,
PyErr_SetString(PyExc_TypeError, "expected an int type");
ret = -1;
} else {
RNA_property_int_set_array(ptr, prop, index, param);
RNA_property_int_set_index(ptr, prop, index, param);
}
break;
}
@ -441,7 +435,7 @@ static int pyrna_py_to_prop_index(PointerRNA *ptr, PropertyRNA *prop, int index,
PyErr_SetString(PyExc_TypeError, "expected a float type");
ret = -1;
} else {
RNA_property_float_set_array(ptr, prop, index, param);
RNA_property_float_set_index(ptr, prop, index, param);
}
break;
}
@ -679,7 +673,7 @@ PyObject *pyrna_struct_to_docstring(BPy_StructRNA *self)
// TODO - why does this crash sometimes
// PointerRNA newptr;
// RNA_property_pointer_get(&iter.ptr, prop, &newptr);
// newptr= RNA_property_pointer_get(&iter.ptr, prop);
// Use this instead, its not that useful
BLI_dynstr_appendf(dynstr, "@type %s: PyRNA %s\n", identifier, RNA_struct_identifier(&iter.ptr));