Commit f810ccc8 authored by daniel.bevenius's avatar daniel.bevenius Committed by Commit bot

Updating the code example in FunctionTemplate class documentation

Currently the code example in the FunctionTemplate class documentation
is out of date. This commit updates the examples so they compile and run
without error.

BUG=

Review-Url: https://codereview.chromium.org/2127523003
Cr-Commit-Position: refs/heads/master@{#37741}
parent c8a0c0bd
......@@ -51,6 +51,7 @@ Craig Schlenter <craig.schlenter@gmail.com>
Chris Nardi <hichris123@gmail.com>
Christopher A. Taylor <chris@gameclosure.com>
Daniel Andersson <kodandersson@gmail.com>
Daniel Bevenius <daniel.bevenius@gmail.com>
Daniel James <dnljms@gmail.com>
Deon Dior <diaoyuanjie@gmail.com>
Douglas Crosher <dtc-v8@scieneer.com>
......
......@@ -4418,17 +4418,21 @@ typedef bool (*AccessCheckCallback)(Local<Context> accessing_context,
* The following example shows how to use a FunctionTemplate:
*
* \code
* v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New();
* t->Set("func_property", v8::Number::New(1));
* v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate);
* t->Set(isolate, "func_property", v8::Number::New(isolate, 1));
*
* v8::Local<v8::Template> proto_t = t->PrototypeTemplate();
* proto_t->Set("proto_method", v8::FunctionTemplate::New(InvokeCallback));
* proto_t->Set("proto_const", v8::Number::New(2));
* proto_t->Set(isolate,
* "proto_method",
* v8::FunctionTemplate::New(isolate, InvokeCallback));
* proto_t->Set(isolate, "proto_const", v8::Number::New(isolate, 2));
*
* v8::Local<v8::ObjectTemplate> instance_t = t->InstanceTemplate();
* instance_t->SetAccessor("instance_accessor", InstanceAccessorCallback);
* instance_t->SetNamedPropertyHandler(PropertyHandlerCallback, ...);
* instance_t->Set("instance_property", Number::New(3));
* instance_t->SetAccessor(String::NewFromUtf8(isolate, "instance_accessor"),
* InstanceAccessorCallback);
* instance_t->SetNamedPropertyHandler(PropertyHandlerCallback);
* instance_t->Set(String::NewFromUtf8(isolate, "instance_property"),
* Number::New(isolate, 3));
*
* v8::Local<v8::Function> function = t->GetFunction();
* v8::Local<v8::Object> instance = function->NewInstance();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment