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

Brecht Van Lommel brecht at blender.org
Sat Nov 29 20:08:46 CET 2008


Revision: 17626
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17626
Author:   blendix
Date:     2008-11-29 20:08:46 +0100 (Sat, 29 Nov 2008)

Log Message:
-----------

RNA
* Fix sensor data pointer code, also made sensor type non editable,
  would need to do more work than just setting the type.
* Fix a fairly obscure bug related to inheritance and sorting.
* Complete DNA_ID.h wrapping, just a few extra properties and the
  Library struct, most of this is internal.

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/editors/interface/interface.c
    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_color.c
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_define.c
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_main.c
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_sensor.c

Modified: branches/blender2.5/blender/source/blender/editors/interface/interface.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface.c	2008-11-29 17:58:17 UTC (rev 17625)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface.c	2008-11-29 19:08:46 UTC (rev 17626)
@@ -1240,8 +1240,10 @@
 
 void ui_set_but_string(uiBut *but, const char *str)
 {
-	if(but->rnaprop)
-		RNA_property_string_set(&but->rnapoin, but->rnaprop, str);
+	if(but->rnaprop) {
+		if(RNA_property_editable(&but->rnapoin, but->rnaprop))
+			RNA_property_string_set(&but->rnapoin, but->rnaprop, str);
+	}
 	else
 		BLI_strncpy(but->poin, str, but->max);
 }

Modified: branches/blender2.5/blender/source/blender/makesrna/intern/makesrna.c
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/intern/makesrna.c	2008-11-29 17:58:17 UTC (rev 17625)
+++ branches/blender2.5/blender/source/blender/makesrna/intern/makesrna.c	2008-11-29 19:08:46 UTC (rev 17626)
@@ -490,7 +490,7 @@
 			if(!pprop->get) pprop->get= (void*)rna_def_property_get_func(f, srna, prop, dp);
 			if(!pprop->set) pprop->set= (void*)rna_def_property_set_func(f, srna, prop, dp);
 			if(!pprop->structtype && !pprop->type) {
-				fprintf(stderr, "rna_def_property_funcs: %s.%s, collection must have either type function or fixed type.\n", srna->identifier, prop->identifier);
+				fprintf(stderr, "rna_def_property_funcs: %s.%s, pointer must have either type function or fixed type.\n", srna->identifier, prop->identifier);
 				DefRNA.error= 1;
 			}
 			break;
@@ -777,7 +777,7 @@
 			}
 			case PROP_INT: {
 				IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
-				fprintf(f, "\t%s, %s, %s, %s, %s,\n\t", rna_function_string(iprop->get), rna_function_string(iprop->set), rna_function_string(iprop->getarray), rna_function_string(iprop->setarray), rna_function_string(iprop->range), iprop->softmin, iprop->softmax, iprop->hardmin, iprop->hardmax, iprop->step, iprop->defaultvalue);
+				fprintf(f, "\t%s, %s, %s, %s, %s,\n\t", rna_function_string(iprop->get), rna_function_string(iprop->set), rna_function_string(iprop->getarray), rna_function_string(iprop->setarray), rna_function_string(iprop->range));
 				rna_int_print(f, iprop->softmin); fprintf(f, ", ");
 				rna_int_print(f, iprop->softmax); fprintf(f, ", ");
 				rna_int_print(f, iprop->hardmin); fprintf(f, ", ");
@@ -921,6 +921,8 @@
 	for(i=0; PROCESS_ITEMS[i].filename; i++)
 		if(PROCESS_ITEMS[i].define)
 			PROCESS_ITEMS[i].define(brna);
+
+	rna_sort(brna);
 	rna_auto_types();
 	
 	rna_generate_prototypes(brna, f);
@@ -930,7 +932,6 @@
 	fprintf(f, "\n");
 
 	rna_auto_functions(f);
-	rna_sort(brna);
 
 	for(srna=brna->structs.first; srna; srna=srna->next)
 		rna_generate_struct(brna, srna, f);

Modified: branches/blender2.5/blender/source/blender/makesrna/intern/rna_ID.c
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/intern/rna_ID.c	2008-11-29 17:58:17 UTC (rev 17625)
+++ branches/blender2.5/blender/source/blender/makesrna/intern/rna_ID.c	2008-11-29 19:08:46 UTC (rev 17626)
@@ -59,6 +59,7 @@
 
 	switch(GS(id->name)) {
 		case ID_LA: return &RNA_Lamp;
+		case ID_LI: return &RNA_Library;
 		case ID_MA: return &RNA_Material;
 		case ID_NT: return &RNA_NodeTree;
 		case ID_ME: return &RNA_Mesh;
@@ -70,6 +71,20 @@
 	}
 }
 
+static void rna_ID_fake_user_set(PointerRNA *ptr, int value)
+{
+	ID *id= (ID*)ptr->data;
+
+	if(value && !(id->flag & LIB_FAKEUSER)) {
+		id->flag |= LIB_FAKEUSER;
+		id->us++;
+	}
+	else if(!value && (id->flag & LIB_FAKEUSER)) {
+		id->flag &= ~LIB_FAKEUSER;
+		id->us--;
+	}
+}
+
 #else
 
 static void rna_def_ID_properties(BlenderRNA *brna)
@@ -122,7 +137,7 @@
 	srna= RNA_def_struct(brna, "IDPropertyGroup", NULL, "ID Property Group");
 }
 
-void rna_def_ID(BlenderRNA *brna)
+static void rna_def_ID(BlenderRNA *brna)
 {
 	StructRNA *srna;
 	PropertyRNA *prop;
@@ -137,15 +152,40 @@
 	RNA_def_property_string_funcs(prop, "rna_ID_name_get", "rna_ID_name_length", "rna_ID_name_set");
 	RNA_def_property_string_maxlength(prop, 22);
 	RNA_def_struct_name_property(srna, prop);
+
+	prop= RNA_def_property(srna, "users", PROP_INT, PROP_UNSIGNED);
+	RNA_def_property_int_sdna(prop, NULL, "us");
+	RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
+	RNA_def_property_ui_text(prop, "Users", "Number of times this datablock is referenced.");
+
+	prop= RNA_def_property(srna, "fake_user", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "flag", LIB_FAKEUSER);
+	RNA_def_property_ui_text(prop, "Fake User", "Saves this datablock even if it has no users");
+	RNA_def_property_boolean_funcs(prop, NULL, "rna_ID_fake_user_set");
+
+	prop= RNA_def_property(srna, "library", PROP_POINTER, PROP_NONE);
+	RNA_def_property_pointer_sdna(prop, NULL, "lib");
+	RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
+	RNA_def_property_ui_text(prop, "Library", "Library file the datablock is linked from.");
 }
 
+static void rna_def_library(BlenderRNA *brna)
+{
+	StructRNA *srna;
+	PropertyRNA *prop;
+
+	srna= RNA_def_struct(brna, "Library", "ID", "Library");
+
+	prop= RNA_def_property(srna, "filename", PROP_STRING, PROP_NONE);
+	RNA_def_property_string_sdna(prop, NULL, "name");
+	RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
+	RNA_def_property_ui_text(prop, "Filename", "Path to the library .blend file.");
+}
 void RNA_def_ID(BlenderRNA *brna)
 {
-	/* ID */
 	rna_def_ID(brna);
-
-	/* ID Properties */
 	rna_def_ID_properties(brna);
+	rna_def_library(brna);
 }
 
 #endif

Modified: branches/blender2.5/blender/source/blender/makesrna/intern/rna_access.c
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/intern/rna_access.c	2008-11-29 17:58:17 UTC (rev 17625)
+++ branches/blender2.5/blender/source/blender/makesrna/intern/rna_access.c	2008-11-29 19:08:46 UTC (rev 17626)
@@ -796,7 +796,7 @@
 	else
 		type= pprop->structtype;
 	
-	if(type->refine)
+	if(type && type->refine)
 		type= type->refine(r_ptr);
 	
 	r_ptr->type= type;

Modified: branches/blender2.5/blender/source/blender/makesrna/intern/rna_color.c
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/intern/rna_color.c	2008-11-29 17:58:17 UTC (rev 17625)
+++ branches/blender2.5/blender/source/blender/makesrna/intern/rna_color.c	2008-11-29 19:08:46 UTC (rev 17626)
@@ -37,7 +37,6 @@
 void RNA_def_color(BlenderRNA *brna)
 {
 	StructRNA *srna;
-	PropertyRNA *prop;
 
 	srna= RNA_def_struct(brna, "CurveMapPoint", NULL, "CurveMapPoint");
 

Modified: branches/blender2.5/blender/source/blender/makesrna/intern/rna_define.c
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/intern/rna_define.c	2008-11-29 17:58:17 UTC (rev 17625)
+++ branches/blender2.5/blender/source/blender/makesrna/intern/rna_define.c	2008-11-29 19:08:46 UTC (rev 17626)
@@ -249,12 +249,26 @@
 	}
 }
 
+static PropertyDefRNA *rna_find_def_property(StructRNA *srna, PropertyRNA *prop)
+{
+	StructDefRNA *ds;
+	PropertyDefRNA *dp;
+
+	for(ds=DefRNA.structs.first; ds; ds=ds->next)
+		if(ds->srna == srna)
+			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, const char *name)
 {
 	StructRNA *srna, *srnafrom= NULL;
-	StructDefRNA *ds;
+	StructDefRNA *ds= NULL;
 	PropertyRNA *prop, *propfrom;
 
 	if(from) {
@@ -272,9 +286,9 @@
 	srna= MEM_callocN(sizeof(StructRNA), "StructRNA");
 	DefRNA.laststruct= srna;
 
-	/* copy from struct to derive stuff, a bit clumsy since we can't
-	 * use MEM_dupallocN, data structs may not be alloced but builtin */
 	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 */
 		memcpy(srna, srnafrom, sizeof(StructRNA));
 		srna->properties.first= srna->properties.last= NULL;
 
@@ -282,7 +296,29 @@
 			srna->from= (StructRNA*)from;
 		else
 			srna->from= srnafrom;
+	}
 
+	srna->identifier= identifier;
+	srna->name= name;
+
+	rna_addtail(&brna->structs, srna);
+
+	if(DefRNA.preprocess) {
+		ds= MEM_callocN(sizeof(StructDefRNA), "StructDefRNA");
+		ds->srna= srna;
+		rna_addtail(&DefRNA.structs, ds);
+	}
+
+	/* in preprocess, try to find sdna */
+	if(DefRNA.preprocess)
+		RNA_def_struct_sdna(srna, srna->identifier);
+	else
+		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);
 
@@ -299,28 +335,24 @@
 				srna->nameproperty= prop;
 			if(propfrom == srnafrom->iteratorproperty)
 				srna->iteratorproperty= prop;
-		}
-	}
 
-	srna->identifier= identifier;
-	srna->name= name;
+			if(DefRNA.preprocess) {
+				PropertyDefRNA *dp, *dpfrom;
+				
+				dp= ds->properties.last;
+				dpfrom= rna_find_def_property(srnafrom, propfrom);
 
-	if(DefRNA.preprocess) {
-		ds= MEM_callocN(sizeof(StructDefRNA), "StructDefRNA");
-		ds->srna= srna;
-		rna_addtail(&DefRNA.structs, ds);
+				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);
+			}
+		}
 	}
-
-	rna_addtail(&brna->structs, srna);
-
-	/* in preprocess, try to find sdna */
-	if(DefRNA.preprocess)
-		RNA_def_struct_sdna(srna, srna->identifier);
-	else
-		srna->flag |= STRUCT_RUNTIME;
-
-	/* define some builtin properties */
-	if(!srnafrom) {
+	else {
+		/* define some builtin properties */
 		prop= RNA_def_property(srna, "rna_properties", PROP_COLLECTION, PROP_NONE);
 		RNA_def_property_flag(prop, PROP_BUILTIN);
 		RNA_def_property_ui_text(prop, "Properties", "RNA property collection.");

Modified: branches/blender2.5/blender/source/blender/makesrna/intern/rna_main.c
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/intern/rna_main.c	2008-11-29 17:58:17 UTC (rev 17625)

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list