| // WARNING: This file is machine generated by fidlgen. |
| |
| #pragma once |
| |
| #include "lib/fidl/cpp/internal/header.h" |
| |
| namespace test { |
| namespace name { |
| |
| class Union; |
| class Table; |
| class Struct; |
| #ifdef __Fuchsia__ |
| |
| /// interface comment #1 |
| /// |
| /// interface comment #3 |
| class Interface; |
| using InterfacePtr = ::fidl::InterfacePtr<Interface>; |
| class Interface_Proxy; |
| class Interface_Stub; |
| class Interface_EventSender; |
| class Interface_Sync; |
| using InterfaceSyncPtr = ::fidl::SynchronousInterfacePtr<Interface>; |
| class Interface_SyncProxy; |
| using InterfaceHandle = ::fidl::InterfaceHandle<Interface>; |
| namespace internal { |
| constexpr uint64_t kInterface_Method_Ordinal = 0x3f43684c00000000lu; |
| constexpr uint64_t kInterface_Method_GenOrdinal = 0x60e700e002995ef8lu; |
| constexpr uint64_t kInterface_OnEvent_Ordinal = 0x136d200d00000000lu; |
| constexpr uint64_t kInterface_OnEvent_GenOrdinal = 0x914c226136244edlu; |
| |
| } // namespace internal |
| #endif // __Fuchsia__ |
| #ifdef __Fuchsia__ |
| class Service; |
| #endif // __Fuchsia |
| |
| /// enum comment #1. |
| /// |
| /// enum comment #2. |
| enum class MyEnum : uint32_t { |
| |
| /// enum Member comment 1. |
| FOO = 1u, |
| |
| BAR = 2u, |
| }; |
| |
| inline zx_status_t Clone(::test::name::MyEnum value, |
| ::test::name::MyEnum* result) { |
| *result = value; |
| return ZX_OK; |
| } |
| |
| /// bits comment #1 |
| /// |
| /// bits comment #2 |
| enum class MyBits : uint32_t { |
| |
| /// bits member comment #1 |
| /// |
| /// bits member comment #3 |
| MY_FIRST_BIT = 1u, |
| |
| MY_OTHER_BIT = 2u, |
| }; |
| |
| const static MyBits MyBitsMask = static_cast<MyBits>(3u); |
| |
| inline zx_status_t Clone(::test::name::MyBits value, |
| ::test::name::MyBits* result) { |
| *result = value; |
| return ZX_OK; |
| } |
| |
| constexpr inline ::test::name::MyBits operator|(::test::name::MyBits _lhs, |
| ::test::name::MyBits _rhs) { |
| return static_cast<::test::name::MyBits>(static_cast<uint32_t>(_lhs) | |
| static_cast<uint32_t>(_rhs)); |
| } |
| |
| constexpr inline ::test::name::MyBits& operator|=(::test::name::MyBits& _lhs, |
| ::test::name::MyBits _rhs) { |
| _lhs = _lhs | _rhs; |
| return _lhs; |
| } |
| |
| constexpr inline ::test::name::MyBits operator&(::test::name::MyBits _lhs, |
| ::test::name::MyBits _rhs) { |
| return static_cast<::test::name::MyBits>(static_cast<uint32_t>(_lhs) & |
| static_cast<uint32_t>(_rhs)); |
| } |
| |
| constexpr inline ::test::name::MyBits& operator&=(::test::name::MyBits& _lhs, |
| ::test::name::MyBits _rhs) { |
| _lhs = _lhs & _rhs; |
| return _lhs; |
| } |
| |
| constexpr inline ::test::name::MyBits operator^(::test::name::MyBits _lhs, |
| ::test::name::MyBits _rhs) { |
| return static_cast<::test::name::MyBits>(static_cast<uint32_t>(_lhs) ^ |
| static_cast<uint32_t>(_rhs)); |
| } |
| |
| constexpr inline ::test::name::MyBits& operator^=(::test::name::MyBits& _lhs, |
| ::test::name::MyBits _rhs) { |
| _lhs = _lhs ^ _rhs; |
| return _lhs; |
| } |
| |
| constexpr inline ::test::name::MyBits operator~(::test::name::MyBits _value) { |
| return static_cast<::test::name::MyBits>(~static_cast<uint32_t>(_value) & |
| static_cast<uint32_t>(MyBitsMask)); |
| } |
| |
| /// union comment #1 |
| /// |
| /// union comment #3 |
| class Union final { |
| public: |
| static const fidl_type_t* FidlType; |
| |
| Union(); |
| ~Union(); |
| |
| Union(Union&&); |
| Union& operator=(Union&&); |
| |
| static Union WithField(int32_t&&); |
| |
| enum __attribute__((enum_extensibility(closed))) Tag : fidl_xunion_tag_t { |
| |
| kField = 1, // 0x1 |
| Invalid = ::std::numeric_limits<::fidl_union_tag_t>::max(), |
| }; |
| |
| static inline ::std::unique_ptr<Union> New() { |
| return ::std::make_unique<Union>(); |
| } |
| |
| void Encode(::fidl::Encoder* encoder, size_t offset); |
| static void Decode(::fidl::Decoder* decoder, Union* value, size_t offset); |
| zx_status_t Clone(Union* result) const; |
| |
| bool has_invalid_tag() const { return tag_ == Invalid; } |
| |
| bool is_Field() const { return tag_ == Tag::kField; } |
| |
| /// union member comment #1 |
| /// |
| /// union member comment #3 |
| int32_t& Field() { |
| EnsureStorageInitialized(Tag::kField); |
| return Field_; |
| } |
| |
| /// union member comment #1 |
| /// |
| /// union member comment #3 |
| const int32_t& Field() const { |
| ZX_ASSERT(is_Field()); |
| return Field_; |
| } |
| Union& set_Field(int32_t value); |
| |
| Tag Which() const { return Tag(tag_); } |
| |
| // You probably want to use Which() method instead of Ordinal(). Use Ordinal() |
| // only when you need access to the raw integral ordinal value. |
| fidl_xunion_tag_t Ordinal() const { return tag_; } |
| |
| const std::vector<uint8_t>* UnknownData() const { return nullptr; } |
| |
| friend ::fidl::Equality<::test::name::Union>; |
| |
| private: |
| void Destroy(); |
| void EnsureStorageInitialized(::fidl_xunion_tag_t tag); |
| |
| ::fidl_xunion_tag_t tag_ = static_cast<fidl_xunion_tag_t>(Tag::Invalid); |
| union { |
| int32_t Field_; |
| }; |
| }; |
| |
| inline zx_status_t Clone(const ::test::name::Union& value, |
| ::test::name::Union* result) { |
| return value.Clone(result); |
| } |
| |
| using UnionPtr = ::std::unique_ptr<Union>; |
| |
| /// table comment #1 |
| /// |
| /// table comment #3 |
| class Table final { |
| public: |
| static const fidl_type_t* FidlType; |
| /// Returns whether no field is set. |
| bool IsEmpty() const; |
| |
| /// table field comment #1 |
| /// |
| /// table field comment #3 |
| const int32_t& Field() const { |
| ZX_ASSERT(has_Field_); |
| return Field_value_.value; |
| } |
| bool has_Field() const { return has_Field_; } |
| |
| /// table field comment #1 |
| /// |
| /// table field comment #3 |
| int32_t* mutable_Field() { |
| if (!has_Field_) { |
| has_Field_ = true; |
| Construct(&Field_value_.value); |
| } |
| return &Field_value_.value; |
| } |
| Table& set_Field(int32_t _value) { |
| if (!has_Field_) { |
| has_Field_ = true; |
| Construct(&Field_value_.value, std::move(_value)); |
| } else { |
| Field_value_.value = std::move(_value); |
| } |
| return *this; |
| } |
| void clear_Field() { |
| if (!has_Field_) { |
| return; |
| } |
| has_Field_ = false; |
| Destruct(&Field_value_.value); |
| } |
| |
| Table(); |
| Table(Table&& other); |
| ~Table(); |
| Table& operator=(Table&& other); |
| |
| static inline ::std::unique_ptr<Table> New() { |
| return ::std::make_unique<Table>(); |
| } |
| |
| void Encode(::fidl::Encoder* _encoder, size_t _offset); |
| static void Decode(::fidl::Decoder* _decoder, Table* _value, size_t _offset); |
| zx_status_t Clone(Table* _result) const; |
| |
| private: |
| template <class T, class... Args> |
| void Construct(T* p, Args&&... args) { |
| new (p) T(std::forward<Args>(args)...); |
| } |
| |
| template <class T> |
| void Destruct(T* p) { |
| p->~T(); |
| } |
| bool has_Field_ : 1; |
| union ValueUnion_Field { |
| ValueUnion_Field() {} |
| ~ValueUnion_Field() {} |
| |
| int32_t value; |
| }; |
| ValueUnion_Field Field_value_; |
| }; |
| |
| using TablePtr = ::std::unique_ptr<Table>; |
| |
| /// struct comment #1 |
| /// |
| /// struct comment #3 |
| class Struct final { |
| public: |
| static const fidl_type_t* FidlType; |
| |
| /// struct member comment #1 |
| /// |
| /// struct member comment #3 |
| int32_t Field{}; |
| |
| static inline ::std::unique_ptr<Struct> New() { |
| return ::std::make_unique<Struct>(); |
| } |
| |
| void Encode(::fidl::Encoder* _encoder, size_t _offset); |
| static void Decode(::fidl::Decoder* _decoder, Struct* value, size_t _offset); |
| zx_status_t Clone(Struct* result) const; |
| }; |
| |
| inline zx_status_t Clone(const ::test::name::Struct& _value, |
| ::test::name::Struct* _result) { |
| return _value.Clone(_result); |
| } |
| |
| using StructPtr = ::std::unique_ptr<Struct>; |
| #ifdef __Fuchsia__ |
| |
| /// interface comment #1 |
| /// |
| /// interface comment #3 |
| class Interface { |
| public: |
| using Proxy_ = Interface_Proxy; |
| using Stub_ = Interface_Stub; |
| using EventSender_ = Interface_EventSender; |
| using Sync_ = Interface_Sync; |
| virtual ~Interface(); |
| |
| /// method comment #1 |
| /// |
| /// method comment #3 |
| virtual void Method() = 0; |
| using OnEventCallback = fit::function<void()>; |
| }; |
| |
| class Interface_RequestEncoder { |
| public: |
| static ::fidl::Message Method(::fidl::Encoder* _encoder) { |
| _encoder->Alloc(16 - sizeof(fidl_message_header_t)); |
| return _encoder->GetMessage(); |
| } |
| }; |
| |
| class Interface_RequestDecoder { |
| public: |
| Interface_RequestDecoder() = default; |
| virtual ~Interface_RequestDecoder() = default; |
| static const fidl_type_t* GetType(uint64_t ordinal, bool* out_needs_response); |
| zx_status_t Decode_(::fidl::Message request) { |
| bool needs_response; |
| const fidl_type_t* request_type = |
| GetType(request.ordinal(), &needs_response); |
| if (request_type == nullptr) { |
| return ZX_ERR_NOT_SUPPORTED; |
| } |
| const char* error_msg = nullptr; |
| zx_status_t status = request.Decode(request_type, &error_msg); |
| if (status != ZX_OK) { |
| FIDL_REPORT_DECODING_ERROR(request, request_type, error_msg); |
| return status; |
| } |
| ::fidl::Decoder request_decoder(std::move(request)); |
| switch (request.ordinal()) { |
| case internal::kInterface_Method_Ordinal: |
| case internal::kInterface_Method_GenOrdinal: { |
| Method(); |
| break; |
| } |
| default: { |
| status = ZX_ERR_NOT_SUPPORTED; |
| break; |
| } |
| } |
| return status; |
| } |
| virtual void Method() = 0; |
| }; |
| |
| class Interface_ResponseEncoder { |
| public: |
| static ::fidl::Message OnEvent(::fidl::Encoder* _encoder) { |
| _encoder->Alloc(16 - sizeof(fidl_message_header_t)); |
| return _encoder->GetMessage(); |
| } |
| }; |
| |
| class Interface_ResponseDecoder { |
| public: |
| Interface_ResponseDecoder() = default; |
| virtual ~Interface_ResponseDecoder() = default; |
| static const fidl_type_t* GetType(uint64_t ordinal); |
| zx_status_t Decode_(::fidl::Message response) { |
| const fidl_type_t* response_type = GetType(response.ordinal()); |
| if (response_type == nullptr) { |
| return ZX_ERR_NOT_SUPPORTED; |
| } |
| const char* error_msg = nullptr; |
| zx_status_t status = response.Decode(response_type, &error_msg); |
| if (status != ZX_OK) { |
| FIDL_REPORT_DECODING_ERROR(response, response_type, error_msg); |
| return status; |
| } |
| ::fidl::Decoder response_decoder(std::move(response)); |
| switch (response.ordinal()) { |
| case internal::kInterface_OnEvent_Ordinal: |
| case internal::kInterface_OnEvent_GenOrdinal: { |
| OnEvent(); |
| break; |
| } |
| default: { |
| break; |
| } |
| } |
| return ZX_OK; |
| } |
| virtual void OnEvent() = 0; |
| }; |
| |
| class Interface_EventSender { |
| public: |
| virtual ~Interface_EventSender(); |
| virtual void OnEvent() = 0; |
| }; |
| |
| class Interface_Sync { |
| public: |
| using Proxy_ = Interface_SyncProxy; |
| virtual ~Interface_Sync(); |
| virtual zx_status_t Method() = 0; |
| }; |
| |
| class Interface_Proxy final : public ::fidl::internal::Proxy, public Interface { |
| public: |
| explicit Interface_Proxy(::fidl::internal::ProxyController* controller); |
| ~Interface_Proxy() override; |
| |
| zx_status_t Dispatch_(::fidl::Message message) override; |
| void Method() override; |
| OnEventCallback OnEvent; |
| |
| private: |
| Interface_Proxy(const Interface_Proxy&) = delete; |
| Interface_Proxy& operator=(const Interface_Proxy&) = delete; |
| |
| ::fidl::internal::ProxyController* controller_; |
| }; |
| |
| class Interface_Stub final : public ::fidl::internal::Stub, |
| public Interface_EventSender { |
| public: |
| typedef class ::test::name::Interface Interface_clazz; |
| explicit Interface_Stub(Interface_clazz* impl); |
| ~Interface_Stub() override; |
| |
| zx_status_t Dispatch_(::fidl::Message message, |
| ::fidl::internal::PendingResponse response) override; |
| void OnEvent() override; |
| |
| private: |
| Interface_clazz* impl_; |
| }; |
| |
| class Interface_SyncProxy : public Interface_Sync { |
| public: |
| explicit Interface_SyncProxy(::zx::channel channel); |
| ~Interface_SyncProxy() override; |
| zx_status_t Method() override; |
| |
| private: |
| ::fidl::internal::SynchronousProxy proxy_; |
| friend class ::fidl::SynchronousInterfacePtr<Interface>; |
| }; |
| #endif // __Fuchsia__ |
| #ifdef __Fuchsia__ |
| |
| /// service comment #1 |
| /// |
| /// service comment #3 |
| class Service final { |
| public: |
| class Handler; |
| |
| static constexpr char Name[] = "test.name.Service"; |
| |
| explicit Service(std::unique_ptr<::fidl::ServiceConnector> service) |
| : service_(std::move(service)) {} |
| |
| explicit operator bool() const { return !!service_; } |
| /// Returns a |fidl::MemberConnector| which can be used to connect to the |
| /// member protocol "interface". |
| ::fidl::MemberConnector<Interface> interface() const { |
| return ::fidl::MemberConnector<Interface>(service_.get(), "interface"); |
| } |
| |
| private: |
| std::unique_ptr<::fidl::ServiceConnector> service_; |
| }; |
| |
| /// Facilitates member protocol registration for servers. |
| class Service::Handler final { |
| public: |
| /// Constructs a new |Handler|. Does not take ownership of |service|. |
| explicit Handler(::fidl::ServiceHandlerBase* service) : service_(service) {} |
| /// Adds member "interface" to the service instance. |handler| is invoked when |
| /// a connection is made to the member protocol. |
| /// |
| /// # Errors |
| /// |
| /// Returns ZX_ERR_ALREADY_EXISTS if the member was already added. |
| zx_status_t add_interface( |
| ::fidl::InterfaceRequestHandler<Interface> handler) { |
| return service_->AddMember("interface", std::move(handler)); |
| } |
| |
| private: |
| ::fidl::ServiceHandlerBase* const service_; |
| }; |
| #endif // __Fuchsia |
| |
| /// const comment #1 |
| /// |
| /// const comment #3 |
| constexpr int32_t C = 4u; |
| } // namespace name |
| } // namespace test |
| namespace fidl { |
| |
| template <> |
| struct IsFidlXUnion<::test::name::Union> : public std::true_type {}; |
| |
| template <> |
| struct CodingTraits<::test::name::Union> |
| : public EncodableCodingTraits<::test::name::Union, 24> {}; |
| |
| template <> |
| struct CodingTraits<std::unique_ptr<::test::name::Union>> { |
| static constexpr size_t inline_size_v1_no_ee = 24; |
| |
| static void Encode(Encoder* encoder, |
| std::unique_ptr<::test::name::Union>* value, |
| size_t offset) { |
| auto&& p_xunion = *value; |
| if (p_xunion) { |
| p_xunion->Encode(encoder, offset); |
| } |
| } |
| |
| static void Decode(Decoder* decoder, |
| std::unique_ptr<::test::name::Union>* value, |
| size_t offset) { |
| fidl_xunion_t* encoded = decoder->GetPtr<fidl_xunion_t>(offset); |
| if (encoded->tag == 0) { |
| value->reset(nullptr); |
| return; |
| } |
| |
| value->reset(new ::test::name::Union); |
| |
| ::test::name::Union::Decode(decoder, value->get(), offset); |
| } |
| }; |
| |
| inline zx_status_t Clone(const ::test::name::Union& value, |
| ::test::name::Union* result) { |
| return ::test::name::Clone(value, result); |
| } |
| |
| template <> |
| struct Equality<::test::name::Union> { |
| bool operator()(const ::test::name::Union& _lhs, |
| const ::test::name::Union& _rhs) const { |
| if (_lhs.Ordinal() != _rhs.Ordinal()) { |
| return false; |
| } |
| |
| switch (_lhs.Ordinal()) { |
| case static_cast<fidl_xunion_tag_t>(::test::name::Union::Tag::Invalid): |
| return true; |
| case ::test::name::Union::Tag::kField: |
| return ::fidl::Equals(_lhs.Field_, _rhs.Field_); |
| |
| default: |
| return false; |
| } |
| } |
| }; |
| template <> |
| struct CodingTraits<::test::name::Table> |
| : public EncodableCodingTraits<::test::name::Table, 16> {}; |
| |
| inline zx_status_t Clone(const ::test::name::Table& _value, |
| ::test::name::Table* result) { |
| return _value.Clone(result); |
| } |
| template <> |
| struct Equality<::test::name::Table> { |
| bool operator()(const ::test::name::Table& _lhs, |
| const ::test::name::Table& _rhs) const { |
| if (_lhs.has_Field()) { |
| if (!_rhs.has_Field()) { |
| return false; |
| } |
| if (!::fidl::Equals(_lhs.Field(), _rhs.Field())) { |
| return false; |
| } |
| } else if (_rhs.has_Field()) { |
| return false; |
| } |
| return true; |
| } |
| }; |
| template <> |
| struct CodingTraits<::test::name::Struct> |
| : public EncodableCodingTraits<::test::name::Struct, 4> {}; |
| |
| inline zx_status_t Clone(const ::test::name::Struct& value, |
| ::test::name::Struct* result) { |
| return ::test::name::Clone(value, result); |
| } |
| |
| template <> |
| struct Equality<::test::name::Struct> { |
| bool operator()(const ::test::name::Struct& _lhs, |
| const ::test::name::Struct& _rhs) const { |
| if (!::fidl::Equals(_lhs.Field, _rhs.Field)) { |
| return false; |
| } |
| return true; |
| } |
| }; |
| template <> |
| struct CodingTraits<::test::name::MyEnum> { |
| static constexpr size_t inline_size_old = sizeof(::test::name::MyEnum); |
| static constexpr size_t inline_size_v1_no_ee = sizeof(::test::name::MyEnum); |
| static void Encode(Encoder* encoder, ::test::name::MyEnum* value, |
| size_t offset) { |
| uint32_t underlying = static_cast<uint32_t>(*value); |
| ::fidl::Encode(encoder, &underlying, offset); |
| } |
| static void Decode(Decoder* decoder, ::test::name::MyEnum* value, |
| size_t offset) { |
| uint32_t underlying = {}; |
| ::fidl::Decode(decoder, &underlying, offset); |
| *value = static_cast<::test::name::MyEnum>(underlying); |
| } |
| }; |
| |
| inline zx_status_t Clone(::test::name::MyEnum value, |
| ::test::name::MyEnum* result) { |
| return ::test::name::Clone(value, result); |
| } |
| template <> |
| struct Equality<::test::name::MyEnum> { |
| bool operator()(const ::test::name::MyEnum& _lhs, |
| const ::test::name::MyEnum& _rhs) const { |
| return _lhs == _rhs; |
| } |
| }; |
| |
| template <> |
| struct CodingTraits<::test::name::MyBits> { |
| static constexpr size_t inline_size_old = sizeof(::test::name::MyBits); |
| static constexpr size_t inline_size_v1_no_ee = sizeof(::test::name::MyBits); |
| static void Encode(Encoder* encoder, ::test::name::MyBits* value, |
| size_t offset) { |
| uint32_t underlying = static_cast<uint32_t>(*value); |
| ::fidl::Encode(encoder, &underlying, offset); |
| } |
| static void Decode(Decoder* decoder, ::test::name::MyBits* value, |
| size_t offset) { |
| uint32_t underlying = {}; |
| ::fidl::Decode(decoder, &underlying, offset); |
| *value = static_cast<::test::name::MyBits>(underlying); |
| } |
| }; |
| |
| inline zx_status_t Clone(::test::name::MyBits value, |
| ::test::name::MyBits* result) { |
| return ::test::name::Clone(value, result); |
| } |
| |
| template <> |
| struct Equality<::test::name::MyBits> { |
| bool operator()(const ::test::name::MyBits& _lhs, |
| const ::test::name::MyBits& _rhs) const { |
| uint32_t _lhs_underlying = static_cast<uint32_t>(_lhs); |
| uint32_t _rhs_underlying = static_cast<uint32_t>(_rhs); |
| return ::fidl::Equals(_lhs_underlying, _rhs_underlying); |
| } |
| }; |
| } // namespace fidl |