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-02-02 22:57:57 +0300
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2009-02-02 22:57:57 +0300
commit284db61572125c8b2a916a20e5a4333ea72440dc (patch)
tree826d68aaccaee0cba7855955cc0e5dcf3a90ef62 /source/blender/makesrna/intern/rna_define.c
parenteb00687cde2fd5724b22a8831d3294f4846ff934 (diff)
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
Diffstat (limited to 'source/blender/makesrna/intern/rna_define.c')
-rw-r--r--source/blender/makesrna/intern/rna_define.c68
1 files changed, 13 insertions, 55 deletions
diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c
index da3bc584266..1393f266734 100644
--- a/source/blender/makesrna/intern/rna_define.c
+++ b/source/blender/makesrna/intern/rna_define.c
@@ -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;