MCPcopy Create free account
hub / github.com/WiseLibs/better-sqlite3 / TypeSafeCallback

Function TypeSafeCallback

src/util/helpers.cpp:126–133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

124// db.exec.call(stmt)) would reinterpret the wrapped pointer as the wrong type.
125template <typename T, Napi::Value (*method)(const Napi::CallbackInfo&)>
126napi_value TypeSafeCallback(napi_env env, napi_callback_info info) {
127 Napi::CallbackInfo cbinfo(env, info);
128 if (!IsInstanceOf<T>(env, cbinfo.This())) {
129 Napi::TypeError::New(env, "Illegal invocation").ThrowAsJavaScriptException();
130 return NULL;
131 }
132 return method(cbinfo);
133}
134
135// These match the default attributes of properties created by a V8 template.
136constexpr napi_property_attributes DEFAULT_ATTRIBUTES =

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected