Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1771)

Unified Diff: mojo/public/c/bindings/array.h

Issue 2072903002: C bindings pt3: Type table definitions and barebones files to get generated code to compile. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: elem_table -> elem_descriptor Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/public/c/bindings/BUILD.gn ('k') | mojo/public/c/bindings/interface.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..423899d98d1e1ec5b52cd5cdb1e62b1366b17e7c
--- /dev/null
+++ b/mojo/public/c/bindings/array.h
@@ -0,0 +1,39 @@
+// 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(MojomArrayHeader)| bytes describing |num_elements| elements of the
+// array.
+struct MojomArrayHeader {
+ // 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 MojomArrayHeader) == 8,
+ "struct MojomArrayHeader must be 8 bytes.");
+
+// This union is used to represent references to a mojom array.
+union MojomArrayHeaderPtr {
+ // |ptr| is used to access the array when it hasn't been encoded yet.
+ struct MojomArrayHeader* ptr;
+ // |offset| is used to access the array after it has been encoded.
+ uint64_t offset;
+};
+MOJO_STATIC_ASSERT(sizeof(union MojomArrayHeaderPtr) == 8,
+ "union MojomArrayHeaderPtr must be 8 bytes.");
+
+MOJO_END_EXTERN_C
+
+#endif // MOJO_PUBLIC_C_BINDINGS_ARRAY_H_
« no previous file with comments | « mojo/public/c/bindings/BUILD.gn ('k') | mojo/public/c/bindings/interface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698