diff options
author | crupest <crupest@outlook.com> | 2023-10-12 17:10:18 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2023-10-12 17:10:18 +0800 |
commit | 9a077caa6d3f7eb8255ae68916dccac9b50a4333 (patch) | |
tree | 486f5f01d5de8ff1b236029e1b955df1d70728a8 /include/cru/platform/web/Js.h | |
parent | 6fc14693d01f2be98b45d70405b16883607d4666 (diff) | |
download | cru-9a077caa6d3f7eb8255ae68916dccac9b50a4333.tar.gz cru-9a077caa6d3f7eb8255ae68916dccac9b50a4333.tar.bz2 cru-9a077caa6d3f7eb8255ae68916dccac9b50a4333.zip |
...
Diffstat (limited to 'include/cru/platform/web/Js.h')
-rw-r--r-- | include/cru/platform/web/Js.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/include/cru/platform/web/Js.h b/include/cru/platform/web/Js.h new file mode 100644 index 00000000..b4c91702 --- /dev/null +++ b/include/cru/platform/web/Js.h @@ -0,0 +1,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 |