OLD | NEW |
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_WRAPPABLE_H_ | 5 #ifndef SKY_ENGINE_TONIC_DART_WRAPPABLE_H_ |
6 #define SKY_ENGINE_TONIC_DART_WRAPPABLE_H_ | 6 #define SKY_ENGINE_TONIC_DART_WRAPPABLE_H_ |
7 | 7 |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/template_util.h" | 9 #include "base/template_util.h" |
10 #include "dart/runtime/include/dart_api.h" | 10 #include "dart/runtime/include/dart_api.h" |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 return static_cast<T*>(DartConverterWrappable::FromArgumentsWithNullCheck( | 119 return static_cast<T*>(DartConverterWrappable::FromArgumentsWithNullCheck( |
120 args, index, exception)); | 120 args, index, exception)); |
121 } | 121 } |
122 }; | 122 }; |
123 | 123 |
124 template<typename T> | 124 template<typename T> |
125 struct DartConverter<RefPtr<T>> { | 125 struct DartConverter<RefPtr<T>> { |
126 static Dart_Handle ToDart(RefPtr<T> val) { | 126 static Dart_Handle ToDart(RefPtr<T> val) { |
127 return DartConverter<T*>::ToDart(val.get()); | 127 return DartConverter<T*>::ToDart(val.get()); |
128 } | 128 } |
| 129 |
| 130 static RefPtr<T> FromDart(Dart_Handle handle) { |
| 131 return DartConverter<T*>::FromDart(handle); |
| 132 } |
129 }; | 133 }; |
130 | 134 |
131 template<typename T> | 135 template<typename T> |
132 static T* GetReceiver(Dart_NativeArguments args) { | 136 static T* GetReceiver(Dart_NativeArguments args) { |
133 intptr_t receiver; | 137 intptr_t receiver; |
134 Dart_Handle result = Dart_GetNativeReceiver(args, &receiver); | 138 Dart_Handle result = Dart_GetNativeReceiver(args, &receiver); |
135 DCHECK(!Dart_IsError(result)); | 139 DCHECK(!Dart_IsError(result)); |
136 return static_cast<T*>(reinterpret_cast<DartWrappable*>(receiver)); | 140 return static_cast<T*>(reinterpret_cast<DartWrappable*>(receiver)); |
137 } | 141 } |
138 | 142 |
139 } // namespace blink | 143 } // namespace blink |
140 | 144 |
141 #endif // SKY_ENGINE_TONIC_DART_WRAPPABLE_H_ | 145 #endif // SKY_ENGINE_TONIC_DART_WRAPPABLE_H_ |
OLD | NEW |