1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
|
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "qqmlsasourcelocation.h"
#include "qqmlsasourcelocation_p.h"
QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
namespace QQmlSA {
static_assert(SourceLocationPrivate::sizeOfSourceLocation() == sizeof(SourceLocation));
/*!
\class QQmlSA::SourceLocation
\inmodule QtQmlCompiler
\brief Represents a location or region in the source code.
*/
/*!
Constructs a new SourceLocation with values given by \a offset, \a length,
\a line, and \a column.
*/
QQmlSA::SourceLocation::SourceLocation(quint32 offset, quint32 length, quint32 line, quint32 column)
{
new (m_data) QQmlJS::SourceLocation{ offset, length, line, column };
}
// explicitly defaulted out-of-line for PIMPL
/*!
Creates a copy of \a other.
*/
QQmlSA::SourceLocation::SourceLocation(const SourceLocation &other) = default;
/*!
\fn SourceLocation::SourceLocation(SourceLocation &&other) noexcept
Move-Constructs a SourceLocation from \a other.
*/
/*!
Assigns \a other to this SourceLocation.
*/
QQmlSA::SourceLocation & QQmlSA::SourceLocation::operator=(const QQmlSA::SourceLocation &other) = default;
/*!
\fn SourceLocation &SourceLocation::operator=(SourceLocation &&other) noexcept
Move-assigns \a other to this SourceLocation.
*/
/*!
Destructs this SourceLocation instance.
*/
SourceLocation::~SourceLocation() = default;
/*!
Returns \c true is this SourceLocation is valid, \c false otherwise.
*/
bool QQmlSA::SourceLocation::isValid() const
{
return QQmlSA::SourceLocationPrivate::sourceLocation(*this).isValid();
}
/*!
Returns the offset of the beginning of this source location.
*/
quint32 QQmlSA::SourceLocation::begin() const
{
return offset();
}
/*!
Returns the offset of the end of this source location.
*/
quint32 QQmlSA::SourceLocation::end() const
{
return offset() + length();
}
/*!
Returns the offset of the beginning of this source location.
*/
quint32 QQmlSA::SourceLocation::offset() const
{
return QQmlSA::SourceLocationPrivate::sourceLocation(*this).offset;
}
/*!
Returns the length of this source location.
*/
quint32 QQmlSA::SourceLocation::length() const
{
return QQmlSA::SourceLocationPrivate::sourceLocation(*this).length;
}
/*!
Returns the line number containing the beginning of this source location.
*/
quint32 QQmlSA::SourceLocation::startLine() const
{
return QQmlSA::SourceLocationPrivate::sourceLocation(*this).startLine;
}
/*!
Returns the column number containing the beginning of this source location.
*/
quint32 QQmlSA::SourceLocation::startColumn() const
{
return QQmlSA::SourceLocationPrivate::sourceLocation(*this).startColumn;
}
/*!
Returns a source location of lenth zero pointing to the beginning of this
source location.
*/
QQmlSA::SourceLocation QQmlSA::SourceLocation::startZeroLengthLocation() const
{
QQmlSA::SourceLocation saLocation;
auto &wrappedLocation = reinterpret_cast<QQmlJS::SourceLocation &>(saLocation.m_data);
wrappedLocation =
QQmlSA::SourceLocationPrivate::sourceLocation(*this).startZeroLengthLocation();
return saLocation;
}
/*!
Returns a source location of lenth zero pointing to the end of this source
location pointing to \a text.
*/
QQmlSA::SourceLocation QQmlSA::SourceLocation::endZeroLengthLocation(QStringView text) const
{
QQmlSA::SourceLocation saLocation;
auto &wrappedLocation = reinterpret_cast<QQmlJS::SourceLocation &>(saLocation.m_data);
wrappedLocation = wrappedLocation.endZeroLengthLocation(text);
return saLocation;
}
/*!
\fn friend qsizetype SourceLocation::qHash(const SourceLocation &location, qsizetype seed)
Returns the hash value for \a location, using \a seed to seed the calculation.
*/
/*!
\fn friend bool SourceLocation::operator==(const SourceLocation &lhs, const SourceLocation &rhs)
Returns true if \a lhs equals \a rhs, and \c false otherwise.
Two SourceLocations are considered equal if they have the same values for
their offset, length, line, and column members.
*/
/*!
\fn friend bool SourceLocation::operator!=(const SourceLocation &lhs, const SourceLocation &rhs)
Returns true if \a lhs does not equal \a rhs, and \c false otherwise.
See \l {SourceLocation::operator==} for when two source locations are considered equal.
*/
qsizetype QQmlSA::SourceLocation::qHashImpl(const SourceLocation &location, qsizetype seed)
{
return qHash(QQmlSA::SourceLocationPrivate::sourceLocation(location), seed);
}
bool QQmlSA::SourceLocation::operatorEqualsImpl(const SourceLocation &lhs,
const SourceLocation &rhs)
{
return QQmlSA::SourceLocationPrivate::sourceLocation(lhs)
== QQmlSA::SourceLocationPrivate::sourceLocation(rhs);
}
} // namespace QQmlSA
QT_END_NAMESPACE
|