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

Side by Side Diff: gin/arguments.cc

Issue 89723002: Convert the rest of the functions in core.cc to use CreateFunctionTemplate. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase+comments Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « gin/arguments.h ('k') | gin/array_buffer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium 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 #include "gin/arguments.h" 5 #include "gin/arguments.h"
6 6
7 #include "base/strings/stringprintf.h" 7 #include "base/strings/stringprintf.h"
8 #include "gin/converter.h" 8 #include "gin/converter.h"
9 9
10 namespace gin { 10 namespace gin {
11 11
12 Arguments::Arguments(const v8::FunctionCallbackInfo<v8::Value>& info) 12 Arguments::Arguments()
13 : isolate_(info.GetIsolate()), 13 : isolate_(NULL),
14 info_(info), 14 info_(NULL),
15 next_(0), 15 next_(0),
16 insufficient_arguments_(false) { 16 insufficient_arguments_(false) {
17 } 17 }
18
19 Arguments::Arguments(const v8::FunctionCallbackInfo<v8::Value>& info)
20 : isolate_(info.GetIsolate()),
21 info_(&info),
22 next_(0),
23 insufficient_arguments_(false) {
24 }
18 25
19 Arguments::~Arguments() { 26 Arguments::~Arguments() {
20 } 27 }
21 28
22 v8::Handle<v8::Value> Arguments::PeekNext() { 29 v8::Handle<v8::Value> Arguments::PeekNext() {
23 if (next_ >= info_.Length()) 30 if (next_ >= info_->Length())
24 return v8::Handle<v8::Value>(); 31 return v8::Handle<v8::Value>();
25 return info_[next_]; 32 return (*info_)[next_];
26 } 33 }
27 34
28 void Arguments::ThrowError() { 35 void Arguments::ThrowError() {
29 if (insufficient_arguments_) 36 if (insufficient_arguments_)
30 return ThrowTypeError("Insufficient number of arguments."); 37 return ThrowTypeError("Insufficient number of arguments.");
31 38
32 ThrowTypeError(base::StringPrintf( 39 ThrowTypeError(base::StringPrintf(
33 "Error processing argument %d.", next_ - 1)); 40 "Error processing argument %d.", next_ - 1));
34 } 41 }
35 42
36 void Arguments::ThrowTypeError(const std::string& message) { 43 void Arguments::ThrowTypeError(const std::string& message) {
37 isolate_->ThrowException(v8::Exception::TypeError( 44 isolate_->ThrowException(v8::Exception::TypeError(
38 StringToV8(isolate_, message))); 45 StringToV8(isolate_, message)));
39 } 46 }
40 47
48 template<>
49 bool Arguments::GetNext<Arguments>(Arguments* out) {
50 *out = *this;
51 return true;
52 }
53
41 } // namespace gin 54 } // namespace gin
OLDNEW
« no previous file with comments | « gin/arguments.h ('k') | gin/array_buffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698