RNA
[blender.git] / source / blender / makesrna / intern / rna_main.c
1 /**
2  * $Id$
3  *
4  * ***** BEGIN GPL LICENSE BLOCK *****
5  *
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.
10  *
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.
15  *
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.
19  *
20  * Contributor(s): Blender Foundation (2008).
21  *
22  * ***** END GPL LICENSE BLOCK *****
23  */
24
25 #include <stdlib.h>
26 #include <string.h>
27
28 #include "RNA_define.h"
29 #include "RNA_types.h"
30
31 #ifdef RNA_RUNTIME
32
33 #include "BKE_main.h"
34
35 /* all the list begin functions are added manually here, Main is not in SDNA */
36
37 static void rna_Main_scene_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
38 {
39         Main *bmain= (Main*)ptr->data;
40         rna_iterator_listbase_begin(iter, &bmain->scene);
41 }
42
43 static void rna_Main_object_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
44 {
45         Main *bmain= (Main*)ptr->data;
46         rna_iterator_listbase_begin(iter, &bmain->object);
47 }
48
49 #if 0
50 static void rna_Main_library_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
51 {
52         Main *bmain= (Main*)ptr->data;
53         rna_iterator_listbase_begin(iter, &bmain->library);
54 }
55 #endif
56
57 static void rna_Main_mesh_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
58 {
59         Main *bmain= (Main*)ptr->data;
60         rna_iterator_listbase_begin(iter, &bmain->mesh);
61 }
62
63 #if 0
64 static void rna_Main_curve_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
65 {
66         Main *bmain= (Main*)ptr->data;
67         rna_iterator_listbase_begin(iter, &bmain->curve);
68 }
69
70 static void rna_Main_mball_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
71 {
72         Main *bmain= (Main*)ptr->data;
73         rna_iterator_listbase_begin(iter, &bmain->mball);
74 }
75
76 static void rna_Main_mat_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
77 {
78         Main *bmain= (Main*)ptr->data;
79         rna_iterator_listbase_begin(iter, &bmain->mat);
80 }
81
82 static void rna_Main_tex_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
83 {
84         Main *bmain= (Main*)ptr->data;
85         rna_iterator_listbase_begin(iter, &bmain->tex);
86 }
87
88 static void rna_Main_image_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
89 {
90         Main *bmain= (Main*)ptr->data;
91         rna_iterator_listbase_begin(iter, &bmain->image);
92 }
93
94 static void rna_Main_latt_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
95 {
96         Main *bmain= (Main*)ptr->data;
97         rna_iterator_listbase_begin(iter, &bmain->latt);
98 }
99
100 static void rna_Main_lamp_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
101 {
102         Main *bmain= (Main*)ptr->data;
103         rna_iterator_listbase_begin(iter, &bmain->lamp);
104 }
105
106 static void rna_Main_camera_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
107 {
108         Main *bmain= (Main*)ptr->data;
109         rna_iterator_listbase_begin(iter, &bmain->camera);
110 }
111
112 static void rna_Main_ipo_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
113 {
114         Main *bmain= (Main*)ptr->data;
115         rna_iterator_listbase_begin(iter, &bmain->ipo);
116 }
117
118 static void rna_Main_key_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
119 {
120         Main *bmain= (Main*)ptr->data;
121         rna_iterator_listbase_begin(iter, &bmain->key);
122 }
123
124 static void rna_Main_world_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
125 {
126         Main *bmain= (Main*)ptr->data;
127         rna_iterator_listbase_begin(iter, &bmain->world);
128 }
129
130 static void rna_Main_screen_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
131 {
132         Main *bmain= (Main*)ptr->data;
133         rna_iterator_listbase_begin(iter, &bmain->screen);
134 }
135
136 static void rna_Main_script_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
137 {
138         Main *bmain= (Main*)ptr->data;
139         rna_iterator_listbase_begin(iter, &bmain->script);
140 }
141
142 static void rna_Main_vfont_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
143 {
144         Main *bmain= (Main*)ptr->data;
145         rna_iterator_listbase_begin(iter, &bmain->vfont);
146 }
147
148 static void rna_Main_text_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
149 {
150         Main *bmain= (Main*)ptr->data;
151         rna_iterator_listbase_begin(iter, &bmain->text);
152 }
153
154 static void rna_Main_sound_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
155 {
156         Main *bmain= (Main*)ptr->data;
157         rna_iterator_listbase_begin(iter, &bmain->sound);
158 }
159
160 static void rna_Main_group_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
161 {
162         Main *bmain= (Main*)ptr->data;
163         rna_iterator_listbase_begin(iter, &bmain->group);
164 }
165
166 static void rna_Main_armature_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
167 {
168         Main *bmain= (Main*)ptr->data;
169         rna_iterator_listbase_begin(iter, &bmain->armature);
170 }
171
172 static void rna_Main_action_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
173 {
174         Main *bmain= (Main*)ptr->data;
175         rna_iterator_listbase_begin(iter, &bmain->action);
176 }
177
178 static void rna_Main_nodetree_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
179 {
180         Main *bmain= (Main*)ptr->data;
181         rna_iterator_listbase_begin(iter, &bmain->nodetree);
182 }
183
184 static void rna_Main_brush_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
185 {
186         Main *bmain= (Main*)ptr->data;
187         rna_iterator_listbase_begin(iter, &bmain->brush);
188 }
189
190 static void rna_Main_particle_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
191 {
192         Main *bmain= (Main*)ptr->data;
193         rna_iterator_listbase_begin(iter, &bmain->particle);
194 }
195
196 static void rna_Main_wm_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
197 {
198         Main *bmain= (Main*)ptr->data;
199         rna_iterator_listbase_begin(iter, &bmain->wm);
200 }
201 #endif
202
203 #else
204
205 void RNA_def_main(BlenderRNA *brna)
206 {
207         StructRNA *srna;
208         PropertyRNA *prop;
209         const char *lists[][5]= {
210                 {"scenes", "Scene", "rna_Main_scene_begin", "Scenes", "Scene datablocks."},
211                 {"objects", "Object", "rna_Main_object_begin", "Objects", "Object datablocks."},
212                 {"meshes", "Mesh", "rna_Main_mesh_begin", "Meshes", "Mesh datablocks."}, 
213                 {NULL, NULL, NULL, NULL, NULL},
214                 {"libraries", "Library", "rna_Main_library_begin", "Libraries", "Library datablocks."},
215                 {"curves", "Curve", "rna_Main_curve_begin", "Curves", "Curve datablocks."}, 
216                 {"metaballs", "MBall", "rna_Main_mball_begin", "Metaballs", "Metaball datablocks."}, 
217                 {"materials", "Material", "rna_Main_mat_begin", "Materials", "Material datablocks."},
218                 {"textures", "Texture", "rna_Main_tex_begin", "Textures", "Texture datablocks."},
219                 {"images", "Image", "rna_Main_image_begin", "Images", "Image datablocks."},
220                 {"lattices", "Lattice", "rna_Main_latt_begin", "Lattices", "Lattice datablocks."},
221                 {"lamps", "Lamp", "rna_Main_lamp_begin", "Lamps", "Lamp datablocks."},
222                 {"cameras", "Camera", "rna_Main_camera_begin", "Cameras", "Camera datablocks."},
223                 {"ipos", "Ipo", "rna_Main_ipo_begin", "Ipos", "Ipo datablocks."},
224                 {"keys", "Key", "rna_Main_key_begin", "Keys", "Key datablocks."},
225                 {"worlds", "World", "rna_Main_world_begin", "Worlds", "World datablocks."},
226                 {"screens", "Screen", "rna_Main_screen_begin", "Screens", "Screen datablocks."},
227                 {"scripts", "Script", "rna_Main_script_begin", "Scripts", "Script datablocks."},
228                 {"vfonts", "VFont", "rna_Main_vfont_begin", "VFonts", "VFont datablocks."},
229                 {"texts", "Text", "rna_Main_text_begin", "Texts", "Text datablocks."},
230                 {"sounds", "Sound", "rna_Main_sound_begin", "Sounds", "Sound datablocks."},
231                 {"groups", "Group", "rna_Main_group_begin", "Groups", "Group datablocks."},
232                 {"armatures", "Armature", "rna_Main_armature_begin", "Armatures", "Armature datablocks."},
233                 {"actions", "Action", "rna_Main_action_begin", "Actions", "Action datablocks."},
234                 {"nodegroups", "NodeGroup", "rna_Main_nodetree_begin", "Node Groups", "Node group datablocks."},
235                 {"brushes", "Brush", "rna_Main_brush_begin", "Brushes", "Brush datablocks."},
236                 {"particles", "Particle", "rna_Main_particle_begin", "Particles", "Particle datablocks."},
237                 {"windowmanagers", "wmWindowManager", "rna_Main_wm_begin", "Window Managers", "Window manager datablocks."},
238                 {NULL, NULL, NULL, NULL, NULL}};
239         int i;
240         
241         srna= RNA_def_struct(brna, "Main", "Main");
242
243         for(i=0; lists[i][0]; i++)
244         {
245                 prop= RNA_def_property(srna, lists[i][0], PROP_COLLECTION, PROP_NONE);
246                 RNA_def_property_struct_type(prop, lists[i][1]);
247                 RNA_def_property_collection_funcs(prop, lists[i][2], "rna_iterator_listbase_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get", 0, 0, 0, 0);
248                 RNA_def_property_ui_text(prop, lists[i][3], lists[i][4]);
249         }
250 }
251
252 #endif
253