| // WARNING: This file is machine generated by fidlgen. |
| |
| #pragma once |
| |
| #include "lib/fidl/cpp/internal/header.h" |
| |
| // |
| // Domain objects declarations (i.e. "natural types" in unified bindings). |
| // |
| namespace fidl { |
| namespace test { |
| namespace doccomments { |
| class Table; |
| |
| class Struct; |
| |
| class StrictUnion; |
| |
| #ifdef __Fuchsia__ |
| |
| /// interface comment #1 |
| /// |
| /// interface comment #3 |
| class Interface; |
| using InterfaceHandle = ::fidl::InterfaceHandle<Interface>; |
| #endif // __Fuchsia__ |
| |
| #ifdef __Fuchsia__ |
| class Service; |
| #endif // __Fuchsia__ |
| |
| /// strict enum comment #1. |
| /// |
| /// strict enum comment #2. |
| enum class MyStrictEnum : uint32_t { |
| |
| /// FOO member comment #1 |
| /// |
| /// FOO member comment #3 |
| FOO = 1u, |
| |
| /// BAR member comment #1 |
| /// |
| /// BAR member comment #3 |
| BAR = 2u, |
| }; |
| |
| inline zx_status_t Clone(::fidl::test::doccomments::MyStrictEnum value, |
| ::fidl::test::doccomments::MyStrictEnum* result) { |
| *result = value; |
| return ZX_OK; |
| } |
| |
| /// strict bits comment #1 |
| /// |
| /// strict bits comment #2 |
| enum class MyStrictBits : uint32_t { |
| |
| /// MY_FIRST_BIT member comment #1 |
| /// |
| /// MY_FIRST_BIT member comment #3 |
| MY_FIRST_BIT = 1u, |
| |
| /// MY_OTHER_BIT member comment #1 |
| /// |
| /// MY_OTHER_BIT member comment #3 |
| MY_OTHER_BIT = 2u, |
| }; |
| |
| const static MyStrictBits MyStrictBitsMask = static_cast<MyStrictBits>(3u); |
| |
| constexpr inline ::fidl::test::doccomments::MyStrictBits operator|( |
| ::fidl::test::doccomments::MyStrictBits _lhs, |
| ::fidl::test::doccomments::MyStrictBits _rhs) { |
| return static_cast<::fidl::test::doccomments::MyStrictBits>( |
| static_cast<uint32_t>(_lhs) | static_cast<uint32_t>(_rhs)); |
| } |
| |
| constexpr inline ::fidl::test::doccomments::MyStrictBits& operator|=( |
| ::fidl::test::doccomments::MyStrictBits& _lhs, |
| ::fidl::test::doccomments::MyStrictBits _rhs) { |
| _lhs = _lhs | _rhs; |
| return _lhs; |
| } |
| |
| constexpr inline ::fidl::test::doccomments::MyStrictBits operator&( |
| ::fidl::test::doccomments::MyStrictBits _lhs, |
| ::fidl::test::doccomments::MyStrictBits _rhs) { |
| return static_cast<::fidl::test::doccomments::MyStrictBits>( |
| static_cast<uint32_t>(_lhs) & static_cast<uint32_t>(_rhs)); |
| } |
| |
| constexpr inline ::fidl::test::doccomments::MyStrictBits& operator&=( |
| ::fidl::test::doccomments::MyStrictBits& _lhs, |
| ::fidl::test::doccomments::MyStrictBits _rhs) { |
| _lhs = _lhs & _rhs; |
| return _lhs; |
| } |
| |
| constexpr inline ::fidl::test::doccomments::MyStrictBits operator^( |
| ::fidl::test::doccomments::MyStrictBits _lhs, |
| ::fidl::test::doccomments::MyStrictBits _rhs) { |
| return static_cast<::fidl::test::doccomments::MyStrictBits>( |
| static_cast<uint32_t>(_lhs) ^ static_cast<uint32_t>(_rhs)); |
| } |
| |
| constexpr inline ::fidl::test::doccomments::MyStrictBits& operator^=( |
| ::fidl::test::doccomments::MyStrictBits& _lhs, |
| ::fidl::test::doccomments::MyStrictBits _rhs) { |
| _lhs = _lhs ^ _rhs; |
| return _lhs; |
| } |
| |
| constexpr inline ::fidl::test::doccomments::MyStrictBits operator~( |
| ::fidl::test::doccomments::MyStrictBits _value) { |
| return static_cast<::fidl::test::doccomments::MyStrictBits>( |
| ~static_cast<uint32_t>(_value) & |
| static_cast<uint32_t>(::fidl::test::doccomments::MyStrictBitsMask)); |
| } |
| |
| inline zx_status_t Clone(::fidl::test::doccomments::MyStrictBits value, |
| ::fidl::test::doccomments::MyStrictBits* result) { |
| *result = value; |
| return ZX_OK; |
| } |
| |
| /// flexible enum comment #1. |
| /// |
| /// flexible enum comment #2. |
| class MyFlexibleEnum final { |
| public: |
| constexpr MyFlexibleEnum() : value_(0) {} |
| constexpr explicit MyFlexibleEnum(uint32_t value) : value_(value) {} |
| constexpr MyFlexibleEnum(const MyFlexibleEnum& other) = default; |
| constexpr operator uint32_t() const { return value_; } |
| |
| constexpr bool IsUnknown() const { |
| switch (value_) { |
| case 1u: |
| |
| case 2u: |
| |
| return false; |
| default: |
| return true; |
| } |
| } |
| |
| constexpr static MyFlexibleEnum Unknown() { |
| return MyFlexibleEnum(0xffffffff); |
| } |
| |
| /// FOO member comment #1 |
| /// |
| /// FOO member comment #3 |
| static const MyFlexibleEnum FOO; |
| |
| /// BAR member comment #1 |
| /// |
| /// BAR member comment #3 |
| static const MyFlexibleEnum BAR; |
| |
| private: |
| uint32_t value_; |
| }; |
| |
| #if !(__cplusplus < 201703) |
| constexpr const ::fidl::test::doccomments::MyFlexibleEnum MyFlexibleEnum::FOO = |
| ::fidl::test::doccomments::MyFlexibleEnum(1u); |
| constexpr const ::fidl::test::doccomments::MyFlexibleEnum MyFlexibleEnum::BAR = |
| ::fidl::test::doccomments::MyFlexibleEnum(2u); |
| #endif // !(__cplusplus < 201703) |
| |
| inline zx_status_t Clone(::fidl::test::doccomments::MyFlexibleEnum value, |
| ::fidl::test::doccomments::MyFlexibleEnum* result) { |
| *result = value; |
| return ZX_OK; |
| } |
| |
| /// flexible bits comment #1 |
| /// |
| /// flexible bits comment #2 |
| // |MyFlexibleBits| is flexible, hence may contain unknown members not |
| // defined in the FIDL schema. |
| class MyFlexibleBits final { |
| public: |
| constexpr MyFlexibleBits() = default; |
| constexpr MyFlexibleBits(const MyFlexibleBits& other) = default; |
| |
| // Constructs an instance of |MyFlexibleBits| from an underlying primitive |
| // value if the primitive does not contain any unknown members not defined in |
| // the FIDL schema. Otherwise, returns |cpp17::nullopt|. |
| constexpr inline static cpp17::optional<MyFlexibleBits> TryFrom( |
| uint32_t value) { |
| if (value & ~kMask.value_) { |
| return cpp17::nullopt; |
| } |
| return MyFlexibleBits(value & MyFlexibleBits::kMask.value_); |
| } |
| |
| // Constructs an instance of |MyFlexibleBits| from an underlying primitive |
| // value, clearing any bit member not defined in the FIDL schema. |
| constexpr inline static MyFlexibleBits TruncatingUnknown(uint32_t value) { |
| return MyFlexibleBits(value & MyFlexibleBits::kMask.value_); |
| } |
| |
| // Constructs an instance of |MyFlexibleBits| from an underlying primitive |
| // value, preserving any bit member not defined in the FIDL schema. |
| constexpr explicit MyFlexibleBits(uint32_t value) : value_(value) {} |
| const static MyFlexibleBits MY_FIRST_BIT; |
| const static MyFlexibleBits MY_OTHER_BIT; |
| const static MyFlexibleBits kMask; |
| |
| explicit constexpr inline operator uint32_t() const { return value_; } |
| explicit constexpr inline operator bool() const { |
| return static_cast<bool>(value_); |
| } |
| constexpr inline bool operator==(const MyFlexibleBits& other) const { |
| return value_ == other.value_; |
| } |
| constexpr inline bool operator!=(const MyFlexibleBits& other) const { |
| return value_ != other.value_; |
| } |
| constexpr inline MyFlexibleBits operator~() const; |
| constexpr inline MyFlexibleBits operator|(const MyFlexibleBits& other) const; |
| constexpr inline MyFlexibleBits operator&(const MyFlexibleBits& other) const; |
| constexpr inline MyFlexibleBits operator^(const MyFlexibleBits& other) const; |
| constexpr inline void operator|=(const MyFlexibleBits& other); |
| constexpr inline void operator&=(const MyFlexibleBits& other); |
| constexpr inline void operator^=(const MyFlexibleBits& other); |
| constexpr inline MyFlexibleBits unknown_bits() const { |
| return *this & MyFlexibleBits(~kMask.value_); |
| } |
| constexpr inline bool has_unknown_bits() const { |
| return static_cast<bool>(unknown_bits()); |
| } |
| |
| private: |
| uint32_t value_ = 0; |
| }; |
| |
| #if !(__cplusplus < 201703) |
| constexpr const ::fidl::test::doccomments::MyFlexibleBits |
| MyFlexibleBits::MY_FIRST_BIT = |
| ::fidl::test::doccomments::MyFlexibleBits(1u); |
| constexpr const ::fidl::test::doccomments::MyFlexibleBits |
| MyFlexibleBits::MY_OTHER_BIT = |
| ::fidl::test::doccomments::MyFlexibleBits(2u); |
| constexpr const ::fidl::test::doccomments::MyFlexibleBits |
| MyFlexibleBits::kMask = ::fidl::test::doccomments::MyFlexibleBits(3u); |
| |
| #endif // !(__cplusplus < 201703) |
| |
| constexpr inline ::fidl::test::doccomments::MyFlexibleBits |
| MyFlexibleBits::operator~() const { |
| return ::fidl::test::doccomments::MyFlexibleBits( |
| static_cast<uint32_t>(~this->value_ & kMask.value_)); |
| } |
| |
| constexpr inline ::fidl::test::doccomments::MyFlexibleBits |
| MyFlexibleBits::operator|( |
| const ::fidl::test::doccomments::MyFlexibleBits& other) const { |
| return ::fidl::test::doccomments::MyFlexibleBits( |
| static_cast<uint32_t>(this->value_ | other.value_)); |
| } |
| |
| constexpr inline ::fidl::test::doccomments::MyFlexibleBits |
| MyFlexibleBits::operator&( |
| const ::fidl::test::doccomments::MyFlexibleBits& other) const { |
| return ::fidl::test::doccomments::MyFlexibleBits( |
| static_cast<uint32_t>(this->value_ & other.value_)); |
| } |
| |
| constexpr inline ::fidl::test::doccomments::MyFlexibleBits |
| MyFlexibleBits::operator^( |
| const ::fidl::test::doccomments::MyFlexibleBits& other) const { |
| return ::fidl::test::doccomments::MyFlexibleBits( |
| static_cast<uint32_t>(this->value_ ^ other.value_)); |
| } |
| |
| constexpr inline void MyFlexibleBits::operator|=( |
| const ::fidl::test::doccomments::MyFlexibleBits& other) { |
| this->value_ |= other.value_; |
| } |
| |
| constexpr inline void MyFlexibleBits::operator&=( |
| const ::fidl::test::doccomments::MyFlexibleBits& other) { |
| this->value_ &= other.value_; |
| } |
| |
| constexpr inline void MyFlexibleBits::operator^=( |
| const ::fidl::test::doccomments::MyFlexibleBits& other) { |
| this->value_ ^= other.value_; |
| } |
| |
| inline zx_status_t Clone(::fidl::test::doccomments::MyFlexibleBits value, |
| ::fidl::test::doccomments::MyFlexibleBits* result) { |
| *result = value; |
| return ZX_OK; |
| } |
| |
| class FlexibleUnion; |
| |
| /// 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(field_presence_.IsSet<0>()); |
| return Field_value_.value; |
| } |
| bool has_Field() const { return field_presence_.IsSet<0>(); } |
| |
| /// table field comment #1 |
| /// |
| /// table field comment #3 |
| int32_t* mutable_Field() { |
| if (!field_presence_.IsSet<0>()) { |
| field_presence_.Set<0>(); |
| Construct(&Field_value_.value); |
| } |
| return &Field_value_.value; |
| } |
| Table& set_Field(int32_t _value) { |
| if (!field_presence_.IsSet<0>()) { |
| field_presence_.Set<0>(); |
| Construct(&Field_value_.value, std::move(_value)); |
| } else { |
| Field_value_.value = std::move(_value); |
| } |
| return *this; |
| } |
| void clear_Field() { |
| if (!field_presence_.IsSet<0>()) { |
| return; |
| } |
| field_presence_.Clear<0>(); |
| Destruct(&Field_value_.value); |
| } |
| |
| const std::map<uint64_t, std::vector<uint8_t>>& UnknownData() const { |
| return _unknown_data; |
| } |
| |
| void SetUnknownDataEntry(uint32_t ordinal, std::vector<uint8_t>&& data) { |
| auto ord = static_cast<uint64_t>(ordinal); |
| ZX_ASSERT(!IsOrdinalKnown(ord)); |
| _unknown_data.insert({ord, std::move(data)}); |
| } |
| |
| 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, |
| cpp17::optional<::fidl::HandleInformation> maybe_handle_info = |
| cpp17::nullopt); |
| 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(); |
| } |
| |
| size_t MaxOrdinal() const { |
| size_t max_ordinal = |
| static_cast<size_t>(field_presence_.MaxSetIndex()) + std::size_t{1}; |
| for (const auto& data : _unknown_data) { |
| if (data.first > max_ordinal) { |
| max_ordinal = data.first; |
| } |
| } |
| return max_ordinal; |
| } |
| |
| static bool IsOrdinalKnown(uint64_t ordinal) { |
| switch (ordinal) { |
| case 1: |
| return true; |
| default: |
| return false; |
| } |
| } |
| |
| ::fidl::internal::BitSet<1> field_presence_; |
| union ValueUnion_Field { |
| ValueUnion_Field() {} |
| ~ValueUnion_Field() {} |
| |
| int32_t value; |
| }; |
| ValueUnion_Field Field_value_; |
| std::map<uint64_t, std::vector<uint8_t>> _unknown_data; |
| }; |
| |
| 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, |
| cpp17::optional<::fidl::HandleInformation> maybe_handle_info = |
| cpp17::nullopt); |
| static void Decode(::fidl::Decoder* _decoder, Struct* value, size_t _offset); |
| zx_status_t Clone(Struct* result) const; |
| }; |
| |
| inline zx_status_t Clone(const ::fidl::test::doccomments::Struct& _value, |
| ::fidl::test::doccomments::Struct* _result) { |
| return _value.Clone(_result); |
| } |
| |
| using StructPtr = ::std::unique_ptr<Struct>; |
| |
| /// strict union comment #1 |
| /// |
| /// strict union comment #3 |
| class StrictUnion final { |
| public: |
| static const fidl_type_t* FidlType; |
| |
| StrictUnion(); |
| ~StrictUnion(); |
| |
| StrictUnion(StrictUnion&&); |
| StrictUnion& operator=(StrictUnion&&); |
| |
| static StrictUnion 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<StrictUnion> New() { |
| return ::std::make_unique<StrictUnion>(); |
| } |
| |
| void Encode(::fidl::Encoder* encoder, size_t offset, |
| cpp17::optional<::fidl::HandleInformation> maybe_handle_info = |
| cpp17::nullopt); |
| static void Decode(::fidl::Decoder* decoder, StrictUnion* value, |
| size_t offset); |
| zx_status_t Clone(StrictUnion* result) const; |
| |
| bool has_invalid_tag() const { return tag_ == Invalid; } |
| |
| bool is_Field() const { |
| return tag_ == ::fidl::test::doccomments::StrictUnion::Tag::kField; |
| } |
| |
| /// union member comment #1 |
| /// |
| /// union member comment #3 |
| int32_t& Field() { |
| EnsureStorageInitialized( |
| ::fidl::test::doccomments::StrictUnion::Tag::kField); |
| return Field_; |
| } |
| |
| /// union member comment #1 |
| /// |
| /// union member comment #3 |
| const int32_t& Field() const { |
| ZX_ASSERT(is_Field()); |
| return Field_; |
| } |
| StrictUnion& set_Field(int32_t value); |
| |
| ::fidl::test::doccomments::StrictUnion::Tag Which() const { |
| return ::fidl::test::doccomments::StrictUnion::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_; } |
| |
| friend ::fidl::Equality<::fidl::test::doccomments::StrictUnion>; |
| |
| private: |
| void Destroy(); |
| void EnsureStorageInitialized(::fidl_xunion_tag_t tag); |
| |
| ::fidl_xunion_tag_t tag_ = static_cast<fidl_xunion_tag_t>( |
| ::fidl::test::doccomments::StrictUnion::Tag::Invalid); |
| union { |
| int32_t Field_; |
| }; |
| }; |
| |
| inline zx_status_t Clone(const ::fidl::test::doccomments::StrictUnion& value, |
| ::fidl::test::doccomments::StrictUnion* result) { |
| return value.Clone(result); |
| } |
| |
| using StrictUnionPtr = ::std::unique_ptr<StrictUnion>; |
| |
| #ifdef __Fuchsia__ |
| |
| namespace _internal { |
| extern "C" const fidl_type_t fidl_test_doccomments_InterfaceMethodRequestTable; |
| |
| } // namespace _internal |
| class Interface_RequestEncoder { |
| public: |
| static ::fidl::HLCPPOutgoingMessage Method(::fidl::Encoder* _encoder) { |
| fidl_trace(WillHLCPPEncode); |
| _encoder->Alloc(16 - sizeof(fidl_message_header_t)); |
| |
| fidl_trace(DidHLCPPEncode, |
| &::fidl::test::doccomments::_internal:: |
| fidl_test_doccomments_InterfaceMethodRequestTable, |
| _encoder->GetPtr<const char>(0), _encoder->CurrentLength(), |
| _encoder->CurrentHandleCount()); |
| |
| return _encoder->GetMessage(); |
| } |
| }; |
| namespace _internal { |
| extern "C" const fidl_type_t fidl_test_doccomments_InterfaceOnEventEventTable; |
| |
| } // namespace _internal |
| class Interface_ResponseEncoder { |
| public: |
| static ::fidl::HLCPPOutgoingMessage OnEvent(::fidl::Encoder* _encoder) { |
| fidl_trace(WillHLCPPEncode); |
| _encoder->Alloc(16 - sizeof(fidl_message_header_t)); |
| |
| fidl_trace(DidHLCPPEncode, |
| &::fidl::test::doccomments::_internal:: |
| fidl_test_doccomments_InterfaceOnEventEventTable, |
| _encoder->GetPtr<const char>(0), _encoder->CurrentLength(), |
| _encoder->CurrentHandleCount()); |
| return _encoder->GetMessage(); |
| } |
| }; |
| #endif // __Fuchsia__ |
| |
| /// flexible union comment #1 |
| /// |
| /// flexible union comment #3 |
| class FlexibleUnion final { |
| public: |
| static const fidl_type_t* FidlType; |
| |
| FlexibleUnion(); |
| ~FlexibleUnion(); |
| |
| FlexibleUnion(FlexibleUnion&&); |
| FlexibleUnion& operator=(FlexibleUnion&&); |
| |
| static FlexibleUnion WithField(int32_t&&); |
| |
| enum __attribute__((enum_extensibility(closed))) Tag : fidl_xunion_tag_t { |
| kUnknown = 0, |
| Empty = kUnknown, // DEPRECATED: use kUnknown instead. |
| |
| kField = 1, // 0x1 |
| Invalid = ::std::numeric_limits<::fidl_union_tag_t>::max(), |
| }; |
| |
| static inline ::std::unique_ptr<FlexibleUnion> New() { |
| return ::std::make_unique<FlexibleUnion>(); |
| } |
| |
| void Encode(::fidl::Encoder* encoder, size_t offset, |
| cpp17::optional<::fidl::HandleInformation> maybe_handle_info = |
| cpp17::nullopt); |
| static void Decode(::fidl::Decoder* decoder, FlexibleUnion* value, |
| size_t offset); |
| zx_status_t Clone(FlexibleUnion* result) const; |
| |
| bool has_invalid_tag() const { return tag_ == Invalid; } |
| |
| bool is_Field() const { |
| return tag_ == ::fidl::test::doccomments::FlexibleUnion::Tag::kField; |
| } |
| |
| /// union member comment #1 |
| /// |
| /// union member comment #3 |
| int32_t& Field() { |
| EnsureStorageInitialized( |
| ::fidl::test::doccomments::FlexibleUnion::Tag::kField); |
| return Field_; |
| } |
| |
| /// union member comment #1 |
| /// |
| /// union member comment #3 |
| const int32_t& Field() const { |
| ZX_ASSERT(is_Field()); |
| return Field_; |
| } |
| FlexibleUnion& set_Field(int32_t value); |
| FlexibleUnion& SetUnknownData(fidl_xunion_tag_t ordinal, |
| std::vector<uint8_t> bytes); |
| |
| ::fidl::test::doccomments::FlexibleUnion::Tag Which() const { |
| switch (tag_) { |
| case ::fidl::test::doccomments::FlexibleUnion::Tag::Invalid: |
| case ::fidl::test::doccomments::FlexibleUnion::Tag::kField: |
| return ::fidl::test::doccomments::FlexibleUnion::Tag(tag_); |
| default: |
| return ::fidl::test::doccomments::FlexibleUnion::Tag::kUnknown; |
| } |
| } |
| |
| // 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>* UnknownBytes() const { |
| if (Which() != ::fidl::test::doccomments::FlexibleUnion::Tag::kUnknown) { |
| return nullptr; |
| } |
| return &unknown_data_; |
| } |
| |
| friend ::fidl::Equality<::fidl::test::doccomments::FlexibleUnion>; |
| |
| private: |
| void Destroy(); |
| void EnsureStorageInitialized(::fidl_xunion_tag_t tag); |
| |
| ::fidl_xunion_tag_t tag_ = static_cast<fidl_xunion_tag_t>( |
| ::fidl::test::doccomments::FlexibleUnion::Tag::Invalid); |
| union { |
| int32_t Field_; |
| std::vector<uint8_t> unknown_data_; |
| }; |
| }; |
| |
| inline zx_status_t Clone(const ::fidl::test::doccomments::FlexibleUnion& value, |
| ::fidl::test::doccomments::FlexibleUnion* result) { |
| return value.Clone(result); |
| } |
| |
| using FlexibleUnionPtr = ::std::unique_ptr<FlexibleUnion>; |
| |
| /// const comment #1 |
| /// |
| /// const comment #3 |
| constexpr int32_t C = 4u; |
| |
| } // namespace doccomments |
| } // namespace test |
| template <> |
| struct CodingTraits<::fidl::test::doccomments::Table> |
| : public EncodableCodingTraits<::fidl::test::doccomments::Table, 16> {}; |
| |
| inline zx_status_t Clone(const ::fidl::test::doccomments::Table& _value, |
| ::fidl::test::doccomments::Table* result) { |
| return _value.Clone(result); |
| } |
| template <> |
| struct Equality<::fidl::test::doccomments::Table> { |
| bool operator()(const ::fidl::test::doccomments::Table& _lhs, |
| const ::fidl::test::doccomments::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 ::fidl::Equals(_lhs.UnknownData(), _rhs.UnknownData()); |
| } |
| }; |
| template <> |
| struct CodingTraits<::fidl::test::doccomments::Struct> |
| : public EncodableCodingTraits<::fidl::test::doccomments::Struct, 4> {}; |
| |
| template <> |
| struct IsMemcpyCompatible<::fidl::test::doccomments::Struct> |
| : public internal::BoolConstant< |
| !HasPadding<::fidl::test::doccomments::Struct>::value && |
| IsMemcpyCompatible<int32_t>::value> {}; |
| |
| inline zx_status_t Clone(const ::fidl::test::doccomments::Struct& value, |
| ::fidl::test::doccomments::Struct* result) { |
| return ::fidl::test::doccomments::Clone(value, result); |
| } |
| |
| template <> |
| struct Equality<::fidl::test::doccomments::Struct> { |
| bool operator()(const ::fidl::test::doccomments::Struct& _lhs, |
| const ::fidl::test::doccomments::Struct& _rhs) const { |
| if (!::fidl::Equals(_lhs.Field, _rhs.Field)) { |
| return false; |
| } |
| return true; |
| } |
| }; |
| template <> |
| struct IsFidlXUnion<::fidl::test::doccomments::StrictUnion> |
| : public std::true_type {}; |
| |
| template <> |
| struct CodingTraits<::fidl::test::doccomments::StrictUnion> |
| : public EncodableCodingTraits<::fidl::test::doccomments::StrictUnion, 24> { |
| }; |
| |
| template <> |
| struct CodingTraits<std::unique_ptr<::fidl::test::doccomments::StrictUnion>> { |
| static constexpr size_t inline_size_v1_no_ee = 24; |
| |
| static void Encode( |
| Encoder* encoder, |
| std::unique_ptr<::fidl::test::doccomments::StrictUnion>* value, |
| size_t offset, |
| cpp17::optional<::fidl::HandleInformation> maybe_handle_info) { |
| auto&& p_xunion = *value; |
| if (p_xunion) { |
| p_xunion->Encode(encoder, offset); |
| } |
| } |
| |
| static void Decode( |
| Decoder* decoder, |
| std::unique_ptr<::fidl::test::doccomments::StrictUnion>* 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 ::fidl::test::doccomments::StrictUnion); |
| |
| ::fidl::test::doccomments::StrictUnion::Decode(decoder, value->get(), |
| offset); |
| } |
| }; |
| |
| inline zx_status_t Clone(const ::fidl::test::doccomments::StrictUnion& value, |
| ::fidl::test::doccomments::StrictUnion* result) { |
| return ::fidl::test::doccomments::Clone(value, result); |
| } |
| |
| template <> |
| struct Equality<::fidl::test::doccomments::StrictUnion> { |
| bool operator()(const ::fidl::test::doccomments::StrictUnion& _lhs, |
| const ::fidl::test::doccomments::StrictUnion& _rhs) const { |
| if (_lhs.Ordinal() != _rhs.Ordinal()) { |
| return false; |
| } |
| |
| switch (_lhs.Ordinal()) { |
| case static_cast<fidl_xunion_tag_t>( |
| ::fidl::test::doccomments::StrictUnion::Tag::Invalid): |
| return true; |
| case ::fidl::test::doccomments::StrictUnion::Tag::kField: |
| return ::fidl::Equals(_lhs.Field_, _rhs.Field_); |
| |
| default: |
| return false; |
| } |
| } |
| }; |
| template <> |
| struct CodingTraits<::fidl::test::doccomments::MyStrictEnum> { |
| static constexpr size_t inline_size_old = |
| sizeof(::fidl::test::doccomments::MyStrictEnum); |
| static constexpr size_t inline_size_v1_no_ee = |
| sizeof(::fidl::test::doccomments::MyStrictEnum); |
| static void Encode( |
| Encoder* encoder, ::fidl::test::doccomments::MyStrictEnum* value, |
| size_t offset, |
| cpp17::optional<::fidl::HandleInformation> maybe_handle_info) { |
| ZX_DEBUG_ASSERT(!maybe_handle_info); |
| uint32_t underlying = static_cast<uint32_t>(*value); |
| ::fidl::Encode(encoder, &underlying, offset); |
| } |
| static void Decode(Decoder* decoder, |
| ::fidl::test::doccomments::MyStrictEnum* value, |
| size_t offset) { |
| uint32_t underlying = {}; |
| ::fidl::Decode(decoder, &underlying, offset); |
| *value = static_cast<::fidl::test::doccomments::MyStrictEnum>(underlying); |
| } |
| }; |
| |
| inline zx_status_t Clone(::fidl::test::doccomments::MyStrictEnum value, |
| ::fidl::test::doccomments::MyStrictEnum* result) { |
| return ::fidl::test::doccomments::Clone(value, result); |
| } |
| template <> |
| struct Equality<::fidl::test::doccomments::MyStrictEnum> { |
| bool operator()(const ::fidl::test::doccomments::MyStrictEnum& _lhs, |
| const ::fidl::test::doccomments::MyStrictEnum& _rhs) const { |
| return _lhs == _rhs; |
| } |
| }; |
| |
| template <> |
| struct CodingTraits<::fidl::test::doccomments::MyStrictBits> { |
| static constexpr size_t inline_size_old = |
| sizeof(::fidl::test::doccomments::MyStrictBits); |
| static constexpr size_t inline_size_v1_no_ee = |
| sizeof(::fidl::test::doccomments::MyStrictBits); |
| static void Encode( |
| Encoder* encoder, ::fidl::test::doccomments::MyStrictBits* value, |
| size_t offset, |
| cpp17::optional<::fidl::HandleInformation> maybe_handle_info) { |
| ZX_DEBUG_ASSERT(!maybe_handle_info); |
| uint32_t underlying = static_cast<uint32_t>(*value); |
| ::fidl::Encode(encoder, &underlying, offset); |
| } |
| static void Decode(Decoder* decoder, |
| ::fidl::test::doccomments::MyStrictBits* value, |
| size_t offset) { |
| uint32_t underlying = {}; |
| ::fidl::Decode(decoder, &underlying, offset); |
| *value = static_cast<::fidl::test::doccomments::MyStrictBits>(underlying); |
| } |
| }; |
| |
| inline zx_status_t Clone(::fidl::test::doccomments::MyStrictBits value, |
| ::fidl::test::doccomments::MyStrictBits* result) { |
| return ::fidl::test::doccomments::Clone(value, result); |
| } |
| |
| template <> |
| struct Equality<::fidl::test::doccomments::MyStrictBits> { |
| bool operator()(const ::fidl::test::doccomments::MyStrictBits& _lhs, |
| const ::fidl::test::doccomments::MyStrictBits& _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); |
| } |
| }; |
| template <> |
| struct CodingTraits<::fidl::test::doccomments::MyFlexibleEnum> { |
| static constexpr size_t inline_size_old = |
| sizeof(::fidl::test::doccomments::MyFlexibleEnum); |
| static constexpr size_t inline_size_v1_no_ee = |
| sizeof(::fidl::test::doccomments::MyFlexibleEnum); |
| static void Encode( |
| Encoder* encoder, ::fidl::test::doccomments::MyFlexibleEnum* value, |
| size_t offset, |
| cpp17::optional<::fidl::HandleInformation> maybe_handle_info) { |
| ZX_DEBUG_ASSERT(!maybe_handle_info); |
| uint32_t underlying = static_cast<uint32_t>(*value); |
| ::fidl::Encode(encoder, &underlying, offset); |
| } |
| static void Decode(Decoder* decoder, |
| ::fidl::test::doccomments::MyFlexibleEnum* value, |
| size_t offset) { |
| uint32_t underlying = {}; |
| ::fidl::Decode(decoder, &underlying, offset); |
| *value = static_cast<::fidl::test::doccomments::MyFlexibleEnum>(underlying); |
| } |
| }; |
| |
| inline zx_status_t Clone(::fidl::test::doccomments::MyFlexibleEnum value, |
| ::fidl::test::doccomments::MyFlexibleEnum* result) { |
| return ::fidl::test::doccomments::Clone(value, result); |
| } |
| template <> |
| struct Equality<::fidl::test::doccomments::MyFlexibleEnum> { |
| bool operator()(const ::fidl::test::doccomments::MyFlexibleEnum& _lhs, |
| const ::fidl::test::doccomments::MyFlexibleEnum& _rhs) const { |
| return _lhs == _rhs; |
| } |
| }; |
| |
| template <> |
| struct CodingTraits<::fidl::test::doccomments::MyFlexibleBits> { |
| static constexpr size_t inline_size_old = |
| sizeof(::fidl::test::doccomments::MyFlexibleBits); |
| static constexpr size_t inline_size_v1_no_ee = |
| sizeof(::fidl::test::doccomments::MyFlexibleBits); |
| static void Encode( |
| Encoder* encoder, ::fidl::test::doccomments::MyFlexibleBits* value, |
| size_t offset, |
| cpp17::optional<::fidl::HandleInformation> maybe_handle_info) { |
| ZX_DEBUG_ASSERT(!maybe_handle_info); |
| uint32_t underlying = static_cast<uint32_t>(*value); |
| ::fidl::Encode(encoder, &underlying, offset); |
| } |
| static void Decode(Decoder* decoder, |
| ::fidl::test::doccomments::MyFlexibleBits* value, |
| size_t offset) { |
| uint32_t underlying = {}; |
| ::fidl::Decode(decoder, &underlying, offset); |
| *value = static_cast<::fidl::test::doccomments::MyFlexibleBits>(underlying); |
| } |
| }; |
| |
| inline zx_status_t Clone(::fidl::test::doccomments::MyFlexibleBits value, |
| ::fidl::test::doccomments::MyFlexibleBits* result) { |
| return ::fidl::test::doccomments::Clone(value, result); |
| } |
| |
| template <> |
| struct Equality<::fidl::test::doccomments::MyFlexibleBits> { |
| bool operator()(const ::fidl::test::doccomments::MyFlexibleBits& _lhs, |
| const ::fidl::test::doccomments::MyFlexibleBits& _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); |
| } |
| }; |
| template <> |
| struct IsFidlXUnion<::fidl::test::doccomments::FlexibleUnion> |
| : public std::true_type {}; |
| |
| template <> |
| struct CodingTraits<::fidl::test::doccomments::FlexibleUnion> |
| : public EncodableCodingTraits<::fidl::test::doccomments::FlexibleUnion, |
| 24> {}; |
| |
| template <> |
| struct CodingTraits<std::unique_ptr<::fidl::test::doccomments::FlexibleUnion>> { |
| static constexpr size_t inline_size_v1_no_ee = 24; |
| |
| static void Encode( |
| Encoder* encoder, |
| std::unique_ptr<::fidl::test::doccomments::FlexibleUnion>* value, |
| size_t offset, |
| cpp17::optional<::fidl::HandleInformation> maybe_handle_info) { |
| auto&& p_xunion = *value; |
| if (p_xunion) { |
| p_xunion->Encode(encoder, offset); |
| } |
| } |
| |
| static void Decode( |
| Decoder* decoder, |
| std::unique_ptr<::fidl::test::doccomments::FlexibleUnion>* 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 ::fidl::test::doccomments::FlexibleUnion); |
| |
| ::fidl::test::doccomments::FlexibleUnion::Decode(decoder, value->get(), |
| offset); |
| } |
| }; |
| |
| inline zx_status_t Clone(const ::fidl::test::doccomments::FlexibleUnion& value, |
| ::fidl::test::doccomments::FlexibleUnion* result) { |
| return ::fidl::test::doccomments::Clone(value, result); |
| } |
| |
| template <> |
| struct Equality<::fidl::test::doccomments::FlexibleUnion> { |
| bool operator()(const ::fidl::test::doccomments::FlexibleUnion& _lhs, |
| const ::fidl::test::doccomments::FlexibleUnion& _rhs) const { |
| if (_lhs.Ordinal() != _rhs.Ordinal()) { |
| return false; |
| } |
| |
| switch (_lhs.Ordinal()) { |
| case static_cast<fidl_xunion_tag_t>( |
| ::fidl::test::doccomments::FlexibleUnion::Tag::Invalid): |
| return true; |
| case ::fidl::test::doccomments::FlexibleUnion::Tag::kField: |
| return ::fidl::Equals(_lhs.Field_, _rhs.Field_); |
| default: |
| return ::fidl::Equals(_lhs.unknown_data_, _rhs.unknown_data_); |
| } |
| } |
| }; |
| |
| // |
| // Proxies and stubs declarations |
| // |
| namespace test { |
| namespace doccomments { |
| #ifdef __Fuchsia__ |
| |
| /// interface comment #1 |
| /// |
| /// interface comment #3 |
| 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; |
| |
| namespace internal { |
| constexpr uint64_t kInterface_Method_Ordinal = 0x5c492542705b4265lu; |
| constexpr uint64_t kInterface_OnEvent_Ordinal = 0x37812b697096f6falu; |
| } // namespace internal |
| #endif // __Fuchsia__ |
| |
| #ifdef __Fuchsia__ |
| class Service; |
| #endif // __Fuchsia__ |
| |
| #ifdef __Fuchsia__ |
| |
| /// interface comment #1 |
| /// |
| /// interface comment #3 |
| class Interface { |
| public: |
| using Proxy_ = ::fidl::test::doccomments::Interface_Proxy; |
| using Stub_ = ::fidl::test::doccomments::Interface_Stub; |
| using EventSender_ = ::fidl::test::doccomments::Interface_EventSender; |
| using Sync_ = ::fidl::test::doccomments::Interface_Sync; |
| virtual ~Interface(); |
| |
| /// method comment #1 |
| /// |
| /// method comment #3 |
| virtual void Method() = 0; |
| using OnEventCallback = fit::function<void()>; |
| }; |
| |
| class Interface_RequestDecoder { |
| public: |
| Interface_RequestDecoder() = default; |
| virtual ~Interface_RequestDecoder() = default; |
| static const fidl_type_t* GetType(uint64_t ordinal, bool* out_needs_response); |
| virtual void Method() = 0; |
| }; |
| |
| class Interface_ResponseDecoder { |
| public: |
| Interface_ResponseDecoder() = default; |
| virtual ~Interface_ResponseDecoder() = default; |
| static const fidl_type_t* GetType(uint64_t ordinal); |
| virtual void OnEvent() = 0; |
| }; |
| |
| class Interface_EventSender { |
| public: |
| virtual ~Interface_EventSender(); |
| virtual void OnEvent() = 0; |
| }; |
| |
| class Interface_Sync { |
| public: |
| using Proxy_ = ::fidl::test::doccomments::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::HLCPPIncomingMessage message) override; |
| void Method() override; |
| OnEventCallback OnEvent; |
| |
| private: |
| Interface_Proxy(const ::fidl::test::doccomments::Interface_Proxy&) = delete; |
| Interface_Proxy& operator=( |
| const ::fidl::test::doccomments::Interface_Proxy&) = delete; |
| |
| ::fidl::internal::ProxyController* controller_; |
| }; |
| |
| class Interface_Stub final |
| : public ::fidl::internal::Stub, |
| public ::fidl::test::doccomments::Interface_EventSender { |
| public: |
| typedef class ::fidl::test::doccomments::Interface Interface_clazz; |
| explicit Interface_Stub( |
| ::fidl::test::doccomments::Interface_Stub::Interface_clazz* impl); |
| ~Interface_Stub() override; |
| |
| zx_status_t Dispatch_(::fidl::HLCPPIncomingMessage message, |
| ::fidl::internal::PendingResponse response) override; |
| void OnEvent() override; |
| |
| private: |
| ::fidl::test::doccomments::Interface_Stub::Interface_clazz* impl_; |
| }; |
| |
| class Interface_SyncProxy : public ::fidl::test::doccomments::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[] = "fidl.test.doccomments.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<::fidl::test::doccomments::Interface> interface() |
| const { |
| return ::fidl::MemberConnector<::fidl::test::doccomments::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<::fidl::test::doccomments::Interface> |
| handler) { |
| return service_->AddMember("interface", std::move(handler)); |
| } |
| |
| private: |
| ::fidl::ServiceHandlerBase* const service_; |
| }; |
| #endif // __Fuchsia__ |
| |
| } // namespace doccomments |
| } // namespace test |
| } // namespace fidl |