Last active
October 12, 2019 11:27
-
-
Save ghaiklor/7f9d22dddae9b2e1f2f5 to your computer and use it in GitHub Desktop.
Simple example how V8 Function\Object Templates can be used
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create a template for the global object and set the built-in global functions | |
Local<ObjectTemplate> global = ObjectTemplate::New(isolate); | |
global->Set( | |
String::NewFromUtf8(isolate, "log"), | |
FunctionTemplate::New(isolate, LogCallback) | |
); | |
// Each processor gets its own context so different processors do not affect each other | |
Persistent<Context> context = Context::New(isolate, NULL, global); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It's from the unattributed V8 samples: https://github.com/v8/v8/blob/master/samples/process.cc