| // 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/memory.h> |
| #include <lib/fidl/llcpp/message.h> |
| #include <lib/fidl/llcpp/message_storage.h> |
| #include <lib/fidl/llcpp/object_view.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 <algorithm> |
| #include <cstddef> |
| #include <variant> |
| #ifdef __Fuchsia__ |
| #include <lib/fidl/llcpp/client.h> |
| #include <lib/fidl/llcpp/client_end.h> |
| #include <lib/fidl/llcpp/connect_service.h> |
| #include <lib/fidl/llcpp/result.h> |
| #include <lib/fidl/llcpp/server.h> |
| #include <lib/fidl/llcpp/server_end.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 <dependent/llcpp/fidl.h> |
| #include <zircon/fidl.h> |
| |
| namespace llcpp { |
| |
| namespace fidl { |
| namespace test { |
| namespace structdefaultvalueenumlibraryreference { |
| |
| struct Foo; |
| |
| extern "C" const fidl_type_t |
| fidl_test_structdefaultvalueenumlibraryreference_FooTable; |
| |
| struct Foo { |
| static constexpr const fidl_type_t* Type = |
| &fidl_test_structdefaultvalueenumlibraryreference_FooTable; |
| 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; |
| |
| ::llcpp::dependent::MyEnum field = {}; |
| |
| class UnownedEncodedMessage final { |
| public: |
| UnownedEncodedMessage(uint8_t* bytes, uint32_t byte_size, Foo* value) |
| : message_(bytes, byte_size, sizeof(Foo), nullptr, 0, 0) { |
| message_.LinearizeAndEncode<Foo>(value); |
| } |
| UnownedEncodedMessage(const UnownedEncodedMessage&) = delete; |
| UnownedEncodedMessage(UnownedEncodedMessage&&) = delete; |
| UnownedEncodedMessage* operator=(const UnownedEncodedMessage&) = delete; |
| UnownedEncodedMessage* operator=(UnownedEncodedMessage&&) = delete; |
| |
| zx_status_t status() const { return message_.status(); } |
| #ifdef __Fuchsia__ |
| const char* status_string() const { return message_.status_string(); } |
| #endif |
| 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 OwnedEncodedMessage final { |
| public: |
| explicit OwnedEncodedMessage(Foo* value) |
| : message_(bytes_, sizeof(bytes_), value) {} |
| OwnedEncodedMessage(const OwnedEncodedMessage&) = delete; |
| OwnedEncodedMessage(OwnedEncodedMessage&&) = delete; |
| OwnedEncodedMessage* operator=(const OwnedEncodedMessage&) = delete; |
| OwnedEncodedMessage* operator=(OwnedEncodedMessage&&) = delete; |
| |
| zx_status_t status() const { return message_.status(); } |
| #ifdef __Fuchsia__ |
| const char* status_string() const { return message_.status_string(); } |
| #endif |
| 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_[FIDL_ALIGN(PrimarySize + MaxOutOfLine)]; |
| UnownedEncodedMessage message_; |
| }; |
| |
| class DecodedMessage final : public ::fidl::internal::IncomingMessage { |
| public: |
| DecodedMessage(uint8_t* bytes, uint32_t byte_actual, |
| zx_handle_info_t* handles = nullptr, |
| uint32_t handle_actual = 0) |
| : ::fidl::internal::IncomingMessage(bytes, byte_actual, handles, |
| handle_actual) { |
| Decode<struct Foo>(); |
| } |
| DecodedMessage(fidl_incoming_msg_t* msg) |
| : ::fidl::internal::IncomingMessage(msg) { |
| Decode<struct Foo>(); |
| } |
| DecodedMessage(const DecodedMessage&) = delete; |
| DecodedMessage(DecodedMessage&&) = delete; |
| DecodedMessage* operator=(const DecodedMessage&) = delete; |
| DecodedMessage* operator=(DecodedMessage&&) = delete; |
| |
| struct Foo* PrimaryObject() { |
| ZX_DEBUG_ASSERT(ok()); |
| return reinterpret_cast<struct Foo*>(bytes()); |
| } |
| |
| // Release the ownership of the decoded message. That means that the handles |
| // won't be closed When the object is destroyed. After calling this method, |
| // the DecodedMessage object should not be used anymore. |
| void ReleasePrimaryObject() { ResetBytes(); } |
| |
| // These methods should only be used for testing purpose. |
| // They create an DecodedMessage using the bytes of an outgoing message and |
| // copying the handles. |
| static DecodedMessage FromOutgoingWithRawHandleCopy( |
| UnownedEncodedMessage* encoded_message) { |
| return DecodedMessage(encoded_message->GetOutgoingMessage()); |
| } |
| static DecodedMessage FromOutgoingWithRawHandleCopy( |
| OwnedEncodedMessage* encoded_message) { |
| return DecodedMessage(encoded_message->GetOutgoingMessage()); |
| } |
| |
| private: |
| DecodedMessage(::fidl::OutgoingMessage& outgoing_message) { |
| Init(outgoing_message, nullptr, 0); |
| if (ok()) { |
| Decode<struct Foo>(); |
| } |
| } |
| }; |
| }; |
| |
| } // namespace structdefaultvalueenumlibraryreference |
| } // namespace test |
| } // namespace fidl |
| } // namespace llcpp |
| |
| namespace fidl { |
| |
| template <> |
| struct IsFidlType< |
| ::llcpp::fidl::test::structdefaultvalueenumlibraryreference::Foo> |
| : public std::true_type {}; |
| template <> |
| struct IsStruct< |
| ::llcpp::fidl::test::structdefaultvalueenumlibraryreference::Foo> |
| : public std::true_type {}; |
| static_assert( |
| std::is_standard_layout_v< |
| ::llcpp::fidl::test::structdefaultvalueenumlibraryreference::Foo>); |
| static_assert( |
| offsetof(::llcpp::fidl::test::structdefaultvalueenumlibraryreference::Foo, |
| field) == 0); |
| static_assert( |
| sizeof(::llcpp::fidl::test::structdefaultvalueenumlibraryreference::Foo) == |
| ::llcpp::fidl::test::structdefaultvalueenumlibraryreference::Foo:: |
| PrimarySize); |
| |
| } // namespace fidl |
| |
| namespace llcpp { |
| |
| namespace fidl { |
| namespace test { |
| namespace structdefaultvalueenumlibraryreference { |
| |
| } // namespace structdefaultvalueenumlibraryreference |
| } // namespace test |
| } // namespace fidl |
| } // namespace llcpp |