summaryrefslogtreecommitdiffstats
path: root/src/opengl/util
diff options
context:
space:
mode:
authorKim Motoyoshi Kalland <kim.kalland@nokia.com>2009-10-14 15:29:01 (GMT)
committerKim Motoyoshi Kalland <kim.kalland@nokia.com>2009-10-14 15:43:40 (GMT)
commitd109954578b4948706577dfffb7bde139678370a (patch)
tree9e9265182786a9cbc733c84d483c8f7455414a20 /src/opengl/util
parent33d2bd641fd031d1a4e38198bf50538344a4ccdb (diff)
downloadQt-d109954578b4948706577dfffb7bde139678370a.zip
Qt-d109954578b4948706577dfffb7bde139678370a.tar.gz
Qt-d109954578b4948706577dfffb7bde139678370a.tar.bz2
Fixed the GLSL-to-assembly code generator to output enums correctly.
Fixed the output of enums such that the last item in the enum is not followed by comma. Changed the output of the license to say that the file is part of the QtOpenGL module, not the test suite. Reviewed-by: Trond
Diffstat (limited to 'src/opengl/util')
-rw-r--r--src/opengl/util/generator.cpp53
1 files changed, 32 insertions, 21 deletions
diff --git a/src/opengl/util/generator.cpp b/src/opengl/util/generator.cpp
index 62d19ff..0202fe1 100644
--- a/src/opengl/util/generator.cpp
+++ b/src/opengl/util/generator.cpp
@@ -54,6 +54,8 @@ QT_BEGIN_NAMESPACE
QT_USE_NAMESPACE
+#define TAB " "
+
typedef QPair<QString, QString> QStringPair;
QString readSourceFile(const QString &sourceFile, bool fragmentProgram = false)
@@ -243,6 +245,30 @@ QString trimmed(QString source)
return result;
}
+void writeVariablesEnum(QTextStream &out, const char *name, const QSet<QString> &s)
+{
+ out << "enum " << name << " {";
+ QSet<QString>::const_iterator it = s.begin();
+ if (it != s.end()) {
+ out << "\n" TAB "VAR_" << it->toUpper();
+ for (++it; it != s.end(); ++it)
+ out << ",\n" TAB "VAR_" << it->toUpper();
+ }
+ out << "\n};\n\n";
+}
+
+void writeTypesEnum(QTextStream &out, const char *name, const QList<QStringPair> &s)
+{
+ out << "enum " << name << " {";
+ QList<QStringPair>::const_iterator it = s.begin();
+ if (it != s.end()) {
+ out << "\n" TAB << it->first;
+ for (++it; it != s.end(); ++it)
+ out << ",\n" TAB << it->first;
+ }
+ out << "\n};\n\n";
+}
+
void writeIncludeFile(const QSet<QString> &variables,
const QList<QStringPair> &brushes,
const QList<QStringPair> &compositionModes,
@@ -257,7 +283,7 @@ void writeIncludeFile(const QSet<QString> &variables,
QTextStream out(&includeFile);
- QLatin1String tab(" ");
+ QLatin1String tab(TAB);
out << "/****************************************************************************\n"
"**\n"
@@ -265,7 +291,7 @@ void writeIncludeFile(const QSet<QString> &variables,
"** All rights reserved.\n"
"** Contact: Nokia Corporation (qt-info@nokia.com)\n"
"**\n"
- "** This file is part of the test suite of the Qt Toolkit.\n"
+ "** This file is part of the QtOpenGL module of the Qt Toolkit.\n"
"**\n"
"** $QT_BEGIN_LICENSE:LGPL$\n"
"** No Commercial Usage\n"
@@ -315,25 +341,10 @@ void writeIncludeFile(const QSet<QString> &variables,
"//\n"
"\n";
- out << "enum FragmentVariable {\n";
- foreach (QString str, variables)
- out << tab << "VAR_" << str.toUpper() << ",\n";
- out << "};\n\n";
-
- out << "enum FragmentBrushType {\n";
- foreach (QStringPair brush, brushes)
- out << tab << brush.first << ",\n";
- out << "};\n\n";
-
- out << "enum FragmentCompositionModeType {\n";
- foreach (QStringPair mode, compositionModes)
- out << tab << mode.first << ",\n";
- out << "};\n\n";
-
- out << "enum FragmentMaskType {\n";
- foreach (QStringPair mask, masks)
- out << tab << mask.first << ",\n";
- out << "};\n\n";
+ writeVariablesEnum(out, "FragmentVariable", variables);
+ writeTypesEnum(out, "FragmentBrushType", brushes);
+ writeTypesEnum(out, "FragmentCompositionModeType", compositionModes);
+ writeTypesEnum(out, "FragmentMaskType", masks);
out << "static const unsigned int num_fragment_variables = " << variables.size() << ";\n\n";
out << "static const unsigned int num_fragment_brushes = " << brushes.size() << ";\n";