Blender V2.61 - r43446

rna_internal.h

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