| 254 | } |
| 255 | |
| 256 | void registerFunction (const std::string& name, Context::NativeFunction fn) override |
| 257 | { |
| 258 | v8::Isolate::Scope isolateScope (isolate); |
| 259 | v8::HandleScope handleScope (isolate); |
| 260 | auto localContext = context.Get (isolate); |
| 261 | v8::Context::Scope contextScope (localContext); |
| 262 | |
| 263 | ++nextNativeFunctionHandle; |
| 264 | nativeFunctions[nextNativeFunctionHandle] = std::move (fn); |
| 265 | |
| 266 | auto global = localContext->Global(); |
| 267 | auto ft = v8::FunctionTemplate::New (isolate, staticCallback, v8::Int32::New (isolate, nextNativeFunctionHandle)); |
| 268 | (void) global->Set (localContext, stringToV8 (name), ft->GetFunction (localContext).ToLocalChecked()); |
| 269 | } |
| 270 | |
| 271 | static void staticCallback (const v8::FunctionCallbackInfo<v8::Value>& info) |
| 272 | { |
nothing calls this directly
no outgoing calls
no test coverage detected