4#ifndef QWASMSUSPENDRESUMECONTROL_P_H
5#define QWASMSUSPENDRESUMECONTROL_P_H
7#include <QtCore/qglobal.h>
8#include <emscripten/val.h>
27 QWasmSuspendResumeControl();
28 ~QWasmSuspendResumeControl();
30 QWasmSuspendResumeControl(
const QWasmSuspendResumeControl&) =
delete;
31 QWasmSuspendResumeControl& operator=(
const QWasmSuspendResumeControl&) =
delete;
33 static QWasmSuspendResumeControl *get();
35 uint32_t registerEventHandler(std::function<
void(emscripten::val)> handler);
36 void removeEventHandler(uint32_t index);
37 emscripten::val jsEventHandlerAt(uint32_t index);
38 static emscripten::val suspendResumeControlJs();
41 int sendPendingEvents();
44 friend void qtSendPendingEvents();
46 static QWasmSuspendResumeControl *s_suspendResumeControl;
47 std::map<
int, std::function<
void(emscripten::val)>> m_eventHandlers;
53 QWasmEventHandler() =
default;
54 QWasmEventHandler(emscripten::val element,
const std::string &name,
55 std::function<
void(emscripten::val)> fn);
57 QWasmEventHandler(QWasmEventHandler
const&) =
delete;
58 QWasmEventHandler& operator=(QWasmEventHandler
const&) =
delete;
59 QWasmEventHandler(QWasmEventHandler&& other)
noexcept;
60 QWasmEventHandler& operator=(QWasmEventHandler&& other)
noexcept;
62 emscripten::val m_element;
63 emscripten::val m_name;
64 uint32_t m_eventHandlerIndex = 0;
70 QWasmTimer(QWasmSuspendResumeControl* suspendResume,
std::function<
void()> handler);
79 QWasmSuspendResumeControl *m_suspendResume;
80 uint32_t m_handlerIndex;
81 uint64_t m_timerId = 0;
void setTimeout(std::chrono::milliseconds timeout)
QWasmTimer(QWasmSuspendResumeControl *suspendResume, std::function< void()> handler)
QWasmTimer(QWasmTimer const &)=delete
QWasmTimer & operator=(QWasmTimer const &)=delete
qint64 size() const override
For open random-access devices, this function returns the size of the device.
bool seek(qint64 pos) override
For random-access devices, this function sets the current position to pos, returning true on success,...
Uint8ArrayIODevice(Uint8Array array)
bool isSequential() const override
Returns true if this device is sequential; otherwise returns false.
qint64 writeData(const char *data, qint64 size) override
Writes up to maxSize bytes from data to the device.
bool open(QIODevice::OpenMode mode) override
qint64 readData(char *data, qint64 maxSize) override
Reads up to maxSize bytes from the device into data, and returns the number of bytes read or -1 if an...
void make(emscripten::val target, QString methodName, PromiseCallbacks callbacks, Args... args)
bool canBlockCallingThread()
const char makeContextfulPromiseFunctionName[]
static void usePotentialyUnusedSymbols()
decltype(auto) bindForever(F wrappedCallback)
std::function< void(emscripten::val)> thenFunc
std::function< void()> finallyFunc
std::function< void(emscripten::val)> catchFunc