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 *****
25 /** \file blender/makesrna/intern/rna_internal_types.h
30 #ifndef RNA_INTERNAL_TYPES_H
31 #define RNA_INTERNAL_TYPES_H
33 #include "DNA_listBase.h"
42 struct CollectionPropertyIterator;
51 #define RNA_MAX_ARRAY_LENGTH 64
53 #define RNA_MAX_ARRAY_LENGTH 32
56 #define RNA_MAX_ARRAY_DIMENSION 3
59 /* store local properties here */
60 #define RNA_IDP_UI "_RNA_UI"
62 /* Function Callbacks */
64 typedef void (*UpdateFunc)(struct Main *main, struct Scene *scene, struct PointerRNA *ptr);
65 typedef void (*ContextUpdateFunc)(struct bContext *C, struct PointerRNA *ptr);
66 typedef int (*EditableFunc)(struct PointerRNA *ptr);
67 typedef int (*ItemEditableFunc)(struct PointerRNA *ptr, int index);
68 typedef struct IDProperty* (*IDPropertiesFunc)(struct PointerRNA *ptr, int create);
69 typedef struct StructRNA *(*StructRefineFunc)(struct PointerRNA *ptr);
70 typedef char *(*StructPathFunc)(struct PointerRNA *ptr);
72 typedef int (*PropArrayLengthGetFunc)(struct PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION]);
73 typedef int (*PropBooleanGetFunc)(struct PointerRNA *ptr);
74 typedef void (*PropBooleanSetFunc)(struct PointerRNA *ptr, int value);
75 typedef void (*PropBooleanArrayGetFunc)(struct PointerRNA *ptr, int *values);
76 typedef void (*PropBooleanArraySetFunc)(struct PointerRNA *ptr, const int *values);
77 typedef int (*PropIntGetFunc)(struct PointerRNA *ptr);
78 typedef void (*PropIntSetFunc)(struct PointerRNA *ptr, int value);
79 typedef void (*PropIntArrayGetFunc)(struct PointerRNA *ptr, int *values);
80 typedef void (*PropIntArraySetFunc)(struct PointerRNA *ptr, const int *values);
81 typedef void (*PropIntRangeFunc)(struct PointerRNA *ptr, int *min, int *max);
82 typedef float (*PropFloatGetFunc)(struct PointerRNA *ptr);
83 typedef void (*PropFloatSetFunc)(struct PointerRNA *ptr, float value);
84 typedef void (*PropFloatArrayGetFunc)(struct PointerRNA *ptr, float *values);
85 typedef void (*PropFloatArraySetFunc)(struct PointerRNA *ptr, const float *values);
86 typedef void (*PropFloatRangeFunc)(struct PointerRNA *ptr, float *min, float *max);
87 typedef void (*PropStringGetFunc)(struct PointerRNA *ptr, char *value);
88 typedef int (*PropStringLengthFunc)(struct PointerRNA *ptr);
89 typedef void (*PropStringSetFunc)(struct PointerRNA *ptr, const char *value);
90 typedef int (*PropEnumGetFunc)(struct PointerRNA *ptr);
91 typedef void (*PropEnumSetFunc)(struct PointerRNA *ptr, int value);
92 typedef EnumPropertyItem *(*PropEnumItemFunc)(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, int *free);
93 typedef PointerRNA (*PropPointerGetFunc)(struct PointerRNA *ptr);
94 typedef StructRNA* (*PropPointerTypeFunc)(struct PointerRNA *ptr);
95 typedef void (*PropPointerSetFunc)(struct PointerRNA *ptr, const PointerRNA value);
96 typedef int (*PropPointerPollFunc)(struct PointerRNA *ptr, const PointerRNA value);
97 typedef void (*PropCollectionBeginFunc)(struct CollectionPropertyIterator *iter, struct PointerRNA *ptr);
98 typedef void (*PropCollectionNextFunc)(struct CollectionPropertyIterator *iter);
99 typedef void (*PropCollectionEndFunc)(struct CollectionPropertyIterator *iter);
100 typedef PointerRNA (*PropCollectionGetFunc)(struct CollectionPropertyIterator *iter);
101 typedef int (*PropCollectionLengthFunc)(struct PointerRNA *ptr);
102 typedef int (*PropCollectionLookupIntFunc)(struct PointerRNA *ptr, int key, struct PointerRNA *r_ptr);
103 typedef int (*PropCollectionLookupStringFunc)(struct PointerRNA *ptr, const char *key, struct PointerRNA *r_ptr);
105 /* Container - generic abstracted container of RNA properties */
106 typedef struct ContainerRNA {
109 struct GHash *prophash;
114 /* structs are containers of properties */
117 /* unique identifier, keep after 'cont' */
118 const char *identifier;
119 /* various options */
122 /* single line description, displayed in the tooltip for example */
123 const char *description;
125 /* callback to execute the function */
128 /* parameter for the return value
129 * note: this is only the C return value, rna functions can have multiple return values */
134 struct PropertyRNA *next, *prev;
136 /* magic bytes to distinguish with IDProperty */
139 /* unique identifier */
140 const char *identifier;
141 /* various options */
144 /* user readable name */
146 /* single line description, displayed in the tooltip for example */
147 const char *description;
151 /* property type as it appears to the outside */
153 /* subtype, 'interpretation' of the property */
154 PropertySubType subtype;
155 /* if non-NULL, overrides arraylength. Must not return 0? */
156 PropArrayLengthGetFunc getlength;
157 /* dimension of array */
158 unsigned int arraydimension;
159 /* array lengths lengths for all dimensions (when arraydimension > 0) */
160 unsigned int arraylength[RNA_MAX_ARRAY_DIMENSION];
161 unsigned int totarraylength;
163 /* callback for updates on change */
167 /* callback for testing if editable */
168 EditableFunc editable;
169 /* callback for testing if array-item editable (if applicable) */
170 ItemEditableFunc itemeditable;
174 RawPropertyType rawtype;
176 /* This is used for accessing props/functions of this property
177 * any property can have this but should only be used for collections and arrays
178 * since python will convert int/bool/pointer's */
179 struct StructRNA *srna; /* attributes attached directly to this collection */
184 typedef struct BooleanPropertyRNA {
185 PropertyRNA property;
187 PropBooleanGetFunc get;
188 PropBooleanSetFunc set;
190 PropBooleanArrayGetFunc getarray;
191 PropBooleanArraySetFunc setarray;
194 const int *defaultarray;
195 } BooleanPropertyRNA;
197 typedef struct IntPropertyRNA {
198 PropertyRNA property;
203 PropIntArrayGetFunc getarray;
204 PropIntArraySetFunc setarray;
206 PropIntRangeFunc range;
208 int softmin, softmax;
209 int hardmin, hardmax;
213 const int *defaultarray;
216 typedef struct FloatPropertyRNA {
217 PropertyRNA property;
219 PropFloatGetFunc get;
220 PropFloatSetFunc set;
222 PropFloatArrayGetFunc getarray;
223 PropFloatArraySetFunc setarray;
225 PropFloatRangeFunc range;
227 float softmin, softmax;
228 float hardmin, hardmax;
233 const float *defaultarray;
236 typedef struct StringPropertyRNA {
237 PropertyRNA property;
239 PropStringGetFunc get;
240 PropStringLengthFunc length;
241 PropStringSetFunc set;
243 int maxlength; /* includes string terminator! */
245 const char *defaultvalue;
248 typedef struct EnumPropertyRNA {
249 PropertyRNA property;
253 PropEnumItemFunc itemf;
255 EnumPropertyItem *item;
261 typedef struct PointerPropertyRNA {
262 PropertyRNA property;
264 PropPointerGetFunc get;
265 PropPointerSetFunc set;
266 PropPointerTypeFunc typef;
267 PropPointerPollFunc poll; /* unlike operators, 'set' can still run if poll fails, used for filtering display */
269 struct StructRNA *type;
270 } PointerPropertyRNA;
272 typedef struct CollectionPropertyRNA {
273 PropertyRNA property;
275 PropCollectionBeginFunc begin;
276 PropCollectionNextFunc next;
277 PropCollectionEndFunc end; /* optional */
278 PropCollectionGetFunc get;
279 PropCollectionLengthFunc length; /* optional */
280 PropCollectionLookupIntFunc lookupint; /* optional */
281 PropCollectionLookupStringFunc lookupstring; /* optional */
283 struct StructRNA *item_type; /* the type of this item */
284 } CollectionPropertyRNA;
287 /* changes to this struct require updating rna_generate_struct in makesrna.c */
289 /* structs are containers of properties */
292 /* unique identifier, keep after 'cont' */
293 const char *identifier;
295 /* python type, this is a subtype of pyrna_struct_Type but used so each struct can have its own type
296 * which is useful for subclassing RNA */
300 /* various options */
303 /* user readable name */
305 /* single line description, displayed in the tooltip for example */
306 const char *description;
310 /* property that defines the name */
311 PropertyRNA *nameproperty;
313 /* property to iterate over properties */
314 PropertyRNA *iteratorproperty;
316 /* struct this is derivedfrom */
317 struct StructRNA *base;
319 /* only use for nested structs, where both the parent and child access
320 * the same C Struct but nesting is used for grouping properties.
321 * The parent property is used so we know NULL checks are not needed,
322 * and that this struct will never exist without its parent */
323 struct StructRNA *nested;
325 /* function to give the more specific type */
326 StructRefineFunc refine;
328 /* function to find path to this struct in an ID */
331 /* function to register/unregister subclasses */
332 StructRegisterFunc reg;
333 StructUnregisterFunc unreg;
334 StructInstanceFunc instance;
336 /* callback to get id properties */
337 IDPropertiesFunc idproperties;
339 /* functions of this struct */
345 * Root RNA data structure that lists all struct types. */
351 #define CONTAINER_RNA_ID(cont) (*(const char **)(((ContainerRNA *)(cont))+1))
353 #endif /* RNA_INTERNAL_TYPES_H */