OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef MOJO_PUBLIC_C_BINDINGS_ARRAY_H_ |
| 6 #define MOJO_PUBLIC_C_BINDINGS_ARRAY_H_ |
| 7 |
| 8 #include <stdint.h> |
| 9 |
| 10 #include "mojo/public/c/system/macros.h" |
| 11 |
| 12 MOJO_BEGIN_EXTERN_C |
| 13 |
| 14 // The fields below are just the header of a mojom array. The bytes that |
| 15 // immediately follow this struct consist of |num_bytes - |
| 16 // sizeof(MojomArrayHeader)| bytes describing |num_elements| elements of the |
| 17 // array. |
| 18 struct MojomArrayHeader { |
| 19 // num_bytes includes the size of this struct along with the |
| 20 // accompanying array bytes that follow these fields. |
| 21 uint32_t num_bytes; |
| 22 uint32_t num_elements; |
| 23 }; |
| 24 MOJO_STATIC_ASSERT(sizeof(struct MojomArrayHeader) == 8, |
| 25 "struct MojomArrayHeader must be 8 bytes."); |
| 26 |
| 27 // This union is used to represent references to a mojom array. |
| 28 union MojomArrayHeaderPtr { |
| 29 // |ptr| is used to access the array when it hasn't been encoded yet. |
| 30 struct MojomArrayHeader* ptr; |
| 31 // |offset| is used to access the array after it has been encoded. |
| 32 uint64_t offset; |
| 33 }; |
| 34 MOJO_STATIC_ASSERT(sizeof(union MojomArrayHeaderPtr) == 8, |
| 35 "union MojomArrayHeaderPtr must be 8 bytes."); |
| 36 |
| 37 MOJO_END_EXTERN_C |
| 38 |
| 39 #endif // MOJO_PUBLIC_C_BINDINGS_ARRAY_H_ |
OLD | NEW |