blob: ba66d9452da3c4c00d0e7cab215aa487bde19091 [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/buffer_then_heap_allocator.h>
#include <lib/fidl/llcpp/coding.h>
#include <lib/fidl/llcpp/envelope.h>
#include <lib/fidl/llcpp/errors.h>
#include <lib/fidl/llcpp/linearized_and_encoded.h>
#include <lib/fidl/llcpp/memory.h>
#include <lib/fidl/llcpp/message.h>
#include <lib/fidl/llcpp/string_view.h>
#include <lib/fidl/llcpp/tracking_ptr.h>
#include <lib/fidl/llcpp/traits.h>
#include <lib/fidl/llcpp/vector_view.h>
#include <lib/fit/function.h>
#include <lib/fit/optional.h>
#include <variant>
#ifdef __Fuchsia__
#include <lib/fidl/llcpp/client.h>
#include <lib/fidl/llcpp/connect_service.h>
#include <lib/fidl/llcpp/result.h>
#include <lib/fidl/llcpp/server.h>
#include <lib/fidl/llcpp/service_handler_interface.h>
#include <lib/fidl/llcpp/sync_call.h>
#include <lib/fidl/llcpp/transaction.h>
#include <lib/fidl/txn_header.h>
#endif // __Fuchsia__
#include <zircon/fidl.h>
namespace llcpp {
namespace fidl {
namespace test {
namespace json {
struct Simple;
struct BasicStruct;
extern "C" const fidl_type_t fidl_test_json_SimpleTable;
struct Simple {
static constexpr const fidl_type_t* Type = &fidl_test_json_SimpleTable;
static constexpr uint32_t MaxNumHandles = 0;
static constexpr uint32_t PrimarySize = 2;
[[maybe_unused]] static constexpr uint32_t MaxOutOfLine = 0;
static constexpr bool HasPointer = false;
static constexpr bool IsResource = false;
uint8_t f1 = {};
bool f2 = {};
void _CloseHandles();
class UnownedOutgoingMessage final {
public:
UnownedOutgoingMessage(uint8_t* bytes, uint32_t byte_size, Simple* value)
: message_(bytes, byte_size, sizeof(Simple), nullptr, 0, 0) {
message_.LinearizeAndEncode<Simple>(value);
}
UnownedOutgoingMessage(const UnownedOutgoingMessage&) = delete;
UnownedOutgoingMessage(UnownedOutgoingMessage&&) = delete;
UnownedOutgoingMessage* operator=(const UnownedOutgoingMessage&) = delete;
UnownedOutgoingMessage* operator=(UnownedOutgoingMessage&&) = delete;
zx_status_t status() const { return message_.status(); }
bool ok() const { return message_.status() == ZX_OK; }
const char* error() const { return message_.error(); }
::fidl::OutgoingMessage& GetOutgoingMessage() { return message_; }
private:
::fidl::OutgoingMessage message_;
};
class OwnedOutgoingMessage final {
public:
explicit OwnedOutgoingMessage(Simple* value)
: message_(bytes_, sizeof(bytes_), value) {}
OwnedOutgoingMessage(const OwnedOutgoingMessage&) = delete;
OwnedOutgoingMessage(OwnedOutgoingMessage&&) = delete;
OwnedOutgoingMessage* operator=(const OwnedOutgoingMessage&) = delete;
OwnedOutgoingMessage* operator=(OwnedOutgoingMessage&&) = delete;
zx_status_t status() const { return message_.status(); }
bool ok() const { return message_.ok(); }
const char* error() const { return message_.error(); }
::fidl::OutgoingMessage& GetOutgoingMessage() {
return message_.GetOutgoingMessage();
}
private:
FIDL_ALIGNDECL
uint8_t bytes_[PrimarySize + MaxOutOfLine];
UnownedOutgoingMessage message_;
};
class IncomingMessage final : public ::fidl::internal::IncomingMessage {
public:
IncomingMessage(const IncomingMessage&) = delete;
IncomingMessage(IncomingMessage&&) = delete;
IncomingMessage* operator=(const IncomingMessage&) = delete;
IncomingMessage* operator=(IncomingMessage&&) = delete;
struct Simple* PrimaryObject() {
ZX_DEBUG_ASSERT(ok());
return reinterpret_cast<struct Simple*>(bytes());
}
// These methods should only be used for testing purpose.
// They create an IncomingMessage using the bytes of an outgoing message and
// copying the handles.
static IncomingMessage FromOutgoingWithRawHandleCopy(
UnownedOutgoingMessage* outgoing_message) {
return IncomingMessage(outgoing_message->GetOutgoingMessage());
}
static IncomingMessage FromOutgoingWithRawHandleCopy(
OwnedOutgoingMessage* outgoing_message) {
return IncomingMessage(outgoing_message->GetOutgoingMessage());
}
private:
IncomingMessage(::fidl::OutgoingMessage& outgoing_message) {
Init(outgoing_message, nullptr, 0);
if (ok()) {
Decode<struct Simple>();
}
}
};
};
extern "C" const fidl_type_t fidl_test_json_BasicStructTable;
struct BasicStruct {
static constexpr const fidl_type_t* Type = &fidl_test_json_BasicStructTable;
static constexpr uint32_t MaxNumHandles = 0;
static constexpr uint32_t PrimarySize = 24;
[[maybe_unused]] static constexpr uint32_t MaxOutOfLine = 4294967295;
static constexpr bool HasPointer = true;
static constexpr bool IsResource = false;
uint32_t x = {};
::fidl::StringView y = {};
void _CloseHandles();
class UnownedOutgoingMessage final {
public:
UnownedOutgoingMessage(uint8_t* bytes, uint32_t byte_size,
BasicStruct* value)
: message_(bytes, byte_size, sizeof(BasicStruct), nullptr, 0, 0) {
message_.LinearizeAndEncode<BasicStruct>(value);
}
UnownedOutgoingMessage(const UnownedOutgoingMessage&) = delete;
UnownedOutgoingMessage(UnownedOutgoingMessage&&) = delete;
UnownedOutgoingMessage* operator=(const UnownedOutgoingMessage&) = delete;
UnownedOutgoingMessage* operator=(UnownedOutgoingMessage&&) = delete;
zx_status_t status() const { return message_.status(); }
bool ok() const { return message_.status() == ZX_OK; }
const char* error() const { return message_.error(); }
::fidl::OutgoingMessage& GetOutgoingMessage() { return message_; }
private:
::fidl::OutgoingMessage message_;
};
class OwnedOutgoingMessage final {
public:
explicit OwnedOutgoingMessage(BasicStruct* value)
: bytes_(std::make_unique<
::fidl::internal::AlignedBuffer<ZX_CHANNEL_MAX_MSG_BYTES>>()),
message_(bytes_->data(), ZX_CHANNEL_MAX_MSG_BYTES, value) {}
OwnedOutgoingMessage(const OwnedOutgoingMessage&) = delete;
OwnedOutgoingMessage(OwnedOutgoingMessage&&) = delete;
OwnedOutgoingMessage* operator=(const OwnedOutgoingMessage&) = delete;
OwnedOutgoingMessage* operator=(OwnedOutgoingMessage&&) = delete;
zx_status_t status() const { return message_.status(); }
bool ok() const { return message_.ok(); }
const char* error() const { return message_.error(); }
::fidl::OutgoingMessage& GetOutgoingMessage() {
return message_.GetOutgoingMessage();
}
private:
std::unique_ptr<::fidl::internal::AlignedBuffer<ZX_CHANNEL_MAX_MSG_BYTES>>
bytes_;
UnownedOutgoingMessage message_;
};
class IncomingMessage final : public ::fidl::internal::IncomingMessage {
public:
IncomingMessage(const IncomingMessage&) = delete;
IncomingMessage(IncomingMessage&&) = delete;
IncomingMessage* operator=(const IncomingMessage&) = delete;
IncomingMessage* operator=(IncomingMessage&&) = delete;
struct BasicStruct* PrimaryObject() {
ZX_DEBUG_ASSERT(ok());
return reinterpret_cast<struct BasicStruct*>(bytes());
}
// These methods should only be used for testing purpose.
// They create an IncomingMessage using the bytes of an outgoing message and
// copying the handles.
static IncomingMessage FromOutgoingWithRawHandleCopy(
UnownedOutgoingMessage* outgoing_message) {
return IncomingMessage(outgoing_message->GetOutgoingMessage());
}
static IncomingMessage FromOutgoingWithRawHandleCopy(
OwnedOutgoingMessage* outgoing_message) {
return IncomingMessage(outgoing_message->GetOutgoingMessage());
}
private:
IncomingMessage(::fidl::OutgoingMessage& outgoing_message) {
Init(outgoing_message, nullptr, 0);
if (ok()) {
Decode<struct BasicStruct>();
}
}
};
};
} // namespace json
} // namespace test
} // namespace fidl
} // namespace llcpp
namespace fidl {
template <>
struct IsFidlType<::llcpp::fidl::test::json::Simple> : public std::true_type {};
template <>
struct IsStruct<::llcpp::fidl::test::json::Simple> : public std::true_type {};
static_assert(std::is_standard_layout_v<::llcpp::fidl::test::json::Simple>);
static_assert(offsetof(::llcpp::fidl::test::json::Simple, f1) == 0);
static_assert(offsetof(::llcpp::fidl::test::json::Simple, f2) == 1);
static_assert(sizeof(::llcpp::fidl::test::json::Simple) ==
::llcpp::fidl::test::json::Simple::PrimarySize);
template <>
struct IsFidlType<::llcpp::fidl::test::json::BasicStruct>
: public std::true_type {};
template <>
struct IsStruct<::llcpp::fidl::test::json::BasicStruct>
: public std::true_type {};
static_assert(
std::is_standard_layout_v<::llcpp::fidl::test::json::BasicStruct>);
static_assert(offsetof(::llcpp::fidl::test::json::BasicStruct, x) == 0);
static_assert(offsetof(::llcpp::fidl::test::json::BasicStruct, y) == 8);
static_assert(sizeof(::llcpp::fidl::test::json::BasicStruct) ==
::llcpp::fidl::test::json::BasicStruct::PrimarySize);
} // namespace fidl
namespace llcpp {
namespace fidl {
namespace test {
namespace json {} // namespace json
} // namespace test
} // namespace fidl
} // namespace llcpp