blob: 5a1488f08ffe5b31e87b1aa4759582a3352222d5 [file] [log] [blame]
// WARNING: This file is machine generated by fidlgen.
#pragma once
#include "lib/fidl/cpp/internal/header.h"
namespace test {
namespace name {
class UnionWithHandle;
class TableWithHandle;
class HandlesInTypes;
class UnionWithHandle final {
public:
static const fidl_type_t* FidlType;
UnionWithHandle();
~UnionWithHandle();
UnionWithHandle(UnionWithHandle&&);
UnionWithHandle& operator=(UnionWithHandle&&);
static UnionWithHandle WithH(::zx::vmo&&);
enum __attribute__((enum_extensibility(closed))) Tag : fidl_xunion_tag_t {
kUnknown = 0,
Empty = kUnknown, // DEPRECATED: use kUnknown instead.
kH = 1, // 0x1
Invalid = ::std::numeric_limits<::fidl_union_tag_t>::max(),
};
static inline ::std::unique_ptr<UnionWithHandle> New() {
return ::std::make_unique<UnionWithHandle>();
}
void Encode(::fidl::Encoder* encoder, size_t offset);
static void Decode(::fidl::Decoder* decoder, UnionWithHandle* value,
size_t offset);
zx_status_t Clone(UnionWithHandle* result) const;
bool has_invalid_tag() const { return tag_ == Invalid; }
bool is_h() const { return tag_ == Tag::kH; }
::zx::vmo& h() {
EnsureStorageInitialized(Tag::kH);
return h_;
}
const ::zx::vmo& h() const {
ZX_ASSERT(is_h());
return h_;
}
UnionWithHandle& set_h(::zx::vmo value);
Tag Which() const {
switch (tag_) {
case Tag::kH:
return Tag(tag_);
default:
return 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>* UnknownData() const {
if (Which() != Tag::kUnknown) {
return nullptr;
}
return &unknown_data_;
}
friend ::fidl::Equality<::test::name::UnionWithHandle>;
private:
void Destroy();
void EnsureStorageInitialized(::fidl_xunion_tag_t tag);
::fidl_xunion_tag_t tag_ = static_cast<fidl_xunion_tag_t>(Tag::Invalid);
union {
::zx::vmo h_;
std::vector<uint8_t> unknown_data_;
};
};
inline zx_status_t Clone(const ::test::name::UnionWithHandle& value,
::test::name::UnionWithHandle* result) {
return value.Clone(result);
}
using UnionWithHandlePtr = ::std::unique_ptr<UnionWithHandle>;
class TableWithHandle final {
public:
static const fidl_type_t* FidlType;
/// Returns whether no field is set.
bool IsEmpty() const;
const ::zx::vmo& h() const {
ZX_ASSERT(has_h_);
return h_value_.value;
}
bool has_h() const { return has_h_; }
::zx::vmo* mutable_h() {
if (!has_h_) {
has_h_ = true;
Construct(&h_value_.value);
}
return &h_value_.value;
}
TableWithHandle& set_h(::zx::vmo _value) {
if (!has_h_) {
has_h_ = true;
Construct(&h_value_.value, std::move(_value));
} else {
h_value_.value = std::move(_value);
}
return *this;
}
void clear_h() {
if (!has_h_) {
return;
}
has_h_ = false;
Destruct(&h_value_.value);
}
TableWithHandle();
TableWithHandle(TableWithHandle&& other);
~TableWithHandle();
TableWithHandle& operator=(TableWithHandle&& other);
static inline ::std::unique_ptr<TableWithHandle> New() {
return ::std::make_unique<TableWithHandle>();
}
void Encode(::fidl::Encoder* _encoder, size_t _offset);
static void Decode(::fidl::Decoder* _decoder, TableWithHandle* _value,
size_t _offset);
zx_status_t Clone(TableWithHandle* _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_h_ : 1;
union ValueUnion_h {
ValueUnion_h() {}
~ValueUnion_h() {}
::zx::vmo value;
};
ValueUnion_h h_value_;
};
using TableWithHandlePtr = ::std::unique_ptr<TableWithHandle>;
class HandlesInTypes final {
public:
static const fidl_type_t* FidlType;
::zx::vmo normal_handle{};
::std::vector<::zx::vmo> handle_in_vec{};
::std::array<::zx::vmo, 5> handle_in_array{};
::std::vector<::std::array<::zx::vmo, 5>> handle_in_mixed_vec_array{};
TableWithHandle table_with_handle{};
UnionWithHandle union_with_handle{};
static inline ::std::unique_ptr<HandlesInTypes> New() {
return ::std::make_unique<HandlesInTypes>();
}
void Encode(::fidl::Encoder* _encoder, size_t _offset);
static void Decode(::fidl::Decoder* _decoder, HandlesInTypes* value,
size_t _offset);
zx_status_t Clone(HandlesInTypes* result) const;
};
inline zx_status_t Clone(const ::test::name::HandlesInTypes& _value,
::test::name::HandlesInTypes* _result) {
return _value.Clone(_result);
}
using HandlesInTypesPtr = ::std::unique_ptr<HandlesInTypes>;
} // namespace name
} // namespace test
namespace fidl {
template <>
struct IsFidlXUnion<::test::name::UnionWithHandle> : public std::true_type {};
template <>
struct CodingTraits<::test::name::UnionWithHandle>
: public EncodableCodingTraits<::test::name::UnionWithHandle, 24> {};
template <>
struct CodingTraits<std::unique_ptr<::test::name::UnionWithHandle>> {
static constexpr size_t inline_size_v1_no_ee = 24;
static void Encode(Encoder* encoder,
std::unique_ptr<::test::name::UnionWithHandle>* 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::UnionWithHandle>* 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::UnionWithHandle);
::test::name::UnionWithHandle::Decode(decoder, value->get(), offset);
}
};
inline zx_status_t Clone(const ::test::name::UnionWithHandle& value,
::test::name::UnionWithHandle* result) {
return ::test::name::Clone(value, result);
}
template <>
struct Equality<::test::name::UnionWithHandle> {
bool operator()(const ::test::name::UnionWithHandle& _lhs,
const ::test::name::UnionWithHandle& _rhs) const {
if (_lhs.Ordinal() != _rhs.Ordinal()) {
return false;
}
switch (_lhs.Ordinal()) {
case static_cast<fidl_xunion_tag_t>(
::test::name::UnionWithHandle::Tag::Invalid):
return true;
case ::test::name::UnionWithHandle::Tag::kH:
return ::fidl::Equals(_lhs.h_, _rhs.h_);
default:
return *_lhs.UnknownData() == *_rhs.UnknownData();
}
}
};
template <>
struct CodingTraits<::test::name::TableWithHandle>
: public EncodableCodingTraits<::test::name::TableWithHandle, 16> {};
inline zx_status_t Clone(const ::test::name::TableWithHandle& _value,
::test::name::TableWithHandle* result) {
return _value.Clone(result);
}
template <>
struct Equality<::test::name::TableWithHandle> {
bool operator()(const ::test::name::TableWithHandle& _lhs,
const ::test::name::TableWithHandle& _rhs) const {
if (_lhs.has_h()) {
if (!_rhs.has_h()) {
return false;
}
if (!::fidl::Equals(_lhs.h(), _rhs.h())) {
return false;
}
} else if (_rhs.has_h()) {
return false;
}
return true;
}
};
template <>
struct CodingTraits<::test::name::HandlesInTypes>
: public EncodableCodingTraits<::test::name::HandlesInTypes, 104> {};
inline zx_status_t Clone(const ::test::name::HandlesInTypes& value,
::test::name::HandlesInTypes* result) {
return ::test::name::Clone(value, result);
}
template <>
struct Equality<::test::name::HandlesInTypes> {
bool operator()(const ::test::name::HandlesInTypes& _lhs,
const ::test::name::HandlesInTypes& _rhs) const {
if (!::fidl::Equals(_lhs.normal_handle, _rhs.normal_handle)) {
return false;
}
if (!::fidl::Equals(_lhs.handle_in_vec, _rhs.handle_in_vec)) {
return false;
}
if (!::fidl::Equals(_lhs.handle_in_array, _rhs.handle_in_array)) {
return false;
}
if (!::fidl::Equals(_lhs.handle_in_mixed_vec_array,
_rhs.handle_in_mixed_vec_array)) {
return false;
}
if (!::fidl::Equals(_lhs.table_with_handle, _rhs.table_with_handle)) {
return false;
}
if (!::fidl::Equals(_lhs.union_with_handle, _rhs.union_with_handle)) {
return false;
}
return true;
}
};
} // namespace fidl