diff --git a/.github/workflows/build_latest.yml b/.github/workflows/build_latest.yml
index d3351f31f..b586f4bf1 100644
--- a/.github/workflows/build_latest.yml
+++ b/.github/workflows/build_latest.yml
@@ -20,7 +20,7 @@ jobs:
fail-fast: false
matrix:
os: ['ubuntu', 'windows']
- qt-version: [ '5.12.*', '5.15.*', '6.7.*' ]
+ qt-version: [ '5.12.*', '5.15.*', '6.7.*', '6.8.*' ]
python-version: [ '3.12' ]
runs-on: ${{ matrix.os }}-latest
steps:
@@ -34,10 +34,9 @@ jobs:
- name: Install Qt ${{matrix.qt-version}}
uses: jurplel/install-qt-action@v4
with:
- # 6.7.* currently does not work with ubuntu with this action
- version: ${{ matrix.os == 'ubuntu' && matrix.qt-version == '6.7.*' && '6.6.*' || matrix.qt-version }}
+ version: ${{ matrix.qt-version }}
modules: ${{startsWith(matrix.qt-version, '6') && 'qt5compat qtscxml qtpositioning qtwebchannel qtmultimedia qtwebengine' || '' }}
- arch: ${{ matrix.os == 'ubuntu' && 'gcc_64' || (startsWith(matrix.qt-version, '5.12') && 'win64_msvc2017_64' || 'win64_msvc2019_64') }}
+ arch: ${{ (matrix.os == 'ubuntu' && (startsWith(matrix.qt-version, '5') && 'gcc_64' || 'linux_gcc_64')) || startsWith(matrix.qt-version, '5.12') && 'win64_msvc2017_64' || startsWith(matrix.qt-version, '6.8') && 'win64_msvc2022_64' || 'win64_msvc2019_64' }}
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
diff --git a/README.md b/README.md
index 1ee9a2b4c..39f4e3449 100644
--- a/README.md
+++ b/README.md
@@ -26,6 +26,11 @@ See https://code.qt.io/cgit/qt-labs/qtscriptgenerator.git for the original proje
The PythonQt wrappers generated by the generator are distributed under the `LGPL`
as well.
+The integrated preprocessor has been replaced with code from the simplecpp project,
+see https://github.com/danmar/simplecpp. It is licensed under the `0BSDL` license,
+see the `LICENSE` file in the generator/simplecpp directory.
+Copyright (C) 2016-2023 simplecpp team
+
The generated wrappers are pre-generated and checked-in, so you only
need to build and run the generator when you want to build additional wrappers
or you want to upgrade/downgrade to another Qt version, but this requires
diff --git a/extensions/PythonQt_QtAll/PythonQt_QtAll.pro b/extensions/PythonQt_QtAll/PythonQt_QtAll.pro
index 8881d00c1..39293951d 100644
--- a/extensions/PythonQt_QtAll/PythonQt_QtAll.pro
+++ b/extensions/PythonQt_QtAll/PythonQt_QtAll.pro
@@ -69,6 +69,8 @@ unix {
unix: target.path = $${INSTALL_PREFIX}/lib
win32: target.path = /
+msvc:QMAKE_CXXFLAGS += /bigobj
+
headers.files = $${HEADERS}
headers.path = $${INSTALL_PREFIX}/include
diff --git a/generator/abstractmetabuilder.cpp b/generator/abstractmetabuilder.cpp
index d73b0792b..d8df13e42 100644
--- a/generator/abstractmetabuilder.cpp
+++ b/generator/abstractmetabuilder.cpp
@@ -1169,7 +1169,7 @@ void AbstractMetaBuilder::traverseFunctions(ScopeModelItem scope_item, AbstractM
ReportHandler::warning(warn);
}
- meta_class->addFunction(meta_function);
+ meta_class->addFunction(meta_function, /*check_duplicates=*/true);
} else if (meta_function->isDestructor()) {
meta_class->setDestructorException(meta_function->exception());
if (!meta_function->isPublic()) {
diff --git a/generator/generator.pri b/generator/generator.pri
index 9bcfaac44..5c272cce9 100644
--- a/generator/generator.pri
+++ b/generator/generator.pri
@@ -16,7 +16,7 @@ RESOURCES += generator.qrc
include($$GENERATORPATH/parser/rxx.pri)
-include($$GENERATORPATH/parser/rpp/rpp.pri)
+include($$GENERATORPATH/simplecpp/simplecpp.pri)
CONFIG += strict_c++
win32-msvc*{
diff --git a/generator/generator.qrc b/generator/generator.qrc
index 0c591c714..e7203d779 100644
--- a/generator/generator.qrc
+++ b/generator/generator.qrc
@@ -15,6 +15,5 @@
typesystem_multimedia.xml
typesystem_qml.xml
typesystem_quick.xml
-parser/rpp/pp-qt-configuration
diff --git a/generator/main.cpp b/generator/main.cpp
index a6494363b..621542f52 100644
--- a/generator/main.cpp
+++ b/generator/main.cpp
@@ -48,7 +48,7 @@
#include "generatorset.h"
#include "fileout.h"
#include "control.h"
-#include "pp.h"
+#include "simplecpp.h"
#include
#include
@@ -56,6 +56,8 @@
#include
#include
+#include
+
void displayHelp(GeneratorSet *generatorSet);
namespace
@@ -125,53 +127,86 @@ namespace
}
bool
- preprocess(const QString &sourceFile, const QString &targetFile, const QString &commandLineIncludes = QString())
+ preprocess(const QString& sourceFile, const QString& targetFile, const QString& commandLineIncludes = QString())
{
- rpp::pp_environment env;
- rpp::pp preprocess(env);
-
- rpp::pp_null_output_iterator null_out;
+ simplecpp::DUI dui; // settings
- const char *ppconfig = ":/trolltech/generator/parser/rpp/pp-qt-configuration";
+ for(QString include : getIncludeDirectories(commandLineIncludes)) {
+ dui.includePaths.push_back(QDir::toNativeSeparators(include).toStdString());
+ }
+ dui.defines.push_back("__cplusplus=1");
+ dui.defines.push_back("__STDC__");
+ dui.std = "c++20";
+ dui.removeComments = true;
- QFile file(ppconfig);
+ QFile file(sourceFile);
if (!file.open(QFile::ReadOnly))
{
- fprintf(stderr, "Preprocessor configuration file not found '%s'\n", ppconfig);
+ std::cerr << "Main file not found:" << sourceFile.toUtf8().constData() << std::endl;
return false;
}
QByteArray ba = file.readAll();
file.close();
- preprocess.operator()(ba.constData(), ba.constData() + ba.size(), null_out);
- foreach(QString
- include, getIncludeDirectories(commandLineIncludes)) {
- preprocess.push_include_path(QDir::toNativeSeparators(include).toStdString());
+ // Perform preprocessing (code originally taken from simplecpp/main.cpp and modified)
+ simplecpp::OutputList outputList;
+ std::vector files;
+ std::unique_ptr rawtokens(new simplecpp::TokenList(ba.constData(), ba.size(), files, {}, &outputList));
+ rawtokens->removeComments();
+ simplecpp::TokenList outputTokens(files);
+ std::map filedata;
+ simplecpp::preprocess(outputTokens, *rawtokens, files, filedata, dui, &outputList);
+ simplecpp::cleanup(filedata);
+ rawtokens.reset();
+
+ for (const simplecpp::Output& output : outputList) {
+ if (output.type == simplecpp::Output::MISSING_HEADER) {
+ // do not print these messages for now, we are not interested
+ continue;
+ }
+ std::cerr << output.location.file() << ':' << output.location.line << ": ";
+ switch (output.type) {
+ case simplecpp::Output::ERROR:
+ std::cerr << "#error: ";
+ break;
+ case simplecpp::Output::WARNING:
+ std::cerr << "#warning: ";
+ break;
+ case simplecpp::Output::MISSING_HEADER:
+ std::cerr << "missing header: ";
+ break;
+ case simplecpp::Output::INCLUDE_NESTED_TOO_DEEPLY:
+ std::cerr << "include nested too deeply: ";
+ break;
+ case simplecpp::Output::SYNTAX_ERROR:
+ std::cerr << "syntax error: ";
+ break;
+ case simplecpp::Output::PORTABILITY_BACKSLASH:
+ std::cerr << "portability: ";
+ break;
+ case simplecpp::Output::UNHANDLED_CHAR_ERROR:
+ std::cerr << "unhandled char error: ";
+ break;
+ case simplecpp::Output::EXPLICIT_INCLUDE_NOT_FOUND:
+ std::cerr << "explicit include not found: ";
+ break;
+ case simplecpp::Output::FILE_NOT_FOUND:
+ std::cerr << "file not found: ";
+ break;
+ case simplecpp::Output::DUI_ERROR:
+ std::cerr << "dui error: ";
+ break;
+ }
+ std::cerr << output.msg << std::endl;
}
- QString currentDir = QDir::current().absolutePath();
- QFileInfo sourceInfo(sourceFile);
- QDir::setCurrent(sourceInfo.absolutePath());
-
- std::string result;
- result.reserve(20 * 1024); // 20K
-
- result += "# 1 \"builtins\"\n";
- result += "# 1 \"";
- result += sourceFile.toStdString();
- result += "\"\n";
-
- preprocess.file(sourceInfo.fileName().toStdString(),
- rpp::pp_output_iterator(result));
-
- QDir::setCurrent(currentDir);
-
QFile f(targetFile);
if (!f.open(QIODevice::WriteOnly | QIODevice::Text))
{
fprintf(stderr, "Failed to write preprocessed file: %s\n", qPrintable(targetFile));
}
+ std::string result = outputTokens.stringify();
f.write(result.c_str(), result.length());
return true;
diff --git a/generator/parser/lexer.cpp b/generator/parser/lexer.cpp
index be6c4ccf1..2ea0bcf59 100644
--- a/generator/parser/lexer.cpp
+++ b/generator/parser/lexer.cpp
@@ -69,6 +69,9 @@ void LocationManager::extract_line(int offset, int *line, QString *filename) con
const unsigned char *cursor = begin_buffer + offset;
++cursor; // skip '#'
+ if (cursor[0] == 'l' && cursor[1] == 'i' && cursor[2] == 'n' && cursor[3] == 'e') {
+ cursor += 4;
+ }
if (std::isspace(*cursor) && std::isdigit(*(cursor + 1)))
{
++cursor;
diff --git a/generator/parser/rpp/builtin-macros.cpp b/generator/parser/rpp/builtin-macros.cpp
deleted file mode 100644
index bae1ab77d..000000000
--- a/generator/parser/rpp/builtin-macros.cpp
+++ /dev/null
@@ -1,41 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Script Generator project on Qt Labs.
-**
-** $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$
-**
-****************************************************************************/
-
diff --git a/generator/parser/rpp/pp-cctype.h b/generator/parser/rpp/pp-cctype.h
deleted file mode 100644
index 9bfef9097..000000000
--- a/generator/parser/rpp/pp-cctype.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Script Generator project on Qt Labs.
-**
-** $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$
-**
-****************************************************************************/
-
-#ifndef PP_CCTYPE_H
-#define PP_CCTYPE_H
-
-#include
-
-namespace rpp {
-
-inline bool pp_isalpha (int __ch)
-{ return std::isalpha ((unsigned char) __ch) != 0; }
-
-inline bool pp_isalnum (int __ch)
-{ return std::isalnum ((unsigned char) __ch) != 0; }
-
-inline bool pp_isdigit (int __ch)
-{ return std::isdigit ((unsigned char) __ch) != 0; }
-
-inline bool pp_isspace (int __ch)
-{ return std::isspace ((unsigned char) __ch) != 0; }
-
-} // namespace rpp
-
-#endif // PP_CCTYPE_H
-
-// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/generator/parser/rpp/pp-configuration b/generator/parser/rpp/pp-configuration
deleted file mode 100644
index 15586dd88..000000000
--- a/generator/parser/rpp/pp-configuration
+++ /dev/null
@@ -1,86 +0,0 @@
-#define __DBL_MIN_EXP__ (-1021)
-#define __FLT_MIN__ 1.17549435e-38F
-#define __CHAR_BIT__ 8
-#define __WCHAR_MAX__ 2147483647
-#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
-#define __FLT_EVAL_METHOD__ 2
-#define __DBL_MIN_10_EXP__ (-307)
-#define __FINITE_MATH_ONLY__ 0
-#define __GNUC_PATCHLEVEL__ 2
-#define __SHRT_MAX__ 32767
-#define __LDBL_MAX__ 1.18973149535723176502e+4932L
-#define __UINTMAX_TYPE__ long long unsigned int
-#define __linux 1
-#define __unix 1
-#define __LDBL_MAX_EXP__ 16384
-#define __linux__ 1
-#define __SCHAR_MAX__ 127
-#define __USER_LABEL_PREFIX__
-#define __STDC_HOSTED__ 1
-#define __LDBL_HAS_INFINITY__ 1
-#define __DBL_DIG__ 15
-#define __FLT_EPSILON__ 1.19209290e-7F
-#define __GXX_WEAK__ 1
-#define __LDBL_MIN__ 3.36210314311209350626e-4932L
-#define __unix__ 1
-#define __DECIMAL_DIG__ 21
-#define __gnu_linux__ 1
-#define __LDBL_HAS_QUIET_NAN__ 1
-#define __GNUC__ 4
-#define __DBL_MAX__ 1.7976931348623157e+308
-#define __DBL_HAS_INFINITY__ 1
-#define __cplusplus 1
-#define __DEPRECATED 1
-#define __DBL_MAX_EXP__ 1024
-#define __GNUG__ 4
-#define __LONG_LONG_MAX__ 9223372036854775807LL
-#define __GXX_ABI_VERSION 1002
-#define __FLT_MIN_EXP__ (-125)
-#define __DBL_MIN__ 2.2250738585072014e-308
-#define __FLT_MIN_10_EXP__ (-37)
-#define __DBL_HAS_QUIET_NAN__ 1
-#define __REGISTER_PREFIX__
-#define __NO_INLINE__ 1
-#define __i386 1
-#define __FLT_MANT_DIG__ 24
-#define __VERSION__ "4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu9)"
-#define i386 1
-#define __i486__ 1
-#define unix 1
-#define __i386__ 1
-#define __SIZE_TYPE__ unsigned int
-#define __ELF__ 1
-#define __FLT_RADIX__ 2
-#define __LDBL_EPSILON__ 1.08420217248550443401e-19L
-#define __FLT_HAS_QUIET_NAN__ 1
-#define __FLT_MAX_10_EXP__ 38
-#define __LONG_MAX__ 2147483647L
-#define __FLT_HAS_INFINITY__ 1
-#define linux 1
-#define __EXCEPTIONS 1
-#define __LDBL_MANT_DIG__ 64
-#define __WCHAR_TYPE__ int
-#define __FLT_DIG__ 6
-#define __INT_MAX__ 2147483647
-#define __i486 1
-#define __FLT_MAX_EXP__ 128
-#define __DBL_MANT_DIG__ 53
-#define __WINT_TYPE__ unsigned int
-#define __LDBL_MIN_EXP__ (-16381)
-#define __LDBL_MAX_10_EXP__ 4932
-#define __DBL_EPSILON__ 2.2204460492503131e-16
-#define __tune_i486__ 1
-#define __INTMAX_MAX__ 9223372036854775807LL
-#define __FLT_DENORM_MIN__ 1.40129846e-45F
-#define __FLT_MAX__ 3.40282347e+38F
-#define __INTMAX_TYPE__ long long int
-#define __GNUC_MINOR__ 0
-#define __DBL_MAX_10_EXP__ 308
-#define __LDBL_DENORM_MIN__ 3.64519953188247460253e-4951L
-#define __PTRDIFF_TYPE__ int
-#define __LDBL_MIN_10_EXP__ (-4931)
-#define __LDBL_DIG__ 18
-#define _GNU_SOURCE 1
-
-
-#define __STDC__
diff --git a/generator/parser/rpp/pp-engine-bits.h b/generator/parser/rpp/pp-engine-bits.h
deleted file mode 100644
index cbae8e072..000000000
--- a/generator/parser/rpp/pp-engine-bits.h
+++ /dev/null
@@ -1,1392 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Script Generator project on Qt Labs.
-**
-** $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$
-**
-****************************************************************************/
-
-#ifndef PP_ENGINE_BITS_H
-#define PP_ENGINE_BITS_H
-
-#include
-
-namespace rpp {
-
-inline std::string pp::fix_file_path(std::string const &filename) const
-{
-#if defined (PP_OS_WIN)
- std::string s = filename;
- for (std::string::iterator it = s.begin(); it != s.end(); ++it)
- {
- if (*it == '/')
- *it = '\\';
- }
- return s;
-#else
- return filename;
-#endif
-}
-
-inline bool pp::is_absolute(std::string const &filename) const
-{
-#if defined(PP_OS_WIN)
- return filename.length() >= 3
- && filename.at(1) == ':'
- && (filename.at(2) == '\\' || filename.at(2) == '/');
-#else
- return filename.length() >= 1
- && filename.at(0) == '/';
-#endif
-}
-
-template
-void pp::file (std::string const &filename, _OutputIterator _result)
-{
- FILE *fp = fopen (filename.c_str(), "rb");
- if (fp != 0)
- {
- std::string was = env.current_file;
- env.current_file = filename;
- file (fp, _result);
- env.current_file = was;
- }
- //else
- //std::cerr << "** WARNING file ``" << filename << " not found!" << std::endl;
-}
-
-template
-void pp::file (FILE *fp, _OutputIterator _result)
-{
- assert (fp != 0);
-
-#if defined (HAVE_MMAP)
- struct stat st;
- fstat(FILENO (fp), &st);
- std::size_t size = st.st_size;
- char *buffer = 0;
- buffer = (char *) ::mmap(0, size, PROT_READ, MAP_SHARED, FILENO (fp), 0);
- fclose (fp);
- if (!buffer || buffer == (char*) -1)
- return;
- this->operator () (buffer, buffer + size, _result);
- ::munmap(buffer, size);
-#else
- std::string buffer;
- while (!feof(fp)) {
- char tmp[1024];
- int read = (int) fread (tmp, sizeof(char), 1023, fp);
- tmp[read] = '\0';
- buffer += tmp;
- }
- fclose (fp);
- this->operator () (buffer.c_str(), buffer.c_str() + buffer.size(), _result);
-#endif
-}
-
-template
-bool pp::find_header_protection (InputIterator _first, InputIterator _last, std::string *_prot)
-{
- int was = env.current_line;
-
- while (_first != _last)
- {
- if (pp_isspace (*_first))
- {
- if (*_first == '\n')
- ++env.current_line;
-
- ++_first;
- }
- else if (_PP_internal::comment_p (_first, _last))
- {
- _first = skip_comment_or_divop (_first, _last);
- env.current_line += skip_comment_or_divop.lines;
- }
- else if (*_first == '#')
- {
- _first = skip_blanks (++_first, _last);
- env.current_line += skip_blanks.lines;
-
- if (_first != _last && *_first == 'i')
- {
- InputIterator begin = _first;
- _first = skip_identifier (begin, _last);
- env.current_line += skip_identifier.lines;
-
- std::string directive (begin, _first);
-
- if (directive == "ifndef")
- {
- _first = skip_blanks (_first, _last);
- env.current_line += skip_blanks.lines;
-
- begin = _first;
- _first = skip_identifier (_first, _last);
- env.current_line += skip_identifier.lines;
-
- if (begin != _first && _first != _last)
- {
- _prot->assign (begin, _first);
- return true;
- }
- }
- }
- break;
- }
- else
- break;
- }
-
- env.current_line = was;
- return false;
-}
-
-inline pp::PP_DIRECTIVE_TYPE pp::find_directive (char const *_directive, std::size_t _size) const
-{
- switch (_size)
- {
- case 2:
- if (_directive[0] == 'i'
- && _directive[1] == 'f')
- return PP_IF;
- break;
-
- case 4:
- if (_directive[0] == 'e' && !strcmp (_directive, "elif"))
- return PP_ELIF;
- else if (_directive[0] == 'e' && !strcmp (_directive, "else"))
- return PP_ELSE;
- break;
-
- case 5:
- if (_directive[0] == 'i' && !strcmp (_directive, "ifdef"))
- return PP_IFDEF;
- else if (_directive[0] == 'u' && !strcmp (_directive, "undef"))
- return PP_UNDEF;
- else if (_directive[0] == 'e') {
- if (!strcmp (_directive, "endif"))
- return PP_ENDIF;
- else if (!strcmp (_directive, "error"))
- return PP_ERROR;
- }
- break;
-
- case 6:
- if (_directive[0] == 'i' && !strcmp (_directive, "ifndef"))
- return PP_IFNDEF;
- else if (_directive[0] == 'd' && !strcmp (_directive, "define"))
- return PP_DEFINE;
- else if (_directive[0] == 'p' && !strcmp (_directive, "pragma"))
- return PP_PRAGMA;
- break;
-
- case 7:
- if (_directive[0] == 'i' && !strcmp (_directive, "include"))
- return PP_INCLUDE;
- else if (_directive[0] == 'w' && !strcmp(_directive, "warning"))
- return PP_WARNING;
- break;
-
- case 12:
- if (_directive[0] == 'i' && !strcmp (_directive, "include_next"))
- return PP_INCLUDE_NEXT;
- break;
-
- default:
- break;
- }
- if (strlen(_directive)) {
- std::cerr << "** WARNING unknown directive '#" << _directive << "' at " << env.current_file << ":" << env.current_line << std::endl;
- }
- return PP_UNKNOWN_DIRECTIVE;
-}
-
-inline bool pp::file_isdir (std::string const &_filename) const
-{
- struct stat st;
-#if defined(PP_OS_WIN)
- if (stat(_filename.c_str (), &st) == 0)
- return (st.st_mode & _S_IFDIR) == _S_IFDIR;
- else
- return false;
-#else
- if (lstat(_filename.c_str (), &st) == 0)
- return (st.st_mode & S_IFDIR) == S_IFDIR;
- else
- return false;
-#endif
-}
-
-inline bool pp::file_exists (std::string const &_filename) const
-{
- struct stat st;
-#if defined(PP_OS_WIN)
- return stat(_filename.c_str (), &st) == 0;
-#else
- return lstat (_filename.c_str (), &st) == 0;
-#endif
-}
-
-inline FILE *pp::find_include_file(std::string const &_input_filename, std::string *_filepath,
- INCLUDE_POLICY _include_policy, bool _skip_current_path) const
-{
- assert (_filepath != 0);
- assert (! _input_filename.empty());
-
- _filepath->assign (_input_filename);
-
- if (is_absolute (*_filepath))
- return fopen (_filepath->c_str(), "r");
-
- if (! env.current_file.empty ())
- _PP_internal::extract_file_path (env.current_file, _filepath);
-
- if (_include_policy == INCLUDE_LOCAL && ! _skip_current_path)
- {
- std::string tmp (*_filepath);
- tmp += _input_filename;
-
- if (file_exists (tmp) && !file_isdir(tmp))
- {
- _filepath->append (_input_filename);
- return fopen (_filepath->c_str (), "r");
- }
- }
-
- std::vector::const_iterator it = include_paths.begin ();
-
- if (_skip_current_path)
- {
- it = std::find (include_paths.begin (), include_paths.end (), *_filepath);
-
- if (it != include_paths.end ())
- ++it;
-
- else
- it = include_paths.begin ();
- }
-
- for (; it != include_paths.end (); ++it)
- {
- if (_skip_current_path && it == include_paths.begin())
- continue;
-
- _filepath->assign (*it);
- _filepath->append (_input_filename);
-
- if (file_exists (*_filepath) && !file_isdir(*_filepath))
- return fopen (_filepath->c_str(), "r");
-
-#ifdef Q_OS_MAC
- // try in Framework path on Mac, if there is a path in front
- // ### what about escaped slashes?
- size_t slashPos = _input_filename.find('/');
- if (slashPos != std::string::npos) {
- _filepath->assign (*it);
- _filepath->append (_input_filename.substr(0, slashPos));
- _filepath->append (".framework/Headers/");
- _filepath->append (_input_filename.substr(slashPos+1, std::string::npos));
- std::cerr << *_filepath << "\n";
-
- if (file_exists (*_filepath) && !file_isdir(*_filepath))
- return fopen (_filepath->c_str(), "r");
- }
-#endif // Q_OS_MAC
- }
-
- return 0;
-}
-
-template
-InputIterator pp::handle_directive(char const *_directive, std::size_t _size,
- InputIterator _first, InputIterator _last, OutputIterator _result)
-{
- _first = skip_blanks (_first, _last);
-
- PP_DIRECTIVE_TYPE d = find_directive (_directive, _size);
- switch (d)
- {
- case PP_DEFINE:
- if (! skipping ())
- return handle_define (_first, _last);
- break;
-
- case PP_INCLUDE:
- case PP_INCLUDE_NEXT:
- if (! skipping ())
- return handle_include (d == PP_INCLUDE_NEXT, _first, _last, _result);
- break;
-
- case PP_UNDEF:
- if (! skipping ())
- return handle_undef(_first, _last);
- break;
-
- case PP_ELIF:
- return handle_elif (_first, _last);
-
- case PP_ELSE:
- return handle_else (_first, _last);
-
- case PP_ENDIF:
- return handle_endif (_first, _last);
-
- case PP_IF:
- return handle_if (_first, _last);
-
- case PP_IFDEF:
- return handle_ifdef (false, _first, _last);
-
- case PP_IFNDEF:
- return handle_ifdef (true, _first, _last);
-
- default:
- break;
- }
-
- return _first;
-}
-
-template
-InputIterator pp::handle_include (bool _skip_current_path, InputIterator _first, InputIterator _last,
- OutputIterator _result)
-{
- // uncomment to print included files
- // std::cout << env.current_file << std::endl;
- if (pp_isalpha (*_first) || *_first == '_')
- {
- pp_macro_expander expand_include (env);
- std::string name;
- name.reserve (255);
- expand_include (_first, _last, std::back_inserter (name));
- std::string::iterator it = skip_blanks (name.begin (), name.end ());
- printf("%s", name.c_str());
- assert((it != name.end () && (*it == '<' || *it == '"')));
- handle_include (_skip_current_path, it, name.end (), _result);
- return _first;
- }
-
- assert (*_first == '<' || *_first == '"');
- int quote = (*_first == '"') ? '"' : '>';
- ++_first;
-
- InputIterator end_name = _first;
- for (; end_name != _last; ++end_name)
- {
- assert (*end_name != '\n');
-
- if (*end_name == quote)
- break;
- }
-
- std::string filename (_first, end_name);
-
-#ifdef PP_OS_WIN
- std::replace(filename.begin(), filename.end(), '/', '\\');
-#endif
-
- std::string filepath;
- FILE *fp = find_include_file (filename, &filepath, quote == '>' ? INCLUDE_GLOBAL : INCLUDE_LOCAL, _skip_current_path);
-
-#if defined (PP_HOOK_ON_FILE_INCLUDED)
- PP_HOOK_ON_FILE_INCLUDED (env.current_file, fp ? filepath : filename, fp);
-#endif
-
- if (fp != 0)
- {
- std::string old_file = env.current_file;
- env.current_file = filepath;
- int saved_lines = env.current_line;
-
- env.current_line = 1;
- //output_line (env.current_file, 1, _result);
-
- file (fp, _result);
-
- // restore the file name and the line position
- env.current_file = old_file;
- env.current_line = saved_lines;
-
- // sync the buffer
- _PP_internal::output_line (env.current_file, env.current_line, _result);
- }
-#ifndef RPP_JAMBI
-// else
-// std::cerr << "*** WARNING " << filename << ": No such file or directory" << std::endl;
-#endif
-
- return _first;
-}
-
-template
-void pp::operator () (InputIterator _first, InputIterator _last, OutputIterator _result)
-{
-#ifndef PP_NO_SMART_HEADER_PROTECTION
- std::string prot;
- prot.reserve (255);
- pp_fast_string tmp (prot.c_str (), prot.size ());
-
- if (find_header_protection (_first, _last, &prot)
- && env.resolve (&tmp) != 0)
- {
- // std::cerr << "** DEBUG found header protection:" << prot << std::endl;
- return;
- }
-#endif
-
- env.current_line = 1;
- char buffer[512];
-
- while (true)
- {
- _first = skip_blanks (_first, _last);
- env.current_line += skip_blanks.lines;
-
- if (_first == _last)
- break;
- else if (*_first == '#')
- {
- assert (*_first == '#');
- _first = skip_blanks (++_first, _last);
- env.current_line += skip_blanks.lines;
-
- InputIterator end_id = skip_identifier (_first, _last);
- env.current_line += skip_identifier.lines;
- std::size_t size = end_id - _first;
-
- assert (size < 512);
- char *cp = buffer;
- std::copy (_first, end_id, cp);
- cp[size] = '\0';
-
- end_id = skip_blanks (end_id, _last);
- _first = skip (end_id, _last);
-
- int was = env.current_line;
- (void) handle_directive (buffer, size, end_id, _first, _result);
-
- if (env.current_line != was)
- {
- env.current_line = was;
- _PP_internal::output_line (env.current_file, env.current_line, _result);
- }
- }
- else if (*_first == '\n')
- {
- // ### compress the line
- *_result++ = *_first++;
- ++env.current_line;
- }
- else if (skipping ())
- _first = skip (_first, _last);
- else
- {
- _PP_internal::output_line (env.current_file, env.current_line, _result);
- _first = expand (_first, _last, _result);
- env.current_line += expand.lines;
-
- if (expand.generated_lines)
- _PP_internal::output_line (env.current_file, env.current_line, _result);
- }
- }
-}
-
-inline pp::pp (pp_environment &_env):
- env (_env), expand (env), skip_comment(false)
-{
- iflevel = 0;
- _M_skipping[iflevel] = 0;
- _M_true_test[iflevel] = 0;
-}
-
-inline std::back_insert_iterator > pp::include_paths_inserter ()
-{ return std::back_inserter (include_paths); }
-
-inline std::vector::iterator pp::include_paths_begin ()
-{ return include_paths.begin (); }
-
-inline std::vector::iterator pp::include_paths_end ()
-{ return include_paths.end (); }
-
-inline std::vector::const_iterator pp::include_paths_begin () const
-{ return include_paths.begin (); }
-
-inline std::vector::const_iterator pp::include_paths_end () const
-{ return include_paths.end (); }
-
-inline void pp::push_include_path (std::string const &_path)
-{
- if (_path.empty () || _path [_path.size () - 1] != PATH_SEPARATOR)
- {
- std::string tmp (_path);
- tmp += PATH_SEPARATOR;
- include_paths.push_back (tmp);
- }
-
- else
- include_paths.push_back (_path);
-}
-
-template
-InputIterator pp::handle_define (InputIterator _first, InputIterator _last)
-{
- pp_macro macro;
-#if defined (PP_WITH_MACRO_POSITION)
- macro.file = pp_symbol::get (env.current_file);
-#endif
- std::string definition;
-
- _first = skip_blanks (_first, _last);
- InputIterator end_macro_name = skip_identifier (_first, _last);
- pp_fast_string const *macro_name = pp_symbol::get (_first, end_macro_name);
- _first = end_macro_name;
-
- if (_first != _last && *_first == '(')
- {
- macro.is.function_like = true;
- macro.formals.reserve (5);
-
- _first = skip_blanks (++_first, _last); // skip '('
- InputIterator arg_end = skip_identifier (_first, _last);
- if (_first != arg_end)
- macro.formals.push_back (pp_symbol::get (_first, arg_end));
-
- _first = skip_blanks (arg_end, _last);
-
- if (*_first == '.')
- {
- macro.is.variadics = true;
- while (*_first == '.')
- ++_first;
- }
-
- while (_first != _last && *_first == ',')
- {
- _first = skip_blanks (++_first, _last);
-
- arg_end = skip_identifier (_first, _last);
- if (_first != arg_end)
- macro.formals.push_back (pp_symbol::get (_first, arg_end));
-
- _first = skip_blanks (arg_end, _last);
-
- if (*_first == '.')
- {
- macro.is.variadics = true;
- while (*_first == '.')
- ++_first;
- }
- }
-
- assert (*_first == ')');
- ++_first;
- }
-
- _first = skip_blanks (_first, _last);
-
- while (_first != _last && *_first != '\n')
- {
- if (*_first == '/') {
- const InputIterator _before = _first;
- _first = skip_comment(_first, _last);
- env.current_line += skip_comment.lines;
- if (_first != _before) {
- // do not indiscriminately add the character after comment
- continue;
- }
- }
-
- if (*_first == '\\')
- {
- InputIterator begin = _first;
- begin = skip_blanks (++begin, _last);
-
- if (begin != _last && *begin == '\n')
- {
- ++macro.lines;
- _first = skip_blanks (++begin, _last);
- definition += ' ';
- continue;
- }
- }
-
- definition += *_first++;
- }
-
- macro.definition = pp_symbol::get (definition);
- env.bind (macro_name, macro);
-
- return _first;
-}
-
-template
-InputIterator pp::skip (InputIterator _first, InputIterator _last)
-{
- pp_skip_string_literal skip_string_literal;
- pp_skip_char_literal skip_char_literal;
-
- while (_first != _last && *_first != '\n')
- {
- if (*_first == '/')
- {
- _first = skip_comment_or_divop (_first, _last);
- env.current_line += skip_comment_or_divop.lines;
- }
- else if (*_first == '"')
- {
- _first = skip_string_literal (_first, _last);
- env.current_line += skip_string_literal.lines;
- }
- else if (*_first == '\'')
- {
- _first = skip_char_literal (_first, _last);
- env.current_line += skip_char_literal.lines;
- }
- else if (*_first == '\\')
- {
- _first = skip_blanks (++_first, _last);
- env.current_line += skip_blanks.lines;
-
- if (_first != _last && *_first == '\n')
- {
- ++_first;
- ++env.current_line;
- }
- }
- else
- ++_first;
- }
-
- return _first;
-}
-
-inline bool pp::test_if_level()
-{
- bool result = !_M_skipping[iflevel++];
- _M_skipping[iflevel] = _M_skipping[iflevel - 1];
- _M_true_test[iflevel] = false;
- return result;
-}
-
-inline int pp::skipping() const
-{ return _M_skipping[iflevel]; }
-
-template
-InputIterator pp::eval_primary(InputIterator _first, InputIterator _last, Value *result)
-{
- bool expect_paren = false;
- int token;
- _first = next_token (_first, _last, &token);
-
- switch (token)
- {
- case TOKEN_NUMBER:
- result->set_long (token_value);
- break;
-
- case TOKEN_UNUMBER:
- result->set_ulong (token_uvalue);
- break;
-
- case TOKEN_DEFINED:
- _first = next_token (_first, _last, &token);
-
- if (token == '(')
- {
- expect_paren = true;
- _first = next_token (_first, _last, &token);
- }
-
- if (token != TOKEN_IDENTIFIER)
- {
- std::cerr << "** WARNING expected ``identifier'' found:" << char(token) << " at " << env.current_file << ":" << env.current_line << std::endl;
- result->set_long (0);
- break;
- }
-
- result->set_long (env.resolve (token_text->c_str (), token_text->size ()) != 0);
-
- next_token (_first, _last, &token); // skip '('
-
- if (expect_paren)
- {
- InputIterator next = next_token (_first, _last, &token);
- if (token != ')')
- std::cerr << "** WARNING expected ``)'' at " << env.current_file << ":" << env.current_line << std::endl;
- else
- _first = next;
- }
- break;
-
- case TOKEN_IDENTIFIER:
- result->set_long (0);
- break;
-
- case '-':
- _first = eval_primary (_first, _last, result);
- result->set_long (- result->l);
- return _first;
-
- case '+':
- _first = eval_primary (_first, _last, result);
- return _first;
-
- case '!':
- _first = eval_primary (_first, _last, result);
- result->set_long (result->is_zero ());
- return _first;
-
- case '(':
- _first = eval_constant_expression(_first, _last, result);
- next_token (_first, _last, &token);
-
- if (token != ')')
- std::cerr << "** WARNING expected ``)'' = " << token << " at " << env.current_file << ":" << env.current_line << std::endl;
- else
- _first = next_token(_first, _last, &token);
- break;
-
- default:
- result->set_long (0);
- }
-
- return _first;
-}
-
-template
-InputIterator pp::eval_multiplicative(InputIterator _first, InputIterator _last, Value *result)
-{
- _first = eval_primary(_first, _last, result);
-
- int token;
- InputIterator next = next_token (_first, _last, &token);
-
- while (token == '*' || token == '/' || token == '%')
- {
- Value value;
- _first = eval_primary(next, _last, &value);
-
- if (token == '*')
- result->op_mult (value);
- else if (token == '/')
- {
- if (value.is_zero ())
- {
- std::cerr << "** WARNING division by zero at " << env.current_file << ":" << env.current_line << std::endl;
- result->set_long (0);
- }
- else
- result->op_div (value);
- }
- else
- {
- if (value.is_zero ())
- {
- std::cerr << "** WARNING division by zero at " << env.current_file << ":" << env.current_line << std::endl;
- result->set_long (0);
- }
- else
- result->op_mod (value);
- }
- next = next_token (_first, _last, &token);
- }
-
- return _first;
-}
-
-template
-InputIterator pp::eval_additive(InputIterator _first, InputIterator _last, Value *result)
-{
- _first = eval_multiplicative(_first, _last, result);
-
- int token;
- InputIterator next = next_token (_first, _last, &token);
-
- while (token == '+' || token == '-')
- {
- Value value;
- _first = eval_multiplicative(next, _last, &value);
-
- if (token == '+')
- result->op_add (value);
- else
- result->op_sub (value);
- next = next_token (_first, _last, &token);
- }
-
- return _first;
-}
-
-template
-InputIterator pp::eval_shift(InputIterator _first, InputIterator _last, Value *result)
-{
- _first = eval_additive(_first, _last, result);
-
- int token;
- InputIterator next = next_token (_first, _last, &token);
-
- while (token == TOKEN_LT_LT || token == TOKEN_GT_GT)
- {
- Value value;
- _first = eval_additive (next, _last, &value);
-
- if (token == TOKEN_LT_LT)
- result->op_lhs (value);
- else
- result->op_rhs (value);
- next = next_token (_first, _last, &token);
- }
-
- return _first;
-}
-
-template
-InputIterator pp::eval_relational(InputIterator _first, InputIterator _last, Value *result)
-{
- _first = eval_shift(_first, _last, result);
-
- int token;
- InputIterator next = next_token (_first, _last, &token);
-
- while (token == '<'
- || token == '>'
- || token == TOKEN_LT_EQ
- || token == TOKEN_GT_EQ)
- {
- Value value;
- _first = eval_shift(next, _last, &value);
-
- switch (token)
- {
- default:
- assert (0);
- break;
-
- case '<':
- result->op_lt (value);
- break;
-
- case '>':
- result->op_gt (value);
- break;
-
- case TOKEN_LT_EQ:
- result->op_le (value);
- break;
-
- case TOKEN_GT_EQ:
- result->op_ge (value);
- break;
- }
- next = next_token (_first, _last, &token);
- }
-
- return _first;
-}
-
-template
-InputIterator pp::eval_equality(InputIterator _first, InputIterator _last, Value *result)
-{
- _first = eval_relational(_first, _last, result);
-
- int token;
- InputIterator next = next_token (_first, _last, &token);
-
- while (token == TOKEN_EQ_EQ || token == TOKEN_NOT_EQ)
- {
- Value value;
- _first = eval_relational(next, _last, &value);
-
- if (token == TOKEN_EQ_EQ)
- result->op_eq (value);
- else
- result->op_ne (value);
- next = next_token (_first, _last, &token);
- }
-
- return _first;
-}
-
-template
-InputIterator pp::eval_and(InputIterator _first, InputIterator _last, Value *result)
-{
- _first = eval_equality(_first, _last, result);
-
- int token;
- InputIterator next = next_token (_first, _last, &token);
-
- while (token == '&')
- {
- Value value;
- _first = eval_equality(next, _last, &value);
- result->op_bit_and (value);
- next = next_token (_first, _last, &token);
- }
-
- return _first;
-}
-
-template
-InputIterator pp::eval_xor(InputIterator _first, InputIterator _last, Value *result)
-{
- _first = eval_and(_first, _last, result);
-
- int token;
- InputIterator next = next_token (_first, _last, &token);
-
- while (token == '^')
- {
- Value value;
- _first = eval_and(next, _last, &value);
- result->op_bit_xor (value);
- next = next_token (_first, _last, &token);
- }
-
- return _first;
-}
-
-template
-InputIterator pp::eval_or(InputIterator _first, InputIterator _last, Value *result)
-{
- _first = eval_xor(_first, _last, result);
-
- int token;
- InputIterator next = next_token (_first, _last, &token);
-
- while (token == '|')
- {
- Value value;
- _first = eval_xor(next, _last, &value);
- result->op_bit_or (value);
- next = next_token (_first, _last, &token);
- }
-
- return _first;
-}
-
-template
-InputIterator pp::eval_logical_and(InputIterator _first, InputIterator _last, Value *result)
-{
- _first = eval_or(_first, _last, result);
-
- int token;
- InputIterator next = next_token (_first, _last, &token);
-
- while (token == TOKEN_AND_AND)
- {
- Value value;
- _first = eval_or(next, _last, &value);
- result->op_and (value);
- next = next_token (_first, _last, &token);
- }
-
- return _first;
-}
-
-template
-InputIterator pp::eval_logical_or(InputIterator _first, InputIterator _last, Value *result)
-{
- _first = eval_logical_and (_first, _last, result);
-
- int token;
- InputIterator next = next_token (_first, _last, &token);
-
- while (token == TOKEN_OR_OR)
- {
- Value value;
- _first = eval_logical_and(next, _last, &value);
- result->op_or (value);
- next = next_token (_first, _last, &token);
- }
-
- return _first;
-}
-
-template
-InputIterator pp::eval_constant_expression(InputIterator _first, InputIterator _last, Value *result)
-{
- _first = eval_logical_or(_first, _last, result);
-
- int token;
- InputIterator next = next_token (_first, _last, &token);
-
- if (token == '?')
- {
- Value left_value;
- _first = eval_constant_expression(next, _last, &left_value);
- _first = skip_blanks (_first, _last);
-
- _first = next_token(_first, _last, &token);
- if (token == ':')
- {
- Value right_value;
- _first = eval_constant_expression(_first, _last, &right_value);
-
- *result = !result->is_zero () ? left_value : right_value;
- }
- else
- {
- std::cerr << "** WARNING expected ``:'' = " << int (token) << " at " << env.current_file << ":" << env.current_line << std::endl;
- *result = left_value;
- }
- }
-
- return _first;
-}
-
-template
-InputIterator pp::eval_expression (InputIterator _first, InputIterator _last, Value *result)
-{
- return _first = eval_constant_expression (skip_blanks (_first, _last), _last, result);
-}
-
-template
-std::string pp::expand_condition(InputIterator _first, InputIterator _last)
-{
- pp_macro_expander expand_condition(env);
- std::string condition;
- condition.reserve(255);
- expand_condition(skip_blanks(_first, _last), _last, std::back_inserter(condition));
- std::string condition2ndpass;
- condition2ndpass.reserve(255);
- const char* first = condition.c_str();
- const char* last = first + condition.size();
- expand_condition(skip_blanks(first, last), last, std::back_inserter(condition2ndpass));
- return condition2ndpass;
-}
-
-template
-InputIterator pp::handle_if (InputIterator _first, InputIterator _last)
-{
- if (test_if_level())
- {
- std::string condition = expand_condition(_first, _last);
-
- Value result;
- result.set_long (0);
- eval_expression(condition.c_str (), condition.c_str () + condition.size (), &result);
-
- _M_true_test[iflevel] = !result.is_zero ();
- _M_skipping[iflevel] = result.is_zero ();
- }
-
- return _first;
-}
-
-template
-InputIterator pp::handle_else (InputIterator __first, InputIterator /*__last*/)
-{
- if (iflevel == 0 && !skipping ())
- {
- std::cerr << "** WARNING #else without #if" << " at " << env.current_file << ":" << env.current_line << std::endl;
- }
- else if (iflevel > 0 && _M_skipping[iflevel - 1])
- {
- _M_skipping[iflevel] = true;
- }
- else
- {
- _M_skipping[iflevel] = _M_true_test[iflevel];
- }
-
- return __first;
-}
-
-template
-InputIterator pp::handle_elif (InputIterator _first, InputIterator _last)
-{
- assert(iflevel > 0);
-
- if (iflevel == 0 && !skipping())
- {
- std::cerr << "** WARNING #else without #if" << " at " << env.current_file << ":" << env.current_line << std::endl;
- }
- else if (!_M_true_test[iflevel] && !_M_skipping[iflevel - 1])
- {
- std::string condition = expand_condition(_first, _last);
-
- Value result;
- result.set_long(0);
- eval_expression(condition.c_str(), condition.c_str() + condition.size(), &result);
- _M_true_test[iflevel] = !result.is_zero ();
- _M_skipping[iflevel] = result.is_zero ();
- }
- else
- {
- _M_skipping[iflevel] = true;
- }
-
- return _first;
-}
-
-template
-InputIterator pp::handle_endif (InputIterator _first, InputIterator /*__last*/)
-{
- if (iflevel == 0 && !skipping())
- {
- std::cerr << "** WARNING #endif without #if" << " at " << env.current_file << ":" << env.current_line << std::endl;
- }
- else
- {
- _M_skipping[iflevel] = 0;
- _M_true_test[iflevel] = 0;
-
- --iflevel;
- }
-
- return _first;
-}
-
-template
-InputIterator pp::handle_ifdef (bool check_undefined, InputIterator _first, InputIterator _last)
-{
- if (test_if_level())
- {
- InputIterator end_macro_name = skip_identifier (_first, _last);
-
- std::size_t __size;
-#if defined(__SUNPRO_CC)
- std::distance (__first, end_macro_name, __size);
-#else
- __size = std::distance (_first, end_macro_name);
-#endif
- assert (__size < 256);
-
- char __buffer [256];
- std::copy (_first, end_macro_name, __buffer);
-
- bool value = env.resolve (__buffer, __size) != 0;
-
- _first = end_macro_name;
-
- if (check_undefined)
- value = !value;
-
- _M_true_test[iflevel] = value;
- _M_skipping[iflevel] = !value;
- }
-
- return _first;
-}
-
-template
-InputIterator pp::handle_undef(InputIterator _first, InputIterator _last)
-{
- _first = skip_blanks (_first, _last);
- InputIterator end_macro_name = skip_identifier (_first, _last);
- assert (end_macro_name != _first);
-
- std::size_t __size;
-#if defined(__SUNPRO_CC)
- std::distance (__first, end_macro_name, __size);
-#else
- __size = std::distance (_first, end_macro_name);
-#endif
-
- assert (__size < 256);
-
- char __buffer [256];
- std::copy (_first, end_macro_name, __buffer);
-
- pp_fast_string const __tmp (__buffer, __size);
- env.unbind (&__tmp);
-
- _first = end_macro_name;
-
- return _first;
-}
-
-template
-char pp::peek_char (InputIterator _first, InputIterator _last)
-{
- if (_first == _last)
- return 0;
-
- return *++_first;
-}
-
-template
-InputIterator pp::next_token (InputIterator _first, InputIterator _last, int *kind)
-{
- _first = skip_blanks (_first, _last);
-
- if (_first == _last)
- {
- *kind = 0;
- return _first;
- }
-
- char ch = *_first;
- char ch2 = peek_char (_first, _last);
-
- switch (ch)
- {
- case '/':
- if (ch2 == '/' || ch2 == '*')
- {
- _first = skip_comment_or_divop (_first, _last);
- return next_token (_first, _last, kind);
- }
- ++_first;
- *kind = '/';
- break;
-
- case '<':
- ++_first;
- if (ch2 == '<')
- {
- ++_first;
- *kind = TOKEN_LT_LT;
- }
- else if (ch2 == '=')
- {
- ++_first;
- *kind = TOKEN_LT_EQ;
- }
- else
- *kind = '<';
-
- return _first;
-
- case '>':
- ++_first;
- if (ch2 == '>')
- {
- ++_first;
- *kind = TOKEN_GT_GT;
- }
- else if (ch2 == '=')
- {
- ++_first;
- *kind = TOKEN_GT_EQ;
- }
- else
- *kind = '>';
-
- return _first;
-
- case '!':
- ++_first;
- if (ch2 == '=')
- {
- ++_first;
- *kind = TOKEN_NOT_EQ;
- }
- else
- *kind = '!';
-
- return _first;
-
- case '=':
- ++_first;
- if (ch2 == '=')
- {
- ++_first;
- *kind = TOKEN_EQ_EQ;
- }
- else
- *kind = '=';
-
- return _first;
-
- case '|':
- ++_first;
- if (ch2 == '|')
- {
- ++_first;
- *kind = TOKEN_OR_OR;
- }
- else
- *kind = '|';
-
- return _first;
-
- case '&':
- ++_first;
- if (ch2 == '&')
- {
- ++_first;
- *kind = TOKEN_AND_AND;
- }
- else
- *kind = '&';
-
- return _first;
-
- default:
- if (pp_isalpha (ch) || ch == '_')
- {
- InputIterator end = skip_identifier (_first, _last);
- _M_current_text.assign (_first, end);
-
- token_text = &_M_current_text;
- _first = end;
-
- if (*token_text == "defined")
- *kind = TOKEN_DEFINED;
- else
- *kind = TOKEN_IDENTIFIER;
- }
- else if (pp_isdigit (ch))
- {
- InputIterator end = skip_number (_first, _last);
- std::string __str (_first, _last);
- char ch = __str [__str.size () - 1];
- if (ch == 'u' || ch == 'U')
- {
- token_uvalue = strtoul (__str.c_str (), 0, 0);
- *kind = TOKEN_UNUMBER;
- }
- else
- {
- token_value = strtol (__str.c_str (), 0, 0);
- *kind = TOKEN_NUMBER;
- }
- _first = end;
- }
- else
- *kind = *_first++;
- }
-
- return _first;
-}
-
-} // namespace rpp
-
-#endif // PP_ENGINE_BITS_H
-
-// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/generator/parser/rpp/pp-engine.h b/generator/parser/rpp/pp-engine.h
deleted file mode 100644
index 2704fa274..000000000
--- a/generator/parser/rpp/pp-engine.h
+++ /dev/null
@@ -1,297 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Script Generator project on Qt Labs.
-**
-** $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$
-**
-****************************************************************************/
-
-#ifndef PP_ENGINE_H
-#define PP_ENGINE_H
-
-namespace rpp {
-
-struct Value
-{
- enum Kind {
- Kind_Long,
- Kind_ULong,
- };
-
- Kind kind;
-
- union {
- long l;
- unsigned long ul;
- };
-
- inline bool is_ulong () const { return kind == Kind_ULong; }
-
- inline void set_ulong (unsigned long v)
- {
- ul = v;
- kind = Kind_ULong;
- }
-
- inline void set_long (long v)
- {
- l = v;
- kind = Kind_Long;
- }
-
- inline bool is_zero () const { return l == 0; }
-
-#define PP_DEFINE_BIN_OP(name, op) \
- inline Value &name (const Value &other) \
- { \
- if (is_ulong () || other.is_ulong ()) \
- set_ulong (ul op other.ul); \
- else \
- set_long (l op other.l); \
- return *this; \
- }
-
- PP_DEFINE_BIN_OP(op_add, +)
- PP_DEFINE_BIN_OP(op_sub, -)
- PP_DEFINE_BIN_OP(op_mult, *)
- PP_DEFINE_BIN_OP(op_div, /)
- PP_DEFINE_BIN_OP(op_mod, %)
- PP_DEFINE_BIN_OP(op_lhs, <<)
- PP_DEFINE_BIN_OP(op_rhs, >>)
- PP_DEFINE_BIN_OP(op_lt, <)
- PP_DEFINE_BIN_OP(op_gt, >)
- PP_DEFINE_BIN_OP(op_le, <=)
- PP_DEFINE_BIN_OP(op_ge, >=)
- PP_DEFINE_BIN_OP(op_eq, ==)
- PP_DEFINE_BIN_OP(op_ne, !=)
- PP_DEFINE_BIN_OP(op_bit_and, &)
- PP_DEFINE_BIN_OP(op_bit_or, |)
- PP_DEFINE_BIN_OP(op_bit_xor, ^)
- PP_DEFINE_BIN_OP(op_and, &&)
- PP_DEFINE_BIN_OP(op_or, ||)
-
-#undef PP_DEFINE_BIN_OP
-};
-
-class pp
-{
- pp_environment &env;
- pp_macro_expander expand;
- pp_skip_identifier skip_identifier;
- pp_skip_comment_or_divop skip_comment_or_divop;
- pp_skip_comment_or_divop skip_comment;
- pp_skip_blanks skip_blanks;
- pp_skip_number skip_number;
- std::vector include_paths;
- std::string _M_current_text;
-
- enum { MAX_LEVEL = 512 };
- int _M_skipping[MAX_LEVEL];
- int _M_true_test[MAX_LEVEL];
- int iflevel;
-
- union
- {
- long token_value;
- unsigned long token_uvalue;
- std::string *token_text;
- };
-
- enum INCLUDE_POLICY
- {
- INCLUDE_GLOBAL,
- INCLUDE_LOCAL
- };
-
- enum TOKEN_TYPE
- {
- TOKEN_NUMBER = 1000,
- TOKEN_UNUMBER,
- TOKEN_IDENTIFIER,
- TOKEN_DEFINED,
- TOKEN_LT_LT,
- TOKEN_LT_EQ,
- TOKEN_GT_GT,
- TOKEN_GT_EQ,
- TOKEN_EQ_EQ,
- TOKEN_NOT_EQ,
- TOKEN_OR_OR,
- TOKEN_AND_AND,
- };
-
- enum PP_DIRECTIVE_TYPE
- {
- PP_UNKNOWN_DIRECTIVE,
- PP_DEFINE,
- PP_INCLUDE,
- PP_INCLUDE_NEXT,
- PP_ELIF,
- PP_ELSE,
- PP_ENDIF,
- PP_IF,
- PP_IFDEF,
- PP_IFNDEF,
- PP_UNDEF,
- PP_PRAGMA,
- PP_ERROR,
- PP_WARNING
- };
-
-public:
- pp (pp_environment &env);
-
- inline std::back_insert_iterator > include_paths_inserter ();
-
- inline void push_include_path (std::string const &path);
-
- inline std::vector::iterator include_paths_begin ();
- inline std::vector::iterator include_paths_end ();
-
- inline std::vector::const_iterator include_paths_begin () const;
- inline std::vector::const_iterator include_paths_end () const;
-
- template
- inline InputIterator eval_expression (InputIterator _first, InputIterator _last, Value *result);
-
- template
- std::string expand_condition(InputIterator _first, InputIterator _last);
-
- template
- void file (std::string const &filename, OutputIterator _result);
-
- template
- void file (FILE *fp, OutputIterator _result);
-
- template
- void operator () (InputIterator _first, InputIterator _last, OutputIterator _result);
-
-private:
- inline bool file_isdir (std::string const &_filename) const;
- inline bool file_exists (std::string const &_filename) const;
- FILE *find_include_file (std::string const &_filename, std::string *_filepath,
- INCLUDE_POLICY include_policy, bool _skip_current_path = false) const;
-
- inline int skipping() const;
- bool test_if_level();
-
- inline std::string fix_file_path (std::string const &filename) const;
- inline bool is_absolute (std::string const &filename) const;
-
- PP_DIRECTIVE_TYPE find_directive (char const *_directive, std::size_t _size) const;
-
- template
- bool find_header_protection (InputIterator _first, InputIterator _last, std::string *_prot);
-
- template
- InputIterator skip (InputIterator _first, InputIterator _last);
-
- template
- InputIterator eval_primary(InputIterator _first, InputIterator _last, Value *result);
-
- template
- InputIterator eval_multiplicative(InputIterator _first, InputIterator _last, Value *result);
-
- template
- InputIterator eval_additive(InputIterator _first, InputIterator _last, Value *result);
-
- template
- InputIterator eval_shift(InputIterator _first, InputIterator _last, Value *result);
-
- template
- InputIterator eval_relational(InputIterator _first, InputIterator _last, Value *result);
-
- template
- InputIterator eval_equality(InputIterator _first, InputIterator _last, Value *result);
-
- template
- InputIterator eval_and(InputIterator _first, InputIterator _last, Value *result);
-
- template
- InputIterator eval_xor(InputIterator _first, InputIterator _last, Value *result);
-
- template
- InputIterator eval_or(InputIterator _first, InputIterator _last, Value *result);
-
- template
- InputIterator eval_logical_and(InputIterator _first, InputIterator _last, Value *result);
-
- template
- InputIterator eval_logical_or(InputIterator _first, InputIterator _last, Value *result);
-
- template
- InputIterator eval_constant_expression(InputIterator _first, InputIterator _last, Value *result);
-
- template
- InputIterator handle_directive(char const *_directive, std::size_t _size,
- InputIterator _first, InputIterator _last, OutputIterator _result);
-
- template
- InputIterator handle_include(bool skip_current_path, InputIterator _first, InputIterator _last,
- OutputIterator _result);
-
- template
- InputIterator handle_define (InputIterator _first, InputIterator _last);
-
- template
- InputIterator handle_if (InputIterator _first, InputIterator _last);
-
- template
- InputIterator handle_else (InputIterator _first, InputIterator _last);
-
- template
- InputIterator handle_elif (InputIterator _first, InputIterator _last);
-
- template
- InputIterator handle_endif (InputIterator _first, InputIterator _last);
-
- template
- InputIterator handle_ifdef (bool check_undefined, InputIterator _first, InputIterator _last);
-
- template
- InputIterator handle_undef(InputIterator _first, InputIterator _last);
-
- template
- char peek_char (InputIterator _first, InputIterator _last);
-
- template
- InputIterator next_token (InputIterator _first, InputIterator _last, int *kind);
-};
-
-} // namespace rpp
-
-#endif // PP_ENGINE_H
-
-// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/generator/parser/rpp/pp-environment.h b/generator/parser/rpp/pp-environment.h
deleted file mode 100644
index 049ff5899..000000000
--- a/generator/parser/rpp/pp-environment.h
+++ /dev/null
@@ -1,159 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Script Generator project on Qt Labs.
-**
-** $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$
-**
-****************************************************************************/
-
-#ifndef PP_ENVIRONMENT_H
-#define PP_ENVIRONMENT_H
-
-#include
-#include
-
-namespace rpp {
-
-class pp_environment
-{
-public:
- typedef std::vector::const_iterator const_iterator;
-
-public:
- pp_environment ():
- current_line (0),
- _M_hash_size (4093)
- {
- _M_base = (pp_macro **) memset (new pp_macro* [_M_hash_size], 0, _M_hash_size * sizeof (pp_macro*));
- }
-
- ~pp_environment ()
- {
- for (std::size_t i = 0; i < _M_macros.size (); ++i)
- delete _M_macros [i];
-
- delete [] _M_base;
- }
-
- const_iterator first_macro () const { return _M_macros.begin (); }
- const_iterator last_macro () const { return _M_macros.end (); }
-
- inline void bind (pp_fast_string const *_name, pp_macro const &_macro)
- {
- std::size_t h = hash_code (*_name) % _M_hash_size;
- pp_macro *m = new pp_macro (_macro);
- m->name = _name;
- m->next = _M_base [h];
- m->hash_code = h;
- _M_base [h] = m;
-
- _M_macros.push_back (m);
-
- if (_M_macros.size() == _M_hash_size)
- rehash();
- }
-
- inline void unbind (pp_fast_string const *_name)
- {
- if (pp_macro *m = resolve (_name))
- m->is.hidden = true;
- }
-
- inline void unbind (char const *_s, std::size_t _size)
- {
- pp_fast_string tmp (_s, _size);
- unbind (&tmp);
- }
-
- inline pp_macro *resolve (pp_fast_string const *_name) const
- {
- std::size_t h = hash_code (*_name) % _M_hash_size;
- pp_macro *it = _M_base [h];
-
- while (it && it->name && it->hash_code == h && (*it->name != *_name || it->is.hidden))
- it = it->next;
-
- return it;
- }
-
- inline pp_macro *resolve (char const *_data, std::size_t _size) const
- {
- pp_fast_string const tmp (_data, _size);
- return resolve (&tmp);
- }
-
- std::string current_file;
- int current_line;
-
-private:
- inline std::size_t hash_code (pp_fast_string const &s) const
- {
- std::size_t hash_value = 0;
-
- for (std::size_t i = 0; i < s.size (); ++i)
- hash_value = (hash_value << 5) - hash_value + s.at (i);
-
- return hash_value;
- }
-
- void rehash()
- {
- delete[] _M_base;
-
- _M_hash_size <<= 1;
-
- _M_base = (pp_macro **) memset (new pp_macro* [_M_hash_size], 0, _M_hash_size * sizeof(pp_macro*));
- for (std::size_t index = 0; index < _M_macros.size (); ++index)
- {
- pp_macro *elt = _M_macros [index];
- std::size_t h = hash_code (*elt->name) % _M_hash_size;
- elt->next = _M_base [h];
- elt->hash_code = h;
- _M_base [h] = elt;
- }
- }
-
-private:
- std::vector _M_macros;
- pp_macro **_M_base;
- std::size_t _M_hash_size;
-};
-
-} // namespace rpp
-
-#endif // PP_ENVIRONMENT_H
-
-// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/generator/parser/rpp/pp-fwd.h b/generator/parser/rpp/pp-fwd.h
deleted file mode 100644
index eacac5dac..000000000
--- a/generator/parser/rpp/pp-fwd.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Script Generator project on Qt Labs.
-**
-** $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$
-**
-****************************************************************************/
-
-#ifndef PP_FWD_H
-#define PP_FWD_H
-
-namespace rpp {
-
-template class pp_string;
-
-typedef pp_string pp_fast_string;
-
-#endif // PP_FWD_H
-
-} // namespace rpp
-
-// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/generator/parser/rpp/pp-internal.h b/generator/parser/rpp/pp-internal.h
deleted file mode 100644
index 4821ccb26..000000000
--- a/generator/parser/rpp/pp-internal.h
+++ /dev/null
@@ -1,134 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Script Generator project on Qt Labs.
-**
-** $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$
-**
-****************************************************************************/
-
-#ifndef PP_INTERNAL_H
-#define PP_INTERNAL_H
-
-#include
-#include
-
-namespace rpp {
-
-namespace _PP_internal
-{
-
-inline void extract_file_path (const std::string &_filename, std::string *_filepath)
-{
- std::size_t index = _filename.rfind (PATH_SEPARATOR);
-
- if (index == std::string::npos)
- *_filepath = "/";
-
- else
- _filepath->assign (_filename, 0, index + 1);
-}
-
-template
-void output_line(const std::string &_filename, int _line, OutputIterator _result)
-{
- std::string msg;
-
- msg += "# ";
-
- char line_descr[16];
- pp_snprintf (line_descr, 16, "%d", _line);
- msg += line_descr;
-
- msg += " \"";
-
- if (_filename.empty ())
- msg += "";
- else
- msg += _filename;
-
- msg += "\"\n";
- std::copy (msg.begin (), msg.end (), _result);
-}
-
-template
-inline bool comment_p (InputIterator _first, InputIterator _last) /*const*/
-{
- if (_first == _last)
- return false;
-
- if (*_first != '/')
- return false;
-
- if (++_first == _last)
- return false;
-
- return (*_first == '/' || *_first == '*');
-}
-
-struct _Compare_string
-{
- inline bool operator () (pp_fast_string const *__lhs, pp_fast_string const *__rhs) const
- { return *__lhs < *__rhs; }
-};
-
-struct _Equal_to_string
-{
- inline bool operator () (pp_fast_string const *__lhs, pp_fast_string const *__rhs) const
- { return *__lhs == *__rhs; }
-};
-
-struct _Hash_string
-{
- inline std::size_t operator () (pp_fast_string const *__s) const
- {
- char const *__ptr = __s->begin ();
- std::size_t __size = __s->size ();
- std::size_t __h = 0;
-
- for (std::size_t i = 0; i < __size; ++i)
- __h = (__h << 5) - __h + __ptr [i];
-
- return __h;
- }
-};
-
-} // _PP_internal
-
-} // namespace rpp
-
-#endif // PP_INTERNAL_H
-
-// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/generator/parser/rpp/pp-iterator.h b/generator/parser/rpp/pp-iterator.h
deleted file mode 100644
index 230e3c898..000000000
--- a/generator/parser/rpp/pp-iterator.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Script Generator project on Qt Labs.
-**
-** $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$
-**
-****************************************************************************/
-
-#ifndef PP_ITERATOR_H
-#define PP_ITERATOR_H
-
-#include
-#include // Q_CC_MSVC
-
-namespace rpp {
-
-class pp_null_output_iterator
- : public std::iterator
-{
-public:
- pp_null_output_iterator() {}
-
- template
- pp_null_output_iterator &operator=(_Tp const &)
- { return *this; }
-
- inline pp_null_output_iterator &operator * () { return *this; }
- inline pp_null_output_iterator &operator ++ () { return *this; }
- inline pp_null_output_iterator operator ++ (int) { return *this; }
-};
-
-template
-class pp_output_iterator
- : public std::iterator
-{
- std::string &_M_result;
-
-public:
- explicit pp_output_iterator(std::string &__result):
- _M_result (__result) {}
-
-#ifdef Q_CC_MSVC
- // this copy constructor was needed for Visual Studio 2012 release builds:
- inline pp_output_iterator &operator=(const pp_output_iterator& other)
- {
- *(std::iterator*)(this) = other;
- _M_result = other._M_result;
- return *this;
- }
-#endif
-
- inline pp_output_iterator &operator=(typename _Container::const_reference __v)
- {
- if (_M_result.capacity () == _M_result.size ())
- _M_result.reserve (_M_result.capacity () << 2);
-
- _M_result.push_back(__v);
- return *this;
- }
-
- inline pp_output_iterator &operator * () { return *this; }
- inline pp_output_iterator &operator ++ () { return *this; }
- inline pp_output_iterator operator ++ (int) { return *this; }
-};
-
-} // namespace rpp
-
-#endif // PP_ITERATOR_H
-
-// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/generator/parser/rpp/pp-macro-expander.h b/generator/parser/rpp/pp-macro-expander.h
deleted file mode 100644
index 85de8a111..000000000
--- a/generator/parser/rpp/pp-macro-expander.h
+++ /dev/null
@@ -1,421 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Script Generator project on Qt Labs.
-**
-** $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$
-**
-****************************************************************************/
-
-#ifndef PP_MACRO_EXPANDER_H
-#define PP_MACRO_EXPANDER_H
-
-#include
-
-namespace rpp {
-
-struct pp_frame
-{
- pp_macro *expanding_macro;
- std::vector *actuals;
-
- pp_frame (pp_macro *_expanding_macro, std::vector *_actuals):
- expanding_macro (_expanding_macro), actuals (_actuals) {}
-};
-
-class pp_macro_expander
-{
- pp_environment &env;
- pp_frame *frame;
-
- pp_skip_number skip_number;
- pp_skip_identifier skip_identifier;
- pp_skip_string_literal skip_string_literal;
- pp_skip_char_literal skip_char_literal;
- pp_skip_argument skip_argument;
- pp_skip_comment_or_divop skip_comment_or_divop;
- pp_skip_blanks skip_blanks;
- pp_skip_whitespaces skip_whitespaces;
-
- std::string const *resolve_formal (pp_fast_string const *_name)
- {
- static const pp_fast_string va_args_name("__VA_ARGS__", 11);
- static std::string empty("");
-
- assert (_name != 0);
-
- if (! frame)
- return 0;
-
- assert (frame->expanding_macro != 0);
-
- std::vector formals = frame->expanding_macro->formals;
- if (frame->expanding_macro->is.variadics)
- formals.push_back(&va_args_name);
-
- for (std::size_t index = 0; index < formals.size(); ++index)
- {
- pp_fast_string const *formal = formals[index];
-
- if (*formal != *_name)
- continue;
-
- else if (frame->actuals && index < frame->actuals->size())
- return &(*frame->actuals)[index];
-
- else if (frame->expanding_macro->is.variadics && index == formals.size()-1)
- // variadic argument may also be missing, replace with empty then
- return ∅
-
- else
- assert (0); // internal error?
- }
-
- return 0;
- }
-
-public: // attributes
- int lines;
- int generated_lines;
-
-public:
- pp_macro_expander (pp_environment &_env, pp_frame *_frame = 0):
- env (_env), frame (_frame), lines (0), generated_lines (0) {}
-
- template
- InputIterator operator () (InputIterator _first, InputIterator _last, OutputIterator _result)
- {
- generated_lines = 0;
- _first = skip_blanks (_first, _last);
- lines = skip_blanks.lines;
-
- while (_first != _last)
- {
- if (*_first == '\n')
- {
- *_result++ = *_first;
- ++lines;
-
- _first = skip_blanks (++_first, _last);
- lines += skip_blanks.lines;
-
- if (_first != _last && *_first == '#')
- break;
- }
- else if (*_first == '#')
- {
- _first = skip_blanks (++_first, _last);
- lines += skip_blanks.lines;
-
- InputIterator end_id = skip_identifier (_first, _last);
-
- // ### rewrite: not safe
- char name_buffer[512], *cp = name_buffer;
- std::copy (_first, end_id, cp);
- std::size_t name_size = end_id - _first;
- name_buffer[name_size] = '\0';
-
- pp_fast_string fast_name (name_buffer, name_size);
-
- if (std::string const *actual = resolve_formal (&fast_name))
- {
- *_result++ = '\"';
-
- for (std::string::const_iterator it = skip_whitespaces (actual->begin (), actual->end ());
- it != actual->end (); ++it)
- {
- if (*it == '"')
- {
- *_result++ = '\\';
- *_result++ = *it;
- }
-
- else if (*it == '\n')
- {
- *_result++ = '"';
- *_result++ = '\n';
- *_result++ = '"';
- }
-
- else
- *_result++ = *it;
- }
-
- *_result++ = '\"';
- _first = end_id;
- }
- else
- *_result++ = '#'; // ### warning message?
- }
- else if (*_first == '\"')
- {
- InputIterator next_pos = skip_string_literal (_first, _last);
- lines += skip_string_literal.lines;
- std::copy (_first, next_pos, _result);
- _first = next_pos;
- }
- else if (*_first == '\'')
- {
- InputIterator next_pos = skip_char_literal (_first, _last);
- lines += skip_char_literal.lines;
- std::copy (_first, next_pos, _result);
- _first = next_pos;
- }
- else if (_PP_internal::comment_p (_first, _last))
- {
- _first = skip_comment_or_divop (_first, _last);
- int n = skip_comment_or_divop.lines;
- lines += n;
-
- while (n-- > 0)
- *_result++ = '\n';
- }
- else if (pp_isspace (*_first))
- {
- for (; _first != _last; ++_first)
- {
- if (*_first == '\n' || !pp_isspace (*_first))
- break;
- }
-
- *_result = ' ';
- }
- else if (pp_isdigit (*_first))
- {
- InputIterator next_pos = skip_number (_first, _last);
- lines += skip_number.lines;
- std::copy (_first, next_pos, _result);
- _first = next_pos;
- }
- else if (pp_isalpha (*_first) || *_first == '_')
- {
- InputIterator name_begin = _first;
- InputIterator name_end = skip_identifier (_first, _last);
- _first = name_end; // advance
-
- // search for the paste token
- InputIterator next = skip_blanks (_first, _last);
- if (next != _last && *next == '#')
- {
- ++next;
- if (next != _last && *next == '#')
- _first = skip_blanks(++next, _last);
- }
-
- // ### rewrite: not safe
-
- std::ptrdiff_t name_size;
-#if defined(__SUNPRO_CC)
- std::distance (name_begin, name_end, name_size);
-#else
- name_size = std::distance (name_begin, name_end);
-#endif
- assert (name_size >= 0 && name_size < 512);
-
- char name_buffer[512], *cp = name_buffer;
- std::size_t _size = name_end - name_begin;
- std::copy (name_begin, name_end, cp);
- name_buffer[_size] = '\0';
-
- pp_fast_string fast_name (name_buffer, name_size);
-
- if (std::string const *actual = resolve_formal (&fast_name))
- {
- std::copy (actual->begin (), actual->end (), _result);
- continue;
- }
-
- static bool hide_next = false; // ### remove me
-
- pp_macro *macro = env.resolve (name_buffer, name_size);
- if (! macro || macro->is.hidden || hide_next)
- {
- hide_next = ! strcmp (name_buffer, "defined");
-
- if (_size == 8 && name_buffer [0] == '_' && name_buffer [1] == '_')
- {
- if (! strcmp (name_buffer, "__LINE__"))
- {
- char buf [16];
- char *end = buf + pp_snprintf (buf, 16, "%d", env.current_line + lines);
-
- std::copy (&buf [0], end, _result);
- continue;
- }
-
- else if (! strcmp (name_buffer, "__FILE__"))
- {
- _result++ = '"';
- std::copy (env.current_file.begin (), env.current_file.end (), _result); // ### quote
- _result++ = '"';
- continue;
- }
- }
-
- std::copy (name_begin, name_end, _result);
- continue;
- }
-
- if (! macro->is.function_like)
- {
- pp_macro *m = 0;
-
- if (macro->definition)
- {
- macro->is.hidden = true;
-
- std::string tmp;
- tmp.reserve (256);
-
- pp_macro_expander expand_macro (env);
- expand_macro (macro->definition->begin (), macro->definition->end (), std::back_inserter (tmp));
- generated_lines += expand_macro.lines;
-
- if (! tmp.empty ())
- {
- std::string::iterator begin_id = skip_whitespaces (tmp.begin (), tmp.end ());
- std::string::iterator end_id = skip_identifier (begin_id, tmp.end ());
-
- if (end_id == tmp.end ())
- {
- std::string id;
- id.assign (begin_id, end_id);
-
- std::size_t x;
-#if defined(__SUNPRO_CC)
- std::distance (__begin_id, __end_id, x);
-#else
- x = std::distance (begin_id, end_id);
-#endif
- m = env.resolve (id.c_str (), x);
- }
-
- if (! m)
- std::copy (tmp.begin (), tmp.end (), _result);
- }
-
- macro->is.hidden = false;
- }
-
- if (! m)
- continue;
-
- macro = m;
- }
-
- // function like macro
- InputIterator arg_it = skip_whitespaces (_first, _last);
-
- if (arg_it == _last || *arg_it != '(')
- {
- std::copy (name_begin, name_end, _result);
- lines += skip_whitespaces.lines;
- _first = arg_it;
- continue;
- }
-
- std::vector actuals;
- actuals.reserve (5);
- ++arg_it; // skip '('
-
- pp_macro_expander expand_actual (env, frame);
-
- InputIterator arg_end = skip_argument_variadics (actuals, macro, arg_it, _last);
- if (arg_it != arg_end)
- {
- std::string actual (arg_it, arg_end);
- actuals.resize (actuals.size() + 1);
- actuals.back ().reserve (255);
- expand_actual (actual.begin (), actual.end(), std::back_inserter (actuals.back()));
- arg_it = arg_end;
- }
-
- while (arg_it != _last && *arg_end == ',')
- {
- ++arg_it; // skip ','
-
- arg_end = skip_argument_variadics (actuals, macro, arg_it, _last);
- std::string actual (arg_it, arg_end);
- actuals.resize (actuals.size() + 1);
- actuals.back ().reserve (255);
- expand_actual (actual.begin (), actual.end(), std::back_inserter (actuals.back()));
- arg_it = arg_end;
- }
-
- assert (arg_it != _last && *arg_it == ')');
-
- ++arg_it; // skip ')'
- _first = arg_it;
-
-#if 0 // ### enable me
- assert ((macro->is.variadics && macro->formals.size () >= actuals.size ())
- || macro->formals.size() == actuals.size());
-#endif
-
- pp_frame frame (macro, &actuals);
- pp_macro_expander expand_macro (env, &frame);
- macro->is.hidden = true;
- expand_macro (macro->definition->begin (), macro->definition->end (), _result);
- macro->is.hidden = false;
- generated_lines += expand_macro.lines;
- }
- else
- *_result++ = *_first++;
- }
-
- return _first;
- }
-
- template
- InputIterator skip_argument_variadics (std::vector const &_actuals, pp_macro *_macro,
- InputIterator _first, InputIterator _last)
- {
- InputIterator arg_end = skip_argument (_first, _last);
-
- while (_macro->is.variadics && arg_end != _last && *arg_end == ','
- && _actuals.size () == _macro->formals.size ())
- {
- arg_end = skip_argument (++arg_end, _last);
- }
-
- return arg_end;
- }
-};
-
-} // namespace rpp
-
-#endif // PP_MACRO_EXPANDER_H
-
-// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/generator/parser/rpp/pp-macro.h b/generator/parser/rpp/pp-macro.h
deleted file mode 100644
index 6342549d4..000000000
--- a/generator/parser/rpp/pp-macro.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Script Generator project on Qt Labs.
-**
-** $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$
-**
-****************************************************************************/
-
-#ifndef PP_MACRO_H
-#define PP_MACRO_H
-
-namespace rpp {
-
-struct pp_macro
-{
-#if defined (PP_WITH_MACRO_POSITION)
- pp_fast_string const *file;
-#endif
- pp_fast_string const *name;
- pp_fast_string const *definition;
- std::vector formals;
-
- union
- {
- int unsigned state;
-
- struct
- {
- int unsigned hidden: 1;
- int unsigned function_like: 1;
- int unsigned variadics: 1;
- } is;
- };
-
- int lines;
- pp_macro *next;
- std::size_t hash_code;
-
- inline pp_macro():
-#if defined (PP_WITH_MACRO_POSITION)
- file (0),
-#endif
- name (0),
- definition (0),
- state (0),
- lines (0),
- next (0),
- hash_code (0)
- {}
-};
-
-} // namespace rpp
-
-#endif // PP_MACRO_H
-
-// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/generator/parser/rpp/pp-main.cpp b/generator/parser/rpp/pp-main.cpp
deleted file mode 100644
index aaf09e141..000000000
--- a/generator/parser/rpp/pp-main.cpp
+++ /dev/null
@@ -1,340 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Script Generator project on Qt Labs.
-**
-** $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$
-**
-****************************************************************************/
-
-#include
-#include "pp.h"
-
-using namespace rpp;
-
-#ifndef GCC_MACHINE
-# define GCC_MACHINE "i386-redhat-linux"
-#endif
-
-#ifndef GCC_VERSION
-# define GCC_VERSION "4.1.1"
-#endif
-
-void usage ()
-{
- std::cerr << "usage: rpp file.cpp" << std::endl;
- ::exit (EXIT_FAILURE);
-}
-
-void dump_macros (pp_environment &env, pp &, std::ostream &__out)
-{
- for (pp_environment::const_iterator it = env.first_macro (); it != env.last_macro (); ++it)
- {
- pp_macro const *m = *it;
-
- if (m->hidden)
- continue;
-
- std::string id (m->name->begin (), m->name->end ());
- __out << "#define " << id;
-
- if (m->function_like)
- {
- __out << "(";
-
- for (std::size_t i = 0; i < m->formals.size (); ++i)
- {
- if (i != 0)
- __out << ", ";
-
- pp_fast_string const *f = m->formals [i];
- std::string name (f->begin (), f->end ());
- __out << name;
- }
-
- if (m->variadics)
- __out << "...";
-
- __out << ")";
- }
-
- __out << "\t";
- if (m->definition)
- {
- std::string def (m->definition->begin (), m->definition->end ());
- __out << def;
- }
-
- __out << std::endl;
- }
-}
-
-int main (int, char *argv [])
-{
- char const *input_file = 0;
- char const *output_file = 0;
- char const *include_pch_file = 0;
- bool opt_help = false;
- bool opt_dump_macros = false;
- bool opt_pch = false;
-
- pp_environment env;
- pp preprocess(env);
-
- std::string result;
- result.reserve (20 * 1024); // 20K
-
- pp_output_iterator out (result);
- pp_null_output_iterator null_out;
-
- preprocess.push_include_path ("/usr/include");
- preprocess.push_include_path ("/usr/lib/gcc/" GCC_MACHINE "/" GCC_VERSION "/include");
-
- preprocess.push_include_path ("/usr/include/c++/" GCC_VERSION);
- preprocess.push_include_path ("/usr/include/c++/" GCC_VERSION "/" GCC_MACHINE);
-
- std::string extra_args;
-
- while (const char *arg = *++argv)
- {
- if (arg [0] != '-')
- input_file = arg;
-
- else if (! strcmp (arg, "-help"))
- opt_help = true;
-
- else if (! strcmp (arg, "-dM"))
- opt_dump_macros = true;
-
- else if (! strcmp (arg, "-pch"))
- opt_pch = true;
-
- else if (! strcmp (arg, "-msse"))
- {
- pp_macro __macro;
- __macro.name = pp_symbol::get ("__SSE__", 7);
- env.bind (__macro.name, __macro);
-
- __macro.name = pp_symbol::get ("__MMX__", 7);
- env.bind (__macro.name, __macro);
- }
-
- else if (! strcmp (arg, "-include"))
- {
- if (argv [1])
- include_pch_file = *++argv;
- }
-
- else if (! strncmp (arg, "-o", 2))
- {
- arg += 2;
-
- if (! arg [0] && argv [1])
- arg = *++argv;
-
- if (arg)
- output_file = arg;
- }
-
- else if (! strncmp (arg, "-conf", 8))
- {
- if (argv [1])
- preprocess.file (*++argv, null_out);
- }
-
- else if (! strncmp (arg, "-I", 2))
- {
- arg += 2;
-
- if (! arg [0] && argv [1])
- arg = *++argv;
-
- if (arg)
- preprocess.push_include_path (arg);
- }
-
- else if (! strncmp (arg, "-U", 2))
- {
- arg += 2;
-
- if (! arg [0] && argv [1])
- arg = *++argv;
-
- if (arg)
- {
- env.unbind (arg, strlen (arg));
- }
- }
-
- else if (! strncmp (arg, "-D", 2))
- {
- arg += 2;
-
- if (! arg [0] && argv [1])
- arg = *++argv;
-
- if (arg)
- {
- pp_macro __macro;
-
- char const *end = arg;
- char const *eq = 0;
-
- for (; *end; ++end)
- {
- if (*end == '=')
- eq = end;
- }
-
- if (eq != 0)
- {
- __macro.name = pp_symbol::get (arg, eq - arg);
- __macro.definition = pp_symbol::get (eq + 1, end - (eq + 1));
- }
-
- else
- {
- __macro.name = pp_symbol::get (arg, end - arg);
- __macro.definition = 0;
- }
-
- env.bind (__macro.name, __macro);
- }
- }
- else
- {
- extra_args += " ";
- extra_args += arg;
- }
- }
-
- if (! input_file || opt_help)
- {
- usage ();
- return EXIT_FAILURE;
- }
-
- std::string __ifile (input_file);
- bool is_c_file = false;
- if (__ifile.size () > 2 && __ifile [__ifile.size () - 1] == 'c' && __ifile [__ifile.size () - 2] == '.')
- {
- is_c_file = true;
- env.unbind ("__cplusplus", 11);
-
- pp_macro __macro;
- __macro.name = pp_symbol::get ("__null");
- __macro.definition = pp_symbol::get ("((void*) 0)");
- env.bind (__macro.name, __macro);
-
- // turn off the pch
- include_pch_file = 0;
- }
- else if (include_pch_file)
- {
- std::string __pch (include_pch_file);
- __pch += ".gch/c++.conf";
-
- //std::cerr << "*** pch file " << __pch << std::endl;
- preprocess.file (__pch, null_out);
- }
-
- if (opt_dump_macros)
- {
- preprocess.file (input_file, null_out);
- dump_macros (env, preprocess, std::cout);
- return EXIT_SUCCESS;
- }
-
- preprocess.file (input_file, out);
-
- if (opt_pch)
- {
- if (! output_file)
- {
- std::cerr << "*** WARNING expected a file name" << std::endl;
- return EXIT_FAILURE;
- }
-
- std::string __conf_file (output_file);
- __conf_file += ".conf";
-
- std::ofstream __out;
- __out.open (__conf_file.c_str ());
- dump_macros (env, preprocess, __out);
- __out.close ();
-
- std::string __pp_file (output_file);
- __pp_file += ".i";
-
- __out.open (__pp_file.c_str ());
- __out.write (result.c_str (), result.size ());
- __out.close ();
- return EXIT_SUCCESS;
- }
-
- std::ostream *__out = &std::cout;
- std::ofstream __ofile;
-
- if (output_file)
- {
- std::string __output_file_name (output_file);
- __ofile.open (output_file);
- __out = &__ofile;
- }
-
- if (include_pch_file)
- {
- std::string __pch (include_pch_file);
- __pch += ".gch/c++.i";
-
- std::ifstream __in (__pch.c_str ());
-
- char buffer [1024];
- while (__in.read (buffer, 1024))
- __out->write (buffer, 1024);
-
- __in.close ();
- }
-
- __out->write (result.c_str (), result.size ());
-
- if (output_file)
- __ofile.close ();
-
- return EXIT_SUCCESS;
-}
-
-// kate: space-indent on; indent-width 2; replace-tabs on;
-
diff --git a/generator/parser/rpp/pp-qt-configuration b/generator/parser/rpp/pp-qt-configuration
deleted file mode 100644
index fd79c8506..000000000
--- a/generator/parser/rpp/pp-qt-configuration
+++ /dev/null
@@ -1,36 +0,0 @@
-#define __cplusplus 1
-
-#define __STDC__
-
-// Qt
-#define QOBJECTDEFS_H
-#define QTMETAMACROS_H
-
-// not yet supported
-#define Q_SLOTS slots
-#define Q_SIGNALS signals
-#define Q_FLAGS(a)
-#define Q_FLAG(a)
-#define Q_PRIVATE_SLOT(a, b)
-#define Q_DECLARE_INTERFACE(a,b)
-#define Q_INTERFACES(a)
-#define Q_GADGET
-#define Q_OVERRIDE(a)
-#define Q_OS_OS2
-#define Q_NO_USING_KEYWORD
-#define Q_DECL_OVERRIDE override
-
-// There are symbols in Qt that exist in Debug but
-// not in release
-#define QT_NO_DEBUG
-
-#define QT_JAMBI_RUN
-
-// Qt6
-#define Q_NAMESPACE_EXPORT(...)
-#define Q_ENUM_NS(x)
-#define Q_FLAG_NS(x)
-#define Q_MOC_INCLUDE(...)
-
-// ignore static_assert
-#define static_assert(...)
\ No newline at end of file
diff --git a/generator/parser/rpp/pp-scanner.h b/generator/parser/rpp/pp-scanner.h
deleted file mode 100644
index 862590beb..000000000
--- a/generator/parser/rpp/pp-scanner.h
+++ /dev/null
@@ -1,373 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Script Generator project on Qt Labs.
-**
-** $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$
-**
-****************************************************************************/
-
-#ifndef PP_SCANNER_H
-#define PP_SCANNER_H
-
-namespace rpp {
-
-struct pp_skip_blanks
-{
- int lines;
-
- template
- _InputIterator operator () (_InputIterator __first, _InputIterator __last)
- {
- lines = 0;
-
- for (; __first != __last; lines += (*__first != '\n' ? 0 : 1), ++__first)
- {
- if (*__first == '\\')
- {
- _InputIterator __begin = __first;
- ++__begin;
-
- if (__begin != __last && *__begin == '\n')
- ++__first;
- else
- break;
- }
- else if (*__first == '\n' || !pp_isspace (*__first))
- break;
- }
-
- return __first;
- }
-};
-
-struct pp_skip_whitespaces
-{
- int lines;
-
- template
- _InputIterator operator () (_InputIterator __first, _InputIterator __last)
- {
- lines = 0;
-
- for (; __first != __last; lines += (*__first != '\n' ? 0 : 1), ++__first)
- {
- if (! pp_isspace (*__first))
- break;
- }
-
- return __first;
- }
-};
-
-struct pp_skip_comment_or_divop
-{
- pp_skip_comment_or_divop(bool skipDiv = true) { _skipDiv = skipDiv; }
-
- int lines;
-
- template
- _InputIterator operator () (_InputIterator __first, _InputIterator __last)
- {
- enum {
- MAYBE_BEGIN,
- BEGIN,
- MAYBE_END,
- END,
- IN_COMMENT,
- IN_CXX_COMMENT
- } state (MAYBE_BEGIN);
-
- lines = 0;
-
- for (; __first != __last; lines += (*__first != '\n' ? 0 : 1), ++__first)
- {
- switch (state)
- {
- default:
- assert (0);
- break;
-
- case MAYBE_BEGIN:
- if (*__first != '/')
- return __first;
-
- state = BEGIN;
- break;
-
- case BEGIN:
- if (*__first == '*')
- state = IN_COMMENT;
- else if (*__first == '/')
- state = IN_CXX_COMMENT;
- else if (_skipDiv)
- return __first;
- else
- return __first-1;
- break;
-
- case IN_COMMENT:
- if (*__first == '*')
- state = MAYBE_END;
- break;
-
- case IN_CXX_COMMENT:
- if (*__first == '\n')
- return __first;
- break;
-
- case MAYBE_END:
- if (*__first == '/')
- state = END;
- else if (*__first != '*')
- state = IN_COMMENT;
- break;
-
- case END:
- return __first;
- }
- }
-
- return __first;
- }
-private:
- bool _skipDiv;
-};
-
-struct pp_skip_identifier
-{
- int lines;
-
- template
- _InputIterator operator () (_InputIterator __first, _InputIterator __last)
- {
- lines = 0;
-
- for (; __first != __last; lines += (*__first != '\n' ? 0 : 1), ++__first)
- {
- if (! pp_isalnum (*__first) && *__first != '_')
- break;
- }
-
- return __first;
- }
-};
-
-struct pp_skip_number
-{
- int lines;
-
- template
- _InputIterator operator () (_InputIterator __first, _InputIterator __last)
- {
- lines = 0;
-
- for (; __first != __last; lines += (*__first != '\n' ? 0 : 1), ++__first)
- {
- if (! pp_isalnum (*__first) && *__first != '.')
- break;
- }
-
- return __first;
- }
-};
-
-struct pp_skip_string_literal
-{
- int lines;
-
- template
- _InputIterator operator () (_InputIterator __first, _InputIterator __last)
- {
- enum {
- BEGIN,
- IN_STRING,
- QUOTE,
- END
- } state (BEGIN);
-
- lines = 0;
-
- for (; __first != __last; lines += (*__first != '\n' ? 0 : 1), ++__first)
- {
- switch (state)
- {
- default:
- assert (0);
- break;
-
- case BEGIN:
- if (*__first != '\"')
- return __first;
- state = IN_STRING;
- break;
-
- case IN_STRING:
- assert (*__first != '\n');
-
- if (*__first == '\"')
- state = END;
- else if (*__first == '\\')
- state = QUOTE;
- break;
-
- case QUOTE:
- state = IN_STRING;
- break;
-
- case END:
- return __first;
- }
- }
-
- return __first;
- }
-};
-
-struct pp_skip_char_literal
-{
- int lines;
-
- template
- _InputIterator operator () (_InputIterator __first, _InputIterator __last)
- {
- enum {
- BEGIN,
- IN_STRING,
- QUOTE,
- END
- } state (BEGIN);
-
- lines = 0;
-
- for (; state != END && __first != __last; lines += (*__first != '\n' ? 0 : 1), ++__first)
- {
- switch (state)
- {
- default:
- assert (0);
- break;
-
- case BEGIN:
- if (*__first != '\'')
- return __first;
- state = IN_STRING;
- break;
-
- case IN_STRING:
- assert (*__first != '\n');
-
- if (*__first == '\'')
- state = END;
- else if (*__first == '\\')
- state = QUOTE;
- break;
-
- case QUOTE:
- state = IN_STRING;
- break;
- }
- }
-
- return __first;
- }
-};
-
-struct pp_skip_argument
-{
- pp_skip_identifier skip_number;
- pp_skip_identifier skip_identifier;
- pp_skip_string_literal skip_string_literal;
- pp_skip_char_literal skip_char_literal;
- pp_skip_comment_or_divop skip_comment_or_divop;
- int lines;
-
- template
- _InputIterator operator () (_InputIterator __first, _InputIterator __last)
- {
- int depth = 0;
- lines = 0;
-
- while (__first != __last)
- {
- if (!depth && (*__first == ')' || *__first == ','))
- break;
- else if (*__first == '(')
- ++depth, ++__first;
- else if (*__first == ')')
- --depth, ++__first;
- else if (*__first == '\"')
- {
- __first = skip_string_literal (__first, __last);
- lines += skip_string_literal.lines;
- }
- else if (*__first == '\'')
- {
- __first = skip_char_literal (__first, __last);
- lines += skip_char_literal.lines;
- }
- else if (*__first == '/')
- {
- __first = skip_comment_or_divop (__first, __last);
- lines += skip_comment_or_divop.lines;
- }
- else if (pp_isalpha (*__first) || *__first == '_')
- {
- __first = skip_identifier (__first, __last);
- lines += skip_identifier.lines;
- }
- else if (pp_isdigit (*__first))
- {
- __first = skip_number (__first, __last);
- lines += skip_number.lines;
- }
- else if (*__first == '\n')
- {
- ++__first;
- ++lines;
- }
- else
- ++__first;
- }
-
- return __first;
- }
-};
-
-} // namespace rpp
-
-#endif // PP_SCANNER_H
-
-// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/generator/parser/rpp/pp-string.h b/generator/parser/rpp/pp-string.h
deleted file mode 100644
index f0c3d4c4d..000000000
--- a/generator/parser/rpp/pp-string.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Script Generator project on Qt Labs.
-**
-** $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$
-**
-****************************************************************************/
-
-#ifndef PP_STRING_H
-#define PP_STRING_H
-
-namespace rpp {
-
-template
-class pp_string
-{
- typedef std::char_traits<_CharT> traits_type;
- typedef std::size_t size_type;
-
- _CharT const *_M_begin;
- std::size_t _M_size;
-
-public:
- inline pp_string ():
- _M_begin (0), _M_size(0) {}
-
- explicit pp_string (std::string const &__s):
- _M_begin (__s.c_str ()), _M_size (__s.size ()) {}
-
- inline pp_string (_CharT const *__begin, std::size_t __size):
- _M_begin (__begin), _M_size (__size) {}
-
- inline _CharT const *begin () const { return _M_begin; }
- inline _CharT const *end () const { return _M_begin + _M_size; }
-
- inline _CharT at (std::size_t index) const { return _M_begin [index]; }
-
- inline std::size_t size () const { return _M_size; }
-
- inline int compare (pp_string const &__other) const
- {
- size_type const __size = this->size();
- size_type const __osize = __other.size();
- size_type const __len = std::min (__size, __osize);
-
- int __r = traits_type::compare (_M_begin, __other._M_begin, __len);
- if (!__r)
- __r = (int) (__size - __osize);
-
- return __r;
- }
-
- inline bool operator == (pp_string const &__other) const
- { return compare (__other) == 0; }
-
- inline bool operator != (pp_string const &__other) const
- { return compare (__other) != 0; }
-
- inline bool operator < (pp_string const &__other) const
- { return compare (__other) < 0; }
-
- inline bool operator == (char const *s) const
- {
- std::size_t n = strlen (s);
-
- if (n != _M_size)
- return false;
-
- return ! strncmp (_M_begin, s, n);
- }
-
- inline bool operator != (char const *s) const
- { return ! operator == (s); }
-};
-
-} // namespace rpp
-
-#endif // PP_STRING_H
-
-// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/generator/parser/rpp/pp-symbol.h b/generator/parser/rpp/pp-symbol.h
deleted file mode 100644
index b078b6651..000000000
--- a/generator/parser/rpp/pp-symbol.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Script Generator project on Qt Labs.
-**
-** $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$
-**
-****************************************************************************/
-
-#ifndef PP_SYMBOL_H
-#define PP_SYMBOL_H
-
-namespace rpp {
-
-class pp_symbol
-{
- static rxx_allocator &allocator_instance ()
- {
- static rxx_allocator__allocator;
- return __allocator;
- }
-
-public:
- static int &N()
- {
- static int __N;
- return __N;
- }
-
- static pp_fast_string const *get (char const *__data, std::size_t __size)
- {
- ++N();
- char *data = allocator_instance ().allocate (__size + 1);
- memcpy(data, __data, __size);
- data[__size] = '\0';
-
- char *where = allocator_instance ().allocate (sizeof (pp_fast_string));
- return new (where) pp_fast_string (data, __size);
- }
-
- template
- static pp_fast_string const *get (_InputIterator __first, _InputIterator __last)
- {
- ++N();
- std::ptrdiff_t __size;
-#if defined(__SUNPRO_CC)
- std::distance (__first, __last, __size);
-#else
- __size = std::distance (__first, __last);
-#endif
- assert (__size >= 0 && __size < 512);
-
- char *data = allocator_instance ().allocate (__size + 1);
- std::copy (__first, __last, data);
- data[__size] = '\0';
-
- char *where = allocator_instance ().allocate (sizeof (pp_fast_string));
- return new (where) pp_fast_string (data, __size);
- }
-
- static pp_fast_string const *get(std::string const &__s)
- { return get (__s.c_str (), __s.size ()); }
-};
-
-} // namespace rpp
-
-#endif // PP_SYMBOL_H
-
-// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/generator/parser/rpp/pp.h b/generator/parser/rpp/pp.h
deleted file mode 100644
index b7d042101..000000000
--- a/generator/parser/rpp/pp.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Script Generator project on Qt Labs.
-**
-** $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$
-**
-****************************************************************************/
-
-#ifndef PP_H
-#define PP_H
-
-#if defined(_WIN64) || defined(WIN64) || defined(__WIN64__) \
- || defined(_WIN32) || defined(WIN32) || defined(__WIN32__)
-# define PP_OS_WIN
-#endif
-
-#include
-#include