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#ifndef QV4_SYMBOL_H
4#define QV4_SYMBOL_H
5
6//
7// W A R N I N G
8// -------------
9//
10// This file is not part of the Qt API. It exists purely as an
11// implementation detail. This header file may change from version to
12// version without notice, or even be removed.
13//
14// We mean it.
15//
16
17#include "qv4string_p.h"
18#include "qv4functionobject_p.h"
19
20QT_BEGIN_NAMESPACE
21
22
23namespace QV4 {
24
25namespace Heap {
26
27struct SymbolCtor : FunctionObject {
28 void init(QV4::ExecutionContext *scope);
29};
30
31struct Symbol : StringOrSymbol {
32 void init(const QString &s);
33};
34
35#define SymbolObjectMembers(class, Member) \
36 Member(class, Pointer, Symbol *, symbol)
37
38DECLARE_HEAP_OBJECT(SymbolObject, Object) {
39 DECLARE_MARKOBJECTS(SymbolObject)
40 void init(const QV4::Symbol *s);
41};
42
43}
44
45struct SymbolCtor : FunctionObject
46{
47 V4_OBJECT2(SymbolCtor, FunctionObject)
48
49 static ReturnedValue virtualCall(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
50 static ReturnedValue virtualCallAsConstructor(const FunctionObject *, const Value *argv, int argc, const Value *newTarget);
51 static ReturnedValue method_for(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
52 static ReturnedValue method_keyFor(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
53};
54
55struct SymbolPrototype : Object
56{
57 V4_PROTOTYPE(objectPrototype)
58 void init(ExecutionEngine *engine, Object *ctor);
59
60 static ReturnedValue method_toString(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
61 static ReturnedValue method_valueOf(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
62
63 static ReturnedValue method_symbolToPrimitive(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
64};
65
66struct Symbol : StringOrSymbol
67{
68 V4_MANAGED(Symbol, StringOrSymbol)
69 Q_MANAGED_TYPE(Symbol)
70 V4_INTERNALCLASS(Symbol)
71 V4_NEEDS_DESTROY
72
73 static Heap::Symbol *create(ExecutionEngine *e, const QString &s);
74
75 QString descriptiveString() const;
76};
77
78struct SymbolObject : Object
79{
80 V4_OBJECT2(SymbolObject, Object)
81 Q_MANAGED_TYPE(SymbolObject)
82 V4_INTERNALCLASS(SymbolObject)
83 V4_PROTOTYPE(symbolPrototype)
84};
85
86}
87
88QT_END_NAMESPACE
89
90#endif
91

source code of qtdeclarative/src/qml/jsruntime/qv4symbol_p.h