| // WARNING: This file is machine generated by fidlgen. |
| |
| #include <fidl/test/requestflexibleenvelope/cpp/fidl.h> |
| |
| #include "lib/fidl/cpp/internal/implementation.h" |
| |
| // |
| // Domain objects definitions (i.e. "natural types" in unified bindings) |
| // |
| namespace fidl { |
| namespace test { |
| namespace requestflexibleenvelope { |
| extern "C" const fidl_type_t fidl_test_requestflexibleenvelope_StrictFooTable; |
| const fidl_type_t* StrictFoo::FidlType = |
| &fidl_test_requestflexibleenvelope_StrictFooTable; |
| |
| StrictFoo::StrictFoo() {} |
| |
| StrictFoo::~StrictFoo() { Destroy(); } |
| |
| StrictFoo::StrictFoo(StrictFoo&& other) : tag_(other.tag_) { |
| switch (tag_) { |
| case ::fidl::test::requestflexibleenvelope::StrictFoo::Tag::kS: |
| new (&s_)::std::string(); |
| s_ = std::move(other.s_); |
| break; |
| case ::fidl::test::requestflexibleenvelope::StrictFoo::Tag::kI: |
| i_ = std::move(other.i_); |
| break; |
| case static_cast<fidl_xunion_tag_t>( |
| ::fidl::test::requestflexibleenvelope::StrictFoo::Tag::Invalid): |
| break; |
| } |
| } |
| |
| StrictFoo& StrictFoo::operator=(StrictFoo&& other) { |
| if (this != &other) { |
| Destroy(); |
| tag_ = other.tag_; |
| switch (tag_) { |
| case ::fidl::test::requestflexibleenvelope::StrictFoo::Tag::kS: |
| new (&s_)::std::string(); |
| s_ = std::move(other.s_); |
| break; |
| case ::fidl::test::requestflexibleenvelope::StrictFoo::Tag::kI: |
| i_ = std::move(other.i_); |
| break; |
| case static_cast<fidl_xunion_tag_t>( |
| ::fidl::test::requestflexibleenvelope::StrictFoo::Tag::Invalid): |
| break; |
| } |
| } |
| return *this; |
| } |
| |
| StrictFoo StrictFoo::WithS(::std::string&& val) { |
| StrictFoo result; |
| result.set_s(std::move(val)); |
| return result; |
| } |
| StrictFoo StrictFoo::WithI(int32_t&& val) { |
| StrictFoo result; |
| result.set_i(std::move(val)); |
| return result; |
| } |
| |
| void StrictFoo::Encode( |
| ::fidl::Encoder* encoder, size_t offset, |
| cpp17::optional<::fidl::HandleInformation> maybe_handle_info) { |
| const size_t length_before = encoder->CurrentLength(); |
| const size_t handles_before = encoder->CurrentHandleCount(); |
| |
| switch (Which()) { |
| case ::fidl::test::requestflexibleenvelope::StrictFoo::Tag::kS: { |
| switch (encoder->wire_format()) { |
| case ::fidl::internal::WireFormatVersion::kV1: { |
| ::fidl::Encode( |
| encoder, &s_, |
| encoder->Alloc( |
| ::fidl::EncodingInlineSize<::std::string, ::fidl::Encoder>( |
| encoder))); |
| |
| fidl_xunion_t* xunion = encoder->GetPtr<fidl_xunion_t>(offset); |
| xunion->tag = tag_; |
| xunion->envelope.num_bytes = |
| static_cast<uint32_t>(encoder->CurrentLength() - length_before); |
| xunion->envelope.num_handles = static_cast<uint32_t>( |
| encoder->CurrentHandleCount() - handles_before); |
| xunion->envelope.presence = FIDL_ALLOC_PRESENT; |
| break; |
| } |
| case ::fidl::internal::WireFormatVersion::kV2: { |
| if (::fidl::EncodingInlineSize<::std::string>(encoder) <= |
| FIDL_ENVELOPE_INLINING_SIZE_THRESHOLD) { |
| ::fidl::Encode(encoder, &s_, |
| offset + offsetof(fidl_xunion_v2_t, envelope)); |
| |
| fidl_xunion_v2_t* xunion = |
| encoder->GetPtr<fidl_xunion_v2_t>(offset); |
| xunion->tag = tag_; |
| xunion->envelope.num_handles = static_cast<uint16_t>( |
| encoder->CurrentHandleCount() - handles_before); |
| xunion->envelope.flags = FIDL_ENVELOPE_FLAGS_INLINING_MASK; |
| break; |
| } |
| |
| ::fidl::Encode( |
| encoder, &s_, |
| encoder->Alloc( |
| ::fidl::EncodingInlineSize<::std::string, ::fidl::Encoder>( |
| encoder))); |
| |
| fidl_xunion_v2_t* xunion = encoder->GetPtr<fidl_xunion_v2_t>(offset); |
| xunion->tag = tag_; |
| xunion->envelope.num_bytes = |
| static_cast<uint32_t>(encoder->CurrentLength() - length_before); |
| xunion->envelope.num_handles = static_cast<uint16_t>( |
| encoder->CurrentHandleCount() - handles_before); |
| xunion->envelope.flags = 0; |
| break; |
| } |
| } |
| break; |
| } |
| case ::fidl::test::requestflexibleenvelope::StrictFoo::Tag::kI: { |
| switch (encoder->wire_format()) { |
| case ::fidl::internal::WireFormatVersion::kV1: { |
| ::fidl::Encode( |
| encoder, &i_, |
| encoder->Alloc( |
| ::fidl::EncodingInlineSize<int32_t, ::fidl::Encoder>( |
| encoder))); |
| |
| fidl_xunion_t* xunion = encoder->GetPtr<fidl_xunion_t>(offset); |
| xunion->tag = tag_; |
| xunion->envelope.num_bytes = |
| static_cast<uint32_t>(encoder->CurrentLength() - length_before); |
| xunion->envelope.num_handles = static_cast<uint32_t>( |
| encoder->CurrentHandleCount() - handles_before); |
| xunion->envelope.presence = FIDL_ALLOC_PRESENT; |
| break; |
| } |
| case ::fidl::internal::WireFormatVersion::kV2: { |
| if (::fidl::EncodingInlineSize<int32_t>(encoder) <= |
| FIDL_ENVELOPE_INLINING_SIZE_THRESHOLD) { |
| ::fidl::Encode(encoder, &i_, |
| offset + offsetof(fidl_xunion_v2_t, envelope)); |
| |
| fidl_xunion_v2_t* xunion = |
| encoder->GetPtr<fidl_xunion_v2_t>(offset); |
| xunion->tag = tag_; |
| xunion->envelope.num_handles = static_cast<uint16_t>( |
| encoder->CurrentHandleCount() - handles_before); |
| xunion->envelope.flags = FIDL_ENVELOPE_FLAGS_INLINING_MASK; |
| break; |
| } |
| |
| ::fidl::Encode( |
| encoder, &i_, |
| encoder->Alloc( |
| ::fidl::EncodingInlineSize<int32_t, ::fidl::Encoder>( |
| encoder))); |
| |
| fidl_xunion_v2_t* xunion = encoder->GetPtr<fidl_xunion_v2_t>(offset); |
| xunion->tag = tag_; |
| xunion->envelope.num_bytes = |
| static_cast<uint32_t>(encoder->CurrentLength() - length_before); |
| xunion->envelope.num_handles = static_cast<uint16_t>( |
| encoder->CurrentHandleCount() - handles_before); |
| xunion->envelope.flags = 0; |
| break; |
| } |
| } |
| break; |
| } |
| default: |
| break; |
| } |
| } |
| |
| void StrictFoo::Decode(::fidl::Decoder* _decoder, StrictFoo* value, |
| size_t offset) { |
| fidl_xunion_v2_t* xunion = _decoder->GetPtr<fidl_xunion_v2_t>(offset); |
| |
| if (xunion->envelope.num_bytes == 0 && xunion->envelope.num_handles == 0 && |
| xunion->envelope.flags == 0) { |
| value->EnsureStorageInitialized(static_cast<fidl_xunion_tag_t>( |
| ::fidl::test::requestflexibleenvelope::StrictFoo::Tag::Invalid)); |
| return; |
| } |
| |
| value->EnsureStorageInitialized(xunion->tag); |
| |
| size_t value_offset = _decoder->EnvelopeValueOffset(&xunion->envelope); |
| |
| switch (value->tag_) { |
| case ::fidl::test::requestflexibleenvelope::StrictFoo::Tag::kS: { |
| new (&value->s_)::std::string(); |
| ::fidl::Decode(_decoder, &value->s_, value_offset); |
| break; |
| } |
| case ::fidl::test::requestflexibleenvelope::StrictFoo::Tag::kI: { |
| ::fidl::Decode(_decoder, &value->i_, value_offset); |
| break; |
| } |
| default: { |
| break; |
| } |
| } |
| } |
| |
| zx_status_t StrictFoo::Clone(StrictFoo* result) const { |
| result->Destroy(); |
| result->tag_ = tag_; |
| switch (tag_) { |
| case ::fidl::test::requestflexibleenvelope::StrictFoo::Tag::Invalid: |
| return ZX_OK; |
| case ::fidl::test::requestflexibleenvelope::StrictFoo::Tag::kS: |
| new (&result->s_)::std::string(); |
| return ::fidl::Clone(s_, &result->s_); |
| case ::fidl::test::requestflexibleenvelope::StrictFoo::Tag::kI: |
| return ::fidl::Clone(i_, &result->i_); |
| default: |
| return ZX_OK; |
| } |
| } |
| |
| StrictFoo& StrictFoo::set_s(::std::string value) { |
| EnsureStorageInitialized( |
| ::fidl::test::requestflexibleenvelope::StrictFoo::Tag::kS); |
| s_ = std::move(value); |
| return *this; |
| } |
| |
| StrictFoo& StrictFoo::set_i(int32_t value) { |
| EnsureStorageInitialized( |
| ::fidl::test::requestflexibleenvelope::StrictFoo::Tag::kI); |
| i_ = std::move(value); |
| return *this; |
| } |
| |
| void StrictFoo::Destroy() { |
| switch (tag_) { |
| case ::fidl::test::requestflexibleenvelope::StrictFoo::Tag::kS: |
| s_.~decltype(s_)(); |
| break; |
| case ::fidl::test::requestflexibleenvelope::StrictFoo::Tag::kI: |
| break; |
| |
| default: |
| break; |
| } |
| tag_ = static_cast<fidl_xunion_tag_t>( |
| ::fidl::test::requestflexibleenvelope::StrictFoo::Tag::Invalid); |
| } |
| |
| void StrictFoo::EnsureStorageInitialized(::fidl_xunion_tag_t tag) { |
| if (tag_ != tag) { |
| Destroy(); |
| tag_ = tag; |
| switch (tag_) { |
| case static_cast<fidl_xunion_tag_t>( |
| ::fidl::test::requestflexibleenvelope::StrictFoo::Tag::Invalid): |
| break; |
| case ::fidl::test::requestflexibleenvelope::StrictFoo::Tag::kS: |
| new (&s_)::std::string(); |
| break; |
| case ::fidl::test::requestflexibleenvelope::StrictFoo::Tag::kI: |
| new (&i_) int32_t(); |
| break; |
| default: |
| break; |
| } |
| } |
| } |
| |
| extern "C" const fidl_type_t fidl_test_requestflexibleenvelope_FlexibleFooTable; |
| const fidl_type_t* FlexibleFoo::FidlType = |
| &fidl_test_requestflexibleenvelope_FlexibleFooTable; |
| |
| FlexibleFoo::FlexibleFoo() {} |
| |
| FlexibleFoo::~FlexibleFoo() { Destroy(); } |
| |
| FlexibleFoo::FlexibleFoo(FlexibleFoo&& other) : tag_(other.tag_) { |
| switch (tag_) { |
| case ::fidl::test::requestflexibleenvelope::FlexibleFoo::Tag::kS: |
| new (&s_)::std::string(); |
| s_ = std::move(other.s_); |
| break; |
| case ::fidl::test::requestflexibleenvelope::FlexibleFoo::Tag::kI: |
| i_ = std::move(other.i_); |
| break; |
| case static_cast<fidl_xunion_tag_t>( |
| ::fidl::test::requestflexibleenvelope::FlexibleFoo::Tag::Invalid): |
| break; |
| default: |
| new (&unknown_data_) decltype(unknown_data_); |
| unknown_data_ = std::move(other.unknown_data_); |
| break; |
| } |
| } |
| |
| FlexibleFoo& FlexibleFoo::operator=(FlexibleFoo&& other) { |
| if (this != &other) { |
| Destroy(); |
| tag_ = other.tag_; |
| switch (tag_) { |
| case ::fidl::test::requestflexibleenvelope::FlexibleFoo::Tag::kS: |
| new (&s_)::std::string(); |
| s_ = std::move(other.s_); |
| break; |
| case ::fidl::test::requestflexibleenvelope::FlexibleFoo::Tag::kI: |
| i_ = std::move(other.i_); |
| break; |
| case static_cast<fidl_xunion_tag_t>( |
| ::fidl::test::requestflexibleenvelope::FlexibleFoo::Tag::Invalid): |
| break; |
| default: |
| new (&unknown_data_) decltype(unknown_data_); |
| unknown_data_ = std::move(other.unknown_data_); |
| break; |
| } |
| } |
| return *this; |
| } |
| |
| FlexibleFoo FlexibleFoo::WithS(::std::string&& val) { |
| FlexibleFoo result; |
| result.set_s(std::move(val)); |
| return result; |
| } |
| FlexibleFoo FlexibleFoo::WithI(int32_t&& val) { |
| FlexibleFoo result; |
| result.set_i(std::move(val)); |
| return result; |
| } |
| |
| void FlexibleFoo::Encode( |
| ::fidl::Encoder* encoder, size_t offset, |
| cpp17::optional<::fidl::HandleInformation> maybe_handle_info) { |
| const size_t length_before = encoder->CurrentLength(); |
| const size_t handles_before = encoder->CurrentHandleCount(); |
| |
| switch (Which()) { |
| case ::fidl::test::requestflexibleenvelope::FlexibleFoo::Tag::kS: { |
| switch (encoder->wire_format()) { |
| case ::fidl::internal::WireFormatVersion::kV1: { |
| ::fidl::Encode( |
| encoder, &s_, |
| encoder->Alloc( |
| ::fidl::EncodingInlineSize<::std::string, ::fidl::Encoder>( |
| encoder))); |
| |
| fidl_xunion_t* xunion = encoder->GetPtr<fidl_xunion_t>(offset); |
| xunion->tag = tag_; |
| xunion->envelope.num_bytes = |
| static_cast<uint32_t>(encoder->CurrentLength() - length_before); |
| xunion->envelope.num_handles = static_cast<uint32_t>( |
| encoder->CurrentHandleCount() - handles_before); |
| xunion->envelope.presence = FIDL_ALLOC_PRESENT; |
| break; |
| } |
| case ::fidl::internal::WireFormatVersion::kV2: { |
| if (::fidl::EncodingInlineSize<::std::string>(encoder) <= |
| FIDL_ENVELOPE_INLINING_SIZE_THRESHOLD) { |
| ::fidl::Encode(encoder, &s_, |
| offset + offsetof(fidl_xunion_v2_t, envelope)); |
| |
| fidl_xunion_v2_t* xunion = |
| encoder->GetPtr<fidl_xunion_v2_t>(offset); |
| xunion->tag = tag_; |
| xunion->envelope.num_handles = static_cast<uint16_t>( |
| encoder->CurrentHandleCount() - handles_before); |
| xunion->envelope.flags = FIDL_ENVELOPE_FLAGS_INLINING_MASK; |
| break; |
| } |
| |
| ::fidl::Encode( |
| encoder, &s_, |
| encoder->Alloc( |
| ::fidl::EncodingInlineSize<::std::string, ::fidl::Encoder>( |
| encoder))); |
| |
| fidl_xunion_v2_t* xunion = encoder->GetPtr<fidl_xunion_v2_t>(offset); |
| xunion->tag = tag_; |
| xunion->envelope.num_bytes = |
| static_cast<uint32_t>(encoder->CurrentLength() - length_before); |
| xunion->envelope.num_handles = static_cast<uint16_t>( |
| encoder->CurrentHandleCount() - handles_before); |
| xunion->envelope.flags = 0; |
| break; |
| } |
| } |
| break; |
| } |
| case ::fidl::test::requestflexibleenvelope::FlexibleFoo::Tag::kI: { |
| switch (encoder->wire_format()) { |
| case ::fidl::internal::WireFormatVersion::kV1: { |
| ::fidl::Encode( |
| encoder, &i_, |
| encoder->Alloc( |
| ::fidl::EncodingInlineSize<int32_t, ::fidl::Encoder>( |
| encoder))); |
| |
| fidl_xunion_t* xunion = encoder->GetPtr<fidl_xunion_t>(offset); |
| xunion->tag = tag_; |
| xunion->envelope.num_bytes = |
| static_cast<uint32_t>(encoder->CurrentLength() - length_before); |
| xunion->envelope.num_handles = static_cast<uint32_t>( |
| encoder->CurrentHandleCount() - handles_before); |
| xunion->envelope.presence = FIDL_ALLOC_PRESENT; |
| break; |
| } |
| case ::fidl::internal::WireFormatVersion::kV2: { |
| if (::fidl::EncodingInlineSize<int32_t>(encoder) <= |
| FIDL_ENVELOPE_INLINING_SIZE_THRESHOLD) { |
| ::fidl::Encode(encoder, &i_, |
| offset + offsetof(fidl_xunion_v2_t, envelope)); |
| |
| fidl_xunion_v2_t* xunion = |
| encoder->GetPtr<fidl_xunion_v2_t>(offset); |
| xunion->tag = tag_; |
| xunion->envelope.num_handles = static_cast<uint16_t>( |
| encoder->CurrentHandleCount() - handles_before); |
| xunion->envelope.flags = FIDL_ENVELOPE_FLAGS_INLINING_MASK; |
| break; |
| } |
| |
| ::fidl::Encode( |
| encoder, &i_, |
| encoder->Alloc( |
| ::fidl::EncodingInlineSize<int32_t, ::fidl::Encoder>( |
| encoder))); |
| |
| fidl_xunion_v2_t* xunion = encoder->GetPtr<fidl_xunion_v2_t>(offset); |
| xunion->tag = tag_; |
| xunion->envelope.num_bytes = |
| static_cast<uint32_t>(encoder->CurrentLength() - length_before); |
| xunion->envelope.num_handles = static_cast<uint16_t>( |
| encoder->CurrentHandleCount() - handles_before); |
| xunion->envelope.flags = 0; |
| break; |
| } |
| } |
| break; |
| } |
| case ::fidl::test::requestflexibleenvelope::FlexibleFoo::Tag::kUnknown: { |
| ::fidl::EncodeUnknownBytes(encoder, &unknown_data_, |
| offset + offsetof(fidl_xunion_t, envelope)); |
| *encoder->GetPtr<uint64_t>(offset) = tag_; |
| break; |
| } |
| default: |
| break; |
| } |
| } |
| |
| void FlexibleFoo::Decode(::fidl::Decoder* _decoder, FlexibleFoo* value, |
| size_t offset) { |
| fidl_xunion_v2_t* xunion = _decoder->GetPtr<fidl_xunion_v2_t>(offset); |
| |
| if (xunion->envelope.num_bytes == 0 && xunion->envelope.num_handles == 0 && |
| xunion->envelope.flags == 0) { |
| value->EnsureStorageInitialized(static_cast<fidl_xunion_tag_t>( |
| ::fidl::test::requestflexibleenvelope::FlexibleFoo::Tag::Invalid)); |
| return; |
| } |
| |
| value->EnsureStorageInitialized(xunion->tag); |
| |
| size_t value_offset = _decoder->EnvelopeValueOffset(&xunion->envelope); |
| |
| switch (value->tag_) { |
| case ::fidl::test::requestflexibleenvelope::FlexibleFoo::Tag::kS: { |
| new (&value->s_)::std::string(); |
| ::fidl::Decode(_decoder, &value->s_, value_offset); |
| break; |
| } |
| case ::fidl::test::requestflexibleenvelope::FlexibleFoo::Tag::kI: { |
| ::fidl::Decode(_decoder, &value->i_, value_offset); |
| break; |
| } |
| default: { |
| auto unknown_info = _decoder->EnvelopeUnknownDataInfo(&xunion->envelope); |
| value->unknown_data_.resize(unknown_info.num_bytes); |
| ::fidl::DecodeUnknownBytesContents(_decoder, &value->unknown_data_, |
| unknown_info.value_offset); |
| break; |
| } |
| } |
| } |
| |
| zx_status_t FlexibleFoo::Clone(FlexibleFoo* result) const { |
| result->Destroy(); |
| result->tag_ = tag_; |
| switch (tag_) { |
| case ::fidl::test::requestflexibleenvelope::FlexibleFoo::Tag::Invalid: |
| return ZX_OK; |
| case ::fidl::test::requestflexibleenvelope::FlexibleFoo::Tag::kS: |
| new (&result->s_)::std::string(); |
| return ::fidl::Clone(s_, &result->s_); |
| case ::fidl::test::requestflexibleenvelope::FlexibleFoo::Tag::kI: |
| return ::fidl::Clone(i_, &result->i_); |
| default: |
| new (&result->unknown_data_) decltype(unknown_data_); |
| return ::fidl::Clone(unknown_data_, &result->unknown_data_); |
| return ZX_OK; |
| } |
| } |
| |
| FlexibleFoo& FlexibleFoo::set_s(::std::string value) { |
| EnsureStorageInitialized( |
| ::fidl::test::requestflexibleenvelope::FlexibleFoo::Tag::kS); |
| s_ = std::move(value); |
| return *this; |
| } |
| |
| FlexibleFoo& FlexibleFoo::set_i(int32_t value) { |
| EnsureStorageInitialized( |
| ::fidl::test::requestflexibleenvelope::FlexibleFoo::Tag::kI); |
| i_ = std::move(value); |
| return *this; |
| } |
| FlexibleFoo& FlexibleFoo::SetUnknownData(fidl_xunion_tag_t ordinal, |
| std::vector<uint8_t> bytes) { |
| EnsureStorageInitialized(ordinal); |
| unknown_data_ = std::move(bytes); |
| return *this; |
| } |
| |
| void FlexibleFoo::Destroy() { |
| switch (tag_) { |
| case ::fidl::test::requestflexibleenvelope::FlexibleFoo::Tag::kS: |
| s_.~decltype(s_)(); |
| break; |
| case ::fidl::test::requestflexibleenvelope::FlexibleFoo::Tag::kI: |
| break; |
| |
| case static_cast<fidl_xunion_tag_t>( |
| ::fidl::test::requestflexibleenvelope::FlexibleFoo::Tag::Invalid): |
| break; |
| default: |
| unknown_data_.~decltype(unknown_data_)(); |
| break; |
| } |
| tag_ = static_cast<fidl_xunion_tag_t>( |
| ::fidl::test::requestflexibleenvelope::FlexibleFoo::Tag::Invalid); |
| } |
| |
| void FlexibleFoo::EnsureStorageInitialized(::fidl_xunion_tag_t tag) { |
| if (tag_ != tag) { |
| Destroy(); |
| tag_ = tag; |
| switch (tag_) { |
| case static_cast<fidl_xunion_tag_t>( |
| ::fidl::test::requestflexibleenvelope::FlexibleFoo::Tag::Invalid): |
| break; |
| case ::fidl::test::requestflexibleenvelope::FlexibleFoo::Tag::kS: |
| new (&s_)::std::string(); |
| break; |
| case ::fidl::test::requestflexibleenvelope::FlexibleFoo::Tag::kI: |
| new (&i_) int32_t(); |
| break; |
| default: |
| new (&unknown_data_) decltype(unknown_data_); |
| break; |
| } |
| } |
| } |
| |
| // |
| // Proxies and stubs definitions |
| // |
| #ifdef __Fuchsia__ |
| |
| namespace _internal { |
| __LOCAL extern "C" const fidl_type_t |
| fidl_test_requestflexibleenvelope_ProtocolRequestStrictResponseFlexibleRequestMessageTable; |
| |
| __LOCAL extern "C" const fidl_type_t |
| fidl_test_requestflexibleenvelope_ProtocolRequestStrictResponseFlexibleResponseMessageTable; |
| |
| __LOCAL extern "C" const fidl_type_t |
| fidl_test_requestflexibleenvelope_ProtocolRequestFlexibleResponseStrictRequestMessageTable; |
| |
| __LOCAL extern "C" const fidl_type_t |
| fidl_test_requestflexibleenvelope_ProtocolRequestFlexibleResponseStrictResponseMessageTable; |
| |
| } // namespace _internal |
| Protocol::~Protocol() = default; |
| |
| const fidl_type_t* ::fidl::test::requestflexibleenvelope:: |
| Protocol_RequestDecoder::GetType(uint64_t ordinal, |
| bool* out_needs_response) { |
| switch (ordinal) { |
| case ::fidl::test::requestflexibleenvelope::internal:: |
| kProtocol_RequestStrictResponseFlexible_Ordinal: |
| *out_needs_response = true; |
| return &::fidl::test::requestflexibleenvelope::_internal:: |
| fidl_test_requestflexibleenvelope_ProtocolRequestStrictResponseFlexibleRequestMessageTable; |
| case ::fidl::test::requestflexibleenvelope::internal:: |
| kProtocol_RequestFlexibleResponseStrict_Ordinal: |
| *out_needs_response = true; |
| return &::fidl::test::requestflexibleenvelope::_internal:: |
| fidl_test_requestflexibleenvelope_ProtocolRequestFlexibleResponseStrictRequestMessageTable; |
| default: |
| *out_needs_response = false; |
| return nullptr; |
| } |
| } |
| |
| const fidl_type_t* Protocol_ResponseDecoder::GetType(uint64_t ordinal) { |
| switch (ordinal) { |
| case ::fidl::test::requestflexibleenvelope::internal:: |
| kProtocol_RequestStrictResponseFlexible_Ordinal: |
| return &::fidl::test::requestflexibleenvelope::_internal:: |
| fidl_test_requestflexibleenvelope_ProtocolRequestStrictResponseFlexibleResponseMessageTable; |
| case ::fidl::test::requestflexibleenvelope::internal:: |
| kProtocol_RequestFlexibleResponseStrict_Ordinal: |
| return &::fidl::test::requestflexibleenvelope::_internal:: |
| fidl_test_requestflexibleenvelope_ProtocolRequestFlexibleResponseStrictResponseMessageTable; |
| default: |
| return nullptr; |
| } |
| } |
| |
| Protocol_EventSender::~Protocol_EventSender() = default; |
| |
| Protocol_Sync::~Protocol_Sync() = default; |
| |
| Protocol_Proxy::Protocol_Proxy(::fidl::internal::ProxyController* controller) |
| : controller_(controller) { |
| (void)controller_; |
| } |
| |
| Protocol_Proxy::~Protocol_Proxy() = default; |
| |
| zx_status_t Protocol_Proxy::Dispatch_(::fidl::HLCPPIncomingMessage message) { |
| zx_status_t status = ZX_OK; |
| switch (message.ordinal()) { |
| default: { |
| status = ZX_ERR_NOT_SUPPORTED; |
| break; |
| } |
| } |
| return status; |
| } |
| |
| namespace { |
| |
| ::std::unique_ptr<::fidl::internal::SingleUseMessageHandler> |
| Protocol_RequestStrictResponseFlexible_ResponseHandler( |
| Protocol::RequestStrictResponseFlexibleCallback&& callback) { |
| ZX_DEBUG_ASSERT_MSG(callback, |
| "Callback must not be empty for " |
| "Protocol::RequestStrictResponseFlexible\n"); |
| return ::std::make_unique<::fidl::internal::SingleUseMessageHandler>( |
| [callback_ = |
| std::move(callback)](::fidl::HLCPPIncomingMessage&& message) { |
| ::fidl::Decoder decoder(std::move(message)); |
| callback_(::fidl::DecodeAs< |
| ::fidl::test::requestflexibleenvelope::FlexibleFoo>(&decoder, |
| 16)); |
| return ZX_OK; |
| }, |
| &::fidl::test::requestflexibleenvelope::_internal:: |
| fidl_test_requestflexibleenvelope_ProtocolRequestStrictResponseFlexibleResponseMessageTable); |
| } |
| |
| } // namespace |
| void Protocol_Proxy::RequestStrictResponseFlexible( |
| ::fidl::test::requestflexibleenvelope::StrictFoo s, |
| RequestStrictResponseFlexibleCallback callback) { |
| ::fidl::Encoder _encoder(::fidl::test::requestflexibleenvelope::internal:: |
| kProtocol_RequestStrictResponseFlexible_Ordinal); |
| controller_->Send( |
| &::fidl::test::requestflexibleenvelope::_internal:: |
| fidl_test_requestflexibleenvelope_ProtocolRequestStrictResponseFlexibleRequestMessageTable, |
| ::fidl::test::requestflexibleenvelope::Protocol_RequestEncoder:: |
| RequestStrictResponseFlexible(&_encoder, &s), |
| Protocol_RequestStrictResponseFlexible_ResponseHandler( |
| std::move(callback))); |
| } |
| namespace { |
| |
| ::std::unique_ptr<::fidl::internal::SingleUseMessageHandler> |
| Protocol_RequestFlexibleResponseStrict_ResponseHandler( |
| Protocol::RequestFlexibleResponseStrictCallback&& callback) { |
| ZX_DEBUG_ASSERT_MSG(callback, |
| "Callback must not be empty for " |
| "Protocol::RequestFlexibleResponseStrict\n"); |
| return ::std::make_unique<::fidl::internal::SingleUseMessageHandler>( |
| [callback_ = |
| std::move(callback)](::fidl::HLCPPIncomingMessage&& message) { |
| ::fidl::Decoder decoder(std::move(message)); |
| callback_( |
| ::fidl::DecodeAs<::fidl::test::requestflexibleenvelope::StrictFoo>( |
| &decoder, 16)); |
| return ZX_OK; |
| }, |
| &::fidl::test::requestflexibleenvelope::_internal:: |
| fidl_test_requestflexibleenvelope_ProtocolRequestFlexibleResponseStrictResponseMessageTable); |
| } |
| |
| } // namespace |
| void Protocol_Proxy::RequestFlexibleResponseStrict( |
| ::fidl::test::requestflexibleenvelope::FlexibleFoo s, |
| RequestFlexibleResponseStrictCallback callback) { |
| ::fidl::Encoder _encoder(::fidl::test::requestflexibleenvelope::internal:: |
| kProtocol_RequestFlexibleResponseStrict_Ordinal); |
| controller_->Send( |
| &::fidl::test::requestflexibleenvelope::_internal:: |
| fidl_test_requestflexibleenvelope_ProtocolRequestFlexibleResponseStrictRequestMessageTable, |
| ::fidl::test::requestflexibleenvelope::Protocol_RequestEncoder:: |
| RequestFlexibleResponseStrict(&_encoder, &s), |
| Protocol_RequestFlexibleResponseStrict_ResponseHandler( |
| std::move(callback))); |
| } |
| |
| Protocol_Stub::Protocol_Stub( |
| ::fidl::test::requestflexibleenvelope::Protocol_Stub::Protocol_clazz* impl) |
| : impl_(impl) { |
| (void)impl_; |
| } |
| |
| Protocol_Stub::~Protocol_Stub() = default; |
| |
| namespace { |
| |
| class Protocol_RequestStrictResponseFlexible_Responder final { |
| public: |
| Protocol_RequestStrictResponseFlexible_Responder( |
| ::fidl::internal::PendingResponse response) |
| : response_(std::move(response)) {} |
| |
| void operator()(::fidl::test::requestflexibleenvelope::FlexibleFoo f) { |
| ::fidl::Encoder _encoder( |
| ::fidl::test::requestflexibleenvelope::internal:: |
| kProtocol_RequestStrictResponseFlexible_Ordinal); |
| response_.Send( |
| &::fidl::test::requestflexibleenvelope::_internal:: |
| fidl_test_requestflexibleenvelope_ProtocolRequestStrictResponseFlexibleResponseMessageTable, |
| ::fidl::test::requestflexibleenvelope::Protocol_ResponseEncoder:: |
| RequestStrictResponseFlexible(&_encoder, &f)); |
| } |
| |
| private: |
| ::fidl::internal::PendingResponse response_; |
| }; |
| |
| class Protocol_RequestFlexibleResponseStrict_Responder final { |
| public: |
| Protocol_RequestFlexibleResponseStrict_Responder( |
| ::fidl::internal::PendingResponse response) |
| : response_(std::move(response)) {} |
| |
| void operator()(::fidl::test::requestflexibleenvelope::StrictFoo f) { |
| ::fidl::Encoder _encoder( |
| ::fidl::test::requestflexibleenvelope::internal:: |
| kProtocol_RequestFlexibleResponseStrict_Ordinal); |
| response_.Send( |
| &::fidl::test::requestflexibleenvelope::_internal:: |
| fidl_test_requestflexibleenvelope_ProtocolRequestFlexibleResponseStrictResponseMessageTable, |
| ::fidl::test::requestflexibleenvelope::Protocol_ResponseEncoder:: |
| RequestFlexibleResponseStrict(&_encoder, &f)); |
| } |
| |
| private: |
| ::fidl::internal::PendingResponse response_; |
| }; |
| |
| } // namespace |
| |
| zx_status_t Protocol_Stub::Dispatch_( |
| ::fidl::HLCPPIncomingMessage message, |
| ::fidl::internal::PendingResponse response) { |
| bool needs_response; |
| const fidl_type_t* request_type = |
| ::fidl::test::requestflexibleenvelope::Protocol_RequestDecoder::GetType( |
| message.ordinal(), &needs_response); |
| if (request_type == nullptr) { |
| return ZX_ERR_NOT_SUPPORTED; |
| } |
| if (response.needs_response() != needs_response) { |
| if (needs_response) { |
| FIDL_REPORT_DECODING_ERROR(message, request_type, |
| "Message needing a response with no txid"); |
| } else { |
| FIDL_REPORT_DECODING_ERROR(message, request_type, |
| "Message not needing a response with a txid"); |
| } |
| return ZX_ERR_INVALID_ARGS; |
| } |
| const char* error_msg = nullptr; |
| zx_status_t status = message.Decode(request_type, &error_msg); |
| if (status != ZX_OK) { |
| FIDL_REPORT_DECODING_ERROR(message, request_type, error_msg); |
| return status; |
| } |
| uint64_t ordinal = message.ordinal(); |
| switch (ordinal) { |
| case ::fidl::test::requestflexibleenvelope::internal:: |
| kProtocol_RequestStrictResponseFlexible_Ordinal: { |
| ::fidl::Decoder decoder(std::move(message)); |
| impl_->RequestStrictResponseFlexible( |
| ::fidl::DecodeAs<::fidl::test::requestflexibleenvelope::StrictFoo>( |
| &decoder, 16), |
| Protocol_RequestStrictResponseFlexible_Responder( |
| std::move(response))); |
| break; |
| } |
| case ::fidl::test::requestflexibleenvelope::internal:: |
| kProtocol_RequestFlexibleResponseStrict_Ordinal: { |
| ::fidl::Decoder decoder(std::move(message)); |
| impl_->RequestFlexibleResponseStrict( |
| ::fidl::DecodeAs<::fidl::test::requestflexibleenvelope::FlexibleFoo>( |
| &decoder, 16), |
| Protocol_RequestFlexibleResponseStrict_Responder( |
| std::move(response))); |
| break; |
| } |
| default: { |
| status = ZX_ERR_NOT_SUPPORTED; |
| break; |
| } |
| } |
| return status; |
| } |
| |
| Protocol_SyncProxy::Protocol_SyncProxy(::zx::channel channel) |
| : proxy_(::std::move(channel)) {} |
| |
| Protocol_SyncProxy::~Protocol_SyncProxy() = default; |
| |
| zx_status_t Protocol_SyncProxy::RequestStrictResponseFlexible( |
| ::fidl::test::requestflexibleenvelope::StrictFoo s, |
| ::fidl::test::requestflexibleenvelope::FlexibleFoo* out_f) { |
| ::fidl::Encoder _encoder(::fidl::test::requestflexibleenvelope::internal:: |
| kProtocol_RequestStrictResponseFlexible_Ordinal); |
| ::fidl::IncomingMessageBuffer buffer_; |
| ::fidl::HLCPPIncomingMessage response_ = buffer_.CreateEmptyIncomingMessage(); |
| zx_status_t status_ = proxy_.Call( |
| &::fidl::test::requestflexibleenvelope::_internal:: |
| fidl_test_requestflexibleenvelope_ProtocolRequestStrictResponseFlexibleRequestMessageTable, |
| &::fidl::test::requestflexibleenvelope::_internal:: |
| fidl_test_requestflexibleenvelope_ProtocolRequestStrictResponseFlexibleResponseMessageTable, |
| ::fidl::test::requestflexibleenvelope::Protocol_RequestEncoder:: |
| RequestStrictResponseFlexible(&_encoder, &s), |
| &response_); |
| if (status_ != ZX_OK) return status_; |
| ::fidl::Decoder decoder_(std::move(response_)); |
| *out_f = ::fidl::DecodeAs<::fidl::test::requestflexibleenvelope::FlexibleFoo>( |
| &decoder_, 16); |
| return ZX_OK; |
| } |
| |
| zx_status_t Protocol_SyncProxy::RequestFlexibleResponseStrict( |
| ::fidl::test::requestflexibleenvelope::FlexibleFoo s, |
| ::fidl::test::requestflexibleenvelope::StrictFoo* out_f) { |
| ::fidl::Encoder _encoder(::fidl::test::requestflexibleenvelope::internal:: |
| kProtocol_RequestFlexibleResponseStrict_Ordinal); |
| ::fidl::IncomingMessageBuffer buffer_; |
| ::fidl::HLCPPIncomingMessage response_ = buffer_.CreateEmptyIncomingMessage(); |
| zx_status_t status_ = proxy_.Call( |
| &::fidl::test::requestflexibleenvelope::_internal:: |
| fidl_test_requestflexibleenvelope_ProtocolRequestFlexibleResponseStrictRequestMessageTable, |
| &::fidl::test::requestflexibleenvelope::_internal:: |
| fidl_test_requestflexibleenvelope_ProtocolRequestFlexibleResponseStrictResponseMessageTable, |
| ::fidl::test::requestflexibleenvelope::Protocol_RequestEncoder:: |
| RequestFlexibleResponseStrict(&_encoder, &s), |
| &response_); |
| if (status_ != ZX_OK) return status_; |
| ::fidl::Decoder decoder_(std::move(response_)); |
| *out_f = ::fidl::DecodeAs<::fidl::test::requestflexibleenvelope::StrictFoo>( |
| &decoder_, 16); |
| return ZX_OK; |
| } |
| #endif // __Fuchsia__ |
| |
| } // namespace requestflexibleenvelope |
| } // namespace test |
| } // namespace fidl |