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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 * Contributor(s): Blender Foundation (2008).
22 * ***** END GPL LICENSE BLOCK *****
25 #ifndef RNA_INTERNAL_TYPES
26 #define RNA_INTERNAL_TYPES
28 #include "DNA_listBase.h"
37 struct CollectionPropertyIterator;
43 #define RNA_MAX_ARRAY_LENGTH 64
45 #define RNA_MAX_ARRAY_LENGTH 32
48 #define RNA_MAX_ARRAY_DIMENSION 3
50 /* Function Callbacks */
52 typedef void (*UpdateFunc)(struct bContext *C, struct PointerRNA *ptr);
53 typedef int (*EditableFunc)(struct PointerRNA *ptr);
54 typedef struct IDProperty* (*IDPropertiesFunc)(struct PointerRNA *ptr, int create);
55 typedef struct StructRNA *(*StructRefineFunc)(struct PointerRNA *ptr);
56 typedef char *(*StructPathFunc)(struct PointerRNA *ptr);
58 typedef int (*PropArrayLengthGetFunc)(struct PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION]);
59 typedef int (*PropBooleanGetFunc)(struct PointerRNA *ptr);
60 typedef void (*PropBooleanSetFunc)(struct PointerRNA *ptr, int value);
61 typedef void (*PropBooleanArrayGetFunc)(struct PointerRNA *ptr, int *values);
62 typedef void (*PropBooleanArraySetFunc)(struct PointerRNA *ptr, const int *values);
63 typedef int (*PropIntGetFunc)(struct PointerRNA *ptr);
64 typedef void (*PropIntSetFunc)(struct PointerRNA *ptr, int value);
65 typedef void (*PropIntArrayGetFunc)(struct PointerRNA *ptr, int *values);
66 typedef void (*PropIntArraySetFunc)(struct PointerRNA *ptr, const int *values);
67 typedef void (*PropIntRangeFunc)(struct PointerRNA *ptr, int *min, int *max);
68 typedef float (*PropFloatGetFunc)(struct PointerRNA *ptr);
69 typedef void (*PropFloatSetFunc)(struct PointerRNA *ptr, float value);
70 typedef void (*PropFloatArrayGetFunc)(struct PointerRNA *ptr, float *values);
71 typedef void (*PropFloatArraySetFunc)(struct PointerRNA *ptr, const float *values);
72 typedef void (*PropFloatRangeFunc)(struct PointerRNA *ptr, float *min, float *max);
73 typedef void (*PropStringGetFunc)(struct PointerRNA *ptr, char *value);
74 typedef int (*PropStringLengthFunc)(struct PointerRNA *ptr);
75 typedef void (*PropStringSetFunc)(struct PointerRNA *ptr, const char *value);
76 typedef int (*PropEnumGetFunc)(struct PointerRNA *ptr);
77 typedef void (*PropEnumSetFunc)(struct PointerRNA *ptr, int value);
78 typedef EnumPropertyItem *(*PropEnumItemFunc)(struct bContext *C, struct PointerRNA *ptr, int *free);
79 typedef PointerRNA (*PropPointerGetFunc)(struct PointerRNA *ptr);
80 typedef StructRNA* (*PropPointerTypeFunc)(struct PointerRNA *ptr);
81 typedef void (*PropPointerSetFunc)(struct PointerRNA *ptr, const PointerRNA value);
82 typedef void (*PropCollectionBeginFunc)(struct CollectionPropertyIterator *iter, struct PointerRNA *ptr);
83 typedef void (*PropCollectionNextFunc)(struct CollectionPropertyIterator *iter);
84 typedef void (*PropCollectionEndFunc)(struct CollectionPropertyIterator *iter);
85 typedef PointerRNA (*PropCollectionGetFunc)(struct CollectionPropertyIterator *iter);
86 typedef int (*PropCollectionLengthFunc)(struct PointerRNA *ptr);
87 typedef PointerRNA (*PropCollectionLookupIntFunc)(struct PointerRNA *ptr, int key);
88 typedef PointerRNA (*PropCollectionLookupStringFunc)(struct PointerRNA *ptr, const char *key);
90 /* Container - generic abstracted container of RNA properties */
91 typedef struct ContainerRNA {
94 struct GHash *prophash;
99 /* structs are containers of properties */
102 /* unique identifier */
103 const char *identifier;
104 /* various options */
107 /* single line description, displayed in the tooltip for example */
108 const char *description;
110 /* callback to execute the function */
113 /* parameter for the return value */
118 struct PropertyRNA *next, *prev;
120 /* magic bytes to distinguish with IDProperty */
123 /* unique identifier */
124 const char *identifier;
125 /* various options */
128 /* user readable name */
130 /* single line description, displayed in the tooltip for example */
131 const char *description;
135 /* property type as it appears to the outside */
137 /* subtype, 'interpretation' of the property */
138 PropertySubType subtype;
139 /* if non-NULL, overrides arraylength. Must not return 0? */
140 PropArrayLengthGetFunc getlength;
141 /* dimension of array */
142 unsigned int arraydimension;
143 /* array lengths lengths for all dimensions (when arraydimension > 0) */
144 unsigned int arraylength[RNA_MAX_ARRAY_DIMENSION];
145 unsigned int totarraylength;
147 /* callback for updates on change */
151 /* callback for testing if editable/evaluated */
152 EditableFunc editable;
156 RawPropertyType rawtype;
158 /* This is used for accessing props/functions of this property
159 * any property can have this but should only be used for collections and arrays
160 * since python will convert int/bool/pointer's */
161 struct StructRNA *srna; /* attributes attached directly to this collection */
166 typedef struct BooleanPropertyRNA {
167 PropertyRNA property;
169 PropBooleanGetFunc get;
170 PropBooleanSetFunc set;
172 PropBooleanArrayGetFunc getarray;
173 PropBooleanArraySetFunc setarray;
176 const int *defaultarray;
177 } BooleanPropertyRNA;
179 typedef struct IntPropertyRNA {
180 PropertyRNA property;
185 PropIntArrayGetFunc getarray;
186 PropIntArraySetFunc setarray;
188 PropIntRangeFunc range;
190 int softmin, softmax;
191 int hardmin, hardmax;
195 const int *defaultarray;
198 typedef struct FloatPropertyRNA {
199 PropertyRNA property;
201 PropFloatGetFunc get;
202 PropFloatSetFunc set;
204 PropFloatArrayGetFunc getarray;
205 PropFloatArraySetFunc setarray;
207 PropFloatRangeFunc range;
209 float softmin, softmax;
210 float hardmin, hardmax;
215 const float *defaultarray;
218 typedef struct StringPropertyRNA {
219 PropertyRNA property;
221 PropStringGetFunc get;
222 PropStringLengthFunc length;
223 PropStringSetFunc set;
225 int maxlength; /* includes string terminator! */
227 const char *defaultvalue;
230 typedef struct EnumPropertyRNA {
231 PropertyRNA property;
235 PropEnumItemFunc itemf;
237 EnumPropertyItem *item;
243 typedef struct PointerPropertyRNA {
244 PropertyRNA property;
246 PropPointerGetFunc get;
247 PropPointerSetFunc set;
248 PropPointerTypeFunc typef;
250 struct StructRNA *type;
251 } PointerPropertyRNA;
253 typedef struct CollectionPropertyRNA {
254 PropertyRNA property;
256 PropCollectionBeginFunc begin;
257 PropCollectionNextFunc next;
258 PropCollectionEndFunc end; /* optional */
259 PropCollectionGetFunc get;
260 PropCollectionLengthFunc length; /* optional */
261 PropCollectionLookupIntFunc lookupint; /* optional */
262 PropCollectionLookupStringFunc lookupstring; /* optional */
264 struct StructRNA *item_type; /* the type of this item */
265 } CollectionPropertyRNA;
268 /* changes to this struct require updating rna_generate_struct in makesrna.c */
270 /* structs are containers of properties */
273 /* python type, this is a subtype of pyrna_struct_Type but used so each struct can have its own type
274 * which is useful for subclassing RNA */
278 /* unique identifier */
279 const char *identifier;
280 /* various options */
283 /* user readable name */
285 /* single line description, displayed in the tooltip for example */
286 const char *description;
290 /* property that defines the name */
291 PropertyRNA *nameproperty;
293 /* property to iterate over properties */
294 PropertyRNA *iteratorproperty;
296 /* struct this is derivedfrom */
297 struct StructRNA *base;
299 /* only use for nested structs, where both the parent and child access
300 * the same C Struct but nesting is used for grouping properties.
301 * The parent property is used so we know NULL checks are not needed,
302 * and that this struct will never exist without its parent */
303 struct StructRNA *nested;
305 /* function to give the more specific type */
306 StructRefineFunc refine;
308 /* function to find path to this struct in an ID */
311 /* function to register/unregister subclasses */
312 StructRegisterFunc reg;
313 StructUnregisterFunc unreg;
315 /* callback to get id properties */
316 IDPropertiesFunc idproperties;
318 /* functions of this struct */
324 * Root RNA data structure that lists all struct types. */
330 #endif /* RNA_INTERNAL_TYPES */