Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qv4propertykey.cpp
Go to the documentation of this file.
1
// Copyright (C) 2018 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
// Qt-Security score:significant
4
5
#
include
"qv4propertykey_p.h"
6
7
#
include
<
QtCore
/
qstring
.
h
>
8
#
include
<
qv4string_p
.
h
>
9
#
include
<
qv4engine_p
.
h
>
10
#
include
<
qv4scopedvalue_p
.
h
>
11
#
include
<
private
/
qv4mm_p
.
h
>
12
13
using
namespace
Qt::Literals::StringLiterals;
14
15
QV4
::
Heap
::StringOrSymbol *
QV4
::
PropertyKey
::
toStringOrSymbol
(
QV4
::ExecutionEngine *e)
16
{
17
if
(isArrayIndex())
18
return
Value::fromUInt32(asArrayIndex()).toString(e);
19
return
asStringOrSymbol();
20
}
21
22
bool
QV4
::
PropertyKey
::
isString
()
const
{
23
Heap
::StringOrSymbol *s = asStringOrSymbol();
24
return
s && s->internalClass->vtable->isString;
25
}
26
27
bool
QV4
::
PropertyKey
::
isSymbol
()
const
{
28
Heap
::StringOrSymbol *s = asStringOrSymbol();
29
return
s && !s->internalClass->vtable->isString && s->internalClass->vtable->isStringOrSymbol;
30
}
31
32
bool
QV4
::
PropertyKey
::
isCanonicalNumericIndexString
()
const
33
{
34
if
(
isArrayIndex
(
)
)
35
return
true
;
36
if
(isSymbol())
37
return
false
;
38
Heap
::String *s =
static_cast
<
Heap
::String *>(asStringOrSymbol());
39
Scope
scope(s->internalClass->engine);
40
ScopedString
str(scope, s);
41
double
d = str->toNumber();
42
if
(d == 0. &&
std
::signbit(d))
43
return
true
;
44
ScopedString
converted(scope, Value::fromDouble(d).toString(scope.engine));
45
if
(converted->equals(str))
46
return
true
;
47
return
false
;
48
}
49
50
QString
QV4
::
PropertyKey
::toQString()
const
51
{
52
if
(isArrayIndex())
53
return
QString::number(asArrayIndex());
54
Heap
::StringOrSymbol *s = asStringOrSymbol();
55
Q_ASSERT(s->internalClass->vtable->isStringOrSymbol);
56
return
s->toQString();
57
}
58
59
QV4
::
Heap
::String *
QV4
::
PropertyKey
::
asFunctionName
(ExecutionEngine *engine,
FunctionNamePrefix
prefix)
const
60
{
61
QString n;
62
if
(prefix ==
Getter
)
63
n +=
"get "_L1
;
64
else
if
(prefix ==
Setter
)
65
n +=
"set "_L1
;
66
if
(
isArrayIndex
(
)
)
67
n += QString::number(asArrayIndex());
68
else
{
69
Heap
::StringOrSymbol *s = asStringOrSymbol();
70
QString str = s->toQString();
71
if
(s->internalClass->vtable->isString)
72
n += s->toQString();
73
else
if
(str.size() > 1)
74
n += QChar::fromLatin1(
'['
) + QStringView{str}.mid(1) + QChar::fromLatin1(
']'
);
75
}
76
return
engine->newString(n);
77
}
QV4::Heap
Definition
qv4compileddata_p.h:76
QV4
Definition
qjsvalue.h:24
QV4::ScopedString
Scoped< String > ScopedString
Definition
qv4global_p.h:164
std
[33]
Definition
src_corelib_tools_qhash.cpp:421
QV4::PropertyKey
Definition
qv4propertykey_p.h:30
QV4::PropertyKey::isArrayIndex
bool isArrayIndex() const
Definition
qv4propertykey_p.h:69
QV4::PropertyKey::toStringOrSymbol
Heap::StringOrSymbol * toStringOrSymbol(ExecutionEngine *e)
Definition
qv4propertykey.cpp:15
QV4::PropertyKey::isCanonicalNumericIndexString
bool isCanonicalNumericIndexString() const
Definition
qv4propertykey.cpp:32
QV4::PropertyKey::isSymbol
Q_QML_EXPORT bool isSymbol() const
Definition
qv4propertykey.cpp:27
QV4::PropertyKey::isString
Q_QML_EXPORT bool isString() const
Definition
qv4propertykey.cpp:22
QV4::PropertyKey::FunctionNamePrefix
FunctionNamePrefix
Definition
qv4propertykey_p.h:112
QV4::PropertyKey::Setter
@ Setter
Definition
qv4propertykey_p.h:115
QV4::PropertyKey::Getter
@ Getter
Definition
qv4propertykey_p.h:114
QV4::PropertyKey::asFunctionName
Heap::String * asFunctionName(ExecutionEngine *e, FunctionNamePrefix prefix) const
Definition
qv4propertykey.cpp:59
QV4::Scope
Definition
qv4scopedvalue_p.h:61
qtdeclarative
src
qml
jsruntime
qv4propertykey.cpp
Generated on
for Qt by
1.18.0