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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2009-08-18 05:29:25 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2009-08-18 05:29:25 +0400
commit4fb19159ea47027bbaf31d379da3d6b0ea0f0f28 (patch)
treeb50c21dd7873b33912516c9f59429afec5a856c7 /source/blender/makesrna/intern/rna_access.c
parenta5da26f59d8cd820ca4d27a06028dd6aaee65784 (diff)
2.5: RNA, defining enums, pointers and collections properties is now
possible from python, but it's still work in progress. Pointers and collections are restricted to types derived from IDPropertyGroup (same as for operators), because RNA knows how to allocate/deallocate those. Collections have .add() and .remove(number) functions that can be used. The remove function should be fixed to take an other argument than a number. With the IDPropertyGroup restriction, pointers are more like nested structs. They don't have add(), remove() yet, not sure where to put them. Currently the pointer / nested struct is automatically allocated in the get() function, this needs to be fixed, rule is that RNA get() will not change any data for thread safety. Also, it is only possible to add properties to structs after they have been registered, which needs to be improved as well. Example code: http://www.pasteall.org/7201/python
Diffstat (limited to 'source/blender/makesrna/intern/rna_access.c')
-rw-r--r--source/blender/makesrna/intern/rna_access.c36
1 files changed, 23 insertions, 13 deletions
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index 2de59586611..54cde57a54f 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -1259,8 +1259,15 @@ PointerRNA RNA_property_pointer_get(PointerRNA *ptr, PropertyRNA *prop)
else if(pprop->get) {
return pprop->get(ptr);
}
+ else if(prop->flag & PROP_IDPROPERTY) {
+ /* XXX temporary hack to add it automatically, reading should
+ never do any write ops, to ensure thread safety etc .. */
+ RNA_property_pointer_add(ptr, prop);
+ return RNA_property_pointer_get(ptr, prop);
+ }
else {
PointerRNA result;
+
memset(&result, 0, sizeof(result));
return result;
}
@@ -1398,7 +1405,7 @@ int RNA_property_collection_length(PointerRNA *ptr, PropertyRNA *prop)
void RNA_property_collection_add(PointerRNA *ptr, PropertyRNA *prop, PointerRNA *r_ptr)
{
IDProperty *idprop;
- //CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
+ CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
if((idprop=rna_idproperty_check(&prop, ptr))) {
IDPropertyTemplate val = {0};
@@ -1424,7 +1431,6 @@ void RNA_property_collection_add(PointerRNA *ptr, PropertyRNA *prop, PointerRNA
MEM_freeN(item);
}
}
-#if 0
else if(cprop->add){
if(!(cprop->add->flag & FUNC_USE_CONTEXT)) { /* XXX check for this somewhere else */
ParameterList params;
@@ -1433,9 +1439,8 @@ void RNA_property_collection_add(PointerRNA *ptr, PropertyRNA *prop, PointerRNA
RNA_parameter_list_free(&params);
}
}
-#endif
- else
- printf("RNA_property_collection_add %s.%s: not implemented for this property.\n", ptr->type->identifier, prop->identifier);
+ /*else
+ printf("RNA_property_collection_add %s.%s: not implemented for this property.\n", ptr->type->identifier, prop->identifier);*/
if(r_ptr) {
if(idprop) {
@@ -1450,10 +1455,10 @@ void RNA_property_collection_add(PointerRNA *ptr, PropertyRNA *prop, PointerRNA
}
}
-void RNA_property_collection_remove(PointerRNA *ptr, PropertyRNA *prop, int key)
+int RNA_property_collection_remove(PointerRNA *ptr, PropertyRNA *prop, int key)
{
IDProperty *idprop;
- //CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
+ CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
if((idprop=rna_idproperty_check(&prop, ptr))) {
IDProperty tmp, *array;
@@ -1472,20 +1477,25 @@ void RNA_property_collection_remove(PointerRNA *ptr, PropertyRNA *prop, int key)
IDP_ResizeIDPArray(idprop, len-1);
}
+
+ return 1;
}
- else if(prop->flag & PROP_IDPROPERTY);
-#if 0
+ else if(prop->flag & PROP_IDPROPERTY)
+ return 1;
else if(cprop->remove){
if(!(cprop->remove->flag & FUNC_USE_CONTEXT)) { /* XXX check for this somewhere else */
ParameterList params;
- RNA_parameter_list_create(&ptr, cprop->remove);
+ RNA_parameter_list_create(&params, ptr, cprop->remove);
RNA_function_call(NULL, NULL, ptr, cprop->remove, &params);
RNA_parameter_list_free(&params);
}
+
+ return 0;
}
-#endif
- else
- printf("RNA_property_collection_remove %s.%s: only supported for id properties.\n", ptr->type->identifier, prop->identifier);
+ /*else
+ printf("RNA_property_collection_remove %s.%s: only supported for id properties.\n", ptr->type->identifier, prop->identifier);*/
+
+ return 0;
}
void RNA_property_collection_clear(PointerRNA *ptr, PropertyRNA *prop)