RNA
* Added more error prints for wrong definitions, for cases that would laters cause problems compiling or crash at runtime, and also made messages more clear. * Added some skeleton code for main/ID/mesh/vertex types for testing. * Added support for automatic arrays as collections using SDNA. * Changed how pointers to data work. Now they are always wrapped in a PointerRNA struct, which contains the data pointer and type, and also the data pointer and type of the ID datablock that this belongs to, since for example a vertex on it's own may not have enough information for some operations, it also needs the mesh. * Added some code for defining dependencies with RNA, and looking up data with paths like: scenes[0].objects["Cube"].data.verts[7].co. Note sure either will end up being used, this is experimental. http://wiki.blender.org/index.php/BlenderDev/Blender2.5/RNA
This commit is contained in:
@@ -44,11 +44,6 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* TODO
|
||||
* - better crash checks for autogenerated functions
|
||||
* - missing warnings for makesdna/rna scons compile?
|
||||
*/
|
||||
|
||||
/* Preprocessing */
|
||||
|
||||
static void rna_print_c_string(FILE *f, const char *str)
|
||||
@@ -101,52 +96,55 @@ static const char *rna_type_type(PropertyRNA *prop)
|
||||
}
|
||||
}
|
||||
|
||||
static char *rna_def_property_get_func(FILE *f, PropertyRNA *prop, PropertyDefRNA *dp)
|
||||
static char *rna_def_property_get_func(FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA *dp)
|
||||
{
|
||||
char *func;
|
||||
|
||||
if(!dp->dnastructname || !dp->dnaname) {
|
||||
fprintf(stderr, "rna_def_property_get_func: %s has no valid dna info.\n", prop->cname);
|
||||
fprintf(stderr, "rna_def_property_get_func: %s.%s has no valid dna info.\n", srna->cname, prop->cname);
|
||||
DefRNA.error= 1;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(prop->type == PROP_STRING && ((StringPropertyRNA*)prop)->maxlength == 0) {
|
||||
fprintf(stderr, "rna_def_property_get_func: string %s has max length 0.\n", prop->cname);
|
||||
fprintf(stderr, "rna_def_property_get_func: string %s.%s has max length 0.\n", srna->cname, prop->cname);
|
||||
DefRNA.error= 1;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
func= rna_alloc_function_name(dp->strct->cname, prop->cname, "get");
|
||||
func= rna_alloc_function_name(srna->cname, prop->cname, "get");
|
||||
|
||||
switch(prop->type) {
|
||||
case PROP_STRING: {
|
||||
StringPropertyRNA *sprop= (StringPropertyRNA*)prop;
|
||||
fprintf(f, "static void %s(void *data, char *value)\n", func);
|
||||
fprintf(f, "static void %s(PointerRNA *ptr, char *value)\n", func);
|
||||
fprintf(f, "{\n");
|
||||
fprintf(f, " BLI_strncpy(value, ((%s*)data)->%s, %d);\n", dp->dnastructname, dp->dnaname, sprop->maxlength);
|
||||
fprintf(f, " %s *data= (%s*)ptr->data;\n", dp->dnastructname, dp->dnastructname);
|
||||
fprintf(f, " BLI_strncpy(value, data->%s, %d);\n", dp->dnaname, sprop->maxlength);
|
||||
fprintf(f, "}\n\n");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
if(prop->arraylength) {
|
||||
fprintf(f, "static %s %s(void *data, int index)\n", rna_type_type(prop), func);
|
||||
fprintf(f, "static %s %s(PointerRNA *ptr, int index)\n", rna_type_type(prop), func);
|
||||
fprintf(f, "{\n");
|
||||
fprintf(f, " %s *data= (%s*)ptr->data;\n", dp->dnastructname, dp->dnastructname);
|
||||
if(prop->type == PROP_BOOLEAN && dp->booleanbit && dp->dnaarraylength==1)
|
||||
fprintf(f, " return ((((%s*)data)->%s & (%d<<index)) != 0);\n", dp->dnastructname, dp->dnaname, dp->booleanbit);
|
||||
fprintf(f, " return ((data->%s & (%d<<index)) != 0);\n", dp->dnaname, dp->booleanbit);
|
||||
else if(prop->type == PROP_BOOLEAN && dp->booleanbit)
|
||||
fprintf(f, " return ((((%s*)data)->%s[index] & %d) != 0);\n", dp->dnastructname, dp->dnaname, dp->booleanbit);
|
||||
fprintf(f, " return ((data->%s[index] & %d) != 0);\n", dp->dnaname, dp->booleanbit);
|
||||
else
|
||||
fprintf(f, " return (%s)(((%s*)data)->%s[index]);\n", rna_type_type(prop), dp->dnastructname, dp->dnaname);
|
||||
fprintf(f, " return (%s)(data->%s[index]);\n", rna_type_type(prop), dp->dnaname);
|
||||
fprintf(f, "}\n\n");
|
||||
}
|
||||
else {
|
||||
fprintf(f, "static %s %s(void *data)\n", rna_type_type(prop), func);
|
||||
fprintf(f, "static %s %s(PointerRNA *ptr)\n", rna_type_type(prop), func);
|
||||
fprintf(f, "{\n");
|
||||
fprintf(f, " %s *data= (%s*)ptr->data;\n", dp->dnastructname, dp->dnastructname);
|
||||
if(prop->type == PROP_BOOLEAN && dp->booleanbit)
|
||||
fprintf(f, " return (((((%s*)data)->%s) & %d) != 0);\n", dp->dnastructname, dp->dnaname, dp->booleanbit);
|
||||
fprintf(f, " return (((data->%s) & %d) != 0);\n", dp->dnaname, dp->booleanbit);
|
||||
else
|
||||
fprintf(f, " return (%s)(((%s*)data)->%s);\n", rna_type_type(prop), dp->dnastructname, dp->dnaname);
|
||||
fprintf(f, " return (%s)(data->%s);\n", rna_type_type(prop), dp->dnaname);
|
||||
fprintf(f, "}\n\n");
|
||||
}
|
||||
break;
|
||||
@@ -187,55 +185,58 @@ static void rna_clamp_value(FILE *f, PropertyRNA *prop)
|
||||
}
|
||||
}
|
||||
|
||||
static char *rna_def_property_set_func(FILE *f, PropertyRNA *prop, PropertyDefRNA *dp)
|
||||
static char *rna_def_property_set_func(FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA *dp)
|
||||
{
|
||||
char *func;
|
||||
|
||||
if(!dp->dnastructname || !dp->dnaname) {
|
||||
fprintf(stderr, "rna_def_property_set_func: %s has no valid dna info.\n", prop->cname);
|
||||
fprintf(stderr, "rna_def_property_set_func: %s.%s has no valid dna info.\n", srna->cname, prop->cname);
|
||||
DefRNA.error= 1;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
func= rna_alloc_function_name(dp->strct->cname, prop->cname, "set");
|
||||
func= rna_alloc_function_name(srna->cname, prop->cname, "set");
|
||||
|
||||
switch(prop->type) {
|
||||
case PROP_STRING: {
|
||||
StringPropertyRNA *sprop= (StringPropertyRNA*)prop;
|
||||
fprintf(f, "static void %s(void *data, const char *value)\n", func);
|
||||
fprintf(f, "static void %s(PointerRNA *ptr, const char *value)\n", func);
|
||||
fprintf(f, "{\n");
|
||||
fprintf(f, " BLI_strncpy(((%s*)data)->%s, value, %d);\n", dp->dnastructname, dp->dnaname, sprop->maxlength);
|
||||
fprintf(f, " %s *data= (%s*)ptr->data;\n", dp->dnastructname, dp->dnastructname);
|
||||
fprintf(f, " BLI_strncpy(data->%s, value, %d);\n", dp->dnaname, sprop->maxlength);
|
||||
fprintf(f, "}\n\n");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
if(prop->arraylength) {
|
||||
fprintf(f, "static void %s(void *data, int index, %s value)\n", func, rna_type_type(prop));
|
||||
fprintf(f, "static void %s(PointerRNA *ptr, int index, %s value)\n", func, rna_type_type(prop));
|
||||
fprintf(f, "{\n");
|
||||
fprintf(f, " %s *data= (%s*)ptr->data;\n", dp->dnastructname, dp->dnastructname);
|
||||
if(prop->type == PROP_BOOLEAN && dp->booleanbit && dp->dnaarraylength==1) {
|
||||
fprintf(f, " if(value) ((%s*)data)->%s |= (%d<<index);\n", dp->dnastructname, dp->dnaname, dp->booleanbit);
|
||||
fprintf(f, " else ((%s*)data)->%s &= ~(%d<<index);\n", dp->dnastructname, dp->dnaname, dp->booleanbit);
|
||||
fprintf(f, " if(value) data->%s |= (%d<<index);\n", dp->dnaname, dp->booleanbit);
|
||||
fprintf(f, " else data->%s &= ~(%d<<index);\n", dp->dnaname, dp->booleanbit);
|
||||
}
|
||||
else if(prop->type == PROP_BOOLEAN && dp->booleanbit) {
|
||||
fprintf(f, " if(value) ((%s*)data)->%s[index] |= %d;\n", dp->dnastructname, dp->dnaname, dp->booleanbit);
|
||||
fprintf(f, " else ((%s*)data)->%s[index] &= ~%d;\n", dp->dnastructname, dp->dnaname, dp->booleanbit);
|
||||
fprintf(f, " if(value) data->%s[index] |= %d;\n", dp->dnaname, dp->booleanbit);
|
||||
fprintf(f, " else data->%s[index] &= ~%d;\n", dp->dnaname, dp->booleanbit);
|
||||
}
|
||||
else {
|
||||
rna_clamp_value(f, prop);
|
||||
fprintf(f, " ((%s*)data)->%s[index]= value;\n", dp->dnastructname, dp->dnaname);
|
||||
fprintf(f, " data->%s[index]= value;\n", dp->dnaname);
|
||||
}
|
||||
fprintf(f, "}\n\n");
|
||||
}
|
||||
else {
|
||||
fprintf(f, "static void %s(void *data, %s value)\n", func, rna_type_type(prop));
|
||||
fprintf(f, "static void %s(PointerRNA *ptr, %s value)\n", func, rna_type_type(prop));
|
||||
fprintf(f, "{\n");
|
||||
fprintf(f, " %s *data= (%s*)ptr->data;\n", dp->dnastructname, dp->dnastructname);
|
||||
if(prop->type == PROP_BOOLEAN && dp->booleanbit) {
|
||||
fprintf(f, " if(value) ((%s*)data)->%s |= %d;\n", dp->dnastructname, dp->dnaname, dp->booleanbit);
|
||||
fprintf(f, " else ((%s*)data)->%s &= ~%d;\n", dp->dnastructname, dp->dnaname, dp->booleanbit);
|
||||
fprintf(f, " if(value) data->%s |= %d;\n", dp->dnaname, dp->booleanbit);
|
||||
fprintf(f, " else data->%s &= ~%d;\n", dp->dnaname, dp->booleanbit);
|
||||
}
|
||||
else {
|
||||
rna_clamp_value(f, prop);
|
||||
fprintf(f, " ((%s*)data)->%s= value;\n", dp->dnastructname, dp->dnaname);
|
||||
fprintf(f, " data->%s= value;\n", dp->dnaname);
|
||||
}
|
||||
fprintf(f, "}\n\n");
|
||||
}
|
||||
@@ -245,42 +246,70 @@ static char *rna_def_property_set_func(FILE *f, PropertyRNA *prop, PropertyDefRN
|
||||
return func;
|
||||
}
|
||||
|
||||
static char *rna_def_property_length_func(FILE *f, PropertyRNA *prop, PropertyDefRNA *dp)
|
||||
static char *rna_def_property_length_func(FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA *dp)
|
||||
{
|
||||
char *func;
|
||||
char *func= NULL;
|
||||
|
||||
if(!dp->dnastructname || !dp->dnaname) {
|
||||
fprintf(stderr, "rna_def_property_length_func: %s has no valid dna info.\n", prop->cname);
|
||||
DefRNA.error= 1;
|
||||
return NULL;
|
||||
if(prop->type == PROP_STRING) {
|
||||
if(!dp->dnastructname || !dp->dnaname) {
|
||||
fprintf(stderr, "rna_def_property_length_func: %s.%s has no valid dna info.\n", srna->cname, prop->cname);
|
||||
DefRNA.error= 1;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
func= rna_alloc_function_name(srna->cname, prop->cname, "length");
|
||||
|
||||
fprintf(f, "static int %s(PointerRNA *ptr)\n", func);
|
||||
fprintf(f, "{\n");
|
||||
fprintf(f, " %s *data= (%s*)ptr->data;\n", dp->dnastructname, dp->dnastructname);
|
||||
fprintf(f, " return strlen(data->%s);\n", dp->dnaname);
|
||||
fprintf(f, "}\n\n");
|
||||
}
|
||||
else if(prop->type == PROP_COLLECTION) {
|
||||
if(prop->type == PROP_COLLECTION && !dp->dnalengthname) {
|
||||
fprintf(stderr, "rna_def_property_length_func: %s.%s has no valid dna info.\n", srna->cname, prop->cname);
|
||||
DefRNA.error= 1;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
func= rna_alloc_function_name(dp->strct->cname, prop->cname, "length");
|
||||
func= rna_alloc_function_name(srna->cname, prop->cname, "length");
|
||||
|
||||
fprintf(f, "static int %s(void *data)\n", func);
|
||||
fprintf(f, "{\n");
|
||||
fprintf(f, " return strlen(((%s*)data)->%s);\n", dp->dnastructname, dp->dnaname);
|
||||
fprintf(f, "}\n\n");
|
||||
fprintf(f, "static int %s(PointerRNA *ptr)\n", func);
|
||||
fprintf(f, "{\n");
|
||||
fprintf(f, " %s *data= (%s*)ptr->data;\n", dp->dnastructname, dp->dnastructname);
|
||||
fprintf(f, " return data->%s;\n", dp->dnalengthname);
|
||||
fprintf(f, "}\n\n");
|
||||
}
|
||||
|
||||
return func;
|
||||
}
|
||||
|
||||
static char *rna_def_property_begin_func(FILE *f, PropertyRNA *prop, PropertyDefRNA *dp)
|
||||
static char *rna_def_property_begin_func(FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA *dp)
|
||||
{
|
||||
char *func;
|
||||
|
||||
if(!dp->dnastructname || !dp->dnaname) {
|
||||
fprintf(stderr, "rna_def_property_begin_func: %s has no valid dna info.\n", prop->cname);
|
||||
fprintf(stderr, "rna_def_property_begin_func: %s.%s has no valid dna info.\n", srna->cname, prop->cname);
|
||||
DefRNA.error= 1;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
func= rna_alloc_function_name(dp->strct->cname, prop->cname, "begin");
|
||||
func= rna_alloc_function_name(srna->cname, prop->cname, "begin");
|
||||
|
||||
fprintf(f, "static void %s(CollectionPropertyIterator *iter, void *data)\n", func);
|
||||
fprintf(f, "{\n");
|
||||
fprintf(f, " rna_iterator_listbase_begin(iter, &((%s*)data)->%s);\n", dp->dnastructname, dp->dnaname);
|
||||
fprintf(f, "}\n\n");
|
||||
if(dp->dnalengthname) {
|
||||
fprintf(f, "static void %s(CollectionPropertyIterator *iter, PointerRNA *ptr)\n", func);
|
||||
fprintf(f, "{\n");
|
||||
fprintf(f, " %s *data= (%s*)ptr->data;\n", dp->dnastructname, dp->dnastructname);
|
||||
fprintf(f, " rna_iterator_array_begin(iter, data->%s, sizeof(data->%s[0]), data->%s);\n", dp->dnaname, dp->dnaname, dp->dnalengthname);
|
||||
fprintf(f, "}\n\n");
|
||||
}
|
||||
else {
|
||||
fprintf(f, "static void %s(CollectionPropertyIterator *iter, PointerRNA *ptr)\n", func);
|
||||
fprintf(f, "{\n");
|
||||
fprintf(f, " %s *data= (%s*)ptr->data;\n", dp->dnastructname, dp->dnastructname);
|
||||
fprintf(f, " rna_iterator_listbase_begin(iter, &data->%s);\n", dp->dnaname);
|
||||
fprintf(f, "}\n\n");
|
||||
}
|
||||
|
||||
return func;
|
||||
}
|
||||
@@ -288,7 +317,9 @@ static char *rna_def_property_begin_func(FILE *f, PropertyRNA *prop, PropertyDef
|
||||
static void rna_def_property_funcs(FILE *f, PropertyDefRNA *dp)
|
||||
{
|
||||
PropertyRNA *prop;
|
||||
StructRNA *srna;
|
||||
|
||||
srna= dp->srna;
|
||||
prop= dp->prop;
|
||||
|
||||
switch(prop->type) {
|
||||
@@ -296,12 +327,12 @@ static void rna_def_property_funcs(FILE *f, PropertyDefRNA *dp)
|
||||
BooleanPropertyRNA *bprop= (BooleanPropertyRNA*)prop;
|
||||
|
||||
if(!prop->arraylength) {
|
||||
if(!bprop->get) bprop->get= (void*)rna_def_property_get_func(f, prop, dp);
|
||||
if(!bprop->set) bprop->set= (void*)rna_def_property_set_func(f, prop, dp);
|
||||
if(!bprop->get) bprop->get= (void*)rna_def_property_get_func(f, srna, prop, dp);
|
||||
if(!bprop->set) bprop->set= (void*)rna_def_property_set_func(f, srna, prop, dp);
|
||||
}
|
||||
else {
|
||||
if(!bprop->getarray) bprop->getarray= (void*)rna_def_property_get_func(f, prop, dp);
|
||||
if(!bprop->setarray) bprop->setarray= (void*)rna_def_property_set_func(f, prop, dp);
|
||||
if(!bprop->getarray) bprop->getarray= (void*)rna_def_property_get_func(f, srna, prop, dp);
|
||||
if(!bprop->setarray) bprop->setarray= (void*)rna_def_property_set_func(f, srna, prop, dp);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -309,12 +340,12 @@ static void rna_def_property_funcs(FILE *f, PropertyDefRNA *dp)
|
||||
IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
|
||||
|
||||
if(!prop->arraylength) {
|
||||
if(!iprop->get) iprop->get= (void*)rna_def_property_get_func(f, prop, dp);
|
||||
if(!iprop->set) iprop->set= (void*)rna_def_property_set_func(f, prop, dp);
|
||||
if(!iprop->get) iprop->get= (void*)rna_def_property_get_func(f, srna, prop, dp);
|
||||
if(!iprop->set) iprop->set= (void*)rna_def_property_set_func(f, srna, prop, dp);
|
||||
}
|
||||
else {
|
||||
if(!iprop->getarray) iprop->getarray= (void*)rna_def_property_get_func(f, prop, dp);
|
||||
if(!iprop->setarray) iprop->setarray= (void*)rna_def_property_set_func(f, prop, dp);
|
||||
if(!iprop->getarray) iprop->getarray= (void*)rna_def_property_get_func(f, srna, prop, dp);
|
||||
if(!iprop->setarray) iprop->setarray= (void*)rna_def_property_set_func(f, srna, prop, dp);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -322,43 +353,71 @@ static void rna_def_property_funcs(FILE *f, PropertyDefRNA *dp)
|
||||
FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop;
|
||||
|
||||
if(!prop->arraylength) {
|
||||
if(!fprop->get) fprop->get= (void*)rna_def_property_get_func(f, prop, dp);
|
||||
if(!fprop->set) fprop->set= (void*)rna_def_property_set_func(f, prop, dp);
|
||||
if(!fprop->get) fprop->get= (void*)rna_def_property_get_func(f, srna, prop, dp);
|
||||
if(!fprop->set) fprop->set= (void*)rna_def_property_set_func(f, srna, prop, dp);
|
||||
}
|
||||
else {
|
||||
if(!fprop->getarray) fprop->getarray= (void*)rna_def_property_get_func(f, prop, dp);
|
||||
if(!fprop->setarray) fprop->setarray= (void*)rna_def_property_set_func(f, prop, dp);
|
||||
if(!fprop->getarray) fprop->getarray= (void*)rna_def_property_get_func(f, srna, prop, dp);
|
||||
if(!fprop->setarray) fprop->setarray= (void*)rna_def_property_set_func(f, srna, prop, dp);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case PROP_ENUM: {
|
||||
EnumPropertyRNA *eprop= (EnumPropertyRNA*)prop;
|
||||
|
||||
if(!eprop->get) eprop->get= (void*)rna_def_property_get_func(f, prop, dp);
|
||||
if(!eprop->set) eprop->set= (void*)rna_def_property_set_func(f, prop, dp);
|
||||
if(!eprop->get) eprop->get= (void*)rna_def_property_get_func(f, srna, prop, dp);
|
||||
if(!eprop->set) eprop->set= (void*)rna_def_property_set_func(f, srna, prop, dp);
|
||||
break;
|
||||
}
|
||||
case PROP_STRING: {
|
||||
StringPropertyRNA *sprop= (StringPropertyRNA*)prop;
|
||||
|
||||
if(!sprop->get) sprop->get= (void*)rna_def_property_get_func(f, prop, dp);
|
||||
if(!sprop->length) sprop->length= (void*)rna_def_property_length_func(f, prop, dp);
|
||||
if(!sprop->set) sprop->set= (void*)rna_def_property_set_func(f, prop, dp);
|
||||
if(!sprop->get) sprop->get= (void*)rna_def_property_get_func(f, srna, prop, dp);
|
||||
if(!sprop->length) sprop->length= (void*)rna_def_property_length_func(f, srna, prop, dp);
|
||||
if(!sprop->set) sprop->set= (void*)rna_def_property_set_func(f, srna, prop, dp);
|
||||
break;
|
||||
}
|
||||
case PROP_POINTER: {
|
||||
PointerPropertyRNA *pprop= (PointerPropertyRNA*)prop;
|
||||
|
||||
if(!pprop->get) pprop->get= (void*)rna_def_property_get_func(f, prop, dp);
|
||||
if(!pprop->set) pprop->set= (void*)rna_def_property_set_func(f, prop, dp);
|
||||
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->cname, prop->cname);
|
||||
DefRNA.error= 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case PROP_COLLECTION: {
|
||||
CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
|
||||
|
||||
if(dp->dnatype && strcmp(dp->dnatype, "ListBase")==0)
|
||||
if(dp->dnatype && strcmp(dp->dnatype, "ListBase")==0) {
|
||||
if(!cprop->begin)
|
||||
cprop->begin= (void*)rna_def_property_begin_func(f, prop, dp);
|
||||
cprop->begin= (void*)rna_def_property_begin_func(f, srna, prop, dp);
|
||||
}
|
||||
else if(dp->dnalengthname) {
|
||||
if(!cprop->begin)
|
||||
cprop->begin= (void*)rna_def_property_begin_func(f, srna, prop, dp);
|
||||
if(!cprop->length)
|
||||
cprop->length= (void*)rna_def_property_length_func(f, srna, prop, dp);
|
||||
}
|
||||
|
||||
if(!cprop->begin) {
|
||||
fprintf(stderr, "rna_def_property_funcs: %s.%s, collection must have a begin function.\n", srna->cname, prop->cname);
|
||||
DefRNA.error= 1;
|
||||
}
|
||||
if(!cprop->next) {
|
||||
fprintf(stderr, "rna_def_property_funcs: %s.%s, collection must have a next function.\n", srna->cname, prop->cname);
|
||||
DefRNA.error= 1;
|
||||
}
|
||||
if(!cprop->get) {
|
||||
fprintf(stderr, "rna_def_property_funcs: %s.%s, collection must have a get function.\n", srna->cname, prop->cname);
|
||||
DefRNA.error= 1;
|
||||
}
|
||||
if(!cprop->structtype && !cprop->type) {
|
||||
fprintf(stderr, "rna_def_property_funcs: %s.%s, collection must have either type function or fixed type.\n", srna->cname, prop->cname);
|
||||
DefRNA.error= 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -370,7 +429,7 @@ static const char *rna_find_type(const char *type)
|
||||
|
||||
for(ds=DefRNA.structs.first; ds; ds=ds->next)
|
||||
if(ds->dnaname && strcmp(ds->dnaname, type)==0)
|
||||
return ds->strct->cname;
|
||||
return ds->srna->cname;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -455,46 +514,46 @@ static const char *rna_property_subtypename(PropertyType type)
|
||||
|
||||
static void rna_generate_prototypes(BlenderRNA *brna, FILE *f)
|
||||
{
|
||||
StructRNA *strct;
|
||||
StructRNA *srna;
|
||||
|
||||
for(strct=brna->structs.first; strct; strct=strct->next)
|
||||
fprintf(f, "StructRNA RNA_%s;\n", strct->cname);
|
||||
for(srna=brna->structs.first; srna; srna=srna->next)
|
||||
fprintf(f, "StructRNA RNA_%s;\n", srna->cname);
|
||||
fprintf(f, "\n");
|
||||
|
||||
fprintf(f, "BlenderRNA BLENDER_RNA = {");
|
||||
|
||||
strct= brna->structs.first;
|
||||
if(strct) fprintf(f, "{&RNA_%s, ", strct->cname);
|
||||
srna= brna->structs.first;
|
||||
if(srna) fprintf(f, "{&RNA_%s, ", srna->cname);
|
||||
else fprintf(f, "{NULL, ");
|
||||
|
||||
strct= brna->structs.last;
|
||||
if(strct) fprintf(f, "&RNA_%s}", strct->cname);
|
||||
srna= brna->structs.last;
|
||||
if(srna) fprintf(f, "&RNA_%s}", srna->cname);
|
||||
else fprintf(f, "NULL}");
|
||||
|
||||
fprintf(f, "};\n\n");
|
||||
}
|
||||
|
||||
static void rna_generate_struct(BlenderRNA *brna, StructRNA *strct, FILE *f)
|
||||
static void rna_generate_struct(BlenderRNA *brna, StructRNA *srna, FILE *f)
|
||||
{
|
||||
PropertyRNA *prop;
|
||||
|
||||
fprintf(f, "/* %s */\n", strct->name);
|
||||
fprintf(f, "/* %s */\n", srna->name);
|
||||
|
||||
if(strct->properties.first)
|
||||
if(srna->properties.first)
|
||||
fprintf(f, "\n");
|
||||
|
||||
for(prop=strct->properties.first; prop; prop=prop->next)
|
||||
fprintf(f, "static %s rna_%s_%s;\n", rna_property_structname(prop->type), strct->cname, prop->cname);
|
||||
for(prop=srna->properties.first; prop; prop=prop->next)
|
||||
fprintf(f, "static %s rna_%s_%s;\n", rna_property_structname(prop->type), srna->cname, prop->cname);
|
||||
fprintf(f, "\n");
|
||||
|
||||
for(prop=strct->properties.first; prop; prop=prop->next) {
|
||||
for(prop=srna->properties.first; prop; prop=prop->next) {
|
||||
switch(prop->type) {
|
||||
case PROP_ENUM: {
|
||||
EnumPropertyRNA *eprop= (EnumPropertyRNA*)prop;
|
||||
int i;
|
||||
|
||||
if(eprop->item) {
|
||||
fprintf(f, "static PropertyEnumItem rna_%s_%s_items[%d] = {", strct->cname, prop->cname, eprop->totitem);
|
||||
fprintf(f, "static PropertyEnumItem rna_%s_%s_items[%d] = {", srna->cname, prop->cname, eprop->totitem);
|
||||
|
||||
for(i=0; i<eprop->totitem; i++) {
|
||||
fprintf(f, "{%d, ", eprop->item[i].value);
|
||||
@@ -513,7 +572,7 @@ static void rna_generate_struct(BlenderRNA *brna, StructRNA *strct, FILE *f)
|
||||
unsigned int i;
|
||||
|
||||
if(bprop->defaultarray) {
|
||||
fprintf(f, "static int rna_%s_%s_default[%d] = {", strct->cname, prop->cname, prop->arraylength);
|
||||
fprintf(f, "static int rna_%s_%s_default[%d] = {", srna->cname, prop->cname, prop->arraylength);
|
||||
|
||||
for(i=0; i<prop->arraylength; i++) {
|
||||
fprintf(f, "%d", bprop->defaultarray[i]);
|
||||
@@ -530,7 +589,7 @@ static void rna_generate_struct(BlenderRNA *brna, StructRNA *strct, FILE *f)
|
||||
unsigned int i;
|
||||
|
||||
if(iprop->defaultarray) {
|
||||
fprintf(f, "static int rna_%s_%s_default[%d] = {", strct->cname, prop->cname, prop->arraylength);
|
||||
fprintf(f, "static int rna_%s_%s_default[%d] = {", srna->cname, prop->cname, prop->arraylength);
|
||||
|
||||
for(i=0; i<prop->arraylength; i++) {
|
||||
fprintf(f, "%d", iprop->defaultarray[i]);
|
||||
@@ -547,7 +606,7 @@ static void rna_generate_struct(BlenderRNA *brna, StructRNA *strct, FILE *f)
|
||||
unsigned int i;
|
||||
|
||||
if(fprop->defaultarray) {
|
||||
fprintf(f, "static float rna_%s_%s_default[%d] = {", strct->cname, prop->cname, prop->arraylength);
|
||||
fprintf(f, "static float rna_%s_%s_default[%d] = {", srna->cname, prop->cname, prop->arraylength);
|
||||
|
||||
for(i=0; i<prop->arraylength; i++) {
|
||||
rna_float_print(f, fprop->defaultarray[i]);
|
||||
@@ -563,11 +622,11 @@ static void rna_generate_struct(BlenderRNA *brna, StructRNA *strct, FILE *f)
|
||||
break;
|
||||
}
|
||||
|
||||
fprintf(f, "static %s rna_%s_%s = {\n", rna_property_structname(prop->type), strct->cname, prop->cname);
|
||||
fprintf(f, "static %s rna_%s_%s = {\n", rna_property_structname(prop->type), srna->cname, prop->cname);
|
||||
|
||||
if(prop->next) fprintf(f, "\t{(PropertyRNA*)&rna_%s_%s, ", strct->cname, prop->next->cname);
|
||||
if(prop->next) fprintf(f, "\t{(PropertyRNA*)&rna_%s_%s, ", srna->cname, prop->next->cname);
|
||||
else fprintf(f, "\t{NULL, ");
|
||||
if(prop->prev) fprintf(f, "(PropertyRNA*)&rna_%s_%s,\n", strct->cname, prop->prev->cname);
|
||||
if(prop->prev) fprintf(f, "(PropertyRNA*)&rna_%s_%s,\n", srna->cname, prop->prev->cname);
|
||||
else fprintf(f, "NULL,\n");
|
||||
fprintf(f, "\t"); rna_print_c_string(f, prop->cname);
|
||||
fprintf(f, ", %d, ", prop->flag);
|
||||
@@ -580,14 +639,14 @@ static void rna_generate_struct(BlenderRNA *brna, StructRNA *strct, FILE *f)
|
||||
case PROP_BOOLEAN: {
|
||||
BooleanPropertyRNA *bprop= (BooleanPropertyRNA*)prop;
|
||||
fprintf(f, "\t%s, %s, %s, %s, %d, ", rna_function_string(bprop->get), rna_function_string(bprop->set), rna_function_string(bprop->getarray), rna_function_string(bprop->setarray), bprop->defaultvalue);
|
||||
if(bprop->defaultarray) fprintf(f, "rna_%s_%s_default\n", strct->name, prop->cname);
|
||||
if(bprop->defaultarray) fprintf(f, "rna_%s_%s_default\n", srna->name, prop->cname);
|
||||
else fprintf(f, "NULL\n");
|
||||
break;
|
||||
}
|
||||
case PROP_INT: {
|
||||
IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
|
||||
fprintf(f, "\t%s, %s, %s, %s, %d, %d, %d, %d, %d,\n\t%d, \n", rna_function_string(iprop->get), rna_function_string(iprop->set), rna_function_string(iprop->getarray), rna_function_string(iprop->setarray), iprop->softmin, iprop->softmax, iprop->hardmin, iprop->hardmax, iprop->step, iprop->defaultvalue);
|
||||
if(iprop->defaultarray) fprintf(f, "rna_%s_%s_default\n", strct->name, prop->cname);
|
||||
if(iprop->defaultarray) fprintf(f, "rna_%s_%s_default\n", srna->name, prop->cname);
|
||||
else fprintf(f, "NULL\n");
|
||||
break;
|
||||
}
|
||||
@@ -601,7 +660,7 @@ static void rna_generate_struct(BlenderRNA *brna, StructRNA *strct, FILE *f)
|
||||
rna_float_print(f, fprop->step); fprintf(f, ", ");
|
||||
rna_float_print(f, fprop->precision); fprintf(f, ", ");
|
||||
rna_float_print(f, fprop->defaultvalue); fprintf(f, ", ");
|
||||
if(fprop->defaultarray) fprintf(f, "rna_%s_%s_default\n", strct->name, prop->cname);
|
||||
if(fprop->defaultarray) fprintf(f, "rna_%s_%s_default\n", srna->name, prop->cname);
|
||||
else fprintf(f, "NULL\n");
|
||||
break;
|
||||
}
|
||||
@@ -613,7 +672,7 @@ static void rna_generate_struct(BlenderRNA *brna, StructRNA *strct, FILE *f)
|
||||
}
|
||||
case PROP_ENUM: {
|
||||
EnumPropertyRNA *eprop= (EnumPropertyRNA*)prop;
|
||||
fprintf(f, "\t%s, %s, rna_%s_%s_items, %d, %d\n", rna_function_string(eprop->get), rna_function_string(eprop->set), strct->cname, prop->cname, eprop->totitem, eprop->defaultvalue);
|
||||
fprintf(f, "\t%s, %s, rna_%s_%s_items, %d, %d\n", rna_function_string(eprop->get), rna_function_string(eprop->set), srna->cname, prop->cname, eprop->totitem, eprop->defaultvalue);
|
||||
break;
|
||||
}
|
||||
case PROP_POINTER: {
|
||||
@@ -635,29 +694,29 @@ static void rna_generate_struct(BlenderRNA *brna, StructRNA *strct, FILE *f)
|
||||
fprintf(f, "};\n\n");
|
||||
}
|
||||
|
||||
fprintf(f, "StructRNA RNA_%s = {\n", strct->cname);
|
||||
fprintf(f, "StructRNA RNA_%s = {\n", srna->cname);
|
||||
|
||||
if(strct->next) fprintf(f, "\t&RNA_%s, ", strct->next->cname);
|
||||
if(srna->next) fprintf(f, "\t&RNA_%s, ", srna->next->cname);
|
||||
else fprintf(f, "\tNULL, ");
|
||||
if(strct->prev) fprintf(f, "&RNA_%s,\n", strct->prev->cname);
|
||||
if(srna->prev) fprintf(f, "&RNA_%s,\n", srna->prev->cname);
|
||||
else fprintf(f, "NULL,\n");
|
||||
|
||||
fprintf(f, "\t");
|
||||
rna_print_c_string(f, strct->cname);
|
||||
fprintf(f, ", %d, ", strct->flag);
|
||||
rna_print_c_string(f, strct->name);
|
||||
rna_print_c_string(f, srna->cname);
|
||||
fprintf(f, ", %d, ", srna->flag);
|
||||
rna_print_c_string(f, srna->name);
|
||||
fprintf(f, ",\n");
|
||||
|
||||
prop= strct->nameproperty;
|
||||
if(prop) fprintf(f, "\t(PropertyRNA*)&rna_%s_%s,\n", strct->cname, prop->cname);
|
||||
prop= srna->nameproperty;
|
||||
if(prop) fprintf(f, "\t(PropertyRNA*)&rna_%s_%s,\n", srna->cname, prop->cname);
|
||||
else fprintf(f, "\tNULL,\n");
|
||||
|
||||
prop= strct->properties.first;
|
||||
if(prop) fprintf(f, "\t{(PropertyRNA*)&rna_%s_%s, ", strct->cname, prop->cname);
|
||||
prop= srna->properties.first;
|
||||
if(prop) fprintf(f, "\t{(PropertyRNA*)&rna_%s_%s, ", srna->cname, prop->cname);
|
||||
else fprintf(f, "\t{NULL, ");
|
||||
|
||||
prop= strct->properties.last;
|
||||
if(prop) fprintf(f, "(PropertyRNA*)&rna_%s_%s}\n", strct->cname, prop->cname);
|
||||
prop= srna->properties.last;
|
||||
if(prop) fprintf(f, "(PropertyRNA*)&rna_%s_%s}\n", srna->cname, prop->cname);
|
||||
else fprintf(f, "NULL}\n");
|
||||
|
||||
fprintf(f, "};\n");
|
||||
@@ -671,6 +730,9 @@ typedef struct RNAProcessItem {
|
||||
} RNAProcessItem;
|
||||
|
||||
RNAProcessItem PROCESS_ITEMS[]= {
|
||||
{"rna_ID.c", NULL},
|
||||
{"rna_main.c", RNA_def_main},
|
||||
{"rna_mesh.c", RNA_def_mesh},
|
||||
{"rna_object.c", RNA_def_object},
|
||||
{"rna_scene.c", RNA_def_scene},
|
||||
{NULL, NULL}};
|
||||
@@ -678,7 +740,7 @@ RNAProcessItem PROCESS_ITEMS[]= {
|
||||
static int rna_preprocess(char *basedirectory, FILE *f)
|
||||
{
|
||||
BlenderRNA *brna;
|
||||
StructRNA *strct;
|
||||
StructRNA *srna;
|
||||
int i, status;
|
||||
|
||||
fprintf(f, "\n/* Automatically generated struct definitions for the Data API.\n"
|
||||
@@ -699,19 +761,20 @@ static int rna_preprocess(char *basedirectory, FILE *f)
|
||||
fprintf(f, "#include \"RNA_types.h\"\n\n");
|
||||
|
||||
fprintf(f, "#include \"rna_internal.h\"\n\n");
|
||||
for(i=0; PROCESS_ITEMS[i].define; i++)
|
||||
for(i=0; PROCESS_ITEMS[i].filename; i++)
|
||||
fprintf(f, "#include \"%s\"\n", PROCESS_ITEMS[i].filename);
|
||||
fprintf(f, "\n");
|
||||
|
||||
for(i=0; PROCESS_ITEMS[i].define; i++)
|
||||
PROCESS_ITEMS[i].define(brna);
|
||||
for(i=0; PROCESS_ITEMS[i].filename; i++)
|
||||
if(PROCESS_ITEMS[i].define)
|
||||
PROCESS_ITEMS[i].define(brna);
|
||||
rna_auto_types();
|
||||
|
||||
rna_generate_prototypes(brna, f);
|
||||
rna_auto_functions(f);
|
||||
|
||||
for(strct=brna->structs.first; strct; strct=strct->next)
|
||||
rna_generate_struct(brna, strct, f);
|
||||
for(srna=brna->structs.first; srna; srna=srna->next)
|
||||
rna_generate_struct(brna, srna, f);
|
||||
|
||||
status= DefRNA.error;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user