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

Side by Side Diff: sky/engine/tonic/dart_converter.h

Issue 942993002: Add support for |any| to Sky's code generator (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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 | « sky/engine/bindings/scripts/dart_types.py ('k') | sky/engine/tonic/dart_state.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #ifndef SKY_ENGINE_TONIC_DART_CONVERTER_H_ 5 #ifndef SKY_ENGINE_TONIC_DART_CONVERTER_H_
6 #define SKY_ENGINE_TONIC_DART_CONVERTER_H_ 6 #define SKY_ENGINE_TONIC_DART_CONVERTER_H_
7 7
8 #include <string> 8 #include <string>
9 #include "sky/engine/tonic/dart_state.h" 9 #include "sky/engine/tonic/dart_state.h"
10 #include "sky/engine/tonic/dart_string.h" 10 #include "sky/engine/tonic/dart_string.h"
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 bool auto_scope = true) { 262 bool auto_scope = true) {
263 // TODO(abarth): What should we do with auto_scope? 263 // TODO(abarth): What should we do with auto_scope?
264 return FromDart(Dart_GetNativeArgument(args, index)); 264 return FromDart(Dart_GetNativeArgument(args, index));
265 } 265 }
266 }; 266 };
267 267
268 //////////////////////////////////////////////////////////////////////////////// 268 ////////////////////////////////////////////////////////////////////////////////
269 // DartValue 269 // DartValue
270 270
271 template <> 271 template <>
272 struct DartConverter<DartValue> { 272 struct DartConverter<DartValue*> {
273 static Dart_Handle ToDart(DartState* state, DartValue* val) { 273 static Dart_Handle ToDart(DartState* state, DartValue* val) {
274 return val->dart_value(); 274 return val->dart_value();
275 } 275 }
276 276
277 static void SetReturnValue(Dart_NativeArguments args, DartValue* val) { 277 static void SetReturnValue(Dart_NativeArguments args, DartValue* val) {
278 Dart_SetReturnValue(args, val->dart_value()); 278 Dart_SetReturnValue(args, val->dart_value());
279 } 279 }
280
281 static PassRefPtr<DartValue> FromDart(Dart_Handle handle) {
282 return DartValue::Create(DartState::Current(), handle);
283 }
284
285 static PassRefPtr<DartValue> FromArguments(Dart_NativeArguments args,
286 int index,
287 Dart_Handle& exception,
288 bool auto_scope = true) {
289 // TODO(abarth): What should we do with auto_scope?
290 return FromDart(Dart_GetNativeArgument(args, index));
291 }
280 }; 292 };
281 293
282 //////////////////////////////////////////////////////////////////////////////// 294 ////////////////////////////////////////////////////////////////////////////////
283 // Convience wrappers for commonly used conversions 295 // Convience wrappers for commonly used conversions
284 296
285 inline Dart_Handle StringToDart(DartState* state, const String& val) { 297 inline Dart_Handle StringToDart(DartState* state, const String& val) {
286 return DartConverter<String>::ToDart(state, val); 298 return DartConverter<String>::ToDart(state, val);
287 } 299 }
288 300
289 inline Dart_Handle StringToDart(DartState* state, const AtomicString& val) { 301 inline Dart_Handle StringToDart(DartState* state, const AtomicString& val) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 335
324 336
325 // Alias Dart_NewStringFromCString for less typing. 337 // Alias Dart_NewStringFromCString for less typing.
326 inline Dart_Handle ToDart(const char* val) { 338 inline Dart_Handle ToDart(const char* val) {
327 return Dart_NewStringFromCString(val); 339 return Dart_NewStringFromCString(val);
328 } 340 }
329 341
330 } // namespace blink 342 } // namespace blink
331 343
332 #endif // SKY_ENGINE_TONIC_DART_CONVERTER_H_ 344 #endif // SKY_ENGINE_TONIC_DART_CONVERTER_H_
OLDNEW
« no previous file with comments | « sky/engine/bindings/scripts/dart_types.py ('k') | sky/engine/tonic/dart_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698