* More ID property support. What was already possible was showing
  ID properties as RNA properties. Now it is possible to define
  RNA properties and have an ID property automatically created the
  first time it is set (if not set it retuns the default).

* Added support for defining RNA structs and properties at runtime.
  This is useful for python and plugins, and could also be used
  for operators, not sure yet what is best there, they could be done
  in preprocess for speed, but not sure how to do that while keeping
  operator registration a single function.

* Added quick functions to get/set properties based on names, to be
  used for operators.

* Added some simple support for inheritance, was already doing this
  but having it as a feature simplifies things. Two things were added
  for this: when defining a struct you can give a 'from' struct whose
  properties will be copied, and structs like ID, operator, modifier,
  can define a refine callback that will return the more specific type
  of the struct like ID -> Object, Mesh, .. .

* Added simple windowmanager wrap with only the registered operators
  list, used for testing RNA for operators.
This commit is contained in:
Brecht Van Lommel 2008-11-21 02:23:46 +00:00
parent a1b2c0c0fb
commit 129585285c
16 changed files with 1490 additions and 624 deletions

@ -30,6 +30,8 @@
struct bContext;
struct Main;
extern BlenderRNA BLENDER_RNA;
/* Pointer
*
* Currently only an RNA pointer to Main can be obtained, this
@ -45,6 +47,8 @@ const char *RNA_struct_ui_name(PointerRNA *ptr);
PropertyRNA *RNA_struct_name_property(PointerRNA *ptr);
PropertyRNA *RNA_struct_iterator_property(PointerRNA *ptr);
PropertyRNA *RNA_struct_find_property(PointerRNA *ptr, const char *identifier);
/* Properties
*
* Access to struct properties. All this works with RNA pointers rather than
@ -103,7 +107,6 @@ void RNA_property_enum_set(PropertyRNA *prop, PointerRNA *ptr, int value);
void RNA_property_pointer_get(PropertyRNA *prop, PointerRNA *ptr, PointerRNA *r_ptr);
void RNA_property_pointer_set(PropertyRNA *prop, PointerRNA *ptr, PointerRNA *ptr_value);
StructRNA *RNA_property_pointer_type(PropertyRNA *prop, PointerRNA *ptr);
void RNA_property_collection_begin(PropertyRNA *prop, CollectionPropertyIterator *iter, PointerRNA *ptr);
void RNA_property_collection_next(PropertyRNA *prop, CollectionPropertyIterator *iter);
@ -142,5 +145,54 @@ void RNA_test_dependencies_cb(void *udata, PointerRNA *from, PointerRNA *to);
void RNA_generate_dependencies(PointerRNA *mainptr, void *udata, PropDependencyCallback cb);
#endif
/* Quick name based property access
*
* These are just an easier way to access property values without having to
* call RNA_struct_find_property. The names have to exist as RNA properties
* for the type in the pointer, if they do not exist an error will be printed.
*
* The get and set functions work like the corresponding functions above, the
* default functions are intended to be used for runtime / id properties
* specifically. They will set the value only if the id property does not yet
* exist, and return the current value. This is useful to set inputs in an
* operator, avoiding to overwrite them if they were specified by the caller.
*
* There is no support for pointers and collections here yet, these can be
* added when ID properties support them. */
int RNA_boolean_get(PointerRNA *ptr, const char *name);
void RNA_boolean_set(PointerRNA *ptr, const char *name, int value);
int RNA_boolean_default(PointerRNA *ptr, const char *name, int value);
void RNA_boolean_get_array(PointerRNA *ptr, const char *name, int *values);
void RNA_boolean_set_array(PointerRNA *ptr, const char *name, const int *values);
void RNA_boolean_default_array(PointerRNA *ptr, const char *name, int *values);
int RNA_int_get(PointerRNA *ptr, const char *name);
void RNA_int_set(PointerRNA *ptr, const char *name, int value);
int RNA_int_default(PointerRNA *ptr, const char *name, int value);
void RNA_int_get_array(PointerRNA *ptr, const char *name, int *values);
void RNA_int_set_array(PointerRNA *ptr, const char *name, const int *values);
void RNA_int_default_array(PointerRNA *ptr, const char *name, int *values);
float RNA_float_get(PointerRNA *ptr, const char *name);
void RNA_float_set(PointerRNA *ptr, const char *name, float value);
float RNA_float_default(PointerRNA *ptr, const char *name, float value);
void RNA_float_get_array(PointerRNA *ptr, const char *name, float *values);
void RNA_float_set_array(PointerRNA *ptr, const char *name, const float *values);
void RNA_float_default_array(PointerRNA *ptr, const char *name, float *values);
int RNA_enum_get(PointerRNA *ptr, const char *name);
void RNA_enum_set(PointerRNA *ptr, const char *name, int value);
int RNA_enum_default(PointerRNA *ptr, const char *name, int value);
void RNA_string_get(PointerRNA *ptr, const char *name, char *value);
char *RNA_string_get_alloc(PointerRNA *ptr, const char *name, char *fixedbuf, int fixedlen);
int RNA_string_length(PointerRNA *ptr, const char *name);
void RNA_string_set(PointerRNA *ptr, const char *name, const char *value);
void RNA_string_default(PointerRNA *ptr, const char *name, const char *value);
/* check if the idproperty exists, for operators */
int RNA_property_is_set(PointerRNA *ptr, const char *name);
#endif /* RNA_ACCESS */

@ -25,12 +25,7 @@
#ifndef RNA_DEFINE_H
#define RNA_DEFINE_H
/* Functions used during preprocess, for defining the RNA.
*
* This is currently only used internally in the module, but should eventually
* also become available outside of that, at runtime for python and plugins.
* Where the result of such runtime RNA is stored and how it integrates needs
* to be figured out still. */
/* Functions used during preprocess and runtime, for defining the RNA. */
#include "DNA_listBase.h"
#include "RNA_types.h"
@ -40,13 +35,16 @@
BlenderRNA *RNA_create(void);
void RNA_define_free(BlenderRNA *brna);
void RNA_free(BlenderRNA *brna);
void RNA_exit(void);
/* Struct */
StructRNA *RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *name);
StructRNA *RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from, const char *name);
void RNA_def_struct_sdna(StructRNA *srna, const char *structname);
void RNA_def_struct_name_property(StructRNA *srna, PropertyRNA *prop);
void RNA_def_struct_flag(StructRNA *srna, int flag);
void RNA_def_struct_funcs(StructRNA *srna, const char *notify, const char *refine);
void RNA_def_struct_identifier(StructRNA *srna, const char *identifier, const char *name);
/* Property */
@ -80,7 +78,7 @@ void RNA_def_property_string_default(PropertyRNA *prop, const char *value);
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description);
void RNA_def_property_ui_range(PropertyRNA *prop, double min, double max, double step, int precision);
void RNA_def_property_funcs(PropertyRNA *prop, const char *notify, const char *readonly);
void RNA_def_property_funcs(PropertyRNA *prop, const char *notify);
void RNA_def_property_boolean_funcs(PropertyRNA *prop, const char *get, const char *set);
void RNA_def_property_int_funcs(PropertyRNA *prop, const char *get, const char *set);
void RNA_def_property_float_funcs(PropertyRNA *prop, const char *get, const char *set);

@ -96,7 +96,9 @@ typedef enum PropertyFlag {
/* internal flags */
PROP_BUILTIN = 128,
PROP_EXPORT = 256
PROP_EXPORT = 256,
PROP_RUNTIME = 512,
PROP_IDPROPERTY = 1024
} PropertyFlag;
typedef struct CollectionPropertyIterator {
@ -120,7 +122,10 @@ typedef struct PropertyRNA PropertyRNA;
typedef enum StructFlag {
/* indicates that this struct is an ID struct */
STRUCT_ID = 1
STRUCT_ID = 1,
/* internal flags */
STRUCT_RUNTIME = 2
} StructFlag;
struct StructRNA;

@ -100,6 +100,9 @@ static char *rna_def_property_get_func(FILE *f, StructRNA *srna, PropertyRNA *pr
{
char *func;
if(prop->flag & PROP_IDPROPERTY)
return NULL;
if(!dp->dnastructname || !dp->dnaname) {
fprintf(stderr, "rna_def_property_get_func: %s.%s has no valid dna info.\n", srna->identifier, prop->identifier);
DefRNA.error= 1;
@ -195,6 +198,9 @@ static char *rna_def_property_set_func(FILE *f, StructRNA *srna, PropertyRNA *pr
{
char *func;
if(prop->flag & PROP_IDPROPERTY)
return NULL;
if(!dp->dnastructname || !dp->dnaname) {
if(!(prop->flag & PROP_NOT_EDITABLE)) {
fprintf(stderr, "rna_def_property_set_func: %s.%s has no valid dna info.\n", srna->identifier, prop->identifier);
@ -266,6 +272,9 @@ static char *rna_def_property_length_func(FILE *f, StructRNA *srna, PropertyRNA
{
char *func= NULL;
if(prop->flag & PROP_IDPROPERTY)
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->identifier, prop->identifier);
@ -304,6 +313,9 @@ static char *rna_def_property_begin_func(FILE *f, StructRNA *srna, PropertyRNA *
{
char *func;
if(prop->flag & PROP_IDPROPERTY)
return NULL;
if(!dp->dnastructname || !dp->dnaname) {
fprintf(stderr, "rna_def_property_begin_func: %s.%s has no valid dna info.\n", srna->identifier, prop->identifier);
DefRNA.error= 1;
@ -741,7 +753,12 @@ static void rna_generate_struct(BlenderRNA *brna, StructRNA *srna, FILE *f)
if(prop) fprintf(f, "\t(PropertyRNA*)&rna_%s_%s, ", srna->identifier, prop->identifier);
else fprintf(f, "\tNULL, ");
fprintf(f, "\t(PropertyRNA*)&rna_%s_rna_properties,\n", srna->identifier);
fprintf(f, "(PropertyRNA*)&rna_%s_rna_properties,\n", srna->identifier);
if(srna->from) fprintf(f, "\t&RNA_%s,\n", (char*)srna->from);
else fprintf(f, "\tNULL,\n");
fprintf(f, "\t%s, %s,\n", rna_function_string(srna->notify), rna_function_string(srna->refine));
prop= srna->properties.first;
if(prop) fprintf(f, "\t{(PropertyRNA*)&rna_%s_%s, ", srna->identifier, prop->identifier);
@ -762,13 +779,14 @@ typedef struct RNAProcessItem {
} RNAProcessItem;
RNAProcessItem PROCESS_ITEMS[]= {
{"rna_ID.c", RNA_def_ID_types},
{"rna_ID.c", RNA_def_ID},
{"rna_main.c", RNA_def_main},
{"rna_mesh.c", RNA_def_mesh},
{"rna_object.c", RNA_def_object},
{"rna_rna.c", RNA_def_rna},
{"rna_scene.c", RNA_def_scene},
{"rna_lamp.c", RNA_def_lamp},
{"rna_wm.c", RNA_def_wm},
{NULL, NULL}};
static int rna_preprocess(char *basedirectory, FILE *f)
@ -795,6 +813,10 @@ static int rna_preprocess(char *basedirectory, FILE *f)
fprintf(f, "#include \"RNA_types.h\"\n");
fprintf(f, "#include \"rna_internal.h\"\n\n");
/* this is ugly, but we cannot have c files compiled for both
* makesrna and blender with some build systems at the moment */
fprintf(f, "#include \"rna_define.c\"\n\n");
for(i=0; PROCESS_ITEMS[i].filename; i++)
if(PROCESS_ITEMS[i].define)
PROCESS_ITEMS[i].define(brna);

@ -53,180 +53,96 @@ static void rna_ID_name_set(PointerRNA *ptr, const char *value)
BLI_strncpy(id->name+2, value, sizeof(id->name)-2);
}
/* ID properties */
static void rna_IDProperty_string_get(PointerRNA *ptr, char *value)
static StructRNA *rna_ID_refine(PointerRNA *ptr)
{
IDProperty *prop= (IDProperty*)ptr->data;
strcpy(value, IDP_String(prop));
}
ID *id= (ID*)ptr->data;
static int rna_IDProperty_string_length(PointerRNA *ptr)
{
IDProperty *prop= (IDProperty*)ptr->data;
return strlen(IDP_String(prop));
}
static void rna_IDProperty_string_set(PointerRNA *ptr, const char *value)
{
IDProperty *prop= (IDProperty*)ptr->data;
IDP_AssignString(prop, (char*)value);
}
static int rna_IDProperty_int_get(PointerRNA *ptr)
{
IDProperty *prop= (IDProperty*)ptr->data;
return IDP_Int(prop);
}
static void rna_IDProperty_int_set(PointerRNA *ptr, int value)
{
IDProperty *prop= (IDProperty*)ptr->data;
IDP_Int(prop)= value;
}
static int rna_IDProperty_intarray_get(PointerRNA *ptr, int index)
{
IDProperty *prop= (IDProperty*)ptr->data;
return ((int*)IDP_Array(prop))[index];
}
static void rna_IDProperty_intarray_set(PointerRNA *ptr, int index, int value)
{
IDProperty *prop= (IDProperty*)ptr->data;
((int*)IDP_Array(prop))[index]= value;
}
static float rna_IDProperty_float_get(PointerRNA *ptr)
{
IDProperty *prop= (IDProperty*)ptr->data;
return IDP_Float(prop);
}
static void rna_IDProperty_float_set(PointerRNA *ptr, float value)
{
IDProperty *prop= (IDProperty*)ptr->data;
IDP_Float(prop)= value;
}
static float rna_IDProperty_floatarray_get(PointerRNA *ptr, int index)
{
IDProperty *prop= (IDProperty*)ptr->data;
return ((float*)IDP_Array(prop))[index];
}
static void rna_IDProperty_floatarray_set(PointerRNA *ptr, int index, float value)
{
IDProperty *prop= (IDProperty*)ptr->data;
((float*)IDP_Array(prop))[index]= value;
}
static float rna_IDProperty_double_get(PointerRNA *ptr)
{
IDProperty *prop= (IDProperty*)ptr->data;
return (float)IDP_Double(prop);
}
static void rna_IDProperty_double_set(PointerRNA *ptr, float value)
{
IDProperty *prop= (IDProperty*)ptr->data;
IDP_Double(prop)= value;
}
static float rna_IDProperty_doublearray_get(PointerRNA *ptr, int index)
{
IDProperty *prop= (IDProperty*)ptr->data;
return (float)(((double*)IDP_Array(prop))[index]);
}
static void rna_IDProperty_doublearray_set(PointerRNA *ptr, int index, float value)
{
IDProperty *prop= (IDProperty*)ptr->data;
((double*)IDP_Array(prop))[index]= value;
}
static void* rna_IDProperty_group_get(PointerRNA *ptr)
{
IDProperty *prop= (IDProperty*)ptr->data;
return prop;
switch(GS(id->name)) {
case ID_LA: return &RNA_Lamp;
case ID_ME: return &RNA_Mesh;
case ID_OB: return &RNA_Object;
case ID_SCE: return &RNA_Scene;
case ID_WM: return &RNA_WindowManager;
default: return &RNA_ID;
}
}
#else
static void RNA_def_ID_property(BlenderRNA *brna)
static void rna_def_ID_properties(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
/* this is struct is used for holding the virtual
* PropertyRNA's for ID properties */
srna= RNA_def_struct(brna, "IDProperty", "ID Property");
srna= RNA_def_struct(brna, "IDProperty", NULL, "ID Property");
/* IDP_STRING */
prop= RNA_def_property(srna, "string", PROP_STRING, PROP_NONE);
RNA_def_property_flag(prop, PROP_EXPORT);
RNA_def_property_string_funcs(prop, "rna_IDProperty_string_get", "rna_IDProperty_string_length", "rna_IDProperty_string_set");
RNA_def_property_flag(prop, PROP_EXPORT|PROP_IDPROPERTY);
/* IDP_INT */
prop= RNA_def_property(srna, "int", PROP_INT, PROP_NONE);
RNA_def_property_flag(prop, PROP_EXPORT);
RNA_def_property_int_funcs(prop, "rna_IDProperty_int_get", "rna_IDProperty_int_set");
RNA_def_property_flag(prop, PROP_EXPORT|PROP_IDPROPERTY);
prop= RNA_def_property(srna, "intarray", PROP_INT, PROP_NONE);
RNA_def_property_flag(prop, PROP_EXPORT);
RNA_def_property_flag(prop, PROP_EXPORT|PROP_IDPROPERTY);
RNA_def_property_array(prop, 1);
RNA_def_property_int_funcs(prop, "rna_IDProperty_intarray_get", "rna_IDProperty_intarray_set");
/* IDP_FLOAT */
prop= RNA_def_property(srna, "float", PROP_FLOAT, PROP_NONE);
RNA_def_property_flag(prop, PROP_EXPORT);
RNA_def_property_float_funcs(prop, "rna_IDProperty_float_get", "rna_IDProperty_float_set");
RNA_def_property_flag(prop, PROP_EXPORT|PROP_IDPROPERTY);
prop= RNA_def_property(srna, "floatarray", PROP_FLOAT, PROP_NONE);
RNA_def_property_flag(prop, PROP_EXPORT);
RNA_def_property_flag(prop, PROP_EXPORT|PROP_IDPROPERTY);
RNA_def_property_array(prop, 1);
RNA_def_property_float_funcs(prop, "rna_IDProperty_floatarray_get", "rna_IDProperty_floatarray_set");
/* IDP_DOUBLE */
prop= RNA_def_property(srna, "double", PROP_FLOAT, PROP_NONE);
RNA_def_property_flag(prop, PROP_EXPORT);
RNA_def_property_float_funcs(prop, "rna_IDProperty_double_get", "rna_IDProperty_double_set");
RNA_def_property_flag(prop, PROP_EXPORT|PROP_IDPROPERTY);
prop= RNA_def_property(srna, "doublearray", PROP_FLOAT, PROP_NONE);
RNA_def_property_flag(prop, PROP_EXPORT);
RNA_def_property_flag(prop, PROP_EXPORT|PROP_IDPROPERTY);
RNA_def_property_array(prop, 1);
RNA_def_property_float_funcs(prop, "rna_IDProperty_doublearray_get", "rna_IDProperty_doublearray_set");
/* IDP_GROUP */
prop= RNA_def_property(srna, "group", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_EXPORT|PROP_NOT_EDITABLE);
RNA_def_property_flag(prop, PROP_EXPORT|PROP_NOT_EDITABLE|PROP_IDPROPERTY);
RNA_def_property_struct_type(prop, "IDPropertyGroup");
RNA_def_property_pointer_funcs(prop, "rna_IDProperty_group_get", 0, 0);
/* IDP_ID -- not implemented yet in id properties */
/* ID property groups > level 0, since level 0 group is merged
* with native RNA properties. the builtin_properties will take
* care of the properties here */
srna= RNA_def_struct(brna, "IDPropertyGroup", "ID Property Group");
srna= RNA_def_struct(brna, "IDPropertyGroup", NULL, "ID Property Group");
}
void RNA_def_ID(StructRNA *srna)
void rna_def_ID(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
srna= RNA_def_struct(brna, "ID", NULL, "ID");
RNA_def_struct_flag(srna, STRUCT_ID);
RNA_def_struct_funcs(srna, NULL, "rna_ID_refine");
prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, "ID", "name");
RNA_def_property_ui_text(prop, "Name", "Object ID name.");
RNA_def_property_string_funcs(prop, "rna_ID_name_get", "rna_ID_name_length", "rna_ID_name_set");
RNA_def_property_string_maxlength(prop, 22);
RNA_def_struct_name_property(srna, prop);
}
void RNA_def_ID_types(BlenderRNA *brna)
void RNA_def_ID(BlenderRNA *brna)
{
RNA_def_ID_property(brna);
/* ID */
rna_def_ID(brna);
/* ID Properties */
rna_def_ID_properties(brna);
}
#endif

File diff suppressed because it is too large Load Diff

@ -41,12 +41,14 @@
/* Global used during defining */
BlenderDefRNA DefRNA;
BlenderDefRNA DefRNA = {0, {0, 0}, {0, 0}, 0, 0, 0};
/* Duplicated code since we can't link in blenkernel or blenlib */
#ifndef MIN2
#define MIN2(x,y) ((x)<(y)? (x): (y))
#define MAX2(x,y) ((x)>(y)? (x): (y))
#endif
void rna_addtail(ListBase *listbase, void *vlink)
{
@ -60,6 +62,23 @@ void rna_addtail(ListBase *listbase, void *vlink)
listbase->last = link;
}
void rna_remlink(ListBase *listbase, void *vlink)
{
Link *link= vlink;
if (link->next) link->next->prev = link->prev;
if (link->prev) link->prev->next = link->next;
if (listbase->last == link) listbase->last = link->prev;
if (listbase->first == link) listbase->first = link->next;
}
void rna_freelinkN(ListBase *listbase, void *vlink)
{
rna_remlink(listbase, vlink);
MEM_freeN(vlink);
}
void rna_freelistN(ListBase *listbase)
{
Link *link, *next;
@ -151,6 +170,7 @@ BlenderRNA *RNA_create()
DefRNA.sdna= DNA_sdna_from_data(DNAstr, DNAlen, 0);
DefRNA.structs.first= DefRNA.structs.last= NULL;
DefRNA.error= 0;
DefRNA.preprocess= 1;
return brna;
}
@ -179,8 +199,10 @@ void RNA_define_free(BlenderRNA *brna)
void RNA_free(BlenderRNA *brna)
{
StructRNA *srna;
StructRNA *srna, *nextsrna;
PropertyRNA *prop, *nextprop;
if(DefRNA.preprocess) {
RNA_define_free(brna);
for(srna=brna->structs.first; srna; srna=srna->next)
@ -189,29 +211,144 @@ void RNA_free(BlenderRNA *brna)
rna_freelistN(&brna->structs);
MEM_freeN(brna);
}
else {
for(srna=brna->structs.first; srna; srna=nextsrna) {
nextsrna= srna->next;
for(prop=srna->properties.first; prop; prop=nextprop) {
nextprop= prop->next;
if(prop->flag & PROP_RUNTIME)
rna_freelinkN(&srna->properties, prop);
}
if(srna->flag & STRUCT_RUNTIME)
rna_freelinkN(&brna->structs, srna);
}
}
}
static size_t rna_property_type_sizeof(PropertyType type)
{
switch(type) {
case PROP_BOOLEAN: return sizeof(BooleanPropertyRNA);
case PROP_INT: return sizeof(IntPropertyRNA);
case PROP_FLOAT: return sizeof(FloatPropertyRNA);
case PROP_STRING: return sizeof(StringPropertyRNA);
case PROP_ENUM: return sizeof(EnumPropertyRNA);
case PROP_POINTER: return sizeof(PointerPropertyRNA);
case PROP_COLLECTION: return sizeof(CollectionPropertyRNA);
default: return 0;
}
}
/* Struct Definition */
StructRNA *RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *name)
StructRNA *RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from, const char *name)
{
StructRNA *srna;
StructRNA *srna, *srnafrom= NULL;
StructDefRNA *ds;
PropertyRNA *prop, *propfrom;
ds= MEM_callocN(sizeof(StructDefRNA), "StructDefRNA");
rna_addtail(&DefRNA.structs, ds);
if(from) {
/* find struct to derive from */
for(srnafrom= brna->structs.first; srnafrom; srnafrom=srnafrom->next)
if(strcmp(srnafrom->identifier, from) == 0)
break;
if(!srnafrom) {
fprintf(stderr, "RNA_def_struct: struct %s not found to define %s.\n", from, identifier);
DefRNA.error= 1;
}
}
srna= MEM_callocN(sizeof(StructRNA), "StructRNA");
/* copy from struct to derive stuff, a bit clumsy since we can't
* use MEM_dupallocN, data structs may not be alloced but builtin */
if(srnafrom) {
memcpy(srna, srnafrom, sizeof(StructRNA));
srna->properties.first= srna->properties.last= NULL;
if(DefRNA.preprocess)
srna->from= (StructRNA*)from;
else
srna->from= srnafrom;
for(propfrom= srnafrom->properties.first; propfrom; propfrom=propfrom->next) {
prop= RNA_def_property(srna, propfrom->identifier, propfrom->type, propfrom->subtype);
rna_remlink(&srna->properties, prop);
memcpy(prop, propfrom, rna_property_type_sizeof(propfrom->type));
if(!DefRNA.preprocess)
prop->flag |= PROP_RUNTIME;
prop->next= prop->prev= NULL;
rna_addtail(&srna->properties, prop);
if(propfrom == srnafrom->nameproperty)
srna->nameproperty= prop;
if(propfrom == srnafrom->iteratorproperty)
srna->iteratorproperty= prop;
}
}
srna->identifier= identifier;
srna->name= name;
if(DefRNA.preprocess) {
ds= MEM_callocN(sizeof(StructDefRNA), "StructDefRNA");
ds->srna= srna;
rna_addtail(&DefRNA.structs, ds);
}
rna_addtail(&brna->structs, srna);
/* in preprocess, try to find sdna */
if(DefRNA.preprocess)
RNA_def_struct_sdna(srna, srna->identifier);
else
srna->flag |= STRUCT_RUNTIME;
rna_def_builtin_properties(srna);
/* define some builtin properties */
if(!srnafrom) {
prop= RNA_def_property(srna, "rna_properties", PROP_COLLECTION, PROP_NONE);
RNA_def_property_flag(prop, PROP_BUILTIN);
RNA_def_property_ui_text(prop, "Properties", "RNA property collection.");
if(DefRNA.preprocess) {
RNA_def_property_struct_type(prop, "Property");
RNA_def_property_collection_funcs(prop, "rna_builtin_properties_begin", "rna_builtin_properties_next", "rna_iterator_listbase_end", "rna_builtin_properties_get", 0, 0, 0, 0);
}
else {
#ifdef RNA_RUNTIME
CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
cprop->begin= rna_builtin_properties_begin;
cprop->next= rna_builtin_properties_next;
cprop->next= rna_iterator_listbase_end;
cprop->get= rna_builtin_properties_get;
cprop->structtype= &RNA_Property;
#endif
}
prop= RNA_def_property(srna, "rna_type", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
RNA_def_property_ui_text(prop, "RNA", "RNA type definition.");
if(DefRNA.preprocess) {
RNA_def_property_struct_type(prop, "Struct");
RNA_def_property_pointer_funcs(prop, "rna_builtin_type_get", NULL, NULL);
}
else {
#ifdef RNA_RUNTIME
PointerPropertyRNA *pprop= (PointerPropertyRNA*)prop;
pprop->get= rna_builtin_type_get;
pprop->structtype= &RNA_Struct;
#endif
}
}
return srna;
}
@ -220,6 +357,11 @@ void RNA_def_struct_sdna(StructRNA *srna, const char *structname)
{
StructDefRNA *ds= DefRNA.structs.last;
if(!DefRNA.preprocess) {
fprintf(stderr, "RNA_def_struct_sdna: only during preprocessing.\n");
return;
}
if(!DNA_struct_find_nr(DefRNA.sdna, structname)) {
if(!DefRNA.silent) {
fprintf(stderr, "RNA_def_struct_sdna: %s not found.\n", structname);
@ -246,26 +388,50 @@ void RNA_def_struct_flag(StructRNA *srna, int flag)
srna->flag= flag;
}
void RNA_def_struct_funcs(StructRNA *srna, const char *notify, const char *refine)
{
if(!DefRNA.preprocess) {
fprintf(stderr, "RNA_def_struct_funcs: only during preprocessing.\n");
return;
}
if(notify) srna->notify= (NotifyFunc)notify;
if(refine) srna->refine= (StructRefineFunc)refine;
}
void RNA_def_struct_identifier(StructRNA *srna, const char *identifier, const char *name)
{
if(DefRNA.preprocess) {
fprintf(stderr, "RNA_def_struct_name_runtime: only at runtime.\n");
return;
}
srna->identifier= identifier;
srna->name= name;
}
/* Property Definition */
PropertyRNA *RNA_def_property(StructRNA *srna, const char *identifier, int type, int subtype)
{
StructDefRNA *ds;
PropertyDefRNA *dp;
PropertyDefRNA *dp= NULL;
PropertyRNA *prop;
if(DefRNA.preprocess) {
ds= DefRNA.structs.last;
dp= MEM_callocN(sizeof(PropertyDefRNA), "PropertyDefRNA");
rna_addtail(&ds->properties, dp);
}
prop= MEM_callocN(rna_property_type_sizeof(type), "PropertyRNA");
switch(type) {
case PROP_BOOLEAN:
prop= MEM_callocN(sizeof(BooleanPropertyRNA), "BooleanPropertyRNA");
break;
case PROP_INT: {
IntPropertyRNA *iprop;
iprop= MEM_callocN(sizeof(IntPropertyRNA), "IntPropertyRNA");
prop= &iprop->property;
IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
iprop->hardmin= (subtype == PROP_UNSIGNED)? 0: INT_MIN;
iprop->hardmax= INT_MAX;
@ -276,9 +442,7 @@ PropertyRNA *RNA_def_property(StructRNA *srna, const char *identifier, int type,
break;
}
case PROP_FLOAT: {
FloatPropertyRNA *fprop;
fprop= MEM_callocN(sizeof(FloatPropertyRNA), "FloatPropertyRNA");
prop= &fprop->property;
FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop;
fprop->hardmin= (subtype == PROP_UNSIGNED)? 0.0f: -FLT_MAX;
fprop->hardmax= FLT_MAX;
@ -290,31 +454,26 @@ PropertyRNA *RNA_def_property(StructRNA *srna, const char *identifier, int type,
break;
}
case PROP_STRING: {
StringPropertyRNA *sprop;
sprop= MEM_callocN(sizeof(StringPropertyRNA), "StringPropertyRNA");
prop= &sprop->property;
StringPropertyRNA *sprop= (StringPropertyRNA*)prop;
sprop->defaultvalue= "";
sprop->maxlength= 0;
break;
}
case PROP_ENUM:
prop= MEM_callocN(sizeof(EnumPropertyRNA), "EnumPropertyRNA");
break;
case PROP_POINTER:
prop= MEM_callocN(sizeof(PointerPropertyRNA), "PointerPropertyRNA");
break;
case PROP_COLLECTION:
prop= MEM_callocN(sizeof(CollectionPropertyRNA), "CollectionPropertyRNA");
break;
default:
fprintf(stderr, "RNA_def_property: %s.%s, invalid property type.\n", ds->srna->identifier, identifier);
fprintf(stderr, "RNA_def_property: %s.%s, invalid property type.\n", srna->identifier, identifier);
DefRNA.error= 1;
return NULL;
}
if(DefRNA.preprocess) {
dp->srna= srna;
dp->prop= prop;
}
prop->magic= RNA_MAGIC;
prop->identifier= identifier;
@ -328,46 +487,50 @@ PropertyRNA *RNA_def_property(StructRNA *srna, const char *identifier, int type,
else if(type == PROP_POINTER)
prop->flag= PROP_NOT_DRIVEABLE;
if(DefRNA.preprocess) {
switch(type) {
case PROP_BOOLEAN:
DefRNA.silent= 1;
RNA_def_property_boolean_sdna(prop, srna->identifier, identifier, 0);
RNA_def_property_boolean_sdna(prop, NULL, identifier, 0);
DefRNA.silent= 0;
break;
case PROP_INT: {
DefRNA.silent= 1;
RNA_def_property_int_sdna(prop, srna->identifier, identifier);
RNA_def_property_int_sdna(prop, NULL, identifier);
DefRNA.silent= 0;
break;
}
case PROP_FLOAT: {
DefRNA.silent= 1;
RNA_def_property_float_sdna(prop, srna->identifier, identifier);
RNA_def_property_float_sdna(prop, NULL, identifier);
DefRNA.silent= 0;
break;
}
case PROP_STRING: {
DefRNA.silent= 1;
RNA_def_property_string_sdna(prop, srna->identifier, identifier);
RNA_def_property_string_sdna(prop, NULL, identifier);
DefRNA.silent= 0;
break;
}
case PROP_ENUM:
DefRNA.silent= 1;
RNA_def_property_enum_sdna(prop, srna->identifier, identifier);
RNA_def_property_enum_sdna(prop, NULL, identifier);
DefRNA.silent= 0;
break;
case PROP_POINTER:
DefRNA.silent= 1;
RNA_def_property_pointer_sdna(prop, srna->identifier, identifier);
RNA_def_property_pointer_sdna(prop, NULL, identifier);
DefRNA.silent= 0;
break;
case PROP_COLLECTION:
DefRNA.silent= 1;
RNA_def_property_collection_sdna(prop, srna->identifier, identifier, NULL);
RNA_def_property_collection_sdna(prop, NULL, identifier, NULL);
DefRNA.silent= 0;
break;
}
}
else
prop->flag |= PROP_IDPROPERTY|PROP_RUNTIME;
rna_addtail(&srna->properties, prop);
@ -377,7 +540,7 @@ PropertyRNA *RNA_def_property(StructRNA *srna, const char *identifier, int type,
void RNA_def_property_flag(PropertyRNA *prop, int flag)
{
#if 0
StructDefRNA *ds= DefRNA.structs.last;
StructRNA *srna;
#endif
prop->flag |= flag;
@ -394,7 +557,7 @@ void RNA_def_property_flag(PropertyRNA *prop, int flag)
void RNA_def_property_array(PropertyRNA *prop, int arraylength)
{
StructDefRNA *ds= DefRNA.structs.last;
StructRNA *srna;
switch(prop->type) {
case PROP_BOOLEAN:
@ -403,7 +566,7 @@ void RNA_def_property_array(PropertyRNA *prop, int arraylength)
prop->arraylength= arraylength;
break;
default:
fprintf(stderr, "RNA_def_property_array: %s.%s, only boolean/int/float can be array.\n", ds->srna->identifier, prop->identifier);
fprintf(stderr, "RNA_def_property_array: %s.%s, only boolean/int/float can be array.\n", srna->identifier, prop->identifier);
DefRNA.error= 1;
break;
}
@ -417,7 +580,7 @@ void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *d
void RNA_def_property_ui_range(PropertyRNA *prop, double min, double max, double step, int precision)
{
StructDefRNA *ds= DefRNA.structs.last;
StructRNA *srna;
switch(prop->type) {
case PROP_INT: {
@ -436,7 +599,7 @@ void RNA_def_property_ui_range(PropertyRNA *prop, double min, double max, double
break;
}
default:
fprintf(stderr, "RNA_def_property_ui_range: %s.%s, invalid type for ui range.\n", ds->srna->identifier, prop->identifier);
fprintf(stderr, "RNA_def_property_ui_range: %s.%s, invalid type for ui range.\n", srna->identifier, prop->identifier);
DefRNA.error= 1;
break;
}
@ -444,7 +607,7 @@ void RNA_def_property_ui_range(PropertyRNA *prop, double min, double max, double
void RNA_def_property_range(PropertyRNA *prop, double min, double max)
{
StructDefRNA *ds= DefRNA.structs.last;
StructRNA *srna;
switch(prop->type) {
case PROP_INT: {
@ -464,7 +627,7 @@ void RNA_def_property_range(PropertyRNA *prop, double min, double max)
break;
}
default:
fprintf(stderr, "RNA_def_property_range: %s.%s, invalid type for range.\n", ds->srna->identifier, prop->identifier);
fprintf(stderr, "RNA_def_property_range: %s.%s, invalid type for range.\n", srna->identifier, prop->identifier);
DefRNA.error= 1;
break;
}
@ -472,7 +635,12 @@ void RNA_def_property_range(PropertyRNA *prop, double min, double max)
void RNA_def_property_struct_type(PropertyRNA *prop, const char *type)
{
StructDefRNA *ds= DefRNA.structs.last;
StructRNA *srna;
if(!DefRNA.preprocess) {
fprintf(stderr, "RNA_def_property_struct_type: only during preprocessing.\n");
return;
}
switch(prop->type) {
case PROP_POINTER: {
@ -486,7 +654,7 @@ void RNA_def_property_struct_type(PropertyRNA *prop, const char *type)
break;
}
default:
fprintf(stderr, "RNA_def_property_struct_type: %s.%s, invalid type for struct type.\n", ds->srna->identifier, prop->identifier);
fprintf(stderr, "RNA_def_property_struct_type: %s.%s, invalid type for struct type.\n", srna->identifier, prop->identifier);
DefRNA.error= 1;
break;
}
@ -494,7 +662,7 @@ void RNA_def_property_struct_type(PropertyRNA *prop, const char *type)
void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item)
{
StructDefRNA *ds= DefRNA.structs.last;
StructRNA *srna;
int i;
switch(prop->type) {
@ -508,7 +676,7 @@ void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item
break;
}
default:
fprintf(stderr, "RNA_def_property_struct_type: %s.%s, invalid type for struct type.\n", ds->srna->identifier, prop->identifier);
fprintf(stderr, "RNA_def_property_struct_type: %s.%s, invalid type for struct type.\n", srna->identifier, prop->identifier);
DefRNA.error= 1;
break;
}
@ -516,7 +684,7 @@ void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item
void RNA_def_property_string_maxlength(PropertyRNA *prop, int maxlength)
{
StructDefRNA *ds= DefRNA.structs.last;
StructRNA *srna;
switch(prop->type) {
case PROP_STRING: {
@ -525,7 +693,7 @@ void RNA_def_property_string_maxlength(PropertyRNA *prop, int maxlength)
break;
}
default:
fprintf(stderr, "RNA_def_property_string_maxlength: %s.%s, type is not string.\n", ds->srna->identifier, prop->identifier);
fprintf(stderr, "RNA_def_property_string_maxlength: %s.%s, type is not string.\n", srna->identifier, prop->identifier);
DefRNA.error= 1;
break;
}
@ -533,7 +701,7 @@ void RNA_def_property_string_maxlength(PropertyRNA *prop, int maxlength)
void RNA_def_property_boolean_default(PropertyRNA *prop, int value)
{
StructDefRNA *ds= DefRNA.structs.last;
StructRNA *srna;
switch(prop->type) {
case PROP_BOOLEAN: {
@ -542,7 +710,7 @@ void RNA_def_property_boolean_default(PropertyRNA *prop, int value)
break;
}
default:
fprintf(stderr, "RNA_def_property_boolean_default: %s.%s, type is not boolean.\n", ds->srna->identifier, prop->identifier);
fprintf(stderr, "RNA_def_property_boolean_default: %s.%s, type is not boolean.\n", srna->identifier, prop->identifier);
DefRNA.error= 1;
break;
}
@ -550,7 +718,7 @@ void RNA_def_property_boolean_default(PropertyRNA *prop, int value)
void RNA_def_property_boolean_array_default(PropertyRNA *prop, const int *array)
{
StructDefRNA *ds= DefRNA.structs.last;
StructRNA *srna;
switch(prop->type) {
case PROP_BOOLEAN: {
@ -559,7 +727,7 @@ void RNA_def_property_boolean_array_default(PropertyRNA *prop, const int *array)
break;
}
default:
fprintf(stderr, "RNA_def_property_boolean_default: %s.%s, type is not boolean.\n", ds->srna->identifier, prop->identifier);
fprintf(stderr, "RNA_def_property_boolean_default: %s.%s, type is not boolean.\n", srna->identifier, prop->identifier);
DefRNA.error= 1;
break;
}
@ -567,7 +735,7 @@ void RNA_def_property_boolean_array_default(PropertyRNA *prop, const int *array)
void RNA_def_property_int_default(PropertyRNA *prop, int value)
{
StructDefRNA *ds= DefRNA.structs.last;
StructRNA *srna;
switch(prop->type) {
case PROP_INT: {
@ -576,7 +744,7 @@ void RNA_def_property_int_default(PropertyRNA *prop, int value)
break;
}
default:
fprintf(stderr, "RNA_def_property_int_default: %s.%s, type is not int.\n", ds->srna->identifier, prop->identifier);
fprintf(stderr, "RNA_def_property_int_default: %s.%s, type is not int.\n", srna->identifier, prop->identifier);
DefRNA.error= 1;
break;
}
@ -584,7 +752,7 @@ void RNA_def_property_int_default(PropertyRNA *prop, int value)
void RNA_def_property_int_array_default(PropertyRNA *prop, const int *array)
{
StructDefRNA *ds= DefRNA.structs.last;
StructRNA *srna;
switch(prop->type) {
case PROP_INT: {
@ -593,7 +761,7 @@ void RNA_def_property_int_array_default(PropertyRNA *prop, const int *array)
break;
}
default:
fprintf(stderr, "RNA_def_property_int_default: %s.%s, type is not int.\n", ds->srna->identifier, prop->identifier);
fprintf(stderr, "RNA_def_property_int_default: %s.%s, type is not int.\n", srna->identifier, prop->identifier);
DefRNA.error= 1;
break;
}
@ -601,7 +769,7 @@ void RNA_def_property_int_array_default(PropertyRNA *prop, const int *array)
void RNA_def_property_float_default(PropertyRNA *prop, float value)
{
StructDefRNA *ds= DefRNA.structs.last;
StructRNA *srna;
switch(prop->type) {
case PROP_FLOAT: {
@ -610,7 +778,7 @@ void RNA_def_property_float_default(PropertyRNA *prop, float value)
break;
}
default:
fprintf(stderr, "RNA_def_property_float_default: %s.%s, type is not float.\n", ds->srna->identifier, prop->identifier);
fprintf(stderr, "RNA_def_property_float_default: %s.%s, type is not float.\n", srna->identifier, prop->identifier);
DefRNA.error= 1;
break;
}
@ -618,7 +786,7 @@ void RNA_def_property_float_default(PropertyRNA *prop, float value)
void RNA_def_property_float_array_default(PropertyRNA *prop, const float *array)
{
StructDefRNA *ds= DefRNA.structs.last;
StructRNA *srna;
switch(prop->type) {
case PROP_FLOAT: {
@ -627,7 +795,7 @@ void RNA_def_property_float_array_default(PropertyRNA *prop, const float *array)
break;
}
default:
fprintf(stderr, "RNA_def_property_float_default: %s.%s, type is not float.\n", ds->srna->identifier, prop->identifier);
fprintf(stderr, "RNA_def_property_float_default: %s.%s, type is not float.\n", srna->identifier, prop->identifier);
DefRNA.error= 1;
break;
}
@ -635,7 +803,7 @@ void RNA_def_property_float_array_default(PropertyRNA *prop, const float *array)
void RNA_def_property_string_default(PropertyRNA *prop, const char *value)
{
StructDefRNA *ds= DefRNA.structs.last;
StructRNA *srna;
switch(prop->type) {
case PROP_STRING: {
@ -644,7 +812,7 @@ void RNA_def_property_string_default(PropertyRNA *prop, const char *value)
break;
}
default:
fprintf(stderr, "RNA_def_property_string_default: %s.%s, type is not string.\n", ds->srna->identifier, prop->identifier);
fprintf(stderr, "RNA_def_property_string_default: %s.%s, type is not string.\n", srna->identifier, prop->identifier);
DefRNA.error= 1;
break;
}
@ -652,7 +820,7 @@ void RNA_def_property_string_default(PropertyRNA *prop, const char *value)
void RNA_def_property_enum_default(PropertyRNA *prop, int value)
{
StructDefRNA *ds= DefRNA.structs.last;
StructRNA *srna;
switch(prop->type) {
case PROP_ENUM: {
@ -661,7 +829,7 @@ void RNA_def_property_enum_default(PropertyRNA *prop, int value)
break;
}
default:
fprintf(stderr, "RNA_def_property_enum_default: %s.%s, type is not enum.\n", ds->srna->identifier, prop->identifier);
fprintf(stderr, "RNA_def_property_enum_default: %s.%s, type is not enum.\n", srna->identifier, prop->identifier);
DefRNA.error= 1;
break;
}
@ -705,6 +873,11 @@ void RNA_def_property_boolean_sdna(PropertyRNA *prop, const char *structname, co
{
PropertyDefRNA *dp;
if(!DefRNA.preprocess) {
fprintf(stderr, "RNA_def_property_*_sdna: only during preprocessing.\n");
return;
}
if((dp=rna_def_property_sdna(prop, structname, propname)))
dp->booleanbit= bit;
}
@ -714,6 +887,11 @@ void RNA_def_property_int_sdna(PropertyRNA *prop, const char *structname, const
PropertyDefRNA *dp;
IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
if(!DefRNA.preprocess) {
fprintf(stderr, "RNA_def_property_*_sdna: only during preprocessing.\n");
return;
}
if((dp= rna_def_property_sdna(prop, structname, propname))) {
/* SDNA doesn't pass us unsigned unfortunately .. */
if(strcmp(dp->dnatype, "char") == 0) {
@ -746,6 +924,11 @@ void RNA_def_property_enum_sdna(PropertyRNA *prop, const char *structname, const
{
PropertyDefRNA *dp;
if(!DefRNA.preprocess) {
fprintf(stderr, "RNA_def_property_*_sdna: only during preprocessing.\n");
return;
}
if((dp=rna_def_property_sdna(prop, structname, propname))) {
if(prop->arraylength) {
prop->arraylength= 0;
@ -762,6 +945,11 @@ void RNA_def_property_string_sdna(PropertyRNA *prop, const char *structname, con
PropertyDefRNA *dp;
StringPropertyRNA *sprop= (StringPropertyRNA*)prop;
if(!DefRNA.preprocess) {
fprintf(stderr, "RNA_def_property_*_sdna: only during preprocessing.\n");
return;
}
if((dp=rna_def_property_sdna(prop, structname, propname))) {
if(prop->arraylength) {
sprop->maxlength= prop->arraylength;
@ -774,6 +962,11 @@ void RNA_def_property_pointer_sdna(PropertyRNA *prop, const char *structname, co
{
PropertyDefRNA *dp;
if(!DefRNA.preprocess) {
fprintf(stderr, "RNA_def_property_*_sdna: only during preprocessing.\n");
return;
}
if((dp=rna_def_property_sdna(prop, structname, propname))) {
if(prop->arraylength) {
prop->arraylength= 0;
@ -790,6 +983,11 @@ void RNA_def_property_collection_sdna(PropertyRNA *prop, const char *structname,
PropertyDefRNA *dp;
CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
if(!DefRNA.preprocess) {
fprintf(stderr, "RNA_def_property_*_sdna: only during preprocessing.\n");
return;
}
if((dp=rna_def_property_sdna(prop, structname, propname))) {
if(prop->arraylength) {
prop->arraylength= 0;
@ -833,14 +1031,24 @@ void RNA_def_property_collection_sdna(PropertyRNA *prop, const char *structname,
/* Functions */
void RNA_def_property_notify_func(PropertyRNA *prop, const char *notify)
void RNA_def_property_funcs(PropertyRNA *prop, const char *notify)
{
if(notify) prop->notify= (PropNotifyFunc)notify;
if(!DefRNA.preprocess) {
fprintf(stderr, "RNA_def_property_funcs: only during preprocessing.\n");
return;
}
if(notify) prop->notify= (NotifyFunc)notify;
}
void RNA_def_property_boolean_funcs(PropertyRNA *prop, const char *get, const char *set)
{
StructDefRNA *ds= DefRNA.structs.last;
StructRNA *srna;
if(!DefRNA.preprocess) {
fprintf(stderr, "RNA_def_property_*_funcs: only during preprocessing.\n");
return;
}
switch(prop->type) {
case PROP_BOOLEAN: {
@ -857,7 +1065,7 @@ void RNA_def_property_boolean_funcs(PropertyRNA *prop, const char *get, const ch
break;
}
default:
fprintf(stderr, "RNA_def_property_boolean_funcs: %s.%s, type is not boolean.\n", ds->srna->identifier, prop->identifier);
fprintf(stderr, "RNA_def_property_boolean_funcs: %s.%s, type is not boolean.\n", srna->identifier, prop->identifier);
DefRNA.error= 1;
break;
}
@ -865,7 +1073,12 @@ void RNA_def_property_boolean_funcs(PropertyRNA *prop, const char *get, const ch
void RNA_def_property_int_funcs(PropertyRNA *prop, const char *get, const char *set)
{
StructDefRNA *ds= DefRNA.structs.last;
StructRNA *srna;
if(!DefRNA.preprocess) {
fprintf(stderr, "RNA_def_property_*_funcs: only during preprocessing.\n");
return;
}
switch(prop->type) {
case PROP_INT: {
@ -882,7 +1095,7 @@ void RNA_def_property_int_funcs(PropertyRNA *prop, const char *get, const char *
break;
}
default:
fprintf(stderr, "RNA_def_property_int_funcs: %s.%s, type is not int.\n", ds->srna->identifier, prop->identifier);
fprintf(stderr, "RNA_def_property_int_funcs: %s.%s, type is not int.\n", srna->identifier, prop->identifier);
DefRNA.error= 1;
break;
}
@ -890,7 +1103,12 @@ void RNA_def_property_int_funcs(PropertyRNA *prop, const char *get, const char *
void RNA_def_property_float_funcs(PropertyRNA *prop, const char *get, const char *set)
{
StructDefRNA *ds= DefRNA.structs.last;
StructRNA *srna;
if(!DefRNA.preprocess) {
fprintf(stderr, "RNA_def_property_*_funcs: only during preprocessing.\n");
return;
}
switch(prop->type) {
case PROP_FLOAT: {
@ -907,7 +1125,7 @@ void RNA_def_property_float_funcs(PropertyRNA *prop, const char *get, const char
break;
}
default:
fprintf(stderr, "RNA_def_property_float_funcs: %s.%s, type is not float.\n", ds->srna->identifier, prop->identifier);
fprintf(stderr, "RNA_def_property_float_funcs: %s.%s, type is not float.\n", srna->identifier, prop->identifier);
DefRNA.error= 1;
break;
}
@ -915,7 +1133,12 @@ void RNA_def_property_float_funcs(PropertyRNA *prop, const char *get, const char
void RNA_def_property_enum_funcs(PropertyRNA *prop, const char *get, const char *set)
{
StructDefRNA *ds= DefRNA.structs.last;
StructRNA *srna;
if(!DefRNA.preprocess) {
fprintf(stderr, "RNA_def_property_*_funcs: only during preprocessing.\n");
return;
}
switch(prop->type) {
case PROP_ENUM: {
@ -926,7 +1149,7 @@ void RNA_def_property_enum_funcs(PropertyRNA *prop, const char *get, const char
break;
}
default:
fprintf(stderr, "RNA_def_property_enum_funcs: %s.%s, type is not enum.\n", ds->srna->identifier, prop->identifier);
fprintf(stderr, "RNA_def_property_enum_funcs: %s.%s, type is not enum.\n", srna->identifier, prop->identifier);
DefRNA.error= 1;
break;
}
@ -934,7 +1157,12 @@ void RNA_def_property_enum_funcs(PropertyRNA *prop, const char *get, const char
void RNA_def_property_string_funcs(PropertyRNA *prop, const char *get, const char *length, const char *set)
{
StructDefRNA *ds= DefRNA.structs.last;
StructRNA *srna;
if(!DefRNA.preprocess) {
fprintf(stderr, "RNA_def_property_*_funcs: only during preprocessing.\n");
return;
}
switch(prop->type) {
case PROP_STRING: {
@ -946,7 +1174,7 @@ void RNA_def_property_string_funcs(PropertyRNA *prop, const char *get, const cha
break;
}
default:
fprintf(stderr, "RNA_def_property_string_funcs: %s.%s, type is not string.\n", ds->srna->identifier, prop->identifier);
fprintf(stderr, "RNA_def_property_string_funcs: %s.%s, type is not string.\n", srna->identifier, prop->identifier);
DefRNA.error= 1;
break;
}
@ -954,7 +1182,12 @@ void RNA_def_property_string_funcs(PropertyRNA *prop, const char *get, const cha
void RNA_def_property_pointer_funcs(PropertyRNA *prop, const char *get, const char *type, const char *set)
{
StructDefRNA *ds= DefRNA.structs.last;
StructRNA *srna;
if(!DefRNA.preprocess) {
fprintf(stderr, "RNA_def_property_*_funcs: only during preprocessing.\n");
return;
}
switch(prop->type) {
case PROP_POINTER: {
@ -966,7 +1199,7 @@ void RNA_def_property_pointer_funcs(PropertyRNA *prop, const char *get, const ch
break;
}
default:
fprintf(stderr, "RNA_def_property_pointer_funcs: %s.%s, type is not pointer.\n", ds->srna->identifier, prop->identifier);
fprintf(stderr, "RNA_def_property_pointer_funcs: %s.%s, type is not pointer.\n", srna->identifier, prop->identifier);
DefRNA.error= 1;
break;
}
@ -974,7 +1207,12 @@ void RNA_def_property_pointer_funcs(PropertyRNA *prop, const char *get, const ch
void RNA_def_property_collection_funcs(PropertyRNA *prop, const char *begin, const char *next, const char *end, const char *get, const char *type, const char *length, const char *lookupint, const char *lookupstring)
{
StructDefRNA *ds= DefRNA.structs.last;
StructRNA *srna;
if(!DefRNA.preprocess) {
fprintf(stderr, "RNA_def_property_*_funcs: only during preprocessing.\n");
return;
}
switch(prop->type) {
case PROP_COLLECTION: {
@ -991,7 +1229,7 @@ void RNA_def_property_collection_funcs(PropertyRNA *prop, const char *begin, con
break;
}
default:
fprintf(stderr, "RNA_def_property_collection_funcs: %s.%s, type is not collection.\n", ds->srna->identifier, prop->identifier);
fprintf(stderr, "RNA_def_property_collection_funcs: %s.%s, type is not collection.\n", srna->identifier, prop->identifier);
DefRNA.error= 1;
break;
}

@ -68,13 +68,37 @@ typedef struct BlenderDefRNA {
struct SDNA *sdna;
ListBase structs;
ListBase allocs;
int error, silent;
struct StructRNA *laststruct;
int error, silent, preprocess;
} BlenderDefRNA;
extern BlenderDefRNA DefRNA;
/* Define functions for all types */
extern BlenderRNA BLENDER_RNA;
extern StructRNA RNA_Lamp;
extern StructRNA RNA_Main;
extern StructRNA RNA_Mesh;
extern StructRNA RNA_Object;
extern StructRNA RNA_Operator;
extern StructRNA RNA_Property;
extern StructRNA RNA_Scene;
extern StructRNA RNA_Struct;
extern StructRNA RNA_WindowManager;
void RNA_def_ID(struct BlenderRNA *brna);
void RNA_def_lamp(struct BlenderRNA *brna);
void RNA_def_main(struct BlenderRNA *brna);
void RNA_def_mesh(struct BlenderRNA *brna);
void RNA_def_object(struct BlenderRNA *brna);
void RNA_def_rna(struct BlenderRNA *brna);
void RNA_def_scene(struct BlenderRNA *brna);
void RNA_def_wm(struct BlenderRNA *brna);
/* ID Properties */
extern StringPropertyRNA rna_IDProperty_string;
extern IntPropertyRNA rna_IDProperty_int;
extern IntPropertyRNA rna_IDProperty_intarray;
@ -84,29 +108,21 @@ extern PointerPropertyRNA rna_IDProperty_group;
extern FloatPropertyRNA rna_IDProperty_double;
extern FloatPropertyRNA rna_IDProperty_doublearray;
extern StructRNA RNA_Main;
extern StructRNA RNA_Mesh;
extern StructRNA RNA_Object;
extern StructRNA RNA_Scene;
extern StructRNA RNA_Lamp;
extern StructRNA RNA_Struct;
void RNA_def_ID(struct StructRNA *srna);
void RNA_def_ID_types(struct BlenderRNA *brna);
void RNA_def_main(struct BlenderRNA *brna);
void RNA_def_mesh(struct BlenderRNA *brna);
void RNA_def_object(struct BlenderRNA *brna);
void RNA_def_rna(struct BlenderRNA *brna);
void RNA_def_scene(struct BlenderRNA *brna);
void RNA_def_lamp(struct BlenderRNA *brna);
/* Internal Functions */
void rna_def_builtin_properties(struct StructRNA *srna);
extern StructRNA RNA_IDProperty;
extern StructRNA RNA_IDPropertyGroup;
struct IDProperty *rna_idproperties_get(struct StructRNA *type, void *data, int create);
struct IDProperty *rna_idproperty_check(struct PropertyRNA **prop, struct PointerRNA *ptr);
/* Builtin Property Callbacks */
void rna_builtin_properties_begin(struct CollectionPropertyIterator *iter, struct PointerRNA *ptr);
void rna_builtin_properties_next(struct CollectionPropertyIterator *iter);
void *rna_builtin_properties_get(struct CollectionPropertyIterator *iter);
void *rna_builtin_type_get(struct PointerRNA *ptr);
/* Iterators */
typedef struct ListBaseIterator {
Link *link;
int flag;
@ -131,6 +147,7 @@ void rna_iterator_array_end(struct CollectionPropertyIterator *iter);
/* Duplicated code since we can't link in blenlib */
void rna_addtail(struct ListBase *listbase, void *vlink);
void rna_freelinkN(struct ListBase *listbase, void *vlink);
void rna_freelistN(struct ListBase *listbase);
#endif /* RNA_INTERNAL_H */

@ -36,7 +36,9 @@ struct bContext;
/* Function Callbacks */
typedef void (*PropNotifyFunc)(struct bContext *C, struct PointerRNA *ptr);
typedef void (*NotifyFunc)(struct bContext *C, struct PointerRNA *ptr);
typedef struct StructRNA *(*StructRefineFunc)(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);
@ -90,7 +92,7 @@ struct PropertyRNA {
unsigned int arraylength;
/* callback for notifys on change */
PropNotifyFunc notify;
NotifyFunc notify;
};
/* Property Types */
@ -209,6 +211,15 @@ struct StructRNA {
/* property to iterate over properties */
PropertyRNA *iteratorproperty;
/* struct this is derivedfrom */
struct StructRNA *from;
/* callback for notifys on change */
NotifyFunc notify;
/* function to give the more specific type */
StructRefineFunc refine;
/* properties of this struct */
ListBase properties;
};

@ -33,7 +33,6 @@
#ifdef RNA_RUNTIME
#else
void RNA_def_lamp(BlenderRNA *brna)
@ -42,9 +41,7 @@ void RNA_def_lamp(BlenderRNA *brna)
PropertyRNA *prop;
static EnumPropertyItem prop_type_items[] = {{LA_LOCAL, "LOCAL", "Local"}, {LA_SUN, "SUN", "Sun"}, {LA_SPOT, "SPOT", "Spot"}, {LA_HEMI, "HEMI", "Hemi"}, {LA_AREA, "AREA", "Area"}, {0, NULL, NULL}};
srna= RNA_def_struct(brna, "Lamp", "Lamp");
RNA_def_ID(srna);
srna= RNA_def_struct(brna, "Lamp", "ID", "Lamp");
prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, prop_type_items);

@ -194,13 +194,13 @@ static void rna_Main_particle_begin(CollectionPropertyIterator *iter, PointerRNA
Main *bmain= (Main*)ptr->data;
rna_iterator_listbase_begin(iter, &bmain->particle);
}
#endif
static void rna_Main_wm_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
Main *bmain= (Main*)ptr->data;
rna_iterator_listbase_begin(iter, &bmain->wm);
}
#endif
#else
@ -213,6 +213,7 @@ void RNA_def_main(BlenderRNA *brna)
{"objects", "Object", "rna_Main_object_begin", "Objects", "Object datablocks."},
{"meshes", "Mesh", "rna_Main_mesh_begin", "Meshes", "Mesh datablocks."},
{"lamps", "Lamp", "rna_Main_lamp_begin", "Lamps", "Lamp datablocks."},
{"windowmanagers", "WindowManager", "rna_Main_wm_begin", "Window Managers", "Window manager datablocks."},
{NULL, NULL, NULL, NULL, NULL},
{"libraries", "Library", "rna_Main_library_begin", "Libraries", "Library datablocks."},
{"curves", "Curve", "rna_Main_curve_begin", "Curves", "Curve datablocks."},
@ -236,11 +237,10 @@ void RNA_def_main(BlenderRNA *brna)
{"nodegroups", "NodeGroup", "rna_Main_nodetree_begin", "Node Groups", "Node group datablocks."},
{"brushes", "Brush", "rna_Main_brush_begin", "Brushes", "Brush datablocks."},
{"particles", "Particle", "rna_Main_particle_begin", "Particles", "Particle datablocks."},
{"windowmanagers", "wmWindowManager", "rna_Main_wm_begin", "Window Managers", "Window manager datablocks."},
{NULL, NULL, NULL, NULL, NULL}};
int i;
srna= RNA_def_struct(brna, "Main", "Main");
srna= RNA_def_struct(brna, "Main", NULL, "Main");
for(i=0; lists[i][0]; i++)
{

@ -42,9 +42,7 @@ void RNA_def_mesh(BlenderRNA *brna)
PropertyRNA *prop;
/* mesh */
srna= RNA_def_struct(brna, "Mesh", "Mesh");
RNA_def_ID(srna);
srna= RNA_def_struct(brna, "Mesh", "ID", "Mesh");
prop= RNA_def_property(srna, "verts", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "mvert", "totvert");
@ -52,7 +50,7 @@ void RNA_def_mesh(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Vertices", "Vertices of the mesh.");
/* vertex */
srna= RNA_def_struct(brna, "MVert", "Mesh Vertex");
srna= RNA_def_struct(brna, "MVert", NULL, "Mesh Vertex");
prop= RNA_def_property(srna, "co", PROP_FLOAT, PROP_VECTOR);
RNA_def_property_ui_text(prop, "Location", "Location of the vertex.");

@ -34,40 +34,6 @@
#ifdef RNA_RUNTIME
static StructRNA *rna_Object_data_type(PointerRNA *ptr)
{
Object *ob= (Object*)ptr->data;
switch(ob->type) {
case OB_EMPTY:
return NULL;
case OB_MESH:
return &RNA_Mesh;
case OB_LAMP:
return &RNA_Lamp;
#if 0
case OB_CURVE:
return &RNA_Curve;
case OB_SURF:
return &RNA_Surface;
case OB_FONT:
return &RNA_Font;
case OB_MBALL:
return &RNA_MBall;
case OB_LAMP:
return &RNA_Lamp;
case OB_CAMERA:
return &RNA_Camera;
case OB_WAVE:
return &RNA_Wave;
case OB_LATTICE:
return &RNA_Lattice;
#endif
default:
return NULL;
}
}
#else
void RNA_def_object(BlenderRNA *brna)
@ -75,12 +41,10 @@ void RNA_def_object(BlenderRNA *brna)
StructRNA *srna;
PropertyRNA *prop;
srna= RNA_def_struct(brna, "Object", "Object");
RNA_def_ID(srna);
srna= RNA_def_struct(brna, "Object", "ID", "Object");
prop= RNA_def_property(srna, "data", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_funcs(prop, NULL, "rna_Object_data_type", NULL);
RNA_def_property_struct_type(prop, "ID");
RNA_def_property_ui_text(prop, "Data", "Object data.");
prop= RNA_def_property(srna, "parent", PROP_POINTER, PROP_NONE);

@ -57,16 +57,29 @@ static void *rna_Struct_name_property_get(PointerRNA *ptr)
return ((StructRNA*)ptr->data)->nameproperty;
}
static int rna_idproperty_known(CollectionPropertyIterator *iter)
{
ListBaseIterator *internal= iter->internal;
IDProperty *idprop= (IDProperty*)internal->link;
PropertyRNA *prop;
for(prop= iter->parent.type->properties.first; prop; prop=prop->next)
if(strcmp(prop->identifier, idprop->name) == 0)
return 1;
return 0;
}
static void rna_Struct_properties_next(CollectionPropertyIterator *iter)
{
ListBaseIterator *internal= iter->internal;
ID *id;
StructRNA *type;
IDProperty *group;
if(internal->flag) {
/* id properties */
do {
rna_iterator_listbase_next(iter);
} while(iter->valid && rna_idproperty_known(iter));
}
else {
/* regular properties */
@ -76,21 +89,16 @@ static void rna_Struct_properties_next(CollectionPropertyIterator *iter)
/* try id properties */
if(!iter->valid) {
type= iter->parent.id.type;
id= iter->parent.id.data;
if(iter->parent.type == &RNA_IDPropertyGroup)
group= iter->parent.data;
else if(iter->parent.data == id && type && (type->flag & STRUCT_ID))
group= IDP_GetProperties(id, 0);
else
group= NULL;
group= rna_idproperties_get(iter->parent.type, iter->parent.data, 0);
if(group) {
rna_iterator_listbase_end(iter);
rna_iterator_listbase_begin(iter, &group->data.group);
internal= iter->internal;
internal->flag= 1;
if(iter->valid && rna_idproperty_known(iter))
rna_Struct_properties_next(iter);
}
}
}
@ -116,26 +124,7 @@ static void *rna_Struct_properties_get(CollectionPropertyIterator *iter)
return internal->link;
}
static StructRNA *rna_Struct_properties_type(CollectionPropertyIterator *iter)
{
ListBaseIterator *internal= iter->internal;
PropertyRNA *prop= (PropertyRNA*)internal->link;
rna_idproperty_check(&prop, NULL);
switch(prop->type) {
case PROP_BOOLEAN: return &RNA_BooleanProperty;
case PROP_INT: return &RNA_IntProperty;
case PROP_FLOAT: return &RNA_FloatProperty;
case PROP_STRING: return &RNA_StringProperty;
case PROP_ENUM: return &RNA_EnumProperty;
case PROP_POINTER: return &RNA_PointerProperty;
case PROP_COLLECTION: return &RNA_CollectionProperty;
default: return NULL;
}
}
static void rna_builtin_properties_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
void rna_builtin_properties_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
PointerRNA newptr;
@ -155,172 +144,185 @@ static void rna_builtin_properties_begin(CollectionPropertyIterator *iter, Point
rna_Struct_properties_begin(iter, &newptr);
}
static void rna_builtin_properties_next(CollectionPropertyIterator *iter)
void rna_builtin_properties_next(CollectionPropertyIterator *iter)
{
rna_Struct_properties_next(iter);
}
static void *rna_builtin_properties_get(CollectionPropertyIterator *iter)
void *rna_builtin_properties_get(CollectionPropertyIterator *iter)
{
return rna_Struct_properties_get(iter);
}
static StructRNA *rna_builtin_properties_type(CollectionPropertyIterator *iter)
{
return rna_Struct_properties_type(iter);
}
static void *rna_builtin_type_get(PointerRNA *ptr)
void *rna_builtin_type_get(PointerRNA *ptr)
{
return ptr->type;
}
/* Property */
static StructRNA *rna_Property_refine(PointerRNA *ptr)
{
PropertyRNA *prop= (PropertyRNA*)ptr->data;
rna_idproperty_check(&prop, ptr); /* XXX ptr? */
switch(prop->type) {
case PROP_BOOLEAN: return &RNA_BooleanProperty;
case PROP_INT: return &RNA_IntProperty;
case PROP_FLOAT: return &RNA_FloatProperty;
case PROP_STRING: return &RNA_StringProperty;
case PROP_ENUM: return &RNA_EnumProperty;
case PROP_POINTER: return &RNA_PointerProperty;
case PROP_COLLECTION: return &RNA_CollectionProperty;
default: return &RNA_Property;
}
}
static void rna_Property_identifier_get(PointerRNA *ptr, char *value)
{
PropertyRNA *prop= (PropertyRNA*)ptr->data;
rna_idproperty_check(&prop, NULL);
rna_idproperty_check(&prop, ptr);
strcpy(value, ((PropertyRNA*)prop)->identifier);
}
static int rna_Property_identifier_length(PointerRNA *ptr)
{
PropertyRNA *prop= (PropertyRNA*)ptr->data;
rna_idproperty_check(&prop, NULL);
rna_idproperty_check(&prop, ptr);
return strlen(prop->identifier);
}
static void rna_Property_name_get(PointerRNA *ptr, char *value)
{
PropertyRNA *prop= (PropertyRNA*)ptr->data;
rna_idproperty_check(&prop, NULL);
rna_idproperty_check(&prop, ptr);
strcpy(value, prop->name);
}
static int rna_Property_name_length(PointerRNA *ptr)
{
PropertyRNA *prop= (PropertyRNA*)ptr->data;
rna_idproperty_check(&prop, NULL);
rna_idproperty_check(&prop, ptr);
return strlen(prop->name);
}
static void rna_Property_description_get(PointerRNA *ptr, char *value)
{
PropertyRNA *prop= (PropertyRNA*)ptr->data;
rna_idproperty_check(&prop, NULL);
rna_idproperty_check(&prop, ptr);
strcpy(value, prop->description);
}
static int rna_Property_description_length(PointerRNA *ptr)
{
PropertyRNA *prop= (PropertyRNA*)ptr->data;
rna_idproperty_check(&prop, NULL);
rna_idproperty_check(&prop, ptr);
return strlen(prop->description);
}
static int rna_Property_type_get(PointerRNA *ptr)
{
PropertyRNA *prop= (PropertyRNA*)ptr->data;
rna_idproperty_check(&prop, NULL);
rna_idproperty_check(&prop, ptr);
return prop->type;
}
static int rna_Property_subtype_get(PointerRNA *ptr)
{
PropertyRNA *prop= (PropertyRNA*)ptr->data;
rna_idproperty_check(&prop, NULL);
rna_idproperty_check(&prop, ptr);
return prop->subtype;
}
static int rna_Property_array_length_get(PointerRNA *ptr)
{
PropertyRNA *prop= (PropertyRNA*)ptr->data;
rna_idproperty_check(&prop, NULL);
rna_idproperty_check(&prop, ptr);
return prop->arraylength;
}
static int rna_IntProperty_hard_min_get(PointerRNA *ptr)
{
PropertyRNA *prop= (PropertyRNA*)ptr->data;
rna_idproperty_check(&prop, NULL);
rna_idproperty_check(&prop, ptr);
return ((IntPropertyRNA*)prop)->hardmin;
}
static int rna_IntProperty_hard_max_get(PointerRNA *ptr)
{
PropertyRNA *prop= (PropertyRNA*)ptr->data;
rna_idproperty_check(&prop, NULL);
rna_idproperty_check(&prop, ptr);
return ((IntPropertyRNA*)prop)->hardmax;
}
static int rna_IntProperty_soft_min_get(PointerRNA *ptr)
{
PropertyRNA *prop= (PropertyRNA*)ptr->data;
rna_idproperty_check(&prop, NULL);
rna_idproperty_check(&prop, ptr);
return ((IntPropertyRNA*)prop)->softmin;
}
static int rna_IntProperty_soft_max_get(PointerRNA *ptr)
{
PropertyRNA *prop= (PropertyRNA*)ptr->data;
rna_idproperty_check(&prop, NULL);
rna_idproperty_check(&prop, ptr);
return ((IntPropertyRNA*)prop)->softmax;
}
static int rna_IntProperty_step_get(PointerRNA *ptr)
{
PropertyRNA *prop= (PropertyRNA*)ptr->data;
rna_idproperty_check(&prop, NULL);
rna_idproperty_check(&prop, ptr);
return ((IntPropertyRNA*)prop)->step;
}
static float rna_FloatProperty_hard_min_get(PointerRNA *ptr)
{
PropertyRNA *prop= (PropertyRNA*)ptr->data;
rna_idproperty_check(&prop, NULL);
rna_idproperty_check(&prop, ptr);
return ((FloatPropertyRNA*)prop)->hardmin;
}
static float rna_FloatProperty_hard_max_get(PointerRNA *ptr)
{
PropertyRNA *prop= (PropertyRNA*)ptr->data;
rna_idproperty_check(&prop, NULL);
rna_idproperty_check(&prop, ptr);
return ((FloatPropertyRNA*)prop)->hardmax;
}
static float rna_FloatProperty_soft_min_get(PointerRNA *ptr)
{
PropertyRNA *prop= (PropertyRNA*)ptr->data;
rna_idproperty_check(&prop, NULL);
rna_idproperty_check(&prop, ptr);
return ((FloatPropertyRNA*)prop)->softmin;
}
static float rna_FloatProperty_soft_max_get(PointerRNA *ptr)
{
PropertyRNA *prop= (PropertyRNA*)ptr->data;
rna_idproperty_check(&prop, NULL);
rna_idproperty_check(&prop, ptr);
return ((FloatPropertyRNA*)prop)->softmax;
}
static float rna_FloatProperty_step_get(PointerRNA *ptr)
{
PropertyRNA *prop= (PropertyRNA*)ptr->data;
rna_idproperty_check(&prop, NULL);
rna_idproperty_check(&prop, ptr);
return ((FloatPropertyRNA*)prop)->step;
}
static int rna_FloatProperty_precision_get(PointerRNA *ptr)
{
PropertyRNA *prop= (PropertyRNA*)ptr->data;
rna_idproperty_check(&prop, NULL);
rna_idproperty_check(&prop, ptr);
return ((FloatPropertyRNA*)prop)->precision;
}
static int rna_StringProperty_max_length_get(PointerRNA *ptr)
{
PropertyRNA *prop= (PropertyRNA*)ptr->data;
rna_idproperty_check(&prop, NULL);
rna_idproperty_check(&prop, ptr);
return ((StringPropertyRNA*)prop)->maxlength;
}
@ -329,7 +331,7 @@ static void rna_EnumProperty_items_begin(CollectionPropertyIterator *iter, Point
PropertyRNA *prop= (PropertyRNA*)ptr->data;
EnumPropertyRNA *eprop;
rna_idproperty_check(&prop, NULL);
rna_idproperty_check(&prop, ptr);
eprop= (EnumPropertyRNA*)prop;
rna_iterator_array_begin(iter, (void*)eprop->item, sizeof(eprop->item[0]), eprop->totitem);
@ -363,21 +365,53 @@ static int rna_EnumPropertyItem_value_get(PointerRNA *ptr)
static void *rna_PointerProperty_fixed_type_get(PointerRNA *ptr)
{
PropertyRNA *prop= (PropertyRNA*)ptr->data;
rna_idproperty_check(&prop, NULL);
rna_idproperty_check(&prop, ptr);
return ((PointerPropertyRNA*)prop)->structtype;
}
static void *rna_CollectionProperty_fixed_type_get(PointerRNA *ptr)
{
PropertyRNA *prop= (PropertyRNA*)ptr->data;
rna_idproperty_check(&prop, NULL);
rna_idproperty_check(&prop, ptr);
return ((CollectionPropertyRNA*)prop)->structtype;
}
#else
static void rna_def_property(StructRNA *srna)
static void rna_def_struct(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
srna= RNA_def_struct(brna, "Struct", NULL, "Struct Definition");
prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
RNA_def_property_string_funcs(prop, "rna_Struct_name_get", "rna_Struct_name_length", NULL);
RNA_def_property_ui_text(prop, "Name", "Human readable name.");
RNA_def_struct_name_property(srna, prop);
prop= RNA_def_property(srna, "identifier", PROP_STRING, PROP_NONE);
RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
RNA_def_property_string_funcs(prop, "rna_Struct_identifier_get", "rna_Struct_identifier_length", NULL);
RNA_def_property_ui_text(prop, "Identifier", "Unique name used in the code and scripting.");
prop= RNA_def_property(srna, "name_property", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
RNA_def_property_struct_type(prop, "StringProperty");
RNA_def_property_pointer_funcs(prop, "rna_Struct_name_property_get", NULL, NULL);
RNA_def_property_ui_text(prop, "Name Property", "Property that gives the name of the struct.");
prop= RNA_def_property(srna, "properties", PROP_COLLECTION, PROP_NONE);
RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
RNA_def_property_struct_type(prop, "Property");
RNA_def_property_collection_funcs(prop, "rna_Struct_properties_begin", "rna_Struct_properties_next", "rna_iterator_listbase_end", "rna_Struct_properties_get", 0, 0, 0, 0);
RNA_def_property_ui_text(prop, "Properties", "Properties in the struct.");
}
static void rna_def_property(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
static EnumPropertyItem type_items[] = {
{PROP_BOOLEAN, "BOOLEAN", "Boolean"},
@ -398,6 +432,9 @@ static void rna_def_property(StructRNA *srna)
{PROP_ROTATION, "ROTATION", "Rotation"},
{0, NULL, NULL}};
srna= RNA_def_struct(brna, "Property", NULL, "Property Definition");
RNA_def_struct_funcs(srna, NULL, "rna_Property_refine");
prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
RNA_def_property_string_funcs(prop, "rna_Property_name_get", "rna_Property_name_length", NULL);
@ -477,6 +514,16 @@ static void rna_def_number_property(StructRNA *srna, PropertyType type)
}
}
static void rna_def_string_property(StructRNA *srna)
{
PropertyRNA *prop;
prop= RNA_def_property(srna, "max_length", PROP_INT, PROP_UNSIGNED);
RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
RNA_def_property_int_funcs(prop, "rna_StringProperty_max_length_get", NULL);
RNA_def_property_ui_text(prop, "Maximum Length", "Maximum length of the string, 0 means unlimited.");
}
static void rna_def_enum_property(BlenderRNA *brna, StructRNA *srna)
{
PropertyRNA *prop;
@ -487,7 +534,7 @@ static void rna_def_enum_property(BlenderRNA *brna, StructRNA *srna)
RNA_def_property_collection_funcs(prop, "rna_EnumProperty_items_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", 0, 0, 0, 0);
RNA_def_property_ui_text(prop, "Items", "Possible values for the property.");
srna= RNA_def_struct(brna, "EnumPropertyItem", "Enum Item Definition");
srna= RNA_def_struct(brna, "EnumPropertyItem", NULL, "Enum Item Definition");
prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
@ -523,88 +570,41 @@ static void rna_def_pointer_property(StructRNA *srna, PropertyType type)
void RNA_def_rna(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
/* StructRNA */
srna= RNA_def_struct(brna, "Struct", "Struct Definition");
/* Struct*/
rna_def_struct(brna);
prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
RNA_def_property_string_funcs(prop, "rna_Struct_name_get", "rna_Struct_name_length", NULL);
RNA_def_property_ui_text(prop, "Name", "Human readable name.");
RNA_def_struct_name_property(srna, prop);
prop= RNA_def_property(srna, "identifier", PROP_STRING, PROP_NONE);
RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
RNA_def_property_string_funcs(prop, "rna_Struct_identifier_get", "rna_Struct_identifier_length", NULL);
RNA_def_property_ui_text(prop, "Identifier", "Unique name used in the code and scripting.");
prop= RNA_def_property(srna, "name_property", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
RNA_def_property_struct_type(prop, "StringProperty");
RNA_def_property_pointer_funcs(prop, "rna_Struct_name_property_get", NULL, NULL);
RNA_def_property_ui_text(prop, "Name Property", "Property that gives the name of the struct.");
prop= RNA_def_property(srna, "properties", PROP_COLLECTION, PROP_NONE);
RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
RNA_def_property_collection_funcs(prop, "rna_Struct_properties_begin", "rna_Struct_properties_next", "rna_iterator_listbase_end", "rna_Struct_properties_get", "rna_Struct_properties_type", 0, 0, 0);
RNA_def_property_ui_text(prop, "Properties", "Properties in the struct.");
/* Property */
rna_def_property(brna);
/* BooleanProperty */
srna= RNA_def_struct(brna, "BooleanProperty", "Boolean Definition");
rna_def_property(srna);
srna= RNA_def_struct(brna, "BooleanProperty", "Property", "Boolean Definition");
rna_def_number_property(srna, PROP_BOOLEAN);
/* IntProperty */
srna= RNA_def_struct(brna, "IntProperty", "Int Definition");
rna_def_property(srna);
srna= RNA_def_struct(brna, "IntProperty", "Property", "Int Definition");
rna_def_number_property(srna, PROP_INT);
/* FloatProperty */
srna= RNA_def_struct(brna, "FloatProperty", "Float Definition");
rna_def_property(srna);
srna= RNA_def_struct(brna, "FloatProperty", "Property", "Float Definition");
rna_def_number_property(srna, PROP_FLOAT);
/* StringProperty */
srna= RNA_def_struct(brna, "StringProperty", "String Definition");
rna_def_property(srna);
prop= RNA_def_property(srna, "max_length", PROP_INT, PROP_UNSIGNED);
RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
RNA_def_property_int_funcs(prop, "rna_StringProperty_max_length_get", NULL);
RNA_def_property_ui_text(prop, "Maximum Length", "Maximum length of the string, 0 means unlimited.");
srna= RNA_def_struct(brna, "StringProperty", "Property", "String Definition");
rna_def_string_property(srna);
/* EnumProperty */
srna= RNA_def_struct(brna, "EnumProperty", "Enum Definition");
rna_def_property(srna);
srna= RNA_def_struct(brna, "EnumProperty", "Property", "Enum Definition");
rna_def_enum_property(brna, srna);
/* PointerProperty */
srna= RNA_def_struct(brna, "PointerProperty", "Pointer Definition");
rna_def_property(srna);
srna= RNA_def_struct(brna, "PointerProperty", "Property", "Pointer Definition");
rna_def_pointer_property(srna, PROP_POINTER);
/* CollectionProperty */
srna= RNA_def_struct(brna, "CollectionProperty", "Collection Definition");
rna_def_property(srna);
srna= RNA_def_struct(brna, "CollectionProperty", "Property", "Collection Definition");
rna_def_pointer_property(srna, PROP_COLLECTION);
}
void rna_def_builtin_properties(StructRNA *srna)
{
PropertyRNA *prop;
prop= RNA_def_property(srna, "rna_properties", PROP_COLLECTION, PROP_NONE);
RNA_def_property_flag(prop, PROP_BUILTIN);
RNA_def_property_collection_funcs(prop, "rna_builtin_properties_begin", "rna_builtin_properties_next", "rna_iterator_listbase_end", "rna_builtin_properties_get", "rna_builtin_properties_type", 0, 0, 0);
RNA_def_property_ui_text(prop, "Properties", "RNA property collection.");
prop= RNA_def_property(srna, "rna_type", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
RNA_def_property_struct_type(prop, "Struct");
RNA_def_property_pointer_funcs(prop, "rna_builtin_type_get", NULL, NULL);
RNA_def_property_ui_text(prop, "RNA", "RNA type definition.");
}
#endif

@ -64,9 +64,7 @@ void RNA_def_scene(BlenderRNA *brna)
static EnumPropertyItem prop_mode_items[] = {{PROP_SMOOTH, "SMOOTH", "Smooth"}, {PROP_SPHERE, "SPHERE", "Sphere"}, {PROP_ROOT, "ROOT", "Root"}, {PROP_SHARP, "SHARP", "Sharp"}, {PROP_LIN, "LINEAR", "Linear"}, {PROP_CONST, "CONSTANT", "Constant"}, {PROP_RANDOM, "RANDOM", "Random"}, {0, NULL, NULL}};
static EnumPropertyItem unwrapper_items[] = {{0, "CONFORMAL", "Conformal"}, {1, "ANGLEBASED", "Angle Based"}, {0, NULL, NULL}};
srna= RNA_def_struct(brna, "Scene", "Scene");
RNA_def_ID(srna);
srna= RNA_def_struct(brna, "Scene", "ID", "Scene");
prop= RNA_def_property(srna, "camera", PROP_POINTER, PROP_NONE);
RNA_def_property_ui_text(prop, "Active Camera", "Active camera used for rendering the scene.");

@ -0,0 +1,93 @@
/**
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* Contributor(s): Blender Foundation (2008).
*
* ***** END GPL LICENSE BLOCK *****
*/
#include <stdlib.h>
#include "RNA_define.h"
#include "RNA_types.h"
#include "rna_internal.h"
#include "DNA_windowmanager_types.h"
#ifdef RNA_RUNTIME
static StructRNA *rna_Operator_refine(PointerRNA *ptr)
{
wmOperator *op= (wmOperator*)ptr->data;
return op->type->rna;
}
static void rna_Operator_name_get(PointerRNA *ptr, char *value)
{
wmOperator *op= (wmOperator*)ptr->data;
strcpy(value, op->type->name);
}
static int rna_Operator_name_length(PointerRNA *ptr)
{
wmOperator *op= (wmOperator*)ptr->data;
return strlen(op->type->name);
}
#else
static void rna_def_operator(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
srna= RNA_def_struct(brna, "Operator", NULL, "Operator");
RNA_def_struct_sdna(srna, "wmOperator");
RNA_def_struct_funcs(srna, NULL, "rna_Operator_refine");
prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
RNA_def_property_ui_text(prop, "Name", "Operator name.");
RNA_def_property_string_funcs(prop, "rna_Operator_name_get", "rna_Operator_name_length", NULL);
RNA_def_struct_name_property(srna, prop);
}
static void rna_def_windowmanager(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
srna= RNA_def_struct(brna, "WindowManager", "ID", "Window Manager");
RNA_def_struct_sdna(srna, "wmWindowManager");
prop= RNA_def_property(srna, "operators", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_type(prop, "Operator");
RNA_def_property_ui_text(prop, "Operators", "Operator registry.");
}
void RNA_def_wm(BlenderRNA *brna)
{
rna_def_operator(brna);
rna_def_windowmanager(brna);
}
#endif