[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [20288] branches/blender2.5/blender/source /blender/makesrna: RNA:

Brecht Van Lommel brecht at blender.org
Wed May 20 11:52:02 CEST 2009


Revision: 20288
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=20288
Author:   blendix
Date:     2009-05-20 11:52:02 +0200 (Wed, 20 May 2009)

Log Message:
-----------
RNA:
* Any Struct can now have ID properties, by creating a callback
  function to create/return an IDProperty.
* Wrapped PoseChannel ID properties.
* Note there is still no way to create ID Properties in 2.5, though
  the callback to get/create the initial group is now exposed through
  RNA_struct_idproperties.

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/makesrna/RNA_access.h
    branches/blender2.5/blender/source/blender/makesrna/RNA_define.h
    branches/blender2.5/blender/source/blender/makesrna/intern/makesrna.c
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_ID.c
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_access.c
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_define.c
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_internal.h
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_internal_types.h
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_pose.c
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_rna.c
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_wm.c

Modified: branches/blender2.5/blender/source/blender/makesrna/RNA_access.h
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/RNA_access.h	2009-05-20 09:17:21 UTC (rev 20287)
+++ branches/blender2.5/blender/source/blender/makesrna/RNA_access.h	2009-05-20 09:52:02 UTC (rev 20288)
@@ -340,6 +340,8 @@
 void *RNA_struct_blender_type_get(StructRNA *srna);
 void RNA_struct_blender_type_set(StructRNA *srna, void *blender_type);
 
+struct IDProperty *RNA_struct_idproperties(PointerRNA *ptr, int create);
+
 PropertyRNA *RNA_struct_find_property(PointerRNA *ptr, const char *identifier);
 const struct ListBase *RNA_struct_defined_properties(StructRNA *srna);
 

Modified: branches/blender2.5/blender/source/blender/makesrna/RNA_define.h
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/RNA_define.h	2009-05-20 09:17:21 UTC (rev 20287)
+++ branches/blender2.5/blender/source/blender/makesrna/RNA_define.h	2009-05-20 09:52:02 UTC (rev 20288)
@@ -53,6 +53,7 @@
 void RNA_def_struct_nested(BlenderRNA *brna, StructRNA *srna, const char *structname);
 void RNA_def_struct_flag(StructRNA *srna, int flag);
 void RNA_def_struct_refine_func(StructRNA *srna, const char *refine);
+void RNA_def_struct_idproperties_func(StructRNA *srna, const char *refine);
 void RNA_def_struct_register_funcs(StructRNA *srna, const char *reg, const char *unreg);
 void RNA_def_struct_path_func(StructRNA *srna, const char *path);
 void RNA_def_struct_identifier(StructRNA *srna, const char *identifier);

Modified: branches/blender2.5/blender/source/blender/makesrna/intern/makesrna.c
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/intern/makesrna.c	2009-05-20 09:17:21 UTC (rev 20287)
+++ branches/blender2.5/blender/source/blender/makesrna/intern/makesrna.c	2009-05-20 09:52:02 UTC (rev 20288)
@@ -1706,6 +1706,7 @@
 	fprintf(f, "\t%s,\n", rna_function_string(srna->path));
 	fprintf(f, "\t%s,\n", rna_function_string(srna->reg));
 	fprintf(f, "\t%s,\n", rna_function_string(srna->unreg));
+	fprintf(f, "\t%s,\n", rna_function_string(srna->idproperties));
 
 	if(srna->reg && !srna->refine) {
 		fprintf(stderr, "rna_generate_struct: %s has a register function, must also have refine function.\n", srna->identifier);

Modified: branches/blender2.5/blender/source/blender/makesrna/intern/rna_ID.c
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/intern/rna_ID.c	2009-05-20 09:17:21 UTC (rev 20287)
+++ branches/blender2.5/blender/source/blender/makesrna/intern/rna_ID.c	2009-05-20 09:52:02 UTC (rev 20288)
@@ -90,6 +90,11 @@
 	}
 }
 
+IDProperty *rna_ID_idproperties(PointerRNA *ptr, int create)
+{
+	return IDP_GetProperties(ptr->data, create);
+}
+
 void rna_ID_fake_user_set(PointerRNA *ptr, int value)
 {
 	ID *id= (ID*)ptr->data;
@@ -104,6 +109,11 @@
 	}
 }
 
+IDProperty *rna_IDPropertyGroup_idproperties(PointerRNA *ptr, int create)
+{
+	return ptr->data;
+}
+
 #else
 
 static void rna_def_ID_properties(BlenderRNA *brna)
@@ -161,6 +171,7 @@
 	 * care of the properties here */
 	srna= RNA_def_struct(brna, "IDPropertyGroup", NULL);
 	RNA_def_struct_ui_text(srna, "ID Property Group", "Group of ID properties.");
+	RNA_def_struct_idproperties_func(srna, "rna_IDPropertyGroup_idproperties");
 }
 
 static void rna_def_ID(BlenderRNA *brna)
@@ -173,6 +184,7 @@
 	RNA_def_struct_ui_text(srna, "ID", "Base type for datablocks, defining a unique name, linking from other libraries and garbage collection.");
 	RNA_def_struct_flag(srna, STRUCT_ID);
 	RNA_def_struct_refine_func(srna, "rna_ID_refine");
+	RNA_def_struct_idproperties_func(srna, "rna_ID_idproperties");
 
 	prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
 	RNA_def_property_ui_text(prop, "Name", "Unique datablock ID name.");

Modified: branches/blender2.5/blender/source/blender/makesrna/intern/rna_access.c
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/intern/rna_access.c	2009-05-20 09:17:21 UTC (rev 20287)
+++ branches/blender2.5/blender/source/blender/makesrna/intern/rna_access.c	2009-05-20 09:52:02 UTC (rev 20288)
@@ -144,28 +144,19 @@
 
 /* ID Properties */
 
-IDProperty *rna_idproperties_get(PointerRNA *ptr, int create)
+IDProperty *RNA_struct_idproperties(PointerRNA *ptr, int create)
 {
-	if(ptr->type->flag & STRUCT_ID)
-		return IDP_GetProperties(ptr->data, create);
-	else if(ptr->type == &RNA_IDPropertyGroup || ptr->type->base == &RNA_IDPropertyGroup)
-		return ptr->data;
-	else if(ptr->type->base == &RNA_OperatorProperties) {
-		if(create && !ptr->data) {
-			IDPropertyTemplate val;
-			val.i = 0; /* silence MSVC warning about uninitialized var when debugging */
-			ptr->data= IDP_New(IDP_GROUP, val, "RNA_OperatorProperties group");
-		}
+	StructRNA *type= ptr->type;
 
-		return ptr->data;
-	}
-	else
-		return NULL;
+	if(type->idproperties)
+		return type->idproperties(ptr, create);
+	
+	return NULL;
 }
 
 static IDProperty *rna_idproperty_find(PointerRNA *ptr, const char *name)
 {
-	IDProperty *group= rna_idproperties_get(ptr, 0);
+	IDProperty *group= RNA_struct_idproperties(ptr, 0);
 	IDProperty *idprop;
 
 	if(group) {
@@ -252,7 +243,7 @@
 			IDProperty *idprop= rna_idproperty_find(ptr, (*prop)->identifier);
 
 			if(idprop && !rna_idproperty_verify_valid(*prop, idprop)) {
-				IDProperty *group= rna_idproperties_get(ptr, 0);
+				IDProperty *group= RNA_struct_idproperties(ptr, 0);
 
 				IDP_RemFromGroup(group, idprop);
 				IDP_FreeProperty(idprop);
@@ -730,12 +721,12 @@
 	else if(bprop->set)
 		bprop->set(ptr, value);
 	else if(prop->flag & PROP_EDITABLE) {
-		IDPropertyTemplate val;
+		IDPropertyTemplate val = {0};
 		IDProperty *group;
 
 		val.i= value;
 
-		group= rna_idproperties_get(ptr, 1);
+		group= RNA_struct_idproperties(ptr, 1);
 		if(group)
 			IDP_AddToGroup(group, IDP_New(IDP_INT, val, (char*)prop->identifier));
 	}
@@ -786,13 +777,13 @@
 	else if(bprop->setarray)
 		bprop->setarray(ptr, values);
 	else if(prop->flag & PROP_EDITABLE) {
-		IDPropertyTemplate val;
+		IDPropertyTemplate val = {0};
 		IDProperty *group;
 
 		val.array.len= prop->arraylength;
 		val.array.type= IDP_INT;
 
-		group= rna_idproperties_get(ptr, 1);
+		group= RNA_struct_idproperties(ptr, 1);
 		if(group) {
 			idprop= IDP_New(IDP_ARRAY, val, (char*)prop->identifier);
 			IDP_AddToGroup(group, idprop);
@@ -833,12 +824,12 @@
 	else if(iprop->set)
 		iprop->set(ptr, value);
 	else if(prop->flag & PROP_EDITABLE) {
-		IDPropertyTemplate val;
+		IDPropertyTemplate val = {0};
 		IDProperty *group;
 
 		val.i= value;
 
-		group= rna_idproperties_get(ptr, 1);
+		group= RNA_struct_idproperties(ptr, 1);
 		if(group)
 			IDP_AddToGroup(group, IDP_New(IDP_INT, val, (char*)prop->identifier));
 	}
@@ -889,13 +880,13 @@
 	else if(iprop->setarray)
 		iprop->setarray(ptr, values);
 	else if(prop->flag & PROP_EDITABLE) {
-		IDPropertyTemplate val;
+		IDPropertyTemplate val = {0};
 		IDProperty *group;
 
 		val.array.len= prop->arraylength;
 		val.array.type= IDP_INT;
 
-		group= rna_idproperties_get(ptr, 1);
+		group= RNA_struct_idproperties(ptr, 1);
 		if(group) {
 			idprop= IDP_New(IDP_ARRAY, val, (char*)prop->identifier);
 			IDP_AddToGroup(group, idprop);
@@ -945,12 +936,12 @@
 		fprop->set(ptr, value);
 	}
 	else if(prop->flag & PROP_EDITABLE) {
-		IDPropertyTemplate val;
+		IDPropertyTemplate val = {0};
 		IDProperty *group;
 
 		val.f= value;
 
-		group= rna_idproperties_get(ptr, 1);
+		group= RNA_struct_idproperties(ptr, 1);
 		if(group)
 			IDP_AddToGroup(group, IDP_New(IDP_FLOAT, val, (char*)prop->identifier));
 	}
@@ -1014,13 +1005,13 @@
 		fprop->setarray(ptr, values);
 	}
 	else if(prop->flag & PROP_EDITABLE) {
-		IDPropertyTemplate val;
+		IDPropertyTemplate val = {0};
 		IDProperty *group;
 
 		val.array.len= prop->arraylength;
 		val.array.type= IDP_FLOAT;
 
-		group= rna_idproperties_get(ptr, 1);
+		group= RNA_struct_idproperties(ptr, 1);
 		if(group) {
 			idprop= IDP_New(IDP_ARRAY, val, (char*)prop->identifier);
 			IDP_AddToGroup(group, idprop);
@@ -1091,12 +1082,12 @@
 	else if(sprop->set)
 		sprop->set(ptr, value);
 	else if(prop->flag & PROP_EDITABLE) {
-		IDPropertyTemplate val;
+		IDPropertyTemplate val = {0};
 		IDProperty *group;
 
 		val.str= (char*)value;
 
-		group= rna_idproperties_get(ptr, 1);
+		group= RNA_struct_idproperties(ptr, 1);
 		if(group)
 			IDP_AddToGroup(group, IDP_New(IDP_STRING, val, (char*)prop->identifier));
 	}
@@ -1127,12 +1118,12 @@
 		eprop->set(ptr, value);
 	}
 	else if(prop->flag & PROP_EDITABLE) {
-		IDPropertyTemplate val;
+		IDPropertyTemplate val = {0};
 		IDProperty *group;
 
 		val.i= value;
 
-		group= rna_idproperties_get(ptr, 1);
+		group= RNA_struct_idproperties(ptr, 1);
 		if(group)
 			IDP_AddToGroup(group, IDP_New(IDP_INT, val, (char*)prop->identifier));
 	}
@@ -1175,12 +1166,12 @@
 		/* already exists */
 	}
 	else if(prop->flag & PROP_IDPROPERTY) {
-		IDPropertyTemplate val;
+		IDPropertyTemplate val = {0};
 		IDProperty *group;
 
 		val.i= 0;
 
-		group= rna_idproperties_get(ptr, 1);
+		group= RNA_struct_idproperties(ptr, 1);
 		if(group)
 			IDP_AddToGroup(group, IDP_New(IDP_GROUP, val, (char*)prop->identifier));
 	}
@@ -1276,9 +1267,8 @@
 	IDProperty *idprop;
 
 	if((idprop=rna_idproperty_check(&prop, ptr))) {
-		IDPropertyTemplate val;
+		IDPropertyTemplate val = {0};
 		IDProperty *item;
-		val.i= 0;
 
 		item= IDP_New(IDP_GROUP, val, "");
 		IDP_AppendArray(idprop, item);
@@ -1287,10 +1277,9 @@
 	}
 	else if(prop->flag & PROP_IDPROPERTY) {
 		IDProperty *group, *item;
-		IDPropertyTemplate val;
-		val.i= 0;
+		IDPropertyTemplate val = {0};
 
-		group= rna_idproperties_get(ptr, 1);
+		group= RNA_struct_idproperties(ptr, 1);
 		if(group) {
 			idprop= IDP_NewIDPArray(prop->identifier);
 			IDP_AddToGroup(group, idprop);

Modified: branches/blender2.5/blender/source/blender/makesrna/intern/rna_define.c
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/intern/rna_define.c	2009-05-20 09:17:21 UTC (rev 20287)
+++ branches/blender2.5/blender/source/blender/makesrna/intern/rna_define.c	2009-05-20 09:52:02 UTC (rev 20288)
@@ -724,6 +724,16 @@
 	if(refine) srna->refine= (StructRefineFunc)refine;
 }
 

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list