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

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: cflags_c = std=c11 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
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_

Powered by Google App Engine
This is Rietveld 408576698