4 * ***** BEGIN GPL LICENSE BLOCK *****
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * Contributor(s): Blender Foundation (2008).
22 * ***** END GPL LICENSE BLOCK *****
43 * RNA pointers are not a single C pointer but include the type,
44 * and a pointer to the ID struct that owns the struct, since
45 * in some cases this information is needed to correctly get/set
46 * the properties and validate them. */
48 typedef struct PointerRNA {
53 struct StructRNA *type;
57 typedef struct PropertyPointerRNA {
59 struct PropertyRNA *prop;
64 typedef enum PropertyType {
74 /* also update rna_property_subtype_unit when you change this */
75 typedef enum PropertyUnit {
76 PROP_UNIT_NONE = (0<<16),
77 PROP_UNIT_LENGTH = (1<<16), /* m */
78 PROP_UNIT_AREA = (2<<16), /* m^2 */
79 PROP_UNIT_VOLUME = (3<<16), /* m^3 */
80 PROP_UNIT_MASS = (4<<16), /* kg */
81 PROP_UNIT_ROTATION = (5<<16), /* rad */
82 PROP_UNIT_TIME = (6<<16), /* frame */
83 PROP_UNIT_VELOCITY = (7<<16), /* m/s */
84 PROP_UNIT_ACCELERATION = (8<<16) /* m/(s^2) */
87 #define RNA_SUBTYPE_UNIT(subtype) ((subtype) & 0x00FF0000)
88 #define RNA_SUBTYPE_VALUE(subtype) ((subtype) & ~0x00FF0000)
89 #define RNA_SUBTYPE_UNIT_VALUE(subtype) ((subtype)>>16)
91 #define RNA_ENUM_BITFLAG_SIZE 32
93 /* also update enums in bpy_props.c when adding items here */
94 typedef enum PropertySubType {
104 PROP_PERCENTAGE = 14,
106 PROP_ANGLE = 16|PROP_UNIT_ROTATION,
107 PROP_TIME = 17|PROP_UNIT_TIME,
108 PROP_DISTANCE = 18|PROP_UNIT_LENGTH,
112 PROP_TRANSLATION = 21|PROP_UNIT_LENGTH,
114 PROP_VELOCITY = 23|PROP_UNIT_VELOCITY,
115 PROP_ACCELERATION = 24|PROP_UNIT_ACCELERATION,
117 PROP_EULER = 26|PROP_UNIT_ROTATION,
118 PROP_QUATERNION = 27,
121 PROP_COLOR_GAMMA = 30,
125 PROP_LAYER_MEMBER = 41
128 /* Make sure enums are updated with thses */
129 typedef enum PropertyFlag {
130 /* editable means the property is editable in the user
131 * interface, properties are editable by default except
132 * for pointers and collections. */
133 PROP_EDITABLE = 1<<0,
135 /* this property is editable even if it is lib linked,
136 * meaning it will get lost on reload, but it's useful
138 PROP_LIB_EXCEPTION = 1<<16,
140 /* animateable means the property can be driven by some
141 * other input, be it animation curves, expressions, ..
142 * properties are animateable by default except for pointers
144 PROP_ANIMATABLE = 1<<1,
147 PROP_ICONS_CONSECUTIVE = 1<<12,
149 /* hidden in the user interface */
152 /* function paramater flags */
153 PROP_REQUIRED = 1<<2,
157 PROP_REGISTER = 1<<4,
158 PROP_REGISTER_OPTIONAL = (1<<4)|(1<<5),
161 PROP_ID_REFCOUNT = 1<<6,
163 /* disallow assigning a variable to its self, eg an object tracking its self
164 * only apply this to types that are derived from an ID ()*/
165 PROP_ID_SELF_CHECK = 1<<20,
166 PROP_NEVER_NULL = 1<<18,
168 /* flag contains multiple enums.
169 * note: not to be confused with prop->enumbitflags
170 * this exposes the flag as multiple options in python and the UI.
172 * note: these can't be animated so use with care.
174 PROP_ENUM_FLAG = 1<<21,
176 /* need context for update function */
177 PROP_CONTEXT_UPDATE = 1<<22,
179 /* Use for arrays or for any data that should not have a referene kept
180 * most common case is functions that return arrays where the array */
181 PROP_THICK_WRAP = 1<<23,
187 PROP_IDPROPERTY = 1<<10,
188 PROP_RAW_ACCESS = 1<<13,
189 PROP_RAW_ARRAY = 1<<14,
190 PROP_FREE_POINTERS = 1<<15,
191 PROP_DYNAMIC = 1<<17, /* for dynamic arrays, and retvals of type string */
192 PROP_ENUM_NO_CONTEXT = 1<<18 /* for enum that shouldn't be contextual */
195 typedef struct CollectionPropertyIterator {
198 PointerRNA builtin_parent;
199 struct PropertyRNA *prop;
207 } CollectionPropertyIterator;
209 typedef struct CollectionPointerLink {
210 struct CollectionPointerLink *next, *prev;
212 } CollectionPointerLink;
214 typedef enum RawPropertyType {
216 PROP_RAW_INT, // XXX - abused for types that are not set, eg. MFace.verts, needs fixing.
223 typedef struct RawArray {
225 RawPropertyType type;
230 typedef struct EnumPropertyItem {
232 const char *identifier;
235 const char *description;
238 typedef EnumPropertyItem *(*EnumPropertyItemFunc)(struct bContext *C, PointerRNA *ptr, int *free);
240 typedef struct PropertyRNA PropertyRNA;
244 typedef struct ParameterList {
245 /* storage for parameters */
248 /* store the parameter size */
251 int arg_count, ret_count;
253 /* function passed at creation time */
254 struct FunctionRNA *func;
257 typedef struct ParameterIterator {
258 struct ParameterList *parms;
269 typedef enum FunctionFlag {
270 FUNC_NO_SELF = 1, /* for static functions */
271 FUNC_USE_CONTEXT = 2,
272 FUNC_USE_REPORTS = 4,
273 FUNC_USE_SELF_ID = 2048,
277 FUNC_REGISTER_OPTIONAL = 8|16,
283 FUNC_FREE_POINTERS = 1024
286 typedef void (*CallFunc)(struct bContext *C, struct ReportList *reports, PointerRNA *ptr, ParameterList *parms);
288 typedef struct FunctionRNA FunctionRNA;
292 typedef enum StructFlag {
293 /* indicates that this struct is an ID struct, and to use refcounting */
295 STRUCT_ID_REFCOUNT = 2,
299 STRUCT_GENERATED = 8,
300 STRUCT_FREE_POINTERS = 16
303 typedef int (*StructValidateFunc)(struct PointerRNA *ptr, void *data, int *have_function);
304 typedef int (*StructCallbackFunc)(struct PointerRNA *ptr, struct FunctionRNA *func, ParameterList *list);
305 typedef void (*StructFreeFunc)(void *data);
306 typedef struct StructRNA *(*StructRegisterFunc)(const struct bContext *C, struct ReportList *reports, void *data,
307 const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free);
308 typedef void (*StructUnregisterFunc)(const struct bContext *C, struct StructRNA *type);
310 typedef struct StructRNA StructRNA;
314 * Root RNA data structure that lists all struct types. */
316 typedef struct BlenderRNA BlenderRNA;
320 * This struct must be embedded in *Type structs in
321 * order to make then definable through RNA. */
323 typedef struct ExtensionRNA {
327 int (*call)(PointerRNA *, FunctionRNA *, ParameterList *);
328 void (*free)(void *data);
331 /* fake struct definitions, needed otherwise collections end up owning the C
332 * structs like 'Object' when defined first */
333 #define MainCameras Main
334 #define MainScenes Main
335 #define MainArmatures Main
336 #define MainMaterials Main
337 #define MainMeshes Main
338 #define MainLamps Main
339 #define MainImages Main
340 #define MainObjects Main
341 #define MainTexts Main
342 #define MainActions Main
343 #define MainGroups Main
344 #define MainTextures Main
345 #define MainCurves Main
351 #endif /* RNA_TYPES */