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

Function TypeSafeCallback

src/util/helpers.cpp:128–135  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected