| 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_LIB_NATIVE_STRUCT_DATA_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_NATIVE_STRUCT_DATA_H_ |
| 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_NATIVE_STRUCT_DATA_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_NATIVE_STRUCT_DATA_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "mojo/public/cpp/bindings/bindings_export.h" | 10 #include "mojo/public/cpp/bindings/bindings_export.h" |
| 11 #include "mojo/public/cpp/bindings/lib/array_internal.h" | 11 #include "mojo/public/cpp/bindings/lib/array_internal.h" |
| 12 #include "mojo/public/cpp/system/handle.h" | 12 #include "mojo/public/cpp/system/handle.h" |
| 13 | 13 |
| 14 namespace mojo { | 14 namespace mojo { |
| 15 namespace internal { | 15 namespace internal { |
| 16 | 16 |
| 17 class Buffer; | |
| 18 class ValidationContext; | 17 class ValidationContext; |
| 19 | 18 |
| 20 class MOJO_CPP_BINDINGS_EXPORT NativeStruct_Data { | 19 class MOJO_CPP_BINDINGS_EXPORT NativeStruct_Data { |
| 21 public: | 20 public: |
| 22 static bool Validate(const void* data, ValidationContext* validation_context); | 21 static bool Validate(const void* data, ValidationContext* validation_context); |
| 23 | 22 |
| 24 // Unlike normal structs, the memory layout is exactly the same as an array | 23 // Unlike normal structs, the memory layout is exactly the same as an array |
| 25 // of uint8_t. | 24 // of uint8_t. |
| 26 Array_Data<uint8_t> data; | 25 Array_Data<uint8_t> data; |
| 27 | 26 |
| 28 private: | 27 private: |
| 29 NativeStruct_Data() = delete; | 28 NativeStruct_Data() = delete; |
| 30 ~NativeStruct_Data() = delete; | 29 ~NativeStruct_Data() = delete; |
| 31 }; | 30 }; |
| 32 | 31 |
| 33 static_assert(sizeof(Array_Data<uint8_t>) == sizeof(NativeStruct_Data), | 32 static_assert(sizeof(Array_Data<uint8_t>) == sizeof(NativeStruct_Data), |
| 34 "Mismatched NativeStruct_Data and Array_Data<uint8_t> size"); | 33 "Mismatched NativeStruct_Data and Array_Data<uint8_t> size"); |
| 35 | 34 |
| 36 } // namespace internal | 35 } // namespace internal |
| 37 } // namespace mojo | 36 } // namespace mojo |
| 38 | 37 |
| 39 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_NATIVE_STRUCT_DATA_H_ | 38 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_NATIVE_STRUCT_DATA_H_ |
| OLD | NEW |