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

Unified Diff: mojo/not-to-commit/mojo_public_test_interfaces/src/org/chromium/mojo/bindings/test/mojom/imported/Thing.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/imported/Thing.java
diff --git a/mojo/not-to-commit/mojo_public_test_interfaces/src/org/chromium/mojo/bindings/test/mojom/imported/Thing.java b/mojo/not-to-commit/mojo_public_test_interfaces/src/org/chromium/mojo/bindings/test/mojom/imported/Thing.java
new file mode 100644
index 0000000000000000000000000000000000000000..fb0db82759a7759755cd2c67f285160a37223f16
--- /dev/null
+++ b/mojo/not-to-commit/mojo_public_test_interfaces/src/org/chromium/mojo/bindings/test/mojom/imported/Thing.java
@@ -0,0 +1,70 @@
+// 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/sample_import2.mojom
+//
+
+package org.chromium.mojo.bindings.test.mojom.imported;
+
+public final class Thing extends org.chromium.mojo.bindings.Struct {
+
+ private static final int STRUCT_SIZE = 32;
+ private static final DataHeader DEFAULT_STRUCT_INFO = new DataHeader(STRUCT_SIZE, 4);
+
+ public int shape;
+ public int color;
+ public Point location;
+ public Size size;
+
+ public Thing() {
+ super(STRUCT_SIZE);
+ shape = (int) Shape.SHAPE_RECTANGLE;
+ color = (int) Color.COLOR_BLACK;
+ }
+
+ public static Thing deserialize(org.chromium.mojo.bindings.Message message) {
+ return decode(new org.chromium.mojo.bindings.Decoder(message));
+ }
+
+ public static Thing decode(org.chromium.mojo.bindings.Decoder decoder0) {
+ Thing result = new Thing();
+ DataHeader mainDataHeader = decoder0.readDataHeader();
+ if (0 < mainDataHeader.numFields) {
+ result.shape = decoder0.readInt(8);
+ }
+ if (1 < mainDataHeader.numFields) {
+ result.color = decoder0.readInt(12);
+ }
+ if (2 < mainDataHeader.numFields) {
+ org.chromium.mojo.bindings.Decoder decoder1 = decoder0.readPointer(16);
rmcilroy 2014/06/25 13:14:39 Could you add the null check at the top of struct'
qsr 2014/06/25 14:43:05 Given that we will still have this kind of constru
rmcilroy 2014/06/26 17:10:25 Yes I think it would be worth it, particularly sin
rmcilroy 2014/07/01 15:53:46 Ping?
+ if (decoder1 == null) {
+ result.location = null;
+ } else {
+ result.location = Point.decode(decoder1);
+ }
+ }
+ if (3 < mainDataHeader.numFields) {
+ org.chromium.mojo.bindings.Decoder decoder1 = decoder0.readPointer(24);
+ if (decoder1 == null) {
+ result.size = null;
+ } else {
+ result.size = Size.decode(decoder1);
+ }
+ }
+ 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(shape, 8);
+ encoder0.encode(color, 12);
+ encoder0.encode(location, 16);
+ encoder0.encode(size, 24);
+ }
+}
+

Powered by Google App Engine
This is Rietveld 408576698