Skip to content

Instantly share code, notes, and snippets.

@ghaiklor
Last active October 12, 2019 11:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ghaiklor/7f9d22dddae9b2e1f2f5 to your computer and use it in GitHub Desktop.
Save ghaiklor/7f9d22dddae9b2e1f2f5 to your computer and use it in GitHub Desktop.
Simple example how V8 Function\Object Templates can be used
// 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);
@brandonros
Copy link

Where is LogCallback defined? :)

@dsoprea
Copy link

dsoprea commented Sep 26, 2018

It's from the unattributed V8 samples: https://github.com/v8/v8/blob/master/samples/process.cc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment