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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 int index, | 116 int index, |
117 Dart_Handle& exception, | 117 Dart_Handle& exception, |
118 bool auto_scope = true) { | 118 bool auto_scope = true) { |
119 // TODO(abarth): We're missing a type check. | 119 // TODO(abarth): We're missing a type check. |
120 return static_cast<T*>(DartConverterWrappable::FromArgumentsWithNullCheck( | 120 return static_cast<T*>(DartConverterWrappable::FromArgumentsWithNullCheck( |
121 args, index, exception)); | 121 args, index, exception)); |
122 } | 122 } |
123 }; | 123 }; |
124 | 124 |
125 template<typename T> | 125 template<typename T> |
126 struct DartConverter<RefPtr<T>> { | |
127 static Dart_Handle ToDart(RefPtr<T> val) { | |
128 return DartConverter<T*>::ToDart(val.get()); | |
129 } | |
130 | |
131 static RefPtr<T> FromDart(Dart_Handle handle) { | |
132 return DartConverter<T*>::FromDart(handle); | |
133 } | |
134 }; | |
135 | |
136 template<typename T> | |
137 inline T* GetReceiver(Dart_NativeArguments args) { | 126 inline T* GetReceiver(Dart_NativeArguments args) { |
138 intptr_t receiver; | 127 intptr_t receiver; |
139 Dart_Handle result = Dart_GetNativeReceiver(args, &receiver); | 128 Dart_Handle result = Dart_GetNativeReceiver(args, &receiver); |
140 DCHECK(!Dart_IsError(result)); | 129 DCHECK(!Dart_IsError(result)); |
141 return static_cast<T*>(reinterpret_cast<DartWrappable*>(receiver)); | 130 return static_cast<T*>(reinterpret_cast<DartWrappable*>(receiver)); |
142 } | 131 } |
143 | 132 |
144 } // namespace blink | 133 } // namespace blink |
145 | 134 |
146 #endif // SKY_ENGINE_TONIC_DART_WRAPPABLE_H_ | 135 #endif // SKY_ENGINE_TONIC_DART_WRAPPABLE_H_ |
OLD | NEW |