| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 MOJO_PUBLIC_CPP_BINDINGS_NATIVE_STRUCT_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_NATIVE_STRUCT_H_ |
| 6 #define MOJO_PUBLIC_CPP_BINDINGS_NATIVE_STRUCT_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_NATIVE_STRUCT_H_ |
| 7 | 7 |
| 8 #include "mojo/public/cpp/bindings/array.h" | 8 #include "mojo/public/cpp/bindings/array.h" |
| 9 #include "mojo/public/cpp/bindings/bindings_export.h" |
| 9 #include "mojo/public/cpp/bindings/lib/native_struct_data.h" | 10 #include "mojo/public/cpp/bindings/lib/native_struct_data.h" |
| 10 #include "mojo/public/cpp/bindings/struct_ptr.h" | 11 #include "mojo/public/cpp/bindings/struct_ptr.h" |
| 11 #include "mojo/public/cpp/bindings/type_converter.h" | 12 #include "mojo/public/cpp/bindings/type_converter.h" |
| 12 | 13 |
| 13 namespace mojo { | 14 namespace mojo { |
| 14 | 15 |
| 15 class NativeStruct; | 16 class NativeStruct; |
| 16 using NativeStructPtr = StructPtr<NativeStruct>; | 17 using NativeStructPtr = StructPtr<NativeStruct>; |
| 17 | 18 |
| 18 // Native-only structs correspond to "[Native] struct Foo;" definitions in | 19 // Native-only structs correspond to "[Native] struct Foo;" definitions in |
| 19 // mojom. | 20 // mojom. |
| 20 class NativeStruct { | 21 class MOJO_CPP_BINDINGS_EXPORT NativeStruct { |
| 21 public: | 22 public: |
| 22 using Data_ = internal::NativeStruct_Data; | 23 using Data_ = internal::NativeStruct_Data; |
| 23 | 24 |
| 24 static NativeStructPtr New(); | 25 static NativeStructPtr New(); |
| 25 | 26 |
| 26 template <typename U> | 27 template <typename U> |
| 27 static NativeStructPtr From(const U& u) { | 28 static NativeStructPtr From(const U& u) { |
| 28 return TypeConverter<NativeStructPtr, U>::Convert(u); | 29 return TypeConverter<NativeStructPtr, U>::Convert(u); |
| 29 } | 30 } |
| 30 | 31 |
| 31 template <typename U> | 32 template <typename U> |
| 32 U To() const { | 33 U To() const { |
| 33 return TypeConverter<U, NativeStruct>::Convert(*this); | 34 return TypeConverter<U, NativeStruct>::Convert(*this); |
| 34 } | 35 } |
| 35 | 36 |
| 36 NativeStruct(); | 37 NativeStruct(); |
| 37 ~NativeStruct(); | 38 ~NativeStruct(); |
| 38 | 39 |
| 39 NativeStructPtr Clone() const; | 40 NativeStructPtr Clone() const; |
| 40 bool Equals(const NativeStruct& other) const; | 41 bool Equals(const NativeStruct& other) const; |
| 41 | 42 |
| 42 Array<uint8_t> data; | 43 Array<uint8_t> data; |
| 43 }; | 44 }; |
| 44 | 45 |
| 45 } // namespace mojo | 46 } // namespace mojo |
| 46 | 47 |
| 47 #endif // MOJO_PUBLIC_CPP_BINDINGS_NATIVE_STRUCT_H_ | 48 #endif // MOJO_PUBLIC_CPP_BINDINGS_NATIVE_STRUCT_H_ |
| OLD | NEW |