Skip to content

Instantly share code, notes, and snippets.

@deepal
Forked from ghaiklor/v8-templates-example.cc
Created October 12, 2019 11:27
Show Gist options
  • Save deepal/980ab6dabb1cb3ed824548e7b6df0df1 to your computer and use it in GitHub Desktop.
Save deepal/980ab6dabb1cb3ed824548e7b6df0df1 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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment