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

Side by Side Diff: gin/arguments.cc

Issue 2820113004: Revert of [gin] Add Arguments::GetAll() (Closed)
Patch Set: Created 3 years, 8 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 | « gin/arguments.h ('k') | gin/arguments_unittest.cc » ('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 {
(...skipping 14 matching lines...) Expand all
25 25
26 Arguments::~Arguments() { 26 Arguments::~Arguments() {
27 } 27 }
28 28
29 v8::Local<v8::Value> Arguments::PeekNext() const { 29 v8::Local<v8::Value> Arguments::PeekNext() const {
30 if (next_ >= info_->Length()) 30 if (next_ >= info_->Length())
31 return v8::Local<v8::Value>(); 31 return v8::Local<v8::Value>();
32 return (*info_)[next_]; 32 return (*info_)[next_];
33 } 33 }
34 34
35 std::vector<v8::Local<v8::Value>> Arguments::GetAll() const {
36 std::vector<v8::Local<v8::Value>> result;
37 int length = info_->Length();
38 if (length == 0)
39 return result;
40
41 result.reserve(length);
42 for (int i = 0; i < length; ++i)
43 result.push_back((*info_)[i]);
44
45 return result;
46 }
47
48 v8::Local<v8::Context> Arguments::GetHolderCreationContext() { 35 v8::Local<v8::Context> Arguments::GetHolderCreationContext() {
49 return info_->Holder()->CreationContext(); 36 return info_->Holder()->CreationContext();
50 } 37 }
51 38
52 std::string V8TypeAsString(v8::Local<v8::Value> value) { 39 std::string V8TypeAsString(v8::Local<v8::Value> value) {
53 if (value.IsEmpty()) 40 if (value.IsEmpty())
54 return "<empty handle>"; 41 return "<empty handle>";
55 if (value->IsUndefined()) 42 if (value->IsUndefined())
56 return "undefined"; 43 return "undefined";
57 if (value->IsNull()) 44 if (value->IsNull())
(...skipping 16 matching lines...) Expand all
74 void Arguments::ThrowTypeError(const std::string& message) const { 61 void Arguments::ThrowTypeError(const std::string& message) const {
75 isolate_->ThrowException(v8::Exception::TypeError( 62 isolate_->ThrowException(v8::Exception::TypeError(
76 StringToV8(isolate_, message))); 63 StringToV8(isolate_, message)));
77 } 64 }
78 65
79 bool Arguments::IsConstructCall() const { 66 bool Arguments::IsConstructCall() const {
80 return info_->IsConstructCall(); 67 return info_->IsConstructCall();
81 } 68 }
82 69
83 } // namespace gin 70 } // namespace gin
OLDNEW
« no previous file with comments | « gin/arguments.h ('k') | gin/arguments_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698