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 | |
20 | QT_BEGIN_NAMESPACE |
21 | |
22 | |
23 | namespace QV4 { |
24 | |
25 | namespace Heap { |
26 | |
27 | struct SymbolCtor : FunctionObject { |
28 | void init(QV4::ExecutionContext *scope); |
29 | }; |
30 | |
31 | struct Symbol : StringOrSymbol { |
32 | void init(const QString &s); |
33 | }; |
34 | |
35 | #define SymbolObjectMembers(class, Member) \ |
36 | Member(class, Pointer, Symbol *, symbol) |
37 | |
38 | DECLARE_HEAP_OBJECT(SymbolObject, Object) { |
39 | DECLARE_MARKOBJECTS(SymbolObject) |
40 | void init(const QV4::Symbol *s); |
41 | }; |
42 | |
43 | } |
44 | |
45 | struct 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 | |
55 | struct 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 | |
66 | struct 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 | |
78 | struct 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 | |
88 | QT_END_NAMESPACE |
89 | |
90 | #endif |
91 | |