Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(540)

Side by Side Diff: include/v8.h

Issue 2127523003: Updating the code example in FunctionTemplate class documentation (Closed) Base URL: git@github.com:danbev/v8.git@master
Patch Set: Adding myself to the AUTHORS file Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « AUTHORS ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** \mainpage V8 API Reference Guide 5 /** \mainpage V8 API Reference Guide
6 * 6 *
7 * V8 is Google's open source JavaScript engine. 7 * V8 is Google's open source JavaScript engine.
8 * 8 *
9 * This set of documents provides reference material generated from the 9 * This set of documents provides reference material generated from the
10 * V8 header file, include/v8.h. 10 * V8 header file, include/v8.h.
(...skipping 4399 matching lines...) Expand 10 before | Expand all | Expand 10 after
4410 * used to create object instances when the function is used as a 4410 * used to create object instances when the function is used as a
4411 * constructor. Properties added to the instance template are added to 4411 * constructor. Properties added to the instance template are added to
4412 * each object instance. 4412 * each object instance.
4413 * 4413 *
4414 * A FunctionTemplate can have a prototype template. The prototype template 4414 * A FunctionTemplate can have a prototype template. The prototype template
4415 * is used to create the prototype object of the function. 4415 * is used to create the prototype object of the function.
4416 * 4416 *
4417 * The following example shows how to use a FunctionTemplate: 4417 * The following example shows how to use a FunctionTemplate:
4418 * 4418 *
4419 * \code 4419 * \code
4420 * v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(); 4420 * v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate);
4421 * t->Set("func_property", v8::Number::New(1)); 4421 * t->Set(isolate, "func_property", v8::Number::New(isolate, 1));
4422 * 4422 *
4423 * v8::Local<v8::Template> proto_t = t->PrototypeTemplate(); 4423 * v8::Local<v8::Template> proto_t = t->PrototypeTemplate();
4424 * proto_t->Set("proto_method", v8::FunctionTemplate::New(InvokeCallback)); 4424 * proto_t->Set(isolate,
4425 * proto_t->Set("proto_const", v8::Number::New(2)); 4425 * "proto_method",
4426 * v8::FunctionTemplate::New(isolate, InvokeCallback));
4427 * proto_t->Set(isolate, "proto_const", v8::Number::New(isolate, 2));
4426 * 4428 *
4427 * v8::Local<v8::ObjectTemplate> instance_t = t->InstanceTemplate(); 4429 * v8::Local<v8::ObjectTemplate> instance_t = t->InstanceTemplate();
4428 * instance_t->SetAccessor("instance_accessor", InstanceAccessorCallback); 4430 * instance_t->SetAccessor(String::NewFromUtf8(isolate, "instance_accessor"),
4429 * instance_t->SetNamedPropertyHandler(PropertyHandlerCallback, ...); 4431 * InstanceAccessorCallback);
4430 * instance_t->Set("instance_property", Number::New(3)); 4432 * instance_t->SetNamedPropertyHandler(PropertyHandlerCallback);
4433 * instance_t->Set(String::NewFromUtf8(isolate, "instance_property"),
4434 * Number::New(isolate, 3));
4431 * 4435 *
4432 * v8::Local<v8::Function> function = t->GetFunction(); 4436 * v8::Local<v8::Function> function = t->GetFunction();
4433 * v8::Local<v8::Object> instance = function->NewInstance(); 4437 * v8::Local<v8::Object> instance = function->NewInstance();
4434 * \endcode 4438 * \endcode
4435 * 4439 *
4436 * Let's use "function" as the JS variable name of the function object 4440 * Let's use "function" as the JS variable name of the function object
4437 * and "instance" for the instance object created above. The function 4441 * and "instance" for the instance object created above. The function
4438 * and the instance will have the following properties: 4442 * and the instance will have the following properties:
4439 * 4443 *
4440 * \code 4444 * \code
(...skipping 4471 matching lines...) Expand 10 before | Expand all | Expand 10 after
8912 */ 8916 */
8913 8917
8914 8918
8915 } // namespace v8 8919 } // namespace v8
8916 8920
8917 8921
8918 #undef TYPE_CHECK 8922 #undef TYPE_CHECK
8919 8923
8920 8924
8921 #endif // INCLUDE_V8_H_ 8925 #endif // INCLUDE_V8_H_
OLDNEW
« no previous file with comments | « AUTHORS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698