aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2021-09-30 11:25:56 +0200
committerUlf Hermann <ulf.hermann@qt.io>2021-09-30 12:48:57 +0200
commiteae65ba6331a6b5066abe5c892de1bda423a8c76 (patch)
tree28d61e92bfe0abea63a83ca1e7f0f9096378f923 /src
parent4deb42b5985cd50d7c2c8983ba0dbf21a45f9c7c (diff)
Make QQmlJS::Engine all inline and eliminate unused function
Change-Id: If30dbc79ca686607ec023f3944f82093106823be Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/qml/CMakeLists.txt2
-rw-r--r--src/qml/parser/qqmljsengine_p.cpp157
-rw-r--r--src/qml/parser/qqmljsengine_p.h50
3 files changed, 32 insertions, 177 deletions
diff --git a/src/qml/CMakeLists.txt b/src/qml/CMakeLists.txt
index 3ad404a33a..12cc827f57 100644
--- a/src/qml/CMakeLists.txt
+++ b/src/qml/CMakeLists.txt
@@ -230,7 +230,7 @@ qt_internal_add_qml_module(Qml
parser/qqmljsast.cpp parser/qqmljsast_p.h
parser/qqmljsastfwd_p.h
parser/qqmljsastvisitor.cpp parser/qqmljsastvisitor_p.h
- parser/qqmljsengine_p.cpp parser/qqmljsengine_p.h
+ parser/qqmljsengine_p.h
parser/qqmljsglobal_p.h
parser/qqmljskeywords_p.h
parser/qqmljslexer.cpp parser/qqmljslexer_p.h
diff --git a/src/qml/parser/qqmljsengine_p.cpp b/src/qml/parser/qqmljsengine_p.cpp
deleted file mode 100644
index 53ad8820dd..0000000000
--- a/src/qml/parser/qqmljsengine_p.cpp
+++ /dev/null
@@ -1,157 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qqmljsengine_p.h"
-#include "qqmljsglobal_p.h"
-
-#include <QtCore/private/qnumeric_p.h>
-#include <QtCore/qhash.h>
-#include <QtCore/qdebug.h>
-
-QT_BEGIN_NAMESPACE
-
-namespace QQmlJS {
-
-static inline int toDigit(char c)
-{
- if ((c >= '0') && (c <= '9'))
- return c - '0';
- else if ((c >= 'a') && (c <= 'z'))
- return 10 + c - 'a';
- else if ((c >= 'A') && (c <= 'Z'))
- return 10 + c - 'A';
- return -1;
-}
-
-double integerFromString(const char *buf, int size, int radix)
-{
- if (size == 0)
- return qt_qnan();
-
- double sign = 1.0;
- int i = 0;
- if (buf[0] == '+') {
- ++i;
- } else if (buf[0] == '-') {
- sign = -1.0;
- ++i;
- }
-
- if (((size-i) >= 2) && (buf[i] == '0')) {
- if (((buf[i+1] == 'x') || (buf[i+1] == 'X'))
- && (radix < 34)) {
- if ((radix != 0) && (radix != 16))
- return 0;
- radix = 16;
- i += 2;
- } else {
- if (radix == 0) {
- radix = 8;
- ++i;
- }
- }
- } else if (radix == 0) {
- radix = 10;
- }
-
- int j = i;
- for ( ; i < size; ++i) {
- int d = toDigit(buf[i]);
- if ((d == -1) || (d >= radix))
- break;
- }
- double result;
- if (j == i) {
- if (!qstrcmp(buf, "Infinity"))
- result = qInf();
- else
- result = qt_qnan();
- } else {
- result = 0;
- double multiplier = 1;
- for (--i ; i >= j; --i, multiplier *= radix)
- result += toDigit(buf[i]) * multiplier;
- }
- result *= sign;
- return result;
-}
-
-Engine::Engine()
- : _lexer(nullptr), _directives(nullptr)
-{ }
-
-Engine::~Engine()
-{ }
-
-void Engine::setCode(const QString &code)
-{ _code = code; }
-
-void Engine::addComment(int pos, int len, int line, int col)
-{ if (len > 0) _comments.append(QQmlJS::SourceLocation(pos, len, line, col)); }
-
-QList<QQmlJS::SourceLocation> Engine::comments() const
-{ return _comments; }
-
-Lexer *Engine::lexer() const
-{ return _lexer; }
-
-void Engine::setLexer(Lexer *lexer)
-{ _lexer = lexer; }
-
-Directives *Engine::directives() const
-{ return _directives; }
-
-void Engine::setDirectives(Directives *directives)
-{ _directives = directives; }
-
-MemoryPool *Engine::pool()
-{ return &_pool; }
-
-QStringView Engine::newStringRef(const QString &text)
-{
- _extraCode.append(text);
- return QStringView{_extraCode.last()};
-}
-
-QStringView Engine::newStringRef(const QChar *chars, int size)
-{ return newStringRef(QString(chars, size)); }
-
-} // end of namespace QQmlJS
-
-QT_END_NAMESPACE
diff --git a/src/qml/parser/qqmljsengine_p.h b/src/qml/parser/qqmljsengine_p.h
index b57515982b..726b1bbcbd 100644
--- a/src/qml/parser/qqmljsengine_p.h
+++ b/src/qml/parser/qqmljsengine_p.h
@@ -92,40 +92,52 @@ public:
}
};
-class QML_PARSER_EXPORT Engine
+class Engine
{
- Lexer *_lexer;
- Directives *_directives;
+ Lexer *_lexer = nullptr;
+ Directives *_directives = nullptr;
MemoryPool _pool;
QList<SourceLocation> _comments;
QStringList _extraCode;
QString _code;
public:
- Engine();
- ~Engine();
-
- void setCode(const QString &code);
+ void setCode(const QString &code) { _code = code; }
const QString &code() const { return _code; }
- void addComment(int pos, int len, int line, int col);
- QList<SourceLocation> comments() const;
+ void addComment(int pos, int len, int line, int col)
+ {
+ if (len > 0)
+ _comments.append(QQmlJS::SourceLocation(pos, len, line, col));
+ }
- Lexer *lexer() const;
- void setLexer(Lexer *lexer);
+ QList<SourceLocation> comments() const { return _comments; }
- Directives *directives() const;
- void setDirectives(Directives *directives);
+ Lexer *lexer() const { return _lexer; }
+ void setLexer(Lexer *lexer) { _lexer = lexer; }
- MemoryPool *pool();
+ Directives *directives() const { return _directives; }
+ void setDirectives(Directives *directives) { _directives = directives; }
- inline QStringView midRef(int position, int size) { return QStringView{_code}.mid(position, size); }
+ MemoryPool *pool() { return &_pool; }
+ const MemoryPool *pool() const { return &_pool; }
- QStringView newStringRef(const QString &s);
- QStringView newStringRef(const QChar *chars, int size);
-};
+ QStringView midRef(int position, int size)
+ {
+ return QStringView{_code}.mid(position, size);
+ }
-double integerFromString(const char *buf, int size, int radix);
+ QStringView newStringRef(const QString &text)
+ {
+ _extraCode.append(text);
+ return QStringView{_extraCode.last()};
+ }
+
+ QStringView newStringRef(const QChar *chars, int size)
+ {
+ return newStringRef(QString(chars, size));
+ }
+};
} // end of namespace QQmlJS