1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
4 | ** Contact: https://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the QtQml module of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:LGPL$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at https://www.qt.io/contact-us. |
16 | ** |
17 | ** GNU Lesser General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
19 | ** General Public License version 3 as published by the Free Software |
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the |
21 | ** packaging of this file. Please review the following information to |
22 | ** ensure the GNU Lesser General Public License version 3 requirements |
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. |
24 | ** |
25 | ** GNU General Public License Usage |
26 | ** Alternatively, this file may be used under the terms of the GNU |
27 | ** General Public License version 2.0 or (at your option) the GNU General |
28 | ** Public license version 3 or any later version approved by the KDE Free |
29 | ** Qt Foundation. The licenses are as published by the Free Software |
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 |
31 | ** included in the packaging of this file. Please review the following |
32 | ** information to ensure the GNU General Public License requirements will |
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and |
34 | ** https://www.gnu.org/licenses/gpl-3.0.html. |
35 | ** |
36 | ** $QT_END_LICENSE$ |
37 | ** |
38 | ****************************************************************************/ |
39 | |
40 | #ifndef QQMLBUILTINFUNCTIONS_P_H |
41 | #define QQMLBUILTINFUNCTIONS_P_H |
42 | |
43 | // |
44 | // W A R N I N G |
45 | // ------------- |
46 | // |
47 | // This file is not part of the Qt API. It exists purely as an |
48 | // implementation detail. This header file may change from version to |
49 | // version without notice, or even be removed. |
50 | // |
51 | // We mean it. |
52 | // |
53 | |
54 | #include <private/qqmlglobal_p.h> |
55 | #include <private/qv4functionobject_p.h> |
56 | #include <private/qjsengine_p.h> |
57 | |
58 | QT_BEGIN_NAMESPACE |
59 | |
60 | class QQmlEngine; |
61 | |
62 | namespace QV4 { |
63 | |
64 | namespace Heap { |
65 | |
66 | struct QtObject : Object { |
67 | void init(QQmlEngine *qmlEngine); |
68 | QObject *platform; |
69 | QObject *application; |
70 | |
71 | enum { Finished = -1 }; |
72 | int enumeratorIterator; |
73 | int keyIterator; |
74 | |
75 | bool isComplete() const |
76 | { return enumeratorIterator == Finished; } |
77 | }; |
78 | |
79 | struct ConsoleObject : Object { |
80 | void init(); |
81 | }; |
82 | |
83 | #define QQmlBindingFunctionMembers(class, Member) \ |
84 | Member(class, Pointer, FunctionObject *, bindingFunction) |
85 | DECLARE_HEAP_OBJECT(QQmlBindingFunction, FunctionObject) { |
86 | DECLARE_MARKOBJECTS(QQmlBindingFunction) |
87 | void init(const QV4::FunctionObject *bindingFunction); |
88 | }; |
89 | |
90 | } |
91 | |
92 | struct QtObject : Object |
93 | { |
94 | V4_OBJECT2(QtObject, Object) |
95 | |
96 | static ReturnedValue virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty); |
97 | static OwnPropertyKeyIterator *virtualOwnPropertyKeys(const Object *m, Value *target); |
98 | |
99 | static ReturnedValue method_isQtObject(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); |
100 | static ReturnedValue method_rgba(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); |
101 | static ReturnedValue method_hsla(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); |
102 | static ReturnedValue method_hsva(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); |
103 | static ReturnedValue method_colorEqual(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); |
104 | static ReturnedValue method_font(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); |
105 | static ReturnedValue method_rect(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); |
106 | static ReturnedValue method_point(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); |
107 | static ReturnedValue method_size(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); |
108 | static ReturnedValue method_vector2d(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); |
109 | static ReturnedValue method_vector3d(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); |
110 | static ReturnedValue method_vector4d(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); |
111 | static ReturnedValue method_quaternion(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); |
112 | static ReturnedValue method_matrix4x4(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); |
113 | static ReturnedValue method_lighter(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); |
114 | static ReturnedValue method_darker(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); |
115 | static ReturnedValue method_tint(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); |
116 | static ReturnedValue method_formatDate(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); |
117 | static ReturnedValue method_formatTime(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); |
118 | static ReturnedValue method_formatDateTime(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); |
119 | static ReturnedValue method_openUrlExternally(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); |
120 | static ReturnedValue method_fontFamilies(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); |
121 | static ReturnedValue method_md5(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); |
122 | static ReturnedValue method_btoa(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); |
123 | static ReturnedValue method_atob(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); |
124 | static ReturnedValue method_quit(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); |
125 | static ReturnedValue method_exit(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); |
126 | static ReturnedValue method_resolvedUrl(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); |
127 | static ReturnedValue method_createQmlObject(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); |
128 | static ReturnedValue method_createComponent(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); |
129 | static ReturnedValue method_get_uiLanguage(const FunctionObject *b, const Value *, const Value *, int); |
130 | static ReturnedValue method_set_uiLanguage(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); |
131 | #if QT_CONFIG(qml_locale) |
132 | static ReturnedValue method_locale(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); |
133 | #endif |
134 | static ReturnedValue method_binding(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); |
135 | |
136 | static ReturnedValue method_get_platform(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); |
137 | static ReturnedValue method_get_application(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); |
138 | static ReturnedValue method_get_inputMethod(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); |
139 | static ReturnedValue method_get_styleHints(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); |
140 | |
141 | static ReturnedValue method_callLater(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); |
142 | |
143 | private: |
144 | void addAll(); |
145 | ReturnedValue findAndAdd(const QString *name, bool &foundProperty) const; |
146 | }; |
147 | |
148 | struct ConsoleObject : Object |
149 | { |
150 | V4_OBJECT2(ConsoleObject, Object) |
151 | |
152 | static ReturnedValue method_error(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); |
153 | static ReturnedValue method_log(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); |
154 | static ReturnedValue method_info(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); |
155 | static ReturnedValue method_profile(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); |
156 | static ReturnedValue method_profileEnd(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); |
157 | static ReturnedValue method_time(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); |
158 | static ReturnedValue method_timeEnd(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); |
159 | static ReturnedValue method_count(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); |
160 | static ReturnedValue method_trace(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); |
161 | static ReturnedValue method_warn(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); |
162 | static ReturnedValue method_assert(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); |
163 | static ReturnedValue method_exception(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); |
164 | |
165 | }; |
166 | |
167 | struct Q_QML_PRIVATE_EXPORT GlobalExtensions { |
168 | static void init(Object *globalObject, QJSEngine::Extensions extensions); |
169 | |
170 | #if QT_CONFIG(translation) |
171 | static ReturnedValue method_qsTranslate(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); |
172 | static ReturnedValue method_qsTranslateNoOp(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); |
173 | static ReturnedValue method_qsTr(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); |
174 | static ReturnedValue method_qsTrNoOp(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); |
175 | static ReturnedValue method_qsTrId(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); |
176 | static ReturnedValue method_qsTrIdNoOp(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); |
177 | #endif |
178 | static ReturnedValue method_gc(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); |
179 | |
180 | // on String:prototype |
181 | static ReturnedValue method_string_arg(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); |
182 | |
183 | }; |
184 | |
185 | struct QQmlBindingFunction : public QV4::FunctionObject |
186 | { |
187 | V4_OBJECT2(QQmlBindingFunction, FunctionObject) |
188 | |
189 | Heap::FunctionObject *bindingFunction() const { return d()->bindingFunction; } |
190 | QQmlSourceLocation currentLocation() const; // from caller stack trace |
191 | }; |
192 | |
193 | inline bool FunctionObject::isBinding() const |
194 | { |
195 | return d()->vtable() == QQmlBindingFunction::staticVTable(); |
196 | } |
197 | |
198 | } |
199 | |
200 | QT_END_NAMESPACE |
201 | |
202 | #endif // QQMLBUILTINFUNCTIONS_P_H |
203 | |