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

Brecht Van Lommel brecht at blender.org
Mon Nov 17 19:44:07 CET 2008


Revision: 17480
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17480
Author:   blendix
Date:     2008-11-17 19:44:06 +0100 (Mon, 17 Nov 2008)

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

RNA
* Added support for ID properties, mapped as follows:
	* IDP Int = RNA Int
	* IDP Float, Double = RNA Float
	* IDP_String = RNA String
	* IDP Group = RNA IDPropertyGroup Struct
	* IDP_Array = RNA Array

* PropertyRNA and StructRNA are now defined private for the module,
  to force external code to always use accessor functions.

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/blenkernel/BKE_idprop.h
    branches/blender2.5/blender/source/blender/editors/interface/interface.c
    branches/blender2.5/blender/source/blender/editors/space_outliner/space_outliner.c
    branches/blender2.5/blender/source/blender/makesdna/DNA_ID.h
    branches/blender2.5/blender/source/blender/makesrna/RNA_access.h
    branches/blender2.5/blender/source/blender/makesrna/RNA_types.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_main.c
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_rna.c
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_scene.c

Added Paths:
-----------
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_internal_types.h

Modified: branches/blender2.5/blender/source/blender/blenkernel/BKE_idprop.h
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/BKE_idprop.h	2008-11-17 10:43:12 UTC (rev 17479)
+++ branches/blender2.5/blender/source/blender/blenkernel/BKE_idprop.h	2008-11-17 18:44:06 UTC (rev 17480)
@@ -30,16 +30,6 @@
 
 #include "DNA_ID.h"
 
-/*
-these two are included for their (new :P )function
-pointers.
-*/
-#include "BLO_readfile.h"
-#include "BLO_writefile.h"
-
-struct WriteData;
-struct FileData;
-
 struct IDProperty;
 struct ID;
 
@@ -176,5 +166,6 @@
 #define IDP_Float(prop) (*(float*)&prop->data.val)
 #define IDP_String(prop) ((char*)prop->data.pointer)
 #define IDP_Array(prop) (prop->data.pointer)
+#define IDP_Double(prop) (*(double*)&prop->data.val)
 
 #endif /* _BKE_IDPROP_H */

Modified: branches/blender2.5/blender/source/blender/editors/interface/interface.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface.c	2008-11-17 10:43:12 UTC (rev 17479)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface.c	2008-11-17 18:44:06 UTC (rev 17480)
@@ -1058,7 +1058,7 @@
 	if(but->pointype==FLO && but->poin)
 		return 1;
 	
-	if(but->rnaprop && but->rnaprop->type==PROP_FLOAT && but->rnapoin.data)
+	if(but->rnaprop && RNA_property_type(but->rnaprop, &but->rnapoin) == PROP_FLOAT)
 		return 1;
 	
 	return 0;
@@ -1075,21 +1075,21 @@
 	if(but->rnaprop) {
 		prop= but->rnaprop;
 
-		switch(prop->type) {
+		switch(RNA_property_type(prop, &but->rnapoin)) {
 			case PROP_BOOLEAN:
-				if(prop->arraylength)
+				if(RNA_property_array_length(prop, &but->rnapoin))
 					value= RNA_property_boolean_get_array(prop, &but->rnapoin, but->rnaindex);
 				else
 					value= RNA_property_boolean_get(prop, &but->rnapoin);
 				break;
 			case PROP_INT:
-				if(prop->arraylength)
+				if(RNA_property_array_length(prop, &but->rnapoin))
 					value= RNA_property_int_get_array(prop, &but->rnapoin, but->rnaindex);
 				else
 					value= RNA_property_int_get(prop, &but->rnapoin);
 				break;
 			case PROP_FLOAT:
-				if(prop->arraylength)
+				if(RNA_property_array_length(prop, &but->rnapoin))
 					value= RNA_property_float_get_array(prop, &but->rnapoin, but->rnaindex);
 				else
 					value= RNA_property_float_get(prop, &but->rnapoin);
@@ -1138,21 +1138,21 @@
 	if(but->rnaprop) {
 		prop= but->rnaprop;
 
-		switch(prop->type) {
+		switch(RNA_property_type(prop, &but->rnapoin)) {
 			case PROP_BOOLEAN:
-				if(prop->arraylength)
+				if(RNA_property_array_length(prop, &but->rnapoin))
 					RNA_property_boolean_set_array(prop, &but->rnapoin, but->rnaindex, value);
 				else
 					RNA_property_boolean_set(prop, &but->rnapoin, value);
 				break;
 			case PROP_INT:
-				if(prop->arraylength)
+				if(RNA_property_array_length(prop, &but->rnapoin))
 					RNA_property_int_set_array(prop, &but->rnapoin, but->rnaindex, value);
 				else
 					RNA_property_int_set(prop, &but->rnapoin, value);
 				break;
 			case PROP_FLOAT:
-				if(prop->arraylength)
+				if(RNA_property_array_length(prop, &but->rnapoin))
 					RNA_property_float_set_array(prop, &but->rnapoin, but->rnaindex, value);
 				else
 					RNA_property_float_set(prop, &but->rnapoin, value);
@@ -2283,7 +2283,14 @@
 			break;
 		}
 		case PROP_STRING: {
-			but= ui_def_but(block, TEX, 0, "", x1, y1, x2, y2, NULL, 0, RNA_property_string_maxlength(prop, ptr), 0, 0, (char*)RNA_property_ui_description(prop, ptr));
+			int maxlength;
+
+			maxlength= RNA_property_string_maxlength(prop, ptr);
+			if(maxlength == 0)
+				/* interface code should ideally support unlimited length */
+				maxlength= UI_MAX_DRAW_STR; 
+
+			but= ui_def_but(block, TEX, 0, "", x1, y1, x2, y2, NULL, 0, maxlength, 0, 0, (char*)RNA_property_ui_description(prop, ptr));
 			break;
 		}
 		case PROP_POINTER: {

Modified: branches/blender2.5/blender/source/blender/editors/space_outliner/space_outliner.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_outliner/space_outliner.c	2008-11-17 10:43:12 UTC (rev 17479)
+++ branches/blender2.5/blender/source/blender/editors/space_outliner/space_outliner.c	2008-11-17 18:44:06 UTC (rev 17480)
@@ -174,7 +174,7 @@
 	char *newpath;
 	int index= GET_INT_FROM_POINTER(arg_index);;
 
-	newpath= RNA_path_append(soutliner->rnapath, prop, index, NULL);
+	newpath= RNA_path_append(soutliner->rnapath, NULL, prop, index, NULL);
 	if(soutliner->rnapath)
 		MEM_freeN(soutliner->rnapath);
 	soutliner->rnapath= newpath;
@@ -278,7 +278,6 @@
 static void rna_table_cell_func(void *userdata, int row, int col, rcti *rct, uiBlock *block)
 {
 	CellRNA *cell= userdata;
-	PropertyRNA *prop;
 	PropertyType type;
 	int length;
 
@@ -319,8 +318,6 @@
 		cell->lastrow= row;
 	}
 
-	prop= cell->prop;
-
 	/* make button */
 	if(col == 0)
 		rna_label(cell, rct, block);

Modified: branches/blender2.5/blender/source/blender/makesdna/DNA_ID.h
===================================================================
--- branches/blender2.5/blender/source/blender/makesdna/DNA_ID.h	2008-11-17 10:43:12 UTC (rev 17479)
+++ branches/blender2.5/blender/source/blender/makesdna/DNA_ID.h	2008-11-17 18:44:06 UTC (rev 17480)
@@ -51,9 +51,9 @@
 
 typedef struct IDProperty {
 	struct IDProperty *next, *prev;
-	char name[32];
 	char type, subtype;
 	short flag;
+	char name[32];
 	int saved; /*saved is used to indicate if this struct has been saved yet.
 				seemed like a good idea as a pad var was needed anyway :)*/
 	IDPropertyData data;	/* note, alignment for 64 bits */
@@ -69,15 +69,16 @@
 #define DEFAULT_ALLOC_FOR_NULL_STRINGS	64
 
 /*->type*/
-#define IDP_STRING	0
-#define IDP_INT		1
-#define IDP_FLOAT	2
-#define IDP_ARRAY	5
-#define IDP_GROUP	6
+#define IDP_STRING		0
+#define IDP_INT			1
+#define IDP_FLOAT		2
+#define IDP_ARRAY		5
+#define IDP_GROUP		6
 /* the ID link property type hasn't been implemented yet, this will require
    some cleanup of blenkernel, most likely.*/
-#define IDP_ID		7
-#define IDP_DOUBLE	8
+#define IDP_ID			7
+#define IDP_DOUBLE		8
+#define IDP_NUMTYPES	9
 
 /* add any future new id property types here.*/
 

Modified: branches/blender2.5/blender/source/blender/makesrna/RNA_access.h
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/RNA_access.h	2008-11-17 10:43:12 UTC (rev 17479)
+++ branches/blender2.5/blender/source/blender/makesrna/RNA_access.h	2008-11-17 18:44:06 UTC (rev 17480)
@@ -121,7 +121,8 @@
  * particular pointers, which is useful in a number of applications, like
  * UI code or Actions, though efficiency is a concern. */
 
-char *RNA_path_append(const char *path, PropertyRNA *prop, int intkey, const char *strkey);
+char *RNA_path_append(const char *path, PointerRNA *ptr, PropertyRNA *prop,
+	int intkey, const char *strkey);
 char *RNA_path_back(const char *path);
 
 int RNA_path_resolve(PointerRNA *ptr, const char *path,

Modified: branches/blender2.5/blender/source/blender/makesrna/RNA_types.h
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/RNA_types.h	2008-11-17 10:43:12 UTC (rev 17479)
+++ branches/blender2.5/blender/source/blender/makesrna/RNA_types.h	2008-11-17 18:44:06 UTC (rev 17480)
@@ -25,47 +25,6 @@
 #ifndef RNA_TYPES
 #define RNA_TYPES
 
-#include "DNA_listBase.h"
-
-struct BlenderRNA;
-struct StructRNA;
-struct PropertyRNA;
-struct PointerRNA;
-struct CollectionPropertyIterator;
-struct bContext;
-
-/* Function Callbacks */
-
-typedef void (*PropNotifyFunc)(struct bContext *C, struct PointerRNA *ptr);
-typedef int (*PropBooleanGetFunc)(struct PointerRNA *ptr);
-typedef void (*PropBooleanSetFunc)(struct PointerRNA *ptr, int value);
-typedef int (*PropBooleanArrayGetFunc)(struct PointerRNA *ptr, int index);
-typedef void (*PropBooleanArraySetFunc)(struct PointerRNA *ptr, int index, int value);
-typedef int (*PropIntGetFunc)(struct PointerRNA *ptr);
-typedef void (*PropIntSetFunc)(struct PointerRNA *ptr, int value);
-typedef int (*PropIntArrayGetFunc)(struct PointerRNA *ptr, int index);
-typedef void (*PropIntArraySetFunc)(struct PointerRNA *ptr, int index, int value);
-typedef float (*PropFloatGetFunc)(struct PointerRNA *ptr);
-typedef void (*PropFloatSetFunc)(struct PointerRNA *ptr, float value);
-typedef float (*PropFloatArrayGetFunc)(struct PointerRNA *ptr, int index);
-typedef void (*PropFloatArraySetFunc)(struct PointerRNA *ptr, int index, float value);
-typedef void (*PropStringGetFunc)(struct PointerRNA *ptr, char *value);
-typedef int (*PropStringLengthFunc)(struct PointerRNA *ptr);
-typedef void (*PropStringSetFunc)(struct PointerRNA *ptr, const char *value);
-typedef int (*PropEnumGetFunc)(struct PointerRNA *ptr);
-typedef void (*PropEnumSetFunc)(struct PointerRNA *ptr, int value);
-typedef void* (*PropPointerGetFunc)(struct PointerRNA *ptr);
-typedef void (*PropPointerSetFunc)(struct PointerRNA *ptr, void *value);
-typedef struct StructRNA* (*PropPointerTypeFunc)(struct PointerRNA *ptr);
-typedef void (*PropCollectionBeginFunc)(struct CollectionPropertyIterator *iter, struct PointerRNA *ptr);
-typedef void (*PropCollectionNextFunc)(struct CollectionPropertyIterator *iter);
-typedef void (*PropCollectionEndFunc)(struct CollectionPropertyIterator *iter);
-typedef void* (*PropCollectionGetFunc)(struct CollectionPropertyIterator *iter);
-typedef struct StructRNA* (*PropCollectionTypeFunc)(struct CollectionPropertyIterator *iter);
-typedef int (*PropCollectionLengthFunc)(struct PointerRNA *ptr);
-typedef void* (*PropCollectionLookupIntFunc)(struct PointerRNA *ptr, int key, struct StructRNA **type);
-typedef void* (*PropCollectionLookupStringFunc)(struct PointerRNA *ptr, const char *key, struct StructRNA **type);
-
 /* Pointer
  *
  * RNA pointers are not a single C pointer but include the type,
@@ -135,8 +94,9 @@
 	PROP_INVERSE_RENDER_DEPENDENCY = 64,
 #endif
 
-	/* internal flag */
-	PROP_BUILTIN = 128
+	/* internal flags */
+	PROP_BUILTIN = 128,
+	PROP_EXPORT = 256
 } PropertyFlag;
 
 typedef struct CollectionPropertyIterator {
@@ -153,129 +113,9 @@
 	const char *name;
 } EnumPropertyItem;
 
-typedef struct PropertyRNA {
-	struct PropertyRNA *next, *prev;
+struct PropertyRNA;
+typedef struct PropertyRNA PropertyRNA;
 
-	/* C code name */
-	const char *identifier;
-	/* various options */

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list