| 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" |
| 11 #include "tonic/dart_converter.h" | 11 #include "tonic/dart_converter.h" |
| 12 #include "tonic/dart_error.h" | 12 #include "tonic/dart_error.h" |
| 13 #include "tonic/dart_state.h" | 13 #include "tonic/dart_state.h" |
| 14 #include "tonic/dart_wrapper_info.h" | 14 #include "tonic/dart_wrapper_info.h" |
| 15 | 15 |
| 16 namespace blink { | 16 namespace tonic { |
| 17 class DartGCVisitor; | 17 class DartGCVisitor; |
| 18 struct DartWrapperInfo; | 18 struct DartWrapperInfo; |
| 19 | 19 |
| 20 // DartWrappable is a base class that you can inherit from in order to be | 20 // DartWrappable is a base class that you can inherit from in order to be |
| 21 // exposed to Dart code as an interface. | 21 // exposed to Dart code as an interface. |
| 22 class DartWrappable { | 22 class DartWrappable { |
| 23 public: | 23 public: |
| 24 enum DartNativeFields { | 24 enum DartNativeFields { |
| 25 kPeerIndex, // Must be first to work with Dart_GetNativeReceiver. | 25 kPeerIndex, // Must be first to work with Dart_GetNativeReceiver. |
| 26 kWrapperInfoIndex, | 26 kWrapperInfoIndex, |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 }; | 123 }; |
| 124 | 124 |
| 125 template<typename T> | 125 template<typename T> |
| 126 inline T* GetReceiver(Dart_NativeArguments args) { | 126 inline T* GetReceiver(Dart_NativeArguments args) { |
| 127 intptr_t receiver; | 127 intptr_t receiver; |
| 128 Dart_Handle result = Dart_GetNativeReceiver(args, &receiver); | 128 Dart_Handle result = Dart_GetNativeReceiver(args, &receiver); |
| 129 DCHECK(!Dart_IsError(result)); | 129 DCHECK(!Dart_IsError(result)); |
| 130 return static_cast<T*>(reinterpret_cast<DartWrappable*>(receiver)); | 130 return static_cast<T*>(reinterpret_cast<DartWrappable*>(receiver)); |
| 131 } | 131 } |
| 132 | 132 |
| 133 } // namespace blink | 133 } // namespace tonic |
| 134 | 134 |
| 135 #endif // SKY_ENGINE_TONIC_DART_WRAPPABLE_H_ | 135 #endif // SKY_ENGINE_TONIC_DART_WRAPPABLE_H_ |
| OLD | NEW |