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/intern/rna_internal.h
28 #ifndef RNA_INTERNAL_H
29 #define RNA_INTERNAL_H
31 #include "UI_resources.h"
33 #include "rna_internal_types.h"
35 #define RNA_MAGIC ((int)~0)
42 /* Data structures used during define */
44 typedef struct ContainerDefRNA {
51 typedef struct FunctionDefRNA {
60 typedef struct PropertyDefRNA {
61 struct PropertyDefRNA *next, *prev;
63 struct ContainerRNA *cont;
64 struct PropertyRNA *prop;
67 const char *dnastructname;
68 const char *dnastructfromname;
69 const char *dnastructfromprop;
77 /* for finding length of array collections */
78 const char *dnalengthstructname;
79 const char *dnalengthname;
82 int booleanbit, booleannegative;
84 /* not to be confused with PROP_ENUM_FLAG
85 * this only allows one of the flags to be set at a time, clearing all others */
89 typedef struct StructDefRNA {
92 struct StructRNA *srna;
97 /* for derived structs to find data in some property */
98 const char *dnafromname;
99 const char *dnafromprop;
104 typedef struct AllocDefRNA {
105 struct AllocDefRNA *next, *prev;
109 typedef struct BlenderDefRNA {
113 struct StructRNA *laststruct;
114 int error, silent, preprocess, verify;
117 extern BlenderDefRNA DefRNA;
119 /* Define functions for all types */
121 extern BlenderRNA BLENDER_RNA;
123 void RNA_def_ID(struct BlenderRNA *brna);
124 void RNA_def_action(struct BlenderRNA *brna);
125 void RNA_def_animation(struct BlenderRNA *brna);
126 void RNA_def_animviz(struct BlenderRNA *brna);
127 void RNA_def_armature(struct BlenderRNA *brna);
128 void RNA_def_actuator(struct BlenderRNA *brna);
129 void RNA_def_boid(struct BlenderRNA *brna);
130 void RNA_def_brush(struct BlenderRNA *brna);
131 void RNA_def_brushclone(struct BlenderRNA *brna);
132 void RNA_def_camera(struct BlenderRNA *brna);
133 void RNA_def_cloth(struct BlenderRNA *brna);
134 void RNA_def_color(struct BlenderRNA *brna);
135 void RNA_def_constraint(struct BlenderRNA *brna);
136 void RNA_def_context(struct BlenderRNA *brna);
137 void RNA_def_controller(struct BlenderRNA *brna);
138 void RNA_def_curve(struct BlenderRNA *brna);
139 void RNA_def_dynamic_paint(struct BlenderRNA *brna);
140 void RNA_def_fluidsim(struct BlenderRNA *brna);
141 void RNA_def_fcurve(struct BlenderRNA *brna);
142 void RNA_def_gameproperty(struct BlenderRNA *brna);
143 void RNA_def_gpencil(struct BlenderRNA *brna);
144 void RNA_def_group(struct BlenderRNA *brna);
145 void RNA_def_image(struct BlenderRNA *brna);
146 void RNA_def_key(struct BlenderRNA *brna);
147 void RNA_def_lamp(struct BlenderRNA *brna);
148 void RNA_def_lattice(struct BlenderRNA *brna);
149 void RNA_def_linestyle(struct BlenderRNA *brna);
150 void RNA_def_main(struct BlenderRNA *brna);
151 void RNA_def_material(struct BlenderRNA *brna);
152 void RNA_def_mesh(struct BlenderRNA *brna);
153 void RNA_def_meta(struct BlenderRNA *brna);
154 void RNA_def_modifier(struct BlenderRNA *brna);
155 void RNA_def_nla(struct BlenderRNA *brna);
156 void RNA_def_nodetree(struct BlenderRNA *brna);
157 void RNA_def_object(struct BlenderRNA *brna);
158 void RNA_def_object_force(struct BlenderRNA *brna);
159 void RNA_def_packedfile(struct BlenderRNA *brna);
160 void RNA_def_particle(struct BlenderRNA *brna);
161 void RNA_def_pose(struct BlenderRNA *brna);
162 void RNA_def_render(struct BlenderRNA *brna);
163 void RNA_def_rna(struct BlenderRNA *brna);
164 void RNA_def_scene(struct BlenderRNA *brna);
165 void RNA_def_screen(struct BlenderRNA *brna);
166 void RNA_def_sculpt_paint(struct BlenderRNA *brna);
167 void RNA_def_sensor(struct BlenderRNA *brna);
168 void RNA_def_sequencer(struct BlenderRNA *brna);
169 void RNA_def_smoke(struct BlenderRNA *brna);
170 void RNA_def_space(struct BlenderRNA *brna);
171 void RNA_def_speaker(struct BlenderRNA *brna);
172 void RNA_def_test(struct BlenderRNA *brna);
173 void RNA_def_text(struct BlenderRNA *brna);
174 void RNA_def_texture(struct BlenderRNA *brna);
175 void RNA_def_timeline_marker(struct BlenderRNA *brna);
176 void RNA_def_sound(struct BlenderRNA *brna);
177 void RNA_def_ui(struct BlenderRNA *brna);
178 void RNA_def_userdef(struct BlenderRNA *brna);
179 void RNA_def_vfont(struct BlenderRNA *brna);
180 void RNA_def_wm(struct BlenderRNA *brna);
181 void RNA_def_world(struct BlenderRNA *brna);
182 void RNA_def_movieclip(struct BlenderRNA *brna);
183 void RNA_def_tracking(struct BlenderRNA *brna);
185 /* Common Define functions */
187 void rna_def_animdata_common(struct StructRNA *srna);
189 void rna_def_animviz_common(struct StructRNA *srna);
190 void rna_def_motionpath_common(struct StructRNA *srna);
192 void rna_def_texmat_common(struct StructRNA *srna, const char *texspace_editable);
193 void rna_def_mtex_common(struct BlenderRNA *brna, struct StructRNA *srna, const char *begin, const char *activeget, const char *activeset, const char *activeeditable, const char *structname, const char *structname_slots, const char *update);
194 void rna_def_render_layer_common(struct StructRNA *srna, int scene);
196 void rna_ID_name_get(struct PointerRNA *ptr, char *value);
197 int rna_ID_name_length(struct PointerRNA *ptr);
198 void rna_ID_name_set(struct PointerRNA *ptr, const char *value);
199 struct StructRNA *rna_ID_refine(struct PointerRNA *ptr);
200 struct IDProperty *rna_ID_idprops(struct PointerRNA *ptr, int create);
201 void rna_ID_fake_user_set(struct PointerRNA *ptr, int value);
202 struct IDProperty *rna_PropertyGroup_idprops(struct PointerRNA *ptr, int create);
203 void rna_PropertyGroup_unregister(struct Main *bmain, struct StructRNA *type);
204 struct StructRNA *rna_PropertyGroup_register(struct Main *bmain, struct ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free);
205 struct StructRNA* rna_PropertyGroup_refine(struct PointerRNA *ptr);
207 void rna_object_vgroup_name_index_get(struct PointerRNA *ptr, char *value, int index);
208 int rna_object_vgroup_name_index_length(struct PointerRNA *ptr, int index);
209 void rna_object_vgroup_name_index_set(struct PointerRNA *ptr, const char *value, short *index);
210 void rna_object_vgroup_name_set(struct PointerRNA *ptr, const char *value, char *result, int maxlen);
211 void rna_object_uvlayer_name_set(struct PointerRNA *ptr, const char *value, char *result, int maxlen);
212 void rna_object_vcollayer_name_set(struct PointerRNA *ptr, const char *value, char *result, int maxlen);
213 PointerRNA rna_object_shapekey_index_get(struct ID *id, int value);
214 int rna_object_shapekey_index_set(struct ID *id, PointerRNA value, int current);
216 /* named internal so as not to conflict with obj.update() rna func */
217 void rna_Object_internal_update_data(struct Main *bmain, struct Scene *scene, struct PointerRNA *ptr);
218 void rna_Mesh_update_draw(struct Main *bmain, struct Scene *scene, struct PointerRNA *ptr);
219 void rna_TextureSlot_update(struct Main *bmain, struct Scene *scene, struct PointerRNA *ptr);
221 /* basic poll functions for object types */
222 int rna_Armature_object_poll(struct PointerRNA *ptr, struct PointerRNA value);
223 int rna_Camera_object_poll(struct PointerRNA *ptr, struct PointerRNA value);
224 int rna_Curve_object_poll(struct PointerRNA *ptr, struct PointerRNA value);
225 int rna_Lattice_object_poll(struct PointerRNA *ptr, struct PointerRNA value);
226 int rna_Mesh_object_poll(struct PointerRNA *ptr, struct PointerRNA value);
228 /* basic poll functions for actions (to prevent actions getting set in wrong places) */
229 int rna_Action_id_poll(struct PointerRNA *ptr, struct PointerRNA value);
230 int rna_Action_actedit_assign_poll(struct PointerRNA *ptr, struct PointerRNA value);
232 char *rna_TextureSlot_path(struct PointerRNA *ptr);
236 void RNA_api_action(StructRNA *srna);
237 void RNA_api_armature_edit_bone(StructRNA *srna);
238 void RNA_api_bone(StructRNA *srna);
239 void RNA_api_camera(StructRNA *srna);
240 void RNA_api_drivers(StructRNA *srna);
241 void RNA_api_image(struct StructRNA *srna);
242 void RNA_api_operator(struct StructRNA *srna);
243 void RNA_api_macro(struct StructRNA *srna);
244 void RNA_api_keyconfig(struct StructRNA *srna);
245 void RNA_api_keyconfigs(struct StructRNA *srna);
246 void RNA_api_keyingset(struct StructRNA *srna);
247 void RNA_api_keymap(struct StructRNA *srna);
248 void RNA_api_keymaps(struct StructRNA *srna);
249 void RNA_api_keymapitem(struct StructRNA *srna);
250 void RNA_api_keymapitems(struct StructRNA *srna);
251 void RNA_api_area(struct StructRNA *srna);
252 void RNA_api_main(struct StructRNA *srna);
253 void RNA_api_material(StructRNA *srna);
254 void RNA_api_mesh(struct StructRNA *srna);
255 void RNA_api_object(struct StructRNA *srna);
256 void RNA_api_object_base(struct StructRNA *srna);
257 void RNA_api_pose_channel(struct StructRNA *srna);
258 void RNA_api_scene(struct StructRNA *srna);
259 void RNA_api_scene_render(struct StructRNA *srna);
260 void RNA_api_sequence_strip(StructRNA *srna);
261 void RNA_api_text(struct StructRNA *srna);
262 void RNA_api_ui_layout(struct StructRNA *srna);
263 void RNA_api_wm(struct StructRNA *srna);
264 void RNA_api_sensor(struct StructRNA *srna);
265 void RNA_api_controller(struct StructRNA *srna);
266 void RNA_api_actuator(struct StructRNA *srna);
267 void RNA_api_texture(struct StructRNA *srna);
268 void RNA_api_environment_map(struct StructRNA *srna);
270 /* main collection functions */
271 void RNA_def_main_cameras(BlenderRNA *brna, PropertyRNA *cprop);
272 void RNA_def_main_scenes(BlenderRNA *brna, PropertyRNA *cprop);
273 void RNA_def_main_objects(BlenderRNA *brna, PropertyRNA *cprop);
274 void RNA_def_main_materials(BlenderRNA *brna, PropertyRNA *cprop);
275 void RNA_def_main_node_groups(BlenderRNA *brna, PropertyRNA *cprop);
276 void RNA_def_main_meshes(BlenderRNA *brna, PropertyRNA *cprop);
277 void RNA_def_main_lamps(BlenderRNA *brna, PropertyRNA *cprop);
278 void RNA_def_main_libraries(BlenderRNA *brna, PropertyRNA *cprop);
279 void RNA_def_main_screens(BlenderRNA *brna, PropertyRNA *cprop);
280 void RNA_def_main_window_managers(BlenderRNA *brna, PropertyRNA *cprop);
281 void RNA_def_main_images(BlenderRNA *brna, PropertyRNA *cprop);
282 void RNA_def_main_lattices(BlenderRNA *brna, PropertyRNA *cprop);
283 void RNA_def_main_curves(BlenderRNA *brna, PropertyRNA *cprop);
284 void RNA_def_main_metaballs(BlenderRNA *brna, PropertyRNA *cprop);
285 void RNA_def_main_fonts(BlenderRNA *brna, PropertyRNA *cprop);
286 void RNA_def_main_textures(BlenderRNA *brna, PropertyRNA *cprop);
287 void RNA_def_main_brushes(BlenderRNA *brna, PropertyRNA *cprop);
288 void RNA_def_main_worlds(BlenderRNA *brna, PropertyRNA *cprop);
289 void RNA_def_main_groups(BlenderRNA *brna, PropertyRNA *cprop);
290 void RNA_def_main_texts(BlenderRNA *brna, PropertyRNA *cprop);
291 void RNA_def_main_speakers(BlenderRNA *brna, PropertyRNA *cprop);
292 void RNA_def_main_sounds(BlenderRNA *brna, PropertyRNA *cprop);
293 void RNA_def_main_armatures(BlenderRNA *brna, PropertyRNA *cprop);
294 void RNA_def_main_actions(BlenderRNA *brna, PropertyRNA *cprop);
295 void RNA_def_main_particles(BlenderRNA *brna, PropertyRNA *cprop);
296 void RNA_def_main_gpencil(BlenderRNA *brna, PropertyRNA *cprop);
297 void RNA_def_main_movieclips(BlenderRNA *brna, PropertyRNA *cprop);
298 void RNA_def_main_linestyles(BlenderRNA *brna, PropertyRNA *cprop);
302 extern StringPropertyRNA rna_PropertyGroupItem_string;
303 extern IntPropertyRNA rna_PropertyGroupItem_int;
304 extern IntPropertyRNA rna_PropertyGroupItem_int_array;
305 extern FloatPropertyRNA rna_PropertyGroupItem_float;
306 extern FloatPropertyRNA rna_PropertyGroupItem_float_array;
307 extern PointerPropertyRNA rna_PropertyGroupItem_group;
308 extern CollectionPropertyRNA rna_PropertyGroupItem_collection;
309 extern CollectionPropertyRNA rna_PropertyGroupItem_idp_array;
310 extern FloatPropertyRNA rna_PropertyGroupItem_double;
311 extern FloatPropertyRNA rna_PropertyGroupItem_double_array;
313 extern StructRNA RNA_PropertyGroupItem;
314 extern StructRNA RNA_PropertyGroup;
316 struct IDProperty *rna_idproperty_check(struct PropertyRNA **prop, struct PointerRNA *ptr);
318 /* Builtin Property Callbacks */
320 void rna_builtin_properties_begin(struct CollectionPropertyIterator *iter, struct PointerRNA *ptr);
321 void rna_builtin_properties_next(struct CollectionPropertyIterator *iter);
322 PointerRNA rna_builtin_properties_get(struct CollectionPropertyIterator *iter);
323 PointerRNA rna_builtin_type_get(struct PointerRNA *ptr);
324 int rna_builtin_properties_lookup_string(PointerRNA *ptr, const char *key, PointerRNA *r_ptr);
328 typedef int (*IteratorSkipFunc)(struct CollectionPropertyIterator *iter, void *data);
330 typedef struct ListBaseIterator {
333 IteratorSkipFunc skip;
336 void rna_iterator_listbase_begin(struct CollectionPropertyIterator *iter, struct ListBase *lb, IteratorSkipFunc skip);
337 void rna_iterator_listbase_next(struct CollectionPropertyIterator *iter);
338 void *rna_iterator_listbase_get(struct CollectionPropertyIterator *iter);
339 void rna_iterator_listbase_end(struct CollectionPropertyIterator *iter);
340 PointerRNA rna_listbase_lookup_int(PointerRNA *ptr, StructRNA *type, struct ListBase *lb, int index);
342 typedef struct ArrayIterator {
344 char *endptr; /* past the last valid pointer, only for comparisons, ignores skipped values */
345 void *free_ptr; /* will be free'd if set */
348 /* array length with no skip functins applied, take care not to compare against index from animsys or python indices */
351 /* optional skip function, when set the array as viewed by rna can contain only a subset of the members.
352 * this changes indices so quick array index lookups are not possible when skip function is used. */
353 IteratorSkipFunc skip;
356 void rna_iterator_array_begin(struct CollectionPropertyIterator *iter, void *ptr, int itemsize, int length, int free_ptr, IteratorSkipFunc skip);
357 void rna_iterator_array_next(struct CollectionPropertyIterator *iter);
358 void *rna_iterator_array_get(struct CollectionPropertyIterator *iter);
359 void *rna_iterator_array_dereference_get(struct CollectionPropertyIterator *iter);
360 void rna_iterator_array_end(struct CollectionPropertyIterator *iter);
361 PointerRNA rna_array_lookup_int(PointerRNA *ptr, StructRNA *type, void *data, int itemsize, int length, int index);
363 /* Duplicated code since we can't link in blenlib */
365 void rna_addtail(struct ListBase *listbase, void *vlink);
366 void rna_freelinkN(struct ListBase *listbase, void *vlink);
367 void rna_freelistN(struct ListBase *listbase);
368 PropertyDefRNA *rna_findlink(ListBase *listbase, const char *identifier);
370 StructDefRNA *rna_find_struct_def(StructRNA *srna);
371 FunctionDefRNA *rna_find_function_def(FunctionRNA *func);
372 PropertyDefRNA *rna_find_parameter_def(PropertyRNA *parm);
373 PropertyDefRNA *rna_find_struct_property_def(StructRNA *srna, PropertyRNA *prop);
375 /* Pointer Handling */
377 PointerRNA rna_pointer_inherit_refine(struct PointerRNA *ptr, struct StructRNA *type, void *data);
381 int rna_parameter_size(struct PropertyRNA *parm);
382 int rna_parameter_size_alloc(struct PropertyRNA *parm);
384 // XXX, these should not need to be defined here~!
385 struct MTex *rna_mtex_texture_slots_add(struct ID *self, struct bContext *C, struct ReportList *reports);
386 struct MTex *rna_mtex_texture_slots_create(struct ID *self, struct bContext *C, struct ReportList *reports, int index);
387 void rna_mtex_texture_slots_clear(struct ID *self, struct bContext *C, struct ReportList *reports, int index);
390 int rna_IDMaterials_assign_int(struct PointerRNA *ptr, int key, const struct PointerRNA *assign_ptr);
392 #endif /* RNA_INTERNAL_H */