2011-02-23 11:52:22 +01:00
|
|
|
/*
|
2008-11-01 00:50:02 +01:00
|
|
|
* ***** 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,
|
2010-02-12 14:34:04 +01:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2008-11-01 00:50:02 +01:00
|
|
|
*
|
|
|
|
* Contributor(s): Blender Foundation (2008).
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
2011-02-27 21:20:01 +01:00
|
|
|
/** \file blender/makesrna/RNA_types.h
|
|
|
|
* \ingroup RNA
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2010-08-31 13:31:21 +02:00
|
|
|
#include "BLO_sys_types.h"
|
|
|
|
|
2011-01-15 17:14:57 +01:00
|
|
|
#ifndef RNA_TYPES_H
|
|
|
|
#define RNA_TYPES_H
|
2008-11-01 00:50:02 +01:00
|
|
|
|
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;
|
2011-05-26 15:38:16 +02:00
|
|
|
struct EnumPropertyRNA;
|
2008-11-24 16:51:55 +01:00
|
|
|
struct StructRNA;
|
|
|
|
struct BlenderRNA;
|
2009-03-19 20:03:38 +01:00
|
|
|
struct IDProperty;
|
2009-04-19 15:37:59 +02:00
|
|
|
struct bContext;
|
2011-05-18 12:56:26 +02:00
|
|
|
struct Main;
|
2009-04-19 15:37:59 +02:00
|
|
|
struct ReportList;
|
2008-11-24 16:51:55 +01:00
|
|
|
|
2011-02-27 21:20:01 +01:00
|
|
|
/** Pointer
|
2008-11-07 03:58:25 +01:00
|
|
|
*
|
|
|
|
* 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;
|
|
|
|
|
2009-10-02 01:32:57 +02:00
|
|
|
typedef struct PropertyPointerRNA {
|
|
|
|
PointerRNA ptr;
|
|
|
|
struct PropertyRNA *prop;
|
|
|
|
} PropertyPointerRNA;
|
|
|
|
|
2008-11-07 03:58:25 +01:00
|
|
|
/* 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;
|
|
|
|
|
2009-08-11 13:50:40 +02:00
|
|
|
/* also update rna_property_subtype_unit when you change this */
|
RNA: subtypes and units
* Reviewed subtypes, making them more specific and adding new ones.
* Subtypes now have an associated type of units (length, area, volume,
mass, rotation, time, velocity, acceleration). These are not used
yet anywhere.
* Centralized code that decides the name of array items based on
subtype (XYZ, RGB), was copied in 3 places.
* RNA_def_float etc functions still need to be update, will do this
later together with another change.
2009-08-10 23:31:05 +02:00
|
|
|
typedef enum PropertyUnit {
|
|
|
|
PROP_UNIT_NONE = (0<<16),
|
|
|
|
PROP_UNIT_LENGTH = (1<<16), /* m */
|
|
|
|
PROP_UNIT_AREA = (2<<16), /* m^2 */
|
|
|
|
PROP_UNIT_VOLUME = (3<<16), /* m^3 */
|
|
|
|
PROP_UNIT_MASS = (4<<16), /* kg */
|
2010-04-15 12:28:32 +02:00
|
|
|
PROP_UNIT_ROTATION = (5<<16), /* radians */
|
RNA: subtypes and units
* Reviewed subtypes, making them more specific and adding new ones.
* Subtypes now have an associated type of units (length, area, volume,
mass, rotation, time, velocity, acceleration). These are not used
yet anywhere.
* Centralized code that decides the name of array items based on
subtype (XYZ, RGB), was copied in 3 places.
* RNA_def_float etc functions still need to be update, will do this
later together with another change.
2009-08-10 23:31:05 +02:00
|
|
|
PROP_UNIT_TIME = (6<<16), /* frame */
|
|
|
|
PROP_UNIT_VELOCITY = (7<<16), /* m/s */
|
|
|
|
PROP_UNIT_ACCELERATION = (8<<16) /* m/(s^2) */
|
|
|
|
} PropertyUnit;
|
|
|
|
|
2009-12-10 10:38:58 +01:00
|
|
|
#define RNA_SUBTYPE_UNIT(subtype) ((subtype) & 0x00FF0000)
|
|
|
|
#define RNA_SUBTYPE_VALUE(subtype) ((subtype) & ~0x00FF0000)
|
|
|
|
#define RNA_SUBTYPE_UNIT_VALUE(subtype) ((subtype)>>16)
|
RNA: subtypes and units
* Reviewed subtypes, making them more specific and adding new ones.
* Subtypes now have an associated type of units (length, area, volume,
mass, rotation, time, velocity, acceleration). These are not used
yet anywhere.
* Centralized code that decides the name of array items based on
subtype (XYZ, RGB), was copied in 3 places.
* RNA_def_float etc functions still need to be update, will do this
later together with another change.
2009-08-10 23:31:05 +02:00
|
|
|
|
2009-12-07 01:16:57 +01:00
|
|
|
#define RNA_ENUM_BITFLAG_SIZE 32
|
|
|
|
|
2011-09-05 23:01:50 +02:00
|
|
|
/* also update enums in bpy_props.c when adding items here
|
|
|
|
* watch it: these values are written to files as part of
|
|
|
|
* node socket button subtypes!
|
|
|
|
*/
|
2008-11-01 00:50:02 +01:00
|
|
|
typedef enum PropertySubType {
|
|
|
|
PROP_NONE = 0,
|
RNA: subtypes and units
* Reviewed subtypes, making them more specific and adding new ones.
* Subtypes now have an associated type of units (length, area, volume,
mass, rotation, time, velocity, acceleration). These are not used
yet anywhere.
* Centralized code that decides the name of array items based on
subtype (XYZ, RGB), was copied in 3 places.
* RNA_def_float etc functions still need to be update, will do this
later together with another change.
2009-08-10 23:31:05 +02:00
|
|
|
|
|
|
|
/* strings */
|
|
|
|
PROP_FILEPATH = 1,
|
|
|
|
PROP_DIRPATH = 2,
|
2009-09-12 21:54:39 +02:00
|
|
|
PROP_FILENAME = 3,
|
2011-11-15 08:09:41 +01:00
|
|
|
PROP_BYTESTRING = 4, /* a string which should be represented as bytes
|
|
|
|
* in python, still NULL terminated though. */
|
|
|
|
PROP_TRANSLATE = 5, /* a string which should be translated */
|
RNA: subtypes and units
* Reviewed subtypes, making them more specific and adding new ones.
* Subtypes now have an associated type of units (length, area, volume,
mass, rotation, time, velocity, acceleration). These are not used
yet anywhere.
* Centralized code that decides the name of array items based on
subtype (XYZ, RGB), was copied in 3 places.
* RNA_def_float etc functions still need to be update, will do this
later together with another change.
2009-08-10 23:31:05 +02:00
|
|
|
|
|
|
|
/* numbers */
|
|
|
|
PROP_UNSIGNED = 13,
|
|
|
|
PROP_PERCENTAGE = 14,
|
2009-09-21 23:19:58 +02:00
|
|
|
PROP_FACTOR = 15,
|
|
|
|
PROP_ANGLE = 16|PROP_UNIT_ROTATION,
|
|
|
|
PROP_TIME = 17|PROP_UNIT_TIME,
|
|
|
|
PROP_DISTANCE = 18|PROP_UNIT_LENGTH,
|
RNA: subtypes and units
* Reviewed subtypes, making them more specific and adding new ones.
* Subtypes now have an associated type of units (length, area, volume,
mass, rotation, time, velocity, acceleration). These are not used
yet anywhere.
* Centralized code that decides the name of array items based on
subtype (XYZ, RGB), was copied in 3 places.
* RNA_def_float etc functions still need to be update, will do this
later together with another change.
2009-08-10 23:31:05 +02:00
|
|
|
|
|
|
|
/* number arrays */
|
|
|
|
PROP_COLOR = 20,
|
|
|
|
PROP_TRANSLATION = 21|PROP_UNIT_LENGTH,
|
|
|
|
PROP_DIRECTION = 22,
|
|
|
|
PROP_VELOCITY = 23|PROP_UNIT_VELOCITY,
|
|
|
|
PROP_ACCELERATION = 24|PROP_UNIT_ACCELERATION,
|
|
|
|
PROP_MATRIX = 25,
|
|
|
|
PROP_EULER = 26|PROP_UNIT_ROTATION,
|
|
|
|
PROP_QUATERNION = 27,
|
2009-09-28 12:19:20 +02:00
|
|
|
PROP_AXISANGLE = 28,
|
|
|
|
PROP_XYZ = 29,
|
2010-06-05 17:31:55 +02:00
|
|
|
PROP_XYZ_LENGTH = 29|PROP_UNIT_LENGTH,
|
Changes to Color Management
After testing and feedback, I've decided to slightly modify the way color
management works internally. While the previous method worked well for
rendering, was a smaller transition and had some advantages over this
new method, it was a bit more ambiguous, and was making things difficult
for other areas such as compositing.
This implementation now considers all color data (with only a couple of
exceptions such as brush colors) to be stored in linear RGB color space,
rather than sRGB as previously. This brings it in line with Nuke, which also
operates this way, quite successfully. Color swatches, pickers, color ramp
display are now gamma corrected to display gamma so you can see what
you're doing, but the numbers themselves are considered linear. This
makes understanding blending modes more clear (a 0.5 value on overlay
will not change the result now) as well as making color swatches act more
predictably in the compositor, however bringing over color values from
applications like photoshop or gimp, that operate in a gamma space,
will give identical results.
This commit will convert over existing files saved by earlier 2.5 versions to
work generally the same, though there may be some slight differences with
things like textures. Now that we're set on changing other areas of shading,
this won't be too disruptive overall.
I've made a diagram explaining the pipeline here:
http://mke3.net/blender/devel/2.5/25_linear_workflow_pipeline.png
and some docs here:
http://www.blender.org/development/release-logs/blender-250/color-management/
2009-12-02 08:56:34 +01:00
|
|
|
PROP_COLOR_GAMMA = 30,
|
2011-04-08 15:32:56 +02:00
|
|
|
PROP_COORDS = 31, /* generic array, no units applied, only that x/y/z/w are used (python vec) */
|
RNA: subtypes and units
* Reviewed subtypes, making them more specific and adding new ones.
* Subtypes now have an associated type of units (length, area, volume,
mass, rotation, time, velocity, acceleration). These are not used
yet anywhere.
* Centralized code that decides the name of array items based on
subtype (XYZ, RGB), was copied in 3 places.
* RNA_def_float etc functions still need to be update, will do this
later together with another change.
2009-08-10 23:31:05 +02:00
|
|
|
|
2009-09-09 19:39:19 +02:00
|
|
|
/* booleans */
|
|
|
|
PROP_LAYER = 40,
|
|
|
|
PROP_LAYER_MEMBER = 41
|
2008-11-01 00:50:02 +01:00
|
|
|
} PropertySubType;
|
|
|
|
|
2010-02-01 23:04:33 +01:00
|
|
|
/* Make sure enums are updated with thses */
|
2008-11-01 00:50:02 +01:00
|
|
|
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-10-14 15:20:20 +02:00
|
|
|
PROP_EDITABLE = 1<<0,
|
2008-11-07 03:58:25 +01:00
|
|
|
|
2009-07-24 18:41:12 +02:00
|
|
|
/* this property is editable even if it is lib linked,
|
|
|
|
* meaning it will get lost on reload, but it's useful
|
|
|
|
* for editing. */
|
2009-10-14 15:20:20 +02:00
|
|
|
PROP_LIB_EXCEPTION = 1<<16,
|
2009-07-24 18:41:12 +02: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 */
|
2010-02-02 01:02:55 +01:00
|
|
|
PROP_ANIMATABLE = 1<<1,
|
2008-11-14 15:34:19 +01:00
|
|
|
|
2009-06-16 02:52:21 +02:00
|
|
|
/* icon */
|
2009-11-25 09:28:57 +01:00
|
|
|
PROP_ICONS_CONSECUTIVE = 1<<12,
|
2009-06-16 02:52:21 +02:00
|
|
|
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 20:40:03 +02:00
|
|
|
/* hidden in the user interface */
|
2009-10-14 15:20:20 +02:00
|
|
|
PROP_HIDDEN = 1<<19,
|
2011-06-07 12:54:57 +02:00
|
|
|
/* do not write in presets */
|
|
|
|
PROP_SKIP_SAVE = 1<<28,
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 20:40:03 +02:00
|
|
|
|
2009-04-11 03:43:50 +02:00
|
|
|
/* function paramater flags */
|
2009-10-14 15:20:20 +02:00
|
|
|
PROP_REQUIRED = 1<<2,
|
2010-01-24 11:51:59 +01:00
|
|
|
PROP_OUTPUT = 1<<3,
|
2009-10-14 15:20:20 +02:00
|
|
|
PROP_RNAPTR = 1<<11,
|
2009-04-19 15:37:59 +02:00
|
|
|
/* registering */
|
2009-10-14 15:20:20 +02:00
|
|
|
PROP_REGISTER = 1<<4,
|
|
|
|
PROP_REGISTER_OPTIONAL = (1<<4)|(1<<5),
|
2009-04-11 03:43:50 +02:00
|
|
|
|
2009-05-29 17:12:31 +02:00
|
|
|
/* pointers */
|
2009-10-14 15:20:20 +02:00
|
|
|
PROP_ID_REFCOUNT = 1<<6,
|
|
|
|
|
|
|
|
/* disallow assigning a variable to its self, eg an object tracking its self
|
|
|
|
* only apply this to types that are derived from an ID ()*/
|
|
|
|
PROP_ID_SELF_CHECK = 1<<20,
|
|
|
|
PROP_NEVER_NULL = 1<<18,
|
2010-12-30 13:22:28 +01:00
|
|
|
/* currently only used for UI, this is similar to PROP_NEVER_NULL
|
|
|
|
* except that the value may be NULL at times, used for ObData, where an Empty's will be NULL
|
|
|
|
* but setting NULL on a mesh object is not possible. So, if its not NULL, setting NULL cant be done! */
|
|
|
|
PROP_NEVER_UNLINK = 1<<25,
|
2009-05-29 17:12:31 +02:00
|
|
|
|
2009-12-22 17:11:11 +01:00
|
|
|
/* flag contains multiple enums.
|
|
|
|
* note: not to be confused with prop->enumbitflags
|
|
|
|
* this exposes the flag as multiple options in python and the UI.
|
|
|
|
*
|
|
|
|
* note: these can't be animated so use with care.
|
|
|
|
*/
|
2009-12-07 01:16:57 +01:00
|
|
|
PROP_ENUM_FLAG = 1<<21,
|
|
|
|
|
2009-12-08 18:23:48 +01:00
|
|
|
/* need context for update function */
|
|
|
|
PROP_CONTEXT_UPDATE = 1<<22,
|
2011-06-06 19:50:20 +02:00
|
|
|
PROP_CONTEXT_PROPERTY_UPDATE = (1<<22)|(1<<27),
|
2009-12-08 18:23:48 +01:00
|
|
|
|
2009-12-28 23:59:09 +01:00
|
|
|
/* Use for arrays or for any data that should not have a referene kept
|
|
|
|
* most common case is functions that return arrays where the array */
|
|
|
|
PROP_THICK_WRAP = 1<<23,
|
|
|
|
|
2011-01-24 04:38:34 +01:00
|
|
|
/* Reject values outside limits, use for python api only so far
|
|
|
|
* this is for use when silently clamping string length will give
|
|
|
|
* bad behavior later. Could also enforce this for INT's and other types.
|
|
|
|
* note: currently no support for function arguments or non utf8 paths (filepaths) */
|
|
|
|
PROP_NEVER_CLAMP = 1<<26,
|
|
|
|
|
2008-11-17 19:44:06 +01:00
|
|
|
/* internal flags */
|
2009-10-14 15:20:20 +02:00
|
|
|
PROP_BUILTIN = 1<<7,
|
|
|
|
PROP_EXPORT = 1<<8,
|
|
|
|
PROP_RUNTIME = 1<<9,
|
|
|
|
PROP_IDPROPERTY = 1<<10,
|
|
|
|
PROP_RAW_ACCESS = 1<<13,
|
|
|
|
PROP_RAW_ARRAY = 1<<14,
|
|
|
|
PROP_FREE_POINTERS = 1<<15,
|
2010-01-27 22:19:39 +01:00
|
|
|
PROP_DYNAMIC = 1<<17, /* for dynamic arrays, and retvals of type string */
|
2010-11-23 13:05:35 +01:00
|
|
|
PROP_ENUM_NO_CONTEXT = 1<<24 /* for enum that shouldn't be contextual */
|
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-14 18:05:25 +01:00
|
|
|
PointerRNA ptr;
|
2011-10-03 03:36:25 +02:00
|
|
|
int valid;
|
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;
|
|
|
|
|
RNA
Implementation of RNA side of foreach_get/foreach_set,
Campbell will do python code.
Three functions for efficiently setting some property for all
items in a collection. RNA_property_collection_raw_array gives
access to the properties as an array with length, stride, and
type specified, if this is possible, i.e. not when it uses a
ListBase, or if a manual get/set function is implemented.
Two other functions take a C array pointer and get/set it
using the a collection + property name, using efficient array
access if possible, and otherwise using slower RNA iterator.
RNA_property_collection_raw_get
RNA_property_collection_raw_set
The number of type conversion required here got a bit out of
hand, it could be more efficient still if checking for more
cases, but function is already long enough.
Example: http://www.pasteall.org/6362/c
2009-06-29 21:15:51 +02:00
|
|
|
typedef enum RawPropertyType {
|
2010-01-04 23:30:09 +01:00
|
|
|
PROP_RAW_UNSET=-1,
|
2009-08-30 01:05:46 +02:00
|
|
|
PROP_RAW_INT, // XXX - abused for types that are not set, eg. MFace.verts, needs fixing.
|
RNA
Implementation of RNA side of foreach_get/foreach_set,
Campbell will do python code.
Three functions for efficiently setting some property for all
items in a collection. RNA_property_collection_raw_array gives
access to the properties as an array with length, stride, and
type specified, if this is possible, i.e. not when it uses a
ListBase, or if a manual get/set function is implemented.
Two other functions take a C array pointer and get/set it
using the a collection + property name, using efficient array
access if possible, and otherwise using slower RNA iterator.
RNA_property_collection_raw_get
RNA_property_collection_raw_set
The number of type conversion required here got a bit out of
hand, it could be more efficient still if checking for more
cases, but function is already long enough.
Example: http://www.pasteall.org/6362/c
2009-06-29 21:15:51 +02:00
|
|
|
PROP_RAW_SHORT,
|
2009-08-30 01:05:46 +02:00
|
|
|
PROP_RAW_CHAR,
|
|
|
|
PROP_RAW_DOUBLE,
|
|
|
|
PROP_RAW_FLOAT
|
RNA
Implementation of RNA side of foreach_get/foreach_set,
Campbell will do python code.
Three functions for efficiently setting some property for all
items in a collection. RNA_property_collection_raw_array gives
access to the properties as an array with length, stride, and
type specified, if this is possible, i.e. not when it uses a
ListBase, or if a manual get/set function is implemented.
Two other functions take a C array pointer and get/set it
using the a collection + property name, using efficient array
access if possible, and otherwise using slower RNA iterator.
RNA_property_collection_raw_get
RNA_property_collection_raw_set
The number of type conversion required here got a bit out of
hand, it could be more efficient still if checking for more
cases, but function is already long enough.
Example: http://www.pasteall.org/6362/c
2009-06-29 21:15:51 +02:00
|
|
|
} RawPropertyType;
|
|
|
|
|
|
|
|
typedef struct RawArray {
|
|
|
|
void *array;
|
|
|
|
RawPropertyType type;
|
|
|
|
int len;
|
|
|
|
int stride;
|
|
|
|
} RawArray;
|
|
|
|
|
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;
|
2009-06-16 02:52:21 +02:00
|
|
|
int icon;
|
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
|
|
|
|
2011-05-26 15:38:16 +02:00
|
|
|
/* this is a copy of 'PropEnumItemFunc' defined in rna_internal_types.h */
|
|
|
|
typedef EnumPropertyItem *(*EnumPropertyItemFunc)(struct bContext *C, PointerRNA *ptr, struct PropertyRNA *prop, int *free);
|
2009-07-08 17:34:41 +02: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 */
|
|
|
|
|
2009-07-17 04:31:28 +02:00
|
|
|
typedef struct ParameterList {
|
|
|
|
/* storage for parameters */
|
|
|
|
void *data;
|
|
|
|
|
2011-10-03 03:36:25 +02:00
|
|
|
/* function passed at creation time */
|
|
|
|
struct FunctionRNA *func;
|
|
|
|
|
2010-03-23 16:04:06 +01:00
|
|
|
/* store the parameter size */
|
|
|
|
int alloc_size;
|
|
|
|
|
|
|
|
int arg_count, ret_count;
|
2009-07-17 04:31:28 +02:00
|
|
|
} ParameterList;
|
2009-04-07 02:49:39 +02:00
|
|
|
|
|
|
|
typedef struct ParameterIterator {
|
2009-07-17 04:31:28 +02:00
|
|
|
struct ParameterList *parms;
|
2011-08-15 05:41:31 +02:00
|
|
|
/* PointerRNA funcptr; */ /*UNUSED*/
|
2009-04-07 02:49:39 +02:00
|
|
|
void *data;
|
|
|
|
int size, offset;
|
|
|
|
|
|
|
|
PropertyRNA *parm;
|
|
|
|
int valid;
|
|
|
|
} ParameterIterator;
|
|
|
|
|
2010-08-31 13:31:21 +02:00
|
|
|
/* mainly to avoid confusing casts */
|
|
|
|
typedef struct ParameterDynAlloc {
|
|
|
|
intptr_t array_tot; /* important, this breaks when set to an int */
|
|
|
|
void *array;
|
|
|
|
} ParameterDynAlloc;
|
|
|
|
|
2009-04-07 02:49:39 +02:00
|
|
|
/* Function */
|
|
|
|
|
|
|
|
typedef enum FunctionFlag {
|
2009-06-18 21:48:55 +02:00
|
|
|
FUNC_NO_SELF = 1, /* for static functions */
|
2011-11-17 19:41:37 +01:00
|
|
|
FUNC_USE_MAIN = 2,
|
|
|
|
FUNC_USE_CONTEXT = 4,
|
|
|
|
FUNC_USE_REPORTS = 8,
|
2010-01-22 11:58:02 +01:00
|
|
|
FUNC_USE_SELF_ID = 2048,
|
2009-04-07 02:49:39 +02:00
|
|
|
|
2009-04-19 15:37:59 +02:00
|
|
|
/* registering */
|
2011-11-17 19:41:37 +01:00
|
|
|
FUNC_REGISTER = 16,
|
|
|
|
FUNC_REGISTER_OPTIONAL = 16|32,
|
2009-04-19 15:37:59 +02:00
|
|
|
|
2009-04-07 02:49:39 +02:00
|
|
|
/* internal flags */
|
|
|
|
FUNC_BUILTIN = 128,
|
|
|
|
FUNC_EXPORT = 256,
|
2009-07-21 22:05:16 +02:00
|
|
|
FUNC_RUNTIME = 512,
|
|
|
|
FUNC_FREE_POINTERS = 1024
|
2009-04-07 02:49:39 +02:00
|
|
|
} FunctionFlag;
|
|
|
|
|
2009-06-18 21:48:55 +02:00
|
|
|
typedef void (*CallFunc)(struct bContext *C, struct ReportList *reports, PointerRNA *ptr, ParameterList *parms);
|
2009-04-07 02:49:39 +02:00
|
|
|
|
|
|
|
typedef struct FunctionRNA FunctionRNA;
|
|
|
|
|
2008-11-07 03:58:25 +01:00
|
|
|
/* Struct */
|
|
|
|
|
|
|
|
typedef enum StructFlag {
|
2009-05-29 17:12:31 +02:00
|
|
|
/* indicates that this struct is an ID struct, and to use refcounting */
|
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,
|
2009-05-29 17:12:31 +02:00
|
|
|
STRUCT_ID_REFCOUNT = 2,
|
2011-11-08 16:11:27 +01:00
|
|
|
STRUCT_UNDO = 4, /* defaults on, clear for user preferences and similar */
|
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
|
|
|
|
|
|
|
/* internal flags */
|
2011-11-08 16:11:27 +01:00
|
|
|
STRUCT_RUNTIME = 8,
|
|
|
|
STRUCT_GENERATED = 16,
|
|
|
|
STRUCT_FREE_POINTERS = 32,
|
|
|
|
STRUCT_NO_IDPROPERTIES = 64 /* Menu's and Panels don't need properties */
|
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);
|
2010-12-07 05:12:15 +01:00
|
|
|
typedef int (*StructCallbackFunc)(struct bContext *C, struct PointerRNA *ptr, struct FunctionRNA *func, ParameterList *list);
|
2009-04-19 15:37:59 +02:00
|
|
|
typedef void (*StructFreeFunc)(void *data);
|
2011-05-18 12:56:26 +02:00
|
|
|
typedef struct StructRNA *(*StructRegisterFunc)(struct Main *bmain, struct ReportList *reports, void *data,
|
2.5: RNA, defining enums, pointers and collections properties is now
possible from python, but it's still work in progress.
Pointers and collections are restricted to types derived from
IDPropertyGroup (same as for operators), because RNA knows how to
allocate/deallocate those.
Collections have .add() and .remove(number) functions that can be
used. The remove function should be fixed to take an other argument
than a number.
With the IDPropertyGroup restriction, pointers are more like nested
structs. They don't have add(), remove() yet, not sure where to put
them. Currently the pointer / nested struct is automatically allocated
in the get() function, this needs to be fixed, rule is that RNA get()
will not change any data for thread safety.
Also, it is only possible to add properties to structs after they have
been registered, which needs to be improved as well.
Example code:
http://www.pasteall.org/7201/python
2009-08-18 03:29:25 +02:00
|
|
|
const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free);
|
2011-05-18 12:56:26 +02:00
|
|
|
typedef void (*StructUnregisterFunc)(struct Main *bmain, struct StructRNA *type);
|
2011-05-18 13:21:10 +02:00
|
|
|
typedef void **(*StructInstanceFunc)(PointerRNA *ptr);
|
2009-04-19 15:37:59 +02:00
|
|
|
|
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-07-21 22:05:16 +02:00
|
|
|
/* Extending
|
|
|
|
*
|
|
|
|
* This struct must be embedded in *Type structs in
|
|
|
|
* order to make then definable through RNA. */
|
|
|
|
|
|
|
|
typedef struct ExtensionRNA {
|
|
|
|
void *data;
|
|
|
|
StructRNA *srna;
|
2010-12-07 05:12:15 +01:00
|
|
|
StructCallbackFunc call;
|
|
|
|
StructFreeFunc free;
|
|
|
|
|
2009-07-21 22:05:16 +02:00
|
|
|
} ExtensionRNA;
|
|
|
|
|
2009-03-15 00:17:55 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-01-15 17:14:57 +01:00
|
|
|
#endif /* RNA_TYPES_H */
|