Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-01-16 18:02:07 +0300
committerCampbell Barton <ideasman42@gmail.com>2011-01-16 18:02:07 +0300
commite025bf3967fc281db09b7a75d9fef2b78ba3181e (patch)
treed9dcb70d7bb24dc7a62792f94c6381e7ec0e1af3 /source/blender/makesrna
parent5b3bf80dd89ab08abf0f22a7eba636e7127955e2 (diff)
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.
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r--source/blender/makesrna/intern/makesrna.c4
-rw-r--r--source/blender/makesrna/intern/rna_define.c8
-rw-r--r--source/blender/makesrna/intern/rna_internal_types.h9
3 files changed, 11 insertions, 10 deletions
diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c
index 94b075c20c0..985ea5827d9 100644
--- a/source/blender/makesrna/intern/makesrna.c
+++ b/source/blender/makesrna/intern/makesrna.c
@@ -2296,11 +2296,9 @@ static void rna_generate_struct(BlenderRNA *brna, StructRNA *srna, FILE *f)
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, ", ");
diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c
index b6b0bd3ae84..454ed7cee71 100644
--- a/source/blender/makesrna/intern/rna_define.c
+++ b/source/blender/makesrna/intern/rna_define.c
@@ -839,7 +839,7 @@ void RNA_def_struct_ui_icon(StructRNA *srna, int icon)
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 @@ PropertyRNA *RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier
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 @@ PropertyRNA *RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier
/* 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 @@ PropertyRNA *RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier
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;
}
diff --git a/source/blender/makesrna/intern/rna_internal_types.h b/source/blender/makesrna/intern/rna_internal_types.h
index 2bb47643e14..c31c473512a 100644
--- a/source/blender/makesrna/intern/rna_internal_types.h
+++ b/source/blender/makesrna/intern/rna_internal_types.h
@@ -108,7 +108,7 @@ struct FunctionRNA {
/* 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 @@ struct StructRNA {
/* 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 @@ struct BlenderRNA {
ListBase structs;
};
+#define CONTAINER_RNA_ID(cont) (const char *)(((ContainerRNA *)(cont))+1)
+
#endif /* RNA_INTERNAL_TYPES_H */