Index: mojo/public/c/bindings/array.h |
diff --git a/mojo/public/c/bindings/array.h b/mojo/public/c/bindings/array.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..0646dd6d8d597afc056315676d343586e1050510 |
--- /dev/null |
+++ b/mojo/public/c/bindings/array.h |
@@ -0,0 +1,38 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef MOJO_PUBLIC_C_BINDINGS_ARRAY_H_ |
+#define MOJO_PUBLIC_C_BINDINGS_ARRAY_H_ |
+ |
+#include <stdint.h> |
+ |
+#include "mojo/public/c/system/macros.h" |
+ |
+MOJO_BEGIN_EXTERN_C |
+ |
+// The fields below are just the header of a mojom array. The bytes that |
+// immediately follow this struct consist of |num_bytes - sizeof(MojomArray)| |
+// bytes describing |num_elements| elements of the array. |
+struct MojomArray { |
viettrungluu
2016/06/17 20:37:19
Maybe this should be called MojomArrayHeader inste
vardhan
2016/06/21 16:07:36
Done.
|
+ // num_bytes includes the size of this struct along with the |
+ // accompanying array bytes that follow these fields. |
+ uint32_t num_bytes; |
+ uint32_t num_elements; |
+}; |
+MOJO_STATIC_ASSERT(sizeof(struct MojomArray) == 8, |
+ "struct MojomArray must be 8 bytes."); |
+ |
+// This union is used to represent references to a mojom array. |
+union MojomArrayPtr { |
+ // |ptr| is used to access the array when it hasn't been encoded yet. |
+ struct MojomArray* ptr; |
+ // |offset| is used to access the array after it has been encoded. |
+ uint64_t offset; |
+}; |
+MOJO_STATIC_ASSERT(sizeof(union MojomArrayPtr) == 8, |
+ "union MojomArrayPtr must be 8 bytes."); |
+ |
+MOJO_END_EXTERN_C |
+ |
+#endif // MOJO_PUBLIC_C_BINDINGS_ARRAY_H_ |