Browser APIs

client.h

You can use browser APIs in genericjs code via the client namespace.

cheerp/clientlib.h

clientlib.h declares browser APIs and can be included with:

#include <cheerp/clientlib.h>

cheerp/client.h

client.h contains helpers like the SAFE_INLINE macro and utilities under the cheerp namespace.

#include <cheerp/client.h>

Promises and cheerp/coroutine.h

Promises can be awaited using coroutines.

For example:

#include <cheerp/coroutine.h>
#include <cheerp/client.h>
using namespace client;
[[cheerp::genericjs]]
[[cheerp::jsexport]]
Promise<String*>* randomUUID() {
Response* response = co_await *fetch("https://httpbin.org/uuid");
Object* json = (co_await *response->Body::json())->cast();
co_return (*json)["uuid"]->cast();
}

Any coroutine can be wrapped into a Promise using the following snippet:

Promise<Object*>* wrapper() {
co_return co_await coroutine();
}

Complex types

client.h also provides complex types like _Any, _Union, and _Function.

OpenGL ES

OpenGL ES is also supported with a different header.

Was this page helpful?
Suggest changes