2008-11-01 00:50:02 +01:00
|
|
|
/**
|
|
|
|
* $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_TYPES
|
|
|
|
#define RNA_TYPES
|
|
|
|
|
2009-03-15 00:17:55 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2009-04-07 02:49:39 +02:00
|
|
|
struct ParameterList;
|
|
|
|
struct FunctionRNA;
|
2008-11-24 16:51:55 +01:00
|
|
|
struct PropertyRNA;
|
|
|
|
struct StructRNA;
|
|
|
|
struct BlenderRNA;
|
2009-03-19 20:03:38 +01:00
|
|
|
struct IDProperty;
|
2009-04-19 15:37:59 +02:00
|
|
|
struct bContext;
|
|
|
|
struct ReportList;
|
2008-11-24 16:51:55 +01:00
|
|
|
|
2008-11-07 03:58:25 +01:00
|
|
|
/* Pointer
|
|
|
|
*
|
|
|
|
* RNA pointers are not a single C pointer but include the type,
|
|
|
|
* and a pointer to the ID struct that owns the struct, since
|
|
|
|
* in some cases this information is needed to correctly get/set
|
|
|
|
* the properties and validate them. */
|
|
|
|
|
|
|
|
typedef struct PointerRNA {
|
|
|
|
struct {
|
|
|
|
void *data;
|
|
|
|
} id;
|
|
|
|
|
|
|
|
struct StructRNA *type;
|
|
|
|
void *data;
|
|
|
|
} PointerRNA;
|
|
|
|
|
|
|
|
/* Property */
|
2008-11-01 00:50:02 +01:00
|
|
|
|
|
|
|
typedef enum PropertyType {
|
|
|
|
PROP_BOOLEAN = 0,
|
|
|
|
PROP_INT = 1,
|
|
|
|
PROP_FLOAT = 2,
|
|
|
|
PROP_STRING = 3,
|
|
|
|
PROP_ENUM = 4,
|
|
|
|
PROP_POINTER = 5,
|
|
|
|
PROP_COLLECTION = 6
|
|
|
|
} PropertyType;
|
|
|
|
|
|
|
|
typedef enum PropertySubType {
|
|
|
|
PROP_NONE = 0,
|
|
|
|
PROP_UNSIGNED = 1,
|
|
|
|
PROP_FILEPATH = 2,
|
2008-12-15 11:48:04 +01:00
|
|
|
PROP_DIRPATH = 3,
|
|
|
|
PROP_COLOR = 4,
|
|
|
|
PROP_VECTOR = 5,
|
|
|
|
PROP_MATRIX = 6,
|
2009-01-10 23:57:33 +01:00
|
|
|
PROP_ROTATION = 7,
|
2009-02-17 22:07:01 +01:00
|
|
|
PROP_NEVER_NULL = 8,
|
|
|
|
PROP_PERCENTAGE = 9
|
2008-11-01 00:50:02 +01:00
|
|
|
} PropertySubType;
|
|
|
|
|
|
|
|
typedef enum PropertyFlag {
|
2008-11-07 03:58:25 +01:00
|
|
|
/* editable means the property is editable in the user
|
2009-01-17 14:54:56 +01:00
|
|
|
* interface, properties are editable by default except
|
|
|
|
* for pointers and collections. */
|
2009-03-23 14:24:48 +01:00
|
|
|
PROP_EDITABLE = 1,
|
2008-11-07 03:58:25 +01:00
|
|
|
|
2009-01-17 14:54:56 +01:00
|
|
|
/* animateable means the property can be driven by some
|
2008-11-07 03:58:25 +01:00
|
|
|
* other input, be it animation curves, expressions, ..
|
2009-01-17 14:54:56 +01:00
|
|
|
* properties are animateable by default except for pointers
|
|
|
|
* and collections */
|
2009-03-23 14:24:48 +01:00
|
|
|
PROP_ANIMATEABLE = 2,
|
2008-11-14 15:34:19 +01:00
|
|
|
|
2009-04-11 03:43:50 +02:00
|
|
|
/* function paramater flags */
|
|
|
|
PROP_REQUIRED = 4,
|
2009-04-19 15:37:59 +02:00
|
|
|
PROP_RETURN = 8,
|
|
|
|
|
|
|
|
/* registering */
|
|
|
|
PROP_REGISTER = 16,
|
|
|
|
PROP_REGISTER_OPTIONAL = 16|32,
|
2009-04-11 03:43:50 +02:00
|
|
|
|
2008-11-17 19:44:06 +01:00
|
|
|
/* internal flags */
|
|
|
|
PROP_BUILTIN = 128,
|
RNA
* 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.
2008-11-21 03:23:46 +01:00
|
|
|
PROP_EXPORT = 256,
|
|
|
|
PROP_RUNTIME = 512,
|
|
|
|
PROP_IDPROPERTY = 1024
|
2008-11-01 00:50:02 +01:00
|
|
|
} PropertyFlag;
|
|
|
|
|
|
|
|
typedef struct CollectionPropertyIterator {
|
2009-02-02 20:57:57 +01:00
|
|
|
/* internal */
|
2008-11-14 18:05:25 +01:00
|
|
|
PointerRNA parent;
|
2009-05-20 11:17:21 +02:00
|
|
|
PointerRNA builtin_parent;
|
2008-11-24 16:51:55 +01:00
|
|
|
struct PropertyRNA *prop;
|
2008-11-01 00:50:02 +01:00
|
|
|
void *internal;
|
RNA:
* Added support for using pointers + collections as operator properties,
but with the restriction that they must point to other type derived from
ID property groups. The "add" function for these properties will allocate
a new ID property group and point to that.
* Added support for arrays with type IDP_GROUP in ID properties.
* Fix bug getting/setting float array values.
Example code for collections, note the "OperatorMousePath" type is defined
in rna_wm.c and has a float[2] property named "loc".
Defining the operator property:
prop= RNA_def_property(ot->srna, "path", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_runtime(prop, &RNA_OperatorMousePath);
Adding values:
PointerRNA itemptr;
float loc[2] = {1, 1},
RNA_collection_add(op->ptr, "path", &itemptr);
RNA_float_set_array(&itemptr, "loc", loc);
Iterating:
RNA_BEGIN(op->ptr, itemptr, "path") {
float loc[2];
RNA_float_get_array(&itemptr, "loc", loc);
printf("Location: %f %f\n", loc[0], loc[1]);
}
RNA_END;
2008-12-26 21:38:52 +01:00
|
|
|
int idprop;
|
2009-02-02 20:57:57 +01:00
|
|
|
int level;
|
2008-11-14 18:05:25 +01:00
|
|
|
|
2009-02-02 20:57:57 +01:00
|
|
|
/* external */
|
2008-11-01 00:50:02 +01:00
|
|
|
int valid;
|
2008-11-14 18:05:25 +01:00
|
|
|
PointerRNA ptr;
|
2008-11-01 00:50:02 +01:00
|
|
|
} CollectionPropertyIterator;
|
|
|
|
|
2009-03-19 20:03:38 +01:00
|
|
|
typedef struct CollectionPointerLink {
|
|
|
|
struct CollectionPointerLink *next, *prev;
|
|
|
|
PointerRNA ptr;
|
|
|
|
} CollectionPointerLink;
|
|
|
|
|
2009-02-02 20:57:57 +01:00
|
|
|
/* Iterator Utility */
|
|
|
|
|
2008-11-14 19:46:57 +01:00
|
|
|
typedef struct EnumPropertyItem {
|
2008-11-01 00:50:02 +01:00
|
|
|
int value;
|
2008-11-14 19:46:57 +01:00
|
|
|
const char *identifier;
|
2008-11-01 00:50:02 +01:00
|
|
|
const char *name;
|
2008-11-24 13:12:24 +01:00
|
|
|
const char *description;
|
2008-11-14 19:46:57 +01:00
|
|
|
} EnumPropertyItem;
|
2008-11-01 00:50:02 +01:00
|
|
|
|
2008-11-17 19:44:06 +01:00
|
|
|
typedef struct PropertyRNA PropertyRNA;
|
2008-11-01 00:50:02 +01:00
|
|
|
|
2009-04-07 02:49:39 +02:00
|
|
|
/* Parameter List */
|
|
|
|
|
|
|
|
typedef struct ParameterList ParameterList;
|
|
|
|
|
|
|
|
typedef struct ParameterIterator {
|
|
|
|
ParameterList *parms;
|
|
|
|
PointerRNA funcptr;
|
|
|
|
void *data;
|
|
|
|
int size, offset;
|
|
|
|
|
|
|
|
PropertyRNA *parm;
|
|
|
|
int valid;
|
|
|
|
} ParameterIterator;
|
|
|
|
|
|
|
|
/* Function */
|
|
|
|
|
|
|
|
typedef enum FunctionFlag {
|
|
|
|
FUNC_TYPESTATIC = 1, /* for static functions, FUNC_ STATIC is taken by some windows header it seems */
|
|
|
|
|
2009-04-19 15:37:59 +02:00
|
|
|
/* registering */
|
|
|
|
FUNC_REGISTER = 2,
|
|
|
|
FUNC_REGISTER_OPTIONAL = 2|4,
|
|
|
|
|
2009-04-07 02:49:39 +02:00
|
|
|
/* internal flags */
|
|
|
|
FUNC_BUILTIN = 128,
|
|
|
|
FUNC_EXPORT = 256,
|
|
|
|
FUNC_RUNTIME = 512
|
|
|
|
} FunctionFlag;
|
|
|
|
|
|
|
|
typedef void (*CallFunc)(PointerRNA *ptr, ParameterList *parms);
|
|
|
|
|
|
|
|
typedef struct FunctionRNA FunctionRNA;
|
|
|
|
|
2008-11-07 03:58:25 +01:00
|
|
|
/* Struct */
|
|
|
|
|
|
|
|
typedef enum StructFlag {
|
|
|
|
/* indicates that this struct is an ID struct */
|
RNA
* 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.
2008-11-21 03:23:46 +01:00
|
|
|
STRUCT_ID = 1,
|
|
|
|
|
|
|
|
/* internal flags */
|
2009-01-08 14:57:29 +01:00
|
|
|
STRUCT_RUNTIME = 2,
|
|
|
|
STRUCT_GENERATED = 4
|
2008-11-07 03:58:25 +01:00
|
|
|
} StructFlag;
|
|
|
|
|
2009-04-19 15:37:59 +02:00
|
|
|
typedef int (*StructValidateFunc)(struct PointerRNA *ptr, void *data, int *have_function);
|
|
|
|
typedef int (*StructCallbackFunc)(struct PointerRNA *ptr, struct FunctionRNA *func, struct ParameterList *list);
|
|
|
|
typedef void (*StructFreeFunc)(void *data);
|
|
|
|
typedef struct StructRNA *(*StructRegisterFunc)(const struct bContext *C, struct ReportList *reports, void *data,
|
|
|
|
StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free);
|
|
|
|
typedef void (*StructUnregisterFunc)(const struct bContext *C, struct StructRNA *type);
|
|
|
|
|
2008-11-17 19:44:06 +01:00
|
|
|
typedef struct StructRNA StructRNA;
|
2008-11-01 00:50:02 +01:00
|
|
|
|
2008-11-07 03:58:25 +01:00
|
|
|
/* Blender RNA
|
|
|
|
*
|
|
|
|
* Root RNA data structure that lists all struct types. */
|
|
|
|
|
2008-11-17 19:44:06 +01:00
|
|
|
typedef struct BlenderRNA BlenderRNA;
|
2008-11-01 00:50:02 +01:00
|
|
|
|
2009-03-15 00:17:55 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2008-11-01 00:50:02 +01:00
|
|
|
#endif /* RNA_TYPES */
|
|
|
|
|
2008-12-19 05:06:24 +01:00
|
|
|
|