4#include <QtCore/qrect.h>
6#include <emscripten/val.h>
9#error This is a wasm-only file.
15
16
17
18
19
20
21
22
23QRectF QRectF::fromDOMRect(emscripten::val domRect)
25 Q_ASSERT_X(domRect[
"constructor"][
"name"].as<std::string>() ==
"DOMRect", Q_FUNC_INFO,
26 "Passed object is not a DOMRect");
28 return QRectF(domRect[
"left"].as<qreal>(), domRect[
"top"].as<qreal>(),
29 domRect[
"width"].as<qreal>(), domRect[
"height"].as<qreal>());
33
34
35
36
37
38
39
40emscripten::val QRectF::toDOMRect()
const
42 return emscripten::val::global(
"DOMRect").new_(left(), top(), width(), height());
46
47
48
49
50
51
52
53
54QString QString::fromEcmaString(emscripten::val jsString)
56 Q_ASSERT_X(jsString.isString(), Q_FUNC_INFO,
"Passed object is not a string");
59 return QString::fromStdU16String(jsString.as<std::u16string>());
62 const double length = jsString[
"length"].as<
double>();
64 Q_ASSERT_X((
double(uint64_t(length)) !=
double(uint64_t(length) - 1)
65 &&
double(uint64_t(length)) !=
double(uint64_t(length) + 1))
66 || !std::numeric_limits<
double>::is_iec559,
67 Q_FUNC_INFO,
"The floating-point length cannot precisely represent an integer");
69 constexpr int zeroTerminatorLength = 1;
70 const auto lengthOfUtf16 = (length + zeroTerminatorLength) * 2;
72 Q_ASSERT_X((
double(uint64_t(lengthOfUtf16)) !=
double(uint64_t(lengthOfUtf16) - 1)
73 &&
double(uint64_t(lengthOfUtf16)) !=
double(uint64_t(lengthOfUtf16) + 1))
74 || !std::numeric_limits<
double>::is_iec559,
76 "The floating-point lengthOfUtf16 cannot precisely represent an integer");
78 const QString result(uint64_t(length), Qt::Uninitialized);
80 static const emscripten::val stringToUTF16(emscripten::val::module_property(
"stringToUTF16"));
81 stringToUTF16(jsString, emscripten::val(quintptr(result.data())),
82 emscripten::val(lengthOfUtf16));
87
88
89
90
91
92
93
94
95emscripten::val QString::toEcmaString()
const
98 return emscripten::val::u16string(toStdU16String().c_str());
100 static const emscripten::val UTF16ToString(emscripten::val::module_property(
"UTF16ToString"));
101 return UTF16ToString(emscripten::val(quintptr(utf16())));
\inmodule QtCore\reentrant