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