2 * ***** BEGIN GPL LICENSE BLOCK *****
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * Contributor(s): Blender Foundation (2008).
20 * ***** END GPL LICENSE BLOCK *****
23 /** \file blender/makesrna/RNA_types.h
28 #include "BLO_sys_types.h"
30 #ifndef __RNA_TYPES_H__
31 #define __RNA_TYPES_H__
40 struct EnumPropertyRNA;
50 * RNA pointers are not a single C pointer but include the type,
51 * and a pointer to the ID struct that owns the struct, since
52 * in some cases this information is needed to correctly get/set
53 * the properties and validate them. */
55 typedef struct PointerRNA {
60 struct StructRNA *type;
64 typedef struct PropertyPointerRNA {
66 struct PropertyRNA *prop;
71 typedef enum PropertyType {
81 /* also update rna_property_subtype_unit when you change this */
82 typedef enum PropertyUnit {
83 PROP_UNIT_NONE = (0<<16),
84 PROP_UNIT_LENGTH = (1<<16), /* m */
85 PROP_UNIT_AREA = (2<<16), /* m^2 */
86 PROP_UNIT_VOLUME = (3<<16), /* m^3 */
87 PROP_UNIT_MASS = (4<<16), /* kg */
88 PROP_UNIT_ROTATION = (5<<16), /* radians */
89 PROP_UNIT_TIME = (6<<16), /* frame */
90 PROP_UNIT_VELOCITY = (7<<16), /* m/s */
91 PROP_UNIT_ACCELERATION = (8<<16) /* m/(s^2) */
94 #define RNA_SUBTYPE_UNIT(subtype) ((subtype) & 0x00FF0000)
95 #define RNA_SUBTYPE_VALUE(subtype) ((subtype) & ~0x00FF0000)
96 #define RNA_SUBTYPE_UNIT_VALUE(subtype) ((subtype) >> 16)
98 #define RNA_ENUM_BITFLAG_SIZE 32
100 #define RNA_TRANSLATION_PREC_DEFAULT 5
102 /* also update enums in bpy_props.c when adding items here
103 * watch it: these values are written to files as part of
104 * node socket button subtypes!
106 typedef enum PropertySubType {
113 PROP_BYTESTRING = 4, /* a string which should be represented as bytes
114 * in python, still NULL terminated though. */
115 PROP_TRANSLATE = 5, /* a string which should be translated */
119 PROP_PERCENTAGE = 14,
121 PROP_ANGLE = 16|PROP_UNIT_ROTATION,
122 PROP_TIME = 17|PROP_UNIT_TIME,
123 PROP_DISTANCE = 18|PROP_UNIT_LENGTH,
127 PROP_TRANSLATION = 21|PROP_UNIT_LENGTH,
129 PROP_VELOCITY = 23|PROP_UNIT_VELOCITY,
130 PROP_ACCELERATION = 24|PROP_UNIT_ACCELERATION,
132 PROP_EULER = 26|PROP_UNIT_ROTATION,
133 PROP_QUATERNION = 27,
136 PROP_XYZ_LENGTH = 29|PROP_UNIT_LENGTH,
137 PROP_COLOR_GAMMA = 30,
138 PROP_COORDS = 31, /* generic array, no units applied, only that x/y/z/w are used (python vec) */
142 PROP_LAYER_MEMBER = 41
145 /* Make sure enums are updated with thses */
146 typedef enum PropertyFlag {
147 /* editable means the property is editable in the user
148 * interface, properties are editable by default except
149 * for pointers and collections. */
150 PROP_EDITABLE = 1<<0,
152 /* this property is editable even if it is lib linked,
153 * meaning it will get lost on reload, but it's useful
155 PROP_LIB_EXCEPTION = 1<<16,
157 /* animatable means the property can be driven by some
158 * other input, be it animation curves, expressions, ..
159 * properties are animatable by default except for pointers
161 PROP_ANIMATABLE = 1<<1,
164 PROP_ICONS_CONSECUTIVE = 1<<12,
166 /* hidden in the user interface */
168 /* do not write in presets */
169 PROP_SKIP_SAVE = 1<<28,
171 /* function paramater flags */
172 PROP_REQUIRED = 1<<2,
176 PROP_REGISTER = 1<<4,
177 PROP_REGISTER_OPTIONAL = (1<<4)|(1<<5),
180 PROP_ID_REFCOUNT = 1<<6,
182 /* disallow assigning a variable to its self, eg an object tracking its self
183 * only apply this to types that are derived from an ID ()*/
184 PROP_ID_SELF_CHECK = 1<<20,
186 * - pointers: in the UI and python so unsetting or setting to None won't work
187 * - strings: so our internal generated get/length/set functions know to do NULL checks before access [#30865] */
188 PROP_NEVER_NULL = 1<<18,
189 /* currently only used for UI, this is similar to PROP_NEVER_NULL
190 * except that the value may be NULL at times, used for ObData, where an Empty's will be NULL
191 * but setting NULL on a mesh object is not possible. So, if its not NULL, setting NULL cant be done! */
192 PROP_NEVER_UNLINK = 1<<25,
194 /* flag contains multiple enums.
195 * note: not to be confused with prop->enumbitflags
196 * this exposes the flag as multiple options in python and the UI.
198 * note: these can't be animated so use with care.
200 PROP_ENUM_FLAG = 1<<21,
202 /* need context for update function */
203 PROP_CONTEXT_UPDATE = 1<<22,
204 PROP_CONTEXT_PROPERTY_UPDATE = (1<<22)|(1<<27),
206 /* Use for arrays or for any data that should not have a referene kept
207 * most common case is functions that return arrays where the array */
208 PROP_THICK_WRAP = 1<<23,
210 /* Reject values outside limits, use for python api only so far
211 * this is for use when silently clamping string length will give
212 * bad behavior later. Could also enforce this for INT's and other types.
213 * note: currently no support for function arguments or non utf8 paths (filepaths) */
214 PROP_NEVER_CLAMP = 1<<26,
220 PROP_IDPROPERTY = 1<<10,
221 PROP_RAW_ACCESS = 1<<13,
222 PROP_RAW_ARRAY = 1<<14,
223 PROP_FREE_POINTERS = 1<<15,
224 PROP_DYNAMIC = 1<<17, /* for dynamic arrays, and retvals of type string */
225 PROP_ENUM_NO_CONTEXT = 1<<24 /* for enum that shouldn't be contextual */
228 typedef struct CollectionPropertyIterator {
231 PointerRNA builtin_parent;
232 struct PropertyRNA *prop;
240 } CollectionPropertyIterator;
242 typedef struct CollectionPointerLink {
243 struct CollectionPointerLink *next, *prev;
245 } CollectionPointerLink;
247 typedef enum RawPropertyType {
249 PROP_RAW_INT, // XXX - abused for types that are not set, eg. MFace.verts, needs fixing.
256 typedef struct RawArray {
258 RawPropertyType type;
263 typedef struct EnumPropertyItem {
265 const char *identifier;
268 const char *description;
271 /* this is a copy of 'PropEnumItemFunc' defined in rna_internal_types.h */
272 typedef EnumPropertyItem *(*EnumPropertyItemFunc)(struct bContext *C, PointerRNA *ptr, struct PropertyRNA *prop, int *free);
274 typedef struct PropertyRNA PropertyRNA;
278 typedef struct ParameterList {
279 /* storage for parameters */
282 /* function passed at creation time */
283 struct FunctionRNA *func;
285 /* store the parameter size */
288 int arg_count, ret_count;
291 typedef struct ParameterIterator {
292 struct ParameterList *parms;
293 /* PointerRNA funcptr; */ /*UNUSED*/
301 /* mainly to avoid confusing casts */
302 typedef struct ParameterDynAlloc {
303 intptr_t array_tot; /* important, this breaks when set to an int */
309 typedef enum FunctionFlag {
310 FUNC_NO_SELF = 1, /* for static functions */
312 FUNC_USE_CONTEXT = 4,
313 FUNC_USE_REPORTS = 8,
314 FUNC_USE_SELF_ID = 2048,
318 FUNC_REGISTER_OPTIONAL = 16|32,
324 FUNC_FREE_POINTERS = 1024
327 typedef void (*CallFunc)(struct bContext *C, struct ReportList *reports, PointerRNA *ptr, ParameterList *parms);
329 typedef struct FunctionRNA FunctionRNA;
333 typedef enum StructFlag {
334 /* indicates that this struct is an ID struct, and to use refcounting */
336 STRUCT_ID_REFCOUNT = 2,
337 STRUCT_UNDO = 4, /* defaults on, clear for user preferences and similar */
341 STRUCT_GENERATED = 16,
342 STRUCT_FREE_POINTERS = 32,
343 STRUCT_NO_IDPROPERTIES = 64 /* Menu's and Panels don't need properties */
346 typedef int (*StructValidateFunc)(struct PointerRNA *ptr, void *data, int *have_function);
347 typedef int (*StructCallbackFunc)(struct bContext *C, struct PointerRNA *ptr, struct FunctionRNA *func, ParameterList *list);
348 typedef void (*StructFreeFunc)(void *data);
349 typedef struct StructRNA *(*StructRegisterFunc)(
350 struct Main *bmain, struct ReportList *reports, void *data, const char *identifier,
351 StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free);
353 typedef void (*StructUnregisterFunc)(struct Main *bmain, struct StructRNA *type);
354 typedef void **(*StructInstanceFunc)(PointerRNA *ptr);
356 typedef struct StructRNA StructRNA;
360 * Root RNA data structure that lists all struct types. */
362 typedef struct BlenderRNA BlenderRNA;
366 * This struct must be embedded in *Type structs in
367 * order to make then definable through RNA. */
369 typedef struct ExtensionRNA {
372 StructCallbackFunc call;
381 #endif /* __RNA_TYPES_H__ */