[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [34352] trunk/blender/source/blender/ makesrna/intern: defining types via python gave confusing errors because DefRNA. laststruct was being used for errors when the new property wasn' t on the last struct.
Campbell Barton
ideasman42 at gmail.com
Sun Jan 16 16:02:08 CET 2011
Revision: 34352
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=34352
Author: campbellbarton
Date: 2011-01-16 15:02:07 +0000 (Sun, 16 Jan 2011)
Log Message:
-----------
defining types via python gave confusing errors because DefRNA.laststruct was being used for errors when the new property wasn't on the last struct.
added CONTAINER_RNA_ID() define to get the ID from the ContainerRNA type.
Modified Paths:
--------------
trunk/blender/source/blender/makesrna/intern/makesrna.c
trunk/blender/source/blender/makesrna/intern/rna_define.c
trunk/blender/source/blender/makesrna/intern/rna_internal_types.h
Modified: trunk/blender/source/blender/makesrna/intern/makesrna.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/makesrna.c 2011-01-16 12:11:09 UTC (rev 34351)
+++ trunk/blender/source/blender/makesrna/intern/makesrna.c 2011-01-16 15:02:07 UTC (rev 34352)
@@ -2296,11 +2296,9 @@
prop= srna->cont.properties.last;
if(prop) fprintf(f, "(PropertyRNA*)&rna_%s_%s}},\n", srna->identifier, prop->identifier);
else fprintf(f, "NULL}},\n");
-
- fprintf(f, "\tNULL,NULL,\n"); /* PyType - Cant initialize here */
-
fprintf(f, "\t");
rna_print_c_string(f, srna->identifier);
+ fprintf(f, "\t, NULL,NULL\n"); /* PyType - Cant initialize here */
fprintf(f, ", %d, ", srna->flag);
rna_print_c_string(f, srna->name);
fprintf(f, ", ");
Modified: trunk/blender/source/blender/makesrna/intern/rna_define.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_define.c 2011-01-16 12:11:09 UTC (rev 34351)
+++ trunk/blender/source/blender/makesrna/intern/rna_define.c 2011-01-16 15:02:07 UTC (rev 34352)
@@ -839,7 +839,7 @@
PropertyRNA *RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier, int type, int subtype)
{
- StructRNA *srna= DefRNA.laststruct;
+ /*StructRNA *srna= DefRNA.laststruct;*/ /* invalid for python defined props */
ContainerRNA *cont= cont_;
ContainerDefRNA *dcont;
PropertyDefRNA *dprop= NULL;
@@ -849,7 +849,7 @@
char error[512];
if (rna_validate_identifier(identifier, error, 1) == 0) {
- fprintf(stderr, "RNA_def_property: property identifier \"%s.%s\" - %s\n", srna->identifier, identifier, error);
+ fprintf(stderr, "RNA_def_property: property identifier \"%s.%s\" - %s\n", CONTAINER_RNA_ID(cont), identifier, error);
DefRNA.error= 1;
}
@@ -857,7 +857,7 @@
/* XXX - toto, detect supertype collisions */
if(rna_findlink(&dcont->properties, identifier)) {
- fprintf(stderr, "RNA_def_property: duplicate identifier \"%s.%s\"\n", srna->identifier, identifier);
+ fprintf(stderr, "RNA_def_property: duplicate identifier \"%s.%s\"\n", CONTAINER_RNA_ID(cont), identifier);
DefRNA.error= 1;
}
@@ -915,7 +915,7 @@
case PROP_COLLECTION:
break;
default:
- fprintf(stderr, "RNA_def_property: \"%s.%s\", invalid property type.\n", srna->identifier, identifier);
+ fprintf(stderr, "RNA_def_property: \"%s.%s\", invalid property type.\n", CONTAINER_RNA_ID(cont), identifier);
DefRNA.error= 1;
return NULL;
}
Modified: trunk/blender/source/blender/makesrna/intern/rna_internal_types.h
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_internal_types.h 2011-01-16 12:11:09 UTC (rev 34351)
+++ trunk/blender/source/blender/makesrna/intern/rna_internal_types.h 2011-01-16 15:02:07 UTC (rev 34352)
@@ -108,7 +108,7 @@
/* structs are containers of properties */
ContainerRNA cont;
- /* unique identifier */
+ /* unique identifier, keep after 'cont' */
const char *identifier;
/* various options */
int flag;
@@ -283,13 +283,14 @@
/* structs are containers of properties */
ContainerRNA cont;
+ /* unique identifier, keep after 'cont' */
+ const char *identifier;
+
/* python type, this is a subtype of pyrna_struct_Type but used so each struct can have its own type
* which is useful for subclassing RNA */
void *py_type;
void *blender_type;
- /* unique identifier */
- const char *identifier;
/* various options */
int flag;
@@ -340,4 +341,6 @@
ListBase structs;
};
+#define CONTAINER_RNA_ID(cont) (const char *)(((ContainerRNA *)(cont))+1)
+
#endif /* RNA_INTERNAL_TYPES_H */
More information about the Bf-blender-cvs
mailing list