##// END OF EJS Templates
- removed phonon temporarily...
florianlink -
r11:27e624e0d6f1
parent child
Show More
@@ -0,0 +1,1
1 qmake -tp vc -r PythonQt.pro
@@ -1,4 +1,4
1 TEMPLATE = subdirs
1 TEMPLATE = subdirs
2
2
3 CONFIG += ordered
3 CONFIG += ordered
4 SUBDIRS = src extensions tests examples
4 SUBDIRS = generator src extensions tests examples
@@ -1,30 +1,30
1 PythonQt
1 PythonQt
2 --------
2 --------
3
3
4 PythonQt is a dynamic Python (http://www.python.org) binding for Qt (http://www.trolltech.com).
4 PythonQt is a dynamic Python (http://www.python.org) binding for Qt (http://www.trolltech.com).
5 It offers an easy way to embed the Python scripting language into
5 It offers an easy way to embed the Python scripting language into
6 your Qt applications. It makes heavy use of the QMetaObject system and thus requires Qt4.x.
6 your Qt applications. It makes heavy use of the QMetaObject system and thus requires Qt4.x.
7
7
8 Licensing of PythonQt
8 Licensing of PythonQt
9 ---------------------
9 ---------------------
10 PythonQt is distributed under the LGPL license.
10 PythonQt is distributed under the LGPL license.
11
11
12 Licensing of Generator
12 Licensing of Generator
13 ----------------------
13 ----------------------
14 The build system of PythonQt makes use of a patched version of the GPL'ed QtScript generator,
14 The build system of PythonQt makes use of a patched version of the GPL'ed QtScript generator,
15 located in the "generator" directory.
15 located in the "generator" directory.
16
16
17 See http://labs.trolltech.com/page/Projects/QtScript/Generator for details of the original project.
17 See http://labs.trolltech.com/page/Projects/QtScript/Generator for details of the original project.
18
18
19 The PythonQt wrappers generated by the generator are distributed under the LGPL, they are not restriced by the GPL.
19 The PythonQt wrappers generated by the generator are distributed under the LGPL, they are not restriced by the GPL.
20
20
21 The generated wrappers are pre-generated and checked-in for Qt 4.5, so you only need to build and run the
21 The generated wrappers are pre-generated and checked-in for Qt 4.4.3, so you only need to build and run the
22 generator when you want to build additional wrappers or you want to upgrade/downgrade to an newer Qt version.
22 generator when you want to build additional wrappers or you want to upgrade/downgrade to an newer Qt version.
23
23
24 Documentation
24 Documentation
25 -------------
25 -------------
26
26
27 More documentation is available at:
27 More documentation is available at:
28
28
29 http://pythonqt.sourceforge.net/
29 http://pythonqt.sourceforge.net/
30
30
@@ -1,62 +1,62
1 /*
1 /*
2 *
2 *
3 * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
3 * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
4 *
4 *
5 * This library is free software; you can redistribute it and/or
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
8 * version 2.1 of the License, or (at your option) any later version.
9 *
9 *
10 * This library is distributed in the hope that it will be useful,
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
13 * Lesser General Public License for more details.
14 *
14 *
15 * Further, this software is distributed without any warranty that it is
15 * Further, this software is distributed without any warranty that it is
16 * free of the rightful claim of any third person regarding infringement
16 * free of the rightful claim of any third person regarding infringement
17 * or the like. Any license provided herein, whether implied or
17 * or the like. Any license provided herein, whether implied or
18 * otherwise, applies only to this software file. Patent licenses, if
18 * otherwise, applies only to this software file. Patent licenses, if
19 * any, provided herein do not apply to combinations of this program with
19 * any, provided herein do not apply to combinations of this program with
20 * other software, or any other product whatsoever.
20 * other software, or any other product whatsoever.
21 *
21 *
22 * You should have received a copy of the GNU Lesser General Public
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
25 *
26 * Contact information: MeVis Research GmbH, Universitaetsallee 29,
26 * Contact information: MeVis Research GmbH, Universitaetsallee 29,
27 * 28359 Bremen, Germany or:
27 * 28359 Bremen, Germany or:
28 *
28 *
29 * http://www.mevis.de
29 * http://www.mevis.de
30 *
30 *
31 */
31 */
32
32
33 #include "PythonQt_QtAll.h"
33 #include "PythonQt_QtAll.h"
34
34
35 void PythonQt_init_QtGui();
35 void PythonQt_init_QtGui();
36 void PythonQt_init_QtSvg();
36 void PythonQt_init_QtSvg();
37 void PythonQt_init_QtSql();
37 void PythonQt_init_QtSql();
38 void PythonQt_init_QtNetwork();
38 void PythonQt_init_QtNetwork();
39 void PythonQt_init_QtCore();
39 void PythonQt_init_QtCore();
40 void PythonQt_init_QtWebKit();
40 void PythonQt_init_QtWebKit();
41 void PythonQt_init_QtOpenGL();
41 void PythonQt_init_QtOpenGL();
42 void PythonQt_init_QtPhonon();
43 void PythonQt_init_QtXml();
42 void PythonQt_init_QtXml();
44 void PythonQt_init_QtXmlPatterns();
43 void PythonQt_init_QtXmlPatterns();
44 //void PythonQt_init_QtPhonon();
45
45
46 namespace PythonQt_QtAll
46 namespace PythonQt_QtAll
47 {
47 {
48 PYTHONQT_QTALL_EXPORT void init() {
48 PYTHONQT_QTALL_EXPORT void init() {
49 PythonQt_init_QtCore();
49 PythonQt_init_QtCore();
50 PythonQt_init_QtNetwork();
50 PythonQt_init_QtNetwork();
51 PythonQt_init_QtGui();
51 PythonQt_init_QtGui();
52 PythonQt_init_QtXml();
52 PythonQt_init_QtXml();
53 PythonQt_init_QtXmlPatterns();
53 PythonQt_init_QtXmlPatterns();
54 PythonQt_init_QtSvg();
54 PythonQt_init_QtSvg();
55 PythonQt_init_QtSql();
55 PythonQt_init_QtSql();
56 PythonQt_init_QtWebKit();
56 PythonQt_init_QtWebKit();
57 PythonQt_init_QtOpenGL();
57 PythonQt_init_QtOpenGL();
58 PythonQt_init_QtPhonon();
58 // PythonQt_init_QtPhonon();
59 };
59 };
60 };
60 };
61
61
62
62
@@ -1,32 +1,34
1
1
2 TARGET = PythonQt_QtAll
2 TARGET = PythonQt_QtAll
3 TEMPLATE = lib
3 TEMPLATE = lib
4
4
5 DESTDIR = ../../lib
5 DESTDIR = ../../lib
6 DLLDESTDIR = ../../lib
6 DLLDESTDIR = ../../lib
7
7
8 include ( ../../build/common.prf )
8 include ( ../../build/common.prf )
9 include ( ../../build/PythonQt.prf )
9 include ( ../../build/PythonQt.prf )
10
10
11 CONFIG += dll qt
11 CONFIG += dll qt
12
12
13 DEFINES += PYTHONQT_QTALL_EXPORTS
13 DEFINES += PYTHONQT_QTALL_EXPORTS
14
14
15 HEADERS += \
15 HEADERS += \
16 PythonQt_QtAll.h
16 PythonQt_QtAll.h
17
17
18 SOURCES += \
18 SOURCES += \
19 PythonQt_QtAll.cpp
19 PythonQt_QtAll.cpp
20
20
21 QT += webkit gui svg sql network xml xmlpatterns phonon opengl
21 QT += webkit gui svg sql network xml xmlpatterns opengl
22 #QT += phonon
22
23
23 include (../../generated_cpp/com_trolltech_qt_core/com_trolltech_qt_core.pri)
24 include (../../generated_cpp/com_trolltech_qt_core/com_trolltech_qt_core.pri)
24 include (../../generated_cpp/com_trolltech_qt_gui/com_trolltech_qt_gui.pri)
25 include (../../generated_cpp/com_trolltech_qt_gui/com_trolltech_qt_gui.pri)
25 include (../../generated_cpp/com_trolltech_qt_svg/com_trolltech_qt_svg.pri)
26 include (../../generated_cpp/com_trolltech_qt_svg/com_trolltech_qt_svg.pri)
26 include (../../generated_cpp/com_trolltech_qt_sql/com_trolltech_qt_sql.pri)
27 include (../../generated_cpp/com_trolltech_qt_sql/com_trolltech_qt_sql.pri)
27 include (../../generated_cpp/com_trolltech_qt_network/com_trolltech_qt_network.pri)
28 include (../../generated_cpp/com_trolltech_qt_network/com_trolltech_qt_network.pri)
28 include (../../generated_cpp/com_trolltech_qt_opengl/com_trolltech_qt_opengl.pri)
29 include (../../generated_cpp/com_trolltech_qt_opengl/com_trolltech_qt_opengl.pri)
29 include (../../generated_cpp/com_trolltech_qt_phonon/com_trolltech_qt_phonon.pri)
30 include (../../generated_cpp/com_trolltech_qt_webkit/com_trolltech_qt_webkit.pri)
30 include (../../generated_cpp/com_trolltech_qt_webkit/com_trolltech_qt_webkit.pri)
31 include (../../generated_cpp/com_trolltech_qt_xml/com_trolltech_qt_xml.pri)
31 include (../../generated_cpp/com_trolltech_qt_xml/com_trolltech_qt_xml.pri)
32 include (../../generated_cpp/com_trolltech_qt_xmlpatterns/com_trolltech_qt_xmlpatterns.pri)
32 include (../../generated_cpp/com_trolltech_qt_xmlpatterns/com_trolltech_qt_xmlpatterns.pri)
33
34 #include (../../generated_cpp/com_trolltech_qt_phonon/com_trolltech_qt_phonon.pri)
@@ -1,1870 +1,1870
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
3 ** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
4 **
4 **
5 ** This file is part of the Qt Script Generator project on Trolltech Labs.
5 ** This file is part of the Qt Script Generator project on Trolltech Labs.
6 **
6 **
7 ** This file may be used under the terms of the GNU General Public
7 ** This file may be used under the terms of the GNU General Public
8 ** License version 2.0 as published by the Free Software Foundation
8 ** License version 2.0 as published by the Free Software Foundation
9 ** and appearing in the file LICENSE.GPL included in the packaging of
9 ** and appearing in the file LICENSE.GPL included in the packaging of
10 ** this file. Please review the following information to ensure GNU
10 ** this file. Please review the following information to ensure GNU
11 ** General Public Licensing requirements will be met:
11 ** General Public Licensing requirements will be met:
12 ** http://www.trolltech.com/products/qt/opensource.html
12 ** http://www.trolltech.com/products/qt/opensource.html
13 **
13 **
14 ** If you are unsure which license is appropriate for your use, please
14 ** If you are unsure which license is appropriate for your use, please
15 ** review the following information:
15 ** review the following information:
16 ** http://www.trolltech.com/products/qt/licensing.html or contact the
16 ** http://www.trolltech.com/products/qt/licensing.html or contact the
17 ** sales department at sales@trolltech.com.
17 ** sales department at sales@trolltech.com.
18 **
18 **
19 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
19 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
20 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21 **
21 **
22 ****************************************************************************/
22 ****************************************************************************/
23
23
24 #include "classgenerator.h"
24 #include "classgenerator.h"
25 #include "fileout.h"
25 #include "fileout.h"
26
26
27 #include <QtCore/QDir>
27 #include <QtCore/QDir>
28 #include <QtCore/QMetaType>
28 #include <QtCore/QMetaType>
29
29
30 #include <qdebug.h>
30 #include <qdebug.h>
31
31
32 #define GENERATOR_NO_PROTECTED_FUNCTIONS
32 #define GENERATOR_NO_PROTECTED_FUNCTIONS
33
33
34 ClassGenerator::ClassGenerator(PriGenerator *pri, SetupGenerator *setup) :
34 ClassGenerator::ClassGenerator(PriGenerator *pri, SetupGenerator *setup) :
35 priGenerator(pri),
35 priGenerator(pri),
36 setupGenerator(setup)
36 setupGenerator(setup)
37 {}
37 {}
38
38
39 QString ClassGenerator::fileNameForClass(const AbstractMetaClass *meta_class) const
39 QString ClassGenerator::fileNameForClass(const AbstractMetaClass *meta_class) const
40 {
40 {
41 return QString("qtscript_%1.cpp").arg(meta_class->name());
41 return QString("qtscript_%1.cpp").arg(meta_class->name());
42 }
42 }
43
43
44 bool ClassGenerator::shouldGenerate(const AbstractMetaClass *meta_class) const
44 bool ClassGenerator::shouldGenerate(const AbstractMetaClass *meta_class) const
45 {
45 {
46 return false; // DISABLED!
46 return false; // DISABLED!
47 uint cg = meta_class->typeEntry()->codeGeneration();
47 uint cg = meta_class->typeEntry()->codeGeneration();
48 return (cg & TypeEntry::GenerateCode) != 0;
48 return (cg & TypeEntry::GenerateCode) != 0;
49 }
49 }
50
50
51 static QString normalizedType(const AbstractMetaType *type)
51 static QString normalizedType(const AbstractMetaType *type)
52 {
52 {
53 QString str = QString::fromLatin1(QMetaObject::normalizedType(type->cppSignature().toLatin1()));
53 QString str = QString::fromLatin1(QMetaObject::normalizedType(type->cppSignature().toLatin1()));
54 if (str.endsWith(QLatin1Char('&')))
54 if (str.endsWith(QLatin1Char('&')))
55 str.chop(1);
55 str.chop(1);
56 else if (str.startsWith("const ")) {
56 else if (str.startsWith("const ")) {
57 if (str.endsWith('*') || type->hasInstantiations() || type->typeEntry()->isValue())
57 if (str.endsWith('*') || type->hasInstantiations() || type->typeEntry()->isValue())
58 str.remove(0, 6);
58 str.remove(0, 6);
59 }
59 }
60 if (str == QLatin1String("QBool")) // ### hack
60 if (str == QLatin1String("QBool")) // ### hack
61 str = QLatin1String("bool");
61 str = QLatin1String("bool");
62 return str;
62 return str;
63 }
63 }
64
64
65 /*!
65 /*!
66 Returns true if the class \a meta_class inherits from QObject,
66 Returns true if the class \a meta_class inherits from QObject,
67 otherwise returns false.
67 otherwise returns false.
68 */
68 */
69 static bool isQObjectBased(const AbstractMetaClass *meta_class)
69 static bool isQObjectBased(const AbstractMetaClass *meta_class)
70 {
70 {
71 while (meta_class) {
71 while (meta_class) {
72 if (meta_class->name() == QLatin1String("QObject"))
72 if (meta_class->name() == QLatin1String("QObject"))
73 return true;
73 return true;
74 meta_class = meta_class->baseClass();
74 meta_class = meta_class->baseClass();
75 }
75 }
76 return false;
76 return false;
77 }
77 }
78
78
79 /*!
79 /*!
80 Returns true if any of the given \a enums has been declared with
80 Returns true if any of the given \a enums has been declared with
81 Q_ENUMS.
81 Q_ENUMS.
82 */
82 */
83 static bool hasQEnums(const AbstractMetaEnumList &enums)
83 static bool hasQEnums(const AbstractMetaEnumList &enums)
84 {
84 {
85 for (int i = 0; i < enums.size(); ++i) {
85 for (int i = 0; i < enums.size(); ++i) {
86 if (enums.at(i)->hasQEnumsDeclaration())
86 if (enums.at(i)->hasQEnumsDeclaration())
87 return true;
87 return true;
88 }
88 }
89 return false;
89 return false;
90 }
90 }
91
91
92 /*!
92 /*!
93 Returns true if any of the given \a enums has a QFlags class
93 Returns true if any of the given \a enums has a QFlags class
94 associated with it.
94 associated with it.
95 */
95 */
96 static bool hasFlags(const AbstractMetaEnumList &enums)
96 static bool hasFlags(const AbstractMetaEnumList &enums)
97 {
97 {
98 for (int i = 0; i < enums.size(); ++i) {
98 for (int i = 0; i < enums.size(); ++i) {
99 FlagsTypeEntry *flags = enums.at(i)->typeEntry()->flags();
99 FlagsTypeEntry *flags = enums.at(i)->typeEntry()->flags();
100 if (flags)
100 if (flags)
101 return true;
101 return true;
102 }
102 }
103 return false;
103 return false;
104 }
104 }
105
105
106 static bool isSequenceType(const AbstractMetaType *tp)
106 static bool isSequenceType(const AbstractMetaType *tp)
107 {
107 {
108 return tp->isContainer() && (tp->instantiations().size() == 1);
108 return tp->isContainer() && (tp->instantiations().size() == 1);
109 }
109 }
110
110
111 static AbstractMetaFunction *findDefaultConstructor(const AbstractMetaFunctionList &ctors)
111 static AbstractMetaFunction *findDefaultConstructor(const AbstractMetaFunctionList &ctors)
112 {
112 {
113 for (int i = 0; i < ctors.size(); ++i) {
113 for (int i = 0; i < ctors.size(); ++i) {
114 if (ctors.at(i)->actualMinimumArgumentCount() == 0)
114 if (ctors.at(i)->actualMinimumArgumentCount() == 0)
115 return ctors.at(i);
115 return ctors.at(i);
116 }
116 }
117 return 0;
117 return 0;
118 }
118 }
119
119
120 static AbstractMetaFunctionList findConstructors(const AbstractMetaClass *meta_class)
120 static AbstractMetaFunctionList findConstructors(const AbstractMetaClass *meta_class)
121 {
121 {
122 return meta_class->queryFunctions(AbstractMetaClass::Constructors
122 return meta_class->queryFunctions(AbstractMetaClass::Constructors
123 | AbstractMetaClass::WasPublic
123 | AbstractMetaClass::WasPublic
124 | AbstractMetaClass::NotRemovedFromTargetLang);
124 | AbstractMetaClass::NotRemovedFromTargetLang);
125 }
125 }
126
126
127 /*!
127 /*!
128 Returns true if \a meta_class has a default constructor, false
128 Returns true if \a meta_class has a default constructor, false
129 otherwise.
129 otherwise.
130 */
130 */
131 bool hasDefaultConstructor(const AbstractMetaClass *meta_class)
131 bool hasDefaultConstructor(const AbstractMetaClass *meta_class)
132 {
132 {
133 return findDefaultConstructor(findConstructors(meta_class)) != 0;
133 return findDefaultConstructor(findConstructors(meta_class)) != 0;
134 }
134 }
135
135
136 /*!
136 /*!
137 Given the list of \a functions, creates a mapping from # of
137 Given the list of \a functions, creates a mapping from # of
138 arguments to list of functions.
138 arguments to list of functions.
139 */
139 */
140 static QMap<int, AbstractMetaFunctionList> createArgcToFunctionsMap(
140 static QMap<int, AbstractMetaFunctionList> createArgcToFunctionsMap(
141 const AbstractMetaFunctionList &functions)
141 const AbstractMetaFunctionList &functions)
142 {
142 {
143 QMap<int, AbstractMetaFunctionList> result;
143 QMap<int, AbstractMetaFunctionList> result;
144 for (int i = 0; i < functions.size(); ++i) {
144 for (int i = 0; i < functions.size(); ++i) {
145 AbstractMetaFunction *func = functions.at(i);
145 AbstractMetaFunction *func = functions.at(i);
146 int argc = func->arguments().size();
146 int argc = func->arguments().size();
147 for (int k = argc; k > 0; --k) {
147 for (int k = argc; k > 0; --k) {
148 if (func->argumentRemoved(k))
148 if (func->argumentRemoved(k))
149 --argc;
149 --argc;
150 }
150 }
151 for (int j = func->actualMinimumArgumentCount(); j <= argc; ++j)
151 for (int j = func->actualMinimumArgumentCount(); j <= argc; ++j)
152 result[j].append(func);
152 result[j].append(func);
153 }
153 }
154 return result;
154 return result;
155 }
155 }
156
156
157 /*!
157 /*!
158 Returns the name of the QScriptValue function to use to test if
158 Returns the name of the QScriptValue function to use to test if
159 a value is of the given \a typeName, or an empty string if there
159 a value is of the given \a typeName, or an empty string if there
160 is no such function.
160 is no such function.
161 */
161 */
162 static QString builtinTypeTesterFunction(const QString &typeName)
162 static QString builtinTypeTesterFunction(const QString &typeName)
163 {
163 {
164 if (typeName == QLatin1String("QString"))
164 if (typeName == QLatin1String("QString"))
165 return QLatin1String("isString");
165 return QLatin1String("isString");
166 else if (typeName == QLatin1String("double"))
166 else if (typeName == QLatin1String("double"))
167 return QLatin1String("isNumber");
167 return QLatin1String("isNumber");
168 else if (typeName == QLatin1String("float"))
168 else if (typeName == QLatin1String("float"))
169 return QLatin1String("isNumber");
169 return QLatin1String("isNumber");
170 else if (typeName == QLatin1String("int"))
170 else if (typeName == QLatin1String("int"))
171 return QLatin1String("isNumber");
171 return QLatin1String("isNumber");
172 else if (typeName == QLatin1String("uint"))
172 else if (typeName == QLatin1String("uint"))
173 return QLatin1String("isNumber");
173 return QLatin1String("isNumber");
174 else if (typeName == QLatin1String("short"))
174 else if (typeName == QLatin1String("short"))
175 return QLatin1String("isNumber");
175 return QLatin1String("isNumber");
176 else if (typeName == QLatin1String("unsigned short"))
176 else if (typeName == QLatin1String("unsigned short"))
177 return QLatin1String("isNumber");
177 return QLatin1String("isNumber");
178 else if (typeName == QLatin1String("bool"))
178 else if (typeName == QLatin1String("bool"))
179 return QLatin1String("isBoolean");
179 return QLatin1String("isBoolean");
180 else if (typeName == QLatin1String("QVariant"))
180 else if (typeName == QLatin1String("QVariant"))
181 return QLatin1String("isVariant");
181 return QLatin1String("isVariant");
182 // else if (typeName == QLatin1String("QDateTime"))
182 // else if (typeName == QLatin1String("QDateTime"))
183 // return QLatin1String("isDate");
183 // return QLatin1String("isDate");
184 else if (typeName == QLatin1String("QRegExp"))
184 else if (typeName == QLatin1String("QRegExp"))
185 return QLatin1String("isRegExp");
185 return QLatin1String("isRegExp");
186 else if (typeName == QLatin1String("QObject*"))
186 else if (typeName == QLatin1String("QObject*"))
187 return QLatin1String("isQObject");
187 return QLatin1String("isQObject");
188 return QString();
188 return QString();
189 }
189 }
190
190
191 /*!
191 /*!
192 Writes the code injections for the class \a meta_class that should
192 Writes the code injections for the class \a meta_class that should
193 be injected at position \a pos.
193 be injected at position \a pos.
194 */
194 */
195 static void writeInjectedCode(QTextStream &s, const AbstractMetaClass *meta_class,
195 static void writeInjectedCode(QTextStream &s, const AbstractMetaClass *meta_class,
196 CodeSnip::Position pos)
196 CodeSnip::Position pos)
197 {
197 {
198 CodeSnipList code_snips = meta_class->typeEntry()->codeSnips();
198 CodeSnipList code_snips = meta_class->typeEntry()->codeSnips();
199 foreach (const CodeSnip &cs, code_snips) {
199 foreach (const CodeSnip &cs, code_snips) {
200 if ((cs.language == TypeSystem::NativeCode) && (cs.position == pos)) {
200 if ((cs.language == TypeSystem::NativeCode) && (cs.position == pos)) {
201 s << cs.code() << endl;
201 s << cs.code() << endl;
202 }
202 }
203 }
203 }
204 }
204 }
205
205
206 /*!
206 /*!
207 Writes the code injections for the function \a fun of the class \a
207 Writes the code injections for the function \a fun of the class \a
208 meta_class that should be injected at position \a pos.
208 meta_class that should be injected at position \a pos.
209 */
209 */
210 static void writeInjectedCode(QTextStream &s, const AbstractMetaClass *meta_class,
210 static void writeInjectedCode(QTextStream &s, const AbstractMetaClass *meta_class,
211 const AbstractMetaFunction *fun, CodeSnip::Position pos)
211 const AbstractMetaFunction *fun, CodeSnip::Position pos)
212 {
212 {
213 FunctionModificationList mods = fun->modifications(meta_class);
213 FunctionModificationList mods = fun->modifications(meta_class);
214 foreach (const FunctionModification &mod, mods) {
214 foreach (const FunctionModification &mod, mods) {
215 if (!mod.isCodeInjection())
215 if (!mod.isCodeInjection())
216 continue;
216 continue;
217 foreach (const CodeSnip &cs, mod.snips) {
217 foreach (const CodeSnip &cs, mod.snips) {
218 if ((cs.language == TypeSystem::NativeCode) && (cs.position == pos)) {
218 if ((cs.language == TypeSystem::NativeCode) && (cs.position == pos)) {
219 s << cs.code() << endl;
219 s << cs.code() << endl;
220 }
220 }
221 }
221 }
222 }
222 }
223 }
223 }
224
224
225 /*!
225 /*!
226 Writes a boolean expression that checks if the actual arguments are
226 Writes a boolean expression that checks if the actual arguments are
227 compatible with what the function expects. This is used to resolve
227 compatible with what the function expects. This is used to resolve
228 ambiguous calls.
228 ambiguous calls.
229 */
229 */
230 static void writeArgumentTypeTests(QTextStream &stream, const AbstractMetaFunction *fun,
230 static void writeArgumentTypeTests(QTextStream &stream, const AbstractMetaFunction *fun,
231 const AbstractMetaArgumentList &arguments, int argc, int indent)
231 const AbstractMetaArgumentList &arguments, int argc, int indent)
232 {
232 {
233 QString indentStr(indent, QLatin1Char(' '));
233 QString indentStr(indent, QLatin1Char(' '));
234 int j = 0;
234 int j = 0;
235 for (int i = 0; i < argc; ++j) {
235 for (int i = 0; i < argc; ++j) {
236 if (fun->argumentRemoved(j+1))
236 if (fun->argumentRemoved(j+1))
237 continue;
237 continue;
238 if (i > 0)
238 if (i > 0)
239 stream << endl << indentStr << "&& ";
239 stream << endl << indentStr << "&& ";
240 const AbstractMetaType *argType = 0;
240 const AbstractMetaType *argType = 0;
241 QString typeName = fun->typeReplaced(j+1);
241 QString typeName = fun->typeReplaced(j+1);
242 if (typeName.isEmpty()) {
242 if (typeName.isEmpty()) {
243 AbstractMetaArgument *arg = arguments.at(j);
243 AbstractMetaArgument *arg = arguments.at(j);
244 argType = arg->type();
244 argType = arg->type();
245 typeName = normalizedType(argType);
245 typeName = normalizedType(argType);
246 }
246 }
247 QString scriptArg = QString::fromLatin1("context->argument(%0)").arg(i);
247 QString scriptArg = QString::fromLatin1("context->argument(%0)").arg(i);
248 if (argType && isSequenceType(argType)) {
248 if (argType && isSequenceType(argType)) {
249 stream << scriptArg << ".isArray()";
249 stream << scriptArg << ".isArray()";
250 } else if (typeName == "QVariant") {
250 } else if (typeName == "QVariant") {
251 stream << "true";
251 stream << "true";
252 } else {
252 } else {
253 QString tester = builtinTypeTesterFunction(typeName);
253 QString tester = builtinTypeTesterFunction(typeName);
254 if (!tester.isEmpty()) {
254 if (!tester.isEmpty()) {
255 stream << scriptArg << "." << tester << "()";
255 stream << scriptArg << "." << tester << "()";
256 } else if (typeName.endsWith('*')) {
256 } else if (typeName.endsWith('*')) {
257 stream << "qscriptvalue_cast<" << typeName << ">(" << scriptArg << ")";
257 stream << "qscriptvalue_cast<" << typeName << ">(" << scriptArg << ")";
258 } else {
258 } else {
259 // typeid-based test
259 // typeid-based test
260 stream << "(qMetaTypeId<" << typeName;
260 stream << "(qMetaTypeId<" << typeName;
261 if (typeName.endsWith(QLatin1Char('>')))
261 if (typeName.endsWith(QLatin1Char('>')))
262 stream << " ";
262 stream << " ";
263 stream << ">() == " << scriptArg << ".toVariant().userType())";
263 stream << ">() == " << scriptArg << ".toVariant().userType())";
264 }
264 }
265 }
265 }
266 ++i;
266 ++i;
267 }
267 }
268 }
268 }
269
269
270 /*!
270 /*!
271 Returns the name of the QScriptValue function to use to convert a
271 Returns the name of the QScriptValue function to use to convert a
272 value is of the given \a typeName, or an empty string if there is no
272 value is of the given \a typeName, or an empty string if there is no
273 such function.
273 such function.
274 */
274 */
275 static QString builtinConversionFunction(const QString &typeName)
275 static QString builtinConversionFunction(const QString &typeName)
276 {
276 {
277 if (typeName == QLatin1String("QString"))
277 if (typeName == QLatin1String("QString"))
278 return QLatin1String("toString");
278 return QLatin1String("toString");
279 else if (typeName == QLatin1String("double"))
279 else if (typeName == QLatin1String("double"))
280 return QLatin1String("toNumber");
280 return QLatin1String("toNumber");
281 else if (typeName == QLatin1String("int"))
281 else if (typeName == QLatin1String("int"))
282 return QLatin1String("toInt32");
282 return QLatin1String("toInt32");
283 else if (typeName == QLatin1String("uint"))
283 else if (typeName == QLatin1String("uint"))
284 return QLatin1String("toUInt32");
284 return QLatin1String("toUInt32");
285 else if (typeName == QLatin1String("bool"))
285 else if (typeName == QLatin1String("bool"))
286 return QLatin1String("toBoolean");
286 return QLatin1String("toBoolean");
287 else if (typeName == QLatin1String("QVariant"))
287 else if (typeName == QLatin1String("QVariant"))
288 return QLatin1String("toVariant");
288 return QLatin1String("toVariant");
289 else if (typeName == QLatin1String("QDateTime"))
289 else if (typeName == QLatin1String("QDateTime"))
290 return QLatin1String("toDateTime");
290 return QLatin1String("toDateTime");
291 else if (typeName == QLatin1String("QRegExp"))
291 else if (typeName == QLatin1String("QRegExp"))
292 return QLatin1String("toRegExp");
292 return QLatin1String("toRegExp");
293 else if (typeName == QLatin1String("QObject*"))
293 else if (typeName == QLatin1String("QObject*"))
294 return QLatin1String("toQObject");
294 return QLatin1String("toQObject");
295 return QString();
295 return QString();
296 }
296 }
297
297
298 /*!
298 /*!
299 Generates script arguments --> C++ types conversion, in preparation
299 Generates script arguments --> C++ types conversion, in preparation
300 for calling the native function we are binding.
300 for calling the native function we are binding.
301 */
301 */
302 static int writePrepareArguments(QTextStream &stream, const AbstractMetaFunction *fun,
302 static int writePrepareArguments(QTextStream &stream, const AbstractMetaFunction *fun,
303 const AbstractMetaArgumentList &arguments,
303 const AbstractMetaArgumentList &arguments,
304 int scriptArgc, int indent)
304 int scriptArgc, int indent)
305 {
305 {
306 if (arguments.size() == 0) {
306 if (arguments.size() == 0) {
307 Q_ASSERT(scriptArgc == 0);
307 Q_ASSERT(scriptArgc == 0);
308 return 0; // nothing to do
308 return 0; // nothing to do
309 }
309 }
310 QString indentStr(indent, QLatin1Char(' '));
310 QString indentStr(indent, QLatin1Char(' '));
311 int j = 0;
311 int j = 0;
312 for (int scriptArgIndex = 0; j < arguments.size(); ++j) {
312 for (int scriptArgIndex = 0; j < arguments.size(); ++j) {
313 const AbstractMetaArgument *arg = arguments.at(j);
313 const AbstractMetaArgument *arg = arguments.at(j);
314 bool isOptional = !arg->defaultValueExpression().isEmpty();
314 bool isOptional = !arg->defaultValueExpression().isEmpty();
315 if (isOptional && (scriptArgIndex == scriptArgc))
315 if (isOptional && (scriptArgIndex == scriptArgc))
316 break;
316 break;
317 QString conv = fun->conversionRule(TypeSystem::NativeCode, j+1);
317 QString conv = fun->conversionRule(TypeSystem::NativeCode, j+1);
318 QString actualIn = QString::fromLatin1("context->argument(%0)").arg(scriptArgIndex);
318 QString actualIn = QString::fromLatin1("context->argument(%0)").arg(scriptArgIndex);
319 QString actualOut = QString::fromLatin1("_q_arg%0").arg(j);
319 QString actualOut = QString::fromLatin1("_q_arg%0").arg(j);
320 if (!conv.isEmpty()) {
320 if (!conv.isEmpty()) {
321 // custom conversion
321 // custom conversion
322 conv.replace(QString::fromLatin1("%in%"), actualIn);
322 conv.replace(QString::fromLatin1("%in%"), actualIn);
323 conv.replace(QString::fromLatin1("%out%"), actualOut);
323 conv.replace(QString::fromLatin1("%out%"), actualOut);
324 conv.replace(QString::fromLatin1("%this%"), QString::fromLatin1("_q_self"));
324 conv.replace(QString::fromLatin1("%this%"), QString::fromLatin1("_q_self"));
325 stream << conv;
325 stream << conv;
326 } else {
326 } else {
327 const AbstractMetaType *argType = 0;
327 const AbstractMetaType *argType = 0;
328 QString typeName = fun->typeReplaced(j+1);
328 QString typeName = fun->typeReplaced(j+1);
329 if (typeName.isEmpty()) {
329 if (typeName.isEmpty()) {
330 argType = arg->type();
330 argType = arg->type();
331 typeName = normalizedType(argType);
331 typeName = normalizedType(argType);
332 }
332 }
333 stream << indentStr << typeName << " " << actualOut;
333 stream << indentStr << typeName << " " << actualOut;
334 QString converter;
334 QString converter;
335 // ### generalize the QSet check (we should check if the type has push_back())
335 // ### generalize the QSet check (we should check if the type has push_back())
336 bool useToSequence = argType && isSequenceType(argType) && !argType->name().startsWith("Set");
336 bool useToSequence = argType && isSequenceType(argType) && !argType->name().startsWith("Set");
337 if (useToSequence) {
337 if (useToSequence) {
338 stream << ";" << endl;
338 stream << ";" << endl;
339 stream << indentStr << "qScriptValueToSequence(";
339 stream << indentStr << "qScriptValueToSequence(";
340 } else {
340 } else {
341 stream << " = ";
341 stream << " = ";
342 converter = builtinConversionFunction(typeName);
342 converter = builtinConversionFunction(typeName);
343 if (converter.isEmpty()) {
343 if (converter.isEmpty()) {
344 // generic conversion
344 // generic conversion
345 stream << "qscriptvalue_cast<" << typeName;
345 stream << "qscriptvalue_cast<" << typeName;
346 if (typeName.endsWith(QLatin1Char('>')))
346 if (typeName.endsWith(QLatin1Char('>')))
347 stream << " ";
347 stream << " ";
348 stream << ">(";
348 stream << ">(";
349 }
349 }
350 }
350 }
351 stream << actualIn;
351 stream << actualIn;
352 if (useToSequence) {
352 if (useToSequence) {
353 stream << ", " << actualOut << ")";
353 stream << ", " << actualOut << ")";
354 } else {
354 } else {
355 if (converter.isEmpty()) {
355 if (converter.isEmpty()) {
356 stream << ")"; // close qscriptvalue_cast
356 stream << ")"; // close qscriptvalue_cast
357 } else {
357 } else {
358 stream << "." << converter << "()";
358 stream << "." << converter << "()";
359 }
359 }
360 }
360 }
361 stream << ";" << endl;
361 stream << ";" << endl;
362 }
362 }
363 if (!fun->argumentRemoved(j+1))
363 if (!fun->argumentRemoved(j+1))
364 ++scriptArgIndex;
364 ++scriptArgIndex;
365 }
365 }
366 return j;
366 return j;
367 }
367 }
368
368
369 /*!
369 /*!
370 Writes the arguments that are passed to the native function we are
370 Writes the arguments that are passed to the native function we are
371 binding. Those arguments must have been prepared already in variables
371 binding. Those arguments must have been prepared already in variables
372 _q_arg0, _q_arg1, .. in the generated code.
372 _q_arg0, _q_arg1, .. in the generated code.
373 */
373 */
374 static void writeArguments(QTextStream &stream, int count)
374 static void writeArguments(QTextStream &stream, int count)
375 {
375 {
376 for (int i = 0; i < count; ++i) {
376 for (int i = 0; i < count; ++i) {
377 if (i > 0)
377 if (i > 0)
378 stream << ", ";
378 stream << ", ";
379 stream << "_q_arg" << i;
379 stream << "_q_arg" << i;
380 }
380 }
381 }
381 }
382
382
383 /*!
383 /*!
384 Writes a constructor call.
384 Writes a constructor call.
385 */
385 */
386 static void writeConstructorCallAndReturn(QTextStream &stream, const AbstractMetaFunction *fun,
386 static void writeConstructorCallAndReturn(QTextStream &stream, const AbstractMetaFunction *fun,
387 int scriptArgc, const AbstractMetaClass *meta_class,
387 int scriptArgc, const AbstractMetaClass *meta_class,
388 int indent)
388 int indent)
389 {
389 {
390 QString indentStr(indent, QLatin1Char(' '));
390 QString indentStr(indent, QLatin1Char(' '));
391
391
392 writeInjectedCode(stream, meta_class, fun, CodeSnip::Beginning);
392 writeInjectedCode(stream, meta_class, fun, CodeSnip::Beginning);
393
393
394 AbstractMetaArgumentList arguments = fun->arguments();
394 AbstractMetaArgumentList arguments = fun->arguments();
395 Q_ASSERT(arguments.size() >= scriptArgc);
395 Q_ASSERT(arguments.size() >= scriptArgc);
396 int nativeArgc = writePrepareArguments(stream, fun, arguments, scriptArgc, indent);
396 int nativeArgc = writePrepareArguments(stream, fun, arguments, scriptArgc, indent);
397 stream << indentStr;
397 stream << indentStr;
398 if (meta_class->generateShellClass()) {
398 if (meta_class->generateShellClass()) {
399 stream << "QtScriptShell_" << meta_class->name();
399 stream << "QtScriptShell_" << meta_class->name();
400 } else {
400 } else {
401 stream << meta_class->qualifiedCppName();
401 stream << meta_class->qualifiedCppName();
402 }
402 }
403 bool useNew = meta_class->typeEntry()->isObject() || !hasDefaultConstructor(meta_class);
403 bool useNew = meta_class->typeEntry()->isObject() || !hasDefaultConstructor(meta_class);
404 if (useNew)
404 if (useNew)
405 stream << "*";
405 stream << "*";
406 stream << " _q_cpp_result";
406 stream << " _q_cpp_result";
407 if (useNew) {
407 if (useNew) {
408 stream << " = new ";
408 stream << " = new ";
409 if (meta_class->generateShellClass())
409 if (meta_class->generateShellClass())
410 stream << "QtScriptShell_" << meta_class->name();
410 stream << "QtScriptShell_" << meta_class->name();
411 else
411 else
412 stream << meta_class->qualifiedCppName();
412 stream << meta_class->qualifiedCppName();
413 }
413 }
414 if (useNew || (nativeArgc != 0)) {
414 if (useNew || (nativeArgc != 0)) {
415 stream << "(";
415 stream << "(";
416 writeArguments(stream, nativeArgc);
416 writeArguments(stream, nativeArgc);
417 stream << ")";
417 stream << ")";
418 }
418 }
419 stream << ";" << endl;
419 stream << ";" << endl;
420
420
421 stream << indentStr << "QScriptValue _q_result = context->engine()->new";
421 stream << indentStr << "QScriptValue _q_result = context->engine()->new";
422 if (isQObjectBased(meta_class))
422 if (isQObjectBased(meta_class))
423 stream << "QObject";
423 stream << "QObject";
424 else
424 else
425 stream << "Variant";
425 stream << "Variant";
426 stream << "(context->thisObject(), ";
426 stream << "(context->thisObject(), ";
427 if (!isQObjectBased(meta_class))
427 if (!isQObjectBased(meta_class))
428 stream << "qVariantFromValue(";
428 stream << "qVariantFromValue(";
429 if (meta_class->generateShellClass()) {
429 if (meta_class->generateShellClass()) {
430 stream << "(" << meta_class->qualifiedCppName();
430 stream << "(" << meta_class->qualifiedCppName();
431 if (useNew)
431 if (useNew)
432 stream << "*";
432 stream << "*";
433 stream << ")";
433 stream << ")";
434 }
434 }
435 stream << "_q_cpp_result";
435 stream << "_q_cpp_result";
436 if (isQObjectBased(meta_class))
436 if (isQObjectBased(meta_class))
437 stream << ", QScriptEngine::AutoOwnership";
437 stream << ", QScriptEngine::AutoOwnership";
438 else
438 else
439 stream << ")";
439 stream << ")";
440 stream << ");" << endl;
440 stream << ");" << endl;
441 if (meta_class->generateShellClass()) {
441 if (meta_class->generateShellClass()) {
442 stream << indentStr << "_q_cpp_result";
442 stream << indentStr << "_q_cpp_result";
443 if (useNew)
443 if (useNew)
444 stream << "->";
444 stream << "->";
445 else
445 else
446 stream << ".";
446 stream << ".";
447 stream << "__qtscript_self = _q_result;" << endl;
447 stream << "__qtscript_self = _q_result;" << endl;
448 }
448 }
449
449
450 writeInjectedCode(stream, meta_class, fun, CodeSnip::End);
450 writeInjectedCode(stream, meta_class, fun, CodeSnip::End);
451
451
452 stream << indentStr << "return _q_result;" << endl;
452 stream << indentStr << "return _q_result;" << endl;
453 }
453 }
454
454
455 /*!
455 /*!
456 Returns true if the given \a typeName has a QScriptValue constructor
456 Returns true if the given \a typeName has a QScriptValue constructor
457 we can use, false otherwise.
457 we can use, false otherwise.
458 */
458 */
459 static bool hasScriptValueConstructor(const QString &typeName)
459 static bool hasScriptValueConstructor(const QString &typeName)
460 {
460 {
461 return (typeName == QLatin1String("bool"))
461 return (typeName == QLatin1String("bool"))
462 || (typeName == QLatin1String("int"))
462 || (typeName == QLatin1String("int"))
463 || (typeName == QLatin1String("uint"))
463 || (typeName == QLatin1String("uint"))
464 || (typeName == QLatin1String("double"))
464 || (typeName == QLatin1String("double"))
465 || (typeName == QLatin1String("QString"));
465 || (typeName == QLatin1String("QString"));
466 }
466 }
467
467
468 /*!
468 /*!
469 Writes a function call.
469 Writes a function call.
470 */
470 */
471 static void writeFunctionCallAndReturn(QTextStream &stream, const AbstractMetaFunction *fun,
471 static void writeFunctionCallAndReturn(QTextStream &stream, const AbstractMetaFunction *fun,
472 int scriptArgc, const AbstractMetaClass *meta_class,
472 int scriptArgc, const AbstractMetaClass *meta_class,
473 int indent)
473 int indent)
474 {
474 {
475 QString indentStr(indent, QLatin1Char(' '));
475 QString indentStr(indent, QLatin1Char(' '));
476 AbstractMetaArgumentList arguments = fun->arguments();
476 AbstractMetaArgumentList arguments = fun->arguments();
477 Q_ASSERT(arguments.size() >= scriptArgc);
477 Q_ASSERT(arguments.size() >= scriptArgc);
478
478
479 writeInjectedCode(stream, meta_class, fun, CodeSnip::Beginning);
479 writeInjectedCode(stream, meta_class, fun, CodeSnip::Beginning);
480
480
481 int nativeArgc = writePrepareArguments(stream, fun, arguments, scriptArgc, indent);
481 int nativeArgc = writePrepareArguments(stream, fun, arguments, scriptArgc, indent);
482 bool returnThisObject = fun->shouldReturnThisObject();
482 bool returnThisObject = fun->shouldReturnThisObject();
483 bool ignoreReturnValue = returnThisObject || fun->shouldIgnoreReturnValue();
483 bool ignoreReturnValue = returnThisObject || fun->shouldIgnoreReturnValue();
484 stream << indentStr;
484 stream << indentStr;
485 AbstractMetaType *retType = fun->type();
485 AbstractMetaType *retType = fun->type();
486 bool constCastResult = false;
486 bool constCastResult = false;
487 if (retType && !ignoreReturnValue) {
487 if (retType && !ignoreReturnValue) {
488 QString rsig = retType->cppSignature();
488 QString rsig = retType->cppSignature();
489 QString typeName = normalizedType(retType);
489 QString typeName = normalizedType(retType);
490 stream << typeName << " _q_result = ";
490 stream << typeName << " _q_result = ";
491 constCastResult = rsig.endsWith('*') && rsig.startsWith("const ");
491 constCastResult = rsig.endsWith('*') && rsig.startsWith("const ");
492 if (constCastResult)
492 if (constCastResult)
493 stream << "const_cast<" << typeName << ">(";
493 stream << "const_cast<" << typeName << ">(";
494 }
494 }
495
495
496 if (!fun->isStatic()) {
496 if (!fun->isStatic()) {
497 // ### the friendly check should be enough...
497 // ### the friendly check should be enough...
498 if (fun->isFriendly()
498 if (fun->isFriendly()
499 || ((fun->name() == QLatin1String("operator_equal"))
499 || ((fun->name() == QLatin1String("operator_equal"))
500 && ((meta_class->name() == QLatin1String("QPoint"))
500 && ((meta_class->name() == QLatin1String("QPoint"))
501 || (meta_class->name() == QLatin1String("QPointF"))
501 || (meta_class->name() == QLatin1String("QPointF"))
502 || (meta_class->name() == QLatin1String("QRect"))
502 || (meta_class->name() == QLatin1String("QRect"))
503 || (meta_class->name() == QLatin1String("QRectF"))
503 || (meta_class->name() == QLatin1String("QRectF"))
504 || (meta_class->name() == QLatin1String("QSize"))
504 || (meta_class->name() == QLatin1String("QSize"))
505 || (meta_class->name() == QLatin1String("QSizeF"))))) {
505 || (meta_class->name() == QLatin1String("QSizeF"))))) {
506 stream << fun->originalName() << "(";
506 stream << fun->originalName() << "(";
507 stream << "*_q_self, ";
507 stream << "*_q_self, ";
508 } else {
508 } else {
509 stream << "_q_self->";
509 stream << "_q_self->";
510 stream << fun->originalName() << "(";
510 stream << fun->originalName() << "(";
511 }
511 }
512 } else {
512 } else {
513 stream << meta_class->qualifiedCppName() << "::";
513 stream << meta_class->qualifiedCppName() << "::";
514 stream << fun->originalName() << "(";
514 stream << fun->originalName() << "(";
515 }
515 }
516 writeArguments(stream, nativeArgc);
516 writeArguments(stream, nativeArgc);
517 if (constCastResult)
517 if (constCastResult)
518 stream << ")";
518 stream << ")";
519 stream << ");" << endl;
519 stream << ");" << endl;
520
520
521 writeInjectedCode(stream, meta_class, fun, CodeSnip::End);
521 writeInjectedCode(stream, meta_class, fun, CodeSnip::End);
522
522
523 // write return statement
523 // write return statement
524 stream << indentStr;
524 stream << indentStr;
525 if (returnThisObject) {
525 if (returnThisObject) {
526 stream << "return context->thisObject();";
526 stream << "return context->thisObject();";
527 } else {
527 } else {
528 QString conv = fun->conversionRule(TypeSystem::NativeCode, 0);
528 QString conv = fun->conversionRule(TypeSystem::NativeCode, 0);
529 if (!conv.isEmpty()) {
529 if (!conv.isEmpty()) {
530 // custom conversion
530 // custom conversion
531 conv.replace(QString::fromLatin1("%in%"), "_q_result");
531 conv.replace(QString::fromLatin1("%in%"), "_q_result");
532 conv.replace(QString::fromLatin1("%out%"), "_q_convertedResult");
532 conv.replace(QString::fromLatin1("%out%"), "_q_convertedResult");
533 stream << conv;
533 stream << conv;
534 stream << "return qScriptValueFromValue(context->engine(), _q_convertedResult);";
534 stream << "return qScriptValueFromValue(context->engine(), _q_convertedResult);";
535 } else {
535 } else {
536 stream << "return ";
536 stream << "return ";
537 if (retType) {
537 if (retType) {
538 if (isSequenceType(retType))
538 if (isSequenceType(retType))
539 stream << "qScriptValueFromSequence";
539 stream << "qScriptValueFromSequence";
540 else if (hasScriptValueConstructor(normalizedType(retType)))
540 else if (hasScriptValueConstructor(normalizedType(retType)))
541 stream << "QScriptValue";
541 stream << "QScriptValue";
542 else
542 else
543 stream << "qScriptValueFromValue";
543 stream << "qScriptValueFromValue";
544 stream << "(context->engine(), _q_result);";
544 stream << "(context->engine(), _q_result);";
545 } else {
545 } else {
546 stream << "context->engine()->undefinedValue();";
546 stream << "context->engine()->undefinedValue();";
547 }
547 }
548 }
548 }
549 }
549 }
550 stream << endl;
550 stream << endl;
551 }
551 }
552
552
553 /*!
553 /*!
554 Returns true if the given function \a fun is operator>>() or
554 Returns true if the given function \a fun is operator>>() or
555 operator<<() that streams from/to a Q{Data,Text}Stream, false
555 operator<<() that streams from/to a Q{Data,Text}Stream, false
556 otherwise.
556 otherwise.
557 */
557 */
558 bool ClassGenerator::isSpecialStreamingOperator(const AbstractMetaFunction *fun)
558 bool ClassGenerator::isSpecialStreamingOperator(const AbstractMetaFunction *fun)
559 {
559 {
560 return ((fun->functionType() == AbstractMetaFunction::GlobalScopeFunction)
560 return ((fun->functionType() == AbstractMetaFunction::GlobalScopeFunction)
561 && (fun->arguments().size() == 1)
561 && (fun->arguments().size() == 1)
562 && (((fun->originalName() == "operator>>") && (fun->modifiedName() == "readFrom"))
562 && (((fun->originalName() == "operator>>") && (fun->modifiedName() == "readFrom"))
563 || ((fun->originalName() == "operator<<") && (fun->modifiedName() == "writeTo"))));
563 || ((fun->originalName() == "operator<<") && (fun->modifiedName() == "writeTo"))));
564 }
564 }
565
565
566 /*!
566 /*!
567 Generates code that uses Q{Data,Text}Stream operator>>() or
567 Generates code that uses Q{Data,Text}Stream operator>>() or
568 operator<<() to read/write an instance of meta_class.
568 operator<<() to read/write an instance of meta_class.
569 */
569 */
570 static void writeStreamingOperatorCall(QTextStream &stream, const AbstractMetaFunction *fun,
570 static void writeStreamingOperatorCall(QTextStream &stream, const AbstractMetaFunction *fun,
571 const AbstractMetaClass */*meta_class*/, int indent)
571 const AbstractMetaClass * /*meta_class*/, int indent)
572 {
572 {
573 QString indentStr(indent, QLatin1Char(' '));
573 QString indentStr(indent, QLatin1Char(' '));
574 QString streamClassName = fun->arguments().at(0)->type()->name();
574 QString streamClassName = fun->arguments().at(0)->type()->name();
575 stream << indentStr << streamClassName << "* _q_arg0 = qscriptvalue_cast<"
575 stream << indentStr << streamClassName << "* _q_arg0 = qscriptvalue_cast<"
576 << streamClassName << "*>(context->argument(0));" << endl;
576 << streamClassName << "*>(context->argument(0));" << endl;
577 stream << indentStr << "operator";
577 stream << indentStr << "operator";
578 if (fun->modifiedName() == "readFrom")
578 if (fun->modifiedName() == "readFrom")
579 stream << ">>";
579 stream << ">>";
580 else
580 else
581 stream << "<<";
581 stream << "<<";
582 stream << "(*_q_arg0, *_q_self);" << endl;
582 stream << "(*_q_arg0, *_q_self);" << endl;
583 stream << indentStr << "return context->engine()->undefinedValue();" << endl;
583 stream << indentStr << "return context->engine()->undefinedValue();" << endl;
584 }
584 }
585
585
586 /*!
586 /*!
587 Writes the constructor forwarding for \a meta_class.
587 Writes the constructor forwarding for \a meta_class.
588 */
588 */
589 static void writeConstructorForwarding(QTextStream &stream,
589 static void writeConstructorForwarding(QTextStream &stream,
590 const AbstractMetaFunctionList &functions,
590 const AbstractMetaFunctionList &functions,
591 const AbstractMetaClass *meta_class)
591 const AbstractMetaClass *meta_class)
592 {
592 {
593 #if 0
593 #if 0
594 stream << "/** signatures:" << endl;
594 stream << "/** signatures:" << endl;
595 foreach (const AbstractMetaFunction *fun, functions) {
595 foreach (const AbstractMetaFunction *fun, functions) {
596 stream << " * " << fun->signature() << endl;
596 stream << " * " << fun->signature() << endl;
597 }
597 }
598 stream << " */" << endl;
598 stream << " */" << endl;
599 #endif
599 #endif
600
600
601 if (/*meta_class->isAbstract() ||*/ (functions.size() == 0)) {
601 if (/*meta_class->isAbstract() ||*/ (functions.size() == 0)) {
602 stream << " return context->throwError(QScriptContext::TypeError," << endl
602 stream << " return context->throwError(QScriptContext::TypeError," << endl
603 << " QString::fromLatin1(\"" << meta_class->name()
603 << " QString::fromLatin1(\"" << meta_class->name()
604 << " cannot be constructed\"));" << endl;
604 << " cannot be constructed\"));" << endl;
605
605
606 } else {
606 } else {
607 stream << " if (context->thisObject().strictlyEquals(context->engine()->globalObject())) {" << endl
607 stream << " if (context->thisObject().strictlyEquals(context->engine()->globalObject())) {" << endl
608 << " return context->throwError(QString::fromLatin1(\""
608 << " return context->throwError(QString::fromLatin1(\""
609 << meta_class->name() << "(): Did you forget to construct with 'new'?\"));" << endl
609 << meta_class->name() << "(): Did you forget to construct with 'new'?\"));" << endl
610 << " }" << endl;
610 << " }" << endl;
611
611
612 writeInjectedCode(stream, meta_class, CodeSnip::Constructor);
612 writeInjectedCode(stream, meta_class, CodeSnip::Constructor);
613
613
614 QMap<int, AbstractMetaFunctionList> argcToFunctions;
614 QMap<int, AbstractMetaFunctionList> argcToFunctions;
615 argcToFunctions = createArgcToFunctionsMap(functions);
615 argcToFunctions = createArgcToFunctionsMap(functions);
616
616
617 int argcMin = argcToFunctions.keys().first();
617 int argcMin = argcToFunctions.keys().first();
618 int argcMax = argcToFunctions.keys().last();
618 int argcMax = argcToFunctions.keys().last();
619 bool needElse = false;
619 bool needElse = false;
620 for (int i = argcMin; i <= argcMax; ++i) {
620 for (int i = argcMin; i <= argcMax; ++i) {
621 AbstractMetaFunctionList funcs = argcToFunctions.value(i);
621 AbstractMetaFunctionList funcs = argcToFunctions.value(i);
622 if (funcs.isEmpty())
622 if (funcs.isEmpty())
623 continue;
623 continue;
624 if (needElse)
624 if (needElse)
625 stream << " else ";
625 stream << " else ";
626 else
626 else
627 stream << " ";
627 stream << " ";
628 needElse = true;
628 needElse = true;
629 stream << "if (context->argumentCount() == " << i << ") {" << endl;
629 stream << "if (context->argumentCount() == " << i << ") {" << endl;
630 if ((funcs.size() == 1) || (i == 0)) {
630 if ((funcs.size() == 1) || (i == 0)) {
631 AbstractMetaFunction *fun = funcs.at(0);
631 AbstractMetaFunction *fun = funcs.at(0);
632 const int indent = 8;
632 const int indent = 8;
633 writeConstructorCallAndReturn(stream, fun, i, meta_class, indent);
633 writeConstructorCallAndReturn(stream, fun, i, meta_class, indent);
634 } else {
634 } else {
635 // handle overloads
635 // handle overloads
636 for (int j = 0; j < funcs.size(); ++j) {
636 for (int j = 0; j < funcs.size(); ++j) {
637 AbstractMetaFunction *fun = funcs.at(j);
637 AbstractMetaFunction *fun = funcs.at(j);
638 stream << " ";
638 stream << " ";
639 if (j > 0)
639 if (j > 0)
640 stream << "} else ";
640 stream << "} else ";
641 stream << "if (";
641 stream << "if (";
642 AbstractMetaArgumentList arguments = fun->arguments();
642 AbstractMetaArgumentList arguments = fun->arguments();
643 const int indent = 12;
643 const int indent = 12;
644 writeArgumentTypeTests(stream, fun, arguments, i, indent);
644 writeArgumentTypeTests(stream, fun, arguments, i, indent);
645 stream << ") {" << endl;
645 stream << ") {" << endl;
646 writeConstructorCallAndReturn(stream, fun, i, meta_class, indent);
646 writeConstructorCallAndReturn(stream, fun, i, meta_class, indent);
647 }
647 }
648 stream << " }" << endl;
648 stream << " }" << endl;
649 }
649 }
650 stream << " }";
650 stream << " }";
651 }
651 }
652 stream << endl;
652 stream << endl;
653 // writeThrowAmbiguityError(stream, meta_class, 0, signatures.toList());
653 // writeThrowAmbiguityError(stream, meta_class, 0, signatures.toList());
654 }
654 }
655 }
655 }
656
656
657 /*!
657 /*!
658 Returns a list of enum \a values that are actually unique.
658 Returns a list of enum \a values that are actually unique.
659 */
659 */
660 QList<int> uniqueEnumValueIndexes(const AbstractMetaEnumValueList &values)
660 QList<int> uniqueEnumValueIndexes(const AbstractMetaEnumValueList &values)
661 {
661 {
662 QMap<int, int> map;
662 QMap<int, int> map;
663 for (int i = 0; i < values.count(); ++i) {
663 for (int i = 0; i < values.count(); ++i) {
664 AbstractMetaEnumValue *val = values.at(i);
664 AbstractMetaEnumValue *val = values.at(i);
665 if (!map.contains(val->value()))
665 if (!map.contains(val->value()))
666 map.insert(val->value(), i);
666 map.insert(val->value(), i);
667 }
667 }
668 return map.values();
668 return map.values();
669 }
669 }
670
670
671 /*!
671 /*!
672 */
672 */
673 static bool isContiguousEnum(const QList<int> &indexes, const AbstractMetaEnumValueList &values)
673 static bool isContiguousEnum(const QList<int> &indexes, const AbstractMetaEnumValueList &values)
674 {
674 {
675 if (indexes.isEmpty())
675 if (indexes.isEmpty())
676 return false;
676 return false;
677 int prev = values.at(indexes.at(0))->value();
677 int prev = values.at(indexes.at(0))->value();
678 for (int i = 1; i < indexes.size(); ++i) {
678 for (int i = 1; i < indexes.size(); ++i) {
679 int curr = values.at(indexes.at(i))->value();
679 int curr = values.at(indexes.at(i))->value();
680 if (curr != prev + 1)
680 if (curr != prev + 1)
681 return false;
681 return false;
682 prev = curr;
682 prev = curr;
683 }
683 }
684 return true;
684 return true;
685 }
685 }
686
686
687 static void writeCreateEnumClassHelper(QTextStream &stream)
687 static void writeCreateEnumClassHelper(QTextStream &stream)
688 {
688 {
689 stream << "static QScriptValue qtscript_create_enum_class_helper(" << endl
689 stream << "static QScriptValue qtscript_create_enum_class_helper(" << endl
690 << " QScriptEngine *engine," << endl
690 << " QScriptEngine *engine," << endl
691 << " QScriptEngine::FunctionSignature construct," << endl
691 << " QScriptEngine::FunctionSignature construct," << endl
692 << " QScriptEngine::FunctionSignature valueOf," << endl
692 << " QScriptEngine::FunctionSignature valueOf," << endl
693 << " QScriptEngine::FunctionSignature toString)" << endl
693 << " QScriptEngine::FunctionSignature toString)" << endl
694 << "{" << endl
694 << "{" << endl
695 << " QScriptValue proto = engine->newObject();" << endl
695 << " QScriptValue proto = engine->newObject();" << endl
696 << " proto.setProperty(QString::fromLatin1(\"valueOf\")," << endl
696 << " proto.setProperty(QString::fromLatin1(\"valueOf\")," << endl
697 << " engine->newFunction(valueOf), QScriptValue::SkipInEnumeration);" << endl
697 << " engine->newFunction(valueOf), QScriptValue::SkipInEnumeration);" << endl
698 << " proto.setProperty(QString::fromLatin1(\"toString\")," << endl
698 << " proto.setProperty(QString::fromLatin1(\"toString\")," << endl
699 << " engine->newFunction(toString), QScriptValue::SkipInEnumeration);" << endl
699 << " engine->newFunction(toString), QScriptValue::SkipInEnumeration);" << endl
700 << " return engine->newFunction(construct, proto, 1);" << endl
700 << " return engine->newFunction(construct, proto, 1);" << endl
701 << "}" << endl << endl;
701 << "}" << endl << endl;
702 }
702 }
703
703
704 static void writeCreateFlagsClassHelper(QTextStream &stream)
704 static void writeCreateFlagsClassHelper(QTextStream &stream)
705 {
705 {
706 stream << "static QScriptValue qtscript_create_flags_class_helper(" << endl
706 stream << "static QScriptValue qtscript_create_flags_class_helper(" << endl
707 << " QScriptEngine *engine," << endl
707 << " QScriptEngine *engine," << endl
708 << " QScriptEngine::FunctionSignature construct," << endl
708 << " QScriptEngine::FunctionSignature construct," << endl
709 << " QScriptEngine::FunctionSignature valueOf," << endl
709 << " QScriptEngine::FunctionSignature valueOf," << endl
710 << " QScriptEngine::FunctionSignature toString," << endl
710 << " QScriptEngine::FunctionSignature toString," << endl
711 << " QScriptEngine::FunctionSignature equals)" << endl
711 << " QScriptEngine::FunctionSignature equals)" << endl
712 << "{" << endl
712 << "{" << endl
713 << " QScriptValue proto = engine->newObject();" << endl
713 << " QScriptValue proto = engine->newObject();" << endl
714 << " proto.setProperty(QString::fromLatin1(\"valueOf\")," << endl
714 << " proto.setProperty(QString::fromLatin1(\"valueOf\")," << endl
715 << " engine->newFunction(valueOf), QScriptValue::SkipInEnumeration);" << endl
715 << " engine->newFunction(valueOf), QScriptValue::SkipInEnumeration);" << endl
716 << " proto.setProperty(QString::fromLatin1(\"toString\")," << endl
716 << " proto.setProperty(QString::fromLatin1(\"toString\")," << endl
717 << " engine->newFunction(toString), QScriptValue::SkipInEnumeration);" << endl
717 << " engine->newFunction(toString), QScriptValue::SkipInEnumeration);" << endl
718 << " proto.setProperty(QString::fromLatin1(\"equals\")," << endl
718 << " proto.setProperty(QString::fromLatin1(\"equals\")," << endl
719 << " engine->newFunction(equals), QScriptValue::SkipInEnumeration);" << endl
719 << " engine->newFunction(equals), QScriptValue::SkipInEnumeration);" << endl
720 << " return engine->newFunction(construct, proto);" << endl
720 << " return engine->newFunction(construct, proto);" << endl
721 << "}" << endl << endl;
721 << "}" << endl << endl;
722 }
722 }
723
723
724 /*!
724 /*!
725 Writes the enum \a enom belonging to the class \a meta_class to the
725 Writes the enum \a enom belonging to the class \a meta_class to the
726 given \a stream.
726 given \a stream.
727 */
727 */
728 static void writeEnumClass(QTextStream &stream, const AbstractMetaClass *meta_class,
728 static void writeEnumClass(QTextStream &stream, const AbstractMetaClass *meta_class,
729 const AbstractMetaEnum *enom)
729 const AbstractMetaEnum *enom)
730 {
730 {
731 QString qualifiedEnumName = meta_class->qualifiedCppName() + "::" + enom->name();
731 QString qualifiedEnumName = meta_class->qualifiedCppName() + "::" + enom->name();
732 QString qtScriptEnumName = meta_class->name() + "_" + enom->name();
732 QString qtScriptEnumName = meta_class->name() + "_" + enom->name();
733
733
734 stream << "//" << endl;
734 stream << "//" << endl;
735 stream << "// " << qualifiedEnumName << endl;
735 stream << "// " << qualifiedEnumName << endl;
736 stream << "//" << endl << endl;
736 stream << "//" << endl << endl;
737
737
738 // determine unique values (aliases will cause switch statement to not compile)
738 // determine unique values (aliases will cause switch statement to not compile)
739 AbstractMetaEnumValueList values = enom->values();
739 AbstractMetaEnumValueList values = enom->values();
740 QList<int> uniqueIndexes = uniqueEnumValueIndexes(values);
740 QList<int> uniqueIndexes = uniqueEnumValueIndexes(values);
741
741
742 bool contiguous = isContiguousEnum(uniqueIndexes, values);
742 bool contiguous = isContiguousEnum(uniqueIndexes, values);
743
743
744 // write arrays of values and keys
744 // write arrays of values and keys
745 stream << "static const " << qualifiedEnumName
745 stream << "static const " << qualifiedEnumName
746 << " qtscript_" << qtScriptEnumName << "_values[] = {" << endl;
746 << " qtscript_" << qtScriptEnumName << "_values[] = {" << endl;
747 for (int i = 0; i < uniqueIndexes.size(); ++i) {
747 for (int i = 0; i < uniqueIndexes.size(); ++i) {
748 stream << " ";
748 stream << " ";
749 if (i > 0)
749 if (i > 0)
750 stream << ", ";
750 stream << ", ";
751 stream << meta_class->qualifiedCppName() << "::" << values.at(uniqueIndexes.at(i))->name() << endl;
751 stream << meta_class->qualifiedCppName() << "::" << values.at(uniqueIndexes.at(i))->name() << endl;
752 }
752 }
753 stream << "};" << endl << endl;
753 stream << "};" << endl << endl;
754 stream << "static const char * const qtscript_" << qtScriptEnumName << "_keys[] = {" << endl;
754 stream << "static const char * const qtscript_" << qtScriptEnumName << "_keys[] = {" << endl;
755 for (int i = 0; i < uniqueIndexes.size(); ++i) {
755 for (int i = 0; i < uniqueIndexes.size(); ++i) {
756 stream << " ";
756 stream << " ";
757 if (i > 0)
757 if (i > 0)
758 stream << ", ";
758 stream << ", ";
759 stream << "\"" << values.at(uniqueIndexes.at(i))->name() << "\"" << endl;
759 stream << "\"" << values.at(uniqueIndexes.at(i))->name() << "\"" << endl;
760 }
760 }
761 stream << "};" << endl << endl;
761 stream << "};" << endl << endl;
762
762
763 // write toString helper
763 // write toString helper
764 stream << "static QString qtscript_"
764 stream << "static QString qtscript_"
765 << qtScriptEnumName << "_toStringHelper"
765 << qtScriptEnumName << "_toStringHelper"
766 << "(" << qualifiedEnumName << " value)" << endl;
766 << "(" << qualifiedEnumName << " value)" << endl;
767 stream << "{" << endl;
767 stream << "{" << endl;
768 if (enom->hasQEnumsDeclaration() && (meta_class->qualifiedCppName() != "QTransform")) {
768 if (enom->hasQEnumsDeclaration() && (meta_class->qualifiedCppName() != "QTransform")) {
769 stream << " const QMetaObject *meta = qtscript_" << meta_class->name() << "_metaObject();" << endl;
769 stream << " const QMetaObject *meta = qtscript_" << meta_class->name() << "_metaObject();" << endl;
770 stream << " int idx = meta->indexOfEnumerator(\"" << enom->name() << "\");" << endl;
770 stream << " int idx = meta->indexOfEnumerator(\"" << enom->name() << "\");" << endl;
771 stream << " Q_ASSERT(idx != -1);" << endl;
771 stream << " Q_ASSERT(idx != -1);" << endl;
772 stream << " QMetaEnum menum = meta->enumerator(idx);" << endl;
772 stream << " QMetaEnum menum = meta->enumerator(idx);" << endl;
773 stream << " return QString::fromLatin1(menum.valueToKey(value));" << endl;
773 stream << " return QString::fromLatin1(menum.valueToKey(value));" << endl;
774 } else {
774 } else {
775 if (contiguous) {
775 if (contiguous) {
776 stream << " if ((value >= " << meta_class->qualifiedCppName()
776 stream << " if ((value >= " << meta_class->qualifiedCppName()
777 << "::" << values.at(uniqueIndexes.first())->name() << ")"
777 << "::" << values.at(uniqueIndexes.first())->name() << ")"
778 << " && (value <= " << meta_class->qualifiedCppName()
778 << " && (value <= " << meta_class->qualifiedCppName()
779 << "::" << values.at(uniqueIndexes.last())->name() << "))" << endl
779 << "::" << values.at(uniqueIndexes.last())->name() << "))" << endl
780 << " return qtscript_" << qtScriptEnumName
780 << " return qtscript_" << qtScriptEnumName
781 << "_keys[static_cast<int>(value)-static_cast<int>("
781 << "_keys[static_cast<int>(value)-static_cast<int>("
782 << meta_class->qualifiedCppName() << "::"
782 << meta_class->qualifiedCppName() << "::"
783 << values.at(uniqueIndexes.first())->name() << ")];" << endl;
783 << values.at(uniqueIndexes.first())->name() << ")];" << endl;
784 } else {
784 } else {
785 stream << " for (int i = 0; i < " << uniqueIndexes.size() << "; ++i) {" << endl
785 stream << " for (int i = 0; i < " << uniqueIndexes.size() << "; ++i) {" << endl
786 << " if (qtscript_" << qtScriptEnumName << "_values[i] == value)" << endl
786 << " if (qtscript_" << qtScriptEnumName << "_values[i] == value)" << endl
787 << " return QString::fromLatin1(qtscript_" << qtScriptEnumName << "_keys[i]);" << endl
787 << " return QString::fromLatin1(qtscript_" << qtScriptEnumName << "_keys[i]);" << endl
788 << " }" << endl;
788 << " }" << endl;
789 }
789 }
790 stream << " return QString();" << endl;
790 stream << " return QString();" << endl;
791 }
791 }
792 stream << "}" << endl << endl;
792 stream << "}" << endl << endl;
793
793
794 // write QScriptValue <--> C++ conversion functions
794 // write QScriptValue <--> C++ conversion functions
795 stream << "static QScriptValue qtscript_"
795 stream << "static QScriptValue qtscript_"
796 << qtScriptEnumName << "_toScriptValue("
796 << qtScriptEnumName << "_toScriptValue("
797 << "QScriptEngine *engine, const " << qualifiedEnumName << " &value)" << endl
797 << "QScriptEngine *engine, const " << qualifiedEnumName << " &value)" << endl
798 << "{" << endl
798 << "{" << endl
799 << " QScriptValue clazz = engine->globalObject().property(QString::fromLatin1(\""
799 << " QScriptValue clazz = engine->globalObject().property(QString::fromLatin1(\""
800 << meta_class->name() << "\"));" << endl
800 << meta_class->name() << "\"));" << endl
801 // << " QScriptValue enumClazz = clazz.property(QString::fromLatin1(\""
801 // << " QScriptValue enumClazz = clazz.property(QString::fromLatin1(\""
802 // << enom->name() << "\"));" << endl
802 // << enom->name() << "\"));" << endl
803 << " return clazz.property(qtscript_" << qtScriptEnumName << "_toStringHelper(value));" << endl
803 << " return clazz.property(qtscript_" << qtScriptEnumName << "_toStringHelper(value));" << endl
804 << "}" << endl << endl;
804 << "}" << endl << endl;
805 stream << "static void qtscript_"
805 stream << "static void qtscript_"
806 << qtScriptEnumName << "_fromScriptValue("
806 << qtScriptEnumName << "_fromScriptValue("
807 << "const QScriptValue &value, " << qualifiedEnumName << " &out)" << endl
807 << "const QScriptValue &value, " << qualifiedEnumName << " &out)" << endl
808 << "{" << endl
808 << "{" << endl
809 << " out = qvariant_cast<" << qualifiedEnumName << ">(value.toVariant());" << endl
809 << " out = qvariant_cast<" << qualifiedEnumName << ">(value.toVariant());" << endl
810 << "}" << endl << endl;
810 << "}" << endl << endl;
811
811
812 // write constructor
812 // write constructor
813 stream << "static QScriptValue qtscript_construct_"
813 stream << "static QScriptValue qtscript_construct_"
814 << qtScriptEnumName
814 << qtScriptEnumName
815 << "(QScriptContext *context, QScriptEngine *engine)" << endl;
815 << "(QScriptContext *context, QScriptEngine *engine)" << endl;
816 stream << "{" << endl;
816 stream << "{" << endl;
817 stream << " int arg = context->argument(0).toInt32();" << endl;
817 stream << " int arg = context->argument(0).toInt32();" << endl;
818 if (enom->hasQEnumsDeclaration() && (meta_class->qualifiedCppName() != "QTransform")) {
818 if (enom->hasQEnumsDeclaration() && (meta_class->qualifiedCppName() != "QTransform")) {
819 stream << " const QMetaObject *meta = qtscript_" << meta_class->name() << "_metaObject();" << endl;
819 stream << " const QMetaObject *meta = qtscript_" << meta_class->name() << "_metaObject();" << endl;
820 stream << " int idx = meta->indexOfEnumerator(\"" << enom->name() << "\");" << endl;
820 stream << " int idx = meta->indexOfEnumerator(\"" << enom->name() << "\");" << endl;
821 stream << " Q_ASSERT(idx != -1);" << endl;
821 stream << " Q_ASSERT(idx != -1);" << endl;
822 stream << " QMetaEnum menum = meta->enumerator(idx);" << endl;
822 stream << " QMetaEnum menum = meta->enumerator(idx);" << endl;
823 stream << " if (menum.valueToKey(arg) != 0)" << endl;
823 stream << " if (menum.valueToKey(arg) != 0)" << endl;
824 stream << " return qScriptValueFromValue(engine, static_cast<"
824 stream << " return qScriptValueFromValue(engine, static_cast<"
825 << qualifiedEnumName << ">(arg));" << endl;
825 << qualifiedEnumName << ">(arg));" << endl;
826 } else {
826 } else {
827 if (contiguous) {
827 if (contiguous) {
828 stream << " if ((arg >= " << meta_class->qualifiedCppName()
828 stream << " if ((arg >= " << meta_class->qualifiedCppName()
829 << "::" << values.at(uniqueIndexes.first())->name() << ")"
829 << "::" << values.at(uniqueIndexes.first())->name() << ")"
830 << " && (arg <= " << meta_class->qualifiedCppName()
830 << " && (arg <= " << meta_class->qualifiedCppName()
831 << "::" << values.at(uniqueIndexes.last())->name() << "))" << endl;
831 << "::" << values.at(uniqueIndexes.last())->name() << "))" << endl;
832 stream << " return qScriptValueFromValue(engine, static_cast<"
832 stream << " return qScriptValueFromValue(engine, static_cast<"
833 << qualifiedEnumName << ">(arg));" << endl;
833 << qualifiedEnumName << ">(arg));" << endl;
834 } else {
834 } else {
835 stream << " for (int i = 0; i < " << uniqueIndexes.size() << "; ++i) {" << endl
835 stream << " for (int i = 0; i < " << uniqueIndexes.size() << "; ++i) {" << endl
836 << " if (qtscript_" << qtScriptEnumName << "_values[i] == arg)" << endl;
836 << " if (qtscript_" << qtScriptEnumName << "_values[i] == arg)" << endl;
837 stream << " return qScriptValueFromValue(engine, static_cast<"
837 stream << " return qScriptValueFromValue(engine, static_cast<"
838 << qualifiedEnumName << ">(arg));" << endl;
838 << qualifiedEnumName << ">(arg));" << endl;
839 stream << " }" << endl;
839 stream << " }" << endl;
840 }
840 }
841 }
841 }
842 stream << " return context->throwError(QString::fromLatin1(\""
842 stream << " return context->throwError(QString::fromLatin1(\""
843 << enom->name() << "(): invalid enum value (%0)\").arg(arg));" << endl;
843 << enom->name() << "(): invalid enum value (%0)\").arg(arg));" << endl;
844 stream << "}" << endl;
844 stream << "}" << endl;
845 stream << endl;
845 stream << endl;
846
846
847 // write prototype.valueOf()
847 // write prototype.valueOf()
848 stream << "static QScriptValue qtscript_" << qtScriptEnumName
848 stream << "static QScriptValue qtscript_" << qtScriptEnumName
849 << "_valueOf(QScriptContext *context, QScriptEngine *engine)" << endl;
849 << "_valueOf(QScriptContext *context, QScriptEngine *engine)" << endl;
850 stream << "{" << endl;
850 stream << "{" << endl;
851 stream << " " << qualifiedEnumName << " value = "
851 stream << " " << qualifiedEnumName << " value = "
852 << "qscriptvalue_cast<" << qualifiedEnumName
852 << "qscriptvalue_cast<" << qualifiedEnumName
853 << ">(context->thisObject());" << endl;
853 << ">(context->thisObject());" << endl;
854 stream << " return QScriptValue(engine, static_cast<int>(value));" << endl;
854 stream << " return QScriptValue(engine, static_cast<int>(value));" << endl;
855 stream << "}" << endl;
855 stream << "}" << endl;
856 stream << endl;
856 stream << endl;
857
857
858 // write prototype.toString()
858 // write prototype.toString()
859 stream << "static QScriptValue qtscript_" << qtScriptEnumName
859 stream << "static QScriptValue qtscript_" << qtScriptEnumName
860 << "_toString(QScriptContext *context, QScriptEngine *engine)" << endl;
860 << "_toString(QScriptContext *context, QScriptEngine *engine)" << endl;
861 stream << "{" << endl;
861 stream << "{" << endl;
862 stream << " " << qualifiedEnumName << " value = "
862 stream << " " << qualifiedEnumName << " value = "
863 << "qscriptvalue_cast<" << qualifiedEnumName
863 << "qscriptvalue_cast<" << qualifiedEnumName
864 << ">(context->thisObject());" << endl;
864 << ">(context->thisObject());" << endl;
865 stream << " return QScriptValue(engine, qtscript_" << qtScriptEnumName << "_toStringHelper(value));" << endl;
865 stream << " return QScriptValue(engine, qtscript_" << qtScriptEnumName << "_toStringHelper(value));" << endl;
866 stream << "}" << endl;
866 stream << "}" << endl;
867 stream << endl;
867 stream << endl;
868
868
869 // write class creation function
869 // write class creation function
870 stream << "static QScriptValue qtscript_create_"
870 stream << "static QScriptValue qtscript_create_"
871 << qtScriptEnumName
871 << qtScriptEnumName
872 << "_class(QScriptEngine *engine, QScriptValue &clazz)" << endl;
872 << "_class(QScriptEngine *engine, QScriptValue &clazz)" << endl;
873 stream << "{" << endl;
873 stream << "{" << endl;
874
874
875 stream << " QScriptValue ctor = qtscript_create_enum_class_helper(" << endl
875 stream << " QScriptValue ctor = qtscript_create_enum_class_helper(" << endl
876 << " engine, qtscript_construct_" << qtScriptEnumName << "," << endl
876 << " engine, qtscript_construct_" << qtScriptEnumName << "," << endl
877 << " qtscript_" << qtScriptEnumName << "_valueOf, qtscript_"
877 << " qtscript_" << qtScriptEnumName << "_valueOf, qtscript_"
878 << qtScriptEnumName << "_toString);" << endl;
878 << qtScriptEnumName << "_toString);" << endl;
879
879
880 stream << " qScriptRegisterMetaType<" << qualifiedEnumName << ">(engine, "
880 stream << " qScriptRegisterMetaType<" << qualifiedEnumName << ">(engine, "
881 << "qtscript_" << qtScriptEnumName << "_toScriptValue," << endl
881 << "qtscript_" << qtScriptEnumName << "_toScriptValue," << endl
882 << " qtscript_" << qtScriptEnumName << "_fromScriptValue,"
882 << " qtscript_" << qtScriptEnumName << "_fromScriptValue,"
883 << " ctor.property(QString::fromLatin1(\"prototype\")));" << endl;
883 << " ctor.property(QString::fromLatin1(\"prototype\")));" << endl;
884
884
885 // enum values are properties of the constructor
885 // enum values are properties of the constructor
886 stream << " for (int i = 0; i < " << uniqueIndexes.size() << "; ++i) {" << endl
886 stream << " for (int i = 0; i < " << uniqueIndexes.size() << "; ++i) {" << endl
887 << " clazz.setProperty(QString::fromLatin1(qtscript_"
887 << " clazz.setProperty(QString::fromLatin1(qtscript_"
888 << qtScriptEnumName << "_keys[i])," << endl
888 << qtScriptEnumName << "_keys[i])," << endl
889 << " engine->newVariant(qVariantFromValue(qtscript_"
889 << " engine->newVariant(qVariantFromValue(qtscript_"
890 << qtScriptEnumName << "_values[i]))," << endl
890 << qtScriptEnumName << "_values[i]))," << endl
891 << " QScriptValue::ReadOnly | QScriptValue::Undeletable);" << endl
891 << " QScriptValue::ReadOnly | QScriptValue::Undeletable);" << endl
892 << " }" << endl;
892 << " }" << endl;
893
893
894 stream << " return ctor;" << endl;
894 stream << " return ctor;" << endl;
895 stream << "}" << endl;
895 stream << "}" << endl;
896 stream << endl;
896 stream << endl;
897
897
898 // write flags class too, if any
898 // write flags class too, if any
899 FlagsTypeEntry *flags = enom->typeEntry()->flags();
899 FlagsTypeEntry *flags = enom->typeEntry()->flags();
900 if (!flags)
900 if (!flags)
901 return;
901 return;
902
902
903 QString qualifiedFlagsName = meta_class->qualifiedCppName() + "::" + flags->targetLangName();
903 QString qualifiedFlagsName = meta_class->qualifiedCppName() + "::" + flags->targetLangName();
904 QString qtScriptFlagsName = meta_class->name() + "_" + flags->targetLangName();
904 QString qtScriptFlagsName = meta_class->name() + "_" + flags->targetLangName();
905
905
906 stream << "//" << endl;
906 stream << "//" << endl;
907 stream << "// " << qualifiedFlagsName << endl;
907 stream << "// " << qualifiedFlagsName << endl;
908 stream << "//" << endl << endl;
908 stream << "//" << endl << endl;
909
909
910 // write QScriptValue <--> C++ conversion functions
910 // write QScriptValue <--> C++ conversion functions
911 stream << "static QScriptValue qtscript_"
911 stream << "static QScriptValue qtscript_"
912 << qtScriptFlagsName << "_toScriptValue("
912 << qtScriptFlagsName << "_toScriptValue("
913 << "QScriptEngine *engine, const " << qualifiedFlagsName << " &value)" << endl
913 << "QScriptEngine *engine, const " << qualifiedFlagsName << " &value)" << endl
914 << "{" << endl
914 << "{" << endl
915 << " return engine->newVariant(qVariantFromValue(value));" << endl
915 << " return engine->newVariant(qVariantFromValue(value));" << endl
916 << "}" << endl << endl;
916 << "}" << endl << endl;
917 stream << "static void qtscript_"
917 stream << "static void qtscript_"
918 << qtScriptFlagsName << "_fromScriptValue("
918 << qtScriptFlagsName << "_fromScriptValue("
919 << "const QScriptValue &value, " << qualifiedFlagsName << " &out)" << endl
919 << "const QScriptValue &value, " << qualifiedFlagsName << " &out)" << endl
920 << "{" << endl
920 << "{" << endl
921 << " QVariant var = value.toVariant();" << endl
921 << " QVariant var = value.toVariant();" << endl
922 << " if (var.userType() == qMetaTypeId<" << qualifiedFlagsName << ">())" << endl
922 << " if (var.userType() == qMetaTypeId<" << qualifiedFlagsName << ">())" << endl
923 << " out = qvariant_cast<" << qualifiedFlagsName << ">(var);" << endl
923 << " out = qvariant_cast<" << qualifiedFlagsName << ">(var);" << endl
924 << " else if (var.userType() == qMetaTypeId<" << qualifiedEnumName << ">())" << endl
924 << " else if (var.userType() == qMetaTypeId<" << qualifiedEnumName << ">())" << endl
925 << " out = qvariant_cast<" << qualifiedEnumName << ">(var);" << endl
925 << " out = qvariant_cast<" << qualifiedEnumName << ">(var);" << endl
926 << " else" << endl
926 << " else" << endl
927 << " out = 0;" << endl
927 << " out = 0;" << endl
928 << "}" << endl << endl;
928 << "}" << endl << endl;
929
929
930 // write constructor
930 // write constructor
931 stream << "static QScriptValue qtscript_construct_"
931 stream << "static QScriptValue qtscript_construct_"
932 << qtScriptFlagsName
932 << qtScriptFlagsName
933 << "(QScriptContext *context, QScriptEngine *engine)" << endl;
933 << "(QScriptContext *context, QScriptEngine *engine)" << endl;
934 stream << "{" << endl;
934 stream << "{" << endl;
935 stream << " " << qualifiedFlagsName << " result = 0;" << endl;
935 stream << " " << qualifiedFlagsName << " result = 0;" << endl;
936 stream << " if ((context->argumentCount() == 1) && context->argument(0).isNumber()) {" << endl;
936 stream << " if ((context->argumentCount() == 1) && context->argument(0).isNumber()) {" << endl;
937 stream << " result = static_cast<" << qualifiedFlagsName << ">(context->argument(0).toInt32());" << endl;
937 stream << " result = static_cast<" << qualifiedFlagsName << ">(context->argument(0).toInt32());" << endl;
938 stream << " } else {" << endl;
938 stream << " } else {" << endl;
939 stream << " for (int i = 0; i < context->argumentCount(); ++i) {" << endl;
939 stream << " for (int i = 0; i < context->argumentCount(); ++i) {" << endl;
940 stream << " QVariant v = context->argument(i).toVariant();" << endl;
940 stream << " QVariant v = context->argument(i).toVariant();" << endl;
941 stream << " if (v.userType() != qMetaTypeId<" << qualifiedEnumName << ">()) {" << endl;
941 stream << " if (v.userType() != qMetaTypeId<" << qualifiedEnumName << ">()) {" << endl;
942 stream << " return context->throwError(QScriptContext::TypeError," << endl
942 stream << " return context->throwError(QScriptContext::TypeError," << endl
943 << " QString::fromLatin1(\"" << flags->targetLangName()
943 << " QString::fromLatin1(\"" << flags->targetLangName()
944 << "(): argument %0 is not of type " << enom->name() << "\").arg(i));" << endl;
944 << "(): argument %0 is not of type " << enom->name() << "\").arg(i));" << endl;
945 stream << " }" << endl;
945 stream << " }" << endl;
946 stream << " result |= qvariant_cast<" << qualifiedEnumName
946 stream << " result |= qvariant_cast<" << qualifiedEnumName
947 << ">(v);" << endl;
947 << ">(v);" << endl;
948 stream << " }" << endl;
948 stream << " }" << endl;
949 stream << " }" << endl;
949 stream << " }" << endl;
950 stream << " return engine->newVariant(qVariantFromValue(result));" << endl;
950 stream << " return engine->newVariant(qVariantFromValue(result));" << endl;
951 stream << "}" << endl;
951 stream << "}" << endl;
952 stream << endl;
952 stream << endl;
953
953
954 // write prototype.valueOf()
954 // write prototype.valueOf()
955 stream << "static QScriptValue qtscript_" << qtScriptFlagsName
955 stream << "static QScriptValue qtscript_" << qtScriptFlagsName
956 << "_valueOf(QScriptContext *context, QScriptEngine *engine)" << endl;
956 << "_valueOf(QScriptContext *context, QScriptEngine *engine)" << endl;
957 stream << "{" << endl;
957 stream << "{" << endl;
958 stream << " " << qualifiedFlagsName << " value = "
958 stream << " " << qualifiedFlagsName << " value = "
959 << "qscriptvalue_cast<" << qualifiedFlagsName
959 << "qscriptvalue_cast<" << qualifiedFlagsName
960 << ">(context->thisObject());" << endl;
960 << ">(context->thisObject());" << endl;
961 stream << " return QScriptValue(engine, static_cast<int>(value));" << endl;
961 stream << " return QScriptValue(engine, static_cast<int>(value));" << endl;
962 stream << "}" << endl;
962 stream << "}" << endl;
963 stream << endl;
963 stream << endl;
964
964
965 // write prototype.toString()
965 // write prototype.toString()
966 stream << "static QScriptValue qtscript_" << qtScriptFlagsName
966 stream << "static QScriptValue qtscript_" << qtScriptFlagsName
967 << "_toString(QScriptContext *context, QScriptEngine *engine)" << endl;
967 << "_toString(QScriptContext *context, QScriptEngine *engine)" << endl;
968 stream << "{" << endl;
968 stream << "{" << endl;
969 stream << " " << qualifiedFlagsName << " value = "
969 stream << " " << qualifiedFlagsName << " value = "
970 << "qscriptvalue_cast<" << qualifiedFlagsName
970 << "qscriptvalue_cast<" << qualifiedFlagsName
971 << ">(context->thisObject());" << endl;
971 << ">(context->thisObject());" << endl;
972 stream << " QString result;" << endl;
972 stream << " QString result;" << endl;
973 stream << " for (int i = 0; i < " << uniqueIndexes.size() << "; ++i) {" << endl
973 stream << " for (int i = 0; i < " << uniqueIndexes.size() << "; ++i) {" << endl
974 << " if ((value & qtscript_" << qtScriptEnumName << "_values[i])"
974 << " if ((value & qtscript_" << qtScriptEnumName << "_values[i])"
975 << " == qtscript_" << qtScriptEnumName << "_values[i]) {" << endl
975 << " == qtscript_" << qtScriptEnumName << "_values[i]) {" << endl
976 << " if (!result.isEmpty())" << endl
976 << " if (!result.isEmpty())" << endl
977 << " result.append(QString::fromLatin1(\",\"));" << endl
977 << " result.append(QString::fromLatin1(\",\"));" << endl
978 << " result.append(QString::fromLatin1(qtscript_" << qtScriptEnumName << "_keys[i]));" << endl
978 << " result.append(QString::fromLatin1(qtscript_" << qtScriptEnumName << "_keys[i]));" << endl
979 << " }" << endl
979 << " }" << endl
980 << " }" << endl
980 << " }" << endl
981 << " return QScriptValue(engine, result);" << endl
981 << " return QScriptValue(engine, result);" << endl
982 << "}" << endl
982 << "}" << endl
983 << endl;
983 << endl;
984
984
985 // write prototype.equals()
985 // write prototype.equals()
986 stream << "static QScriptValue qtscript_" << qtScriptFlagsName
986 stream << "static QScriptValue qtscript_" << qtScriptFlagsName
987 << "_equals(QScriptContext *context, QScriptEngine *engine)" << endl
987 << "_equals(QScriptContext *context, QScriptEngine *engine)" << endl
988 << "{" << endl
988 << "{" << endl
989 << " QVariant thisObj = context->thisObject().toVariant();" << endl
989 << " QVariant thisObj = context->thisObject().toVariant();" << endl
990 << " QVariant otherObj = context->argument(0).toVariant();" << endl
990 << " QVariant otherObj = context->argument(0).toVariant();" << endl
991
991
992 << " return QScriptValue(engine, ((thisObj.userType() == otherObj.userType()) &&" << endl
992 << " return QScriptValue(engine, ((thisObj.userType() == otherObj.userType()) &&" << endl
993 << " (thisObj.value<" << qualifiedFlagsName << ">() == otherObj.value<" << qualifiedFlagsName << ">())));" << endl
993 << " (thisObj.value<" << qualifiedFlagsName << ">() == otherObj.value<" << qualifiedFlagsName << ">())));" << endl
994 << "}" << endl << endl;
994 << "}" << endl << endl;
995
995
996 // write class creation function
996 // write class creation function
997 stream << "static QScriptValue qtscript_create_" << qtScriptFlagsName << "_class(QScriptEngine *engine)" << endl;
997 stream << "static QScriptValue qtscript_create_" << qtScriptFlagsName << "_class(QScriptEngine *engine)" << endl;
998 stream << "{" << endl;
998 stream << "{" << endl;
999 stream << " QScriptValue ctor = qtscript_create_flags_class_helper(" << endl
999 stream << " QScriptValue ctor = qtscript_create_flags_class_helper(" << endl
1000 << " engine, qtscript_construct_" << qtScriptFlagsName
1000 << " engine, qtscript_construct_" << qtScriptFlagsName
1001 << ", qtscript_" << qtScriptFlagsName << "_valueOf," << endl
1001 << ", qtscript_" << qtScriptFlagsName << "_valueOf," << endl
1002 << " qtscript_" << qtScriptFlagsName << "_toString, qtscript_"
1002 << " qtscript_" << qtScriptFlagsName << "_toString, qtscript_"
1003 << qtScriptFlagsName << "_equals);" << endl;
1003 << qtScriptFlagsName << "_equals);" << endl;
1004
1004
1005 stream << " qScriptRegisterMetaType<" << qualifiedFlagsName << ">(engine, "
1005 stream << " qScriptRegisterMetaType<" << qualifiedFlagsName << ">(engine, "
1006 << "qtscript_" << qtScriptFlagsName << "_toScriptValue," << endl
1006 << "qtscript_" << qtScriptFlagsName << "_toScriptValue," << endl
1007 << " qtscript_" << qtScriptFlagsName << "_fromScriptValue,"
1007 << " qtscript_" << qtScriptFlagsName << "_fromScriptValue,"
1008 << " ctor.property(QString::fromLatin1(\"prototype\")));" << endl;
1008 << " ctor.property(QString::fromLatin1(\"prototype\")));" << endl;
1009
1009
1010 stream << " return ctor;" << endl;
1010 stream << " return ctor;" << endl;
1011 stream << "}" << endl;
1011 stream << "}" << endl;
1012 stream << endl;
1012 stream << endl;
1013 }
1013 }
1014
1014
1015 /*!
1015 /*!
1016 Declares the given \a typeName if it hasn't been declared already,
1016 Declares the given \a typeName if it hasn't been declared already,
1017 and adds it to the set of registered type names.
1017 and adds it to the set of registered type names.
1018 */
1018 */
1019 void maybeDeclareMetaType(QTextStream &stream, const QString &typeName,
1019 void maybeDeclareMetaType(QTextStream &stream, const QString &typeName,
1020 QSet<QString> &registeredTypeNames)
1020 QSet<QString> &registeredTypeNames)
1021 {
1021 {
1022 QString name = typeName;
1022 QString name = typeName;
1023 if (name.endsWith(QLatin1Char('&')))
1023 if (name.endsWith(QLatin1Char('&')))
1024 name.chop(1);
1024 name.chop(1);
1025 if (registeredTypeNames.contains(name) || (QMetaType::type(typeName.toLatin1()) != 0))
1025 if (registeredTypeNames.contains(name) || (QMetaType::type(typeName.toLatin1()) != 0))
1026 return;
1026 return;
1027 if (name.contains(QLatin1Char(','))) {
1027 if (name.contains(QLatin1Char(','))) {
1028 // need to expand the Q_DECLARE_METATYPE macro manually,
1028 // need to expand the Q_DECLARE_METATYPE macro manually,
1029 // otherwise the compiler will choke
1029 // otherwise the compiler will choke
1030 stream << "template <> \\" << endl
1030 stream << "template <> \\" << endl
1031 << "struct QMetaTypeId< " << name << " > \\" << endl
1031 << "struct QMetaTypeId< " << name << " > \\" << endl
1032 << "{ \\" << endl
1032 << "{ \\" << endl
1033 << " enum { Defined = 1 }; \\" << endl
1033 << " enum { Defined = 1 }; \\" << endl
1034 << " static int qt_metatype_id() \\" << endl
1034 << " static int qt_metatype_id() \\" << endl
1035 << " { \\" << endl
1035 << " { \\" << endl
1036 << " static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0); \\" << endl
1036 << " static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0); \\" << endl
1037 << " if (!metatype_id) \\" << endl
1037 << " if (!metatype_id) \\" << endl
1038 << " metatype_id = qRegisterMetaType< " << name << " >(\"" << name << "\"); \\" << endl
1038 << " metatype_id = qRegisterMetaType< " << name << " >(\"" << name << "\"); \\" << endl
1039 << " return metatype_id; \\" << endl
1039 << " return metatype_id; \\" << endl
1040 << " } \\" << endl
1040 << " } \\" << endl
1041 << "};" << endl;
1041 << "};" << endl;
1042 } else {
1042 } else {
1043 stream << "Q_DECLARE_METATYPE(" << name << ")" << endl;
1043 stream << "Q_DECLARE_METATYPE(" << name << ")" << endl;
1044 }
1044 }
1045 registeredTypeNames << name;
1045 registeredTypeNames << name;
1046 }
1046 }
1047
1047
1048 /*!
1048 /*!
1049 Declares the given \a type recursively (i.e. subtypes of a composite
1049 Declares the given \a type recursively (i.e. subtypes of a composite
1050 type are also declared).
1050 type are also declared).
1051 */
1051 */
1052 static void declareTypeRecursive(QTextStream &stream, const AbstractMetaType *type,
1052 static void declareTypeRecursive(QTextStream &stream, const AbstractMetaType *type,
1053 QSet<QString> &registeredTypeNames)
1053 QSet<QString> &registeredTypeNames)
1054 {
1054 {
1055 if (!type)
1055 if (!type)
1056 return;
1056 return;
1057 QList<AbstractMetaType *> subTypes = type->instantiations();
1057 QList<AbstractMetaType *> subTypes = type->instantiations();
1058 for (int i = 0; i < subTypes.size(); ++i)
1058 for (int i = 0; i < subTypes.size(); ++i)
1059 declareTypeRecursive(stream, subTypes.at(i), registeredTypeNames);
1059 declareTypeRecursive(stream, subTypes.at(i), registeredTypeNames);
1060 QString typeName = normalizedType(type);
1060 QString typeName = normalizedType(type);
1061 if (typeName == QLatin1String("QStringList<QString>"))
1061 if (typeName == QLatin1String("QStringList<QString>"))
1062 return; // ### wtf...
1062 return; // ### wtf...
1063 maybeDeclareMetaType(stream, typeName, registeredTypeNames);
1063 maybeDeclareMetaType(stream, typeName, registeredTypeNames);
1064 }
1064 }
1065
1065
1066 /*!
1066 /*!
1067 Declares the types associated with the given \a functions.
1067 Declares the types associated with the given \a functions.
1068 */
1068 */
1069 void declareFunctionMetaTypes(QTextStream &stream, const AbstractMetaFunctionList &functions,
1069 void declareFunctionMetaTypes(QTextStream &stream, const AbstractMetaFunctionList &functions,
1070 QSet<QString> &registeredTypeNames)
1070 QSet<QString> &registeredTypeNames)
1071 {
1071 {
1072 for (int i = 0; i < functions.size(); ++i) {
1072 for (int i = 0; i < functions.size(); ++i) {
1073 AbstractMetaFunction *fun = functions.at(i);
1073 AbstractMetaFunction *fun = functions.at(i);
1074 if (ClassGenerator::isSpecialStreamingOperator(fun)) {
1074 if (ClassGenerator::isSpecialStreamingOperator(fun)) {
1075 maybeDeclareMetaType(stream, fun->arguments().at(0)->type()->name() + "*",
1075 maybeDeclareMetaType(stream, fun->arguments().at(0)->type()->name() + "*",
1076 registeredTypeNames);
1076 registeredTypeNames);
1077 continue;
1077 continue;
1078 }
1078 }
1079 AbstractMetaArgumentList arguments = fun->arguments();
1079 AbstractMetaArgumentList arguments = fun->arguments();
1080 for (int j = 0; j < arguments.size(); ++j) {
1080 for (int j = 0; j < arguments.size(); ++j) {
1081 if (fun->argumentRemoved(j+1))
1081 if (fun->argumentRemoved(j+1))
1082 continue;
1082 continue;
1083 QString repl = fun->typeReplaced(j+1);
1083 QString repl = fun->typeReplaced(j+1);
1084 if (!repl.isEmpty()) {
1084 if (!repl.isEmpty()) {
1085 maybeDeclareMetaType(stream, repl, registeredTypeNames);
1085 maybeDeclareMetaType(stream, repl, registeredTypeNames);
1086 } else {
1086 } else {
1087 const AbstractMetaArgument *arg = arguments.at(j);
1087 const AbstractMetaArgument *arg = arguments.at(j);
1088 declareTypeRecursive(stream, arg->type(), registeredTypeNames);
1088 declareTypeRecursive(stream, arg->type(), registeredTypeNames);
1089 }
1089 }
1090 }
1090 }
1091 QString retRepl = fun->typeReplaced(0);
1091 QString retRepl = fun->typeReplaced(0);
1092 if (!retRepl.isEmpty())
1092 if (!retRepl.isEmpty())
1093 maybeDeclareMetaType(stream, retRepl, registeredTypeNames);
1093 maybeDeclareMetaType(stream, retRepl, registeredTypeNames);
1094 else
1094 else
1095 declareTypeRecursive(stream, fun->type(), registeredTypeNames);
1095 declareTypeRecursive(stream, fun->type(), registeredTypeNames);
1096 }
1096 }
1097 }
1097 }
1098
1098
1099 /*!
1099 /*!
1100 Returns true if we don't care about the given enum \a enom,
1100 Returns true if we don't care about the given enum \a enom,
1101 false otherwise.
1101 false otherwise.
1102 */
1102 */
1103 static bool shouldIgnoreEnum(const AbstractMetaEnum *enom)
1103 static bool shouldIgnoreEnum(const AbstractMetaEnum *enom)
1104 {
1104 {
1105 return !enom->wasPublic() || (enom->name() == "enum_1");
1105 return !enom->wasPublic() || (enom->name() == "enum_1");
1106 }
1106 }
1107
1107
1108 /*!
1108 /*!
1109 Declares the types associated with the enums of the given \a
1109 Declares the types associated with the enums of the given \a
1110 meta_class.
1110 meta_class.
1111 */
1111 */
1112 void declareEnumMetaTypes(QTextStream &stream, const AbstractMetaClass *meta_class,
1112 void declareEnumMetaTypes(QTextStream &stream, const AbstractMetaClass *meta_class,
1113 QSet<QString> &registeredTypeNames)
1113 QSet<QString> &registeredTypeNames)
1114 {
1114 {
1115 AbstractMetaEnumList enums = meta_class->enums();
1115 AbstractMetaEnumList enums = meta_class->enums();
1116 for (int i = 0; i < enums.size(); ++i) {
1116 for (int i = 0; i < enums.size(); ++i) {
1117 const AbstractMetaEnum *enom = enums.at(i);
1117 const AbstractMetaEnum *enom = enums.at(i);
1118 if (shouldIgnoreEnum(enom))
1118 if (shouldIgnoreEnum(enom))
1119 continue;
1119 continue;
1120 maybeDeclareMetaType(stream, QString::fromLatin1("%0::%1")
1120 maybeDeclareMetaType(stream, QString::fromLatin1("%0::%1")
1121 .arg(meta_class->qualifiedCppName()).arg(enom->name()),
1121 .arg(meta_class->qualifiedCppName()).arg(enom->name()),
1122 registeredTypeNames);
1122 registeredTypeNames);
1123 FlagsTypeEntry *flags = enom->typeEntry()->flags();
1123 FlagsTypeEntry *flags = enom->typeEntry()->flags();
1124 if (flags) {
1124 if (flags) {
1125 maybeDeclareMetaType(stream, QString::fromLatin1("QFlags<%0::%1>")
1125 maybeDeclareMetaType(stream, QString::fromLatin1("QFlags<%0::%1>")
1126 .arg(meta_class->qualifiedCppName()).arg(enom->name()),
1126 .arg(meta_class->qualifiedCppName()).arg(enom->name()),
1127 registeredTypeNames);
1127 registeredTypeNames);
1128 }
1128 }
1129 }
1129 }
1130 }
1130 }
1131
1131
1132 /*!
1132 /*!
1133 Returns the maximum function length among \a functions.
1133 Returns the maximum function length among \a functions.
1134 */
1134 */
1135 static int maxFunctionLength(const AbstractMetaFunctionList &functions)
1135 static int maxFunctionLength(const AbstractMetaFunctionList &functions)
1136 {
1136 {
1137 int result = 0;
1137 int result = 0;
1138 for (int i = 0; i < functions.size(); ++i)
1138 for (int i = 0; i < functions.size(); ++i)
1139 result = qMax(result, functions.at(i)->arguments().size());
1139 result = qMax(result, functions.at(i)->arguments().size());
1140 return result;
1140 return result;
1141 }
1141 }
1142
1142
1143 /*!
1143 /*!
1144 Writes a prototype/static function.
1144 Writes a prototype/static function.
1145 */
1145 */
1146 static void writeFunctionForwarding(QTextStream &stream, const AbstractMetaClass *meta_class,
1146 static void writeFunctionForwarding(QTextStream &stream, const AbstractMetaClass *meta_class,
1147 const AbstractMetaFunctionList &functions)
1147 const AbstractMetaFunctionList &functions)
1148 {
1148 {
1149 #if 0
1149 #if 0
1150 stream << "/** signatures:" << endl;
1150 stream << "/** signatures:" << endl;
1151 foreach (const AbstractMetaFunction *fun, functions) {
1151 foreach (const AbstractMetaFunction *fun, functions) {
1152 stream << " * " << fun->signature() << endl;
1152 stream << " * " << fun->signature() << endl;
1153 }
1153 }
1154 stream << " */" << endl;
1154 stream << " */" << endl;
1155 #endif
1155 #endif
1156 QMap<int, AbstractMetaFunctionList> argcToFunctions;
1156 QMap<int, AbstractMetaFunctionList> argcToFunctions;
1157 argcToFunctions = createArgcToFunctionsMap(functions);
1157 argcToFunctions = createArgcToFunctionsMap(functions);
1158 QSet<QString> signatures;
1158 QSet<QString> signatures;
1159 int argcMin = argcToFunctions.keys().first();
1159 int argcMin = argcToFunctions.keys().first();
1160 int argcMax = argcToFunctions.keys().last();
1160 int argcMax = argcToFunctions.keys().last();
1161 for (int i = argcMin; i <= argcMax; ++i) {
1161 for (int i = argcMin; i <= argcMax; ++i) {
1162 AbstractMetaFunctionList funcs = argcToFunctions.value(i);
1162 AbstractMetaFunctionList funcs = argcToFunctions.value(i);
1163 if (funcs.isEmpty())
1163 if (funcs.isEmpty())
1164 continue;
1164 continue;
1165 stream << " if (context->argumentCount() == " << i << ") {" << endl;
1165 stream << " if (context->argumentCount() == " << i << ") {" << endl;
1166 if (funcs.size() == 1) {
1166 if (funcs.size() == 1) {
1167 AbstractMetaFunction *fun = funcs.at(0);
1167 AbstractMetaFunction *fun = funcs.at(0);
1168 const int indent = 8;
1168 const int indent = 8;
1169 // special case for Q{Data,Text}Stream streaming operators
1169 // special case for Q{Data,Text}Stream streaming operators
1170 if (ClassGenerator::isSpecialStreamingOperator(fun))
1170 if (ClassGenerator::isSpecialStreamingOperator(fun))
1171 writeStreamingOperatorCall(stream, fun, meta_class, indent);
1171 writeStreamingOperatorCall(stream, fun, meta_class, indent);
1172 else
1172 else
1173 writeFunctionCallAndReturn(stream, fun, i, meta_class, indent);
1173 writeFunctionCallAndReturn(stream, fun, i, meta_class, indent);
1174 signatures.insert(fun->targetLangSignature());
1174 signatures.insert(fun->targetLangSignature());
1175 } else {
1175 } else {
1176 // handle overloads
1176 // handle overloads
1177 QStringList sigs;
1177 QStringList sigs;
1178 for (int j = 0; j < funcs.size(); ++j) {
1178 for (int j = 0; j < funcs.size(); ++j) {
1179 AbstractMetaFunction *fun = funcs.at(j);
1179 AbstractMetaFunction *fun = funcs.at(j);
1180 sigs.append(fun->signature());
1180 sigs.append(fun->signature());
1181 stream << " ";
1181 stream << " ";
1182 if (j > 0)
1182 if (j > 0)
1183 stream << "} else ";
1183 stream << "} else ";
1184 stream << "if (";
1184 stream << "if (";
1185 AbstractMetaArgumentList arguments = fun->arguments();
1185 AbstractMetaArgumentList arguments = fun->arguments();
1186 const int indent = 12;
1186 const int indent = 12;
1187 writeArgumentTypeTests(stream, fun, arguments, i, indent);
1187 writeArgumentTypeTests(stream, fun, arguments, i, indent);
1188 stream << ") {" << endl;
1188 stream << ") {" << endl;
1189 writeFunctionCallAndReturn(stream, fun, i, meta_class, indent);
1189 writeFunctionCallAndReturn(stream, fun, i, meta_class, indent);
1190 signatures.insert(fun->targetLangSignature());
1190 signatures.insert(fun->targetLangSignature());
1191 }
1191 }
1192 stream << " }" << endl;
1192 stream << " }" << endl;
1193 }
1193 }
1194 stream << " }" << endl;
1194 stream << " }" << endl;
1195 }
1195 }
1196 }
1196 }
1197
1197
1198 static void writePrototypeCall(QTextStream &s, const AbstractMetaClass *meta_class,
1198 static void writePrototypeCall(QTextStream &s, const AbstractMetaClass *meta_class,
1199 const QMap<QString, AbstractMetaFunctionList> &nameToFunctions,
1199 const QMap<QString, AbstractMetaFunctionList> &nameToFunctions,
1200 int prototypeFunctionsOffset)
1200 int prototypeFunctionsOffset)
1201 {
1201 {
1202 s << "static QScriptValue qtscript_" << meta_class->name()
1202 s << "static QScriptValue qtscript_" << meta_class->name()
1203 << "_prototype_call(QScriptContext *context, QScriptEngine *)" << endl
1203 << "_prototype_call(QScriptContext *context, QScriptEngine *)" << endl
1204 << "{" << endl;
1204 << "{" << endl;
1205
1205
1206 s << "#if QT_VERSION > 0x040400" << endl;
1206 s << "#if QT_VERSION > 0x040400" << endl;
1207
1207
1208 s << " Q_ASSERT(context->callee().isFunction());" << endl
1208 s << " Q_ASSERT(context->callee().isFunction());" << endl
1209 << " uint _id = context->callee().data().toUInt32();" << endl;
1209 << " uint _id = context->callee().data().toUInt32();" << endl;
1210
1210
1211 s << "#else" << endl
1211 s << "#else" << endl
1212 << " uint _id;" << endl
1212 << " uint _id;" << endl
1213 << " if (context->callee().isFunction())" << endl
1213 << " if (context->callee().isFunction())" << endl
1214 << " _id = context->callee().data().toUInt32();" << endl
1214 << " _id = context->callee().data().toUInt32();" << endl
1215 << " else" << endl
1215 << " else" << endl
1216 << " _id = 0xBABE0000 + " << nameToFunctions.size() << ";" << endl;
1216 << " _id = 0xBABE0000 + " << nameToFunctions.size() << ";" << endl;
1217
1217
1218 s << "#endif" << endl;
1218 s << "#endif" << endl;
1219
1219
1220 s << " Q_ASSERT((_id & 0xFFFF0000) == 0xBABE0000);" << endl
1220 s << " Q_ASSERT((_id & 0xFFFF0000) == 0xBABE0000);" << endl
1221 << " _id &= 0x0000FFFF;" << endl;
1221 << " _id &= 0x0000FFFF;" << endl;
1222
1222
1223 // cast the thisObject to C++ type
1223 // cast the thisObject to C++ type
1224 s << " ";
1224 s << " ";
1225 #ifndef GENERATOR_NO_PROTECTED_FUNCTIONS
1225 #ifndef GENERATOR_NO_PROTECTED_FUNCTIONS
1226 if (meta_class->hasProtectedFunctions())
1226 if (meta_class->hasProtectedFunctions())
1227 s << "qtscript_";
1227 s << "qtscript_";
1228 #endif
1228 #endif
1229 s << meta_class->qualifiedCppName() << "* _q_self = ";
1229 s << meta_class->qualifiedCppName() << "* _q_self = ";
1230 #ifndef GENERATOR_NO_PROTECTED_FUNCTIONS
1230 #ifndef GENERATOR_NO_PROTECTED_FUNCTIONS
1231 if (meta_class->hasProtectedFunctions())
1231 if (meta_class->hasProtectedFunctions())
1232 s << "reinterpret_cast<qtscript_" << meta_class->name() << "*>(";
1232 s << "reinterpret_cast<qtscript_" << meta_class->name() << "*>(";
1233 #endif
1233 #endif
1234 s << "qscriptvalue_cast<" << meta_class->qualifiedCppName()
1234 s << "qscriptvalue_cast<" << meta_class->qualifiedCppName()
1235 << "*>(context->thisObject())";
1235 << "*>(context->thisObject())";
1236 #ifndef GENERATOR_NO_PROTECTED_FUNCTIONS
1236 #ifndef GENERATOR_NO_PROTECTED_FUNCTIONS
1237 if (meta_class->hasProtectedFunctions())
1237 if (meta_class->hasProtectedFunctions())
1238 s << ")";
1238 s << ")";
1239 #endif
1239 #endif
1240 s << ";" << endl
1240 s << ";" << endl
1241 << " if (!_q_self) {" << endl
1241 << " if (!_q_self) {" << endl
1242 << " return context->throwError(QScriptContext::TypeError," << endl
1242 << " return context->throwError(QScriptContext::TypeError," << endl
1243 << " QString::fromLatin1(\"" << meta_class->name()
1243 << " QString::fromLatin1(\"" << meta_class->name()
1244 << ".%0(): this object is not a " << meta_class->name() << "\")" << endl
1244 << ".%0(): this object is not a " << meta_class->name() << "\")" << endl
1245 << " .arg(qtscript_" << meta_class->name()
1245 << " .arg(qtscript_" << meta_class->name()
1246 << "_function_names[_id+" << prototypeFunctionsOffset <<"]));" << endl
1246 << "_function_names[_id+" << prototypeFunctionsOffset <<"]));" << endl
1247 << " }" << endl << endl;
1247 << " }" << endl << endl;
1248
1248
1249 s << " switch (_id) {" << endl;
1249 s << " switch (_id) {" << endl;
1250
1250
1251 QMap<QString, AbstractMetaFunctionList>::const_iterator it;
1251 QMap<QString, AbstractMetaFunctionList>::const_iterator it;
1252 int index = 0;
1252 int index = 0;
1253 for (it = nameToFunctions.constBegin(); it != nameToFunctions.constEnd(); ++it) {
1253 for (it = nameToFunctions.constBegin(); it != nameToFunctions.constEnd(); ++it) {
1254 s << " case " << index << ":" << endl;
1254 s << " case " << index << ":" << endl;
1255 writeFunctionForwarding(s, meta_class, it.value());
1255 writeFunctionForwarding(s, meta_class, it.value());
1256 s << " break;" << endl << endl;
1256 s << " break;" << endl << endl;
1257 ++index;
1257 ++index;
1258 }
1258 }
1259
1259
1260 if (!meta_class->hasDefaultToStringFunction()) {
1260 if (!meta_class->hasDefaultToStringFunction()) {
1261 s << " case " << index << ": {" << endl;
1261 s << " case " << index << ": {" << endl;
1262 s << " QString result";
1262 s << " QString result";
1263 FunctionModelItem fun = meta_class->hasToStringCapability();
1263 FunctionModelItem fun = meta_class->hasToStringCapability();
1264 if (fun) {
1264 if (fun) {
1265 int indirections = fun->arguments().at(1)->type().indirections();
1265 int indirections = fun->arguments().at(1)->type().indirections();
1266 QString deref = QLatin1String(indirections == 0 ? "*" : "");
1266 QString deref = QLatin1String(indirections == 0 ? "*" : "");
1267 s << ";" << endl
1267 s << ";" << endl
1268 << " QDebug d(&result);" << endl
1268 << " QDebug d(&result);" << endl
1269 << " d << " << deref << "_q_self;" << endl;
1269 << " d << " << deref << "_q_self;" << endl;
1270 } else {
1270 } else {
1271 // ### FIXME: can cause compile error
1271 // ### FIXME: can cause compile error
1272 // s << "=QString(\"" << meta_class->name() << "(0x%1)\").arg((int)_q_self, 0, 16);" << endl;
1272 // s << "=QString(\"" << meta_class->name() << "(0x%1)\").arg((int)_q_self, 0, 16);" << endl;
1273 s << " = QString::fromLatin1(\"" << meta_class->name() << "\");" << endl;
1273 s << " = QString::fromLatin1(\"" << meta_class->name() << "\");" << endl;
1274 }
1274 }
1275 s << " return QScriptValue(context->engine(), result);" << endl
1275 s << " return QScriptValue(context->engine(), result);" << endl
1276 << " }" << endl << endl;
1276 << " }" << endl << endl;
1277 }
1277 }
1278
1278
1279 s << " default:" << endl
1279 s << " default:" << endl
1280 << " Q_ASSERT(false);" << endl
1280 << " Q_ASSERT(false);" << endl
1281 << " }" << endl;
1281 << " }" << endl;
1282
1282
1283 s << " return qtscript_" << meta_class->name() << "_throw_ambiguity_error_helper(context," << endl
1283 s << " return qtscript_" << meta_class->name() << "_throw_ambiguity_error_helper(context," << endl
1284 << " qtscript_" << meta_class->name()
1284 << " qtscript_" << meta_class->name()
1285 << "_function_names[_id+" << prototypeFunctionsOffset << "]," << endl
1285 << "_function_names[_id+" << prototypeFunctionsOffset << "]," << endl
1286 << " qtscript_" << meta_class->name()
1286 << " qtscript_" << meta_class->name()
1287 << "_function_signatures[_id+" << prototypeFunctionsOffset << "]);" << endl;
1287 << "_function_signatures[_id+" << prototypeFunctionsOffset << "]);" << endl;
1288
1288
1289 s << "}" << endl << endl;
1289 s << "}" << endl << endl;
1290 }
1290 }
1291
1291
1292 static void writeStaticCall(QTextStream &s, const AbstractMetaClass *meta_class,
1292 static void writeStaticCall(QTextStream &s, const AbstractMetaClass *meta_class,
1293 const AbstractMetaFunctionList &constructors,
1293 const AbstractMetaFunctionList &constructors,
1294 const QMap<QString, AbstractMetaFunctionList> &nameToFunctions)
1294 const QMap<QString, AbstractMetaFunctionList> &nameToFunctions)
1295 {
1295 {
1296 s << "static QScriptValue qtscript_" << meta_class->name()
1296 s << "static QScriptValue qtscript_" << meta_class->name()
1297 << "_static_call(QScriptContext *context, QScriptEngine *)" << endl
1297 << "_static_call(QScriptContext *context, QScriptEngine *)" << endl
1298 << "{" << endl;
1298 << "{" << endl;
1299
1299
1300 s << " uint _id = context->callee().data().toUInt32();" << endl
1300 s << " uint _id = context->callee().data().toUInt32();" << endl
1301 << " Q_ASSERT((_id & 0xFFFF0000) == 0xBABE0000);" << endl
1301 << " Q_ASSERT((_id & 0xFFFF0000) == 0xBABE0000);" << endl
1302 << " _id &= 0x0000FFFF;" << endl;
1302 << " _id &= 0x0000FFFF;" << endl;
1303
1303
1304 s << " switch (_id) {" << endl;
1304 s << " switch (_id) {" << endl;
1305
1305
1306 s << " case 0:" << endl;
1306 s << " case 0:" << endl;
1307 writeConstructorForwarding(s, constructors, meta_class);
1307 writeConstructorForwarding(s, constructors, meta_class);
1308 s << " break;" << endl << endl;
1308 s << " break;" << endl << endl;
1309
1309
1310 QMap<QString, AbstractMetaFunctionList>::const_iterator it;
1310 QMap<QString, AbstractMetaFunctionList>::const_iterator it;
1311 int index = 1;
1311 int index = 1;
1312 for (it = nameToFunctions.constBegin(); it != nameToFunctions.constEnd(); ++it) {
1312 for (it = nameToFunctions.constBegin(); it != nameToFunctions.constEnd(); ++it) {
1313 s << " case " << index << ":" << endl;
1313 s << " case " << index << ":" << endl;
1314 writeFunctionForwarding(s, meta_class, it.value());
1314 writeFunctionForwarding(s, meta_class, it.value());
1315 s << " break;" << endl << endl;
1315 s << " break;" << endl << endl;
1316 ++index;
1316 ++index;
1317 }
1317 }
1318
1318
1319 s << " default:" << endl
1319 s << " default:" << endl
1320 << " Q_ASSERT(false);" << endl
1320 << " Q_ASSERT(false);" << endl
1321 << " }" << endl;
1321 << " }" << endl;
1322
1322
1323 s << " return qtscript_" << meta_class->name() << "_throw_ambiguity_error_helper(context," << endl
1323 s << " return qtscript_" << meta_class->name() << "_throw_ambiguity_error_helper(context," << endl
1324 << " qtscript_" << meta_class->name() << "_function_names[_id]," << endl
1324 << " qtscript_" << meta_class->name() << "_function_names[_id]," << endl
1325 << " qtscript_" << meta_class->name() << "_function_signatures[_id]);" << endl;
1325 << " qtscript_" << meta_class->name() << "_function_signatures[_id]);" << endl;
1326
1326
1327 s << "}" << endl << endl;
1327 s << "}" << endl << endl;
1328 }
1328 }
1329
1329
1330 /*!
1330 /*!
1331 Writes the include defined by \a inc to \a stream.
1331 Writes the include defined by \a inc to \a stream.
1332 */
1332 */
1333 void ClassGenerator::writeInclude(QTextStream &stream, const Include &inc)
1333 void ClassGenerator::writeInclude(QTextStream &stream, const Include &inc)
1334 {
1334 {
1335 if (inc.name.isEmpty())
1335 if (inc.name.isEmpty())
1336 return;
1336 return;
1337 if (inc.type == Include::TargetLangImport)
1337 if (inc.type == Include::TargetLangImport)
1338 return;
1338 return;
1339 stream << "#include ";
1339 stream << "#include ";
1340 if (inc.type == Include::IncludePath)
1340 if (inc.type == Include::IncludePath)
1341 stream << "<";
1341 stream << "<";
1342 else
1342 else
1343 stream << "\"";
1343 stream << "\"";
1344 stream << inc.name;
1344 stream << inc.name;
1345 if (inc.type == Include::IncludePath)
1345 if (inc.type == Include::IncludePath)
1346 stream << ">";
1346 stream << ">";
1347 else
1347 else
1348 stream << "\"";
1348 stream << "\"";
1349 stream << endl;
1349 stream << endl;
1350 }
1350 }
1351
1351
1352 static void writeHelperFunctions(QTextStream &stream, const AbstractMetaClass *meta_class)
1352 static void writeHelperFunctions(QTextStream &stream, const AbstractMetaClass *meta_class)
1353 {
1353 {
1354 stream << "static QScriptValue qtscript_" << meta_class->name() << "_throw_ambiguity_error_helper(" << endl
1354 stream << "static QScriptValue qtscript_" << meta_class->name() << "_throw_ambiguity_error_helper(" << endl
1355 << " QScriptContext *context, const char *functionName, const char *signatures)" << endl
1355 << " QScriptContext *context, const char *functionName, const char *signatures)" << endl
1356 << "{" << endl
1356 << "{" << endl
1357 << " QStringList lines = QString::fromLatin1(signatures).split(QLatin1Char('\\n'));" << endl
1357 << " QStringList lines = QString::fromLatin1(signatures).split(QLatin1Char('\\n'));" << endl
1358 << " QStringList fullSignatures;" << endl
1358 << " QStringList fullSignatures;" << endl
1359 << " for (int i = 0; i < lines.size(); ++i)" << endl
1359 << " for (int i = 0; i < lines.size(); ++i)" << endl
1360 << " fullSignatures.append(QString::fromLatin1(\"%0(%1)\").arg(functionName).arg(lines.at(i)));" << endl
1360 << " fullSignatures.append(QString::fromLatin1(\"%0(%1)\").arg(functionName).arg(lines.at(i)));" << endl
1361 << " return context->throwError(QString::fromLatin1(\"" << meta_class->name()
1361 << " return context->throwError(QString::fromLatin1(\"" << meta_class->name()
1362 << "::%0(): could not find a function match; candidates are:\\n%1\")" << endl
1362 << "::%0(): could not find a function match; candidates are:\\n%1\")" << endl
1363 << " .arg(functionName).arg(fullSignatures.join(QLatin1String(\"\\n\"))));" << endl
1363 << " .arg(functionName).arg(fullSignatures.join(QLatin1String(\"\\n\"))));" << endl
1364 << "}" << endl << endl;
1364 << "}" << endl << endl;
1365 }
1365 }
1366
1366
1367 void writeQtScriptQtBindingsLicense(QTextStream &stream)
1367 void writeQtScriptQtBindingsLicense(QTextStream &stream)
1368 {
1368 {
1369 stream
1369 stream
1370 << "/****************************************************************************" << endl
1370 << "/****************************************************************************" << endl
1371 << "**" << endl
1371 << "**" << endl
1372 << "** Copyright (C) 2008 Trolltech ASA. All rights reserved." << endl
1372 << "** Copyright (C) 2008 Trolltech ASA. All rights reserved." << endl
1373 << "**" << endl
1373 << "**" << endl
1374 << "** This file is part of the Qt Script Qt Bindings project on Trolltech Labs." << endl
1374 << "** This file is part of the Qt Script Qt Bindings project on Trolltech Labs." << endl
1375 << "**" << endl
1375 << "**" << endl
1376 << "** This file may be used under the terms of the GNU General Public" << endl
1376 << "** This file may be used under the terms of the GNU General Public" << endl
1377 << "** License version 2.0 as published by the Free Software Foundation" << endl
1377 << "** License version 2.0 as published by the Free Software Foundation" << endl
1378 << "** and appearing in the file LICENSE.GPL included in the packaging of" << endl
1378 << "** and appearing in the file LICENSE.GPL included in the packaging of" << endl
1379 << "** this file. Please review the following information to ensure GNU" << endl
1379 << "** this file. Please review the following information to ensure GNU" << endl
1380 << "** General Public Licensing requirements will be met:" << endl
1380 << "** General Public Licensing requirements will be met:" << endl
1381 << "** http://www.trolltech.com/products/qt/opensource.html" << endl
1381 << "** http://www.trolltech.com/products/qt/opensource.html" << endl
1382 << "**" << endl
1382 << "**" << endl
1383 << "** If you are unsure which license is appropriate for your use, please" << endl
1383 << "** If you are unsure which license is appropriate for your use, please" << endl
1384 << "** review the following information:" << endl
1384 << "** review the following information:" << endl
1385 << "** http://www.trolltech.com/products/qt/licensing.html or contact the" << endl
1385 << "** http://www.trolltech.com/products/qt/licensing.html or contact the" << endl
1386 << "** sales department at sales@trolltech.com." << endl
1386 << "** sales department at sales@trolltech.com." << endl
1387 << "**" << endl
1387 << "**" << endl
1388 << "** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE" << endl
1388 << "** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE" << endl
1389 << "** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE." << endl
1389 << "** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE." << endl
1390 << "**" << endl
1390 << "**" << endl
1391 << "****************************************************************************/" << endl
1391 << "****************************************************************************/" << endl
1392 << endl;
1392 << endl;
1393 }
1393 }
1394
1394
1395 /*!
1395 /*!
1396 Finds the functions in \a meta_class that we actually want to
1396 Finds the functions in \a meta_class that we actually want to
1397 generate bindings for.
1397 generate bindings for.
1398 */
1398 */
1399 void findPrototypeAndStaticFunctions(
1399 void findPrototypeAndStaticFunctions(
1400 const AbstractMetaClass *meta_class,
1400 const AbstractMetaClass *meta_class,
1401 QMap<QString, AbstractMetaFunctionList> &nameToPrototypeFunctions,
1401 QMap<QString, AbstractMetaFunctionList> &nameToPrototypeFunctions,
1402 QMap<QString, AbstractMetaFunctionList> &nameToStaticFunctions)
1402 QMap<QString, AbstractMetaFunctionList> &nameToStaticFunctions)
1403 {
1403 {
1404 AbstractMetaFunctionList functions = meta_class->functionsInTargetLang();
1404 AbstractMetaFunctionList functions = meta_class->functionsInTargetLang();
1405 for (int i = 0; i < functions.size(); ++i) {
1405 for (int i = 0; i < functions.size(); ++i) {
1406 AbstractMetaFunction* func = functions.at(i);
1406 AbstractMetaFunction* func = functions.at(i);
1407 if (!func->isNormal())
1407 if (!func->isNormal())
1408 continue;
1408 continue;
1409 #ifdef GENERATOR_NO_PROTECTED_FUNCTIONS
1409 #ifdef GENERATOR_NO_PROTECTED_FUNCTIONS
1410 if (func->wasProtected())
1410 if (func->wasProtected())
1411 continue;
1411 continue;
1412 #endif
1412 #endif
1413 if (func->declaringClass() != meta_class)
1413 if (func->declaringClass() != meta_class)
1414 continue; // function inherited through prototype
1414 continue; // function inherited through prototype
1415 if (func->isPropertyReader() || func->isPropertyWriter())
1415 if (func->isPropertyReader() || func->isPropertyWriter())
1416 continue; // no point in including property accessors
1416 continue; // no point in including property accessors
1417 if (func->isSlot() || func->isSignal() || func->isInvokable())
1417 if (func->isSlot() || func->isSignal() || func->isInvokable())
1418 continue; // no point in including signals and slots
1418 continue; // no point in including signals and slots
1419 QMap<QString, AbstractMetaFunctionList> &map =
1419 QMap<QString, AbstractMetaFunctionList> &map =
1420 func->isStatic() ? nameToStaticFunctions : nameToPrototypeFunctions;
1420 func->isStatic() ? nameToStaticFunctions : nameToPrototypeFunctions;
1421 map[func->modifiedName()].append(func);
1421 map[func->modifiedName()].append(func);
1422 }
1422 }
1423 }
1423 }
1424
1424
1425 static void writeFunctionSignaturesString(QTextStream &s, const AbstractMetaFunctionList &functions)
1425 static void writeFunctionSignaturesString(QTextStream &s, const AbstractMetaFunctionList &functions)
1426 {
1426 {
1427 s << "\"";
1427 s << "\"";
1428 for (int i = 0; i < functions.size(); ++i) {
1428 for (int i = 0; i < functions.size(); ++i) {
1429 if (i > 0)
1429 if (i > 0)
1430 s << "\\n";
1430 s << "\\n";
1431 QString sig = functions.at(i)->targetLangSignature();
1431 QString sig = functions.at(i)->targetLangSignature();
1432 sig = sig.mid(sig.indexOf('(') + 1);
1432 sig = sig.mid(sig.indexOf('(') + 1);
1433 sig.chop(1);
1433 sig.chop(1);
1434 s << sig;
1434 s << sig;
1435 }
1435 }
1436 s << "\"";
1436 s << "\"";
1437 }
1437 }
1438
1438
1439 /*!
1439 /*!
1440 Writes the whole native binding for the class \a meta_class.
1440 Writes the whole native binding for the class \a meta_class.
1441 */
1441 */
1442 void ClassGenerator::write(QTextStream &stream, const AbstractMetaClass *meta_class)
1442 void ClassGenerator::write(QTextStream &stream, const AbstractMetaClass *meta_class)
1443 {
1443 {
1444 if (meta_class->name() == "Global") // ### hmmmmmm
1444 if (meta_class->name() == "Global") // ### hmmmmmm
1445 return;
1445 return;
1446
1446
1447 if (FileOut::license)
1447 if (FileOut::license)
1448 writeQtScriptQtBindingsLicense(stream);
1448 writeQtScriptQtBindingsLicense(stream);
1449
1449
1450 // write common includes
1450 // write common includes
1451 stream << "#include <QtScript/QScriptEngine>" << endl;
1451 stream << "#include <QtScript/QScriptEngine>" << endl;
1452 stream << "#include <QtScript/QScriptContext>" << endl;
1452 stream << "#include <QtScript/QScriptContext>" << endl;
1453 stream << "#include <QtScript/QScriptValue>" << endl;
1453 stream << "#include <QtScript/QScriptValue>" << endl;
1454 stream << "#include <QtCore/QStringList>" << endl;
1454 stream << "#include <QtCore/QStringList>" << endl;
1455 stream << "#include <QtCore/QDebug>" << endl;
1455 stream << "#include <QtCore/QDebug>" << endl;
1456 stream << "#include <qmetaobject.h>" << endl;
1456 stream << "#include <qmetaobject.h>" << endl;
1457 stream << endl;
1457 stream << endl;
1458
1458
1459 // write class-specific includes
1459 // write class-specific includes
1460 {
1460 {
1461 Include inc = meta_class->typeEntry()->include();
1461 Include inc = meta_class->typeEntry()->include();
1462 writeInclude(stream, inc);
1462 writeInclude(stream, inc);
1463 }
1463 }
1464 {
1464 {
1465 IncludeList includes = meta_class->typeEntry()->extraIncludes();
1465 IncludeList includes = meta_class->typeEntry()->extraIncludes();
1466 qSort(includes.begin(), includes.end());
1466 qSort(includes.begin(), includes.end());
1467
1467
1468 foreach (const Include &i, includes) {
1468 foreach (const Include &i, includes) {
1469 writeInclude(stream, i);
1469 writeInclude(stream, i);
1470 }
1470 }
1471 }
1471 }
1472 stream << endl;
1472 stream << endl;
1473
1473
1474 if (meta_class->generateShellClass()) {
1474 if (meta_class->generateShellClass()) {
1475 stream << "#include \"qtscriptshell_" << meta_class->name() << ".h\"" << endl;
1475 stream << "#include \"qtscriptshell_" << meta_class->name() << ".h\"" << endl;
1476 stream << endl;
1476 stream << endl;
1477 }
1477 }
1478
1478
1479 AbstractMetaEnumList enums = meta_class->enums();
1479 AbstractMetaEnumList enums = meta_class->enums();
1480 {
1480 {
1481 // kill the enums we don't care about
1481 // kill the enums we don't care about
1482 AbstractMetaEnumList::iterator it;
1482 AbstractMetaEnumList::iterator it;
1483 for (it = enums.begin(); it != enums.end(); ) {
1483 for (it = enums.begin(); it != enums.end(); ) {
1484 if (shouldIgnoreEnum(*it))
1484 if (shouldIgnoreEnum(*it))
1485 it = enums.erase(it);
1485 it = enums.erase(it);
1486 else
1486 else
1487 ++it;
1487 ++it;
1488 }
1488 }
1489 }
1489 }
1490
1490
1491 // find constructors
1491 // find constructors
1492 AbstractMetaFunctionList ctors = findConstructors(meta_class);
1492 AbstractMetaFunctionList ctors = findConstructors(meta_class);
1493 bool hasDefaultCtor = findDefaultConstructor(ctors) != 0;
1493 bool hasDefaultCtor = findDefaultConstructor(ctors) != 0;
1494
1494
1495 // find interesting functions
1495 // find interesting functions
1496 QMap<QString, AbstractMetaFunctionList> nameToPrototypeFunctions;
1496 QMap<QString, AbstractMetaFunctionList> nameToPrototypeFunctions;
1497 QMap<QString, AbstractMetaFunctionList> nameToStaticFunctions;
1497 QMap<QString, AbstractMetaFunctionList> nameToStaticFunctions;
1498 findPrototypeAndStaticFunctions(meta_class, nameToPrototypeFunctions, nameToStaticFunctions);
1498 findPrototypeAndStaticFunctions(meta_class, nameToPrototypeFunctions, nameToStaticFunctions);
1499
1499
1500 int staticFunctionsOffset = 1;
1500 int staticFunctionsOffset = 1;
1501 int prototypeFunctionsOffset = staticFunctionsOffset + nameToStaticFunctions.size();
1501 int prototypeFunctionsOffset = staticFunctionsOffset + nameToStaticFunctions.size();
1502
1502
1503 // write table of function names
1503 // write table of function names
1504 stream << "static const char * const qtscript_"
1504 stream << "static const char * const qtscript_"
1505 << meta_class->name() << "_function_names[] = {" << endl;
1505 << meta_class->name() << "_function_names[] = {" << endl;
1506 stream << " \"" << meta_class->name() << "\"" << endl;
1506 stream << " \"" << meta_class->name() << "\"" << endl;
1507 {
1507 {
1508 QMap<QString, AbstractMetaFunctionList>::const_iterator it;
1508 QMap<QString, AbstractMetaFunctionList>::const_iterator it;
1509 stream << " // static" << endl;
1509 stream << " // static" << endl;
1510 for (it = nameToStaticFunctions.constBegin(); it != nameToStaticFunctions.constEnd(); ++it) {
1510 for (it = nameToStaticFunctions.constBegin(); it != nameToStaticFunctions.constEnd(); ++it) {
1511 stream << " , ";
1511 stream << " , ";
1512 stream << "\"" << it.key() << "\"" << endl;
1512 stream << "\"" << it.key() << "\"" << endl;
1513 }
1513 }
1514 stream << " // prototype" << endl;
1514 stream << " // prototype" << endl;
1515 for (it = nameToPrototypeFunctions.constBegin(); it != nameToPrototypeFunctions.constEnd(); ++it) {
1515 for (it = nameToPrototypeFunctions.constBegin(); it != nameToPrototypeFunctions.constEnd(); ++it) {
1516 QString functionName = it.key();
1516 QString functionName = it.key();
1517 QString scriptName = functionName;
1517 QString scriptName = functionName;
1518 if (functionName == QLatin1String("operator_equal"))
1518 if (functionName == QLatin1String("operator_equal"))
1519 scriptName = QLatin1String("equals");
1519 scriptName = QLatin1String("equals");
1520 stream << " , ";
1520 stream << " , ";
1521 stream << "\"" << scriptName << "\"" << endl;
1521 stream << "\"" << scriptName << "\"" << endl;
1522 }
1522 }
1523 if (!meta_class->hasDefaultToStringFunction())
1523 if (!meta_class->hasDefaultToStringFunction())
1524 stream << " , \"toString\"" << endl;
1524 stream << " , \"toString\"" << endl;
1525 }
1525 }
1526 stream << "};" << endl << endl;
1526 stream << "};" << endl << endl;
1527
1527
1528 // write table of function signatures
1528 // write table of function signatures
1529 stream << "static const char * const qtscript_"
1529 stream << "static const char * const qtscript_"
1530 << meta_class->name() << "_function_signatures[] = {" << endl;
1530 << meta_class->name() << "_function_signatures[] = {" << endl;
1531 stream << " ";
1531 stream << " ";
1532 writeFunctionSignaturesString(stream, ctors);
1532 writeFunctionSignaturesString(stream, ctors);
1533 stream << endl;
1533 stream << endl;
1534 {
1534 {
1535 QMap<QString, AbstractMetaFunctionList>::const_iterator it;
1535 QMap<QString, AbstractMetaFunctionList>::const_iterator it;
1536 stream << " // static" << endl;
1536 stream << " // static" << endl;
1537 for (it = nameToStaticFunctions.constBegin(); it != nameToStaticFunctions.constEnd(); ++it) {
1537 for (it = nameToStaticFunctions.constBegin(); it != nameToStaticFunctions.constEnd(); ++it) {
1538 stream << " , ";
1538 stream << " , ";
1539 writeFunctionSignaturesString(stream, it.value());
1539 writeFunctionSignaturesString(stream, it.value());
1540 stream << endl;
1540 stream << endl;
1541 }
1541 }
1542 stream << " // prototype" << endl;
1542 stream << " // prototype" << endl;
1543 for (it = nameToPrototypeFunctions.constBegin(); it != nameToPrototypeFunctions.constEnd(); ++it) {
1543 for (it = nameToPrototypeFunctions.constBegin(); it != nameToPrototypeFunctions.constEnd(); ++it) {
1544 stream << " , ";
1544 stream << " , ";
1545 writeFunctionSignaturesString(stream, it.value());
1545 writeFunctionSignaturesString(stream, it.value());
1546 stream << endl;
1546 stream << endl;
1547 }
1547 }
1548 if (!meta_class->hasDefaultToStringFunction())
1548 if (!meta_class->hasDefaultToStringFunction())
1549 stream << "\"\"" << endl;
1549 stream << "\"\"" << endl;
1550 }
1550 }
1551 stream << "};" << endl << endl;
1551 stream << "};" << endl << endl;
1552
1552
1553 #ifndef GENERATOR_NO_PROTECTED_FUNCTIONS
1553 #ifndef GENERATOR_NO_PROTECTED_FUNCTIONS
1554 if (meta_class->hasProtectedFunctions()) {
1554 if (meta_class->hasProtectedFunctions()) {
1555 // write a friendly class
1555 // write a friendly class
1556 stream << "class qtscript_" << meta_class->name()
1556 stream << "class qtscript_" << meta_class->name()
1557 << " : public " << meta_class->qualifiedCppName() << endl;
1557 << " : public " << meta_class->qualifiedCppName() << endl;
1558 stream << "{" << endl;
1558 stream << "{" << endl;
1559 for (int x = 0; x < 2; ++x) {
1559 for (int x = 0; x < 2; ++x) {
1560 QMap<QString, AbstractMetaFunctionList> &map =
1560 QMap<QString, AbstractMetaFunctionList> &map =
1561 x ? nameToStaticFunctions : nameToPrototypeFunctions;
1561 x ? nameToStaticFunctions : nameToPrototypeFunctions;
1562 QMap<QString, AbstractMetaFunctionList>::const_iterator it;
1562 QMap<QString, AbstractMetaFunctionList>::const_iterator it;
1563 for (it = map.constBegin(); it != map.constEnd(); ++it) {
1563 for (it = map.constBegin(); it != map.constEnd(); ++it) {
1564 AbstractMetaFunctionList functions = it.value();
1564 AbstractMetaFunctionList functions = it.value();
1565 for (int i = 0; i < functions.size(); ++i) {
1565 for (int i = 0; i < functions.size(); ++i) {
1566 if (functions.at(i)->isProtected()) {
1566 if (functions.at(i)->isProtected()) {
1567 stream << " friend QScriptValue qtscript_" << meta_class->name()
1567 stream << " friend QScriptValue qtscript_" << meta_class->name()
1568 << "_" << it.key();
1568 << "_" << it.key();
1569 if (functions.at(i)->isStatic())
1569 if (functions.at(i)->isStatic())
1570 stream << "_static";
1570 stream << "_static";
1571 stream << "(QScriptContext *, QScriptEngine *);" << endl;
1571 stream << "(QScriptContext *, QScriptEngine *);" << endl;
1572 break;
1572 break;
1573 }
1573 }
1574 }
1574 }
1575 }
1575 }
1576 }
1576 }
1577 stream << "};" << endl;
1577 stream << "};" << endl;
1578 stream << endl;
1578 stream << endl;
1579 }
1579 }
1580 #endif
1580 #endif
1581
1581
1582 writeHelperFunctions(stream, meta_class);
1582 writeHelperFunctions(stream, meta_class);
1583
1583
1584 // write metaobject getter if we need it
1584 // write metaobject getter if we need it
1585 if (hasQEnums(enums) && (meta_class->qualifiedCppName() != "QTransform")) {
1585 if (hasQEnums(enums) && (meta_class->qualifiedCppName() != "QTransform")) {
1586 if (meta_class->qualifiedCppName() == "Qt") {
1586 if (meta_class->qualifiedCppName() == "Qt") {
1587 stream << "struct qtscript_Qt_metaObject_helper : private QObject" << endl
1587 stream << "struct qtscript_Qt_metaObject_helper : private QObject" << endl
1588 << "{" << endl
1588 << "{" << endl
1589 << " static const QMetaObject *get()" << endl
1589 << " static const QMetaObject *get()" << endl
1590 << " { return &static_cast<qtscript_Qt_metaObject_helper*>(0)->staticQtMetaObject; }" << endl
1590 << " { return &static_cast<qtscript_Qt_metaObject_helper*>(0)->staticQtMetaObject; }" << endl
1591 << "};" << endl << endl;
1591 << "};" << endl << endl;
1592 }
1592 }
1593 stream << "static const QMetaObject *qtscript_" << meta_class->name() << "_metaObject()" << endl
1593 stream << "static const QMetaObject *qtscript_" << meta_class->name() << "_metaObject()" << endl
1594 << "{" << endl
1594 << "{" << endl
1595 << " return ";
1595 << " return ";
1596 if (meta_class->qualifiedCppName() == "Qt")
1596 if (meta_class->qualifiedCppName() == "Qt")
1597 stream << "qtscript_Qt_metaObject_helper::get()";
1597 stream << "qtscript_Qt_metaObject_helper::get()";
1598 else
1598 else
1599 stream << "&" << meta_class->qualifiedCppName() << "::staticMetaObject";
1599 stream << "&" << meta_class->qualifiedCppName() << "::staticMetaObject";
1600 stream << ";" << endl
1600 stream << ";" << endl
1601 << "}" << endl << endl;
1601 << "}" << endl << endl;
1602 }
1602 }
1603
1603
1604 // write metatype declarations
1604 // write metatype declarations
1605 {
1605 {
1606 QSet<QString> registeredTypeNames = m_qmetatype_declared_typenames;
1606 QSet<QString> registeredTypeNames = m_qmetatype_declared_typenames;
1607
1607
1608 if (!meta_class->isNamespace()) {
1608 if (!meta_class->isNamespace()) {
1609 if (meta_class->typeEntry()->isValue() && hasDefaultCtor)
1609 if (meta_class->typeEntry()->isValue() && hasDefaultCtor)
1610 maybeDeclareMetaType(stream, meta_class->qualifiedCppName(), registeredTypeNames);
1610 maybeDeclareMetaType(stream, meta_class->qualifiedCppName(), registeredTypeNames);
1611 else
1611 else
1612 registeredTypeNames << meta_class->qualifiedCppName();
1612 registeredTypeNames << meta_class->qualifiedCppName();
1613 maybeDeclareMetaType(stream, meta_class->qualifiedCppName() + "*", registeredTypeNames);
1613 maybeDeclareMetaType(stream, meta_class->qualifiedCppName() + "*", registeredTypeNames);
1614 }
1614 }
1615 if (meta_class->generateShellClass()) {
1615 if (meta_class->generateShellClass()) {
1616 if (meta_class->typeEntry()->isValue()) {
1616 if (meta_class->typeEntry()->isValue()) {
1617 maybeDeclareMetaType(stream, "QtScriptShell_" + meta_class->name(),
1617 maybeDeclareMetaType(stream, "QtScriptShell_" + meta_class->name(),
1618 registeredTypeNames);
1618 registeredTypeNames);
1619 }
1619 }
1620 maybeDeclareMetaType(stream, "QtScriptShell_" + meta_class->name() + "*",
1620 maybeDeclareMetaType(stream, "QtScriptShell_" + meta_class->name() + "*",
1621 registeredTypeNames);
1621 registeredTypeNames);
1622 }
1622 }
1623
1623
1624 declareEnumMetaTypes(stream, meta_class, registeredTypeNames);
1624 declareEnumMetaTypes(stream, meta_class, registeredTypeNames);
1625
1625
1626 for (int x = 0; x < 2; ++x) {
1626 for (int x = 0; x < 2; ++x) {
1627 QMap<QString, AbstractMetaFunctionList> &map =
1627 QMap<QString, AbstractMetaFunctionList> &map =
1628 x ? nameToStaticFunctions : nameToPrototypeFunctions;
1628 x ? nameToStaticFunctions : nameToPrototypeFunctions;
1629 QMap<QString, AbstractMetaFunctionList>::const_iterator it;
1629 QMap<QString, AbstractMetaFunctionList>::const_iterator it;
1630 for (it = map.constBegin(); it != map.constEnd(); ++it) {
1630 for (it = map.constBegin(); it != map.constEnd(); ++it) {
1631 declareFunctionMetaTypes(stream, it.value(), registeredTypeNames);
1631 declareFunctionMetaTypes(stream, it.value(), registeredTypeNames);
1632 }
1632 }
1633 }
1633 }
1634
1634
1635 declareFunctionMetaTypes(stream, ctors, registeredTypeNames);
1635 declareFunctionMetaTypes(stream, ctors, registeredTypeNames);
1636
1636
1637 if (meta_class->baseClass() != 0) {
1637 if (meta_class->baseClass() != 0) {
1638 maybeDeclareMetaType(stream, meta_class->baseClass()->qualifiedCppName()
1638 maybeDeclareMetaType(stream, meta_class->baseClass()->qualifiedCppName()
1639 + QLatin1String("*"), registeredTypeNames);
1639 + QLatin1String("*"), registeredTypeNames);
1640 }
1640 }
1641 foreach (AbstractMetaClass *iface, meta_class->interfaces()) {
1641 foreach (AbstractMetaClass *iface, meta_class->interfaces()) {
1642 AbstractMetaClass *impl = iface->primaryInterfaceImplementor();
1642 AbstractMetaClass *impl = iface->primaryInterfaceImplementor();
1643 maybeDeclareMetaType(stream, impl->qualifiedCppName() + QLatin1String("*"),
1643 maybeDeclareMetaType(stream, impl->qualifiedCppName() + QLatin1String("*"),
1644 registeredTypeNames);
1644 registeredTypeNames);
1645 }
1645 }
1646
1646
1647 // ### hackety hack
1647 // ### hackety hack
1648 if (meta_class->name().endsWith("Gradient"))
1648 if (meta_class->name().endsWith("Gradient"))
1649 maybeDeclareMetaType(stream, "QGradient", registeredTypeNames);
1649 maybeDeclareMetaType(stream, "QGradient", registeredTypeNames);
1650
1650
1651 stream << endl;
1651 stream << endl;
1652 }
1652 }
1653
1653
1654 writeInjectedCode(stream, meta_class, CodeSnip::Beginning);
1654 writeInjectedCode(stream, meta_class, CodeSnip::Beginning);
1655
1655
1656 // write enum classes
1656 // write enum classes
1657 if (!enums.isEmpty()) {
1657 if (!enums.isEmpty()) {
1658 writeCreateEnumClassHelper(stream);
1658 writeCreateEnumClassHelper(stream);
1659 if (hasFlags(enums))
1659 if (hasFlags(enums))
1660 writeCreateFlagsClassHelper(stream);
1660 writeCreateFlagsClassHelper(stream);
1661
1661
1662 for (int i = 0; i < enums.size(); ++i) {
1662 for (int i = 0; i < enums.size(); ++i) {
1663 const AbstractMetaEnum *enom = enums.at(i);
1663 const AbstractMetaEnum *enom = enums.at(i);
1664 writeEnumClass(stream, meta_class, enom);
1664 writeEnumClass(stream, meta_class, enom);
1665 }
1665 }
1666 }
1666 }
1667
1667
1668 stream << "//" << endl;
1668 stream << "//" << endl;
1669 stream << "// " << meta_class->name() << endl;
1669 stream << "// " << meta_class->name() << endl;
1670 stream << "//" << endl << endl;
1670 stream << "//" << endl << endl;
1671
1671
1672 if (!meta_class->isNamespace()) {
1672 if (!meta_class->isNamespace()) {
1673 if (!nameToPrototypeFunctions.isEmpty() || !meta_class->hasDefaultToStringFunction())
1673 if (!nameToPrototypeFunctions.isEmpty() || !meta_class->hasDefaultToStringFunction())
1674 writePrototypeCall(stream, meta_class, nameToPrototypeFunctions, prototypeFunctionsOffset);
1674 writePrototypeCall(stream, meta_class, nameToPrototypeFunctions, prototypeFunctionsOffset);
1675 }
1675 }
1676
1676
1677 writeStaticCall(stream, meta_class, ctors, nameToStaticFunctions);
1677 writeStaticCall(stream, meta_class, ctors, nameToStaticFunctions);
1678
1678
1679 if (isQObjectBased(meta_class)) {
1679 if (isQObjectBased(meta_class)) {
1680 // write C++ <--> script conversion functions
1680 // write C++ <--> script conversion functions
1681 stream << "static QScriptValue qtscript_" << meta_class->name() << "_toScriptValue(QScriptEngine *engine, "
1681 stream << "static QScriptValue qtscript_" << meta_class->name() << "_toScriptValue(QScriptEngine *engine, "
1682 << meta_class->qualifiedCppName() << "* const &in)" << endl
1682 << meta_class->qualifiedCppName() << "* const &in)" << endl
1683 << "{" << endl
1683 << "{" << endl
1684 << " return engine->newQObject(in, QScriptEngine::QtOwnership, QScriptEngine::PreferExistingWrapperObject);" << endl
1684 << " return engine->newQObject(in, QScriptEngine::QtOwnership, QScriptEngine::PreferExistingWrapperObject);" << endl
1685 << "}" << endl << endl;
1685 << "}" << endl << endl;
1686 stream << "static void qtscript_" << meta_class->name() << "_fromScriptValue(const QScriptValue &value, "
1686 stream << "static void qtscript_" << meta_class->name() << "_fromScriptValue(const QScriptValue &value, "
1687 << meta_class->qualifiedCppName() << "* &out)" << endl
1687 << meta_class->qualifiedCppName() << "* &out)" << endl
1688 << "{" << endl
1688 << "{" << endl
1689 << " out = qobject_cast<" << meta_class->qualifiedCppName() << "*>(value.toQObject());" << endl
1689 << " out = qobject_cast<" << meta_class->qualifiedCppName() << "*>(value.toQObject());" << endl
1690 << "}" << endl << endl;
1690 << "}" << endl << endl;
1691 }
1691 }
1692
1692
1693 //
1693 //
1694 // write exported function that creates the QtScript class
1694 // write exported function that creates the QtScript class
1695 //
1695 //
1696 stream << "QScriptValue qtscript_create_" << meta_class->name()
1696 stream << "QScriptValue qtscript_create_" << meta_class->name()
1697 << "_class(QScriptEngine *engine)" << endl;
1697 << "_class(QScriptEngine *engine)" << endl;
1698 stream << "{" << endl;
1698 stream << "{" << endl;
1699
1699
1700 // write lengths array
1700 // write lengths array
1701 stream << " static const int function_lengths[] = {" << endl;
1701 stream << " static const int function_lengths[] = {" << endl;
1702 stream << " " << maxFunctionLength(ctors) << endl;
1702 stream << " " << maxFunctionLength(ctors) << endl;
1703 {
1703 {
1704 QMap<QString, AbstractMetaFunctionList>::const_iterator it;
1704 QMap<QString, AbstractMetaFunctionList>::const_iterator it;
1705 stream << " // static" << endl;
1705 stream << " // static" << endl;
1706 for (it = nameToStaticFunctions.constBegin(); it != nameToStaticFunctions.constEnd(); ++it) {
1706 for (it = nameToStaticFunctions.constBegin(); it != nameToStaticFunctions.constEnd(); ++it) {
1707 stream << " , " << maxFunctionLength(it.value()) << endl;
1707 stream << " , " << maxFunctionLength(it.value()) << endl;
1708 }
1708 }
1709 stream << " // prototype" << endl;
1709 stream << " // prototype" << endl;
1710 for (it = nameToPrototypeFunctions.constBegin(); it != nameToPrototypeFunctions.constEnd(); ++it) {
1710 for (it = nameToPrototypeFunctions.constBegin(); it != nameToPrototypeFunctions.constEnd(); ++it) {
1711 stream << " , " << maxFunctionLength(it.value()) << endl;
1711 stream << " , " << maxFunctionLength(it.value()) << endl;
1712 }
1712 }
1713 if (!meta_class->hasDefaultToStringFunction())
1713 if (!meta_class->hasDefaultToStringFunction())
1714 stream << " , 0" << endl;
1714 stream << " , 0" << endl;
1715 }
1715 }
1716 stream << " };" << endl;
1716 stream << " };" << endl;
1717
1717
1718 // setup prototype
1718 // setup prototype
1719 if (!meta_class->isNamespace()) {
1719 if (!meta_class->isNamespace()) {
1720 stream << " engine->setDefaultPrototype(qMetaTypeId<"
1720 stream << " engine->setDefaultPrototype(qMetaTypeId<"
1721 << meta_class->qualifiedCppName() << "*>(), QScriptValue());" << endl;
1721 << meta_class->qualifiedCppName() << "*>(), QScriptValue());" << endl;
1722 stream << " QScriptValue proto = engine->newVariant(qVariantFromValue(("
1722 stream << " QScriptValue proto = engine->newVariant(qVariantFromValue(("
1723 << meta_class->qualifiedCppName() << "*)0));" << endl;
1723 << meta_class->qualifiedCppName() << "*)0));" << endl;
1724 bool havePrototypePrototype = false;
1724 bool havePrototypePrototype = false;
1725 if (meta_class->baseClass() != 0) {
1725 if (meta_class->baseClass() != 0) {
1726 stream << " proto.setPrototype(engine->defaultPrototype(qMetaTypeId<"
1726 stream << " proto.setPrototype(engine->defaultPrototype(qMetaTypeId<"
1727 << meta_class->baseClass()->qualifiedCppName() << "*>()));" << endl;
1727 << meta_class->baseClass()->qualifiedCppName() << "*>()));" << endl;
1728 havePrototypePrototype = true;
1728 havePrototypePrototype = true;
1729 }
1729 }
1730 foreach (AbstractMetaClass *iface, meta_class->interfaces()) {
1730 foreach (AbstractMetaClass *iface, meta_class->interfaces()) {
1731 AbstractMetaClass *impl = iface->primaryInterfaceImplementor();
1731 AbstractMetaClass *impl = iface->primaryInterfaceImplementor();
1732 if (impl == meta_class)
1732 if (impl == meta_class)
1733 continue;
1733 continue;
1734 if (!havePrototypePrototype) {
1734 if (!havePrototypePrototype) {
1735 stream << " proto.setPrototype(engine->defaultPrototype(qMetaTypeId<"
1735 stream << " proto.setPrototype(engine->defaultPrototype(qMetaTypeId<"
1736 << impl->qualifiedCppName() << "*>()));" << endl;
1736 << impl->qualifiedCppName() << "*>()));" << endl;
1737 havePrototypePrototype = true;
1737 havePrototypePrototype = true;
1738 } else {
1738 } else {
1739 // alternative would be to copy the properties from the secondary
1739 // alternative would be to copy the properties from the secondary
1740 // prototype to the primary prototype.
1740 // prototype to the primary prototype.
1741 stream << " proto.setProperty(QString::fromLatin1(\"__"
1741 stream << " proto.setProperty(QString::fromLatin1(\"__"
1742 << impl->name() << "__\")," << endl
1742 << impl->name() << "__\")," << endl
1743 << " engine->defaultPrototype(qMetaTypeId<"
1743 << " engine->defaultPrototype(qMetaTypeId<"
1744 << impl->qualifiedCppName() << "*>())," << endl
1744 << impl->qualifiedCppName() << "*>())," << endl
1745 << " QScriptValue::SkipInEnumeration);" << endl;
1745 << " QScriptValue::SkipInEnumeration);" << endl;
1746 }
1746 }
1747 }
1747 }
1748 if (!nameToPrototypeFunctions.isEmpty()) {
1748 if (!nameToPrototypeFunctions.isEmpty()) {
1749 QMap<QString, AbstractMetaFunctionList>::const_iterator it;
1749 QMap<QString, AbstractMetaFunctionList>::const_iterator it;
1750 int count = nameToPrototypeFunctions.size();
1750 int count = nameToPrototypeFunctions.size();
1751 if (!meta_class->hasDefaultToStringFunction())
1751 if (!meta_class->hasDefaultToStringFunction())
1752 ++count;
1752 ++count;
1753 stream << " for (int i = 0; i < " << count << "; ++i) {" << endl
1753 stream << " for (int i = 0; i < " << count << "; ++i) {" << endl
1754 << " QScriptValue fun = engine->newFunction(qtscript_"
1754 << " QScriptValue fun = engine->newFunction(qtscript_"
1755 << meta_class->name() << "_prototype_call, function_lengths[i+"
1755 << meta_class->name() << "_prototype_call, function_lengths[i+"
1756 << prototypeFunctionsOffset << "]);" << endl
1756 << prototypeFunctionsOffset << "]);" << endl
1757 << " fun.setData(QScriptValue(engine, uint(0xBABE0000 + i)));" << endl
1757 << " fun.setData(QScriptValue(engine, uint(0xBABE0000 + i)));" << endl
1758 << " proto.setProperty(QString::fromLatin1(qtscript_"
1758 << " proto.setProperty(QString::fromLatin1(qtscript_"
1759 << meta_class->name() << "_function_names[i+" << prototypeFunctionsOffset << "])," << endl
1759 << meta_class->name() << "_function_names[i+" << prototypeFunctionsOffset << "])," << endl
1760 << " fun, QScriptValue::SkipInEnumeration);" << endl
1760 << " fun, QScriptValue::SkipInEnumeration);" << endl
1761 << " }" << endl;
1761 << " }" << endl;
1762 }
1762 }
1763 writeInjectedCode(stream, meta_class, CodeSnip::PrototypeInitialization);
1763 writeInjectedCode(stream, meta_class, CodeSnip::PrototypeInitialization);
1764 stream << endl;
1764 stream << endl;
1765
1765
1766 // register the prototype
1766 // register the prototype
1767 // stream << " qDebug() << \"registering " << meta_class->name() << " prototype\";" << endl;
1767 // stream << " qDebug() << \"registering " << meta_class->name() << " prototype\";" << endl;
1768 if (meta_class->typeEntry()->isValue() && hasDefaultCtor) {
1768 if (meta_class->typeEntry()->isValue() && hasDefaultCtor) {
1769 stream << " engine->setDefaultPrototype(qMetaTypeId<"
1769 stream << " engine->setDefaultPrototype(qMetaTypeId<"
1770 << meta_class->qualifiedCppName() << ">(), proto);" << endl;
1770 << meta_class->qualifiedCppName() << ">(), proto);" << endl;
1771 }
1771 }
1772 if (isQObjectBased(meta_class)) {
1772 if (isQObjectBased(meta_class)) {
1773 stream << " qScriptRegisterMetaType<" << meta_class->qualifiedCppName() << "*>(engine, qtscript_"
1773 stream << " qScriptRegisterMetaType<" << meta_class->qualifiedCppName() << "*>(engine, qtscript_"
1774 << meta_class->name() << "_toScriptValue, " << endl << " qtscript_"
1774 << meta_class->name() << "_toScriptValue, " << endl << " qtscript_"
1775 << meta_class->name() << "_fromScriptValue, proto);" << endl;
1775 << meta_class->name() << "_fromScriptValue, proto);" << endl;
1776 } else {
1776 } else {
1777 stream << " engine->setDefaultPrototype(qMetaTypeId<"
1777 stream << " engine->setDefaultPrototype(qMetaTypeId<"
1778 << meta_class->qualifiedCppName() << "*>(), proto);" << endl;
1778 << meta_class->qualifiedCppName() << "*>(), proto);" << endl;
1779 }
1779 }
1780 stream << endl;
1780 stream << endl;
1781 } else {
1781 } else {
1782 stream << " QScriptValue proto = QScriptValue();" << endl;
1782 stream << " QScriptValue proto = QScriptValue();" << endl;
1783 }
1783 }
1784
1784
1785 // setup constructor
1785 // setup constructor
1786 stream << " QScriptValue ctor = engine->newFunction(qtscript_" << meta_class->name()
1786 stream << " QScriptValue ctor = engine->newFunction(qtscript_" << meta_class->name()
1787 << "_static_call, proto, function_lengths[0]);" << endl;
1787 << "_static_call, proto, function_lengths[0]);" << endl;
1788 stream << " ctor.setData(QScriptValue(engine, uint(0xBABE0000 + 0)));" << endl;
1788 stream << " ctor.setData(QScriptValue(engine, uint(0xBABE0000 + 0)));" << endl;
1789 if (!nameToStaticFunctions.isEmpty()) {
1789 if (!nameToStaticFunctions.isEmpty()) {
1790 // static functions
1790 // static functions
1791 QMap<QString, AbstractMetaFunctionList>::const_iterator it;
1791 QMap<QString, AbstractMetaFunctionList>::const_iterator it;
1792 stream << " for (int i = 0; i < " << nameToStaticFunctions.size() << "; ++i) {" << endl
1792 stream << " for (int i = 0; i < " << nameToStaticFunctions.size() << "; ++i) {" << endl
1793 << " QScriptValue fun = engine->newFunction(qtscript_" << meta_class->name()
1793 << " QScriptValue fun = engine->newFunction(qtscript_" << meta_class->name()
1794 << "_static_call," << endl
1794 << "_static_call," << endl
1795 << " function_lengths[i+" << staticFunctionsOffset << "]);" << endl
1795 << " function_lengths[i+" << staticFunctionsOffset << "]);" << endl
1796 << " fun.setData(QScriptValue(engine, uint(0xBABE0000 + i+1)));" << endl
1796 << " fun.setData(QScriptValue(engine, uint(0xBABE0000 + i+1)));" << endl
1797 << " ctor.setProperty(QString::fromLatin1(qtscript_"
1797 << " ctor.setProperty(QString::fromLatin1(qtscript_"
1798 << meta_class->name() << "_function_names[i+" << staticFunctionsOffset << "])," << endl
1798 << meta_class->name() << "_function_names[i+" << staticFunctionsOffset << "])," << endl
1799 << " fun, QScriptValue::SkipInEnumeration);" << endl
1799 << " fun, QScriptValue::SkipInEnumeration);" << endl
1800 << " }" << endl;
1800 << " }" << endl;
1801 }
1801 }
1802 stream << endl;
1802 stream << endl;
1803 // enums and flags classes
1803 // enums and flags classes
1804 {
1804 {
1805 for (int i = 0; i < enums.size(); ++i) {
1805 for (int i = 0; i < enums.size(); ++i) {
1806 const AbstractMetaEnum *enom = enums.at(i);
1806 const AbstractMetaEnum *enom = enums.at(i);
1807 stream << " ctor.setProperty(QString::fromLatin1(\""
1807 stream << " ctor.setProperty(QString::fromLatin1(\""
1808 << enom->name() << "\")," << endl
1808 << enom->name() << "\")," << endl
1809 << " qtscript_create_" << meta_class->name()
1809 << " qtscript_create_" << meta_class->name()
1810 << "_" << enom->name() << "_class(engine, ctor));" << endl;
1810 << "_" << enom->name() << "_class(engine, ctor));" << endl;
1811 FlagsTypeEntry *flags = enom->typeEntry()->flags();
1811 FlagsTypeEntry *flags = enom->typeEntry()->flags();
1812 if (flags) {
1812 if (flags) {
1813 stream << " ctor.setProperty(QString::fromLatin1(\""
1813 stream << " ctor.setProperty(QString::fromLatin1(\""
1814 << flags->targetLangName() << "\")," << endl
1814 << flags->targetLangName() << "\")," << endl
1815 << " qtscript_create_" << meta_class->name()
1815 << " qtscript_create_" << meta_class->name()
1816 << "_" << flags->targetLangName() << "_class(engine));" << endl;
1816 << "_" << flags->targetLangName() << "_class(engine));" << endl;
1817 }
1817 }
1818 }
1818 }
1819 }
1819 }
1820
1820
1821 writeInjectedCode(stream, meta_class, CodeSnip::ConstructorInitialization);
1821 writeInjectedCode(stream, meta_class, CodeSnip::ConstructorInitialization);
1822
1822
1823 stream << " return ctor;" << endl;
1823 stream << " return ctor;" << endl;
1824 stream << "}" << endl;
1824 stream << "}" << endl;
1825
1825
1826 writeInjectedCode(stream, meta_class, CodeSnip::End);
1826 writeInjectedCode(stream, meta_class, CodeSnip::End);
1827
1827
1828 QString pro_file_name = meta_class->package().replace(".", "_") + "/" + meta_class->package().replace(".", "_") + ".pri";
1828 QString pro_file_name = meta_class->package().replace(".", "_") + "/" + meta_class->package().replace(".", "_") + ".pri";
1829 priGenerator->addSource(pro_file_name, fileNameForClass(meta_class));
1829 priGenerator->addSource(pro_file_name, fileNameForClass(meta_class));
1830 setupGenerator->addClass(meta_class);
1830 setupGenerator->addClass(meta_class);
1831 }
1831 }
1832
1832
1833 bool ClassGenerator::isBuiltIn(const QString& name) {
1833 bool ClassGenerator::isBuiltIn(const QString& name) {
1834
1834
1835 static QSet<QString> builtIn;
1835 static QSet<QString> builtIn;
1836 if (builtIn.isEmpty()) {
1836 if (builtIn.isEmpty()) {
1837 builtIn.insert("Qt");
1837 builtIn.insert("Qt");
1838 builtIn.insert("QFont");
1838 builtIn.insert("QFont");
1839 builtIn.insert("QPixmap");
1839 builtIn.insert("QPixmap");
1840 builtIn.insert("QBrush");
1840 builtIn.insert("QBrush");
1841 builtIn.insert("QPalette");
1841 builtIn.insert("QPalette");
1842 builtIn.insert("QIcon");
1842 builtIn.insert("QIcon");
1843 builtIn.insert("QImage");
1843 builtIn.insert("QImage");
1844 builtIn.insert("QPolygon");
1844 builtIn.insert("QPolygon");
1845 builtIn.insert("QRegion");
1845 builtIn.insert("QRegion");
1846 builtIn.insert("QBitmap");
1846 builtIn.insert("QBitmap");
1847 builtIn.insert("QCursor");
1847 builtIn.insert("QCursor");
1848 builtIn.insert("QColor");
1848 builtIn.insert("QColor");
1849 builtIn.insert("QSizePolicy");
1849 builtIn.insert("QSizePolicy");
1850 builtIn.insert("QKeySequence");
1850 builtIn.insert("QKeySequence");
1851 builtIn.insert("QTextLength");
1851 builtIn.insert("QTextLength");
1852 builtIn.insert("QTextFormat");
1852 builtIn.insert("QTextFormat");
1853 builtIn.insert("QMatrix");
1853 builtIn.insert("QMatrix");
1854 builtIn.insert("QDate");
1854 builtIn.insert("QDate");
1855 builtIn.insert("QTime");
1855 builtIn.insert("QTime");
1856 builtIn.insert("QDateTime");
1856 builtIn.insert("QDateTime");
1857 builtIn.insert("QUrl");
1857 builtIn.insert("QUrl");
1858 builtIn.insert("QLocale");
1858 builtIn.insert("QLocale");
1859 builtIn.insert("QRect");
1859 builtIn.insert("QRect");
1860 builtIn.insert("QRectF");
1860 builtIn.insert("QRectF");
1861 builtIn.insert("QSize");
1861 builtIn.insert("QSize");
1862 builtIn.insert("QSizeF");
1862 builtIn.insert("QSizeF");
1863 builtIn.insert("QLine");
1863 builtIn.insert("QLine");
1864 builtIn.insert("QLineF");
1864 builtIn.insert("QLineF");
1865 builtIn.insert("QPoint");
1865 builtIn.insert("QPoint");
1866 builtIn.insert("QPointF");
1866 builtIn.insert("QPointF");
1867 builtIn.insert("QRegExp");
1867 builtIn.insert("QRegExp");
1868 }
1868 }
1869 return builtIn.contains(name);
1869 return builtIn.contains(name);
1870 }
1870 }
@@ -1,27 +1,30
1 TARGET = pythonqt_generator
2 CONFIG -= debug
3 CONFIG += release
4 DESTDIR = .
5
1 include(generator.pri)
6 include(generator.pri)
2
7
8
3 # Input
9 # Input
4 HEADERS += \
10 HEADERS += \
5 generatorsetqtscript.h \
11 generatorsetqtscript.h \
6 metaqtscriptbuilder.h \
12 metaqtscriptbuilder.h \
7 metaqtscript.h \
13 metaqtscript.h \
8 classgenerator.h \
14 classgenerator.h \
9 shellgenerator.h \
15 shellgenerator.h \
10 shellimplgenerator.h \
16 shellimplgenerator.h \
11 shellheadergenerator.h \
17 shellheadergenerator.h \
12 setupgenerator.h \
18 setupgenerator.h \
13 docgenerator.h
19 docgenerator.h
14
20
15 SOURCES += \
21 SOURCES += \
16 generatorsetqtscript.cpp \
22 generatorsetqtscript.cpp \
17 metaqtscriptbuilder.cpp \
23 metaqtscriptbuilder.cpp \
18 metaqtscript.cpp \
24 metaqtscript.cpp \
19 classgenerator.cpp \
25 classgenerator.cpp \
20 shellgenerator.cpp \
26 shellgenerator.cpp \
21 shellimplgenerator.cpp \
27 shellimplgenerator.cpp \
22 shellheadergenerator.cpp \
28 shellheadergenerator.cpp \
23 setupgenerator.cpp \
29 setupgenerator.cpp \
24 docgenerator.cpp
30 docgenerator.cpp
25
26 CONFIG -= debug
27 CONFIG += release
@@ -1,67 +1,70
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
3 ** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
4 **
4 **
5 ** This file is part of the Qt Script Generator project on Trolltech Labs.
5 ** This file is part of the Qt Script Generator project on Trolltech Labs.
6 **
6 **
7 ** This file may be used under the terms of the GNU General Public
7 ** This file may be used under the terms of the GNU General Public
8 ** License version 2.0 as published by the Free Software Foundation
8 ** License version 2.0 as published by the Free Software Foundation
9 ** and appearing in the file LICENSE.GPL included in the packaging of
9 ** and appearing in the file LICENSE.GPL included in the packaging of
10 ** this file. Please review the following information to ensure GNU
10 ** this file. Please review the following information to ensure GNU
11 ** General Public Licensing requirements will be met:
11 ** General Public Licensing requirements will be met:
12 ** http://www.trolltech.com/products/qt/opensource.html
12 ** http://www.trolltech.com/products/qt/opensource.html
13 **
13 **
14 ** If you are unsure which license is appropriate for your use, please
14 ** If you are unsure which license is appropriate for your use, please
15 ** review the following information:
15 ** review the following information:
16 ** http://www.trolltech.com/products/qt/licensing.html or contact the
16 ** http://www.trolltech.com/products/qt/licensing.html or contact the
17 ** sales department at sales@trolltech.com.
17 ** sales department at sales@trolltech.com.
18 **
18 **
19 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
19 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
20 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21 **
21 **
22 ****************************************************************************/
22 ****************************************************************************/
23
23
24 #include "prigenerator.h"
24 #include "prigenerator.h"
25 #include "reporthandler.h"
25 #include "reporthandler.h"
26 #include "fileout.h"
26 #include "fileout.h"
27
27
28 void PriGenerator::addHeader(const QString &folder, const QString &header)
28 void PriGenerator::addHeader(const QString &folder, const QString &header)
29 {
29 {
30 priHash[folder].headers << header;
30 priHash[folder].headers << header;
31 }
31 }
32
32
33 void PriGenerator::addSource(const QString &folder, const QString &source)
33 void PriGenerator::addSource(const QString &folder, const QString &source)
34 {
34 {
35 priHash[folder].sources << source;
35 priHash[folder].sources << source;
36 }
36 }
37
37
38 void PriGenerator::generate()
38 void PriGenerator::generate()
39 {
39 {
40 QHashIterator<QString, Pri> pri(priHash);
40 QHashIterator<QString, Pri> pri(priHash);
41 while (pri.hasNext()) {
41 while (pri.hasNext()) {
42 pri.next();
42 pri.next();
43 QStringList list = pri.value().headers;
43 QStringList list = pri.value().headers;
44 if (list.isEmpty())
44 if (list.isEmpty())
45 continue;
45 continue;
46
46
47 FileOut file(m_out_dir + "/generated_cpp/" + pri.key());
47 FileOut file(m_out_dir + "/generated_cpp/" + pri.key());
48 file.stream << "HEADERS += \\\n";
48 file.stream << "HEADERS += \\\n";
49 qSort(list.begin(), list.end());
49 qSort(list.begin(), list.end());
50 foreach (const QString &entry, list) {
50 foreach (const QString &entry, list) {
51 file.stream << " $$PWD/" << entry << " \\\n";
51 file.stream << " $$PWD/" << entry << " \\\n";
52 }
52 }
53
53
54 file.stream << "\n";
54 file.stream << "\n";
55 file.stream << "SOURCES += \\\n";
55 file.stream << "SOURCES += \\\n";
56 list = pri.value().sources;
56 list = pri.value().sources;
57 qSort(list.begin(), list.end());
57 qSort(list.begin(), list.end());
58 foreach (const QString &entry, list) {
58 foreach (const QString &entry, list) {
59 file.stream << " $$PWD/" << entry << " \\\n";
59 file.stream << " $$PWD/" << entry << " \\\n";
60 }
60 }
61 file.stream << " $$PWD/init.cpp\n";
61 QString initName = pri.key();
62 initName = initName.mid(initName.indexOf('/')+1);
63 initName = initName.left(initName.length()-4);
64 file.stream << " $$PWD/" + initName + "_init.cpp\n";
62
65
63 if (file.done())
66 if (file.done())
64 ++m_num_generated_written;
67 ++m_num_generated_written;
65 ++m_num_generated;
68 ++m_num_generated;
66 }
69 }
67 }
70 }
@@ -1,1134 +1,1134
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
3 ** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
4 **
4 **
5 ** This file is part of the Qt Script Generator project on Trolltech Labs.
5 ** This file is part of the Qt Script Generator project on Trolltech Labs.
6 **
6 **
7 ** This file may be used under the terms of the GNU General Public
7 ** This file may be used under the terms of the GNU General Public
8 ** License version 2.0 as published by the Free Software Foundation
8 ** License version 2.0 as published by the Free Software Foundation
9 ** and appearing in the file LICENSE.GPL included in the packaging of
9 ** and appearing in the file LICENSE.GPL included in the packaging of
10 ** this file. Please review the following information to ensure GNU
10 ** this file. Please review the following information to ensure GNU
11 ** General Public Licensing requirements will be met:
11 ** General Public Licensing requirements will be met:
12 ** http://www.trolltech.com/products/qt/opensource.html
12 ** http://www.trolltech.com/products/qt/opensource.html
13 **
13 **
14 ** If you are unsure which license is appropriate for your use, please
14 ** If you are unsure which license is appropriate for your use, please
15 ** review the following information:
15 ** review the following information:
16 ** http://www.trolltech.com/products/qt/licensing.html or contact the
16 ** http://www.trolltech.com/products/qt/licensing.html or contact the
17 ** sales department at sales@trolltech.com.
17 ** sales department at sales@trolltech.com.
18 **
18 **
19 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
19 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
20 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21 **
21 **
22 ****************************************************************************/
22 ****************************************************************************/
23
23
24 #define QT_NO_STL
24 #define QT_NO_STL
25 #include <QtCore/QtCore>
25 #include <QtCore/QtCore>
26 #include <QtGui/QtGui>
26 #include <QtGui/QtGui>
27 #include <QtNetwork/QtNetwork>
27 #include <QtNetwork/QtNetwork>
28 #include <QtSql/QtSql>
28 #include <QtSql/QtSql>
29 #include <QtSvg/QtSvg>
29 #include <QtSvg/QtSvg>
30 #include <QtXml/QtXml>
30 #include <QtXml/QtXml>
31
31
32 #include <QtUiTools/QtUiTools>
32 #include <QtUiTools/QtUiTools>
33
33
34 #ifndef QT_NO_XMLPATTERNS
34 #ifndef QT_NO_XMLPATTERNS
35 # include <QtXmlPatterns/QtXmlPatterns>
35 # include <QtXmlPatterns/QtXmlPatterns>
36 #endif
36 #endif
37
37
38 #ifndef QT_NO_WEBKIT
38 #ifndef QT_NO_WEBKIT
39 # include <QtWebKit/QtWebKit>
39 # include <QtWebKit/QtWebKit>
40 #endif
40 #endif
41
41
42 #ifndef QT_NO_PHONON
42 #ifndef QT_NO_PHONON
43 # include <phonon/phonon>
43 # include <phonon/phonon>
44 #endif
44 #endif
45
45
46 #include "../qtbindings/qtscript_core/qtscriptconcurrent.h"
46 //#include "../qtbindings/qtscript_core/qtscriptconcurrent.h"
47
47
48 #ifndef QT_NO_OPENGL
48 #ifndef QT_NO_OPENGL
49 #define GL_ACCUM 0x0100
49 #define GL_ACCUM 0x0100
50 #define GL_LOAD 0x0101
50 #define GL_LOAD 0x0101
51 #define GL_RETURN 0x0102
51 #define GL_RETURN 0x0102
52 #define GL_MULT 0x0103
52 #define GL_MULT 0x0103
53 #define GL_ADD 0x0104
53 #define GL_ADD 0x0104
54
54
55 /* AlphaFunction */
55 /* AlphaFunction */
56 #define GL_NEVER 0x0200
56 #define GL_NEVER 0x0200
57 #define GL_LESS 0x0201
57 #define GL_LESS 0x0201
58 #define GL_EQUAL 0x0202
58 #define GL_EQUAL 0x0202
59 #define GL_LEQUAL 0x0203
59 #define GL_LEQUAL 0x0203
60 #define GL_GREATER 0x0204
60 #define GL_GREATER 0x0204
61 #define GL_NOTEQUAL 0x0205
61 #define GL_NOTEQUAL 0x0205
62 #define GL_GEQUAL 0x0206
62 #define GL_GEQUAL 0x0206
63 #define GL_ALWAYS 0x0207
63 #define GL_ALWAYS 0x0207
64
64
65 /* AttribMask */
65 /* AttribMask */
66 #define GL_CURRENT_BIT 0x00000001
66 #define GL_CURRENT_BIT 0x00000001
67 #define GL_POINT_BIT 0x00000002
67 #define GL_POINT_BIT 0x00000002
68 #define GL_LINE_BIT 0x00000004
68 #define GL_LINE_BIT 0x00000004
69 #define GL_POLYGON_BIT 0x00000008
69 #define GL_POLYGON_BIT 0x00000008
70 #define GL_POLYGON_STIPPLE_BIT 0x00000010
70 #define GL_POLYGON_STIPPLE_BIT 0x00000010
71 #define GL_PIXEL_MODE_BIT 0x00000020
71 #define GL_PIXEL_MODE_BIT 0x00000020
72 #define GL_LIGHTING_BIT 0x00000040
72 #define GL_LIGHTING_BIT 0x00000040
73 #define GL_FOG_BIT 0x00000080
73 #define GL_FOG_BIT 0x00000080
74 #define GL_DEPTH_BUFFER_BIT 0x00000100
74 #define GL_DEPTH_BUFFER_BIT 0x00000100
75 #define GL_ACCUM_BUFFER_BIT 0x00000200
75 #define GL_ACCUM_BUFFER_BIT 0x00000200
76 #define GL_STENCIL_BUFFER_BIT 0x00000400
76 #define GL_STENCIL_BUFFER_BIT 0x00000400
77 #define GL_VIEWPORT_BIT 0x00000800
77 #define GL_VIEWPORT_BIT 0x00000800
78 #define GL_TRANSFORM_BIT 0x00001000
78 #define GL_TRANSFORM_BIT 0x00001000
79 #define GL_ENABLE_BIT 0x00002000
79 #define GL_ENABLE_BIT 0x00002000
80 #define GL_COLOR_BUFFER_BIT 0x00004000
80 #define GL_COLOR_BUFFER_BIT 0x00004000
81 #define GL_HINT_BIT 0x00008000
81 #define GL_HINT_BIT 0x00008000
82 #define GL_EVAL_BIT 0x00010000
82 #define GL_EVAL_BIT 0x00010000
83 #define GL_LIST_BIT 0x00020000
83 #define GL_LIST_BIT 0x00020000
84 #define GL_TEXTURE_BIT 0x00040000
84 #define GL_TEXTURE_BIT 0x00040000
85 #define GL_SCISSOR_BIT 0x00080000
85 #define GL_SCISSOR_BIT 0x00080000
86 #define GL_ALL_ATTRIB_BITS 0x000fffff
86 #define GL_ALL_ATTRIB_BITS 0x000fffff
87
87
88 /* BeginMode */
88 /* BeginMode */
89 #define GL_POINTS 0x0000
89 #define GL_POINTS 0x0000
90 #define GL_LINES 0x0001
90 #define GL_LINES 0x0001
91 #define GL_LINE_LOOP 0x0002
91 #define GL_LINE_LOOP 0x0002
92 #define GL_LINE_STRIP 0x0003
92 #define GL_LINE_STRIP 0x0003
93 #define GL_TRIANGLES 0x0004
93 #define GL_TRIANGLES 0x0004
94 #define GL_TRIANGLE_STRIP 0x0005
94 #define GL_TRIANGLE_STRIP 0x0005
95 #define GL_TRIANGLE_FAN 0x0006
95 #define GL_TRIANGLE_FAN 0x0006
96 #define GL_QUADS 0x0007
96 #define GL_QUADS 0x0007
97 #define GL_QUAD_STRIP 0x0008
97 #define GL_QUAD_STRIP 0x0008
98 #define GL_POLYGON 0x0009
98 #define GL_POLYGON 0x0009
99
99
100 /* BlendingFactorDest */
100 /* BlendingFactorDest */
101 #define GL_ZERO 0
101 #define GL_ZERO 0
102 #define GL_ONE 1
102 #define GL_ONE 1
103 #define GL_SRC_COLOR 0x0300
103 #define GL_SRC_COLOR 0x0300
104 #define GL_ONE_MINUS_SRC_COLOR 0x0301
104 #define GL_ONE_MINUS_SRC_COLOR 0x0301
105 #define GL_SRC_ALPHA 0x0302
105 #define GL_SRC_ALPHA 0x0302
106 #define GL_ONE_MINUS_SRC_ALPHA 0x0303
106 #define GL_ONE_MINUS_SRC_ALPHA 0x0303
107 #define GL_DST_ALPHA 0x0304
107 #define GL_DST_ALPHA 0x0304
108 #define GL_ONE_MINUS_DST_ALPHA 0x0305
108 #define GL_ONE_MINUS_DST_ALPHA 0x0305
109
109
110 /* BlendingFactorSrc */
110 /* BlendingFactorSrc */
111 /* GL_ZERO */
111 /* GL_ZERO */
112 /* GL_ONE */
112 /* GL_ONE */
113 #define GL_DST_COLOR 0x0306
113 #define GL_DST_COLOR 0x0306
114 #define GL_ONE_MINUS_DST_COLOR 0x0307
114 #define GL_ONE_MINUS_DST_COLOR 0x0307
115 #define GL_SRC_ALPHA_SATURATE 0x0308
115 #define GL_SRC_ALPHA_SATURATE 0x0308
116 /* GL_SRC_ALPHA */
116 /* GL_SRC_ALPHA */
117 /* GL_ONE_MINUS_SRC_ALPHA */
117 /* GL_ONE_MINUS_SRC_ALPHA */
118 /* GL_DST_ALPHA */
118 /* GL_DST_ALPHA */
119 /* GL_ONE_MINUS_DST_ALPHA */
119 /* GL_ONE_MINUS_DST_ALPHA */
120
120
121 /* Boolean */
121 /* Boolean */
122 #define GL_TRUE 1
122 #define GL_TRUE 1
123 #define GL_FALSE 0
123 #define GL_FALSE 0
124
124
125 /* ClearBufferMask */
125 /* ClearBufferMask */
126 /* GL_COLOR_BUFFER_BIT */
126 /* GL_COLOR_BUFFER_BIT */
127 /* GL_ACCUM_BUFFER_BIT */
127 /* GL_ACCUM_BUFFER_BIT */
128 /* GL_STENCIL_BUFFER_BIT */
128 /* GL_STENCIL_BUFFER_BIT */
129 /* GL_DEPTH_BUFFER_BIT */
129 /* GL_DEPTH_BUFFER_BIT */
130
130
131 /* ClientArrayType */
131 /* ClientArrayType */
132 /* GL_VERTEX_ARRAY */
132 /* GL_VERTEX_ARRAY */
133 /* GL_NORMAL_ARRAY */
133 /* GL_NORMAL_ARRAY */
134 /* GL_COLOR_ARRAY */
134 /* GL_COLOR_ARRAY */
135 /* GL_INDEX_ARRAY */
135 /* GL_INDEX_ARRAY */
136 /* GL_TEXTURE_COORD_ARRAY */
136 /* GL_TEXTURE_COORD_ARRAY */
137 /* GL_EDGE_FLAG_ARRAY */
137 /* GL_EDGE_FLAG_ARRAY */
138
138
139 /* ClipPlaneName */
139 /* ClipPlaneName */
140 #define GL_CLIP_PLANE0 0x3000
140 #define GL_CLIP_PLANE0 0x3000
141 #define GL_CLIP_PLANE1 0x3001
141 #define GL_CLIP_PLANE1 0x3001
142 #define GL_CLIP_PLANE2 0x3002
142 #define GL_CLIP_PLANE2 0x3002
143 #define GL_CLIP_PLANE3 0x3003
143 #define GL_CLIP_PLANE3 0x3003
144 #define GL_CLIP_PLANE4 0x3004
144 #define GL_CLIP_PLANE4 0x3004
145 #define GL_CLIP_PLANE5 0x3005
145 #define GL_CLIP_PLANE5 0x3005
146
146
147 /* ColorMaterialFace */
147 /* ColorMaterialFace */
148 /* GL_FRONT */
148 /* GL_FRONT */
149 /* GL_BACK */
149 /* GL_BACK */
150 /* GL_FRONT_AND_BACK */
150 /* GL_FRONT_AND_BACK */
151
151
152 /* ColorMaterialParameter */
152 /* ColorMaterialParameter */
153 /* GL_AMBIENT */
153 /* GL_AMBIENT */
154 /* GL_DIFFUSE */
154 /* GL_DIFFUSE */
155 /* GL_SPECULAR */
155 /* GL_SPECULAR */
156 /* GL_EMISSION */
156 /* GL_EMISSION */
157 /* GL_AMBIENT_AND_DIFFUSE */
157 /* GL_AMBIENT_AND_DIFFUSE */
158
158
159 /* ColorPointerType */
159 /* ColorPointerType */
160 /* GL_BYTE */
160 /* GL_BYTE */
161 /* GL_UNSIGNED_BYTE */
161 /* GL_UNSIGNED_BYTE */
162 /* GL_SHORT */
162 /* GL_SHORT */
163 /* GL_UNSIGNED_SHORT */
163 /* GL_UNSIGNED_SHORT */
164 /* GL_INT */
164 /* GL_INT */
165 /* GL_UNSIGNED_INT */
165 /* GL_UNSIGNED_INT */
166 /* GL_FLOAT */
166 /* GL_FLOAT */
167 /* GL_DOUBLE */
167 /* GL_DOUBLE */
168
168
169 /* CullFaceMode */
169 /* CullFaceMode */
170 /* GL_FRONT */
170 /* GL_FRONT */
171 /* GL_BACK */
171 /* GL_BACK */
172 /* GL_FRONT_AND_BACK */
172 /* GL_FRONT_AND_BACK */
173
173
174 /* DataType */
174 /* DataType */
175 #define GL_BYTE 0x1400
175 #define GL_BYTE 0x1400
176 #define GL_UNSIGNED_BYTE 0x1401
176 #define GL_UNSIGNED_BYTE 0x1401
177 #define GL_SHORT 0x1402
177 #define GL_SHORT 0x1402
178 #define GL_UNSIGNED_SHORT 0x1403
178 #define GL_UNSIGNED_SHORT 0x1403
179 #define GL_INT 0x1404
179 #define GL_INT 0x1404
180 #define GL_UNSIGNED_INT 0x1405
180 #define GL_UNSIGNED_INT 0x1405
181 #define GL_FLOAT 0x1406
181 #define GL_FLOAT 0x1406
182 #define GL_2_BYTES 0x1407
182 #define GL_2_BYTES 0x1407
183 #define GL_3_BYTES 0x1408
183 #define GL_3_BYTES 0x1408
184 #define GL_4_BYTES 0x1409
184 #define GL_4_BYTES 0x1409
185 #define GL_DOUBLE 0x140A
185 #define GL_DOUBLE 0x140A
186
186
187 /* DepthFunction */
187 /* DepthFunction */
188 /* GL_NEVER */
188 /* GL_NEVER */
189 /* GL_LESS */
189 /* GL_LESS */
190 /* GL_EQUAL */
190 /* GL_EQUAL */
191 /* GL_LEQUAL */
191 /* GL_LEQUAL */
192 /* GL_GREATER */
192 /* GL_GREATER */
193 /* GL_NOTEQUAL */
193 /* GL_NOTEQUAL */
194 /* GL_GEQUAL */
194 /* GL_GEQUAL */
195 /* GL_ALWAYS */
195 /* GL_ALWAYS */
196
196
197 /* DrawBufferMode */
197 /* DrawBufferMode */
198 #define GL_NONE 0
198 #define GL_NONE 0
199 #define GL_FRONT_LEFT 0x0400
199 #define GL_FRONT_LEFT 0x0400
200 #define GL_FRONT_RIGHT 0x0401
200 #define GL_FRONT_RIGHT 0x0401
201 #define GL_BACK_LEFT 0x0402
201 #define GL_BACK_LEFT 0x0402
202 #define GL_BACK_RIGHT 0x0403
202 #define GL_BACK_RIGHT 0x0403
203 #define GL_FRONT 0x0404
203 #define GL_FRONT 0x0404
204 #define GL_BACK 0x0405
204 #define GL_BACK 0x0405
205 #define GL_LEFT 0x0406
205 #define GL_LEFT 0x0406
206 #define GL_RIGHT 0x0407
206 #define GL_RIGHT 0x0407
207 #define GL_FRONT_AND_BACK 0x0408
207 #define GL_FRONT_AND_BACK 0x0408
208 #define GL_AUX0 0x0409
208 #define GL_AUX0 0x0409
209 #define GL_AUX1 0x040A
209 #define GL_AUX1 0x040A
210 #define GL_AUX2 0x040B
210 #define GL_AUX2 0x040B
211 #define GL_AUX3 0x040C
211 #define GL_AUX3 0x040C
212
212
213 /* Enable */
213 /* Enable */
214 /* GL_FOG */
214 /* GL_FOG */
215 /* GL_LIGHTING */
215 /* GL_LIGHTING */
216 /* GL_TEXTURE_1D */
216 /* GL_TEXTURE_1D */
217 /* GL_TEXTURE_2D */
217 /* GL_TEXTURE_2D */
218 /* GL_LINE_STIPPLE */
218 /* GL_LINE_STIPPLE */
219 /* GL_POLYGON_STIPPLE */
219 /* GL_POLYGON_STIPPLE */
220 /* GL_CULL_FACE */
220 /* GL_CULL_FACE */
221 /* GL_ALPHA_TEST */
221 /* GL_ALPHA_TEST */
222 /* GL_BLEND */
222 /* GL_BLEND */
223 /* GL_INDEX_LOGIC_OP */
223 /* GL_INDEX_LOGIC_OP */
224 /* GL_COLOR_LOGIC_OP */
224 /* GL_COLOR_LOGIC_OP */
225 /* GL_DITHER */
225 /* GL_DITHER */
226 /* GL_STENCIL_TEST */
226 /* GL_STENCIL_TEST */
227 /* GL_DEPTH_TEST */
227 /* GL_DEPTH_TEST */
228 /* GL_CLIP_PLANE0 */
228 /* GL_CLIP_PLANE0 */
229 /* GL_CLIP_PLANE1 */
229 /* GL_CLIP_PLANE1 */
230 /* GL_CLIP_PLANE2 */
230 /* GL_CLIP_PLANE2 */
231 /* GL_CLIP_PLANE3 */
231 /* GL_CLIP_PLANE3 */
232 /* GL_CLIP_PLANE4 */
232 /* GL_CLIP_PLANE4 */
233 /* GL_CLIP_PLANE5 */
233 /* GL_CLIP_PLANE5 */
234 /* GL_LIGHT0 */
234 /* GL_LIGHT0 */
235 /* GL_LIGHT1 */
235 /* GL_LIGHT1 */
236 /* GL_LIGHT2 */
236 /* GL_LIGHT2 */
237 /* GL_LIGHT3 */
237 /* GL_LIGHT3 */
238 /* GL_LIGHT4 */
238 /* GL_LIGHT4 */
239 /* GL_LIGHT5 */
239 /* GL_LIGHT5 */
240 /* GL_LIGHT6 */
240 /* GL_LIGHT6 */
241 /* GL_LIGHT7 */
241 /* GL_LIGHT7 */
242 /* GL_TEXTURE_GEN_S */
242 /* GL_TEXTURE_GEN_S */
243 /* GL_TEXTURE_GEN_T */
243 /* GL_TEXTURE_GEN_T */
244 /* GL_TEXTURE_GEN_R */
244 /* GL_TEXTURE_GEN_R */
245 /* GL_TEXTURE_GEN_Q */
245 /* GL_TEXTURE_GEN_Q */
246 /* GL_MAP1_VERTEX_3 */
246 /* GL_MAP1_VERTEX_3 */
247 /* GL_MAP1_VERTEX_4 */
247 /* GL_MAP1_VERTEX_4 */
248 /* GL_MAP1_COLOR_4 */
248 /* GL_MAP1_COLOR_4 */
249 /* GL_MAP1_INDEX */
249 /* GL_MAP1_INDEX */
250 /* GL_MAP1_NORMAL */
250 /* GL_MAP1_NORMAL */
251 /* GL_MAP1_TEXTURE_COORD_1 */
251 /* GL_MAP1_TEXTURE_COORD_1 */
252 /* GL_MAP1_TEXTURE_COORD_2 */
252 /* GL_MAP1_TEXTURE_COORD_2 */
253 /* GL_MAP1_TEXTURE_COORD_3 */
253 /* GL_MAP1_TEXTURE_COORD_3 */
254 /* GL_MAP1_TEXTURE_COORD_4 */
254 /* GL_MAP1_TEXTURE_COORD_4 */
255 /* GL_MAP2_VERTEX_3 */
255 /* GL_MAP2_VERTEX_3 */
256 /* GL_MAP2_VERTEX_4 */
256 /* GL_MAP2_VERTEX_4 */
257 /* GL_MAP2_COLOR_4 */
257 /* GL_MAP2_COLOR_4 */
258 /* GL_MAP2_INDEX */
258 /* GL_MAP2_INDEX */
259 /* GL_MAP2_NORMAL */
259 /* GL_MAP2_NORMAL */
260 /* GL_MAP2_TEXTURE_COORD_1 */
260 /* GL_MAP2_TEXTURE_COORD_1 */
261 /* GL_MAP2_TEXTURE_COORD_2 */
261 /* GL_MAP2_TEXTURE_COORD_2 */
262 /* GL_MAP2_TEXTURE_COORD_3 */
262 /* GL_MAP2_TEXTURE_COORD_3 */
263 /* GL_MAP2_TEXTURE_COORD_4 */
263 /* GL_MAP2_TEXTURE_COORD_4 */
264 /* GL_POINT_SMOOTH */
264 /* GL_POINT_SMOOTH */
265 /* GL_LINE_SMOOTH */
265 /* GL_LINE_SMOOTH */
266 /* GL_POLYGON_SMOOTH */
266 /* GL_POLYGON_SMOOTH */
267 /* GL_SCISSOR_TEST */
267 /* GL_SCISSOR_TEST */
268 /* GL_COLOR_MATERIAL */
268 /* GL_COLOR_MATERIAL */
269 /* GL_NORMALIZE */
269 /* GL_NORMALIZE */
270 /* GL_AUTO_NORMAL */
270 /* GL_AUTO_NORMAL */
271 /* GL_VERTEX_ARRAY */
271 /* GL_VERTEX_ARRAY */
272 /* GL_NORMAL_ARRAY */
272 /* GL_NORMAL_ARRAY */
273 /* GL_COLOR_ARRAY */
273 /* GL_COLOR_ARRAY */
274 /* GL_INDEX_ARRAY */
274 /* GL_INDEX_ARRAY */
275 /* GL_TEXTURE_COORD_ARRAY */
275 /* GL_TEXTURE_COORD_ARRAY */
276 /* GL_EDGE_FLAG_ARRAY */
276 /* GL_EDGE_FLAG_ARRAY */
277 /* GL_POLYGON_OFFSET_POINT */
277 /* GL_POLYGON_OFFSET_POINT */
278 /* GL_POLYGON_OFFSET_LINE */
278 /* GL_POLYGON_OFFSET_LINE */
279 /* GL_POLYGON_OFFSET_FILL */
279 /* GL_POLYGON_OFFSET_FILL */
280
280
281 /* ErrorCode */
281 /* ErrorCode */
282 #define GL_NO_ERROR 0
282 #define GL_NO_ERROR 0
283 #define GL_INVALID_ENUM 0x0500
283 #define GL_INVALID_ENUM 0x0500
284 #define GL_INVALID_VALUE 0x0501
284 #define GL_INVALID_VALUE 0x0501
285 #define GL_INVALID_OPERATION 0x0502
285 #define GL_INVALID_OPERATION 0x0502
286 #define GL_STACK_OVERFLOW 0x0503
286 #define GL_STACK_OVERFLOW 0x0503
287 #define GL_STACK_UNDERFLOW 0x0504
287 #define GL_STACK_UNDERFLOW 0x0504
288 #define GL_OUT_OF_MEMORY 0x0505
288 #define GL_OUT_OF_MEMORY 0x0505
289
289
290 /* FeedBackMode */
290 /* FeedBackMode */
291 #define GL_2D 0x0600
291 #define GL_2D 0x0600
292 #define GL_3D 0x0601
292 #define GL_3D 0x0601
293 #define GL_3D_COLOR 0x0602
293 #define GL_3D_COLOR 0x0602
294 #define GL_3D_COLOR_TEXTURE 0x0603
294 #define GL_3D_COLOR_TEXTURE 0x0603
295 #define GL_4D_COLOR_TEXTURE 0x0604
295 #define GL_4D_COLOR_TEXTURE 0x0604
296
296
297 /* FeedBackToken */
297 /* FeedBackToken */
298 #define GL_PASS_THROUGH_TOKEN 0x0700
298 #define GL_PASS_THROUGH_TOKEN 0x0700
299 #define GL_POINT_TOKEN 0x0701
299 #define GL_POINT_TOKEN 0x0701
300 #define GL_LINE_TOKEN 0x0702
300 #define GL_LINE_TOKEN 0x0702
301 #define GL_POLYGON_TOKEN 0x0703
301 #define GL_POLYGON_TOKEN 0x0703
302 #define GL_BITMAP_TOKEN 0x0704
302 #define GL_BITMAP_TOKEN 0x0704
303 #define GL_DRAW_PIXEL_TOKEN 0x0705
303 #define GL_DRAW_PIXEL_TOKEN 0x0705
304 #define GL_COPY_PIXEL_TOKEN 0x0706
304 #define GL_COPY_PIXEL_TOKEN 0x0706
305 #define GL_LINE_RESET_TOKEN 0x0707
305 #define GL_LINE_RESET_TOKEN 0x0707
306
306
307 /* FogMode */
307 /* FogMode */
308 /* GL_LINEAR */
308 /* GL_LINEAR */
309 #define GL_EXP 0x0800
309 #define GL_EXP 0x0800
310 #define GL_EXP2 0x0801
310 #define GL_EXP2 0x0801
311
311
312
312
313 /* FogParameter */
313 /* FogParameter */
314 /* GL_FOG_COLOR */
314 /* GL_FOG_COLOR */
315 /* GL_FOG_DENSITY */
315 /* GL_FOG_DENSITY */
316 /* GL_FOG_END */
316 /* GL_FOG_END */
317 /* GL_FOG_INDEX */
317 /* GL_FOG_INDEX */
318 /* GL_FOG_MODE */
318 /* GL_FOG_MODE */
319 /* GL_FOG_START */
319 /* GL_FOG_START */
320
320
321 /* FrontFaceDirection */
321 /* FrontFaceDirection */
322 #define GL_CW 0x0900
322 #define GL_CW 0x0900
323 #define GL_CCW 0x0901
323 #define GL_CCW 0x0901
324
324
325 /* GetMapTarget */
325 /* GetMapTarget */
326 #define GL_COEFF 0x0A00
326 #define GL_COEFF 0x0A00
327 #define GL_ORDER 0x0A01
327 #define GL_ORDER 0x0A01
328 #define GL_DOMAIN 0x0A02
328 #define GL_DOMAIN 0x0A02
329
329
330 /* GetPixelMap */
330 /* GetPixelMap */
331 /* GL_PIXEL_MAP_I_TO_I */
331 /* GL_PIXEL_MAP_I_TO_I */
332 /* GL_PIXEL_MAP_S_TO_S */
332 /* GL_PIXEL_MAP_S_TO_S */
333 /* GL_PIXEL_MAP_I_TO_R */
333 /* GL_PIXEL_MAP_I_TO_R */
334 /* GL_PIXEL_MAP_I_TO_G */
334 /* GL_PIXEL_MAP_I_TO_G */
335 /* GL_PIXEL_MAP_I_TO_B */
335 /* GL_PIXEL_MAP_I_TO_B */
336 /* GL_PIXEL_MAP_I_TO_A */
336 /* GL_PIXEL_MAP_I_TO_A */
337 /* GL_PIXEL_MAP_R_TO_R */
337 /* GL_PIXEL_MAP_R_TO_R */
338 /* GL_PIXEL_MAP_G_TO_G */
338 /* GL_PIXEL_MAP_G_TO_G */
339 /* GL_PIXEL_MAP_B_TO_B */
339 /* GL_PIXEL_MAP_B_TO_B */
340 /* GL_PIXEL_MAP_A_TO_A */
340 /* GL_PIXEL_MAP_A_TO_A */
341
341
342 /* GetPointerTarget */
342 /* GetPointerTarget */
343 /* GL_VERTEX_ARRAY_POINTER */
343 /* GL_VERTEX_ARRAY_POINTER */
344 /* GL_NORMAL_ARRAY_POINTER */
344 /* GL_NORMAL_ARRAY_POINTER */
345 /* GL_COLOR_ARRAY_POINTER */
345 /* GL_COLOR_ARRAY_POINTER */
346 /* GL_INDEX_ARRAY_POINTER */
346 /* GL_INDEX_ARRAY_POINTER */
347 /* GL_TEXTURE_COORD_ARRAY_POINTER */
347 /* GL_TEXTURE_COORD_ARRAY_POINTER */
348 /* GL_EDGE_FLAG_ARRAY_POINTER */
348 /* GL_EDGE_FLAG_ARRAY_POINTER */
349
349
350 /* GetTarget */
350 /* GetTarget */
351 #define GL_CURRENT_COLOR 0x0B00
351 #define GL_CURRENT_COLOR 0x0B00
352 #define GL_CURRENT_INDEX 0x0B01
352 #define GL_CURRENT_INDEX 0x0B01
353 #define GL_CURRENT_NORMAL 0x0B02
353 #define GL_CURRENT_NORMAL 0x0B02
354 #define GL_CURRENT_TEXTURE_COORDS 0x0B03
354 #define GL_CURRENT_TEXTURE_COORDS 0x0B03
355 #define GL_CURRENT_RASTER_COLOR 0x0B04
355 #define GL_CURRENT_RASTER_COLOR 0x0B04
356 #define GL_CURRENT_RASTER_INDEX 0x0B05
356 #define GL_CURRENT_RASTER_INDEX 0x0B05
357 #define GL_CURRENT_RASTER_TEXTURE_COORDS 0x0B06
357 #define GL_CURRENT_RASTER_TEXTURE_COORDS 0x0B06
358 #define GL_CURRENT_RASTER_POSITION 0x0B07
358 #define GL_CURRENT_RASTER_POSITION 0x0B07
359 #define GL_CURRENT_RASTER_POSITION_VALID 0x0B08
359 #define GL_CURRENT_RASTER_POSITION_VALID 0x0B08
360 #define GL_CURRENT_RASTER_DISTANCE 0x0B09
360 #define GL_CURRENT_RASTER_DISTANCE 0x0B09
361 #define GL_POINT_SMOOTH 0x0B10
361 #define GL_POINT_SMOOTH 0x0B10
362 #define GL_POINT_SIZE 0x0B11
362 #define GL_POINT_SIZE 0x0B11
363 #define GL_POINT_SIZE_RANGE 0x0B12
363 #define GL_POINT_SIZE_RANGE 0x0B12
364 #define GL_POINT_SIZE_GRANULARITY 0x0B13
364 #define GL_POINT_SIZE_GRANULARITY 0x0B13
365 #define GL_LINE_SMOOTH 0x0B20
365 #define GL_LINE_SMOOTH 0x0B20
366 #define GL_LINE_WIDTH 0x0B21
366 #define GL_LINE_WIDTH 0x0B21
367 #define GL_LINE_WIDTH_RANGE 0x0B22
367 #define GL_LINE_WIDTH_RANGE 0x0B22
368 #define GL_LINE_WIDTH_GRANULARITY 0x0B23
368 #define GL_LINE_WIDTH_GRANULARITY 0x0B23
369 #define GL_LINE_STIPPLE 0x0B24
369 #define GL_LINE_STIPPLE 0x0B24
370 #define GL_LINE_STIPPLE_PATTERN 0x0B25
370 #define GL_LINE_STIPPLE_PATTERN 0x0B25
371 #define GL_LINE_STIPPLE_REPEAT 0x0B26
371 #define GL_LINE_STIPPLE_REPEAT 0x0B26
372 #define GL_LIST_MODE 0x0B30
372 #define GL_LIST_MODE 0x0B30
373 #define GL_MAX_LIST_NESTING 0x0B31
373 #define GL_MAX_LIST_NESTING 0x0B31
374 #define GL_LIST_BASE 0x0B32
374 #define GL_LIST_BASE 0x0B32
375 #define GL_LIST_INDEX 0x0B33
375 #define GL_LIST_INDEX 0x0B33
376 #define GL_POLYGON_MODE 0x0B40
376 #define GL_POLYGON_MODE 0x0B40
377 #define GL_POLYGON_SMOOTH 0x0B41
377 #define GL_POLYGON_SMOOTH 0x0B41
378 #define GL_POLYGON_STIPPLE 0x0B42
378 #define GL_POLYGON_STIPPLE 0x0B42
379 #define GL_EDGE_FLAG 0x0B43
379 #define GL_EDGE_FLAG 0x0B43
380 #define GL_CULL_FACE 0x0B44
380 #define GL_CULL_FACE 0x0B44
381 #define GL_CULL_FACE_MODE 0x0B45
381 #define GL_CULL_FACE_MODE 0x0B45
382 #define GL_FRONT_FACE 0x0B46
382 #define GL_FRONT_FACE 0x0B46
383 #define GL_LIGHTING 0x0B50
383 #define GL_LIGHTING 0x0B50
384 #define GL_LIGHT_MODEL_LOCAL_VIEWER 0x0B51
384 #define GL_LIGHT_MODEL_LOCAL_VIEWER 0x0B51
385 #define GL_LIGHT_MODEL_TWO_SIDE 0x0B52
385 #define GL_LIGHT_MODEL_TWO_SIDE 0x0B52
386 #define GL_LIGHT_MODEL_AMBIENT 0x0B53
386 #define GL_LIGHT_MODEL_AMBIENT 0x0B53
387 #define GL_SHADE_MODEL 0x0B54
387 #define GL_SHADE_MODEL 0x0B54
388 #define GL_COLOR_MATERIAL_FACE 0x0B55
388 #define GL_COLOR_MATERIAL_FACE 0x0B55
389 #define GL_COLOR_MATERIAL_PARAMETER 0x0B56
389 #define GL_COLOR_MATERIAL_PARAMETER 0x0B56
390 #define GL_COLOR_MATERIAL 0x0B57
390 #define GL_COLOR_MATERIAL 0x0B57
391 #define GL_FOG 0x0B60
391 #define GL_FOG 0x0B60
392 #define GL_FOG_INDEX 0x0B61
392 #define GL_FOG_INDEX 0x0B61
393 #define GL_FOG_DENSITY 0x0B62
393 #define GL_FOG_DENSITY 0x0B62
394 #define GL_FOG_START 0x0B63
394 #define GL_FOG_START 0x0B63
395 #define GL_FOG_END 0x0B64
395 #define GL_FOG_END 0x0B64
396 #define GL_FOG_MODE 0x0B65
396 #define GL_FOG_MODE 0x0B65
397 #define GL_FOG_COLOR 0x0B66
397 #define GL_FOG_COLOR 0x0B66
398 #define GL_DEPTH_RANGE 0x0B70
398 #define GL_DEPTH_RANGE 0x0B70
399 #define GL_DEPTH_TEST 0x0B71
399 #define GL_DEPTH_TEST 0x0B71
400 #define GL_DEPTH_WRITEMASK 0x0B72
400 #define GL_DEPTH_WRITEMASK 0x0B72
401 #define GL_DEPTH_CLEAR_VALUE 0x0B73
401 #define GL_DEPTH_CLEAR_VALUE 0x0B73
402 #define GL_DEPTH_FUNC 0x0B74
402 #define GL_DEPTH_FUNC 0x0B74
403 #define GL_ACCUM_CLEAR_VALUE 0x0B80
403 #define GL_ACCUM_CLEAR_VALUE 0x0B80
404 #define GL_STENCIL_TEST 0x0B90
404 #define GL_STENCIL_TEST 0x0B90
405 #define GL_STENCIL_CLEAR_VALUE 0x0B91
405 #define GL_STENCIL_CLEAR_VALUE 0x0B91
406 #define GL_STENCIL_FUNC 0x0B92
406 #define GL_STENCIL_FUNC 0x0B92
407 #define GL_STENCIL_VALUE_MASK 0x0B93
407 #define GL_STENCIL_VALUE_MASK 0x0B93
408 #define GL_STENCIL_FAIL 0x0B94
408 #define GL_STENCIL_FAIL 0x0B94
409 #define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95
409 #define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95
410 #define GL_STENCIL_PASS_DEPTH_PASS 0x0B96
410 #define GL_STENCIL_PASS_DEPTH_PASS 0x0B96
411 #define GL_STENCIL_REF 0x0B97
411 #define GL_STENCIL_REF 0x0B97
412 #define GL_STENCIL_WRITEMASK 0x0B98
412 #define GL_STENCIL_WRITEMASK 0x0B98
413 #define GL_MATRIX_MODE 0x0BA0
413 #define GL_MATRIX_MODE 0x0BA0
414 #define GL_NORMALIZE 0x0BA1
414 #define GL_NORMALIZE 0x0BA1
415 #define GL_VIEWPORT 0x0BA2
415 #define GL_VIEWPORT 0x0BA2
416 #define GL_MODELVIEW_STACK_DEPTH 0x0BA3
416 #define GL_MODELVIEW_STACK_DEPTH 0x0BA3
417 #define GL_PROJECTION_STACK_DEPTH 0x0BA4
417 #define GL_PROJECTION_STACK_DEPTH 0x0BA4
418 #define GL_TEXTURE_STACK_DEPTH 0x0BA5
418 #define GL_TEXTURE_STACK_DEPTH 0x0BA5
419 #define GL_MODELVIEW_MATRIX 0x0BA6
419 #define GL_MODELVIEW_MATRIX 0x0BA6
420 #define GL_PROJECTION_MATRIX 0x0BA7
420 #define GL_PROJECTION_MATRIX 0x0BA7
421 #define GL_TEXTURE_MATRIX 0x0BA8
421 #define GL_TEXTURE_MATRIX 0x0BA8
422 #define GL_ATTRIB_STACK_DEPTH 0x0BB0
422 #define GL_ATTRIB_STACK_DEPTH 0x0BB0
423 #define GL_CLIENT_ATTRIB_STACK_DEPTH 0x0BB1
423 #define GL_CLIENT_ATTRIB_STACK_DEPTH 0x0BB1
424 #define GL_ALPHA_TEST 0x0BC0
424 #define GL_ALPHA_TEST 0x0BC0
425 #define GL_ALPHA_TEST_FUNC 0x0BC1
425 #define GL_ALPHA_TEST_FUNC 0x0BC1
426 #define GL_ALPHA_TEST_REF 0x0BC2
426 #define GL_ALPHA_TEST_REF 0x0BC2
427 #define GL_DITHER 0x0BD0
427 #define GL_DITHER 0x0BD0
428 #define GL_BLEND_DST 0x0BE0
428 #define GL_BLEND_DST 0x0BE0
429 #define GL_BLEND_SRC 0x0BE1
429 #define GL_BLEND_SRC 0x0BE1
430 #define GL_BLEND 0x0BE2
430 #define GL_BLEND 0x0BE2
431 #define GL_LOGIC_OP_MODE 0x0BF0
431 #define GL_LOGIC_OP_MODE 0x0BF0
432 #define GL_INDEX_LOGIC_OP 0x0BF1
432 #define GL_INDEX_LOGIC_OP 0x0BF1
433 #define GL_COLOR_LOGIC_OP 0x0BF2
433 #define GL_COLOR_LOGIC_OP 0x0BF2
434 #define GL_AUX_BUFFERS 0x0C00
434 #define GL_AUX_BUFFERS 0x0C00
435 #define GL_DRAW_BUFFER 0x0C01
435 #define GL_DRAW_BUFFER 0x0C01
436 #define GL_READ_BUFFER 0x0C02
436 #define GL_READ_BUFFER 0x0C02
437 #define GL_SCISSOR_BOX 0x0C10
437 #define GL_SCISSOR_BOX 0x0C10
438 #define GL_SCISSOR_TEST 0x0C11
438 #define GL_SCISSOR_TEST 0x0C11
439 #define GL_INDEX_CLEAR_VALUE 0x0C20
439 #define GL_INDEX_CLEAR_VALUE 0x0C20
440 #define GL_INDEX_WRITEMASK 0x0C21
440 #define GL_INDEX_WRITEMASK 0x0C21
441 #define GL_COLOR_CLEAR_VALUE 0x0C22
441 #define GL_COLOR_CLEAR_VALUE 0x0C22
442 #define GL_COLOR_WRITEMASK 0x0C23
442 #define GL_COLOR_WRITEMASK 0x0C23
443 #define GL_INDEX_MODE 0x0C30
443 #define GL_INDEX_MODE 0x0C30
444 #define GL_RGBA_MODE 0x0C31
444 #define GL_RGBA_MODE 0x0C31
445 #define GL_DOUBLEBUFFER 0x0C32
445 #define GL_DOUBLEBUFFER 0x0C32
446 #define GL_STEREO 0x0C33
446 #define GL_STEREO 0x0C33
447 #define GL_RENDER_MODE 0x0C40
447 #define GL_RENDER_MODE 0x0C40
448 #define GL_PERSPECTIVE_CORRECTION_HINT 0x0C50
448 #define GL_PERSPECTIVE_CORRECTION_HINT 0x0C50
449 #define GL_POINT_SMOOTH_HINT 0x0C51
449 #define GL_POINT_SMOOTH_HINT 0x0C51
450 #define GL_LINE_SMOOTH_HINT 0x0C52
450 #define GL_LINE_SMOOTH_HINT 0x0C52
451 #define GL_POLYGON_SMOOTH_HINT 0x0C53
451 #define GL_POLYGON_SMOOTH_HINT 0x0C53
452 #define GL_FOG_HINT 0x0C54
452 #define GL_FOG_HINT 0x0C54
453 #define GL_TEXTURE_GEN_S 0x0C60
453 #define GL_TEXTURE_GEN_S 0x0C60
454 #define GL_TEXTURE_GEN_T 0x0C61
454 #define GL_TEXTURE_GEN_T 0x0C61
455 #define GL_TEXTURE_GEN_R 0x0C62
455 #define GL_TEXTURE_GEN_R 0x0C62
456 #define GL_TEXTURE_GEN_Q 0x0C63
456 #define GL_TEXTURE_GEN_Q 0x0C63
457 #define GL_PIXEL_MAP_I_TO_I 0x0C70
457 #define GL_PIXEL_MAP_I_TO_I 0x0C70
458 #define GL_PIXEL_MAP_S_TO_S 0x0C71
458 #define GL_PIXEL_MAP_S_TO_S 0x0C71
459 #define GL_PIXEL_MAP_I_TO_R 0x0C72
459 #define GL_PIXEL_MAP_I_TO_R 0x0C72
460 #define GL_PIXEL_MAP_I_TO_G 0x0C73
460 #define GL_PIXEL_MAP_I_TO_G 0x0C73
461 #define GL_PIXEL_MAP_I_TO_B 0x0C74
461 #define GL_PIXEL_MAP_I_TO_B 0x0C74
462 #define GL_PIXEL_MAP_I_TO_A 0x0C75
462 #define GL_PIXEL_MAP_I_TO_A 0x0C75
463 #define GL_PIXEL_MAP_R_TO_R 0x0C76
463 #define GL_PIXEL_MAP_R_TO_R 0x0C76
464 #define GL_PIXEL_MAP_G_TO_G 0x0C77
464 #define GL_PIXEL_MAP_G_TO_G 0x0C77
465 #define GL_PIXEL_MAP_B_TO_B 0x0C78
465 #define GL_PIXEL_MAP_B_TO_B 0x0C78
466 #define GL_PIXEL_MAP_A_TO_A 0x0C79
466 #define GL_PIXEL_MAP_A_TO_A 0x0C79
467 #define GL_PIXEL_MAP_I_TO_I_SIZE 0x0CB0
467 #define GL_PIXEL_MAP_I_TO_I_SIZE 0x0CB0
468 #define GL_PIXEL_MAP_S_TO_S_SIZE 0x0CB1
468 #define GL_PIXEL_MAP_S_TO_S_SIZE 0x0CB1
469 #define GL_PIXEL_MAP_I_TO_R_SIZE 0x0CB2
469 #define GL_PIXEL_MAP_I_TO_R_SIZE 0x0CB2
470 #define GL_PIXEL_MAP_I_TO_G_SIZE 0x0CB3
470 #define GL_PIXEL_MAP_I_TO_G_SIZE 0x0CB3
471 #define GL_PIXEL_MAP_I_TO_B_SIZE 0x0CB4
471 #define GL_PIXEL_MAP_I_TO_B_SIZE 0x0CB4
472 #define GL_PIXEL_MAP_I_TO_A_SIZE 0x0CB5
472 #define GL_PIXEL_MAP_I_TO_A_SIZE 0x0CB5
473 #define GL_PIXEL_MAP_R_TO_R_SIZE 0x0CB6
473 #define GL_PIXEL_MAP_R_TO_R_SIZE 0x0CB6
474 #define GL_PIXEL_MAP_G_TO_G_SIZE 0x0CB7
474 #define GL_PIXEL_MAP_G_TO_G_SIZE 0x0CB7
475 #define GL_PIXEL_MAP_B_TO_B_SIZE 0x0CB8
475 #define GL_PIXEL_MAP_B_TO_B_SIZE 0x0CB8
476 #define GL_PIXEL_MAP_A_TO_A_SIZE 0x0CB9
476 #define GL_PIXEL_MAP_A_TO_A_SIZE 0x0CB9
477 #define GL_UNPACK_SWAP_BYTES 0x0CF0
477 #define GL_UNPACK_SWAP_BYTES 0x0CF0
478 #define GL_UNPACK_LSB_FIRST 0x0CF1
478 #define GL_UNPACK_LSB_FIRST 0x0CF1
479 #define GL_UNPACK_ROW_LENGTH 0x0CF2
479 #define GL_UNPACK_ROW_LENGTH 0x0CF2
480 #define GL_UNPACK_SKIP_ROWS 0x0CF3
480 #define GL_UNPACK_SKIP_ROWS 0x0CF3
481 #define GL_UNPACK_SKIP_PIXELS 0x0CF4
481 #define GL_UNPACK_SKIP_PIXELS 0x0CF4
482 #define GL_UNPACK_ALIGNMENT 0x0CF5
482 #define GL_UNPACK_ALIGNMENT 0x0CF5
483 #define GL_PACK_SWAP_BYTES 0x0D00
483 #define GL_PACK_SWAP_BYTES 0x0D00
484 #define GL_PACK_LSB_FIRST 0x0D01
484 #define GL_PACK_LSB_FIRST 0x0D01
485 #define GL_PACK_ROW_LENGTH 0x0D02
485 #define GL_PACK_ROW_LENGTH 0x0D02
486 #define GL_PACK_SKIP_ROWS 0x0D03
486 #define GL_PACK_SKIP_ROWS 0x0D03
487 #define GL_PACK_SKIP_PIXELS 0x0D04
487 #define GL_PACK_SKIP_PIXELS 0x0D04
488 #define GL_PACK_ALIGNMENT 0x0D05
488 #define GL_PACK_ALIGNMENT 0x0D05
489 #define GL_MAP_COLOR 0x0D10
489 #define GL_MAP_COLOR 0x0D10
490 #define GL_MAP_STENCIL 0x0D11
490 #define GL_MAP_STENCIL 0x0D11
491 #define GL_INDEX_SHIFT 0x0D12
491 #define GL_INDEX_SHIFT 0x0D12
492 #define GL_INDEX_OFFSET 0x0D13
492 #define GL_INDEX_OFFSET 0x0D13
493 #define GL_RED_SCALE 0x0D14
493 #define GL_RED_SCALE 0x0D14
494 #define GL_RED_BIAS 0x0D15
494 #define GL_RED_BIAS 0x0D15
495 #define GL_ZOOM_X 0x0D16
495 #define GL_ZOOM_X 0x0D16
496 #define GL_ZOOM_Y 0x0D17
496 #define GL_ZOOM_Y 0x0D17
497 #define GL_GREEN_SCALE 0x0D18
497 #define GL_GREEN_SCALE 0x0D18
498 #define GL_GREEN_BIAS 0x0D19
498 #define GL_GREEN_BIAS 0x0D19
499 #define GL_BLUE_SCALE 0x0D1A
499 #define GL_BLUE_SCALE 0x0D1A
500 #define GL_BLUE_BIAS 0x0D1B
500 #define GL_BLUE_BIAS 0x0D1B
501 #define GL_ALPHA_SCALE 0x0D1C
501 #define GL_ALPHA_SCALE 0x0D1C
502 #define GL_ALPHA_BIAS 0x0D1D
502 #define GL_ALPHA_BIAS 0x0D1D
503 #define GL_DEPTH_SCALE 0x0D1E
503 #define GL_DEPTH_SCALE 0x0D1E
504 #define GL_DEPTH_BIAS 0x0D1F
504 #define GL_DEPTH_BIAS 0x0D1F
505 #define GL_MAX_EVAL_ORDER 0x0D30
505 #define GL_MAX_EVAL_ORDER 0x0D30
506 #define GL_MAX_LIGHTS 0x0D31
506 #define GL_MAX_LIGHTS 0x0D31
507 #define GL_MAX_CLIP_PLANES 0x0D32
507 #define GL_MAX_CLIP_PLANES 0x0D32
508 #define GL_MAX_TEXTURE_SIZE 0x0D33
508 #define GL_MAX_TEXTURE_SIZE 0x0D33
509 #define GL_MAX_PIXEL_MAP_TABLE 0x0D34
509 #define GL_MAX_PIXEL_MAP_TABLE 0x0D34
510 #define GL_MAX_ATTRIB_STACK_DEPTH 0x0D35
510 #define GL_MAX_ATTRIB_STACK_DEPTH 0x0D35
511 #define GL_MAX_MODELVIEW_STACK_DEPTH 0x0D36
511 #define GL_MAX_MODELVIEW_STACK_DEPTH 0x0D36
512 #define GL_MAX_NAME_STACK_DEPTH 0x0D37
512 #define GL_MAX_NAME_STACK_DEPTH 0x0D37
513 #define GL_MAX_PROJECTION_STACK_DEPTH 0x0D38
513 #define GL_MAX_PROJECTION_STACK_DEPTH 0x0D38
514 #define GL_MAX_TEXTURE_STACK_DEPTH 0x0D39
514 #define GL_MAX_TEXTURE_STACK_DEPTH 0x0D39
515 #define GL_MAX_VIEWPORT_DIMS 0x0D3A
515 #define GL_MAX_VIEWPORT_DIMS 0x0D3A
516 #define GL_MAX_CLIENT_ATTRIB_STACK_DEPTH 0x0D3B
516 #define GL_MAX_CLIENT_ATTRIB_STACK_DEPTH 0x0D3B
517 #define GL_SUBPIXEL_BITS 0x0D50
517 #define GL_SUBPIXEL_BITS 0x0D50
518 #define GL_INDEX_BITS 0x0D51
518 #define GL_INDEX_BITS 0x0D51
519 #define GL_RED_BITS 0x0D52
519 #define GL_RED_BITS 0x0D52
520 #define GL_GREEN_BITS 0x0D53
520 #define GL_GREEN_BITS 0x0D53
521 #define GL_BLUE_BITS 0x0D54
521 #define GL_BLUE_BITS 0x0D54
522 #define GL_ALPHA_BITS 0x0D55
522 #define GL_ALPHA_BITS 0x0D55
523 #define GL_DEPTH_BITS 0x0D56
523 #define GL_DEPTH_BITS 0x0D56
524 #define GL_STENCIL_BITS 0x0D57
524 #define GL_STENCIL_BITS 0x0D57
525 #define GL_ACCUM_RED_BITS 0x0D58
525 #define GL_ACCUM_RED_BITS 0x0D58
526 #define GL_ACCUM_GREEN_BITS 0x0D59
526 #define GL_ACCUM_GREEN_BITS 0x0D59
527 #define GL_ACCUM_BLUE_BITS 0x0D5A
527 #define GL_ACCUM_BLUE_BITS 0x0D5A
528 #define GL_ACCUM_ALPHA_BITS 0x0D5B
528 #define GL_ACCUM_ALPHA_BITS 0x0D5B
529 #define GL_NAME_STACK_DEPTH 0x0D70
529 #define GL_NAME_STACK_DEPTH 0x0D70
530 #define GL_AUTO_NORMAL 0x0D80
530 #define GL_AUTO_NORMAL 0x0D80
531 #define GL_MAP1_COLOR_4 0x0D90
531 #define GL_MAP1_COLOR_4 0x0D90
532 #define GL_MAP1_INDEX 0x0D91
532 #define GL_MAP1_INDEX 0x0D91
533 #define GL_MAP1_NORMAL 0x0D92
533 #define GL_MAP1_NORMAL 0x0D92
534 #define GL_MAP1_TEXTURE_COORD_1 0x0D93
534 #define GL_MAP1_TEXTURE_COORD_1 0x0D93
535 #define GL_MAP1_TEXTURE_COORD_2 0x0D94
535 #define GL_MAP1_TEXTURE_COORD_2 0x0D94
536 #define GL_MAP1_TEXTURE_COORD_3 0x0D95
536 #define GL_MAP1_TEXTURE_COORD_3 0x0D95
537 #define GL_MAP1_TEXTURE_COORD_4 0x0D96
537 #define GL_MAP1_TEXTURE_COORD_4 0x0D96
538 #define GL_MAP1_VERTEX_3 0x0D97
538 #define GL_MAP1_VERTEX_3 0x0D97
539 #define GL_MAP1_VERTEX_4 0x0D98
539 #define GL_MAP1_VERTEX_4 0x0D98
540 #define GL_MAP2_COLOR_4 0x0DB0
540 #define GL_MAP2_COLOR_4 0x0DB0
541 #define GL_MAP2_INDEX 0x0DB1
541 #define GL_MAP2_INDEX 0x0DB1
542 #define GL_MAP2_NORMAL 0x0DB2
542 #define GL_MAP2_NORMAL 0x0DB2
543 #define GL_MAP2_TEXTURE_COORD_1 0x0DB3
543 #define GL_MAP2_TEXTURE_COORD_1 0x0DB3
544 #define GL_MAP2_TEXTURE_COORD_2 0x0DB4
544 #define GL_MAP2_TEXTURE_COORD_2 0x0DB4
545 #define GL_MAP2_TEXTURE_COORD_3 0x0DB5
545 #define GL_MAP2_TEXTURE_COORD_3 0x0DB5
546 #define GL_MAP2_TEXTURE_COORD_4 0x0DB6
546 #define GL_MAP2_TEXTURE_COORD_4 0x0DB6
547 #define GL_MAP2_VERTEX_3 0x0DB7
547 #define GL_MAP2_VERTEX_3 0x0DB7
548 #define GL_MAP2_VERTEX_4 0x0DB8
548 #define GL_MAP2_VERTEX_4 0x0DB8
549 #define GL_MAP1_GRID_DOMAIN 0x0DD0
549 #define GL_MAP1_GRID_DOMAIN 0x0DD0
550 #define GL_MAP1_GRID_SEGMENTS 0x0DD1
550 #define GL_MAP1_GRID_SEGMENTS 0x0DD1
551 #define GL_MAP2_GRID_DOMAIN 0x0DD2
551 #define GL_MAP2_GRID_DOMAIN 0x0DD2
552 #define GL_MAP2_GRID_SEGMENTS 0x0DD3
552 #define GL_MAP2_GRID_SEGMENTS 0x0DD3
553 #define GL_TEXTURE_1D 0x0DE0
553 #define GL_TEXTURE_1D 0x0DE0
554 #define GL_TEXTURE_2D 0x0DE1
554 #define GL_TEXTURE_2D 0x0DE1
555 #define GL_FEEDBACK_BUFFER_POINTER 0x0DF0
555 #define GL_FEEDBACK_BUFFER_POINTER 0x0DF0
556 #define GL_FEEDBACK_BUFFER_SIZE 0x0DF1
556 #define GL_FEEDBACK_BUFFER_SIZE 0x0DF1
557 #define GL_FEEDBACK_BUFFER_TYPE 0x0DF2
557 #define GL_FEEDBACK_BUFFER_TYPE 0x0DF2
558 #define GL_SELECTION_BUFFER_POINTER 0x0DF3
558 #define GL_SELECTION_BUFFER_POINTER 0x0DF3
559 #define GL_SELECTION_BUFFER_SIZE 0x0DF4
559 #define GL_SELECTION_BUFFER_SIZE 0x0DF4
560 /* GL_TEXTURE_BINDING_1D */
560 /* GL_TEXTURE_BINDING_1D */
561 /* GL_TEXTURE_BINDING_2D */
561 /* GL_TEXTURE_BINDING_2D */
562 /* GL_VERTEX_ARRAY */
562 /* GL_VERTEX_ARRAY */
563 /* GL_NORMAL_ARRAY */
563 /* GL_NORMAL_ARRAY */
564 /* GL_COLOR_ARRAY */
564 /* GL_COLOR_ARRAY */
565 /* GL_INDEX_ARRAY */
565 /* GL_INDEX_ARRAY */
566 /* GL_TEXTURE_COORD_ARRAY */
566 /* GL_TEXTURE_COORD_ARRAY */
567 /* GL_EDGE_FLAG_ARRAY */
567 /* GL_EDGE_FLAG_ARRAY */
568 /* GL_VERTEX_ARRAY_SIZE */
568 /* GL_VERTEX_ARRAY_SIZE */
569 /* GL_VERTEX_ARRAY_TYPE */
569 /* GL_VERTEX_ARRAY_TYPE */
570 /* GL_VERTEX_ARRAY_STRIDE */
570 /* GL_VERTEX_ARRAY_STRIDE */
571 /* GL_NORMAL_ARRAY_TYPE */
571 /* GL_NORMAL_ARRAY_TYPE */
572 /* GL_NORMAL_ARRAY_STRIDE */
572 /* GL_NORMAL_ARRAY_STRIDE */
573 /* GL_COLOR_ARRAY_SIZE */
573 /* GL_COLOR_ARRAY_SIZE */
574 /* GL_COLOR_ARRAY_TYPE */
574 /* GL_COLOR_ARRAY_TYPE */
575 /* GL_COLOR_ARRAY_STRIDE */
575 /* GL_COLOR_ARRAY_STRIDE */
576 /* GL_INDEX_ARRAY_TYPE */
576 /* GL_INDEX_ARRAY_TYPE */
577 /* GL_INDEX_ARRAY_STRIDE */
577 /* GL_INDEX_ARRAY_STRIDE */
578 /* GL_TEXTURE_COORD_ARRAY_SIZE */
578 /* GL_TEXTURE_COORD_ARRAY_SIZE */
579 /* GL_TEXTURE_COORD_ARRAY_TYPE */
579 /* GL_TEXTURE_COORD_ARRAY_TYPE */
580 /* GL_TEXTURE_COORD_ARRAY_STRIDE */
580 /* GL_TEXTURE_COORD_ARRAY_STRIDE */
581 /* GL_EDGE_FLAG_ARRAY_STRIDE */
581 /* GL_EDGE_FLAG_ARRAY_STRIDE */
582 /* GL_POLYGON_OFFSET_FACTOR */
582 /* GL_POLYGON_OFFSET_FACTOR */
583 /* GL_POLYGON_OFFSET_UNITS */
583 /* GL_POLYGON_OFFSET_UNITS */
584
584
585 /* GetTextureParameter */
585 /* GetTextureParameter */
586 /* GL_TEXTURE_MAG_FILTER */
586 /* GL_TEXTURE_MAG_FILTER */
587 /* GL_TEXTURE_MIN_FILTER */
587 /* GL_TEXTURE_MIN_FILTER */
588 /* GL_TEXTURE_WRAP_S */
588 /* GL_TEXTURE_WRAP_S */
589 /* GL_TEXTURE_WRAP_T */
589 /* GL_TEXTURE_WRAP_T */
590 #define GL_TEXTURE_WIDTH 0x1000
590 #define GL_TEXTURE_WIDTH 0x1000
591 #define GL_TEXTURE_HEIGHT 0x1001
591 #define GL_TEXTURE_HEIGHT 0x1001
592 #define GL_TEXTURE_INTERNAL_FORMAT 0x1003
592 #define GL_TEXTURE_INTERNAL_FORMAT 0x1003
593 #define GL_TEXTURE_BORDER_COLOR 0x1004
593 #define GL_TEXTURE_BORDER_COLOR 0x1004
594 #define GL_TEXTURE_BORDER 0x1005
594 #define GL_TEXTURE_BORDER 0x1005
595 /* GL_TEXTURE_RED_SIZE */
595 /* GL_TEXTURE_RED_SIZE */
596 /* GL_TEXTURE_GREEN_SIZE */
596 /* GL_TEXTURE_GREEN_SIZE */
597 /* GL_TEXTURE_BLUE_SIZE */
597 /* GL_TEXTURE_BLUE_SIZE */
598 /* GL_TEXTURE_ALPHA_SIZE */
598 /* GL_TEXTURE_ALPHA_SIZE */
599 /* GL_TEXTURE_LUMINANCE_SIZE */
599 /* GL_TEXTURE_LUMINANCE_SIZE */
600 /* GL_TEXTURE_INTENSITY_SIZE */
600 /* GL_TEXTURE_INTENSITY_SIZE */
601 /* GL_TEXTURE_PRIORITY */
601 /* GL_TEXTURE_PRIORITY */
602 /* GL_TEXTURE_RESIDENT */
602 /* GL_TEXTURE_RESIDENT */
603
603
604 /* HintMode */
604 /* HintMode */
605 #define GL_DONT_CARE 0x1100
605 #define GL_DONT_CARE 0x1100
606 #define GL_FASTEST 0x1101
606 #define GL_FASTEST 0x1101
607 #define GL_NICEST 0x1102
607 #define GL_NICEST 0x1102
608
608
609 /* HintTarget */
609 /* HintTarget */
610 /* GL_PERSPECTIVE_CORRECTION_HINT */
610 /* GL_PERSPECTIVE_CORRECTION_HINT */
611 /* GL_POINT_SMOOTH_HINT */
611 /* GL_POINT_SMOOTH_HINT */
612 /* GL_LINE_SMOOTH_HINT */
612 /* GL_LINE_SMOOTH_HINT */
613 /* GL_POLYGON_SMOOTH_HINT */
613 /* GL_POLYGON_SMOOTH_HINT */
614 /* GL_FOG_HINT */
614 /* GL_FOG_HINT */
615 /* GL_PHONG_HINT */
615 /* GL_PHONG_HINT */
616
616
617 /* IndexPointerType */
617 /* IndexPointerType */
618 /* GL_SHORT */
618 /* GL_SHORT */
619 /* GL_INT */
619 /* GL_INT */
620 /* GL_FLOAT */
620 /* GL_FLOAT */
621 /* GL_DOUBLE */
621 /* GL_DOUBLE */
622
622
623 /* LightModelParameter */
623 /* LightModelParameter */
624 /* GL_LIGHT_MODEL_AMBIENT */
624 /* GL_LIGHT_MODEL_AMBIENT */
625 /* GL_LIGHT_MODEL_LOCAL_VIEWER */
625 /* GL_LIGHT_MODEL_LOCAL_VIEWER */
626 /* GL_LIGHT_MODEL_TWO_SIDE */
626 /* GL_LIGHT_MODEL_TWO_SIDE */
627
627
628 /* LightName */
628 /* LightName */
629 #define GL_LIGHT0 0x4000
629 #define GL_LIGHT0 0x4000
630 #define GL_LIGHT1 0x4001
630 #define GL_LIGHT1 0x4001
631 #define GL_LIGHT2 0x4002
631 #define GL_LIGHT2 0x4002
632 #define GL_LIGHT3 0x4003
632 #define GL_LIGHT3 0x4003
633 #define GL_LIGHT4 0x4004
633 #define GL_LIGHT4 0x4004
634 #define GL_LIGHT5 0x4005
634 #define GL_LIGHT5 0x4005
635 #define GL_LIGHT6 0x4006
635 #define GL_LIGHT6 0x4006
636 #define GL_LIGHT7 0x4007
636 #define GL_LIGHT7 0x4007
637
637
638 /* LightParameter */
638 /* LightParameter */
639 #define GL_AMBIENT 0x1200
639 #define GL_AMBIENT 0x1200
640 #define GL_DIFFUSE 0x1201
640 #define GL_DIFFUSE 0x1201
641 #define GL_SPECULAR 0x1202
641 #define GL_SPECULAR 0x1202
642 #define GL_POSITION 0x1203
642 #define GL_POSITION 0x1203
643 #define GL_SPOT_DIRECTION 0x1204
643 #define GL_SPOT_DIRECTION 0x1204
644 #define GL_SPOT_EXPONENT 0x1205
644 #define GL_SPOT_EXPONENT 0x1205
645 #define GL_SPOT_CUTOFF 0x1206
645 #define GL_SPOT_CUTOFF 0x1206
646 #define GL_CONSTANT_ATTENUATION 0x1207
646 #define GL_CONSTANT_ATTENUATION 0x1207
647 #define GL_LINEAR_ATTENUATION 0x1208
647 #define GL_LINEAR_ATTENUATION 0x1208
648 #define GL_QUADRATIC_ATTENUATION 0x1209
648 #define GL_QUADRATIC_ATTENUATION 0x1209
649
649
650 /* InterleavedArrays */
650 /* InterleavedArrays */
651 /* GL_V2F */
651 /* GL_V2F */
652 /* GL_V3F */
652 /* GL_V3F */
653 /* GL_C4UB_V2F */
653 /* GL_C4UB_V2F */
654 /* GL_C4UB_V3F */
654 /* GL_C4UB_V3F */
655 /* GL_C3F_V3F */
655 /* GL_C3F_V3F */
656 /* GL_N3F_V3F */
656 /* GL_N3F_V3F */
657 /* GL_C4F_N3F_V3F */
657 /* GL_C4F_N3F_V3F */
658 /* GL_T2F_V3F */
658 /* GL_T2F_V3F */
659 /* GL_T4F_V4F */
659 /* GL_T4F_V4F */
660 /* GL_T2F_C4UB_V3F */
660 /* GL_T2F_C4UB_V3F */
661 /* GL_T2F_C3F_V3F */
661 /* GL_T2F_C3F_V3F */
662 /* GL_T2F_N3F_V3F */
662 /* GL_T2F_N3F_V3F */
663 /* GL_T2F_C4F_N3F_V3F */
663 /* GL_T2F_C4F_N3F_V3F */
664 /* GL_T4F_C4F_N3F_V4F */
664 /* GL_T4F_C4F_N3F_V4F */
665
665
666 /* ListMode */
666 /* ListMode */
667 #define GL_COMPILE 0x1300
667 #define GL_COMPILE 0x1300
668 #define GL_COMPILE_AND_EXECUTE 0x1301
668 #define GL_COMPILE_AND_EXECUTE 0x1301
669
669
670 /* ListNameType */
670 /* ListNameType */
671 /* GL_BYTE */
671 /* GL_BYTE */
672 /* GL_UNSIGNED_BYTE */
672 /* GL_UNSIGNED_BYTE */
673 /* GL_SHORT */
673 /* GL_SHORT */
674 /* GL_UNSIGNED_SHORT */
674 /* GL_UNSIGNED_SHORT */
675 /* GL_INT */
675 /* GL_INT */
676 /* GL_UNSIGNED_INT */
676 /* GL_UNSIGNED_INT */
677 /* GL_FLOAT */
677 /* GL_FLOAT */
678 /* GL_2_BYTES */
678 /* GL_2_BYTES */
679 /* GL_3_BYTES */
679 /* GL_3_BYTES */
680 /* GL_4_BYTES */
680 /* GL_4_BYTES */
681
681
682 /* LogicOp */
682 /* LogicOp */
683 #define GL_CLEAR 0x1500
683 #define GL_CLEAR 0x1500
684 #define GL_AND 0x1501
684 #define GL_AND 0x1501
685 #define GL_AND_REVERSE 0x1502
685 #define GL_AND_REVERSE 0x1502
686 #define GL_COPY 0x1503
686 #define GL_COPY 0x1503
687 #define GL_AND_INVERTED 0x1504
687 #define GL_AND_INVERTED 0x1504
688 #define GL_NOOP 0x1505
688 #define GL_NOOP 0x1505
689 #define GL_XOR 0x1506
689 #define GL_XOR 0x1506
690 #define GL_OR 0x1507
690 #define GL_OR 0x1507
691 #define GL_NOR 0x1508
691 #define GL_NOR 0x1508
692 #define GL_EQUIV 0x1509
692 #define GL_EQUIV 0x1509
693 #define GL_INVERT 0x150A
693 #define GL_INVERT 0x150A
694 #define GL_OR_REVERSE 0x150B
694 #define GL_OR_REVERSE 0x150B
695 #define GL_COPY_INVERTED 0x150C
695 #define GL_COPY_INVERTED 0x150C
696 #define GL_OR_INVERTED 0x150D
696 #define GL_OR_INVERTED 0x150D
697 #define GL_NAND 0x150E
697 #define GL_NAND 0x150E
698 #define GL_SET 0x150F
698 #define GL_SET 0x150F
699
699
700 /* MapTarget */
700 /* MapTarget */
701 /* GL_MAP1_COLOR_4 */
701 /* GL_MAP1_COLOR_4 */
702 /* GL_MAP1_INDEX */
702 /* GL_MAP1_INDEX */
703 /* GL_MAP1_NORMAL */
703 /* GL_MAP1_NORMAL */
704 /* GL_MAP1_TEXTURE_COORD_1 */
704 /* GL_MAP1_TEXTURE_COORD_1 */
705 /* GL_MAP1_TEXTURE_COORD_2 */
705 /* GL_MAP1_TEXTURE_COORD_2 */
706 /* GL_MAP1_TEXTURE_COORD_3 */
706 /* GL_MAP1_TEXTURE_COORD_3 */
707 /* GL_MAP1_TEXTURE_COORD_4 */
707 /* GL_MAP1_TEXTURE_COORD_4 */
708 /* GL_MAP1_VERTEX_3 */
708 /* GL_MAP1_VERTEX_3 */
709 /* GL_MAP1_VERTEX_4 */
709 /* GL_MAP1_VERTEX_4 */
710 /* GL_MAP2_COLOR_4 */
710 /* GL_MAP2_COLOR_4 */
711 /* GL_MAP2_INDEX */
711 /* GL_MAP2_INDEX */
712 /* GL_MAP2_NORMAL */
712 /* GL_MAP2_NORMAL */
713 /* GL_MAP2_TEXTURE_COORD_1 */
713 /* GL_MAP2_TEXTURE_COORD_1 */
714 /* GL_MAP2_TEXTURE_COORD_2 */
714 /* GL_MAP2_TEXTURE_COORD_2 */
715 /* GL_MAP2_TEXTURE_COORD_3 */
715 /* GL_MAP2_TEXTURE_COORD_3 */
716 /* GL_MAP2_TEXTURE_COORD_4 */
716 /* GL_MAP2_TEXTURE_COORD_4 */
717 /* GL_MAP2_VERTEX_3 */
717 /* GL_MAP2_VERTEX_3 */
718 /* GL_MAP2_VERTEX_4 */
718 /* GL_MAP2_VERTEX_4 */
719
719
720 /* MaterialFace */
720 /* MaterialFace */
721 /* GL_FRONT */
721 /* GL_FRONT */
722 /* GL_BACK */
722 /* GL_BACK */
723 /* GL_FRONT_AND_BACK */
723 /* GL_FRONT_AND_BACK */
724
724
725 /* MaterialParameter */
725 /* MaterialParameter */
726 #define GL_EMISSION 0x1600
726 #define GL_EMISSION 0x1600
727 #define GL_SHININESS 0x1601
727 #define GL_SHININESS 0x1601
728 #define GL_AMBIENT_AND_DIFFUSE 0x1602
728 #define GL_AMBIENT_AND_DIFFUSE 0x1602
729 #define GL_COLOR_INDEXES 0x1603
729 #define GL_COLOR_INDEXES 0x1603
730 /* GL_AMBIENT */
730 /* GL_AMBIENT */
731 /* GL_DIFFUSE */
731 /* GL_DIFFUSE */
732 /* GL_SPECULAR */
732 /* GL_SPECULAR */
733
733
734 /* MatrixMode */
734 /* MatrixMode */
735 #define GL_MODELVIEW 0x1700
735 #define GL_MODELVIEW 0x1700
736 #define GL_PROJECTION 0x1701
736 #define GL_PROJECTION 0x1701
737 #define GL_TEXTURE 0x1702
737 #define GL_TEXTURE 0x1702
738
738
739 /* MeshMode1 */
739 /* MeshMode1 */
740 /* GL_POINT */
740 /* GL_POINT */
741 /* GL_LINE */
741 /* GL_LINE */
742
742
743 /* MeshMode2 */
743 /* MeshMode2 */
744 /* GL_POINT */
744 /* GL_POINT */
745 /* GL_LINE */
745 /* GL_LINE */
746 /* GL_FILL */
746 /* GL_FILL */
747
747
748 /* NormalPointerType */
748 /* NormalPointerType */
749 /* GL_BYTE */
749 /* GL_BYTE */
750 /* GL_SHORT */
750 /* GL_SHORT */
751 /* GL_INT */
751 /* GL_INT */
752 /* GL_FLOAT */
752 /* GL_FLOAT */
753 /* GL_DOUBLE */
753 /* GL_DOUBLE */
754
754
755 /* PixelCopyType */
755 /* PixelCopyType */
756 #define GL_COLOR 0x1800
756 #define GL_COLOR 0x1800
757 #define GL_DEPTH 0x1801
757 #define GL_DEPTH 0x1801
758 #define GL_STENCIL 0x1802
758 #define GL_STENCIL 0x1802
759
759
760 /* PixelFormat */
760 /* PixelFormat */
761 #define GL_COLOR_INDEX 0x1900
761 #define GL_COLOR_INDEX 0x1900
762 #define GL_STENCIL_INDEX 0x1901
762 #define GL_STENCIL_INDEX 0x1901
763 #define GL_DEPTH_COMPONENT 0x1902
763 #define GL_DEPTH_COMPONENT 0x1902
764 #define GL_RED 0x1903
764 #define GL_RED 0x1903
765 #define GL_GREEN 0x1904
765 #define GL_GREEN 0x1904
766 #define GL_BLUE 0x1905
766 #define GL_BLUE 0x1905
767 #define GL_ALPHA 0x1906
767 #define GL_ALPHA 0x1906
768 #define GL_RGB 0x1907
768 #define GL_RGB 0x1907
769 #define GL_RGBA 0x1908
769 #define GL_RGBA 0x1908
770 #define GL_LUMINANCE 0x1909
770 #define GL_LUMINANCE 0x1909
771 #define GL_LUMINANCE_ALPHA 0x190A
771 #define GL_LUMINANCE_ALPHA 0x190A
772
772
773 /* PixelMap */
773 /* PixelMap */
774 /* GL_PIXEL_MAP_I_TO_I */
774 /* GL_PIXEL_MAP_I_TO_I */
775 /* GL_PIXEL_MAP_S_TO_S */
775 /* GL_PIXEL_MAP_S_TO_S */
776 /* GL_PIXEL_MAP_I_TO_R */
776 /* GL_PIXEL_MAP_I_TO_R */
777 /* GL_PIXEL_MAP_I_TO_G */
777 /* GL_PIXEL_MAP_I_TO_G */
778 /* GL_PIXEL_MAP_I_TO_B */
778 /* GL_PIXEL_MAP_I_TO_B */
779 /* GL_PIXEL_MAP_I_TO_A */
779 /* GL_PIXEL_MAP_I_TO_A */
780 /* GL_PIXEL_MAP_R_TO_R */
780 /* GL_PIXEL_MAP_R_TO_R */
781 /* GL_PIXEL_MAP_G_TO_G */
781 /* GL_PIXEL_MAP_G_TO_G */
782 /* GL_PIXEL_MAP_B_TO_B */
782 /* GL_PIXEL_MAP_B_TO_B */
783 /* GL_PIXEL_MAP_A_TO_A */
783 /* GL_PIXEL_MAP_A_TO_A */
784
784
785 /* PixelStore */
785 /* PixelStore */
786 /* GL_UNPACK_SWAP_BYTES */
786 /* GL_UNPACK_SWAP_BYTES */
787 /* GL_UNPACK_LSB_FIRST */
787 /* GL_UNPACK_LSB_FIRST */
788 /* GL_UNPACK_ROW_LENGTH */
788 /* GL_UNPACK_ROW_LENGTH */
789 /* GL_UNPACK_SKIP_ROWS */
789 /* GL_UNPACK_SKIP_ROWS */
790 /* GL_UNPACK_SKIP_PIXELS */
790 /* GL_UNPACK_SKIP_PIXELS */
791 /* GL_UNPACK_ALIGNMENT */
791 /* GL_UNPACK_ALIGNMENT */
792 /* GL_PACK_SWAP_BYTES */
792 /* GL_PACK_SWAP_BYTES */
793 /* GL_PACK_LSB_FIRST */
793 /* GL_PACK_LSB_FIRST */
794 /* GL_PACK_ROW_LENGTH */
794 /* GL_PACK_ROW_LENGTH */
795 /* GL_PACK_SKIP_ROWS */
795 /* GL_PACK_SKIP_ROWS */
796 /* GL_PACK_SKIP_PIXELS */
796 /* GL_PACK_SKIP_PIXELS */
797 /* GL_PACK_ALIGNMENT */
797 /* GL_PACK_ALIGNMENT */
798
798
799 /* PixelTransfer */
799 /* PixelTransfer */
800 /* GL_MAP_COLOR */
800 /* GL_MAP_COLOR */
801 /* GL_MAP_STENCIL */
801 /* GL_MAP_STENCIL */
802 /* GL_INDEX_SHIFT */
802 /* GL_INDEX_SHIFT */
803 /* GL_INDEX_OFFSET */
803 /* GL_INDEX_OFFSET */
804 /* GL_RED_SCALE */
804 /* GL_RED_SCALE */
805 /* GL_RED_BIAS */
805 /* GL_RED_BIAS */
806 /* GL_GREEN_SCALE */
806 /* GL_GREEN_SCALE */
807 /* GL_GREEN_BIAS */
807 /* GL_GREEN_BIAS */
808 /* GL_BLUE_SCALE */
808 /* GL_BLUE_SCALE */
809 /* GL_BLUE_BIAS */
809 /* GL_BLUE_BIAS */
810 /* GL_ALPHA_SCALE */
810 /* GL_ALPHA_SCALE */
811 /* GL_ALPHA_BIAS */
811 /* GL_ALPHA_BIAS */
812 /* GL_DEPTH_SCALE */
812 /* GL_DEPTH_SCALE */
813 /* GL_DEPTH_BIAS */
813 /* GL_DEPTH_BIAS */
814
814
815 /* PixelType */
815 /* PixelType */
816 #define GL_BITMAP 0x1A00
816 #define GL_BITMAP 0x1A00
817 /* GL_BYTE */
817 /* GL_BYTE */
818 /* GL_UNSIGNED_BYTE */
818 /* GL_UNSIGNED_BYTE */
819 /* GL_SHORT */
819 /* GL_SHORT */
820 /* GL_UNSIGNED_SHORT */
820 /* GL_UNSIGNED_SHORT */
821 /* GL_INT */
821 /* GL_INT */
822 /* GL_UNSIGNED_INT */
822 /* GL_UNSIGNED_INT */
823 /* GL_FLOAT */
823 /* GL_FLOAT */
824
824
825 /* PolygonMode */
825 /* PolygonMode */
826 #define GL_POINT 0x1B00
826 #define GL_POINT 0x1B00
827 #define GL_LINE 0x1B01
827 #define GL_LINE 0x1B01
828 #define GL_FILL 0x1B02
828 #define GL_FILL 0x1B02
829
829
830 /* ReadBufferMode */
830 /* ReadBufferMode */
831 /* GL_FRONT_LEFT */
831 /* GL_FRONT_LEFT */
832 /* GL_FRONT_RIGHT */
832 /* GL_FRONT_RIGHT */
833 /* GL_BACK_LEFT */
833 /* GL_BACK_LEFT */
834 /* GL_BACK_RIGHT */
834 /* GL_BACK_RIGHT */
835 /* GL_FRONT */
835 /* GL_FRONT */
836 /* GL_BACK */
836 /* GL_BACK */
837 /* GL_LEFT */
837 /* GL_LEFT */
838 /* GL_RIGHT */
838 /* GL_RIGHT */
839 /* GL_AUX0 */
839 /* GL_AUX0 */
840 /* GL_AUX1 */
840 /* GL_AUX1 */
841 /* GL_AUX2 */
841 /* GL_AUX2 */
842 /* GL_AUX3 */
842 /* GL_AUX3 */
843
843
844 /* RenderingMode */
844 /* RenderingMode */
845 #define GL_RENDER 0x1C00
845 #define GL_RENDER 0x1C00
846 #define GL_FEEDBACK 0x1C01
846 #define GL_FEEDBACK 0x1C01
847 #define GL_SELECT 0x1C02
847 #define GL_SELECT 0x1C02
848
848
849 /* ShadingModel */
849 /* ShadingModel */
850 #define GL_FLAT 0x1D00
850 #define GL_FLAT 0x1D00
851 #define GL_SMOOTH 0x1D01
851 #define GL_SMOOTH 0x1D01
852
852
853
853
854 /* StencilFunction */
854 /* StencilFunction */
855 /* GL_NEVER */
855 /* GL_NEVER */
856 /* GL_LESS */
856 /* GL_LESS */
857 /* GL_EQUAL */
857 /* GL_EQUAL */
858 /* GL_LEQUAL */
858 /* GL_LEQUAL */
859 /* GL_GREATER */
859 /* GL_GREATER */
860 /* GL_NOTEQUAL */
860 /* GL_NOTEQUAL */
861 /* GL_GEQUAL */
861 /* GL_GEQUAL */
862 /* GL_ALWAYS */
862 /* GL_ALWAYS */
863
863
864 /* StencilOp */
864 /* StencilOp */
865 /* GL_ZERO */
865 /* GL_ZERO */
866 #define GL_KEEP 0x1E00
866 #define GL_KEEP 0x1E00
867 #define GL_REPLACE 0x1E01
867 #define GL_REPLACE 0x1E01
868 #define GL_INCR 0x1E02
868 #define GL_INCR 0x1E02
869 #define GL_DECR 0x1E03
869 #define GL_DECR 0x1E03
870 /* GL_INVERT */
870 /* GL_INVERT */
871
871
872 /* StringName */
872 /* StringName */
873 #define GL_VENDOR 0x1F00
873 #define GL_VENDOR 0x1F00
874 #define GL_RENDERER 0x1F01
874 #define GL_RENDERER 0x1F01
875 #define GL_VERSION 0x1F02
875 #define GL_VERSION 0x1F02
876 #define GL_EXTENSIONS 0x1F03
876 #define GL_EXTENSIONS 0x1F03
877
877
878 /* TextureCoordName */
878 /* TextureCoordName */
879 #define GL_S 0x2000
879 #define GL_S 0x2000
880 #define GL_T 0x2001
880 #define GL_T 0x2001
881 #define GL_R 0x2002
881 #define GL_R 0x2002
882 #define GL_Q 0x2003
882 #define GL_Q 0x2003
883
883
884 /* TexCoordPointerType */
884 /* TexCoordPointerType */
885 /* GL_SHORT */
885 /* GL_SHORT */
886 /* GL_INT */
886 /* GL_INT */
887 /* GL_FLOAT */
887 /* GL_FLOAT */
888 /* GL_DOUBLE */
888 /* GL_DOUBLE */
889
889
890 /* TextureEnvMode */
890 /* TextureEnvMode */
891 #define GL_MODULATE 0x2100
891 #define GL_MODULATE 0x2100
892 #define GL_DECAL 0x2101
892 #define GL_DECAL 0x2101
893 /* GL_BLEND */
893 /* GL_BLEND */
894 /* GL_REPLACE */
894 /* GL_REPLACE */
895
895
896 /* TextureEnvParameter */
896 /* TextureEnvParameter */
897 #define GL_TEXTURE_ENV_MODE 0x2200
897 #define GL_TEXTURE_ENV_MODE 0x2200
898 #define GL_TEXTURE_ENV_COLOR 0x2201
898 #define GL_TEXTURE_ENV_COLOR 0x2201
899
899
900 /* TextureEnvTarget */
900 /* TextureEnvTarget */
901 #define GL_TEXTURE_ENV 0x2300
901 #define GL_TEXTURE_ENV 0x2300
902
902
903 /* TextureGenMode */
903 /* TextureGenMode */
904 #define GL_EYE_LINEAR 0x2400
904 #define GL_EYE_LINEAR 0x2400
905 #define GL_OBJECT_LINEAR 0x2401
905 #define GL_OBJECT_LINEAR 0x2401
906 #define GL_SPHERE_MAP 0x2402
906 #define GL_SPHERE_MAP 0x2402
907
907
908 /* TextureGenParameter */
908 /* TextureGenParameter */
909 #define GL_TEXTURE_GEN_MODE 0x2500
909 #define GL_TEXTURE_GEN_MODE 0x2500
910 #define GL_OBJECT_PLANE 0x2501
910 #define GL_OBJECT_PLANE 0x2501
911 #define GL_EYE_PLANE 0x2502
911 #define GL_EYE_PLANE 0x2502
912
912
913 /* TextureMagFilter */
913 /* TextureMagFilter */
914 #define GL_NEAREST 0x2600
914 #define GL_NEAREST 0x2600
915 #define GL_LINEAR 0x2601
915 #define GL_LINEAR 0x2601
916
916
917 /* TextureMinFilter */
917 /* TextureMinFilter */
918 /* GL_NEAREST */
918 /* GL_NEAREST */
919 /* GL_LINEAR */
919 /* GL_LINEAR */
920 #define GL_NEAREST_MIPMAP_NEAREST 0x2700
920 #define GL_NEAREST_MIPMAP_NEAREST 0x2700
921 #define GL_LINEAR_MIPMAP_NEAREST 0x2701
921 #define GL_LINEAR_MIPMAP_NEAREST 0x2701
922 #define GL_NEAREST_MIPMAP_LINEAR 0x2702
922 #define GL_NEAREST_MIPMAP_LINEAR 0x2702
923 #define GL_LINEAR_MIPMAP_LINEAR 0x2703
923 #define GL_LINEAR_MIPMAP_LINEAR 0x2703
924
924
925 /* TextureParameterName */
925 /* TextureParameterName */
926 #define GL_TEXTURE_MAG_FILTER 0x2800
926 #define GL_TEXTURE_MAG_FILTER 0x2800
927 #define GL_TEXTURE_MIN_FILTER 0x2801
927 #define GL_TEXTURE_MIN_FILTER 0x2801
928 #define GL_TEXTURE_WRAP_S 0x2802
928 #define GL_TEXTURE_WRAP_S 0x2802
929 #define GL_TEXTURE_WRAP_T 0x2803
929 #define GL_TEXTURE_WRAP_T 0x2803
930 /* GL_TEXTURE_BORDER_COLOR */
930 /* GL_TEXTURE_BORDER_COLOR */
931 /* GL_TEXTURE_PRIORITY */
931 /* GL_TEXTURE_PRIORITY */
932
932
933 /* TextureTarget */
933 /* TextureTarget */
934 /* GL_TEXTURE_1D */
934 /* GL_TEXTURE_1D */
935 /* GL_TEXTURE_2D */
935 /* GL_TEXTURE_2D */
936 /* GL_PROXY_TEXTURE_1D */
936 /* GL_PROXY_TEXTURE_1D */
937 /* GL_PROXY_TEXTURE_2D */
937 /* GL_PROXY_TEXTURE_2D */
938
938
939 /* TextureWrapMode */
939 /* TextureWrapMode */
940 #define GL_CLAMP 0x2900
940 #define GL_CLAMP 0x2900
941 #define GL_REPEAT 0x2901
941 #define GL_REPEAT 0x2901
942
942
943 /* VertexPointerType */
943 /* VertexPointerType */
944 /* GL_SHORT */
944 /* GL_SHORT */
945 /* GL_INT */
945 /* GL_INT */
946 /* GL_FLOAT */
946 /* GL_FLOAT */
947 /* GL_DOUBLE */
947 /* GL_DOUBLE */
948
948
949 /* ClientAttribMask */
949 /* ClientAttribMask */
950 #define GL_CLIENT_PIXEL_STORE_BIT 0x00000001
950 #define GL_CLIENT_PIXEL_STORE_BIT 0x00000001
951 #define GL_CLIENT_VERTEX_ARRAY_BIT 0x00000002
951 #define GL_CLIENT_VERTEX_ARRAY_BIT 0x00000002
952 #define GL_CLIENT_ALL_ATTRIB_BITS 0xffffffff
952 #define GL_CLIENT_ALL_ATTRIB_BITS 0xffffffff
953
953
954 /* polygon_offset */
954 /* polygon_offset */
955 #define GL_POLYGON_OFFSET_FACTOR 0x8038
955 #define GL_POLYGON_OFFSET_FACTOR 0x8038
956 #define GL_POLYGON_OFFSET_UNITS 0x2A00
956 #define GL_POLYGON_OFFSET_UNITS 0x2A00
957 #define GL_POLYGON_OFFSET_POINT 0x2A01
957 #define GL_POLYGON_OFFSET_POINT 0x2A01
958 #define GL_POLYGON_OFFSET_LINE 0x2A02
958 #define GL_POLYGON_OFFSET_LINE 0x2A02
959 #define GL_POLYGON_OFFSET_FILL 0x8037
959 #define GL_POLYGON_OFFSET_FILL 0x8037
960
960
961 /* texture */
961 /* texture */
962 #define GL_ALPHA4 0x803B
962 #define GL_ALPHA4 0x803B
963 #define GL_ALPHA8 0x803C
963 #define GL_ALPHA8 0x803C
964 #define GL_ALPHA12 0x803D
964 #define GL_ALPHA12 0x803D
965 #define GL_ALPHA16 0x803E
965 #define GL_ALPHA16 0x803E
966 #define GL_LUMINANCE4 0x803F
966 #define GL_LUMINANCE4 0x803F
967 #define GL_LUMINANCE8 0x8040
967 #define GL_LUMINANCE8 0x8040
968 #define GL_LUMINANCE12 0x8041
968 #define GL_LUMINANCE12 0x8041
969 #define GL_LUMINANCE16 0x8042
969 #define GL_LUMINANCE16 0x8042
970 #define GL_LUMINANCE4_ALPHA4 0x8043
970 #define GL_LUMINANCE4_ALPHA4 0x8043
971 #define GL_LUMINANCE6_ALPHA2 0x8044
971 #define GL_LUMINANCE6_ALPHA2 0x8044
972 #define GL_LUMINANCE8_ALPHA8 0x8045
972 #define GL_LUMINANCE8_ALPHA8 0x8045
973 #define GL_LUMINANCE12_ALPHA4 0x8046
973 #define GL_LUMINANCE12_ALPHA4 0x8046
974 #define GL_LUMINANCE12_ALPHA12 0x8047
974 #define GL_LUMINANCE12_ALPHA12 0x8047
975 #define GL_LUMINANCE16_ALPHA16 0x8048
975 #define GL_LUMINANCE16_ALPHA16 0x8048
976 #define GL_INTENSITY 0x8049
976 #define GL_INTENSITY 0x8049
977 #define GL_INTENSITY4 0x804A
977 #define GL_INTENSITY4 0x804A
978 #define GL_INTENSITY8 0x804B
978 #define GL_INTENSITY8 0x804B
979 #define GL_INTENSITY12 0x804C
979 #define GL_INTENSITY12 0x804C
980 #define GL_INTENSITY16 0x804D
980 #define GL_INTENSITY16 0x804D
981 #define GL_R3_G3_B2 0x2A10
981 #define GL_R3_G3_B2 0x2A10
982 #define GL_RGB4 0x804F
982 #define GL_RGB4 0x804F
983 #define GL_RGB5 0x8050
983 #define GL_RGB5 0x8050
984 #define GL_RGB8 0x8051
984 #define GL_RGB8 0x8051
985 #define GL_RGB10 0x8052
985 #define GL_RGB10 0x8052
986 #define GL_RGB12 0x8053
986 #define GL_RGB12 0x8053
987 #define GL_RGB16 0x8054
987 #define GL_RGB16 0x8054
988 #define GL_RGBA2 0x8055
988 #define GL_RGBA2 0x8055
989 #define GL_RGBA4 0x8056
989 #define GL_RGBA4 0x8056
990 #define GL_RGB5_A1 0x8057
990 #define GL_RGB5_A1 0x8057
991 #define GL_RGBA8 0x8058
991 #define GL_RGBA8 0x8058
992 #define GL_RGB10_A2 0x8059
992 #define GL_RGB10_A2 0x8059
993 #define GL_RGBA12 0x805A
993 #define GL_RGBA12 0x805A
994 #define GL_RGBA16 0x805B
994 #define GL_RGBA16 0x805B
995 #define GL_TEXTURE_RED_SIZE 0x805C
995 #define GL_TEXTURE_RED_SIZE 0x805C
996 #define GL_TEXTURE_GREEN_SIZE 0x805D
996 #define GL_TEXTURE_GREEN_SIZE 0x805D
997 #define GL_TEXTURE_BLUE_SIZE 0x805E
997 #define GL_TEXTURE_BLUE_SIZE 0x805E
998 #define GL_TEXTURE_ALPHA_SIZE 0x805F
998 #define GL_TEXTURE_ALPHA_SIZE 0x805F
999 #define GL_TEXTURE_LUMINANCE_SIZE 0x8060
999 #define GL_TEXTURE_LUMINANCE_SIZE 0x8060
1000 #define GL_TEXTURE_INTENSITY_SIZE 0x8061
1000 #define GL_TEXTURE_INTENSITY_SIZE 0x8061
1001 #define GL_PROXY_TEXTURE_1D 0x8063
1001 #define GL_PROXY_TEXTURE_1D 0x8063
1002 #define GL_PROXY_TEXTURE_2D 0x8064
1002 #define GL_PROXY_TEXTURE_2D 0x8064
1003
1003
1004 /* texture_object */
1004 /* texture_object */
1005 #define GL_TEXTURE_PRIORITY 0x8066
1005 #define GL_TEXTURE_PRIORITY 0x8066
1006 #define GL_TEXTURE_RESIDENT 0x8067
1006 #define GL_TEXTURE_RESIDENT 0x8067
1007 #define GL_TEXTURE_BINDING_1D 0x8068
1007 #define GL_TEXTURE_BINDING_1D 0x8068
1008 #define GL_TEXTURE_BINDING_2D 0x8069
1008 #define GL_TEXTURE_BINDING_2D 0x8069
1009
1009
1010 /* vertex_array */
1010 /* vertex_array */
1011 #define GL_VERTEX_ARRAY 0x8074
1011 #define GL_VERTEX_ARRAY 0x8074
1012 #define GL_NORMAL_ARRAY 0x8075
1012 #define GL_NORMAL_ARRAY 0x8075
1013 #define GL_COLOR_ARRAY 0x8076
1013 #define GL_COLOR_ARRAY 0x8076
1014 #define GL_INDEX_ARRAY 0x8077
1014 #define GL_INDEX_ARRAY 0x8077
1015 #define GL_TEXTURE_COORD_ARRAY 0x8078
1015 #define GL_TEXTURE_COORD_ARRAY 0x8078
1016 #define GL_EDGE_FLAG_ARRAY 0x8079
1016 #define GL_EDGE_FLAG_ARRAY 0x8079
1017 #define GL_VERTEX_ARRAY_SIZE 0x807A
1017 #define GL_VERTEX_ARRAY_SIZE 0x807A
1018 #define GL_VERTEX_ARRAY_TYPE 0x807B
1018 #define GL_VERTEX_ARRAY_TYPE 0x807B
1019 #define GL_VERTEX_ARRAY_STRIDE 0x807C
1019 #define GL_VERTEX_ARRAY_STRIDE 0x807C
1020 #define GL_NORMAL_ARRAY_TYPE 0x807E
1020 #define GL_NORMAL_ARRAY_TYPE 0x807E
1021 #define GL_NORMAL_ARRAY_STRIDE 0x807F
1021 #define GL_NORMAL_ARRAY_STRIDE 0x807F
1022 #define GL_COLOR_ARRAY_SIZE 0x8081
1022 #define GL_COLOR_ARRAY_SIZE 0x8081
1023 #define GL_COLOR_ARRAY_TYPE 0x8082
1023 #define GL_COLOR_ARRAY_TYPE 0x8082
1024 #define GL_COLOR_ARRAY_STRIDE 0x8083
1024 #define GL_COLOR_ARRAY_STRIDE 0x8083
1025 #define GL_INDEX_ARRAY_TYPE 0x8085
1025 #define GL_INDEX_ARRAY_TYPE 0x8085
1026 #define GL_INDEX_ARRAY_STRIDE 0x8086
1026 #define GL_INDEX_ARRAY_STRIDE 0x8086
1027 #define GL_TEXTURE_COORD_ARRAY_SIZE 0x8088
1027 #define GL_TEXTURE_COORD_ARRAY_SIZE 0x8088
1028 #define GL_TEXTURE_COORD_ARRAY_TYPE 0x8089
1028 #define GL_TEXTURE_COORD_ARRAY_TYPE 0x8089
1029 #define GL_TEXTURE_COORD_ARRAY_STRIDE 0x808A
1029 #define GL_TEXTURE_COORD_ARRAY_STRIDE 0x808A
1030 #define GL_EDGE_FLAG_ARRAY_STRIDE 0x808C
1030 #define GL_EDGE_FLAG_ARRAY_STRIDE 0x808C
1031 #define GL_VERTEX_ARRAY_POINTER 0x808E
1031 #define GL_VERTEX_ARRAY_POINTER 0x808E
1032 #define GL_NORMAL_ARRAY_POINTER 0x808F
1032 #define GL_NORMAL_ARRAY_POINTER 0x808F
1033 #define GL_COLOR_ARRAY_POINTER 0x8090
1033 #define GL_COLOR_ARRAY_POINTER 0x8090
1034 #define GL_INDEX_ARRAY_POINTER 0x8091
1034 #define GL_INDEX_ARRAY_POINTER 0x8091
1035 #define GL_TEXTURE_COORD_ARRAY_POINTER 0x8092
1035 #define GL_TEXTURE_COORD_ARRAY_POINTER 0x8092
1036 #define GL_EDGE_FLAG_ARRAY_POINTER 0x8093
1036 #define GL_EDGE_FLAG_ARRAY_POINTER 0x8093
1037 #define GL_V2F 0x2A20
1037 #define GL_V2F 0x2A20
1038 #define GL_V3F 0x2A21
1038 #define GL_V3F 0x2A21
1039 #define GL_C4UB_V2F 0x2A22
1039 #define GL_C4UB_V2F 0x2A22
1040 #define GL_C4UB_V3F 0x2A23
1040 #define GL_C4UB_V3F 0x2A23
1041 #define GL_C3F_V3F 0x2A24
1041 #define GL_C3F_V3F 0x2A24
1042 #define GL_N3F_V3F 0x2A25
1042 #define GL_N3F_V3F 0x2A25
1043 #define GL_C4F_N3F_V3F 0x2A26
1043 #define GL_C4F_N3F_V3F 0x2A26
1044 #define GL_T2F_V3F 0x2A27
1044 #define GL_T2F_V3F 0x2A27
1045 #define GL_T4F_V4F 0x2A28
1045 #define GL_T4F_V4F 0x2A28
1046 #define GL_T2F_C4UB_V3F 0x2A29
1046 #define GL_T2F_C4UB_V3F 0x2A29
1047 #define GL_T2F_C3F_V3F 0x2A2A
1047 #define GL_T2F_C3F_V3F 0x2A2A
1048 #define GL_T2F_N3F_V3F 0x2A2B
1048 #define GL_T2F_N3F_V3F 0x2A2B
1049 #define GL_T2F_C4F_N3F_V3F 0x2A2C
1049 #define GL_T2F_C4F_N3F_V3F 0x2A2C
1050 #define GL_T4F_C4F_N3F_V4F 0x2A2D
1050 #define GL_T4F_C4F_N3F_V4F 0x2A2D
1051
1051
1052 /* Extensions */
1052 /* Extensions */
1053 #define GL_EXT_vertex_array 1
1053 #define GL_EXT_vertex_array 1
1054 #define GL_EXT_bgra 1
1054 #define GL_EXT_bgra 1
1055 #define GL_EXT_paletted_texture 1
1055 #define GL_EXT_paletted_texture 1
1056 #define GL_WIN_swap_hint 1
1056 #define GL_WIN_swap_hint 1
1057 #define GL_WIN_draw_range_elements 1
1057 #define GL_WIN_draw_range_elements 1
1058 // #define GL_WIN_phong_shading 1
1058 // #define GL_WIN_phong_shading 1
1059 // #define GL_WIN_specular_fog 1
1059 // #define GL_WIN_specular_fog 1
1060
1060
1061 /* EXT_vertex_array */
1061 /* EXT_vertex_array */
1062 #define GL_VERTEX_ARRAY_EXT 0x8074
1062 #define GL_VERTEX_ARRAY_EXT 0x8074
1063 #define GL_NORMAL_ARRAY_EXT 0x8075
1063 #define GL_NORMAL_ARRAY_EXT 0x8075
1064 #define GL_COLOR_ARRAY_EXT 0x8076
1064 #define GL_COLOR_ARRAY_EXT 0x8076
1065 #define GL_INDEX_ARRAY_EXT 0x8077
1065 #define GL_INDEX_ARRAY_EXT 0x8077
1066 #define GL_TEXTURE_COORD_ARRAY_EXT 0x8078
1066 #define GL_TEXTURE_COORD_ARRAY_EXT 0x8078
1067 #define GL_EDGE_FLAG_ARRAY_EXT 0x8079
1067 #define GL_EDGE_FLAG_ARRAY_EXT 0x8079
1068 #define GL_VERTEX_ARRAY_SIZE_EXT 0x807A
1068 #define GL_VERTEX_ARRAY_SIZE_EXT 0x807A
1069 #define GL_VERTEX_ARRAY_TYPE_EXT 0x807B
1069 #define GL_VERTEX_ARRAY_TYPE_EXT 0x807B
1070 #define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C
1070 #define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C
1071 #define GL_VERTEX_ARRAY_COUNT_EXT 0x807D
1071 #define GL_VERTEX_ARRAY_COUNT_EXT 0x807D
1072 #define GL_NORMAL_ARRAY_TYPE_EXT 0x807E
1072 #define GL_NORMAL_ARRAY_TYPE_EXT 0x807E
1073 #define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F
1073 #define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F
1074 #define GL_NORMAL_ARRAY_COUNT_EXT 0x8080
1074 #define GL_NORMAL_ARRAY_COUNT_EXT 0x8080
1075 #define GL_COLOR_ARRAY_SIZE_EXT 0x8081
1075 #define GL_COLOR_ARRAY_SIZE_EXT 0x8081
1076 #define GL_COLOR_ARRAY_TYPE_EXT 0x8082
1076 #define GL_COLOR_ARRAY_TYPE_EXT 0x8082
1077 #define GL_COLOR_ARRAY_STRIDE_EXT 0x8083
1077 #define GL_COLOR_ARRAY_STRIDE_EXT 0x8083
1078 #define GL_COLOR_ARRAY_COUNT_EXT 0x8084
1078 #define GL_COLOR_ARRAY_COUNT_EXT 0x8084
1079 #define GL_INDEX_ARRAY_TYPE_EXT 0x8085
1079 #define GL_INDEX_ARRAY_TYPE_EXT 0x8085
1080 #define GL_INDEX_ARRAY_STRIDE_EXT 0x8086
1080 #define GL_INDEX_ARRAY_STRIDE_EXT 0x8086
1081 #define GL_INDEX_ARRAY_COUNT_EXT 0x8087
1081 #define GL_INDEX_ARRAY_COUNT_EXT 0x8087
1082 #define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088
1082 #define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088
1083 #define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089
1083 #define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089
1084 #define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A
1084 #define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A
1085 #define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B
1085 #define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B
1086 #define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C
1086 #define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C
1087 #define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D
1087 #define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D
1088 #define GL_VERTEX_ARRAY_POINTER_EXT 0x808E
1088 #define GL_VERTEX_ARRAY_POINTER_EXT 0x808E
1089 #define GL_NORMAL_ARRAY_POINTER_EXT 0x808F
1089 #define GL_NORMAL_ARRAY_POINTER_EXT 0x808F
1090 #define GL_COLOR_ARRAY_POINTER_EXT 0x8090
1090 #define GL_COLOR_ARRAY_POINTER_EXT 0x8090
1091 #define GL_INDEX_ARRAY_POINTER_EXT 0x8091
1091 #define GL_INDEX_ARRAY_POINTER_EXT 0x8091
1092 #define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092
1092 #define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092
1093 #define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093
1093 #define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093
1094 #define GL_DOUBLE_EXT GL_DOUBLE
1094 #define GL_DOUBLE_EXT GL_DOUBLE
1095
1095
1096 /* EXT_bgra */
1096 /* EXT_bgra */
1097 #define GL_BGR_EXT 0x80E0
1097 #define GL_BGR_EXT 0x80E0
1098 #define GL_BGRA_EXT 0x80E1
1098 #define GL_BGRA_EXT 0x80E1
1099
1099
1100 /* EXT_paletted_texture */
1100 /* EXT_paletted_texture */
1101
1101
1102 /* These must match the GL_COLOR_TABLE_*_SGI enumerants */
1102 /* These must match the GL_COLOR_TABLE_*_SGI enumerants */
1103 #define GL_COLOR_TABLE_FORMAT_EXT 0x80D8
1103 #define GL_COLOR_TABLE_FORMAT_EXT 0x80D8
1104 #define GL_COLOR_TABLE_WIDTH_EXT 0x80D9
1104 #define GL_COLOR_TABLE_WIDTH_EXT 0x80D9
1105 #define GL_COLOR_TABLE_RED_SIZE_EXT 0x80DA
1105 #define GL_COLOR_TABLE_RED_SIZE_EXT 0x80DA
1106 #define GL_COLOR_TABLE_GREEN_SIZE_EXT 0x80DB
1106 #define GL_COLOR_TABLE_GREEN_SIZE_EXT 0x80DB
1107 #define GL_COLOR_TABLE_BLUE_SIZE_EXT 0x80DC
1107 #define GL_COLOR_TABLE_BLUE_SIZE_EXT 0x80DC
1108 #define GL_COLOR_TABLE_ALPHA_SIZE_EXT 0x80DD
1108 #define GL_COLOR_TABLE_ALPHA_SIZE_EXT 0x80DD
1109 #define GL_COLOR_TABLE_LUMINANCE_SIZE_EXT 0x80DE
1109 #define GL_COLOR_TABLE_LUMINANCE_SIZE_EXT 0x80DE
1110 #define GL_COLOR_TABLE_INTENSITY_SIZE_EXT 0x80DF
1110 #define GL_COLOR_TABLE_INTENSITY_SIZE_EXT 0x80DF
1111
1111
1112 #define GL_COLOR_INDEX1_EXT 0x80E2
1112 #define GL_COLOR_INDEX1_EXT 0x80E2
1113 #define GL_COLOR_INDEX2_EXT 0x80E3
1113 #define GL_COLOR_INDEX2_EXT 0x80E3
1114 #define GL_COLOR_INDEX4_EXT 0x80E4
1114 #define GL_COLOR_INDEX4_EXT 0x80E4
1115 #define GL_COLOR_INDEX8_EXT 0x80E5
1115 #define GL_COLOR_INDEX8_EXT 0x80E5
1116 #define GL_COLOR_INDEX12_EXT 0x80E6
1116 #define GL_COLOR_INDEX12_EXT 0x80E6
1117 #define GL_COLOR_INDEX16_EXT 0x80E7
1117 #define GL_COLOR_INDEX16_EXT 0x80E7
1118
1118
1119 /* WIN_draw_range_elements */
1119 /* WIN_draw_range_elements */
1120 #define GL_MAX_ELEMENTS_VERTICES_WIN 0x80E8
1120 #define GL_MAX_ELEMENTS_VERTICES_WIN 0x80E8
1121 #define GL_MAX_ELEMENTS_INDICES_WIN 0x80E9
1121 #define GL_MAX_ELEMENTS_INDICES_WIN 0x80E9
1122
1122
1123 /* WIN_phong_shading */
1123 /* WIN_phong_shading */
1124 #define GL_PHONG_WIN 0x80EA
1124 #define GL_PHONG_WIN 0x80EA
1125 #define GL_PHONG_HINT_WIN 0x80EB
1125 #define GL_PHONG_HINT_WIN 0x80EB
1126
1126
1127 /* WIN_specular_fog */
1127 /* WIN_specular_fog */
1128 #define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC
1128 #define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC
1129
1129
1130 /* For compatibility with OpenGL v1.0 */
1130 /* For compatibility with OpenGL v1.0 */
1131 #define GL_LOGIC_OP GL_INDEX_LOGIC_OP
1131 #define GL_LOGIC_OP GL_INDEX_LOGIC_OP
1132 #define GL_TEXTURE_COMPONENTS GL_TEXTURE_INTERNAL_FORMAT
1132 #define GL_TEXTURE_COMPONENTS GL_TEXTURE_INTERNAL_FORMAT
1133 #include <QtOpenGL/QtOpenGL>
1133 #include <QtOpenGL/QtOpenGL>
1134 #endif // QT_NO_OPENGL
1134 #endif // QT_NO_OPENGL
@@ -1,109 +1,111
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
3 ** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
4 **
4 **
5 ** This file is part of the Qt Script Generator project on Trolltech Labs.
5 ** This file is part of the Qt Script Generator project on Trolltech Labs.
6 **
6 **
7 ** This file may be used under the terms of the GNU General Public
7 ** This file may be used under the terms of the GNU General Public
8 ** License version 2.0 as published by the Free Software Foundation
8 ** License version 2.0 as published by the Free Software Foundation
9 ** and appearing in the file LICENSE.GPL included in the packaging of
9 ** and appearing in the file LICENSE.GPL included in the packaging of
10 ** this file. Please review the following information to ensure GNU
10 ** this file. Please review the following information to ensure GNU
11 ** General Public Licensing requirements will be met:
11 ** General Public Licensing requirements will be met:
12 ** http://www.trolltech.com/products/qt/opensource.html
12 ** http://www.trolltech.com/products/qt/opensource.html
13 **
13 **
14 ** If you are unsure which license is appropriate for your use, please
14 ** If you are unsure which license is appropriate for your use, please
15 ** review the following information:
15 ** review the following information:
16 ** http://www.trolltech.com/products/qt/licensing.html or contact the
16 ** http://www.trolltech.com/products/qt/licensing.html or contact the
17 ** sales department at sales@trolltech.com.
17 ** sales department at sales@trolltech.com.
18 **
18 **
19 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
19 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
20 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21 **
21 **
22 ****************************************************************************/
22 ****************************************************************************/
23
23
24 #include "setupgenerator.h"
24 #include "setupgenerator.h"
25 #include "classgenerator.h"
25 #include "classgenerator.h"
26 #include "reporthandler.h"
26 #include "reporthandler.h"
27 #include "fileout.h"
27 #include "fileout.h"
28
28
29 //#define Q_SCRIPT_LAZY_GENERATOR
29 //#define Q_SCRIPT_LAZY_GENERATOR
30
30
31 void SetupGenerator::addClass(const AbstractMetaClass *cls)
31 void SetupGenerator::addClass(const AbstractMetaClass *cls)
32 {
32 {
33 packHash[cls->package()].append(cls);
33 packHash[cls->package()].append(cls);
34 }
34 }
35
35
36 void writeQtScriptQtBindingsLicense(QTextStream &stream);
36 void writeQtScriptQtBindingsLicense(QTextStream &stream);
37
37
38 void maybeDeclareMetaType(QTextStream &stream, const QString &typeName,
38 void maybeDeclareMetaType(QTextStream &stream, const QString &typeName,
39 QSet<QString> &registeredTypeNames);
39 QSet<QString> &registeredTypeNames);
40 bool hasDefaultConstructor(const AbstractMetaClass *meta_class);
40 bool hasDefaultConstructor(const AbstractMetaClass *meta_class);
41
41
42 void SetupGenerator::generate()
42 void SetupGenerator::generate()
43 {
43 {
44 QHashIterator<QString, QList<const AbstractMetaClass*> > pack(packHash);
44 QHashIterator<QString, QList<const AbstractMetaClass*> > pack(packHash);
45 while (pack.hasNext()) {
45 while (pack.hasNext()) {
46 pack.next();
46 pack.next();
47 QList<const AbstractMetaClass*> list = pack.value();
47 QList<const AbstractMetaClass*> list = pack.value();
48 if (list.isEmpty())
48 if (list.isEmpty())
49 continue;
49 continue;
50
50
51 QString packKey = pack.key();
51 QString packName = pack.key();
52 QString packName = pack.key();
52 QStringList components = packName.split(".");
53 QStringList components = packName.split(".");
53 if ((components.size() > 2) && (components.at(0) == "com")
54 if ((components.size() > 2) && (components.at(0) == "com")
54 && (components.at(1) == "trolltech")) {
55 && (components.at(1) == "trolltech")) {
55 // kill com.trolltech in key
56 // kill com.trolltech in key
56 components.removeAt(0);
57 components.removeAt(0);
57 components.removeAt(0);
58 components.removeAt(0);
58 }
59 }
59 packName.replace(".", "_");
60 packName.replace(".", "_");
61 packKey.replace(".", "_");
60
62
61 QString shortPackName;
63 QString shortPackName;
62 foreach (QString comp, components) {
64 foreach (QString comp, components) {
63 comp[0] = comp[0].toUpper();
65 comp[0] = comp[0].toUpper();
64 shortPackName += comp;
66 shortPackName += comp;
65 }
67 }
66 // add missing camel case (workaround..)
68 // add missing camel case (workaround..)
67 if (shortPackName == "QtWebkit") {
69 if (shortPackName == "QtWebkit") {
68 shortPackName = "QtWebKit";
70 shortPackName = "QtWebKit";
69 } else if (shortPackName == "QtXmlpatterns") {
71 } else if (shortPackName == "QtXmlpatterns") {
70 shortPackName = "QtXmlPatterns";
72 shortPackName = "QtXmlPatterns";
71 } else if (shortPackName == "QtOpengl") {
73 } else if (shortPackName == "QtOpengl") {
72 shortPackName = "QtOpenGL";
74 shortPackName = "QtOpenGL";
73 }
75 }
74
76
75
77
76 {
78 {
77 FileOut initFile(m_out_dir + "/generated_cpp/" + packName + "/init.cpp");
79 FileOut initFile(m_out_dir + "/generated_cpp/" + packName + "/" + packKey + "_init.cpp");
78 QTextStream &s = initFile.stream;
80 QTextStream &s = initFile.stream;
79
81
80 if (FileOut::license)
82 if (FileOut::license)
81 writeQtScriptQtBindingsLicense(s);
83 writeQtScriptQtBindingsLicense(s);
82
84
83 s << "#include <PythonQt.h>" << endl;
85 s << "#include <PythonQt.h>" << endl;
84
86
85 foreach (const AbstractMetaClass *cls, list) {
87 foreach (const AbstractMetaClass *cls, list) {
86 s << "#include \"PythonQtWrapper_" << cls->name() << ".h\"" << endl;
88 s << "#include \"PythonQtWrapper_" << cls->name() << ".h\"" << endl;
87 }
89 }
88 s << endl;
90 s << endl;
89
91
90 // declare individual class creation functions
92 // declare individual class creation functions
91 s << "void PythonQt_init_" << shortPackName << "() {" << endl;
93 s << "void PythonQt_init_" << shortPackName << "() {" << endl;
92 QStringList cppClassNames;
94 QStringList cppClassNames;
93 foreach (const AbstractMetaClass *cls, list) {
95 foreach (const AbstractMetaClass *cls, list) {
94 if (ClassGenerator::isBuiltIn(cls->name())) { continue; }
96 if (ClassGenerator::isBuiltIn(cls->name())) { continue; }
95
97
96 if (cls->isQObject()) {
98 if (cls->isQObject()) {
97 s << "PythonQt::self()->registerClass(&" << cls->qualifiedCppName() << "::staticMetaObject, \"" << shortPackName <<"\", PythonQtCreateObject<PythonQtWrapper_" << cls->name() << ">);" << endl;
99 s << "PythonQt::self()->registerClass(&" << cls->qualifiedCppName() << "::staticMetaObject, \"" << shortPackName <<"\", PythonQtCreateObject<PythonQtWrapper_" << cls->name() << ">);" << endl;
98 } else {
100 } else {
99 QString baseName = cls->baseClass()?cls->baseClass()->qualifiedCppName():"";
101 QString baseName = cls->baseClass()?cls->baseClass()->qualifiedCppName():"";
100 s << "PythonQt::self()->registerCPPClass(\""<< cls->qualifiedCppName() << "\", \"" << baseName << "\", \"" << shortPackName <<"\", PythonQtCreateObject<PythonQtWrapper_" << cls->name() << ">);" << endl;
102 s << "PythonQt::self()->registerCPPClass(\""<< cls->qualifiedCppName() << "\", \"" << baseName << "\", \"" << shortPackName <<"\", PythonQtCreateObject<PythonQtWrapper_" << cls->name() << ">);" << endl;
101 }
103 }
102 }
104 }
103 s << endl;
105 s << endl;
104
106
105 s << "}";
107 s << "}";
106 s << endl;
108 s << endl;
107 }
109 }
108 }
110 }
109 }
111 }
1 NO CONTENT: file was removed, binary diff hidden
NO CONTENT: file was removed, binary diff hidden
General Comments 0
You need to be logged in to leave comments. Login now