wasm: rename JsString -> EcmaString

QString::fromJsString -> QString::fromEcmaString()
QString::toJsString() -> QString::toEcmaString()

For API naming compatibility with QByteArray::fromEcmaUin8Array()

Pick-to: 6.6
Change-Id: If6e2121e31e630d6728ed24e41d14b763f395aaa
Reviewed-by: Piotr Wierciński <piotr.wiercinski@qt.io>
Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io>
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
This commit is contained in:
Morten Sørvig 2023-08-25 00:37:25 +02:00
parent 9900a12df6
commit c802a9e987
8 changed files with 19 additions and 19 deletions

View File

@ -49,9 +49,9 @@ emscripten::val QRectF::toDOMRect() const
\since 6.6
\ingroup platform-type-conversions
\sa toJsString()
\sa toEcmaString()
*/
QString QString::fromJsString(emscripten::val jsString)
QString QString::fromEcmaString(emscripten::val jsString)
{
Q_ASSERT_X(jsString.isString(), Q_FUNC_INFO, "Passed object is not a string");
@ -86,9 +86,9 @@ QString QString::fromJsString(emscripten::val jsString)
\since 6.6
\ingroup platform-type-conversions
\sa fromJsString()
\sa fromEcmaString()
*/
emscripten::val QString::toJsString() const
emscripten::val QString::toEcmaString() const
{
static const emscripten::val UTF16ToString(emscripten::val::module_property("UTF16ToString"));
return UTF16ToString(emscripten::val(quintptr(utf16())));

View File

@ -440,7 +440,7 @@ private:
break;
}
QString a;
const QString data = QString::fromJsString(webDataTransfer.call<emscripten::val>(
const QString data = QString::fromEcmaString(webDataTransfer.call<emscripten::val>(
"getData", emscripten::val(itemMimeType.toStdString())));
if (!data.isEmpty()) {

View File

@ -893,8 +893,8 @@ public:
#endif
#if defined(Q_OS_WASM) || defined(Q_QDOC)
static QString fromJsString(emscripten::val jsString);
emscripten::val toJsString() const;
static QString fromEcmaString(emscripten::val jsString);
emscripten::val toEcmaString() const;
#endif
inline bool isNull() const { return d->isNull(); }

View File

@ -27,10 +27,10 @@ static void commonCopyEvent(val event)
// doing it this way seems to sanitize the text better that calling data() like down below
if (_mimes->hasText()) {
event["clipboardData"].call<void>("setData", val("text/plain"),
_mimes->text().toJsString());
_mimes->text().toEcmaString());
}
if (_mimes->hasHtml()) {
event["clipboardData"].call<void>("setData", val("text/html"), _mimes->html().toJsString());
event["clipboardData"].call<void>("setData", val("text/html"), _mimes->html().toEcmaString());
}
for (auto mimetype : _mimes->formats()) {
@ -38,7 +38,7 @@ static void commonCopyEvent(val event)
continue;
QByteArray ba = _mimes->data(mimetype);
if (!ba.isEmpty())
event["clipboardData"].call<void>("setData", mimetype.toJsString(),
event["clipboardData"].call<void>("setData", mimetype.toEcmaString(),
val(ba.constData()));
}
@ -261,12 +261,12 @@ void QWasmClipboard::writeToClipboardApi()
// we have a blob, now create a ClipboardItem
emscripten::val type = emscripten::val::array();
type.set("type", mimetype.toJsString());
type.set("type", mimetype.toEcmaString());
emscripten::val contentBlob = emscripten::val::global("Blob").new_(contentArray, type);
emscripten::val clipboardItemObject = emscripten::val::object();
clipboardItemObject.set(mimetype.toJsString(), contentBlob);
clipboardItemObject.set(mimetype.toEcmaString(), contentBlob);
val clipboardItemData = val::global("ClipboardItem").new_(clipboardItemObject);

View File

@ -373,7 +373,7 @@ void QWasmIntegration::resizeScreen(const emscripten::val &element)
[&] (const ScreenMapping &candidate) { return candidate.emscriptenVal.equals(element); });
if (it == m_screens.end()) {
qWarning() << "Attempting to resize non-existing screen for element"
<< QString::fromJsString(element["id"]);
<< QString::fromEcmaString(element["id"]);
return;
}
it->wasmScreen->updateQScreenAndCanvasRenderSize();

View File

@ -182,7 +182,7 @@ qreal QWasmScreen::devicePixelRatio() const
QString QWasmScreen::name() const
{
return QString::fromJsString(m_shadowContainer["id"]);
return QString::fromEcmaString(m_shadowContainer["id"]);
}
QPlatformCursor *QWasmScreen::cursor() const

View File

@ -12,7 +12,7 @@ QT_BEGIN_NAMESPACE
bool QWasmServices::openUrl(const QUrl &url)
{
emscripten::val::global("window").call<void>("open", url.toString().toJsString(),
emscripten::val::global("window").call<void>("open", url.toString().toEcmaString(),
emscripten::val("_blank"));
return true;
}

View File

@ -12,18 +12,18 @@ void tst_QString_wasmTypes()
// QString <-> emscripten::val
{
QString qtString = testString;
const emscripten::val jsString = qtString.toJsString();
const emscripten::val jsString = qtString.toEcmaString();
QString qtStringCopy(qtString);
qtString = qtString.toUpper(); // modify
QCOMPARE(QString::fromJsString(jsString), qtStringCopy);
QCOMPARE(QString::fromEcmaString(jsString), qtStringCopy);
}
{
QString longString;
for (uint64_t i = 0; i < 1000; ++i)
longString += testString;
const emscripten::val jsString = longString.toJsString();
const emscripten::val jsString = longString.toEcmaString();
QString qtStringCopy(longString);
longString = longString.toUpper(); // modify
QCOMPARE(QString::fromJsString(jsString), qtStringCopy);
QCOMPARE(QString::fromEcmaString(jsString), qtStringCopy);
}
}