[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [24549] trunk/blender/source/blender: arbitrary property and function support for rna properties ( arrays and collections), this means functions can be easily added.
Campbell Barton
ideasman42 at gmail.com
Fri Nov 13 17:08:03 CET 2009
Revision: 24549
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=24549
Author: campbellbarton
Date: 2009-11-13 17:08:03 +0100 (Fri, 13 Nov 2009)
Log Message:
-----------
arbitrary property and function support for rna properties (arrays and collections), this means functions can be easily added.
eg.
scene.objects.link()
object.constraints.new()
mesh.verts.transform(...)
mesh.faces.active
PropertyRNA stores an StructRNA pointer where these can be defined.
Modified Paths:
--------------
trunk/blender/source/blender/makesrna/RNA_access.h
trunk/blender/source/blender/makesrna/RNA_define.h
trunk/blender/source/blender/makesrna/intern/makesrna.c
trunk/blender/source/blender/makesrna/intern/rna_access.c
trunk/blender/source/blender/makesrna/intern/rna_armature.c
trunk/blender/source/blender/makesrna/intern/rna_color.c
trunk/blender/source/blender/makesrna/intern/rna_curve.c
trunk/blender/source/blender/makesrna/intern/rna_define.c
trunk/blender/source/blender/makesrna/intern/rna_fcurve.c
trunk/blender/source/blender/makesrna/intern/rna_fcurve_api.c
trunk/blender/source/blender/makesrna/intern/rna_group.c
trunk/blender/source/blender/makesrna/intern/rna_internal_types.h
trunk/blender/source/blender/makesrna/intern/rna_key.c
trunk/blender/source/blender/makesrna/intern/rna_lattice.c
trunk/blender/source/blender/makesrna/intern/rna_main.c
trunk/blender/source/blender/makesrna/intern/rna_material.c
trunk/blender/source/blender/makesrna/intern/rna_mesh.c
trunk/blender/source/blender/makesrna/intern/rna_modifier.c
trunk/blender/source/blender/makesrna/intern/rna_object.c
trunk/blender/source/blender/makesrna/intern/rna_object_api.c
trunk/blender/source/blender/makesrna/intern/rna_object_force.c
trunk/blender/source/blender/makesrna/intern/rna_pose.c
trunk/blender/source/blender/makesrna/intern/rna_pose_api.c
trunk/blender/source/blender/makesrna/intern/rna_render.c
trunk/blender/source/blender/makesrna/intern/rna_rna.c
trunk/blender/source/blender/makesrna/intern/rna_scene.c
trunk/blender/source/blender/makesrna/intern/rna_sculpt_paint.c
trunk/blender/source/blender/makesrna/intern/rna_sequence.c
trunk/blender/source/blender/python/intern/bpy_operator_wrap.c
trunk/blender/source/blender/python/intern/bpy_rna.c
Modified: trunk/blender/source/blender/makesrna/RNA_access.h
===================================================================
--- trunk/blender/source/blender/makesrna/RNA_access.h 2009-11-13 15:48:45 UTC (rev 24548)
+++ trunk/blender/source/blender/makesrna/RNA_access.h 2009-11-13 16:08:03 UTC (rev 24549)
@@ -683,11 +683,8 @@
int RNA_property_collection_lookup_index(PointerRNA *ptr, PropertyRNA *prop, PointerRNA *t_ptr);
int RNA_property_collection_lookup_int(PointerRNA *ptr, PropertyRNA *prop, int key, PointerRNA *r_ptr);
int RNA_property_collection_lookup_string(PointerRNA *ptr, PropertyRNA *prop, const char *key, PointerRNA *r_ptr);
+int RNA_property_collection_type_get(PointerRNA *ptr, PropertyRNA *prop, PointerRNA *r_ptr);
-PropertyRNA *RNA_property_collection_active(PropertyRNA *prop);
-FunctionRNA *RNA_property_collection_add_func(PropertyRNA *prop);
-FunctionRNA *RNA_property_collection_remove_func(PropertyRNA *prop);
-
/* efficient functions to set properties for arrays */
int RNA_property_collection_raw_array(PointerRNA *ptr, PropertyRNA *prop, PropertyRNA *itemprop, RawArray *array);
int RNA_property_collection_raw_get(struct ReportList *reports, PointerRNA *ptr, PropertyRNA *prop, char *propname, void *array, RawPropertyType type, int len);
Modified: trunk/blender/source/blender/makesrna/RNA_define.h
===================================================================
--- trunk/blender/source/blender/makesrna/RNA_define.h 2009-11-13 15:48:45 UTC (rev 24548)
+++ trunk/blender/source/blender/makesrna/RNA_define.h 2009-11-13 16:08:03 UTC (rev 24549)
@@ -163,8 +163,8 @@
void RNA_def_property_enum_funcs(PropertyRNA *prop, const char *get, const char *set, const char *item);
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 *set, const char *typef);
-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, const char *add, const char *remove);
-void RNA_def_property_collection_active(PropertyRNA *prop, PropertyRNA *prop_act);
+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);
+void RNA_def_property_srna(PropertyRNA *prop, const char *type);
/* Function */
Modified: trunk/blender/source/blender/makesrna/intern/makesrna.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/makesrna.c 2009-11-13 15:48:45 UTC (rev 24548)
+++ trunk/blender/source/blender/makesrna/intern/makesrna.c 2009-11-13 16:08:03 UTC (rev 24549)
@@ -369,7 +369,7 @@
if(strcmp(manualfunc, "rna_iterator_listbase_get") == 0 ||
strcmp(manualfunc, "rna_iterator_array_get") == 0 ||
strcmp(manualfunc, "rna_iterator_array_dereference_get") == 0)
- fprintf(f, " return rna_pointer_inherit_refine(&iter->parent, &RNA_%s, %s(iter));\n", (cprop->type)? (char*)cprop->type: "UnknownType", manualfunc);
+ fprintf(f, " return rna_pointer_inherit_refine(&iter->parent, &RNA_%s, %s(iter));\n", (cprop->item_type)? (char*)cprop->item_type: "UnknownType", manualfunc);
else
fprintf(f, " return %s(iter);\n", manualfunc);
}
@@ -965,7 +965,7 @@
DefRNA.error= 1;
}
}
- if(!cprop->type) {
+ if(!cprop->item_type) {
fprintf(stderr, "rna_def_property_funcs: %s.%s, collection must have a struct type.\n", srna->identifier, prop->identifier);
DefRNA.error= 1;
}
@@ -1132,8 +1132,8 @@
case PROP_COLLECTION: {
CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)dp->prop;
- if(cprop->type)
- fprintf(f, "\tCOLLECTION_PROPERTY(%s, %s, %s)", (char*)cprop->type, srna->identifier, prop->identifier);
+ if(cprop->item_type)
+ fprintf(f, "\tCOLLECTION_PROPERTY(%s, %s, %s)", (char*)cprop->item_type, srna->identifier, prop->identifier);
else
fprintf(f, "\tCOLLECTION_PROPERTY(%s, %s, %s)", "UnknownType", srna->identifier, prop->identifier);
break;
@@ -1357,8 +1357,8 @@
else if(dp->prop->type== PROP_COLLECTION) {
CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)dp->prop;
- if(!cprop->type && !cprop->get && strcmp(dp->dnatype, "ListBase")==0)
- cprop->type= (StructRNA*)rna_find_type(dp->dnatype);
+ if(!cprop->item_type && !cprop->get && strcmp(dp->dnatype, "ListBase")==0)
+ cprop->item_type= (StructRNA*)rna_find_type(dp->dnatype);
}
}
}
@@ -1767,6 +1767,11 @@
if(prop->flag & PROP_RAW_ACCESS) rna_set_raw_offset(f, srna, prop);
else fprintf(f, "\t0, 0");
+
+ /* our own type - collections/arrays only */
+ if(prop->srna) fprintf(f, ", &RNA_%s", (char*)prop->srna);
+ else fprintf(f, ", NULL");
+
fprintf(f, "},\n");
switch(prop->type) {
@@ -1830,13 +1835,7 @@
case PROP_COLLECTION: {
CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
fprintf(f, "\t%s, %s, %s, %s, %s, %s, %s, ", rna_function_string(cprop->begin), rna_function_string(cprop->next), rna_function_string(cprop->end), rna_function_string(cprop->get), rna_function_string(cprop->length), rna_function_string(cprop->lookupint), rna_function_string(cprop->lookupstring));
- if(cprop->add) fprintf(f, "&rna_%s_%s_func, ", srna->identifier, (char*)cprop->add);
- else fprintf(f, "NULL, ");
- if(cprop->remove) fprintf(f, "&rna_%s_%s_func, ", srna->identifier, (char*)cprop->remove);
- else fprintf(f, "NULL, ");
- if(cprop->active) fprintf(f, "(PropertyRNA*)&rna_%s%s_%s, ", srna->identifier, strnest, cprop->active->identifier);
- else fprintf(f, "NULL, ");
- if(cprop->type) fprintf(f, "&RNA_%s\n", (char*)cprop->type);
+ if(cprop->item_type) fprintf(f, "&RNA_%s\n", (char*)cprop->item_type);
else fprintf(f, "NULL\n");
break;
}
Modified: trunk/blender/source/blender/makesrna/intern/rna_access.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_access.c 2009-11-13 15:48:45 UTC (rev 24548)
+++ trunk/blender/source/blender/makesrna/intern/rna_access.c 2009-11-13 16:08:03 UTC (rev 24549)
@@ -727,8 +727,8 @@
else if(prop->type == PROP_COLLECTION) {
CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
- if(cprop->type)
- return cprop->type;
+ if(cprop->item_type)
+ return cprop->item_type;
}
return &RNA_UnknownType;
@@ -1490,8 +1490,8 @@
CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)iter->prop;
iter->ptr.data= rna_iterator_array_get(iter);
- iter->ptr.type= cprop->type;
- rna_pointer_inherit_id(cprop->type, &iter->parent, &iter->ptr);
+ iter->ptr.type= cprop->item_type;
+ rna_pointer_inherit_id(cprop->item_type, &iter->parent, &iter->ptr);
}
void RNA_property_collection_begin(PointerRNA *ptr, PropertyRNA *prop, CollectionPropertyIterator *iter)
@@ -1617,7 +1617,7 @@
CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
r_ptr->data= IDP_GetIndexArray(idprop, idprop->len-1);
- r_ptr->type= cprop->type;
+ r_ptr->type= cprop->item_type;
rna_pointer_inherit_id(NULL, ptr, r_ptr);
}
else
@@ -1772,24 +1772,12 @@
}
}
-PropertyRNA *RNA_property_collection_active(PropertyRNA *prop)
+int RNA_property_collection_type_get(PointerRNA *ptr, PropertyRNA *prop, PointerRNA *r_ptr)
{
- CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
- return cprop->active;
+ *r_ptr= *ptr;
+ return ((r_ptr->type = prop->srna));
}
-FunctionRNA *RNA_property_collection_add_func(PropertyRNA *prop)
-{
- CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
- return cprop->add;
-}
-
-FunctionRNA *RNA_property_collection_remove_func(PropertyRNA *prop)
-{
- CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
- return cprop->remove;
-}
-
int RNA_property_collection_raw_array(PointerRNA *ptr, PropertyRNA *prop, PropertyRNA *itemprop, RawArray *array)
{
CollectionPropertyIterator iter;
Modified: trunk/blender/source/blender/makesrna/intern/rna_armature.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_armature.c 2009-11-13 15:48:45 UTC (rev 24548)
+++ trunk/blender/source/blender/makesrna/intern/rna_armature.c 2009-11-13 16:08:03 UTC (rev 24549)
@@ -663,7 +663,7 @@
/* Collections */
prop= RNA_def_property(srna, "bones", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "bonebase", NULL);
- RNA_def_property_collection_funcs(prop, 0, "rna_Armature_bones_next", 0, 0, 0, 0, 0, 0, 0);
+ RNA_def_property_collection_funcs(prop, 0, "rna_Armature_bones_next", 0, 0, 0, 0, 0);
RNA_def_property_struct_type(prop, "Bone");
RNA_def_property_ui_text(prop, "Bones", "");
@@ -676,7 +676,7 @@
RNA_def_property_pointer_funcs(prop_act, NULL, "rna_Armature_act_bone_set", NULL);
/* todo, redraw */
- RNA_def_property_collection_active(prop, prop_act);
+// RNA_def_property_collection_active(prop, prop_act);
}
prop= RNA_def_property(srna, "edit_bones", PROP_COLLECTION, PROP_NONE);
@@ -692,7 +692,7 @@
RNA_def_property_ui_text(prop_act, "Active EditBone", "Armatures active edit bone.");
//RNA_def_property_update(prop_act, 0, "rna_Armature_act_editbone_update");
RNA_def_property_pointer_funcs(prop_act, NULL, "rna_Armature_act_edit_bone_set", NULL);
- RNA_def_property_collection_active(prop, prop_act);
+// RNA_def_property_collection_active(prop, prop_act);
}
/* Enum values */
Modified: trunk/blender/source/blender/makesrna/intern/rna_color.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_color.c 2009-11-13 15:48:45 UTC (rev 24548)
+++ trunk/blender/source/blender/makesrna/intern/rna_color.c 2009-11-13 16:08:03 UTC (rev 24549)
@@ -212,7 +212,7 @@
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", "rna_CurveMapping_curves_length", 0, 0, 0, 0);
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list