blob: 8ae035f72638c620fecaf3da095f1bd06b25e092 [file] [log] [blame]
// Copyright 2015 The Vanadium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// 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:
// mojom/vanadium/discovery.mojom
//
package io.v.mojo.discovery;
class Advertiser_Internal {
public static final org.chromium.mojo.bindings.Interface.NamedManager<Advertiser, Advertiser.Proxy> MANAGER =
new org.chromium.mojo.bindings.Interface.NamedManager<Advertiser, Advertiser.Proxy>() {
public String getName() {
return "v23::discovery::Advertiser";
}
public int getVersion() {
return 0;
}
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, Advertiser impl) {
return new Stub(core, impl);
}
public Advertiser[] buildArray(int size) {
return new Advertiser[size];
}
};
private static final int ADVERTISE_ORDINAL = 0;
private static final int STOP_ORDINAL = 1;
static final class Proxy extends org.chromium.mojo.bindings.Interface.AbstractProxy implements Advertiser.Proxy {
Proxy(org.chromium.mojo.system.Core core,
org.chromium.mojo.bindings.MessageReceiverWithResponder messageReceiver) {
super(core, messageReceiver);
}
@Override
public void advertise(Service service, String[] visibility, AdvertiseResponse callback) {
AdvertiserAdvertiseParams _message = new AdvertiserAdvertiseParams();
_message.service = service;
_message.visibility = visibility;
getProxyHandler().getMessageReceiver().acceptWithResponder(
_message.serializeWithHeader(
getProxyHandler().getCore(),
new org.chromium.mojo.bindings.MessageHeader(
ADVERTISE_ORDINAL,
org.chromium.mojo.bindings.MessageHeader.MESSAGE_EXPECTS_RESPONSE_FLAG,
0)),
new AdvertiserAdvertiseResponseParamsForwardToCallback(callback));
}
@Override
public void stop(int h, StopResponse callback) {
AdvertiserStopParams _message = new AdvertiserStopParams();
_message.h = h;
getProxyHandler().getMessageReceiver().acceptWithResponder(
_message.serializeWithHeader(
getProxyHandler().getCore(),
new org.chromium.mojo.bindings.MessageHeader(
STOP_ORDINAL,
org.chromium.mojo.bindings.MessageHeader.MESSAGE_EXPECTS_RESPONSE_FLAG,
0)),
new AdvertiserStopResponseParamsForwardToCallback(callback));
}
}
static final class Stub extends org.chromium.mojo.bindings.Interface.Stub<Advertiser> {
Stub(org.chromium.mojo.system.Core core, Advertiser impl) {
super(core, impl);
}
@Override
public boolean accept(org.chromium.mojo.bindings.Message message) {
try {
org.chromium.mojo.bindings.ServiceMessage messageWithHeader =
message.asServiceMessage();
org.chromium.mojo.bindings.MessageHeader header = messageWithHeader.getHeader();
if (!header.validateHeader(org.chromium.mojo.bindings.MessageHeader.NO_FLAG)) {
return false;
}
switch(header.getType()) {
case org.chromium.mojo.bindings.InterfaceControlMessagesConstants.RUN_OR_CLOSE_PIPE_MESSAGE_ID:
return org.chromium.mojo.bindings.InterfaceControlMessagesHelper.handleRunOrClosePipe(
Advertiser_Internal.MANAGER, messageWithHeader);
default:
return false;
}
} catch (org.chromium.mojo.bindings.DeserializationException e) {
System.err.println(e.toString());
return false;
}
}
@Override
public boolean acceptWithResponder(org.chromium.mojo.bindings.Message message, org.chromium.mojo.bindings.MessageReceiver receiver) {
try {
org.chromium.mojo.bindings.ServiceMessage messageWithHeader =
message.asServiceMessage();
org.chromium.mojo.bindings.MessageHeader header = messageWithHeader.getHeader();
if (!header.validateHeader(org.chromium.mojo.bindings.MessageHeader.MESSAGE_EXPECTS_RESPONSE_FLAG)) {
return false;
}
switch(header.getType()) {
case org.chromium.mojo.bindings.InterfaceControlMessagesConstants.RUN_MESSAGE_ID:
return org.chromium.mojo.bindings.InterfaceControlMessagesHelper.handleRun(
getCore(), Advertiser_Internal.MANAGER, messageWithHeader, receiver);
case ADVERTISE_ORDINAL: {
AdvertiserAdvertiseParams data =
AdvertiserAdvertiseParams.deserialize(messageWithHeader.getPayload());
getImpl().advertise(data.service, data.visibility, new AdvertiserAdvertiseResponseParamsProxyToResponder(getCore(), receiver, header.getRequestId()));
return true;
}
case STOP_ORDINAL: {
AdvertiserStopParams data =
AdvertiserStopParams.deserialize(messageWithHeader.getPayload());
getImpl().stop(data.h, new AdvertiserStopResponseParamsProxyToResponder(getCore(), receiver, header.getRequestId()));
return true;
}
default:
return false;
}
} catch (org.chromium.mojo.bindings.DeserializationException e) {
System.err.println(e.toString());
return false;
}
}
}
static final class AdvertiserAdvertiseParams extends org.chromium.mojo.bindings.Struct {
private static final int STRUCT_SIZE = 24;
private static final org.chromium.mojo.bindings.DataHeader[] VERSION_ARRAY = new org.chromium.mojo.bindings.DataHeader[] {new org.chromium.mojo.bindings.DataHeader(24, 0)};
private static final org.chromium.mojo.bindings.DataHeader DEFAULT_STRUCT_INFO = VERSION_ARRAY[0];
public Service service;
public String[] visibility;
private AdvertiserAdvertiseParams(int version) {
super(STRUCT_SIZE, version);
}
public AdvertiserAdvertiseParams() {
this(0);
}
public static AdvertiserAdvertiseParams deserialize(org.chromium.mojo.bindings.Message message) {
return decode(new org.chromium.mojo.bindings.Decoder(message));
}
@SuppressWarnings("unchecked")
public static AdvertiserAdvertiseParams decode(org.chromium.mojo.bindings.Decoder decoder0) {
if (decoder0 == null) {
return null;
}
org.chromium.mojo.bindings.DataHeader mainDataHeader = decoder0.readAndValidateDataHeader(VERSION_ARRAY);
AdvertiserAdvertiseParams result = new AdvertiserAdvertiseParams(mainDataHeader.elementsOrVersion);
if (mainDataHeader.elementsOrVersion >= 0) {
org.chromium.mojo.bindings.Decoder decoder1 = decoder0.readPointer(8, false);
result.service = Service.decode(decoder1);
}
if (mainDataHeader.elementsOrVersion >= 0) {
org.chromium.mojo.bindings.Decoder decoder1 = decoder0.readPointer(16, true);
if (decoder1 == null) {
result.visibility = null;
} else {
org.chromium.mojo.bindings.DataHeader si1 = decoder1.readDataHeaderForPointerArray(org.chromium.mojo.bindings.BindingsHelper.UNSPECIFIED_ARRAY_LENGTH);
result.visibility = new String[si1.elementsOrVersion];
for (int i1 = 0; i1 < si1.elementsOrVersion; ++i1) {
result.visibility[i1] = decoder1.readString(org.chromium.mojo.bindings.DataHeader.HEADER_SIZE + org.chromium.mojo.bindings.BindingsHelper.POINTER_SIZE * i1, false);
}
}
}
return result;
}
@SuppressWarnings("unchecked")
@Override
protected final void encode(org.chromium.mojo.bindings.Encoder encoder) {
org.chromium.mojo.bindings.Encoder encoder0 = encoder.getEncoderAtDataOffset(DEFAULT_STRUCT_INFO);
encoder0.encode(service, 8, false);
if (visibility == null) {
encoder0.encodeNullPointer(16, true);
} else {
org.chromium.mojo.bindings.Encoder encoder1 = encoder0.encodePointerArray(visibility.length, 16, org.chromium.mojo.bindings.BindingsHelper.UNSPECIFIED_ARRAY_LENGTH);
for (int i0 = 0; i0 < visibility.length; ++i0) {
encoder1.encode(visibility[i0], org.chromium.mojo.bindings.DataHeader.HEADER_SIZE + org.chromium.mojo.bindings.BindingsHelper.POINTER_SIZE * i0, false);
}
}
}
/**
* @see Object#equals(Object)
*/
@Override
public boolean equals(Object object) {
if (object == this)
return true;
if (object == null)
return false;
if (getClass() != object.getClass())
return false;
AdvertiserAdvertiseParams other = (AdvertiserAdvertiseParams) object;
if (!org.chromium.mojo.bindings.BindingsHelper.equals(this.service, other.service))
return false;
if (!java.util.Arrays.deepEquals(this.visibility, other.visibility))
return false;
return true;
}
/**
* @see Object#hashCode()
*/
@Override
public int hashCode() {
final int prime = 31;
int result = prime + getClass().hashCode();
result = prime * result + org.chromium.mojo.bindings.BindingsHelper.hashCode(service);
result = prime * result + java.util.Arrays.deepHashCode(visibility);
return result;
}
}
static final class AdvertiserAdvertiseResponseParams extends org.chromium.mojo.bindings.Struct {
private static final int STRUCT_SIZE = 32;
private static final org.chromium.mojo.bindings.DataHeader[] VERSION_ARRAY = new org.chromium.mojo.bindings.DataHeader[] {new org.chromium.mojo.bindings.DataHeader(32, 0)};
private static final org.chromium.mojo.bindings.DataHeader DEFAULT_STRUCT_INFO = VERSION_ARRAY[0];
public int handle;
public String instanceId;
public Error err;
private AdvertiserAdvertiseResponseParams(int version) {
super(STRUCT_SIZE, version);
}
public AdvertiserAdvertiseResponseParams() {
this(0);
}
public static AdvertiserAdvertiseResponseParams deserialize(org.chromium.mojo.bindings.Message message) {
return decode(new org.chromium.mojo.bindings.Decoder(message));
}
@SuppressWarnings("unchecked")
public static AdvertiserAdvertiseResponseParams decode(org.chromium.mojo.bindings.Decoder decoder0) {
if (decoder0 == null) {
return null;
}
org.chromium.mojo.bindings.DataHeader mainDataHeader = decoder0.readAndValidateDataHeader(VERSION_ARRAY);
AdvertiserAdvertiseResponseParams result = new AdvertiserAdvertiseResponseParams(mainDataHeader.elementsOrVersion);
if (mainDataHeader.elementsOrVersion >= 0) {
result.handle = decoder0.readInt(8);
}
if (mainDataHeader.elementsOrVersion >= 0) {
result.instanceId = decoder0.readString(16, false);
}
if (mainDataHeader.elementsOrVersion >= 0) {
org.chromium.mojo.bindings.Decoder decoder1 = decoder0.readPointer(24, true);
result.err = Error.decode(decoder1);
}
return result;
}
@SuppressWarnings("unchecked")
@Override
protected final void encode(org.chromium.mojo.bindings.Encoder encoder) {
org.chromium.mojo.bindings.Encoder encoder0 = encoder.getEncoderAtDataOffset(DEFAULT_STRUCT_INFO);
encoder0.encode(handle, 8);
encoder0.encode(instanceId, 16, false);
encoder0.encode(err, 24, true);
}
/**
* @see Object#equals(Object)
*/
@Override
public boolean equals(Object object) {
if (object == this)
return true;
if (object == null)
return false;
if (getClass() != object.getClass())
return false;
AdvertiserAdvertiseResponseParams other = (AdvertiserAdvertiseResponseParams) object;
if (this.handle != other.handle)
return false;
if (!org.chromium.mojo.bindings.BindingsHelper.equals(this.instanceId, other.instanceId))
return false;
if (!org.chromium.mojo.bindings.BindingsHelper.equals(this.err, other.err))
return false;
return true;
}
/**
* @see Object#hashCode()
*/
@Override
public int hashCode() {
final int prime = 31;
int result = prime + getClass().hashCode();
result = prime * result + org.chromium.mojo.bindings.BindingsHelper.hashCode(handle);
result = prime * result + org.chromium.mojo.bindings.BindingsHelper.hashCode(instanceId);
result = prime * result + org.chromium.mojo.bindings.BindingsHelper.hashCode(err);
return result;
}
}
static class AdvertiserAdvertiseResponseParamsForwardToCallback extends org.chromium.mojo.bindings.SideEffectFreeCloseable
implements org.chromium.mojo.bindings.MessageReceiver {
private final Advertiser.AdvertiseResponse mCallback;
AdvertiserAdvertiseResponseParamsForwardToCallback(Advertiser.AdvertiseResponse callback) {
this.mCallback = callback;
}
@Override
public boolean accept(org.chromium.mojo.bindings.Message message) {
try {
org.chromium.mojo.bindings.ServiceMessage messageWithHeader =
message.asServiceMessage();
org.chromium.mojo.bindings.MessageHeader header = messageWithHeader.getHeader();
if (!header.validateHeader(ADVERTISE_ORDINAL,
org.chromium.mojo.bindings.MessageHeader.MESSAGE_IS_RESPONSE_FLAG)) {
return false;
}
AdvertiserAdvertiseResponseParams response = AdvertiserAdvertiseResponseParams.deserialize(messageWithHeader.getPayload());
mCallback.call(response.handle, response.instanceId, response.err);
return true;
} catch (org.chromium.mojo.bindings.DeserializationException e) {
return false;
}
}
}
static class AdvertiserAdvertiseResponseParamsProxyToResponder implements Advertiser.AdvertiseResponse {
private final org.chromium.mojo.system.Core mCore;
private final org.chromium.mojo.bindings.MessageReceiver mMessageReceiver;
private final long mRequestId;
AdvertiserAdvertiseResponseParamsProxyToResponder(
org.chromium.mojo.system.Core core,
org.chromium.mojo.bindings.MessageReceiver messageReceiver,
long requestId) {
mCore = core;
mMessageReceiver = messageReceiver;
mRequestId = requestId;
}
@Override
public void call(Integer handle, String instanceId, Error err) {
AdvertiserAdvertiseResponseParams _response = new AdvertiserAdvertiseResponseParams();
_response.handle = handle;
_response.instanceId = instanceId;
_response.err = err;
org.chromium.mojo.bindings.ServiceMessage _message =
_response.serializeWithHeader(
mCore,
new org.chromium.mojo.bindings.MessageHeader(
ADVERTISE_ORDINAL,
org.chromium.mojo.bindings.MessageHeader.MESSAGE_IS_RESPONSE_FLAG,
mRequestId));
mMessageReceiver.accept(_message);
}
}
static final class AdvertiserStopParams extends org.chromium.mojo.bindings.Struct {
private static final int STRUCT_SIZE = 16;
private static final org.chromium.mojo.bindings.DataHeader[] VERSION_ARRAY = new org.chromium.mojo.bindings.DataHeader[] {new org.chromium.mojo.bindings.DataHeader(16, 0)};
private static final org.chromium.mojo.bindings.DataHeader DEFAULT_STRUCT_INFO = VERSION_ARRAY[0];
public int h;
private AdvertiserStopParams(int version) {
super(STRUCT_SIZE, version);
}
public AdvertiserStopParams() {
this(0);
}
public static AdvertiserStopParams deserialize(org.chromium.mojo.bindings.Message message) {
return decode(new org.chromium.mojo.bindings.Decoder(message));
}
@SuppressWarnings("unchecked")
public static AdvertiserStopParams decode(org.chromium.mojo.bindings.Decoder decoder0) {
if (decoder0 == null) {
return null;
}
org.chromium.mojo.bindings.DataHeader mainDataHeader = decoder0.readAndValidateDataHeader(VERSION_ARRAY);
AdvertiserStopParams result = new AdvertiserStopParams(mainDataHeader.elementsOrVersion);
if (mainDataHeader.elementsOrVersion >= 0) {
result.h = decoder0.readInt(8);
}
return result;
}
@SuppressWarnings("unchecked")
@Override
protected final void encode(org.chromium.mojo.bindings.Encoder encoder) {
org.chromium.mojo.bindings.Encoder encoder0 = encoder.getEncoderAtDataOffset(DEFAULT_STRUCT_INFO);
encoder0.encode(h, 8);
}
/**
* @see Object#equals(Object)
*/
@Override
public boolean equals(Object object) {
if (object == this)
return true;
if (object == null)
return false;
if (getClass() != object.getClass())
return false;
AdvertiserStopParams other = (AdvertiserStopParams) object;
if (this.h != other.h)
return false;
return true;
}
/**
* @see Object#hashCode()
*/
@Override
public int hashCode() {
final int prime = 31;
int result = prime + getClass().hashCode();
result = prime * result + org.chromium.mojo.bindings.BindingsHelper.hashCode(h);
return result;
}
}
static final class AdvertiserStopResponseParams extends org.chromium.mojo.bindings.Struct {
private static final int STRUCT_SIZE = 16;
private static final org.chromium.mojo.bindings.DataHeader[] VERSION_ARRAY = new org.chromium.mojo.bindings.DataHeader[] {new org.chromium.mojo.bindings.DataHeader(16, 0)};
private static final org.chromium.mojo.bindings.DataHeader DEFAULT_STRUCT_INFO = VERSION_ARRAY[0];
public Error err;
private AdvertiserStopResponseParams(int version) {
super(STRUCT_SIZE, version);
}
public AdvertiserStopResponseParams() {
this(0);
}
public static AdvertiserStopResponseParams deserialize(org.chromium.mojo.bindings.Message message) {
return decode(new org.chromium.mojo.bindings.Decoder(message));
}
@SuppressWarnings("unchecked")
public static AdvertiserStopResponseParams decode(org.chromium.mojo.bindings.Decoder decoder0) {
if (decoder0 == null) {
return null;
}
org.chromium.mojo.bindings.DataHeader mainDataHeader = decoder0.readAndValidateDataHeader(VERSION_ARRAY);
AdvertiserStopResponseParams result = new AdvertiserStopResponseParams(mainDataHeader.elementsOrVersion);
if (mainDataHeader.elementsOrVersion >= 0) {
org.chromium.mojo.bindings.Decoder decoder1 = decoder0.readPointer(8, true);
result.err = Error.decode(decoder1);
}
return result;
}
@SuppressWarnings("unchecked")
@Override
protected final void encode(org.chromium.mojo.bindings.Encoder encoder) {
org.chromium.mojo.bindings.Encoder encoder0 = encoder.getEncoderAtDataOffset(DEFAULT_STRUCT_INFO);
encoder0.encode(err, 8, true);
}
/**
* @see Object#equals(Object)
*/
@Override
public boolean equals(Object object) {
if (object == this)
return true;
if (object == null)
return false;
if (getClass() != object.getClass())
return false;
AdvertiserStopResponseParams other = (AdvertiserStopResponseParams) object;
if (!org.chromium.mojo.bindings.BindingsHelper.equals(this.err, other.err))
return false;
return true;
}
/**
* @see Object#hashCode()
*/
@Override
public int hashCode() {
final int prime = 31;
int result = prime + getClass().hashCode();
result = prime * result + org.chromium.mojo.bindings.BindingsHelper.hashCode(err);
return result;
}
}
static class AdvertiserStopResponseParamsForwardToCallback extends org.chromium.mojo.bindings.SideEffectFreeCloseable
implements org.chromium.mojo.bindings.MessageReceiver {
private final Advertiser.StopResponse mCallback;
AdvertiserStopResponseParamsForwardToCallback(Advertiser.StopResponse callback) {
this.mCallback = callback;
}
@Override
public boolean accept(org.chromium.mojo.bindings.Message message) {
try {
org.chromium.mojo.bindings.ServiceMessage messageWithHeader =
message.asServiceMessage();
org.chromium.mojo.bindings.MessageHeader header = messageWithHeader.getHeader();
if (!header.validateHeader(STOP_ORDINAL,
org.chromium.mojo.bindings.MessageHeader.MESSAGE_IS_RESPONSE_FLAG)) {
return false;
}
AdvertiserStopResponseParams response = AdvertiserStopResponseParams.deserialize(messageWithHeader.getPayload());
mCallback.call(response.err);
return true;
} catch (org.chromium.mojo.bindings.DeserializationException e) {
return false;
}
}
}
static class AdvertiserStopResponseParamsProxyToResponder implements Advertiser.StopResponse {
private final org.chromium.mojo.system.Core mCore;
private final org.chromium.mojo.bindings.MessageReceiver mMessageReceiver;
private final long mRequestId;
AdvertiserStopResponseParamsProxyToResponder(
org.chromium.mojo.system.Core core,
org.chromium.mojo.bindings.MessageReceiver messageReceiver,
long requestId) {
mCore = core;
mMessageReceiver = messageReceiver;
mRequestId = requestId;
}
@Override
public void call(Error err) {
AdvertiserStopResponseParams _response = new AdvertiserStopResponseParams();
_response.err = err;
org.chromium.mojo.bindings.ServiceMessage _message =
_response.serializeWithHeader(
mCore,
new org.chromium.mojo.bindings.MessageHeader(
STOP_ORDINAL,
org.chromium.mojo.bindings.MessageHeader.MESSAGE_IS_RESPONSE_FLAG,
mRequestId));
mMessageReceiver.accept(_message);
}
}
}