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

Unified Diff: mojo/not-to-commit/mojo_public_test_interfaces/src/org/chromium/mojo/bindings/test/mojom/test_structs/NamedRegion.java

Issue 317273006: Add serialization/deserialization of structs for mojo java bindings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Follow review Created 6 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/not-to-commit/mojo_public_test_interfaces/src/org/chromium/mojo/bindings/test/mojom/test_structs/NamedRegion.java
diff --git a/mojo/not-to-commit/mojo_public_test_interfaces/src/org/chromium/mojo/bindings/test/mojom/test_structs/NamedRegion.java b/mojo/not-to-commit/mojo_public_test_interfaces/src/org/chromium/mojo/bindings/test/mojom/test_structs/NamedRegion.java
new file mode 100644
index 0000000000000000000000000000000000000000..90c5549d66e6cb737a42178274117330a9a9e0e1
--- /dev/null
+++ b/mojo/not-to-commit/mojo_public_test_interfaces/src/org/chromium/mojo/bindings/test/mojom/test_structs/NamedRegion.java
@@ -0,0 +1,69 @@
+// Copyright 2014 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.
+
+// This file is autogenerated by:
+// mojo/public/tools/bindings/mojom_bindings_generator.py
+// For:
+// mojo/public/interfaces/bindings/tests/test_structs.mojom
+//
+
+package org.chromium.mojo.bindings.test.mojom.test_structs;
+
+public final class NamedRegion extends org.chromium.mojo.bindings.Struct {
+
+ private static final int STRUCT_SIZE = 24;
+ private static final DataHeader DEFAULT_STRUCT_INFO = new DataHeader(STRUCT_SIZE, 2);
+
+ public String name;
+ public Rect[] rects;
+
+ public NamedRegion() {
+ super(STRUCT_SIZE);
+ }
+
+ public static NamedRegion deserialize(org.chromium.mojo.bindings.Message message) {
+ return decode(new org.chromium.mojo.bindings.Decoder(message));
+ }
+
+ public static NamedRegion decode(org.chromium.mojo.bindings.Decoder decoder0) {
+ NamedRegion result = new NamedRegion();
+ DataHeader mainDataHeader = decoder0.readDataHeader();
+ if (0 < mainDataHeader.numFields) {
+ result.name = decoder0.readString(8);
+ }
+ if (1 < mainDataHeader.numFields) {
+ org.chromium.mojo.bindings.Decoder decoder1 = decoder0.readPointer(16);
+ if (decoder1 == null) {
+ result.rects = null;
+ } else {
+ DataHeader si1 = decoder1.readDataHeader();
+ result.rects = new Rect[si1.numFields];
+ for (int i1 = 0; i1 < si1.numFields; ++i1) {
+ org.chromium.mojo.bindings.Decoder decoder2 = decoder1.readPointer(8 + 8 * i1);
+ if (decoder2 == null) {
+ result.rects[i1] = null;
+ } else {
+ result.rects[i1] = Rect.decode(decoder2);
+ }
+ }
+ }
+ }
+ return result;
+ }
+
+ @Override
+ protected final void encode(org.chromium.mojo.bindings.Encoder encoder) {
+ org.chromium.mojo.bindings.Encoder encoder0 = encoder.getEncoderAtDataOffset(DEFAULT_STRUCT_INFO);
+ encoder0.encode(name, 8);
+ if (rects == null) {
+ encoder0.encodeNullPointer(16);
+ } else {
+ org.chromium.mojo.bindings.Encoder encoder1 = encoder0.encodePointerArray(rects.length, 16);
+ for (int i0 = 0; i0 < rects.length; ++i0) {
+ encoder1.encode(rects[i0], 8 + 8 * i0);
rmcilroy 2014/06/25 13:14:39 constants here (element size and DataHeader.HEADER
qsr 2014/06/25 14:43:05 Ok, but this will then be ugly. We now have a big
rmcilroy 2014/06/26 17:10:26 Yes it's a bit uglier, but at least it's obvious w
+ }
+ }
+ }
+}
+

Powered by Google App Engine
This is Rietveld 408576698