1// Copyright (C) 2016 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 QV4STRINGOBJECT_P_H
4#define QV4STRINGOBJECT_P_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 "qv4object_p.h"
18#include "qv4functionobject_p.h"
19#include <QtCore/qnumeric.h>
20
21QT_BEGIN_NAMESPACE
22
23namespace QV4 {
24
25namespace Heap {
26
27#define StringObjectMembers(class, Member) \
28 Member(class, Pointer, String *, string)
29
30DECLARE_HEAP_OBJECT(StringObject, Object) {
31 DECLARE_MARKOBJECTS(StringObject)
32
33 enum {
34 LengthPropertyIndex = 0
35 };
36
37 void init(bool /*don't init*/)
38 { Object::init(); }
39 void init();
40 void init(const QV4::String *string);
41
42 Heap::String *getIndex(uint index) const;
43 uint length() const;
44};
45
46struct StringCtor : FunctionObject {
47 void init(QV4::ExecutionContext *scope);
48};
49
50}
51
52struct StringObject: Object {
53 V4_OBJECT2(StringObject, Object)
54 Q_MANAGED_TYPE(StringObject)
55 V4_INTERNALCLASS(StringObject)
56 V4_PROTOTYPE(stringPrototype)
57
58 Heap::String *getIndex(uint index) const {
59 return d()->getIndex(index);
60 }
61 uint length() const {
62 return d()->length();
63 }
64
65 using Object::getOwnProperty;
66protected:
67 static bool virtualDeleteProperty(Managed *m, PropertyKey id);
68 static OwnPropertyKeyIterator *virtualOwnPropertyKeys(const Object *m, Value *target);
69 static PropertyAttributes virtualGetOwnProperty(const Managed *m, PropertyKey id, Property *p);
70};
71
72struct StringCtor: FunctionObject
73{
74 V4_OBJECT2(StringCtor, FunctionObject)
75
76 static ReturnedValue virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *);
77 static ReturnedValue virtualCall(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
78
79 static ReturnedValue method_fromCharCode(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
80 static ReturnedValue method_fromCodePoint(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
81 static ReturnedValue method_raw(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
82};
83
84struct StringPrototype: StringObject
85{
86 V4_PROTOTYPE(objectPrototype)
87 void init(ExecutionEngine *engine, Object *ctor);
88
89 static ReturnedValue method_toString(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
90 static ReturnedValue method_charAt(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
91 static ReturnedValue method_charCodeAt(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
92 static ReturnedValue method_codePointAt(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
93 static ReturnedValue method_concat(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
94 static ReturnedValue method_endsWith(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
95 static ReturnedValue method_indexOf(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
96 static ReturnedValue method_includes(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
97 static ReturnedValue method_lastIndexOf(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
98 static ReturnedValue method_localeCompare(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
99 static ReturnedValue method_match(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
100 static ReturnedValue method_normalize(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
101 static ReturnedValue method_padEnd(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc);
102 static ReturnedValue method_padStart(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc);
103 static ReturnedValue method_repeat(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
104 static ReturnedValue method_replace(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
105 static ReturnedValue method_search(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
106 static ReturnedValue method_slice(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
107 static ReturnedValue method_split(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
108 static ReturnedValue method_startsWith(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
109 static ReturnedValue method_substr(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
110 static ReturnedValue method_substring(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
111 static ReturnedValue method_toLowerCase(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
112 static ReturnedValue method_toLocaleLowerCase(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
113 static ReturnedValue method_toUpperCase(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
114 static ReturnedValue method_toLocaleUpperCase(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
115 static ReturnedValue method_trim(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
116 static ReturnedValue method_iterator(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
117};
118
119}
120
121QT_END_NAMESPACE
122
123#endif // QV4ECMAOBJECTS_P_H
124

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