aboutsummaryrefslogtreecommitdiff
path: root/include/cru/platform/web/Js.h
blob: b4c917029ecc9b02ec7bea570b75f218ec22b745 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#pragma once

#include <emscripten/val.h>
#include <utility>

namespace cru::platform::web::js {
bool IsNotNullAndInstanceOf(const emscripten::val& value,
                            const emscripten::val& type);
bool IsNotNullAndInstanceOf(const emscripten::val& value,
                            const char* global_type);

template <typename... Args>
emscripten::val Construct(const char* class_name, Args&&... args) {
  emscripten::val constructor = emscripten::val::global(class_name);
  return constructor.new_(std::forward<Args>(args)...);
}
}  // namespace cru::platform::web