Blender  V2.59
rna_internal.h
Go to the documentation of this file.
00001 /*
00002  * $Id: rna_internal.h 39084 2011-08-05 20:45:26Z blendix $
00003  *
00004  * ***** BEGIN GPL LICENSE BLOCK *****
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software Foundation,
00018  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019  *
00020  * Contributor(s): Blender Foundation (2008).
00021  *
00022  * ***** END GPL LICENSE BLOCK *****
00023  */
00024 
00030 #ifndef RNA_INTERNAL_H
00031 #define RNA_INTERNAL_H
00032 
00033 #include "UI_resources.h"
00034 
00035 #include "rna_internal_types.h"
00036 
00037 #define RNA_MAGIC ((int)~0)
00038 
00039 struct ID;
00040 struct IDProperty;
00041 struct SDNA;
00042 struct Sequence;
00043 
00044 /* Data structures used during define */
00045 
00046 typedef struct ContainerDefRNA {
00047         void *next, *prev;
00048 
00049         ContainerRNA *cont;
00050         ListBase properties;
00051 } ContainerDefRNA;
00052 
00053 typedef struct FunctionDefRNA {
00054         ContainerDefRNA cont;
00055 
00056         FunctionRNA *func;
00057         const char *srna;
00058         const char *call;
00059         const char *gencall;
00060 } FunctionDefRNA;
00061 
00062 typedef struct PropertyDefRNA {
00063         struct PropertyDefRNA *next, *prev;
00064 
00065         struct ContainerRNA *cont;
00066         struct PropertyRNA *prop;
00067 
00068         /* struct */
00069         const char *dnastructname;
00070         const char *dnastructfromname;
00071         const char *dnastructfromprop;
00072 
00073         /* property */
00074         const char *dnaname;
00075         const char *dnatype;
00076         int dnaarraylength;
00077         int dnapointerlevel;
00078 
00079         /* for finding length of array collections */
00080         const char *dnalengthstructname;
00081         const char *dnalengthname;
00082         int dnalengthfixed;
00083 
00084         int booleanbit, booleannegative;
00085 
00086         /* not to be confused with PROP_ENUM_FLAG
00087          * this only allows one of the flags to be set at a time, clearing all others */
00088         int enumbitflags;
00089 } PropertyDefRNA;
00090 
00091 typedef struct StructDefRNA {
00092         ContainerDefRNA cont;
00093 
00094         struct StructRNA *srna;
00095         const char *filename;
00096 
00097         const char *dnaname;
00098 
00099         /* for derived structs to find data in some property */
00100         const char *dnafromname;
00101         const char *dnafromprop;
00102 
00103         ListBase functions;
00104 } StructDefRNA;
00105 
00106 typedef struct AllocDefRNA {
00107         struct AllocDefRNA *next, *prev;
00108         void *mem;
00109 } AllocDefRNA;
00110 
00111 typedef struct BlenderDefRNA {
00112         struct SDNA *sdna;
00113         ListBase structs;
00114         ListBase allocs;
00115         struct StructRNA *laststruct;
00116         int error, silent, preprocess, verify;
00117 } BlenderDefRNA;
00118 
00119 extern BlenderDefRNA DefRNA;
00120 
00121 /* Define functions for all types */
00122 
00123 extern BlenderRNA BLENDER_RNA;
00124 
00125 void RNA_def_ID(struct BlenderRNA *brna);
00126 void RNA_def_action(struct BlenderRNA *brna);
00127 void RNA_def_animation(struct BlenderRNA *brna);
00128 void RNA_def_animviz(struct BlenderRNA *brna);
00129 void RNA_def_armature(struct BlenderRNA *brna);
00130 void RNA_def_actuator(struct BlenderRNA *brna);
00131 void RNA_def_boid(struct BlenderRNA *brna);
00132 void RNA_def_brush(struct BlenderRNA *brna);
00133 void RNA_def_brushclone(struct BlenderRNA *brna);
00134 void RNA_def_camera(struct BlenderRNA *brna);
00135 void RNA_def_cloth(struct BlenderRNA *brna);
00136 void RNA_def_color(struct BlenderRNA *brna);
00137 void RNA_def_constraint(struct BlenderRNA *brna);
00138 void RNA_def_context(struct BlenderRNA *brna);
00139 void RNA_def_controller(struct BlenderRNA *brna);
00140 void RNA_def_curve(struct BlenderRNA *brna);
00141 void RNA_def_fluidsim(struct BlenderRNA *brna);
00142 void RNA_def_fcurve(struct BlenderRNA *brna);
00143 void RNA_def_gameproperty(struct BlenderRNA *brna);
00144 void RNA_def_gpencil(struct BlenderRNA *brna);
00145 void RNA_def_group(struct BlenderRNA *brna);
00146 void RNA_def_image(struct BlenderRNA *brna);
00147 void RNA_def_key(struct BlenderRNA *brna);
00148 void RNA_def_lamp(struct BlenderRNA *brna);
00149 void RNA_def_lattice(struct BlenderRNA *brna);
00150 void RNA_def_main(struct BlenderRNA *brna);
00151 void RNA_def_material(struct BlenderRNA *brna);
00152 void RNA_def_mesh(struct BlenderRNA *brna);
00153 void RNA_def_meta(struct BlenderRNA *brna);
00154 void RNA_def_modifier(struct BlenderRNA *brna);
00155 void RNA_def_nla(struct BlenderRNA *brna);
00156 void RNA_def_nodetree(struct BlenderRNA *brna);
00157 void RNA_def_object(struct BlenderRNA *brna);
00158 void RNA_def_object_force(struct BlenderRNA *brna);
00159 void RNA_def_packedfile(struct BlenderRNA *brna);
00160 void RNA_def_particle(struct BlenderRNA *brna);
00161 void RNA_def_pose(struct BlenderRNA *brna);
00162 void RNA_def_render(struct BlenderRNA *brna);
00163 void RNA_def_rna(struct BlenderRNA *brna);
00164 void RNA_def_scene(struct BlenderRNA *brna);
00165 void RNA_def_screen(struct BlenderRNA *brna);
00166 void RNA_def_sculpt_paint(struct BlenderRNA *brna);
00167 void RNA_def_sensor(struct BlenderRNA *brna);
00168 void RNA_def_sequencer(struct BlenderRNA *brna);
00169 void RNA_def_smoke(struct BlenderRNA *brna);
00170 void RNA_def_space(struct BlenderRNA *brna);
00171 void RNA_def_test(struct BlenderRNA *brna);
00172 void RNA_def_text(struct BlenderRNA *brna);
00173 void RNA_def_texture(struct BlenderRNA *brna);
00174 void RNA_def_timeline_marker(struct BlenderRNA *brna);
00175 void RNA_def_sound(struct BlenderRNA *brna);
00176 void RNA_def_ui(struct BlenderRNA *brna);
00177 void RNA_def_userdef(struct BlenderRNA *brna);
00178 void RNA_def_vfont(struct BlenderRNA *brna);
00179 void RNA_def_wm(struct BlenderRNA *brna);
00180 void RNA_def_world(struct BlenderRNA *brna);
00181 
00182 /* Common Define functions */
00183 
00184 void rna_def_animdata_common(struct StructRNA *srna);
00185 
00186 void rna_def_animviz_common(struct StructRNA *srna);
00187 void rna_def_motionpath_common(struct StructRNA *srna);
00188 
00189 void rna_def_texmat_common(struct StructRNA *srna, const char *texspace_editable);
00190 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);
00191 void rna_def_render_layer_common(struct StructRNA *srna, int scene);
00192 
00193 void rna_ID_name_get(struct PointerRNA *ptr, char *value);
00194 int rna_ID_name_length(struct PointerRNA *ptr);
00195 void rna_ID_name_set(struct PointerRNA *ptr, const char *value);
00196 struct StructRNA *rna_ID_refine(struct PointerRNA *ptr);
00197 struct IDProperty *rna_ID_idprops(struct PointerRNA *ptr, int create);
00198 void rna_ID_fake_user_set(struct PointerRNA *ptr, int value);
00199 struct IDProperty *rna_PropertyGroup_idprops(struct PointerRNA *ptr, int create);
00200 void rna_PropertyGroup_unregister(struct Main *bmain, struct StructRNA *type);
00201 struct StructRNA *rna_PropertyGroup_register(struct Main *bmain, struct ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free);
00202 struct StructRNA* rna_PropertyGroup_refine(struct PointerRNA *ptr);
00203 
00204 void rna_object_vgroup_name_index_get(struct PointerRNA *ptr, char *value, int index);
00205 int rna_object_vgroup_name_index_length(struct PointerRNA *ptr, int index);
00206 void rna_object_vgroup_name_index_set(struct PointerRNA *ptr, const char *value, short *index);
00207 void rna_object_vgroup_name_set(struct PointerRNA *ptr, const char *value, char *result, int maxlen);
00208 void rna_object_uvlayer_name_set(struct PointerRNA *ptr, const char *value, char *result, int maxlen);
00209 void rna_object_vcollayer_name_set(struct PointerRNA *ptr, const char *value, char *result, int maxlen);
00210 PointerRNA rna_object_shapekey_index_get(struct ID *id, int value);
00211 int rna_object_shapekey_index_set(struct ID *id, PointerRNA value, int current);
00212 
00213 /* named internal so as not to conflict with obj.update() rna func */
00214 void rna_Object_internal_update_data(struct Main *bmain, struct Scene *scene, struct PointerRNA *ptr);
00215 void rna_Mesh_update_draw(struct Main *bmain, struct Scene *scene, struct PointerRNA *ptr);
00216 void rna_TextureSlot_update(struct Main *bmain, struct Scene *scene, struct PointerRNA *ptr);
00217 
00218 /* basic poll functions for object types */
00219 int rna_Armature_object_poll(struct PointerRNA *ptr, struct PointerRNA value);
00220 int rna_Camera_object_poll(struct PointerRNA *ptr, struct PointerRNA value);
00221 int rna_Curve_object_poll(struct PointerRNA *ptr, struct PointerRNA value);
00222 int rna_Lattice_object_poll(struct PointerRNA *ptr, struct PointerRNA value);
00223 int rna_Mesh_object_poll(struct PointerRNA *ptr, struct PointerRNA value);
00224 
00225 /* basic poll functions for actions (to prevent actions getting set in wrong places) */
00226 int rna_Action_id_poll(struct PointerRNA *ptr, struct PointerRNA value);
00227 int rna_Action_actedit_assign_poll(struct PointerRNA *ptr, struct PointerRNA value);
00228 
00229 char *rna_TextureSlot_path(struct PointerRNA *ptr);
00230 
00231 /* API functions */
00232 
00233 void RNA_api_action(StructRNA *srna);
00234 void RNA_api_armature_edit_bone(StructRNA *srna);
00235 void RNA_api_bone(StructRNA *srna);
00236 void RNA_api_drivers(StructRNA *srna);
00237 void RNA_api_image(struct StructRNA *srna);
00238 void RNA_api_operator(struct StructRNA *srna);
00239 void RNA_api_macro(struct StructRNA *srna);
00240 void RNA_api_keyconfig(struct StructRNA *srna);
00241 void RNA_api_keyconfigs(struct StructRNA *srna);
00242 void RNA_api_keyingset(struct StructRNA *srna);
00243 void RNA_api_keymap(struct StructRNA *srna);
00244 void RNA_api_keymaps(struct StructRNA *srna);
00245 void RNA_api_keymapitem(struct StructRNA *srna);
00246 void RNA_api_keymapitems(struct StructRNA *srna);
00247 void RNA_api_area(struct StructRNA *srna);
00248 void RNA_api_main(struct StructRNA *srna);
00249 void RNA_api_material(StructRNA *srna);
00250 void RNA_api_mesh(struct StructRNA *srna);
00251 void RNA_api_object(struct StructRNA *srna);
00252 void RNA_api_object_base(struct StructRNA *srna);
00253 void RNA_api_pose_channel(struct StructRNA *srna);
00254 void RNA_api_scene(struct StructRNA *srna);
00255 void RNA_api_scene_render(struct StructRNA *srna);
00256 void RNA_api_sequence_strip(StructRNA *srna);
00257 void RNA_api_text(struct StructRNA *srna);
00258 void RNA_api_ui_layout(struct StructRNA *srna);
00259 void RNA_api_wm(struct StructRNA *srna);
00260 void RNA_api_sensor(struct StructRNA *srna);
00261 void RNA_api_controller(struct StructRNA *srna);
00262 void RNA_api_actuator(struct StructRNA *srna);
00263 
00264 /* main collection functions */
00265 void RNA_def_main_cameras(BlenderRNA *brna, PropertyRNA *cprop);
00266 void RNA_def_main_scenes(BlenderRNA *brna, PropertyRNA *cprop);
00267 void RNA_def_main_objects(BlenderRNA *brna, PropertyRNA *cprop);
00268 void RNA_def_main_materials(BlenderRNA *brna, PropertyRNA *cprop);
00269 void RNA_def_main_node_groups(BlenderRNA *brna, PropertyRNA *cprop);
00270 void RNA_def_main_meshes(BlenderRNA *brna, PropertyRNA *cprop);
00271 void RNA_def_main_lamps(BlenderRNA *brna, PropertyRNA *cprop);
00272 void RNA_def_main_libraries(BlenderRNA *brna, PropertyRNA *cprop);
00273 void RNA_def_main_screens(BlenderRNA *brna, PropertyRNA *cprop);
00274 void RNA_def_main_window_managers(BlenderRNA *brna, PropertyRNA *cprop);
00275 void RNA_def_main_images(BlenderRNA *brna, PropertyRNA *cprop);
00276 void RNA_def_main_lattices(BlenderRNA *brna, PropertyRNA *cprop);
00277 void RNA_def_main_curves(BlenderRNA *brna, PropertyRNA *cprop);
00278 void RNA_def_main_metaballs(BlenderRNA *brna, PropertyRNA *cprop);
00279 void RNA_def_main_fonts(BlenderRNA *brna, PropertyRNA *cprop);
00280 void RNA_def_main_textures(BlenderRNA *brna, PropertyRNA *cprop);
00281 void RNA_def_main_brushes(BlenderRNA *brna, PropertyRNA *cprop);
00282 void RNA_def_main_worlds(BlenderRNA *brna, PropertyRNA *cprop);
00283 void RNA_def_main_groups(BlenderRNA *brna, PropertyRNA *cprop);
00284 void RNA_def_main_texts(BlenderRNA *brna, PropertyRNA *cprop);
00285 void RNA_def_main_sounds(BlenderRNA *brna, PropertyRNA *cprop);
00286 void RNA_def_main_armatures(BlenderRNA *brna, PropertyRNA *cprop);
00287 void RNA_def_main_actions(BlenderRNA *brna, PropertyRNA *cprop);
00288 void RNA_def_main_particles(BlenderRNA *brna, PropertyRNA *cprop);
00289 void RNA_def_main_gpencil(BlenderRNA *brna, PropertyRNA *cprop);
00290 
00291 /* ID Properties */
00292 
00293 extern StringPropertyRNA rna_PropertyGroupItem_string;
00294 extern IntPropertyRNA rna_PropertyGroupItem_int;
00295 extern IntPropertyRNA rna_PropertyGroupItem_int_array;
00296 extern FloatPropertyRNA rna_PropertyGroupItem_float;
00297 extern FloatPropertyRNA rna_PropertyGroupItem_float_array;
00298 extern PointerPropertyRNA rna_PropertyGroupItem_group;
00299 extern CollectionPropertyRNA rna_PropertyGroupItem_collection;
00300 extern CollectionPropertyRNA rna_PropertyGroupItem_idp_array;
00301 extern FloatPropertyRNA rna_PropertyGroupItem_double;
00302 extern FloatPropertyRNA rna_PropertyGroupItem_double_array;
00303 
00304 extern StructRNA RNA_PropertyGroupItem;
00305 extern StructRNA RNA_PropertyGroup;
00306 
00307 struct IDProperty *rna_idproperty_check(struct PropertyRNA **prop, struct PointerRNA *ptr);
00308 
00309 /* Builtin Property Callbacks */
00310 
00311 void rna_builtin_properties_begin(struct CollectionPropertyIterator *iter, struct PointerRNA *ptr);
00312 void rna_builtin_properties_next(struct CollectionPropertyIterator *iter);
00313 PointerRNA rna_builtin_properties_get(struct CollectionPropertyIterator *iter);
00314 PointerRNA rna_builtin_type_get(struct PointerRNA *ptr);
00315 int rna_builtin_properties_lookup_string(PointerRNA *ptr, const char *key, PointerRNA *r_ptr);
00316 
00317 /* Iterators */
00318 
00319 typedef int (*IteratorSkipFunc)(struct CollectionPropertyIterator *iter, void *data);
00320 
00321 typedef struct ListBaseIterator {
00322         Link *link;
00323         int flag;
00324         IteratorSkipFunc skip;
00325 } ListBaseIterator;
00326 
00327 void rna_iterator_listbase_begin(struct CollectionPropertyIterator *iter, struct ListBase *lb, IteratorSkipFunc skip);
00328 void rna_iterator_listbase_next(struct CollectionPropertyIterator *iter);
00329 void *rna_iterator_listbase_get(struct CollectionPropertyIterator *iter);
00330 void rna_iterator_listbase_end(struct CollectionPropertyIterator *iter);
00331 PointerRNA rna_listbase_lookup_int(PointerRNA *ptr, StructRNA *type, struct ListBase *lb, int index);
00332 
00333 typedef struct ArrayIterator {
00334         char *ptr;
00335         char *endptr;   /* past the last valid pointer, only for comparisons, ignores skipped values */
00336         void *free_ptr; /* will be free'd if set */
00337         int itemsize;
00338 
00339         /* array length with no skip functins applied, take care not to compare against index from animsys or python indices */
00340         int length;
00341 
00342         /* optional skip function, when set the array as viewed by rna can contain only a subset of the members.
00343          * this changes indices so quick array index lookups are not possible when skip function is used. */
00344         IteratorSkipFunc skip;
00345 } ArrayIterator;
00346 
00347 void rna_iterator_array_begin(struct CollectionPropertyIterator *iter, void *ptr, int itemsize, int length, int free_ptr, IteratorSkipFunc skip);
00348 void rna_iterator_array_next(struct CollectionPropertyIterator *iter);
00349 void *rna_iterator_array_get(struct CollectionPropertyIterator *iter);
00350 void *rna_iterator_array_dereference_get(struct CollectionPropertyIterator *iter);
00351 void rna_iterator_array_end(struct CollectionPropertyIterator *iter);
00352 PointerRNA rna_array_lookup_int(PointerRNA *ptr, StructRNA *type, void *data, int itemsize, int length, int index);
00353 
00354 /* Duplicated code since we can't link in blenlib */
00355 
00356 void rna_addtail(struct ListBase *listbase, void *vlink);
00357 void rna_freelinkN(struct ListBase *listbase, void *vlink);
00358 void rna_freelistN(struct ListBase *listbase);
00359 PropertyDefRNA *rna_findlink(ListBase *listbase, const char *identifier);
00360 
00361 StructDefRNA *rna_find_struct_def(StructRNA *srna);
00362 FunctionDefRNA *rna_find_function_def(FunctionRNA *func);
00363 PropertyDefRNA *rna_find_parameter_def(PropertyRNA *parm);
00364 PropertyDefRNA *rna_find_struct_property_def(StructRNA *srna, PropertyRNA *prop);
00365 
00366 /* Pointer Handling */
00367 
00368 PointerRNA rna_pointer_inherit_refine(struct PointerRNA *ptr, struct StructRNA *type, void *data);
00369 
00370 /* Functions */
00371 
00372 int rna_parameter_size(struct PropertyRNA *parm);
00373 int rna_parameter_size_alloc(struct PropertyRNA *parm);
00374 
00375 // XXX, these should not need to be defined here~!
00376 struct MTex *rna_mtex_texture_slots_add(struct ID *self, struct bContext *C, struct ReportList *reports);
00377 struct MTex *rna_mtex_texture_slots_create(struct ID *self, struct bContext *C, struct ReportList *reports, int index);
00378 void rna_mtex_texture_slots_clear(struct ID *self, struct bContext *C, struct ReportList *reports, int index);
00379 
00380 #endif /* RNA_INTERNAL_H */
00381 
00382