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

Side by Side Diff: gin/converter.cc

Issue 62333018: Implement Asynchronous Module Definition API for Mojo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Aaron's comments Created 7 years, 1 month 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/gin.gyp » ('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::Boolean; 9 using v8::Boolean;
10 using v8::External;
10 using v8::Function; 11 using v8::Function;
11 using v8::Handle; 12 using v8::Handle;
12 using v8::Integer; 13 using v8::Integer;
13 using v8::Isolate; 14 using v8::Isolate;
14 using v8::Number; 15 using v8::Number;
15 using v8::Object; 16 using v8::Object;
16 using v8::String; 17 using v8::String;
17 using v8::Value; 18 using v8::Value;
18 19
19 namespace gin { 20 namespace gin {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 } 118 }
118 119
119 bool Converter<Handle<Object> >::FromV8(Handle<Value> val, 120 bool Converter<Handle<Object> >::FromV8(Handle<Value> val,
120 Handle<Object>* out) { 121 Handle<Object>* out) {
121 if (!val->IsObject()) 122 if (!val->IsObject())
122 return false; 123 return false;
123 *out = Handle<Object>::Cast(val); 124 *out = Handle<Object>::Cast(val);
124 return true; 125 return true;
125 } 126 }
126 127
128 Handle<Value> Converter<Handle<External> >::ToV8(v8::Isolate* isolate,
129 Handle<External> val) {
130 return val.As<Value>();
131 }
132
133 bool Converter<Handle<External> >::FromV8(Handle<Value> val,
134 Handle<External>* out) {
135 if (!val->IsExternal())
136 return false;
137 *out = Handle<External>::Cast(val);
138 return true;
139 }
140
141 Handle<Value> Converter<Handle<Value> >::ToV8(v8::Isolate* isolate,
142 Handle<Value> val) {
143 return val;
144 }
145
146 bool Converter<Handle<Value> >::FromV8(Handle<Value> val,
147 Handle<Value>* out) {
148 *out = val;
149 return true;
150 }
151
127 v8::Handle<v8::String> StringToSymbol(v8::Isolate* isolate, 152 v8::Handle<v8::String> StringToSymbol(v8::Isolate* isolate,
128 const std::string& val) { 153 const std::string& val) {
129 return String::NewFromUtf8(isolate, 154 return String::NewFromUtf8(isolate,
130 val.data(), 155 val.data(),
131 String::kInternalizedString, 156 String::kInternalizedString,
132 static_cast<uint32_t>(val.length())); 157 static_cast<uint32_t>(val.length()));
133 } 158 }
134 159
135 160
136 } // namespace gin 161 } // namespace gin
OLDNEW
« no previous file with comments | « gin/converter.h ('k') | gin/gin.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698