forked from bartvdbraak/blender
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.
This commit is contained in:
parent
5b3bf80dd8
commit
e025bf3967
@ -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, ", ");
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user