blob: 8b8f8919299a7f4658637b1b0e139296e5375fda [file] [log] [blame]
// WARNING: This file is machine generated by fidlgen.
#pragma once
#include <lib/fidl/internal.h>
#include <lib/fidl/llcpp/array.h>
#include <lib/fidl/llcpp/buffer_allocator.h>
#include <lib/fidl/llcpp/coding.h>
#include <lib/fidl/llcpp/connect_service.h>
#include <lib/fidl/llcpp/envelope.h>
#include <lib/fidl/llcpp/memory.h>
#include <lib/fidl/llcpp/service_handler_interface.h>
#include <lib/fidl/llcpp/string_view.h>
#include <lib/fidl/llcpp/sync_call.h>
#include <lib/fidl/llcpp/tracking_ptr.h>
#include <lib/fidl/llcpp/traits.h>
#include <lib/fidl/llcpp/transaction.h>
#include <lib/fidl/llcpp/vector_view.h>
#include <lib/fidl/txn_header.h>
#include <lib/fit/function.h>
#include <lib/zx/channel.h>
#include <lib/zx/vmo.h>
#include <zircon/fidl.h>
namespace llcpp {
namespace fidl {
namespace test {
namespace nullable {
struct StructWithNullableVector;
struct StructWithNullableUnion;
struct StructWithNullableStruct;
struct StructWithNullableString;
struct StructWithNullableRequest;
struct StructWithNullableProtocol;
struct StructWithNullableHandle;
class SimpleProtocol;
class SimpleUnion;
struct Int32Wrapper;
extern "C" const fidl_type_t v1_fidl_test_nullable_SimpleUnionTable;
class SimpleUnion {
public:
SimpleUnion() : ordinal_(Ordinal::Invalid), envelope_{} {}
SimpleUnion(SimpleUnion&&) = default;
SimpleUnion& operator=(SimpleUnion&&) = default;
~SimpleUnion() { reset_ptr(nullptr); }
enum class Tag : fidl_xunion_tag_t {
kA = 1, // 0x1
kB = 2, // 0x2
};
bool has_invalid_tag() const { return ordinal_ == Ordinal::Invalid; }
bool is_a() const { return ordinal_ == Ordinal::kA; }
static SimpleUnion WithA(::fidl::tracking_ptr<int32_t>&& val) {
SimpleUnion result;
result.set_a(std::move(val));
return result;
}
void set_a(::fidl::tracking_ptr<int32_t>&& elem) {
ordinal_ = Ordinal::kA;
reset_ptr(static_cast<::fidl::tracking_ptr<void>>(std::move(elem)));
}
int32_t& mutable_a() {
ZX_ASSERT(ordinal_ == Ordinal::kA);
return *static_cast<int32_t*>(envelope_.data.get());
}
const int32_t& a() const {
ZX_ASSERT(ordinal_ == Ordinal::kA);
return *static_cast<int32_t*>(envelope_.data.get());
}
bool is_b() const { return ordinal_ == Ordinal::kB; }
static SimpleUnion WithB(::fidl::tracking_ptr<float>&& val) {
SimpleUnion result;
result.set_b(std::move(val));
return result;
}
void set_b(::fidl::tracking_ptr<float>&& elem) {
ordinal_ = Ordinal::kB;
reset_ptr(static_cast<::fidl::tracking_ptr<void>>(std::move(elem)));
}
float& mutable_b() {
ZX_ASSERT(ordinal_ == Ordinal::kB);
return *static_cast<float*>(envelope_.data.get());
}
const float& b() const {
ZX_ASSERT(ordinal_ == Ordinal::kB);
return *static_cast<float*>(envelope_.data.get());
}
Tag which() const {
ZX_ASSERT(!has_invalid_tag());
return static_cast<Tag>(ordinal_);
}
static constexpr const fidl_type_t* Type =
&v1_fidl_test_nullable_SimpleUnionTable;
static constexpr uint32_t MaxNumHandles = 0;
static constexpr uint32_t PrimarySize = 24;
[[maybe_unused]] static constexpr uint32_t MaxOutOfLine = 8;
static constexpr bool HasPointer = true;
private:
enum class Ordinal : fidl_xunion_tag_t {
Invalid = 0,
kA = 1, // 0x1
kB = 2, // 0x2
};
void reset_ptr(::fidl::tracking_ptr<void>&& new_ptr) {
// To clear the existing value, std::move it and let it go out of scope.
switch (static_cast<fidl_xunion_tag_t>(ordinal_)) {
case 1: {
::fidl::tracking_ptr<int32_t> to_destroy =
static_cast<::fidl::tracking_ptr<int32_t>>(
std::move(envelope_.data));
break;
}
case 2: {
::fidl::tracking_ptr<float> to_destroy =
static_cast<::fidl::tracking_ptr<float>>(std::move(envelope_.data));
break;
}
}
envelope_.data = std::move(new_ptr);
}
static void SizeAndOffsetAssertionHelper();
Ordinal ordinal_;
FIDL_ALIGNDECL
::fidl::Envelope<void> envelope_;
};
extern "C" const fidl_type_t
v1_fidl_test_nullable_StructWithNullableVectorTable;
struct StructWithNullableVector {
static constexpr const fidl_type_t* Type =
&v1_fidl_test_nullable_StructWithNullableVectorTable;
static constexpr uint32_t MaxNumHandles = 0;
static constexpr uint32_t PrimarySize = 16;
[[maybe_unused]] static constexpr uint32_t MaxOutOfLine = 4294967295;
static constexpr bool HasPointer = true;
::fidl::VectorView<int32_t> val = {};
};
extern "C" const fidl_type_t v1_fidl_test_nullable_StructWithNullableUnionTable;
struct StructWithNullableUnion {
static constexpr const fidl_type_t* Type =
&v1_fidl_test_nullable_StructWithNullableUnionTable;
static constexpr uint32_t MaxNumHandles = 0;
static constexpr uint32_t PrimarySize = 24;
[[maybe_unused]] static constexpr uint32_t MaxOutOfLine = 8;
static constexpr bool HasPointer = true;
::llcpp::fidl::test::nullable::SimpleUnion val = {};
};
extern "C" const fidl_type_t
v1_fidl_test_nullable_StructWithNullableStructTable;
struct StructWithNullableStruct {
static constexpr const fidl_type_t* Type =
&v1_fidl_test_nullable_StructWithNullableStructTable;
static constexpr uint32_t MaxNumHandles = 0;
static constexpr uint32_t PrimarySize = 8;
[[maybe_unused]] static constexpr uint32_t MaxOutOfLine = 8;
static constexpr bool HasPointer = true;
::fidl::tracking_ptr<::llcpp::fidl::test::nullable::Int32Wrapper> val = {};
};
extern "C" const fidl_type_t
v1_fidl_test_nullable_StructWithNullableStringTable;
struct StructWithNullableString {
static constexpr const fidl_type_t* Type =
&v1_fidl_test_nullable_StructWithNullableStringTable;
static constexpr uint32_t MaxNumHandles = 0;
static constexpr uint32_t PrimarySize = 16;
[[maybe_unused]] static constexpr uint32_t MaxOutOfLine = 4294967295;
static constexpr bool HasPointer = true;
::fidl::StringView val = {};
};
extern "C" const fidl_type_t
v1_fidl_test_nullable_StructWithNullableRequestTable;
struct StructWithNullableRequest {
static constexpr const fidl_type_t* Type =
&v1_fidl_test_nullable_StructWithNullableRequestTable;
static constexpr uint32_t MaxNumHandles = 1;
static constexpr uint32_t PrimarySize = 4;
[[maybe_unused]] static constexpr uint32_t MaxOutOfLine = 0;
static constexpr bool HasPointer = false;
::zx::channel val = {};
};
extern "C" const fidl_type_t
v1_fidl_test_nullable_StructWithNullableProtocolTable;
struct StructWithNullableProtocol {
static constexpr const fidl_type_t* Type =
&v1_fidl_test_nullable_StructWithNullableProtocolTable;
static constexpr uint32_t MaxNumHandles = 1;
static constexpr uint32_t PrimarySize = 4;
[[maybe_unused]] static constexpr uint32_t MaxOutOfLine = 0;
static constexpr bool HasPointer = false;
::zx::channel val = {};
};
extern "C" const fidl_type_t
v1_fidl_test_nullable_StructWithNullableHandleTable;
struct StructWithNullableHandle {
static constexpr const fidl_type_t* Type =
&v1_fidl_test_nullable_StructWithNullableHandleTable;
static constexpr uint32_t MaxNumHandles = 1;
static constexpr uint32_t PrimarySize = 4;
[[maybe_unused]] static constexpr uint32_t MaxOutOfLine = 0;
static constexpr bool HasPointer = false;
::zx::vmo val = {};
};
extern "C" const fidl_type_t
v1_fidl_test_nullable_SimpleProtocolAddRequestTable;
extern "C" const fidl_type_t
v1_fidl_test_nullable_SimpleProtocolAddResponseTable;
class SimpleProtocol final {
SimpleProtocol() = delete;
public:
struct AddResponse final {
FIDL_ALIGNDECL
fidl_message_header_t _hdr;
int32_t sum;
static constexpr const fidl_type_t* Type =
&v1_fidl_test_nullable_SimpleProtocolAddResponseTable;
static constexpr uint32_t MaxNumHandles = 0;
static constexpr uint32_t PrimarySize = 24;
static constexpr uint32_t MaxOutOfLine = 0;
static constexpr bool HasFlexibleEnvelope = false;
static constexpr bool HasPointer = false;
static constexpr bool ContainsUnion = false;
static constexpr ::fidl::internal::TransactionalMessageKind MessageKind =
::fidl::internal::TransactionalMessageKind::kResponse;
};
struct AddRequest final {
FIDL_ALIGNDECL
fidl_message_header_t _hdr;
int32_t a;
int32_t b;
static constexpr const fidl_type_t* Type =
&v1_fidl_test_nullable_SimpleProtocolAddRequestTable;
static constexpr uint32_t MaxNumHandles = 0;
static constexpr uint32_t PrimarySize = 24;
static constexpr uint32_t MaxOutOfLine = 0;
static constexpr uint32_t AltPrimarySize = 24;
static constexpr uint32_t AltMaxOutOfLine = 0;
static constexpr bool HasFlexibleEnvelope = false;
static constexpr bool HasPointer = false;
static constexpr bool ContainsUnion = false;
static constexpr ::fidl::internal::TransactionalMessageKind MessageKind =
::fidl::internal::TransactionalMessageKind::kRequest;
using ResponseType = AddResponse;
};
// Collection of return types of FIDL calls in this protocol.
class ResultOf final {
ResultOf() = delete;
private:
template <typename ResponseType>
class Add_Impl final
: private ::fidl::internal::OwnedSyncCallBase<ResponseType> {
using Super = ::fidl::internal::OwnedSyncCallBase<ResponseType>;
public:
Add_Impl(::zx::unowned_channel _client_end, int32_t a, int32_t b);
~Add_Impl() = default;
Add_Impl(Add_Impl&& other) = default;
Add_Impl& operator=(Add_Impl&& other) = default;
using Super::error;
using Super::ok;
using Super::status;
using Super::Unwrap;
using Super::value;
using Super::operator->;
using Super::operator*;
};
public:
using Add = Add_Impl<AddResponse>;
};
// Collection of return types of FIDL calls in this protocol,
// when the caller-allocate flavor or in-place call is used.
class UnownedResultOf final {
UnownedResultOf() = delete;
private:
template <typename ResponseType>
class Add_Impl final
: private ::fidl::internal::UnownedSyncCallBase<ResponseType> {
using Super = ::fidl::internal::UnownedSyncCallBase<ResponseType>;
public:
Add_Impl(::zx::unowned_channel _client_end,
::fidl::BytePart _request_buffer, int32_t a, int32_t b,
::fidl::BytePart _response_buffer);
~Add_Impl() = default;
Add_Impl(Add_Impl&& other) = default;
Add_Impl& operator=(Add_Impl&& other) = default;
using Super::error;
using Super::ok;
using Super::status;
using Super::Unwrap;
using Super::value;
using Super::operator->;
using Super::operator*;
};
public:
using Add = Add_Impl<AddResponse>;
};
class SyncClient final {
public:
SyncClient() = default;
explicit SyncClient(::zx::channel channel) : channel_(std::move(channel)) {}
~SyncClient() = default;
SyncClient(SyncClient&&) = default;
SyncClient& operator=(SyncClient&&) = default;
const ::zx::channel& channel() const { return channel_; }
::zx::channel* mutable_channel() { return &channel_; }
// Allocates 48 bytes of message buffer on the stack. No heap allocation
// necessary.
ResultOf::Add Add(int32_t a, int32_t b);
// Caller provides the backing storage for FIDL message via request and
// response buffers.
UnownedResultOf::Add Add(::fidl::BytePart _request_buffer, int32_t a,
int32_t b, ::fidl::BytePart _response_buffer);
private:
::zx::channel channel_;
};
// Methods to make a sync FIDL call directly on an unowned channel, avoiding
// setting up a client.
class Call final {
Call() = delete;
public:
// Allocates 48 bytes of message buffer on the stack. No heap allocation
// necessary.
static ResultOf::Add Add(::zx::unowned_channel _client_end, int32_t a,
int32_t b);
// Caller provides the backing storage for FIDL message via request and
// response buffers.
static UnownedResultOf::Add Add(::zx::unowned_channel _client_end,
::fidl::BytePart _request_buffer, int32_t a,
int32_t b,
::fidl::BytePart _response_buffer);
};
// Messages are encoded and decoded in-place when these methods are used.
// Additionally, requests must be already laid-out according to the FIDL
// wire-format.
class InPlace final {
InPlace() = delete;
public:
static ::fidl::DecodeResult<AddResponse> Add(
::zx::unowned_channel _client_end,
::fidl::DecodedMessage<AddRequest> params,
::fidl::BytePart response_buffer);
};
// Pure-virtual interface to be implemented by a server.
class Interface {
public:
Interface() = default;
virtual ~Interface() = default;
using _Outer = SimpleProtocol;
using _Base = ::fidl::CompleterBase;
class AddCompleterBase : public _Base {
public:
void Reply(int32_t sum);
void Reply(::fidl::BytePart _buffer, int32_t sum);
void Reply(::fidl::DecodedMessage<AddResponse> params);
protected:
using ::fidl::CompleterBase::CompleterBase;
};
using AddCompleter = ::fidl::Completer<AddCompleterBase>;
virtual void Add(int32_t a, int32_t b, AddCompleter::Sync _completer) = 0;
};
// Attempts to dispatch the incoming message to a handler function in the
// server implementation. If there is no matching handler, it returns false,
// leaving the message and transaction intact. In all other cases, it consumes
// the message and returns true. It is possible to chain multiple TryDispatch
// functions in this manner.
static bool TryDispatch(Interface* impl, fidl_msg_t* msg,
::fidl::Transaction* txn);
// Dispatches the incoming message to one of the handlers functions in the
// protocol. If there is no matching handler, it closes all the handles in
// |msg| and closes the channel with a |ZX_ERR_NOT_SUPPORTED| epitaph, before
// returning false. The message should then be discarded.
static bool Dispatch(Interface* impl, fidl_msg_t* msg,
::fidl::Transaction* txn);
// Same as |Dispatch|, but takes a |void*| instead of |Interface*|. Only used
// with |fidl::Bind| to reduce template expansion. Do not call this method
// manually. Use |Dispatch| instead.
static bool TypeErasedDispatch(void* impl, fidl_msg_t* msg,
::fidl::Transaction* txn) {
return Dispatch(static_cast<Interface*>(impl), msg, txn);
}
// Helper functions to fill in the transaction header in a
// |DecodedMessage<TransactionalMessage>|.
class SetTransactionHeaderFor final {
SetTransactionHeaderFor() = delete;
public:
static void AddRequest(
const ::fidl::DecodedMessage<SimpleProtocol::AddRequest>& _msg);
static void AddResponse(
const ::fidl::DecodedMessage<SimpleProtocol::AddResponse>& _msg);
};
};
extern "C" const fidl_type_t v1_fidl_test_nullable_Int32WrapperTable;
struct Int32Wrapper {
static constexpr const fidl_type_t* Type =
&v1_fidl_test_nullable_Int32WrapperTable;
static constexpr uint32_t MaxNumHandles = 0;
static constexpr uint32_t PrimarySize = 4;
[[maybe_unused]] static constexpr uint32_t MaxOutOfLine = 0;
static constexpr bool HasPointer = false;
int32_t val = {};
};
} // namespace nullable
} // namespace test
} // namespace fidl
} // namespace llcpp
namespace fidl {
template <>
struct IsFidlType<::llcpp::fidl::test::nullable::StructWithNullableVector>
: public std::true_type {};
static_assert(std::is_standard_layout_v<
::llcpp::fidl::test::nullable::StructWithNullableVector>);
static_assert(offsetof(::llcpp::fidl::test::nullable::StructWithNullableVector,
val) == 0);
static_assert(
sizeof(::llcpp::fidl::test::nullable::StructWithNullableVector) ==
::llcpp::fidl::test::nullable::StructWithNullableVector::PrimarySize);
template <>
struct IsFidlType<::llcpp::fidl::test::nullable::StructWithNullableUnion>
: public std::true_type {};
static_assert(std::is_standard_layout_v<
::llcpp::fidl::test::nullable::StructWithNullableUnion>);
static_assert(offsetof(::llcpp::fidl::test::nullable::StructWithNullableUnion,
val) == 0);
static_assert(
sizeof(::llcpp::fidl::test::nullable::StructWithNullableUnion) ==
::llcpp::fidl::test::nullable::StructWithNullableUnion::PrimarySize);
template <>
struct IsFidlType<::llcpp::fidl::test::nullable::StructWithNullableStruct>
: public std::true_type {};
static_assert(std::is_standard_layout_v<
::llcpp::fidl::test::nullable::StructWithNullableStruct>);
static_assert(offsetof(::llcpp::fidl::test::nullable::StructWithNullableStruct,
val) == 0);
static_assert(
sizeof(::llcpp::fidl::test::nullable::StructWithNullableStruct) ==
::llcpp::fidl::test::nullable::StructWithNullableStruct::PrimarySize);
template <>
struct IsFidlType<::llcpp::fidl::test::nullable::StructWithNullableString>
: public std::true_type {};
static_assert(std::is_standard_layout_v<
::llcpp::fidl::test::nullable::StructWithNullableString>);
static_assert(offsetof(::llcpp::fidl::test::nullable::StructWithNullableString,
val) == 0);
static_assert(
sizeof(::llcpp::fidl::test::nullable::StructWithNullableString) ==
::llcpp::fidl::test::nullable::StructWithNullableString::PrimarySize);
template <>
struct IsFidlType<::llcpp::fidl::test::nullable::StructWithNullableRequest>
: public std::true_type {};
static_assert(std::is_standard_layout_v<
::llcpp::fidl::test::nullable::StructWithNullableRequest>);
static_assert(offsetof(::llcpp::fidl::test::nullable::StructWithNullableRequest,
val) == 0);
static_assert(
sizeof(::llcpp::fidl::test::nullable::StructWithNullableRequest) ==
::llcpp::fidl::test::nullable::StructWithNullableRequest::PrimarySize);
template <>
struct IsFidlType<::llcpp::fidl::test::nullable::StructWithNullableProtocol>
: public std::true_type {};
static_assert(std::is_standard_layout_v<
::llcpp::fidl::test::nullable::StructWithNullableProtocol>);
static_assert(
offsetof(::llcpp::fidl::test::nullable::StructWithNullableProtocol, val) ==
0);
static_assert(
sizeof(::llcpp::fidl::test::nullable::StructWithNullableProtocol) ==
::llcpp::fidl::test::nullable::StructWithNullableProtocol::PrimarySize);
template <>
struct IsFidlType<::llcpp::fidl::test::nullable::StructWithNullableHandle>
: public std::true_type {};
static_assert(std::is_standard_layout_v<
::llcpp::fidl::test::nullable::StructWithNullableHandle>);
static_assert(offsetof(::llcpp::fidl::test::nullable::StructWithNullableHandle,
val) == 0);
static_assert(
sizeof(::llcpp::fidl::test::nullable::StructWithNullableHandle) ==
::llcpp::fidl::test::nullable::StructWithNullableHandle::PrimarySize);
template <>
struct IsFidlType<::llcpp::fidl::test::nullable::SimpleProtocol::AddRequest>
: public std::true_type {};
template <>
struct IsFidlMessage<::llcpp::fidl::test::nullable::SimpleProtocol::AddRequest>
: public std::true_type {};
static_assert(
sizeof(::llcpp::fidl::test::nullable::SimpleProtocol::AddRequest) ==
::llcpp::fidl::test::nullable::SimpleProtocol::AddRequest::PrimarySize);
static_assert(
offsetof(::llcpp::fidl::test::nullable::SimpleProtocol::AddRequest, a) ==
16);
static_assert(
offsetof(::llcpp::fidl::test::nullable::SimpleProtocol::AddRequest, b) ==
20);
template <>
struct IsFidlType<::llcpp::fidl::test::nullable::SimpleProtocol::AddResponse>
: public std::true_type {};
template <>
struct IsFidlMessage<::llcpp::fidl::test::nullable::SimpleProtocol::AddResponse>
: public std::true_type {};
static_assert(
sizeof(::llcpp::fidl::test::nullable::SimpleProtocol::AddResponse) ==
::llcpp::fidl::test::nullable::SimpleProtocol::AddResponse::PrimarySize);
static_assert(
offsetof(::llcpp::fidl::test::nullable::SimpleProtocol::AddResponse, sum) ==
16);
template <>
struct IsFidlType<::llcpp::fidl::test::nullable::SimpleUnion>
: public std::true_type {};
static_assert(
std::is_standard_layout_v<::llcpp::fidl::test::nullable::SimpleUnion>);
template <>
struct IsFidlType<::llcpp::fidl::test::nullable::Int32Wrapper>
: public std::true_type {};
static_assert(
std::is_standard_layout_v<::llcpp::fidl::test::nullable::Int32Wrapper>);
static_assert(offsetof(::llcpp::fidl::test::nullable::Int32Wrapper, val) == 0);
static_assert(sizeof(::llcpp::fidl::test::nullable::Int32Wrapper) ==
::llcpp::fidl::test::nullable::Int32Wrapper::PrimarySize);
} // namespace fidl