summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorPeter Hartmann <peter.hartmann@nokia.com>2009-10-29 13:15:59 (GMT)
committerPeter Hartmann <peter.hartmann@nokia.com>2009-11-11 10:12:12 (GMT)
commit1502df3ddedc5a4365e12bce570d946744259785 (patch)
tree977757c93743bce8df23a180e64a08f749935ba7 /util
parentc412b5f144ea99ea70f4df291678631e13900962 (diff)
downloadQt-1502df3ddedc5a4365e12bce570d946744259785.zip
Qt-1502df3ddedc5a4365e12bce570d946744259785.tar.gz
Qt-1502df3ddedc5a4365e12bce570d946744259785.tar.bz2
utils/qlalr generator: adapt changes to xmlstream and script files
some changes were made to qxmlstream_p.h and script files directly; however, those files are generated automatically by src/corelib/xml/make-parser.sh and src/script/parser/make-parser.sh, respectively, so the generator would overwrite the manual changes to the files the next time it is run. This patch integrates those changes into the generator rather than into the files directly. Reviewed-by: Roberto Raggi Reviewed-by: Olivier Goffart
Diffstat (limited to 'util')
-rw-r--r--util/qlalr/cppgenerator.cpp71
-rw-r--r--util/qlalr/main.cpp4
-rw-r--r--util/qtscriptparser/make-parser.sh55
3 files changed, 45 insertions, 85 deletions
diff --git a/util/qlalr/cppgenerator.cpp b/util/qlalr/cppgenerator.cpp
index 39d94cd..91340d2 100644
--- a/util/qlalr/cppgenerator.cpp
+++ b/util/qlalr/cppgenerator.cpp
@@ -341,8 +341,8 @@ void CppGenerator::operator () ()
}
QTextStream out (&f);
- out << "// This file was generated by qlalr - DO NOT EDIT!\n";
+ // copyright headers must come first, otherwise the headers tests will fail
if (copyright)
{
out << copyrightHeader()
@@ -350,8 +350,16 @@ void CppGenerator::operator () ()
<< endl;
}
+ out << "// This file was generated by qlalr - DO NOT EDIT!\n";
+
out << startIncludeGuard(grammar.merged_output) << endl;
+ if (copyright) {
+ out << "#if defined(Q_OS_VXWORKS) && defined(ERROR)" << endl
+ << "# undef ERROR" << endl
+ << "#endif" << endl << endl;
+ }
+
generateDecl (out);
generateImpl (out);
out << p.decls();
@@ -371,10 +379,10 @@ void CppGenerator::operator () ()
QFile f (declFileName);
f.open (QFile::WriteOnly);
QTextStream out (&f);
- out << "// This file was generated by qlalr - DO NOT EDIT!\n";
QString prot = declFileName.toUpper ().replace (QLatin1Char ('.'), QLatin1Char ('_'));
+ // copyright headers must come first, otherwise the headers tests will fail
if (copyright)
{
out << copyrightHeader()
@@ -382,11 +390,19 @@ void CppGenerator::operator () ()
<< endl;
}
+ out << "// This file was generated by qlalr - DO NOT EDIT!\n";
+
out << "#ifndef " << prot << endl
<< "#define " << prot << endl
<< endl;
+ if (copyright) {
+ out << "#include <QtCore/qglobal.h>" << endl << endl;
+ out << "QT_BEGIN_NAMESPACE" << endl << endl;
+ }
generateDecl (out);
+ if (copyright)
+ out << "QT_END_NAMESPACE" << endl;
out << "#endif // " << prot << endl << endl;
} // end decls
@@ -395,13 +411,19 @@ void CppGenerator::operator () ()
QFile f (bitsFileName);
f.open (QFile::WriteOnly);
QTextStream out (&f);
- out << "// This file was generated by qlalr - DO NOT EDIT!\n";
+ // copyright headers must come first, otherwise the headers tests will fail
if (copyright)
out << copyrightHeader();
+ out << "// This file was generated by qlalr - DO NOT EDIT!\n";
+
out << "#include \"" << declFileName << "\"" << endl << endl;
+ if (copyright)
+ out << "QT_BEGIN_NAMESPACE" << endl << endl;
generateImpl(out);
+ if (copyright)
+ out << "QT_END_NAMESPACE" << endl;
} // end bits
@@ -410,7 +432,6 @@ void CppGenerator::operator () ()
QFile f (grammar.decl_file_name);
f.open (QFile::WriteOnly);
QTextStream out (&f);
- out << "// This file was generated by qlalr - DO NOT EDIT!\n";
out << p.decls();
}
@@ -419,7 +440,6 @@ void CppGenerator::operator () ()
QFile f (grammar.impl_file_name);
f.open (QFile::WriteOnly);
QTextStream out (&f);
- out << "// This file was generated by qlalr - DO NOT EDIT!\n";
out << p.impls();
}
}
@@ -468,9 +488,9 @@ void CppGenerator::generateDecl (QTextStream &out)
<< " GOTO_CHECK_OFFSET = " << compressed_action.check.size () << endl
<< " };" << endl
<< endl
- << " static const char *const spell [];" << endl
- << " static const int lhs [];" << endl
- << " static const int rhs [];" << endl;
+ << " static const char *const spell [];" << endl
+ << " static const short lhs [];" << endl
+ << " static const short rhs [];" << endl;
if (debug_info)
{
@@ -482,24 +502,19 @@ void CppGenerator::generateDecl (QTextStream &out)
<< "#endif // " << prot << endl << endl;
}
- out << " static const int goto_default [];" << endl
- << " static const int action_default [];" << endl
- << " static const int action_index [];" << endl
- << " static const int action_info [];" << endl
- << " static const int action_check [];" << endl
+ out << " static const short goto_default [];" << endl
+ << " static const short action_default [];" << endl
+ << " static const short action_index [];" << endl
+ << " static const short action_info [];" << endl
+ << " static const short action_check [];" << endl
<< endl
<< " static inline int nt_action (int state, int nt)" << endl
<< " {" << endl
- << " const int *const goto_index = &action_index [GOTO_INDEX_OFFSET];" << endl
- << " const int *const goto_check = &action_check [GOTO_CHECK_OFFSET];" << endl
- << endl
- << " const int yyn = goto_index [state] + nt;" << endl
- << endl
- << " if (yyn < 0 || goto_check [yyn] != nt)" << endl
+ << " const int yyn = action_index [GOTO_INDEX_OFFSET + state] + nt;" << endl
+ << " if (yyn < 0 || action_check [GOTO_CHECK_OFFSET + yyn] != nt)" << endl
<< " return goto_default [nt];" << endl
<< endl
- << " const int *const goto_info = &action_info [GOTO_INFO_OFFSET];" << endl
- << " return goto_info [yyn];" << endl
+ << " return action_info [GOTO_INFO_OFFSET + yyn];" << endl
<< " }" << endl
<< endl
<< " static inline int t_action (int state, int token)" << endl
@@ -567,7 +582,7 @@ void CppGenerator::generateImpl (QTextStream &out)
out << "};" << endl << endl;
- out << "const int " << grammar.table_name << "::lhs [] = {";
+ out << "const short " << grammar.table_name << "::lhs [] = {";
idx = 0;
for (RulePointer rule = grammar.rules.begin (); rule != grammar.rules.end (); ++rule, ++idx)
{
@@ -581,7 +596,7 @@ void CppGenerator::generateImpl (QTextStream &out)
}
out << "};" << endl << endl;
- out << "const int " << grammar.table_name << ":: rhs[] = {";
+ out << "const short " << grammar.table_name << "::rhs [] = {";
idx = 0;
for (RulePointer rule = grammar.rules.begin (); rule != grammar.rules.end (); ++rule, ++idx)
{
@@ -636,7 +651,7 @@ void CppGenerator::generateImpl (QTextStream &out)
<< "#endif // " << prot << endl << endl;
}
- out << "const int " << grammar.table_name << "::action_default [] = {";
+ out << "const short " << grammar.table_name << "::action_default [] = {";
idx = 0;
for (StatePointer state = aut.states.begin (); state != aut.states.end (); ++state, ++idx)
{
@@ -653,7 +668,7 @@ void CppGenerator::generateImpl (QTextStream &out)
}
out << "};" << endl << endl;
- out << "const int " << grammar.table_name << "::goto_default [] = {";
+ out << "const short " << grammar.table_name << "::goto_default [] = {";
for (int i = 0; i < defgoto.size (); ++i)
{
if (i)
@@ -666,7 +681,7 @@ void CppGenerator::generateImpl (QTextStream &out)
}
out << "};" << endl << endl;
- out << "const int " << grammar.table_name << "::action_index [] = {";
+ out << "const short " << grammar.table_name << "::action_index [] = {";
for (int i = 0; i < compressed_action.index.size (); ++i)
{
if (! (i % 10))
@@ -687,7 +702,7 @@ void CppGenerator::generateImpl (QTextStream &out)
}
out << "};" << endl << endl;
- out << "const int " << grammar.table_name << "::action_info [] = {";
+ out << "const short " << grammar.table_name << "::action_info [] = {";
for (int i = 0; i < compressed_action.info.size (); ++i)
{
if (! (i % 10))
@@ -708,7 +723,7 @@ void CppGenerator::generateImpl (QTextStream &out)
}
out << "};" << endl << endl;
- out << "const int " << grammar.table_name << "::action_check [] = {";
+ out << "const short " << grammar.table_name << "::action_check [] = {";
for (int i = 0; i < compressed_action.check.size (); ++i)
{
if (! (i % 10))
diff --git a/util/qlalr/main.cpp b/util/qlalr/main.cpp
index 7041e4a..d864796 100644
--- a/util/qlalr/main.cpp
+++ b/util/qlalr/main.cpp
@@ -64,7 +64,7 @@ static void help_me ()
<< " --no-debug\t\tno debug information" << endl
<< " --no-lines\t\tno #line directives" << endl
<< " --dot\t\t\tgenerate a graph" << endl
- << " --troll\t\tadd the Trolltech copyright header" << endl
+ << " --qt\t\tadd the Qt copyright header and Qt-specific types and macros" << endl
<< endl;
exit (0);
}
@@ -100,7 +100,7 @@ int main (int argc, char *argv[])
else if (arg == QLatin1String ("--no-debug"))
debug_info = false;
- else if (arg == QLatin1String ("--troll"))
+ else if (arg == QLatin1String ("--qt"))
troll_copyright = true;
else if (file_name.isEmpty ())
diff --git a/util/qtscriptparser/make-parser.sh b/util/qtscriptparser/make-parser.sh
deleted file mode 100644
index cfe2513..0000000
--- a/util/qtscriptparser/make-parser.sh
+++ /dev/null
@@ -1,55 +0,0 @@
-#!/bin/sh
-#############################################################################
-##
-## Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-## All rights reserved.
-## Contact: Nokia Corporation (qt-info@nokia.com)
-##
-## This file is the build configuration utility of the Qt Toolkit.
-##
-## $QT_BEGIN_LICENSE:LGPL$
-## No Commercial Usage
-## This file contains pre-release code and may not be distributed.
-## You may use this file in accordance with the terms and conditions
-## contained in the Technology Preview License Agreement accompanying
-## this package.
-##
-## GNU Lesser General Public License Usage
-## Alternatively, this file may be used under the terms of the GNU Lesser
-## General Public License version 2.1 as published by the Free Software
-## Foundation and appearing in the file LICENSE.LGPL included in the
-## packaging of this file. Please review the following information to
-## ensure the GNU Lesser General Public License version 2.1 requirements
-## will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-##
-## In addition, as a special exception, Nokia gives you certain additional
-## rights. These rights are described in the Nokia Qt LGPL Exception
-## version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-##
-## If you have questions regarding the use of this file, please contact
-## Nokia at qt-info@nokia.com.
-##
-##
-##
-##
-##
-##
-##
-##
-## $QT_END_LICENSE$
-##
-#############################################################################
-
-me=$(dirname $0)
-mkdir -p $me/out
-(cd $me/out && ${QLALR-qlalr} --troll --no-lines ../qscript.g)
-
-for f in $me/out/*.{h,cpp}; do
- n=$(basename $f)
- p4 open $me/../../src/script/$n
- cp $f $me/../../src/script/$n
-done
-
-p4 revert -a $me/../../src/script/...
-p4 diff -du $me/../../src/script/...
-