MCPcopy Create free account
hub / github.com/BabylonJS/BabylonNative / CreateInstance

Method CreateInstance

Polyfills/Console/Source/Console.cpp:8–23  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6namespace Babylon::Polyfills::Internal
7{
8 void Console::CreateInstance(Napi::Env env, Babylon::Polyfills::Console::CallbackT callback)
9 {
10 Napi::HandleScope scope{env};
11
12 Napi::Function func = ParentT::DefineClass(
13 env,
14 "Console",
15 {
16 ParentT::InstanceMethod("log", &Console::Log),
17 ParentT::InstanceMethod("warn", &Console::Warn),
18 ParentT::InstanceMethod("error", &Console::Error),
19 });
20
21 Napi::Object console = func.New({Napi::External<Babylon::Polyfills::Console::CallbackT>::New(env, new Babylon::Polyfills::Console::CallbackT(std::move(callback)))});
22 env.Global().Set(JS_INSTANCE_NAME, console);
23 }
24
25 Console::Console(const Napi::CallbackInfo& info)
26 : ParentT{info}

Callers

nothing calls this directly

Calls 3

SetMethod · 0.80
GlobalMethod · 0.80
NewMethod · 0.45

Tested by

no test coverage detected