]> git.sesse.net Git - vlc/blob - modules/gui/skins2/parser/gen_builder.py
Make Zorglub less unhappy
[vlc] / modules / gui / skins2 / parser / gen_builder.py
1 #!/usr/bin/python
2
3 # Script to generate builder_data.hpp, with the definitions given in
4 # builder_data.def
5 # Each line of the definition file is in the following format:
6 # ClassName param1:type1 param2:type2 ...
7
8 import string
9
10 deffile = open("builder_data.def")
11 hppfile = open("builder_data.hpp","w")
12
13 hppfile.write(
14 """/*****************************************************************************
15  * builder_data.hpp
16  *****************************************************************************
17  * Copyright (C) 2003 the VideoLAN team
18  * $Id$
19  *
20  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
21  *          Olivier Teulière <ipkiss@via.ecp.fr>
22  *
23  * This program is free software; you can redistribute it and/or modify
24  * it under the terms of the GNU General Public License as published by
25  * the Free Software Foundation; either version 2 of the License, or
26  * (at your option) any later version.
27  *
28  * This program is distributed in the hope that it will be useful,
29  * but WITHOUT ANY WARRANTY; without even the implied warranty of
30  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
31  * GNU General Public License for more details.
32  *
33  * You should have received a copy of the GNU General Public License
34  * along with this program; if not, write to the Free Software
35  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
36  *****************************************************************************/
37
38 //File generated by gen_builder.py
39 //DO NOT EDIT BY HAND !
40
41 #ifndef BUILDER_DATA_HPP
42 #define BUILDER_DATA_HPP
43
44 #include <vlc/vlc.h>
45 #include <list>
46 #include <map>
47 #include <string>
48
49 using namespace std;
50
51 /// Structure for mapping data from XML file
52 struct BuilderData
53 {
54
55 """)
56
57 while 1:
58     line = string.strip(deffile.readline())
59     if line == "":
60         break
61     items = string.split(line, ' ')
62     name = items[0]
63     str = "    /// Type definition\n"
64     str += "    struct " + name + "\n    {\n"
65     str += "        " + name + "( "
66     constructor = ""
67     initlist = ""
68     vars = ""
69     for var in items[1:]:
70         vardef = string.split(var, ':');
71         varname = vardef[0]
72         vartype = vardef[1]
73         if vartype == "string":
74             vartype = "const string &"
75         if constructor != "":
76             constructor += ", "
77         constructor += vartype + " " + varname
78         if initlist != "":
79             initlist += ", "
80         initlist += "m_" + varname + "( " + varname + " )"
81         vartype = vardef[1]
82         if vartype == "string":
83             vartype = "const string"
84         vars += "        " + vartype + " m_" + varname + ";\n"
85     str += constructor + " ):\n" + initlist + " {}\n\n"
86     str += vars + "    };\n"
87     str += "    /// List\n"
88     str += "    list<" + name + "> m_list" + name + ";\n"
89     str += "\n"
90     hppfile.write(str)
91
92 hppfile.write(
93 """
94 };
95
96 #endif
97 """)
98
99 deffile.close()
100 hppfile.close()