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

Side by Side Diff: gin/converter.cc

Issue 114883003: Implement more of the JavaScript GL API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: asdf 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/converter.h ('k') | gin/function_template.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/converter.h" 5 #include "gin/converter.h"
6 6
7 #include "v8/include/v8.h" 7 #include "v8/include/v8.h"
8 8
9 using v8::ArrayBuffer; 9 using v8::ArrayBuffer;
10 using v8::Boolean; 10 using v8::Boolean;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 } 72 }
73 73
74 bool Converter<uint64_t>::FromV8(Isolate* isolate, Handle<Value> val, 74 bool Converter<uint64_t>::FromV8(Isolate* isolate, Handle<Value> val,
75 uint64_t* out) { 75 uint64_t* out) {
76 if (!val->IsNumber()) 76 if (!val->IsNumber())
77 return false; 77 return false;
78 *out = static_cast<uint64_t>(val->IntegerValue()); 78 *out = static_cast<uint64_t>(val->IntegerValue());
79 return true; 79 return true;
80 } 80 }
81 81
82 Handle<Value> Converter<float>::ToV8(Isolate* isolate, float val) {
83 return Number::New(isolate, val).As<Value>();
84 }
85
86 bool Converter<float>::FromV8(Isolate* isolate, Handle<Value> val,
87 float* out) {
88 if (!val->IsNumber())
89 return false;
90 *out = static_cast<float>(val->NumberValue());
91 return true;
92 }
93
82 Handle<Value> Converter<double>::ToV8(Isolate* isolate, double val) { 94 Handle<Value> Converter<double>::ToV8(Isolate* isolate, double val) {
83 return Number::New(isolate, val).As<Value>(); 95 return Number::New(isolate, val).As<Value>();
84 } 96 }
85 97
86 bool Converter<double>::FromV8(Isolate* isolate, Handle<Value> val, 98 bool Converter<double>::FromV8(Isolate* isolate, Handle<Value> val,
87 double* out) { 99 double* out) {
88 if (!val->IsNumber()) 100 if (!val->IsNumber())
89 return false; 101 return false;
90 *out = val->NumberValue(); 102 *out = val->NumberValue();
91 return true; 103 return true;
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 std::string V8ToString(v8::Handle<v8::Value> value) { 196 std::string V8ToString(v8::Handle<v8::Value> value) {
185 if (value.IsEmpty()) 197 if (value.IsEmpty())
186 return std::string(); 198 return std::string();
187 std::string result; 199 std::string result;
188 if (!ConvertFromV8(NULL, value, &result)) 200 if (!ConvertFromV8(NULL, value, &result))
189 return std::string(); 201 return std::string();
190 return result; 202 return result;
191 } 203 }
192 204
193 } // namespace gin 205 } // namespace gin
OLDNEW
« no previous file with comments | « gin/converter.h ('k') | gin/function_template.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698