Chromium Code Reviews| Index: mojo/not-to-commit/mojo_public_test_interfaces/src/org/chromium/mojo/bindings/test/mojom/math/CalculatorInternal.java |
| diff --git a/mojo/not-to-commit/mojo_public_test_interfaces/src/org/chromium/mojo/bindings/test/mojom/math/CalculatorInternal.java b/mojo/not-to-commit/mojo_public_test_interfaces/src/org/chromium/mojo/bindings/test/mojom/math/CalculatorInternal.java |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..00ddf6c15ee6693ef42c597bd5b4cd29de5055ee |
| --- /dev/null |
| +++ b/mojo/not-to-commit/mojo_public_test_interfaces/src/org/chromium/mojo/bindings/test/mojom/math/CalculatorInternal.java |
| @@ -0,0 +1,224 @@ |
| +// 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/math_calculator.mojom |
| +// |
| + |
| +package org.chromium.mojo.bindings.test.mojom.math; |
| + |
| +class CalculatorInternal { |
| + |
| + public static final org.chromium.mojo.bindings.InterfaceWithClient.Builder<CalculatorUi, Calculator, Calculator.Proxy> BUILDER = |
| + new org.chromium.mojo.bindings.InterfaceWithClient.Builder<CalculatorUi, Calculator, Calculator.Proxy>() { |
| + |
| + public Proxy buildProxy(org.chromium.mojo.system.Core core, |
| + org.chromium.mojo.bindings.MessageReceiverWithResponder messageReceiver) { |
| + return new Proxy(core, messageReceiver); |
| + } |
| + |
| + public Stub buildStub(org.chromium.mojo.system.Core core, Calculator impl) { |
| + return new Stub(core, impl); |
| + } |
| + |
| + public Calculator[] newArray(int size) { |
| + return new Calculator[size]; |
| + } |
| + |
| + protected org.chromium.mojo.bindings.Interface.Builder<CalculatorUi, ?> getClientBuilder() { |
| + return CalculatorUi.BUILDER; |
| + } |
| + }; |
| + |
| + private static final int CLEAR_ORDINAL = 0; |
| + private static final int ADD_ORDINAL = 1; |
| + private static final int MULTIPLY_ORDINAL = 2; |
| + |
| + static final class Proxy extends org.chromium.mojo.bindings.InterfaceWithClient.BaseProxy<CalculatorUi> implements Calculator.Proxy { |
| + |
| + Proxy(org.chromium.mojo.system.Core core, |
| + org.chromium.mojo.bindings.MessageReceiverWithResponder messageReceiver) { |
| + super(core, messageReceiver); |
| + } |
| + |
| + @Override |
| + public void clear() { |
| + CalculatorClearParams message = new CalculatorClearParams(); |
| + getMessageReceiver().accept( |
| + message.serializeWithHeader( |
| + getCore(), |
| + new org.chromium.mojo.bindings.MessageHeader(CLEAR_ORDINAL))); |
| + } |
| + |
| + @Override |
| + public void add(double value) { |
| + CalculatorAddParams message = new CalculatorAddParams(); |
| + message.value = value; |
|
rmcilroy
2014/08/21 14:43:52
Could you do the parameter building as constructor
qsr
2014/08/22 08:11:18
The generation of the message is the standard stru
|
| + getMessageReceiver().accept( |
| + message.serializeWithHeader( |
| + getCore(), |
| + new org.chromium.mojo.bindings.MessageHeader(ADD_ORDINAL))); |
| + } |
| + |
| + @Override |
| + public void multiply(double value) { |
| + CalculatorMultiplyParams message = new CalculatorMultiplyParams(); |
| + message.value = value; |
| + getMessageReceiver().accept( |
| + message.serializeWithHeader( |
| + getCore(), |
| + new org.chromium.mojo.bindings.MessageHeader(MULTIPLY_ORDINAL))); |
| + } |
| + |
| + } |
| + |
| + static final class Stub extends org.chromium.mojo.bindings.Interface.Stub<Calculator> { |
| + |
| + Stub(org.chromium.mojo.system.Core core, Calculator impl) { |
| + super(core, impl); |
| + } |
| + |
| + @Override |
| + public boolean accept(org.chromium.mojo.bindings.MessageWithHeader message) { |
| + try { |
| + org.chromium.mojo.bindings.MessageHeader header = message.getHeader(); |
| + switch(header.getType()) { |
| + case CLEAR_ORDINAL: { |
| + if (!header.validateHeader(0)) { |
| + return false; |
| + } |
| + CalculatorClearParams.deserialize(message.getPayload()); |
| + getImpl().clear(); |
| + return true; |
| + } |
| + case ADD_ORDINAL: { |
| + if (!header.validateHeader(0)) { |
| + return false; |
| + } |
| + CalculatorAddParams data = |
| + CalculatorAddParams.deserialize(message.getPayload()); |
| + getImpl().add(data.value); |
| + return true; |
| + } |
| + case MULTIPLY_ORDINAL: { |
| + if (!header.validateHeader(0)) { |
| + return false; |
| + } |
| + CalculatorMultiplyParams data = |
| + CalculatorMultiplyParams.deserialize(message.getPayload()); |
| + getImpl().multiply(data.value); |
| + return true; |
| + } |
| + } |
| + } catch (org.chromium.mojo.bindings.DeserializationException e) { |
| + } |
| + return false; |
| + } |
| + |
| + @Override |
| + public boolean acceptWithResponder(org.chromium.mojo.bindings.MessageWithHeader message, org.chromium.mojo.bindings.MessageReceiver receiver) { |
| + return false; |
| + } |
| + } |
| + |
| + static final class CalculatorClearParams extends org.chromium.mojo.bindings.Struct { |
| + |
| + private static final int STRUCT_SIZE = 8; |
| + private static final DataHeader DEFAULT_STRUCT_INFO = new DataHeader(STRUCT_SIZE, 0); |
| + |
| + public CalculatorClearParams() { |
| + super(STRUCT_SIZE); |
| + } |
| + |
| + public static CalculatorClearParams deserialize(org.chromium.mojo.bindings.Message message) { |
| + return decode(new org.chromium.mojo.bindings.Decoder(message)); |
| + } |
| + |
| + public static CalculatorClearParams decode(org.chromium.mojo.bindings.Decoder decoder0) { |
| + if (decoder0 == null) { |
| + return null; |
| + } |
| + CalculatorClearParams result = new CalculatorClearParams(); |
| + decoder0.readDataHeader(); |
| + return result; |
| + } |
| + |
| + @Override |
| + protected final void encode(org.chromium.mojo.bindings.Encoder encoder) { |
| + encoder.getEncoderAtDataOffset(DEFAULT_STRUCT_INFO); |
| + } |
| + } |
| + |
| + static final class CalculatorAddParams extends org.chromium.mojo.bindings.Struct { |
| + |
| + private static final int STRUCT_SIZE = 16; |
| + private static final DataHeader DEFAULT_STRUCT_INFO = new DataHeader(STRUCT_SIZE, 1); |
| + |
| + public double value; |
| + |
| + public CalculatorAddParams() { |
| + super(STRUCT_SIZE); |
| + } |
| + |
| + public static CalculatorAddParams deserialize(org.chromium.mojo.bindings.Message message) { |
| + return decode(new org.chromium.mojo.bindings.Decoder(message)); |
| + } |
| + |
| + public static CalculatorAddParams decode(org.chromium.mojo.bindings.Decoder decoder0) { |
| + if (decoder0 == null) { |
| + return null; |
| + } |
| + CalculatorAddParams result = new CalculatorAddParams(); |
| + DataHeader mainDataHeader = decoder0.readDataHeader(); |
| + if (mainDataHeader.numFields > 0) { |
| + result.value = decoder0.readDouble(8); |
| + } |
| + 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(value, 8); |
| + } |
| + } |
| + |
| + static final class CalculatorMultiplyParams extends org.chromium.mojo.bindings.Struct { |
| + |
| + private static final int STRUCT_SIZE = 16; |
| + private static final DataHeader DEFAULT_STRUCT_INFO = new DataHeader(STRUCT_SIZE, 1); |
| + |
| + public double value; |
| + |
| + public CalculatorMultiplyParams() { |
| + super(STRUCT_SIZE); |
| + } |
| + |
| + public static CalculatorMultiplyParams deserialize(org.chromium.mojo.bindings.Message message) { |
| + return decode(new org.chromium.mojo.bindings.Decoder(message)); |
| + } |
| + |
| + public static CalculatorMultiplyParams decode(org.chromium.mojo.bindings.Decoder decoder0) { |
| + if (decoder0 == null) { |
| + return null; |
| + } |
| + CalculatorMultiplyParams result = new CalculatorMultiplyParams(); |
| + DataHeader mainDataHeader = decoder0.readDataHeader(); |
| + if (mainDataHeader.numFields > 0) { |
| + result.value = decoder0.readDouble(8); |
| + } |
| + 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(value, 8); |
| + } |
| + } |
| + |
| +} |
| + |