RNA
* Added support for ID properties, mapped as follows: * IDP Int = RNA Int * IDP Float, Double = RNA Float * IDP_String = RNA String * IDP Group = RNA IDPropertyGroup Struct * IDP_Array = RNA Array * PropertyRNA and StructRNA are now defined private for the module, to force external code to always use accessor functions.
This commit is contained in:
parent
6ea6edfa32
commit
623421d580
|
@ -30,16 +30,6 @@
|
|||
|
||||
#include "DNA_ID.h"
|
||||
|
||||
/*
|
||||
these two are included for their (new :P )function
|
||||
pointers.
|
||||
*/
|
||||
#include "BLO_readfile.h"
|
||||
#include "BLO_writefile.h"
|
||||
|
||||
struct WriteData;
|
||||
struct FileData;
|
||||
|
||||
struct IDProperty;
|
||||
struct ID;
|
||||
|
||||
|
@ -176,5 +166,6 @@ void IDP_UnlinkProperty(struct IDProperty *prop);
|
|||
#define IDP_Float(prop) (*(float*)&prop->data.val)
|
||||
#define IDP_String(prop) ((char*)prop->data.pointer)
|
||||
#define IDP_Array(prop) (prop->data.pointer)
|
||||
#define IDP_Double(prop) (*(double*)&prop->data.val)
|
||||
|
||||
#endif /* _BKE_IDPROP_H */
|
||||
|
|
|
@ -1058,7 +1058,7 @@ int ui_is_but_float(uiBut *but)
|
|||
if(but->pointype==FLO && but->poin)
|
||||
return 1;
|
||||
|
||||
if(but->rnaprop && but->rnaprop->type==PROP_FLOAT && but->rnapoin.data)
|
||||
if(but->rnaprop && RNA_property_type(but->rnaprop, &but->rnapoin) == PROP_FLOAT)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
|
@ -1075,21 +1075,21 @@ double ui_get_but_val(uiBut *but)
|
|||
if(but->rnaprop) {
|
||||
prop= but->rnaprop;
|
||||
|
||||
switch(prop->type) {
|
||||
switch(RNA_property_type(prop, &but->rnapoin)) {
|
||||
case PROP_BOOLEAN:
|
||||
if(prop->arraylength)
|
||||
if(RNA_property_array_length(prop, &but->rnapoin))
|
||||
value= RNA_property_boolean_get_array(prop, &but->rnapoin, but->rnaindex);
|
||||
else
|
||||
value= RNA_property_boolean_get(prop, &but->rnapoin);
|
||||
break;
|
||||
case PROP_INT:
|
||||
if(prop->arraylength)
|
||||
if(RNA_property_array_length(prop, &but->rnapoin))
|
||||
value= RNA_property_int_get_array(prop, &but->rnapoin, but->rnaindex);
|
||||
else
|
||||
value= RNA_property_int_get(prop, &but->rnapoin);
|
||||
break;
|
||||
case PROP_FLOAT:
|
||||
if(prop->arraylength)
|
||||
if(RNA_property_array_length(prop, &but->rnapoin))
|
||||
value= RNA_property_float_get_array(prop, &but->rnapoin, but->rnaindex);
|
||||
else
|
||||
value= RNA_property_float_get(prop, &but->rnapoin);
|
||||
|
@ -1138,21 +1138,21 @@ void ui_set_but_val(uiBut *but, double value)
|
|||
if(but->rnaprop) {
|
||||
prop= but->rnaprop;
|
||||
|
||||
switch(prop->type) {
|
||||
switch(RNA_property_type(prop, &but->rnapoin)) {
|
||||
case PROP_BOOLEAN:
|
||||
if(prop->arraylength)
|
||||
if(RNA_property_array_length(prop, &but->rnapoin))
|
||||
RNA_property_boolean_set_array(prop, &but->rnapoin, but->rnaindex, value);
|
||||
else
|
||||
RNA_property_boolean_set(prop, &but->rnapoin, value);
|
||||
break;
|
||||
case PROP_INT:
|
||||
if(prop->arraylength)
|
||||
if(RNA_property_array_length(prop, &but->rnapoin))
|
||||
RNA_property_int_set_array(prop, &but->rnapoin, but->rnaindex, value);
|
||||
else
|
||||
RNA_property_int_set(prop, &but->rnapoin, value);
|
||||
break;
|
||||
case PROP_FLOAT:
|
||||
if(prop->arraylength)
|
||||
if(RNA_property_array_length(prop, &but->rnapoin))
|
||||
RNA_property_float_set_array(prop, &but->rnapoin, but->rnaindex, value);
|
||||
else
|
||||
RNA_property_float_set(prop, &but->rnapoin, value);
|
||||
|
@ -2283,7 +2283,14 @@ uiBut *uiDefRNABut(uiBlock *block, int retval, PointerRNA *ptr, PropertyRNA *pro
|
|||
break;
|
||||
}
|
||||
case PROP_STRING: {
|
||||
but= ui_def_but(block, TEX, 0, "", x1, y1, x2, y2, NULL, 0, RNA_property_string_maxlength(prop, ptr), 0, 0, (char*)RNA_property_ui_description(prop, ptr));
|
||||
int maxlength;
|
||||
|
||||
maxlength= RNA_property_string_maxlength(prop, ptr);
|
||||
if(maxlength == 0)
|
||||
/* interface code should ideally support unlimited length */
|
||||
maxlength= UI_MAX_DRAW_STR;
|
||||
|
||||
but= ui_def_but(block, TEX, 0, "", x1, y1, x2, y2, NULL, 0, maxlength, 0, 0, (char*)RNA_property_ui_description(prop, ptr));
|
||||
break;
|
||||
}
|
||||
case PROP_POINTER: {
|
||||
|
|
|
@ -174,7 +174,7 @@ static void rna_pointer_cb(void *arg_buts, void *arg_prop, void *arg_index)
|
|||
char *newpath;
|
||||
int index= GET_INT_FROM_POINTER(arg_index);;
|
||||
|
||||
newpath= RNA_path_append(soutliner->rnapath, prop, index, NULL);
|
||||
newpath= RNA_path_append(soutliner->rnapath, NULL, prop, index, NULL);
|
||||
if(soutliner->rnapath)
|
||||
MEM_freeN(soutliner->rnapath);
|
||||
soutliner->rnapath= newpath;
|
||||
|
@ -278,7 +278,6 @@ static void rna_path_but(CellRNA *cell, rcti *rct, uiBlock *block)
|
|||
static void rna_table_cell_func(void *userdata, int row, int col, rcti *rct, uiBlock *block)
|
||||
{
|
||||
CellRNA *cell= userdata;
|
||||
PropertyRNA *prop;
|
||||
PropertyType type;
|
||||
int length;
|
||||
|
||||
|
@ -319,8 +318,6 @@ static void rna_table_cell_func(void *userdata, int row, int col, rcti *rct, uiB
|
|||
cell->lastrow= row;
|
||||
}
|
||||
|
||||
prop= cell->prop;
|
||||
|
||||
/* make button */
|
||||
if(col == 0)
|
||||
rna_label(cell, rct, block);
|
||||
|
|
|
@ -51,9 +51,9 @@ typedef struct IDPropertyData {
|
|||
|
||||
typedef struct IDProperty {
|
||||
struct IDProperty *next, *prev;
|
||||
char name[32];
|
||||
char type, subtype;
|
||||
short flag;
|
||||
char name[32];
|
||||
int saved; /*saved is used to indicate if this struct has been saved yet.
|
||||
seemed like a good idea as a pad var was needed anyway :)*/
|
||||
IDPropertyData data; /* note, alignment for 64 bits */
|
||||
|
@ -69,15 +69,16 @@ typedef struct IDProperty {
|
|||
#define DEFAULT_ALLOC_FOR_NULL_STRINGS 64
|
||||
|
||||
/*->type*/
|
||||
#define IDP_STRING 0
|
||||
#define IDP_INT 1
|
||||
#define IDP_FLOAT 2
|
||||
#define IDP_ARRAY 5
|
||||
#define IDP_GROUP 6
|
||||
#define IDP_STRING 0
|
||||
#define IDP_INT 1
|
||||
#define IDP_FLOAT 2
|
||||
#define IDP_ARRAY 5
|
||||
#define IDP_GROUP 6
|
||||
/* the ID link property type hasn't been implemented yet, this will require
|
||||
some cleanup of blenkernel, most likely.*/
|
||||
#define IDP_ID 7
|
||||
#define IDP_DOUBLE 8
|
||||
#define IDP_ID 7
|
||||
#define IDP_DOUBLE 8
|
||||
#define IDP_NUMTYPES 9
|
||||
|
||||
/* add any future new id property types here.*/
|
||||
|
||||
|
|
|
@ -121,7 +121,8 @@ int RNA_property_collection_lookup_string(PropertyRNA *prop, PointerRNA *ptr, co
|
|||
* particular pointers, which is useful in a number of applications, like
|
||||
* UI code or Actions, though efficiency is a concern. */
|
||||
|
||||
char *RNA_path_append(const char *path, PropertyRNA *prop, int intkey, const char *strkey);
|
||||
char *RNA_path_append(const char *path, PointerRNA *ptr, PropertyRNA *prop,
|
||||
int intkey, const char *strkey);
|
||||
char *RNA_path_back(const char *path);
|
||||
|
||||
int RNA_path_resolve(PointerRNA *ptr, const char *path,
|
||||
|
|
|
@ -25,47 +25,6 @@
|
|||
#ifndef RNA_TYPES
|
||||
#define RNA_TYPES
|
||||
|
||||
#include "DNA_listBase.h"
|
||||
|
||||
struct BlenderRNA;
|
||||
struct StructRNA;
|
||||
struct PropertyRNA;
|
||||
struct PointerRNA;
|
||||
struct CollectionPropertyIterator;
|
||||
struct bContext;
|
||||
|
||||
/* Function Callbacks */
|
||||
|
||||
typedef void (*PropNotifyFunc)(struct bContext *C, 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);
|
||||
typedef void (*PropBooleanArraySetFunc)(struct PointerRNA *ptr, int index, int value);
|
||||
typedef int (*PropIntGetFunc)(struct PointerRNA *ptr);
|
||||
typedef void (*PropIntSetFunc)(struct PointerRNA *ptr, int value);
|
||||
typedef int (*PropIntArrayGetFunc)(struct PointerRNA *ptr, int index);
|
||||
typedef void (*PropIntArraySetFunc)(struct PointerRNA *ptr, int index, int value);
|
||||
typedef float (*PropFloatGetFunc)(struct PointerRNA *ptr);
|
||||
typedef void (*PropFloatSetFunc)(struct PointerRNA *ptr, float value);
|
||||
typedef float (*PropFloatArrayGetFunc)(struct PointerRNA *ptr, int index);
|
||||
typedef void (*PropFloatArraySetFunc)(struct PointerRNA *ptr, int index, float value);
|
||||
typedef void (*PropStringGetFunc)(struct PointerRNA *ptr, char *value);
|
||||
typedef int (*PropStringLengthFunc)(struct PointerRNA *ptr);
|
||||
typedef void (*PropStringSetFunc)(struct PointerRNA *ptr, const char *value);
|
||||
typedef int (*PropEnumGetFunc)(struct PointerRNA *ptr);
|
||||
typedef void (*PropEnumSetFunc)(struct PointerRNA *ptr, int value);
|
||||
typedef void* (*PropPointerGetFunc)(struct PointerRNA *ptr);
|
||||
typedef void (*PropPointerSetFunc)(struct PointerRNA *ptr, void *value);
|
||||
typedef struct StructRNA* (*PropPointerTypeFunc)(struct PointerRNA *ptr);
|
||||
typedef void (*PropCollectionBeginFunc)(struct CollectionPropertyIterator *iter, struct PointerRNA *ptr);
|
||||
typedef void (*PropCollectionNextFunc)(struct CollectionPropertyIterator *iter);
|
||||
typedef void (*PropCollectionEndFunc)(struct CollectionPropertyIterator *iter);
|
||||
typedef void* (*PropCollectionGetFunc)(struct CollectionPropertyIterator *iter);
|
||||
typedef struct StructRNA* (*PropCollectionTypeFunc)(struct CollectionPropertyIterator *iter);
|
||||
typedef int (*PropCollectionLengthFunc)(struct PointerRNA *ptr);
|
||||
typedef void* (*PropCollectionLookupIntFunc)(struct PointerRNA *ptr, int key, struct StructRNA **type);
|
||||
typedef void* (*PropCollectionLookupStringFunc)(struct PointerRNA *ptr, const char *key, struct StructRNA **type);
|
||||
|
||||
/* Pointer
|
||||
*
|
||||
* RNA pointers are not a single C pointer but include the type,
|
||||
|
@ -135,8 +94,9 @@ typedef enum PropertyFlag {
|
|||
PROP_INVERSE_RENDER_DEPENDENCY = 64,
|
||||
#endif
|
||||
|
||||
/* internal flag */
|
||||
PROP_BUILTIN = 128
|
||||
/* internal flags */
|
||||
PROP_BUILTIN = 128,
|
||||
PROP_EXPORT = 256
|
||||
} PropertyFlag;
|
||||
|
||||
typedef struct CollectionPropertyIterator {
|
||||
|
@ -153,128 +113,8 @@ typedef struct EnumPropertyItem {
|
|||
const char *name;
|
||||
} EnumPropertyItem;
|
||||
|
||||
typedef struct PropertyRNA {
|
||||
struct PropertyRNA *next, *prev;
|
||||
|
||||
/* C code name */
|
||||
const char *identifier;
|
||||
/* various options */
|
||||
int flag;
|
||||
|
||||
/* user readable name */
|
||||
const char *name;
|
||||
/* single line description, displayed in the tooltip for example */
|
||||
const char *description;
|
||||
|
||||
/* property type as it appears to the outside */
|
||||
PropertyType type;
|
||||
/* subtype, 'interpretation' of the property */
|
||||
PropertySubType subtype;
|
||||
/* if an array this is > 0, specifying the length */
|
||||
unsigned int arraylength;
|
||||
|
||||
/* callback for notifys on change */
|
||||
PropNotifyFunc notify;
|
||||
} PropertyRNA;
|
||||
|
||||
/* Property Types */
|
||||
|
||||
typedef struct BooleanPropertyRNA {
|
||||
PropertyRNA property;
|
||||
|
||||
PropBooleanGetFunc get;
|
||||
PropBooleanSetFunc set;
|
||||
|
||||
PropBooleanArrayGetFunc getarray;
|
||||
PropBooleanArraySetFunc setarray;
|
||||
|
||||
int defaultvalue;
|
||||
const int *defaultarray;
|
||||
} BooleanPropertyRNA;
|
||||
|
||||
typedef struct IntPropertyRNA {
|
||||
PropertyRNA property;
|
||||
|
||||
PropIntGetFunc get;
|
||||
PropIntSetFunc set;
|
||||
|
||||
PropIntArrayGetFunc getarray;
|
||||
PropIntArraySetFunc setarray;
|
||||
|
||||
int softmin, softmax;
|
||||
int hardmin, hardmax;
|
||||
int step;
|
||||
|
||||
int defaultvalue;
|
||||
const int *defaultarray;
|
||||
} IntPropertyRNA;
|
||||
|
||||
typedef struct FloatPropertyRNA {
|
||||
PropertyRNA property;
|
||||
|
||||
PropFloatGetFunc get;
|
||||
PropFloatSetFunc set;
|
||||
|
||||
PropFloatArrayGetFunc getarray;
|
||||
PropFloatArraySetFunc setarray;
|
||||
|
||||
float softmin, softmax;
|
||||
float hardmin, hardmax;
|
||||
float step;
|
||||
int precision;
|
||||
|
||||
float defaultvalue;
|
||||
const float *defaultarray;
|
||||
} FloatPropertyRNA;
|
||||
|
||||
typedef struct StringPropertyRNA {
|
||||
PropertyRNA property;
|
||||
|
||||
PropStringGetFunc get;
|
||||
PropStringLengthFunc length;
|
||||
PropStringSetFunc set;
|
||||
|
||||
int maxlength; /* includes string terminator! */
|
||||
|
||||
const char *defaultvalue;
|
||||
} StringPropertyRNA;
|
||||
|
||||
typedef struct EnumPropertyRNA {
|
||||
PropertyRNA property;
|
||||
|
||||
PropEnumGetFunc get;
|
||||
PropEnumSetFunc set;
|
||||
|
||||
const EnumPropertyItem *item;
|
||||
int totitem;
|
||||
|
||||
int defaultvalue;
|
||||
} EnumPropertyRNA;
|
||||
|
||||
typedef struct PointerPropertyRNA {
|
||||
PropertyRNA property;
|
||||
|
||||
PropPointerGetFunc get;
|
||||
PropPointerSetFunc set;
|
||||
PropPointerTypeFunc type; /* optional */
|
||||
|
||||
struct StructRNA *structtype;
|
||||
} PointerPropertyRNA;
|
||||
|
||||
typedef struct CollectionPropertyRNA {
|
||||
PropertyRNA property;
|
||||
|
||||
PropCollectionBeginFunc begin;
|
||||
PropCollectionNextFunc next;
|
||||
PropCollectionEndFunc end; /* optional */
|
||||
PropCollectionGetFunc get;
|
||||
PropCollectionTypeFunc type; /* optional */
|
||||
PropCollectionLengthFunc length; /* optional */
|
||||
PropCollectionLookupIntFunc lookupint; /* optional */
|
||||
PropCollectionLookupStringFunc lookupstring; /* optional */
|
||||
|
||||
struct StructRNA *structtype;
|
||||
} CollectionPropertyRNA;
|
||||
struct PropertyRNA;
|
||||
typedef struct PropertyRNA PropertyRNA;
|
||||
|
||||
/* Struct */
|
||||
|
||||
|
@ -283,34 +123,15 @@ typedef enum StructFlag {
|
|||
STRUCT_ID = 1
|
||||
} StructFlag;
|
||||
|
||||
typedef struct StructRNA {
|
||||
struct StructRNA *next, *prev;
|
||||
|
||||
/* C code name */
|
||||
const char *identifier;
|
||||
/* various options */
|
||||
int flag;
|
||||
|
||||
/* user readable name */
|
||||
const char *name;
|
||||
|
||||
/* property that defines the name */
|
||||
PropertyRNA *nameproperty;
|
||||
|
||||
/* property to iterate over properties */
|
||||
PropertyRNA *iteratorproperty;
|
||||
|
||||
/* properties of this struct */
|
||||
ListBase properties;
|
||||
} StructRNA;
|
||||
struct StructRNA;
|
||||
typedef struct StructRNA StructRNA;
|
||||
|
||||
/* Blender RNA
|
||||
*
|
||||
* Root RNA data structure that lists all struct types. */
|
||||
|
||||
typedef struct BlenderRNA {
|
||||
ListBase structs;
|
||||
} BlenderRNA;
|
||||
struct BlenderRNA;
|
||||
typedef struct BlenderRNA BlenderRNA;
|
||||
|
||||
#endif /* RNA_TYPES */
|
||||
|
||||
|
|
|
@ -545,7 +545,7 @@ static void rna_generate_struct(BlenderRNA *brna, StructRNA *srna, FILE *f)
|
|||
fprintf(f, "\n");
|
||||
|
||||
for(prop=srna->properties.first; prop; prop=prop->next)
|
||||
fprintf(f, "static %s rna_%s_%s;\n", rna_property_structname(prop->type), srna->identifier, prop->identifier);
|
||||
fprintf(f, "%s%s rna_%s_%s;\n", (prop->flag & PROP_EXPORT)? "": "static ", rna_property_structname(prop->type), srna->identifier, prop->identifier);
|
||||
fprintf(f, "\n");
|
||||
|
||||
for(prop=srna->properties.first; prop; prop=prop->next) {
|
||||
|
@ -628,13 +628,14 @@ static void rna_generate_struct(BlenderRNA *brna, StructRNA *srna, FILE *f)
|
|||
break;
|
||||
}
|
||||
|
||||
fprintf(f, "static %s rna_%s_%s = {\n", rna_property_structname(prop->type), srna->identifier, prop->identifier);
|
||||
fprintf(f, "%s%s rna_%s_%s = {\n", (prop->flag & PROP_EXPORT)? "": "static ", rna_property_structname(prop->type), srna->identifier, prop->identifier);
|
||||
|
||||
if(prop->next) fprintf(f, "\t{(PropertyRNA*)&rna_%s_%s, ", srna->identifier, prop->next->identifier);
|
||||
else fprintf(f, "\t{NULL, ");
|
||||
if(prop->prev) fprintf(f, "(PropertyRNA*)&rna_%s_%s,\n", srna->identifier, prop->prev->identifier);
|
||||
else fprintf(f, "NULL,\n");
|
||||
fprintf(f, "\t"); rna_print_c_string(f, prop->identifier);
|
||||
fprintf(f, "\t%d, ", prop->magic);
|
||||
rna_print_c_string(f, prop->identifier);
|
||||
fprintf(f, ", %d, ", prop->flag);
|
||||
rna_print_c_string(f, prop->name); fprintf(f, ",\n\t");
|
||||
rna_print_c_string(f, prop->description); fprintf(f, ",\n");
|
||||
|
@ -738,7 +739,7 @@ typedef struct RNAProcessItem {
|
|||
} RNAProcessItem;
|
||||
|
||||
RNAProcessItem PROCESS_ITEMS[]= {
|
||||
{"rna_ID.c", NULL},
|
||||
{"rna_ID.c", RNA_def_ID_types},
|
||||
{"rna_main.c", RNA_def_main},
|
||||
{"rna_mesh.c", RNA_def_mesh},
|
||||
{"rna_object.c", RNA_def_object},
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "RNA_define.h"
|
||||
#include "RNA_types.h"
|
||||
|
@ -31,6 +32,8 @@
|
|||
|
||||
#ifdef RNA_RUNTIME
|
||||
|
||||
#include "BKE_idprop.h"
|
||||
|
||||
/* name functions that ignore the first two ID characters */
|
||||
static void rna_ID_name_get(PointerRNA *ptr, char *value)
|
||||
{
|
||||
|
@ -50,8 +53,164 @@ 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)
|
||||
{
|
||||
IDProperty *prop= (IDProperty*)ptr->data;
|
||||
strcpy(value, IDP_String(prop));
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static void RNA_def_ID_property(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");
|
||||
|
||||
/* 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");
|
||||
|
||||
/* 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");
|
||||
|
||||
prop= RNA_def_property(srna, "intarray", PROP_INT, PROP_NONE);
|
||||
RNA_def_property_flag(prop, PROP_EXPORT);
|
||||
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");
|
||||
|
||||
prop= RNA_def_property(srna, "floatarray", PROP_FLOAT, PROP_NONE);
|
||||
RNA_def_property_flag(prop, PROP_EXPORT);
|
||||
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");
|
||||
|
||||
prop= RNA_def_property(srna, "doublearray", PROP_FLOAT, PROP_NONE);
|
||||
RNA_def_property_flag(prop, PROP_EXPORT);
|
||||
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_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");
|
||||
}
|
||||
|
||||
void RNA_def_ID(StructRNA *srna)
|
||||
{
|
||||
PropertyRNA *prop;
|
||||
|
@ -65,5 +224,10 @@ void RNA_def_ID(StructRNA *srna)
|
|||
RNA_def_struct_name_property(srna, prop);
|
||||
}
|
||||
|
||||
void RNA_def_ID_types(BlenderRNA *brna)
|
||||
{
|
||||
RNA_def_ID_property(brna);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
#include "BLI_blenlib.h"
|
||||
#include "BLI_dynstr.h"
|
||||
|
||||
#include "DNA_ID.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
#include "RNA_types.h"
|
||||
|
||||
|
@ -57,6 +59,51 @@ static void rna_pointer_inherit_id(PointerRNA *parent, PointerRNA *ptr)
|
|||
}
|
||||
}
|
||||
|
||||
/* ID Properties */
|
||||
|
||||
IDProperty *rna_idproperty_check(PropertyRNA **prop, PointerRNA *ptr)
|
||||
{
|
||||
/* This is quite a hack, but avoids some complexity in the API. we
|
||||
* pass IDProperty structs as PropertyRNA pointers to the outside.
|
||||
* We store some bytes in PropertyRNA structs that allows us to
|
||||
* distinguish it from IDProperty structs. If it is an ID property,
|
||||
* we look up an IDP PropertyRNA based on the type, and set the data
|
||||
* pointer to the IDProperty. */
|
||||
|
||||
/* these bytes have */
|
||||
if((*prop)->magic == RNA_MAGIC) {
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
static PropertyRNA *typemap[IDP_NUMTYPES] =
|
||||
{(PropertyRNA*)&rna_IDProperty_string,
|
||||
(PropertyRNA*)&rna_IDProperty_int,
|
||||
(PropertyRNA*)&rna_IDProperty_float,
|
||||
NULL, NULL, NULL,
|
||||
(PropertyRNA*)&rna_IDProperty_group, NULL,
|
||||
(PropertyRNA*)&rna_IDProperty_double};
|
||||
|
||||
static PropertyRNA *arraytypemap[IDP_NUMTYPES] =
|
||||
{NULL, (PropertyRNA*)&rna_IDProperty_intarray,
|
||||
(PropertyRNA*)&rna_IDProperty_floatarray,
|
||||
NULL, NULL, NULL, NULL, NULL,
|
||||
(PropertyRNA*)&rna_IDProperty_doublearray};
|
||||
|
||||
IDProperty *idprop;
|
||||
|
||||
idprop= (IDProperty*)*prop;
|
||||
if(idprop->type == IDP_ARRAY)
|
||||
*prop= arraytypemap[(int)(idprop->subtype)];
|
||||
else
|
||||
*prop= typemap[(int)(idprop->type)];
|
||||
|
||||
if(ptr)
|
||||
ptr->data= idprop;
|
||||
|
||||
return idprop;
|
||||
}
|
||||
}
|
||||
|
||||
/* Structs */
|
||||
|
||||
const char *RNA_struct_identifier(PointerRNA *ptr)
|
||||
|
@ -83,27 +130,44 @@ PropertyRNA *RNA_struct_iterator_property(PointerRNA *ptr)
|
|||
|
||||
const char *RNA_property_identifier(PropertyRNA *prop, PointerRNA *ptr)
|
||||
{
|
||||
return prop->identifier;
|
||||
IDProperty *idprop;
|
||||
|
||||
if((idprop=rna_idproperty_check(&prop, NULL)))
|
||||
return idprop->name;
|
||||
else
|
||||
return prop->identifier;
|
||||
}
|
||||
|
||||
PropertyType RNA_property_type(PropertyRNA *prop, PointerRNA *ptr)
|
||||
{
|
||||
rna_idproperty_check(&prop, NULL);
|
||||
|
||||
return prop->type;
|
||||
}
|
||||
|
||||
PropertySubType RNA_property_subtype(PropertyRNA *prop, PointerRNA *ptr)
|
||||
{
|
||||
rna_idproperty_check(&prop, NULL);
|
||||
|
||||
return prop->subtype;
|
||||
}
|
||||
|
||||
int RNA_property_array_length(PropertyRNA *prop, PointerRNA *ptr)
|
||||
{
|
||||
return prop->arraylength;
|
||||
IDProperty *idprop;
|
||||
|
||||
if((idprop=rna_idproperty_check(&prop, NULL)) && idprop->type==IDP_ARRAY)
|
||||
return idprop->len;
|
||||
else
|
||||
return prop->arraylength;
|
||||
}
|
||||
|
||||
void RNA_property_int_range(PropertyRNA *prop, PointerRNA *ptr, int *hardmin, int *hardmax)
|
||||
{
|
||||
IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
|
||||
IntPropertyRNA *iprop;
|
||||
|
||||
rna_idproperty_check(&prop, NULL);
|
||||
iprop= (IntPropertyRNA*)prop;
|
||||
|
||||
*hardmin= iprop->hardmin;
|
||||
*hardmax= iprop->hardmax;
|
||||
|
@ -111,7 +175,10 @@ void RNA_property_int_range(PropertyRNA *prop, PointerRNA *ptr, int *hardmin, in
|
|||
|
||||
void RNA_property_int_ui_range(PropertyRNA *prop, PointerRNA *ptr, int *softmin, int *softmax, int *step)
|
||||
{
|
||||
IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
|
||||
IntPropertyRNA *iprop;
|
||||
|
||||
rna_idproperty_check(&prop, NULL);
|
||||
iprop= (IntPropertyRNA*)prop;
|
||||
|
||||
*softmin= iprop->softmin;
|
||||
*softmax= iprop->softmax;
|
||||
|
@ -120,7 +187,10 @@ void RNA_property_int_ui_range(PropertyRNA *prop, PointerRNA *ptr, int *softmin,
|
|||
|
||||
void RNA_property_float_range(PropertyRNA *prop, PointerRNA *ptr, float *hardmin, float *hardmax)
|
||||
{
|
||||
FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop;
|
||||
FloatPropertyRNA *fprop;
|
||||
|
||||
rna_idproperty_check(&prop, NULL);
|
||||
fprop= (FloatPropertyRNA*)prop;
|
||||
|
||||
*hardmin= fprop->hardmin;
|
||||
*hardmax= fprop->hardmax;
|
||||
|
@ -128,7 +198,10 @@ void RNA_property_float_range(PropertyRNA *prop, PointerRNA *ptr, float *hardmin
|
|||
|
||||
void RNA_property_float_ui_range(PropertyRNA *prop, PointerRNA *ptr, float *softmin, float *softmax, float *step, float *precision)
|
||||
{
|
||||
FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop;
|
||||
FloatPropertyRNA *fprop;
|
||||
|
||||
rna_idproperty_check(&prop, NULL);
|
||||
fprop= (FloatPropertyRNA*)prop;
|
||||
|
||||
*softmin= fprop->softmin;
|
||||
*softmax= fprop->softmax;
|
||||
|
@ -138,14 +211,20 @@ void RNA_property_float_ui_range(PropertyRNA *prop, PointerRNA *ptr, float *soft
|
|||
|
||||
int RNA_property_string_maxlength(PropertyRNA *prop, PointerRNA *ptr)
|
||||
{
|
||||
StringPropertyRNA *sprop= (StringPropertyRNA*)prop;
|
||||
StringPropertyRNA *sprop;
|
||||
|
||||
rna_idproperty_check(&prop, NULL);
|
||||
sprop= (StringPropertyRNA*)prop;
|
||||
|
||||
return sprop->maxlength;
|
||||
}
|
||||
|
||||
void RNA_property_enum_items(PropertyRNA *prop, PointerRNA *ptr, const EnumPropertyItem **item, int *totitem)
|
||||
{
|
||||
EnumPropertyRNA *eprop= (EnumPropertyRNA*)prop;
|
||||
EnumPropertyRNA *eprop;
|
||||
|
||||
rna_idproperty_check(&prop, NULL);
|
||||
eprop= (EnumPropertyRNA*)prop;
|
||||
|
||||
*item= eprop->item;
|
||||
*totitem= eprop->totitem;
|
||||
|
@ -153,42 +232,62 @@ void RNA_property_enum_items(PropertyRNA *prop, PointerRNA *ptr, const EnumPrope
|
|||
|
||||
const char *RNA_property_ui_name(PropertyRNA *prop, PointerRNA *ptr)
|
||||
{
|
||||
return prop->name;
|
||||
IDProperty *idprop;
|
||||
|
||||
if((idprop=rna_idproperty_check(&prop, NULL)))
|
||||
return idprop->name;
|
||||
else
|
||||
return prop->name;
|
||||
}
|
||||
|
||||
const char *RNA_property_ui_description(PropertyRNA *prop, PointerRNA *ptr)
|
||||
{
|
||||
return prop->description;
|
||||
if(rna_idproperty_check(&prop, NULL))
|
||||
return "";
|
||||
else
|
||||
return prop->description;
|
||||
}
|
||||
|
||||
/* Property Data */
|
||||
|
||||
int RNA_property_editable(PropertyRNA *prop, PointerRNA *ptr)
|
||||
{
|
||||
rna_idproperty_check(&prop, NULL);
|
||||
|
||||
return !(prop->flag & PROP_NOT_EDITABLE);
|
||||
}
|
||||
|
||||
int RNA_property_evaluated(PropertyRNA *prop, PointerRNA *ptr)
|
||||
{
|
||||
rna_idproperty_check(&prop, NULL);
|
||||
|
||||
return (prop->flag & PROP_EVALUATED);
|
||||
}
|
||||
|
||||
void RNA_property_notify(PropertyRNA *prop, struct bContext *C, PointerRNA *ptr)
|
||||
{
|
||||
rna_idproperty_check(&prop, NULL);
|
||||
|
||||
if(prop->notify)
|
||||
prop->notify(C, ptr);
|
||||
}
|
||||
|
||||
/* Property Data */
|
||||
|
||||
int RNA_property_boolean_get(PropertyRNA *prop, PointerRNA *ptr)
|
||||
{
|
||||
BooleanPropertyRNA *bprop= (BooleanPropertyRNA*)prop;
|
||||
BooleanPropertyRNA *bprop;
|
||||
|
||||
rna_idproperty_check(&prop, ptr);
|
||||
bprop= (BooleanPropertyRNA*)prop;
|
||||
|
||||
return bprop->get(ptr);
|
||||
}
|
||||
|
||||
void RNA_property_boolean_set(PropertyRNA *prop, PointerRNA *ptr, int value)
|
||||
{
|
||||
BooleanPropertyRNA *bprop= (BooleanPropertyRNA*)prop;
|
||||
BooleanPropertyRNA *bprop;
|
||||
|
||||
rna_idproperty_check(&prop, ptr);
|
||||
bprop= (BooleanPropertyRNA*)prop;
|
||||
|
||||
if(bprop->set)
|
||||
bprop->set(ptr, value);
|
||||
|
@ -196,14 +295,20 @@ void RNA_property_boolean_set(PropertyRNA *prop, PointerRNA *ptr, int value)
|
|||
|
||||
int RNA_property_boolean_get_array(PropertyRNA *prop, PointerRNA *ptr, int index)
|
||||
{
|
||||
BooleanPropertyRNA *bprop= (BooleanPropertyRNA*)prop;
|
||||
BooleanPropertyRNA *bprop;
|
||||
|
||||
rna_idproperty_check(&prop, ptr);
|
||||
bprop= (BooleanPropertyRNA*)prop;
|
||||
|
||||
return bprop->getarray(ptr, index);
|
||||
}
|
||||
|
||||
void RNA_property_boolean_set_array(PropertyRNA *prop, PointerRNA *ptr, int index, int value)
|
||||
{
|
||||
BooleanPropertyRNA *bprop= (BooleanPropertyRNA*)prop;
|
||||
BooleanPropertyRNA *bprop;
|
||||
|
||||
rna_idproperty_check(&prop, ptr);
|
||||
bprop= (BooleanPropertyRNA*)prop;
|
||||
|
||||
if(bprop->setarray)
|
||||
bprop->setarray(ptr, index, value);
|
||||
|
@ -211,14 +316,20 @@ void RNA_property_boolean_set_array(PropertyRNA *prop, PointerRNA *ptr, int inde
|
|||
|
||||
int RNA_property_int_get(PropertyRNA *prop, PointerRNA *ptr)
|
||||
{
|
||||
IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
|
||||
IntPropertyRNA *iprop;
|
||||
|
||||
rna_idproperty_check(&prop, ptr);
|
||||
iprop= (IntPropertyRNA*)prop;
|
||||
|
||||
return iprop->get(ptr);
|
||||
}
|
||||
|
||||
void RNA_property_int_set(PropertyRNA *prop, PointerRNA *ptr, int value)
|
||||
{
|
||||
IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
|
||||
IntPropertyRNA *iprop;
|
||||
|
||||
rna_idproperty_check(&prop, ptr);
|
||||
iprop= (IntPropertyRNA*)prop;
|
||||
|
||||
if(iprop->set)
|
||||
iprop->set(ptr, value);
|
||||
|
@ -226,14 +337,20 @@ void RNA_property_int_set(PropertyRNA *prop, PointerRNA *ptr, int value)
|
|||
|
||||
int RNA_property_int_get_array(PropertyRNA *prop, PointerRNA *ptr, int index)
|
||||
{
|
||||
IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
|
||||
IntPropertyRNA *iprop;
|
||||
|
||||
rna_idproperty_check(&prop, ptr);
|
||||
iprop= (IntPropertyRNA*)prop;
|
||||
|
||||
return iprop->getarray(ptr, index);
|
||||
}
|
||||
|
||||
void RNA_property_int_set_array(PropertyRNA *prop, PointerRNA *ptr, int index, int value)
|
||||
{
|
||||
IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
|
||||
IntPropertyRNA *iprop;
|
||||
|
||||
rna_idproperty_check(&prop, ptr);
|
||||
iprop= (IntPropertyRNA*)prop;
|
||||
|
||||
if(iprop->setarray)
|
||||
iprop->setarray(ptr, index, value);
|
||||
|
@ -241,14 +358,20 @@ void RNA_property_int_set_array(PropertyRNA *prop, PointerRNA *ptr, int index, i
|
|||
|
||||
float RNA_property_float_get(PropertyRNA *prop, PointerRNA *ptr)
|
||||
{
|
||||
FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop;
|
||||
FloatPropertyRNA *fprop;
|
||||
|
||||
rna_idproperty_check(&prop, ptr);
|
||||
fprop= (FloatPropertyRNA*)prop;
|
||||
|
||||
return fprop->get(ptr);
|
||||
}
|
||||
|
||||
void RNA_property_float_set(PropertyRNA *prop, PointerRNA *ptr, float value)
|
||||
{
|
||||
FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop;
|
||||
FloatPropertyRNA *fprop;
|
||||
|
||||
rna_idproperty_check(&prop, ptr);
|
||||
fprop= (FloatPropertyRNA*)prop;
|
||||
|
||||
if(fprop->set)
|
||||
fprop->set(ptr, value);
|
||||
|
@ -256,14 +379,20 @@ void RNA_property_float_set(PropertyRNA *prop, PointerRNA *ptr, float value)
|
|||
|
||||
float RNA_property_float_get_array(PropertyRNA *prop, PointerRNA *ptr, int index)
|
||||
{
|
||||
FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop;
|
||||
FloatPropertyRNA *fprop;
|
||||
|
||||
rna_idproperty_check(&prop, ptr);
|
||||
fprop= (FloatPropertyRNA*)prop;
|
||||
|
||||
return fprop->getarray(ptr, index);
|
||||
}
|
||||
|
||||
void RNA_property_float_set_array(PropertyRNA *prop, PointerRNA *ptr, int index, float value)
|
||||
{
|
||||
FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop;
|
||||
FloatPropertyRNA *fprop;
|
||||
|
||||
rna_idproperty_check(&prop, ptr);
|
||||
fprop= (FloatPropertyRNA*)prop;
|
||||
|
||||
if(fprop->setarray)
|
||||
fprop->setarray(ptr, index, value);
|
||||
|
@ -271,7 +400,10 @@ void RNA_property_float_set_array(PropertyRNA *prop, PointerRNA *ptr, int index,
|
|||
|
||||
void RNA_property_string_get(PropertyRNA *prop, PointerRNA *ptr, char *value)
|
||||
{
|
||||
StringPropertyRNA *sprop= (StringPropertyRNA*)prop;
|
||||
StringPropertyRNA *sprop;
|
||||
|
||||
rna_idproperty_check(&prop, ptr);
|
||||
sprop= (StringPropertyRNA*)prop;
|
||||
|
||||
sprop->get(ptr, value);
|
||||
}
|
||||
|
@ -281,6 +413,8 @@ char *RNA_property_string_get_alloc(PropertyRNA *prop, PointerRNA *ptr, char *fi
|
|||
char *buf;
|
||||
int length;
|
||||
|
||||
rna_idproperty_check(&prop, ptr);
|
||||
|
||||
length= RNA_property_string_length(prop, ptr);
|
||||
|
||||
if(length+1 < fixedlen)
|
||||
|
@ -295,14 +429,20 @@ char *RNA_property_string_get_alloc(PropertyRNA *prop, PointerRNA *ptr, char *fi
|
|||
|
||||
int RNA_property_string_length(PropertyRNA *prop, PointerRNA *ptr)
|
||||
{
|
||||
StringPropertyRNA *sprop= (StringPropertyRNA*)prop;
|
||||
StringPropertyRNA *sprop;
|
||||
|
||||
rna_idproperty_check(&prop, ptr);
|
||||
sprop= (StringPropertyRNA*)prop;
|
||||
|
||||
return sprop->length(ptr);
|
||||
}
|
||||
|
||||
void RNA_property_string_set(PropertyRNA *prop, PointerRNA *ptr, const char *value)
|
||||
{
|
||||
StringPropertyRNA *sprop= (StringPropertyRNA*)prop;
|
||||
StringPropertyRNA *sprop;
|
||||
|
||||
rna_idproperty_check(&prop, ptr);
|
||||
sprop= (StringPropertyRNA*)prop;
|
||||
|
||||
if(sprop->set)
|
||||
sprop->set(ptr, value);
|
||||
|
@ -310,14 +450,20 @@ void RNA_property_string_set(PropertyRNA *prop, PointerRNA *ptr, const char *val
|
|||
|
||||
int RNA_property_enum_get(PropertyRNA *prop, PointerRNA *ptr)
|
||||
{
|
||||
EnumPropertyRNA *eprop= (EnumPropertyRNA*)prop;
|
||||
EnumPropertyRNA *eprop;
|
||||
|
||||
rna_idproperty_check(&prop, ptr);
|
||||
eprop= (EnumPropertyRNA*)prop;
|
||||
|
||||
return eprop->get(ptr);
|
||||
}
|
||||
|
||||
void RNA_property_enum_set(PropertyRNA *prop, PointerRNA *ptr, int value)
|
||||
{
|
||||
EnumPropertyRNA *eprop= (EnumPropertyRNA*)prop;
|
||||
EnumPropertyRNA *eprop;
|
||||
|
||||
rna_idproperty_check(&prop, ptr);
|
||||
eprop= (EnumPropertyRNA*)prop;
|
||||
|
||||
if(eprop->set)
|
||||
eprop->set(ptr, value);
|
||||
|
@ -325,7 +471,10 @@ void RNA_property_enum_set(PropertyRNA *prop, PointerRNA *ptr, int value)
|
|||
|
||||
void RNA_property_pointer_get(PropertyRNA *prop, PointerRNA *ptr, PointerRNA *r_ptr)
|
||||
{
|
||||
PointerPropertyRNA *pprop= (PointerPropertyRNA*)prop;
|
||||
PointerPropertyRNA *pprop;
|
||||
|
||||
rna_idproperty_check(&prop, ptr);
|
||||
pprop= (PointerPropertyRNA*)prop;
|
||||
|
||||
r_ptr->data= pprop->get(ptr);
|
||||
|
||||
|
@ -339,7 +488,10 @@ void RNA_property_pointer_get(PropertyRNA *prop, PointerRNA *ptr, PointerRNA *r_
|
|||
|
||||
void RNA_property_pointer_set(PropertyRNA *prop, PointerRNA *ptr, PointerRNA *ptr_value)
|
||||
{
|
||||
PointerPropertyRNA *pprop= (PointerPropertyRNA*)prop;
|
||||
PointerPropertyRNA *pprop;
|
||||
|
||||
rna_idproperty_check(&prop, ptr);
|
||||
pprop= (PointerPropertyRNA*)prop;
|
||||
|
||||
if(pprop->set)
|
||||
pprop->set(ptr, ptr_value->data);
|
||||
|
@ -347,7 +499,10 @@ void RNA_property_pointer_set(PropertyRNA *prop, PointerRNA *ptr, PointerRNA *pt
|
|||
|
||||
StructRNA *RNA_property_pointer_type(PropertyRNA *prop, PointerRNA *ptr)
|
||||
{
|
||||
PointerPropertyRNA *pprop= (PointerPropertyRNA*)prop;
|
||||
PointerPropertyRNA *pprop;
|
||||
|
||||
rna_idproperty_check(&prop, ptr);
|
||||
pprop= (PointerPropertyRNA*)prop;
|
||||
|
||||
if(pprop->type)
|
||||
return pprop->type(ptr);
|
||||
|
@ -357,7 +512,10 @@ StructRNA *RNA_property_pointer_type(PropertyRNA *prop, PointerRNA *ptr)
|
|||
|
||||
static StructRNA *rna_property_collection_type(PropertyRNA *prop, CollectionPropertyIterator *iter)
|
||||
{
|
||||
CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
|
||||
CollectionPropertyRNA *cprop;
|
||||
|
||||
rna_idproperty_check(&prop, NULL);
|
||||
cprop= (CollectionPropertyRNA*)prop;
|
||||
|
||||
if(cprop->type)
|
||||
return cprop->type(iter);
|
||||
|
@ -367,7 +525,10 @@ static StructRNA *rna_property_collection_type(PropertyRNA *prop, CollectionProp
|
|||
|
||||
static void rna_property_collection_get(PropertyRNA *prop, CollectionPropertyIterator *iter, PointerRNA *r_ptr)
|
||||
{
|
||||
CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
|
||||
CollectionPropertyRNA *cprop;
|
||||
|
||||
rna_idproperty_check(&prop, NULL);
|
||||
cprop= (CollectionPropertyRNA*)prop;
|
||||
|
||||
r_ptr->data= cprop->get(iter);
|
||||
|
||||
|
@ -381,7 +542,10 @@ static void rna_property_collection_get(PropertyRNA *prop, CollectionPropertyIte
|
|||
|
||||
void RNA_property_collection_begin(PropertyRNA *prop, CollectionPropertyIterator *iter, PointerRNA *ptr)
|
||||
{
|
||||
CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
|
||||
CollectionPropertyRNA *cprop;
|
||||
|
||||
rna_idproperty_check(&prop, ptr);
|
||||
cprop= (CollectionPropertyRNA*)prop;
|
||||
|
||||
iter->parent= *ptr;
|
||||
cprop->begin(iter, ptr);
|
||||
|
@ -394,7 +558,10 @@ void RNA_property_collection_begin(PropertyRNA *prop, CollectionPropertyIterator
|
|||
|
||||
void RNA_property_collection_next(PropertyRNA *prop, CollectionPropertyIterator *iter)
|
||||
{
|
||||
CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
|
||||
CollectionPropertyRNA *cprop;
|
||||
|
||||
rna_idproperty_check(&prop, NULL);
|
||||
cprop= (CollectionPropertyRNA*)prop;
|
||||
|
||||
cprop->next(iter);
|
||||
|
||||
|
@ -406,7 +573,10 @@ void RNA_property_collection_next(PropertyRNA *prop, CollectionPropertyIterator
|
|||
|
||||
void RNA_property_collection_end(PropertyRNA *prop, CollectionPropertyIterator *iter)
|
||||
{
|
||||
CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
|
||||
CollectionPropertyRNA *cprop;
|
||||
|
||||
rna_idproperty_check(&prop, NULL);
|
||||
cprop= (CollectionPropertyRNA*)prop;
|
||||
|
||||
if(cprop->end)
|
||||
cprop->end(iter);
|
||||
|
@ -414,7 +584,10 @@ void RNA_property_collection_end(PropertyRNA *prop, CollectionPropertyIterator *
|
|||
|
||||
int RNA_property_collection_length(PropertyRNA *prop, PointerRNA *ptr)
|
||||
{
|
||||
CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
|
||||
CollectionPropertyRNA *cprop;
|
||||
|
||||
rna_idproperty_check(&prop, ptr);
|
||||
cprop= (CollectionPropertyRNA*)prop;
|
||||
|
||||
if(cprop->length) {
|
||||
return cprop->length(ptr);
|
||||
|
@ -423,11 +596,10 @@ int RNA_property_collection_length(PropertyRNA *prop, PointerRNA *ptr)
|
|||
CollectionPropertyIterator iter;
|
||||
int length= 0;
|
||||
|
||||
for(cprop->begin(&iter, ptr); iter.valid; cprop->next(&iter))
|
||||
RNA_property_collection_begin(prop, &iter, ptr);
|
||||
for(; iter.valid; RNA_property_collection_next(prop, &iter))
|
||||
length++;
|
||||
|
||||
if(cprop->end)
|
||||
cprop->end(&iter);
|
||||
RNA_property_collection_end(prop, &iter);
|
||||
|
||||
return length;
|
||||
}
|
||||
|
@ -435,7 +607,10 @@ int RNA_property_collection_length(PropertyRNA *prop, PointerRNA *ptr)
|
|||
|
||||
int RNA_property_collection_lookup_int(PropertyRNA *prop, PointerRNA *ptr, int key, PointerRNA *r_ptr)
|
||||
{
|
||||
CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
|
||||
CollectionPropertyRNA *cprop;
|
||||
|
||||
rna_idproperty_check(&prop, ptr);
|
||||
cprop= (CollectionPropertyRNA*)prop;
|
||||
|
||||
if(cprop->lookupint) {
|
||||
/* we have a callback defined, use it */
|
||||
|
@ -476,7 +651,10 @@ int RNA_property_collection_lookup_int(PropertyRNA *prop, PointerRNA *ptr, int k
|
|||
|
||||
int RNA_property_collection_lookup_string(PropertyRNA *prop, PointerRNA *ptr, const char *key, PointerRNA *r_ptr)
|
||||
{
|
||||
CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
|
||||
CollectionPropertyRNA *cprop;
|
||||
|
||||
rna_idproperty_check(&prop, ptr);
|
||||
cprop= (CollectionPropertyRNA*)prop;
|
||||
|
||||
if(cprop->lookupstring) {
|
||||
/* we have a callback defined, use it */
|
||||
|
@ -544,19 +722,33 @@ int RNA_property_collection_lookup_string(PropertyRNA *prop, PointerRNA *ptr, co
|
|||
|
||||
void rna_iterator_listbase_begin(CollectionPropertyIterator *iter, ListBase *lb)
|
||||
{
|
||||
iter->internal= lb->first;
|
||||
iter->valid= (iter->internal != NULL);
|
||||
ListBaseIterator *internal;
|
||||
|
||||
internal= MEM_callocN(sizeof(ListBaseIterator), "ListBaseIterator");
|
||||
internal->link= lb->first;
|
||||
|
||||
iter->internal= internal;
|
||||
iter->valid= (internal->link != NULL);
|
||||
}
|
||||
|
||||
void rna_iterator_listbase_next(CollectionPropertyIterator *iter)
|
||||
{
|
||||
iter->internal= ((Link*)iter->internal)->next;
|
||||
iter->valid= (iter->internal != NULL);
|
||||
ListBaseIterator *internal= iter->internal;
|
||||
|
||||
internal->link= internal->link->next;
|
||||
iter->valid= (internal->link != NULL);
|
||||
}
|
||||
|
||||
void *rna_iterator_listbase_get(CollectionPropertyIterator *iter)
|
||||
{
|
||||
return iter->internal;
|
||||
ListBaseIterator *internal= iter->internal;
|
||||
|
||||
return internal->link;
|
||||
}
|
||||
|
||||
void rna_iterator_listbase_end(CollectionPropertyIterator *iter)
|
||||
{
|
||||
MEM_freeN(iter->internal);
|
||||
}
|
||||
|
||||
void rna_iterator_array_begin(CollectionPropertyIterator *iter, void *ptr, int itemsize, int length)
|
||||
|
@ -694,7 +886,7 @@ int RNA_path_resolve(PointerRNA *ptr, const char *path, PointerRNA *r_ptr, Prope
|
|||
/* now look up the value of this property if it is a pointer or
|
||||
* collection, otherwise return the property rna so that the
|
||||
* caller can read the value of the property itself */
|
||||
if(prop->type == PROP_POINTER) {
|
||||
if(RNA_property_type(prop, &curptr) == PROP_POINTER) {
|
||||
RNA_property_pointer_get(prop, &curptr, &nextptr);
|
||||
|
||||
if(nextptr.data)
|
||||
|
@ -702,7 +894,7 @@ int RNA_path_resolve(PointerRNA *ptr, const char *path, PointerRNA *r_ptr, Prope
|
|||
else
|
||||
return 0;
|
||||
}
|
||||
else if(prop->type == PROP_COLLECTION && *path) {
|
||||
else if(RNA_property_type(prop, &curptr) == PROP_COLLECTION && *path) {
|
||||
/* resolve the lookup with [] brackets */
|
||||
token= rna_path_token(&path, fixedbuf, sizeof(fixedbuf), 1);
|
||||
|
||||
|
@ -739,7 +931,7 @@ int RNA_path_resolve(PointerRNA *ptr, const char *path, PointerRNA *r_ptr, Prope
|
|||
return 1;
|
||||
}
|
||||
|
||||
char *RNA_path_append(const char *path, PropertyRNA *prop, int intkey, const char *strkey)
|
||||
char *RNA_path_append(const char *path, PointerRNA *ptr, PropertyRNA *prop, int intkey, const char *strkey)
|
||||
{
|
||||
DynStr *dynstr;
|
||||
const char *s;
|
||||
|
@ -754,9 +946,9 @@ char *RNA_path_append(const char *path, PropertyRNA *prop, int intkey, const cha
|
|||
BLI_dynstr_append(dynstr, ".");
|
||||
}
|
||||
|
||||
BLI_dynstr_append(dynstr, (char*)prop->identifier);
|
||||
BLI_dynstr_append(dynstr, (char*)RNA_property_identifier(prop, ptr));
|
||||
|
||||
if(prop->type == PROP_COLLECTION) {
|
||||
if(RNA_property_type(prop, ptr) == PROP_COLLECTION) {
|
||||
/* add ["strkey"] or [intkey] */
|
||||
BLI_dynstr_append(dynstr, "[");
|
||||
|
||||
|
|
|
@ -316,6 +316,7 @@ PropertyRNA *RNA_def_property(StructRNA *srna, const char *identifier, int type,
|
|||
dp->srna= srna;
|
||||
dp->prop= prop;
|
||||
|
||||
prop->magic= RNA_MAGIC;
|
||||
prop->identifier= identifier;
|
||||
prop->type= type;
|
||||
prop->subtype= subtype;
|
||||
|
@ -802,6 +803,7 @@ void RNA_def_property_collection_sdna(PropertyRNA *prop, const char *structname,
|
|||
if(strcmp(dp->dnatype, "ListBase") == 0) {
|
||||
cprop->next= (PropCollectionNextFunc)"rna_iterator_listbase_next";
|
||||
cprop->get= (PropCollectionGetFunc)"rna_iterator_listbase_get";
|
||||
cprop->end= (PropCollectionEndFunc)"rna_iterator_listbase_end";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,10 +25,12 @@
|
|||
#ifndef RNA_INTERNAL_H
|
||||
#define RNA_INTERNAL_H
|
||||
|
||||
struct StructRNA;
|
||||
struct PropertyRNA;
|
||||
#include "rna_internal_types.h"
|
||||
|
||||
#define RNA_MAGIC ((int)~0)
|
||||
|
||||
struct IDProperty;
|
||||
struct SDNA;
|
||||
struct ListBase;
|
||||
|
||||
/* Data structures used during define */
|
||||
|
||||
|
@ -73,6 +75,15 @@ extern BlenderDefRNA DefRNA;
|
|||
|
||||
/* Define functions for all types */
|
||||
|
||||
extern StringPropertyRNA rna_IDProperty_string;
|
||||
extern IntPropertyRNA rna_IDProperty_int;
|
||||
extern IntPropertyRNA rna_IDProperty_intarray;
|
||||
extern FloatPropertyRNA rna_IDProperty_float;
|
||||
extern FloatPropertyRNA rna_IDProperty_floatarray;
|
||||
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;
|
||||
|
@ -80,6 +91,7 @@ extern StructRNA RNA_Scene;
|
|||
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);
|
||||
|
@ -87,13 +99,21 @@ void RNA_def_object(struct BlenderRNA *brna);
|
|||
void RNA_def_rna(struct BlenderRNA *brna);
|
||||
void RNA_def_scene(struct BlenderRNA *brna);
|
||||
|
||||
/* Internal Functions */
|
||||
|
||||
void rna_def_builtin_properties(struct StructRNA *srna);
|
||||
|
||||
/* Standard iterator functions */
|
||||
struct IDProperty *rna_idproperty_check(struct PropertyRNA **prop, struct PointerRNA *ptr);
|
||||
|
||||
typedef struct ListBaseIterator {
|
||||
Link *link;
|
||||
int flag;
|
||||
} ListBaseIterator;
|
||||
|
||||
void rna_iterator_listbase_begin(struct CollectionPropertyIterator *iter, struct ListBase *lb);
|
||||
void rna_iterator_listbase_next(struct CollectionPropertyIterator *iter);
|
||||
void *rna_iterator_listbase_get(struct CollectionPropertyIterator *iter);
|
||||
void rna_iterator_listbase_end(struct CollectionPropertyIterator *iter);
|
||||
|
||||
typedef struct ArrayIterator {
|
||||
char *ptr;
|
||||
|
|
|
@ -0,0 +1,225 @@
|
|||
/**
|
||||
* $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 *****
|
||||
*/
|
||||
|
||||
#ifndef RNA_INTERNAL_TYPES
|
||||
#define RNA_INTERNAL_TYPES
|
||||
|
||||
#include "DNA_listBase.h"
|
||||
|
||||
struct BlenderRNA;
|
||||
struct StructRNA;
|
||||
struct PropertyRNA;
|
||||
struct PointerRNA;
|
||||
struct CollectionPropertyIterator;
|
||||
struct bContext;
|
||||
|
||||
/* Function Callbacks */
|
||||
|
||||
typedef void (*PropNotifyFunc)(struct bContext *C, 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);
|
||||
typedef void (*PropBooleanArraySetFunc)(struct PointerRNA *ptr, int index, int value);
|
||||
typedef int (*PropIntGetFunc)(struct PointerRNA *ptr);
|
||||
typedef void (*PropIntSetFunc)(struct PointerRNA *ptr, int value);
|
||||
typedef int (*PropIntArrayGetFunc)(struct PointerRNA *ptr, int index);
|
||||
typedef void (*PropIntArraySetFunc)(struct PointerRNA *ptr, int index, int value);
|
||||
typedef float (*PropFloatGetFunc)(struct PointerRNA *ptr);
|
||||
typedef void (*PropFloatSetFunc)(struct PointerRNA *ptr, float value);
|
||||
typedef float (*PropFloatArrayGetFunc)(struct PointerRNA *ptr, int index);
|
||||
typedef void (*PropFloatArraySetFunc)(struct PointerRNA *ptr, int index, float value);
|
||||
typedef void (*PropStringGetFunc)(struct PointerRNA *ptr, char *value);
|
||||
typedef int (*PropStringLengthFunc)(struct PointerRNA *ptr);
|
||||
typedef void (*PropStringSetFunc)(struct PointerRNA *ptr, const char *value);
|
||||
typedef int (*PropEnumGetFunc)(struct PointerRNA *ptr);
|
||||
typedef void (*PropEnumSetFunc)(struct PointerRNA *ptr, int value);
|
||||
typedef void* (*PropPointerGetFunc)(struct PointerRNA *ptr);
|
||||
typedef void (*PropPointerSetFunc)(struct PointerRNA *ptr, void *value);
|
||||
typedef struct StructRNA* (*PropPointerTypeFunc)(struct PointerRNA *ptr);
|
||||
typedef void (*PropCollectionBeginFunc)(struct CollectionPropertyIterator *iter, struct PointerRNA *ptr);
|
||||
typedef void (*PropCollectionNextFunc)(struct CollectionPropertyIterator *iter);
|
||||
typedef void (*PropCollectionEndFunc)(struct CollectionPropertyIterator *iter);
|
||||
typedef void* (*PropCollectionGetFunc)(struct CollectionPropertyIterator *iter);
|
||||
typedef struct StructRNA* (*PropCollectionTypeFunc)(struct CollectionPropertyIterator *iter);
|
||||
typedef int (*PropCollectionLengthFunc)(struct PointerRNA *ptr);
|
||||
typedef void* (*PropCollectionLookupIntFunc)(struct PointerRNA *ptr, int key, struct StructRNA **type);
|
||||
typedef void* (*PropCollectionLookupStringFunc)(struct PointerRNA *ptr, const char *key, struct StructRNA **type);
|
||||
|
||||
struct PropertyRNA {
|
||||
struct PropertyRNA *next, *prev;
|
||||
|
||||
/* magic bytes to distinguish with IDProperty */
|
||||
int magic;
|
||||
|
||||
/* unique identifier */
|
||||
const char *identifier;
|
||||
/* various options */
|
||||
int flag;
|
||||
|
||||
/* user readable name */
|
||||
const char *name;
|
||||
/* single line description, displayed in the tooltip for example */
|
||||
const char *description;
|
||||
|
||||
/* property type as it appears to the outside */
|
||||
PropertyType type;
|
||||
/* subtype, 'interpretation' of the property */
|
||||
PropertySubType subtype;
|
||||
/* if an array this is > 0, specifying the length */
|
||||
unsigned int arraylength;
|
||||
|
||||
/* callback for notifys on change */
|
||||
PropNotifyFunc notify;
|
||||
};
|
||||
|
||||
/* Property Types */
|
||||
|
||||
typedef struct BooleanPropertyRNA {
|
||||
PropertyRNA property;
|
||||
|
||||
PropBooleanGetFunc get;
|
||||
PropBooleanSetFunc set;
|
||||
|
||||
PropBooleanArrayGetFunc getarray;
|
||||
PropBooleanArraySetFunc setarray;
|
||||
|
||||
int defaultvalue;
|
||||
const int *defaultarray;
|
||||
} BooleanPropertyRNA;
|
||||
|
||||
typedef struct IntPropertyRNA {
|
||||
PropertyRNA property;
|
||||
|
||||
PropIntGetFunc get;
|
||||
PropIntSetFunc set;
|
||||
|
||||
PropIntArrayGetFunc getarray;
|
||||
PropIntArraySetFunc setarray;
|
||||
|
||||
int softmin, softmax;
|
||||
int hardmin, hardmax;
|
||||
int step;
|
||||
|
||||
int defaultvalue;
|
||||
const int *defaultarray;
|
||||
} IntPropertyRNA;
|
||||
|
||||
typedef struct FloatPropertyRNA {
|
||||
PropertyRNA property;
|
||||
|
||||
PropFloatGetFunc get;
|
||||
PropFloatSetFunc set;
|
||||
|
||||
PropFloatArrayGetFunc getarray;
|
||||
PropFloatArraySetFunc setarray;
|
||||
|
||||
float softmin, softmax;
|
||||
float hardmin, hardmax;
|
||||
float step;
|
||||
int precision;
|
||||
|
||||
float defaultvalue;
|
||||
const float *defaultarray;
|
||||
} FloatPropertyRNA;
|
||||
|
||||
typedef struct StringPropertyRNA {
|
||||
PropertyRNA property;
|
||||
|
||||
PropStringGetFunc get;
|
||||
PropStringLengthFunc length;
|
||||
PropStringSetFunc set;
|
||||
|
||||
int maxlength; /* includes string terminator! */
|
||||
|
||||
const char *defaultvalue;
|
||||
} StringPropertyRNA;
|
||||
|
||||
typedef struct EnumPropertyRNA {
|
||||
PropertyRNA property;
|
||||
|
||||
PropEnumGetFunc get;
|
||||
PropEnumSetFunc set;
|
||||
|
||||
const EnumPropertyItem *item;
|
||||
int totitem;
|
||||
|
||||
int defaultvalue;
|
||||
} EnumPropertyRNA;
|
||||
|
||||
typedef struct PointerPropertyRNA {
|
||||
PropertyRNA property;
|
||||
|
||||
PropPointerGetFunc get;
|
||||
PropPointerSetFunc set;
|
||||
PropPointerTypeFunc type; /* optional */
|
||||
|
||||
struct StructRNA *structtype;
|
||||
} PointerPropertyRNA;
|
||||
|
||||
typedef struct CollectionPropertyRNA {
|
||||
PropertyRNA property;
|
||||
|
||||
PropCollectionBeginFunc begin;
|
||||
PropCollectionNextFunc next;
|
||||
PropCollectionEndFunc end; /* optional */
|
||||
PropCollectionGetFunc get;
|
||||
PropCollectionTypeFunc type; /* optional */
|
||||
PropCollectionLengthFunc length; /* optional */
|
||||
PropCollectionLookupIntFunc lookupint; /* optional */
|
||||
PropCollectionLookupStringFunc lookupstring; /* optional */
|
||||
|
||||
struct StructRNA *structtype;
|
||||
} CollectionPropertyRNA;
|
||||
|
||||
struct StructRNA {
|
||||
struct StructRNA *next, *prev;
|
||||
|
||||
/* unique identifier */
|
||||
const char *identifier;
|
||||
/* various options */
|
||||
int flag;
|
||||
|
||||
/* user readable name */
|
||||
const char *name;
|
||||
|
||||
/* property that defines the name */
|
||||
PropertyRNA *nameproperty;
|
||||
|
||||
/* property to iterate over properties */
|
||||
PropertyRNA *iteratorproperty;
|
||||
|
||||
/* properties of this struct */
|
||||
ListBase properties;
|
||||
};
|
||||
|
||||
/* Blender RNA
|
||||
*
|
||||
* Root RNA data structure that lists all struct types. */
|
||||
|
||||
struct BlenderRNA {
|
||||
ListBase structs;
|
||||
};
|
||||
|
||||
#endif /* RNA_INTERNAL_TYPES */
|
||||
|
|
@ -244,7 +244,7 @@ void RNA_def_main(BlenderRNA *brna)
|
|||
{
|
||||
prop= RNA_def_property(srna, lists[i][0], PROP_COLLECTION, PROP_NONE);
|
||||
RNA_def_property_struct_type(prop, lists[i][1]);
|
||||
RNA_def_property_collection_funcs(prop, lists[i][2], "rna_iterator_listbase_next", 0, "rna_iterator_listbase_get", 0, 0, 0, 0);
|
||||
RNA_def_property_collection_funcs(prop, lists[i][2], "rna_iterator_listbase_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get", 0, 0, 0, 0);
|
||||
RNA_def_property_ui_text(prop, lists[i][3], lists[i][4]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,27 +59,69 @@ static void *rna_Struct_name_property_get(PointerRNA *ptr)
|
|||
|
||||
static void rna_Struct_properties_next(CollectionPropertyIterator *iter)
|
||||
{
|
||||
do {
|
||||
ListBaseIterator *internal= iter->internal;
|
||||
ID *id;
|
||||
StructRNA *type;
|
||||
IDProperty *group;
|
||||
|
||||
if(internal->flag) {
|
||||
/* id properties */
|
||||
rna_iterator_listbase_next(iter);
|
||||
} while(iter->valid && (((PropertyRNA*)iter->internal)->flag & PROP_BUILTIN));
|
||||
}
|
||||
else {
|
||||
/* regular properties */
|
||||
do {
|
||||
rna_iterator_listbase_next(iter);
|
||||
} while(iter->valid && (((PropertyRNA*)internal->link)->flag & PROP_BUILTIN));
|
||||
|
||||
/* 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;
|
||||
|
||||
if(group) {
|
||||
rna_iterator_listbase_end(iter);
|
||||
rna_iterator_listbase_begin(iter, &group->data.group);
|
||||
internal= iter->internal;
|
||||
internal->flag= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void rna_Struct_properties_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
|
||||
{
|
||||
ListBaseIterator *internal;
|
||||
|
||||
rna_iterator_listbase_begin(iter, &((StructRNA*)ptr->data)->properties);
|
||||
|
||||
if(iter->valid && (((PropertyRNA*)iter->internal)->flag & PROP_BUILTIN))
|
||||
internal= iter->internal;
|
||||
if(iter->valid && (((PropertyRNA*)internal->link)->flag & PROP_BUILTIN))
|
||||
rna_Struct_properties_next(iter);
|
||||
}
|
||||
|
||||
static void *rna_Struct_properties_get(CollectionPropertyIterator *iter)
|
||||
{
|
||||
return rna_iterator_listbase_get(iter);
|
||||
ListBaseIterator *internal= iter->internal;
|
||||
|
||||
/* we return either PropertyRNA* or IDProperty*, the rna_access.c
|
||||
* functions can handle both as PropertyRNA* with some tricks */
|
||||
return internal->link;
|
||||
}
|
||||
|
||||
static StructRNA *rna_Struct_properties_type(CollectionPropertyIterator *iter)
|
||||
{
|
||||
PropertyRNA *prop= iter->internal;
|
||||
ListBaseIterator *internal= iter->internal;
|
||||
PropertyRNA *prop= (PropertyRNA*)internal->link;
|
||||
|
||||
rna_idproperty_check(&prop, NULL);
|
||||
|
||||
switch(prop->type) {
|
||||
case PROP_BOOLEAN: return &RNA_BooleanProperty;
|
||||
|
@ -137,112 +179,159 @@ static void *rna_builtin_type_get(PointerRNA *ptr)
|
|||
|
||||
static void rna_Property_identifier_get(PointerRNA *ptr, char *value)
|
||||
{
|
||||
strcpy(value, ((PropertyRNA*)ptr->data)->identifier);
|
||||
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
||||
rna_idproperty_check(&prop, NULL);
|
||||
strcpy(value, ((PropertyRNA*)prop)->identifier);
|
||||
}
|
||||
|
||||
static int rna_Property_identifier_length(PointerRNA *ptr)
|
||||
{
|
||||
return strlen(((PropertyRNA*)ptr->data)->identifier);
|
||||
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
||||
rna_idproperty_check(&prop, NULL);
|
||||
return strlen(prop->identifier);
|
||||
}
|
||||
|
||||
static void rna_Property_name_get(PointerRNA *ptr, char *value)
|
||||
{
|
||||
strcpy(value, ((PropertyRNA*)ptr->data)->name);
|
||||
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
||||
rna_idproperty_check(&prop, NULL);
|
||||
strcpy(value, prop->name);
|
||||
}
|
||||
|
||||
static int rna_Property_name_length(PointerRNA *ptr)
|
||||
{
|
||||
return strlen(((PropertyRNA*)ptr->data)->name);
|
||||
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
||||
rna_idproperty_check(&prop, NULL);
|
||||
return strlen(prop->name);
|
||||
}
|
||||
|
||||
static void rna_Property_description_get(PointerRNA *ptr, char *value)
|
||||
{
|
||||
strcpy(value, ((PropertyRNA*)ptr->data)->description);
|
||||
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
||||
rna_idproperty_check(&prop, NULL);
|
||||
strcpy(value, prop->description);
|
||||
}
|
||||
|
||||
static int rna_Property_description_length(PointerRNA *ptr)
|
||||
{
|
||||
return strlen(((PropertyRNA*)ptr->data)->description);
|
||||
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
||||
rna_idproperty_check(&prop, NULL);
|
||||
return strlen(prop->description);
|
||||
}
|
||||
|
||||
static int rna_Property_type_get(PointerRNA *ptr)
|
||||
{
|
||||
return ((PropertyRNA*)ptr->data)->type;
|
||||
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
||||
rna_idproperty_check(&prop, NULL);
|
||||
return prop->type;
|
||||
}
|
||||
|
||||
static int rna_Property_subtype_get(PointerRNA *ptr)
|
||||
{
|
||||
return ((PropertyRNA*)ptr->data)->subtype;
|
||||
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
||||
rna_idproperty_check(&prop, NULL);
|
||||
return prop->subtype;
|
||||
}
|
||||
|
||||
static int rna_Property_array_length_get(PointerRNA *ptr)
|
||||
{
|
||||
return ((PropertyRNA*)ptr->data)->arraylength;
|
||||
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
||||
rna_idproperty_check(&prop, NULL);
|
||||
return prop->arraylength;
|
||||
}
|
||||
|
||||
static int rna_IntProperty_hard_min_get(PointerRNA *ptr)
|
||||
{
|
||||
return ((IntPropertyRNA*)ptr->data)->hardmin;
|
||||
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
||||
rna_idproperty_check(&prop, NULL);
|
||||
return ((IntPropertyRNA*)prop)->hardmin;
|
||||
}
|
||||
|
||||
static int rna_IntProperty_hard_max_get(PointerRNA *ptr)
|
||||
{
|
||||
return ((IntPropertyRNA*)ptr->data)->hardmax;
|
||||
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
||||
rna_idproperty_check(&prop, NULL);
|
||||
return ((IntPropertyRNA*)prop)->hardmax;
|
||||
}
|
||||
|
||||
static int rna_IntProperty_soft_min_get(PointerRNA *ptr)
|
||||
{
|
||||
return ((IntPropertyRNA*)ptr->data)->softmin;
|
||||
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
||||
rna_idproperty_check(&prop, NULL);
|
||||
return ((IntPropertyRNA*)prop)->softmin;
|
||||
}
|
||||
|
||||
static int rna_IntProperty_soft_max_get(PointerRNA *ptr)
|
||||
{
|
||||
return ((IntPropertyRNA*)ptr->data)->softmax;
|
||||
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
||||
rna_idproperty_check(&prop, NULL);
|
||||
return ((IntPropertyRNA*)prop)->softmax;
|
||||
}
|
||||
|
||||
static int rna_IntProperty_step_get(PointerRNA *ptr)
|
||||
{
|
||||
return ((IntPropertyRNA*)ptr->data)->step;
|
||||
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
||||
rna_idproperty_check(&prop, NULL);
|
||||
return ((IntPropertyRNA*)prop)->step;
|
||||
}
|
||||
|
||||
static float rna_FloatProperty_hard_min_get(PointerRNA *ptr)
|
||||
{
|
||||
return ((FloatPropertyRNA*)ptr->data)->hardmin;
|
||||
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
||||
rna_idproperty_check(&prop, NULL);
|
||||
return ((FloatPropertyRNA*)prop)->hardmin;
|
||||
}
|
||||
|
||||
static float rna_FloatProperty_hard_max_get(PointerRNA *ptr)
|
||||
{
|
||||
return ((FloatPropertyRNA*)ptr->data)->hardmax;
|
||||
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
||||
rna_idproperty_check(&prop, NULL);
|
||||
return ((FloatPropertyRNA*)prop)->hardmax;
|
||||
}
|
||||
|
||||
static float rna_FloatProperty_soft_min_get(PointerRNA *ptr)
|
||||
{
|
||||
return ((FloatPropertyRNA*)ptr->data)->softmin;
|
||||
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
||||
rna_idproperty_check(&prop, NULL);
|
||||
return ((FloatPropertyRNA*)prop)->softmin;
|
||||
}
|
||||
|
||||
static float rna_FloatProperty_soft_max_get(PointerRNA *ptr)
|
||||
{
|
||||
return ((FloatPropertyRNA*)ptr->data)->softmax;
|
||||
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
||||
rna_idproperty_check(&prop, NULL);
|
||||
return ((FloatPropertyRNA*)prop)->softmax;
|
||||
}
|
||||
|
||||
static float rna_FloatProperty_step_get(PointerRNA *ptr)
|
||||
{
|
||||
return ((FloatPropertyRNA*)ptr->data)->step;
|
||||
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
||||
rna_idproperty_check(&prop, NULL);
|
||||
return ((FloatPropertyRNA*)prop)->step;
|
||||
}
|
||||
|
||||
static int rna_FloatProperty_precision_get(PointerRNA *ptr)
|
||||
{
|
||||
return ((FloatPropertyRNA*)ptr->data)->precision;
|
||||
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
||||
rna_idproperty_check(&prop, NULL);
|
||||
return ((FloatPropertyRNA*)prop)->precision;
|
||||
}
|
||||
|
||||
static int rna_StringProperty_max_length_get(PointerRNA *ptr)
|
||||
{
|
||||
return ((StringPropertyRNA*)ptr->data)->maxlength;
|
||||
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
||||
rna_idproperty_check(&prop, NULL);
|
||||
return ((StringPropertyRNA*)prop)->maxlength;
|
||||
}
|
||||
|
||||
static void rna_EnumProperty_items_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
|
||||
{
|
||||
EnumPropertyRNA *eprop= (EnumPropertyRNA*)ptr->data;
|
||||
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
||||
EnumPropertyRNA *eprop;
|
||||
|
||||
rna_idproperty_check(&prop, NULL);
|
||||
eprop= (EnumPropertyRNA*)prop;
|
||||
|
||||
rna_iterator_array_begin(iter, (void*)eprop->item, sizeof(eprop->item[0]), eprop->totitem);
|
||||
}
|
||||
|
||||
|
@ -273,12 +362,16 @@ static int rna_EnumPropertyItem_value_get(PointerRNA *ptr)
|
|||
|
||||
static void *rna_PointerProperty_fixed_type_get(PointerRNA *ptr)
|
||||
{
|
||||
return ((PointerPropertyRNA*)ptr->data)->structtype;
|
||||
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
||||
rna_idproperty_check(&prop, NULL);
|
||||
return ((PointerPropertyRNA*)prop)->structtype;
|
||||
}
|
||||
|
||||
static void *rna_CollectionProperty_fixed_type_get(PointerRNA *ptr)
|
||||
{
|
||||
return ((CollectionPropertyRNA*)ptr->data)->structtype;
|
||||
PropertyRNA *prop= (PropertyRNA*)ptr->data;
|
||||
rna_idproperty_check(&prop, NULL);
|
||||
return ((CollectionPropertyRNA*)prop)->structtype;
|
||||
}
|
||||
|
||||
#else
|
||||
|
@ -454,7 +547,7 @@ void RNA_def_rna(BlenderRNA *brna)
|
|||
|
||||
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", 0, "rna_Struct_properties_get", "rna_Struct_properties_type", 0, 0, 0);
|
||||
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.");
|
||||
|
||||
/* BooleanProperty */
|
||||
|
@ -502,8 +595,8 @@ 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_NOT_EDITABLE|PROP_BUILTIN);
|
||||
RNA_def_property_collection_funcs(prop, "rna_builtin_properties_begin", "rna_builtin_properties_next", 0, "rna_builtin_properties_get", "rna_builtin_properties_type", 0, 0, 0);
|
||||
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);
|
||||
|
|
|
@ -37,8 +37,10 @@
|
|||
|
||||
void *rna_Scene_objects_get(CollectionPropertyIterator *iter)
|
||||
{
|
||||
ListBaseIterator *internal= iter->internal;
|
||||
|
||||
/* we are actually iterating a Base list, so override get */
|
||||
return ((Base*)iter->internal)->object;
|
||||
return ((Base*)internal->link)->object;
|
||||
}
|
||||
|
||||
static void rna_Scene_layer_set(PointerRNA *ptr, int index, int value)
|
||||
|
|
Loading…
Reference in New Issue