Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qv4runtime_p.h
Go to the documentation of this file.
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 QMLJS_RUNTIME_H
4#define QMLJS_RUNTIME_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 "qv4global_p.h"
18#include "qv4value_p.h"
19#include "qv4runtimeapi_p.h"
20#include <QtCore/qnumeric.h>
21
23
24#undef QV4_COUNT_RUNTIME_FUNCTIONS
25
26namespace QV4 {
27
28#ifdef QV4_COUNT_RUNTIME_FUNCTIONS
29class RuntimeCounters
30{
31public:
32 RuntimeCounters();
33 ~RuntimeCounters();
34
35 static RuntimeCounters *instance;
36
37 void count(const char *func);
38 void count(const char *func, uint tag);
39 void count(const char *func, uint tag1, uint tag2);
40
41private:
42 struct Data;
43 Data *d;
44};
45
46# define TRACE0() RuntimeCounters::instance->count(Q_FUNC_INFO);
47# define TRACE1(x) RuntimeCounters::instance->count(Q_FUNC_INFO, x.type());
48# define TRACE2(x, y) RuntimeCounters::instance->count(Q_FUNC_INFO, x.type(), y.type());
49#else
50# define TRACE0()
51# define TRACE1(x)
52# define TRACE2(x, y)
53#endif // QV4_COUNT_RUNTIME_FUNCTIONS
54
60
61struct Q_QML_EXPORT RuntimeHelpers {
62 static ReturnedValue objectDefaultValue(const Object *object, int typeHint);
63 static ReturnedValue toPrimitive(const Value &value, TypeHint typeHint);
64 static ReturnedValue ordinaryToPrimitive(ExecutionEngine *engine, const Object *object, String *typeHint);
65
66 static double stringToNumber(const QString &s);
67 static Heap::String *stringFromNumber(ExecutionEngine *engine, double number);
68 static double toNumber(const Value &value);
69 static void numberToString(QString *result, double num, int radix = 10);
70
72 static Heap::Object *convertToObject(ExecutionEngine *engine, const Value &value);
73
74 static Bool equalHelper(const Value &x, const Value &y);
75 static Bool strictEqual(const Value &x, const Value &y);
76
77 static ReturnedValue addHelper(ExecutionEngine *engine, const Value &left, const Value &right);
78};
79
80
81// type conversion and testing
83{
84 if (!value.isObject())
85 return value.asReturnedValue();
86 return RuntimeHelpers::objectDefaultValue(&reinterpret_cast<const Object &>(value), typeHint);
87}
88
90{
91 return value.toNumber();
92}
93} // namespace QV4
94
96
97#endif // QMLJS_RUNTIME_H
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
Combined button and popup list for selecting options.
@ STRING_HINT
@ PREFERREDTYPE_HINT
@ NUMBER_HINT
quint64 ReturnedValue
uint Bool
AudioChannelLayoutTag tag
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLint GLint GLint GLint GLint x
[0]
GLenum GLenum GLsizei count
GLdouble GLdouble right
GLint left
GLint y
GLdouble s
[6]
Definition qopenglext.h:235
GLenum func
Definition qopenglext.h:663
GLuint64EXT * result
[6]
GLuint num
unsigned int uint
Definition qtypes.h:34
QJSEngine engine
[0]
static ReturnedValue objectDefaultValue(const Object *object, int typeHint)
static ReturnedValue toPrimitive(const Value &value, TypeHint typeHint)
static double toNumber(const Value &value)