Skip to content

Commit

Permalink
Support AnyData in AnyPatch
Browse files Browse the repository at this point in the history
Summary: Support interoperability with the most commonly adapted version of AnyStruct (i.e. AnyData) until we properly support adapted types

Reviewed By: thedavekwon

Differential Revision: D63478001

fbshipit-source-id: 9908f06493aae1d11344b0c807310d5e9cdf7263
  • Loading branch information
Pranav Thulasiram Bhat authored and facebook-github-bot committed Sep 26, 2024
1 parent 66bfc6f commit 4978417
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions thrift/lib/thrift/detail/AnyPatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ class AnyPatch : public BaseClearPatch<Patch, AnyPatch<Patch>> {
using Base::apply;
using Base::Base;
using Base::operator=;
using Base::assign;
using Base::clear;

/// @copybrief AssignPatch::customVisit
Expand Down Expand Up @@ -249,6 +250,20 @@ class AnyPatch : public BaseClearPatch<Patch, AnyPatch<Patch>> {
patchIfTypeIsImpl(std::move(type), std::move(patch), true);
}

// Interop with AnyData
// TODO(pranavtbhat): Replace with actual adapter/typedef support in patch
void assign(const type::AnyData& val) { assign(val.toThrift()); }
void assign(type::AnyData&& val) { assign(std::move(val).toThrift()); }

AnyPatch& operator=(const type::AnyData& val) {
return this->operator=(val.toThrift());
}
AnyPatch& operator=(type::AnyData&& val) {
return this->operator=(std::move(val).toThrift());
}

void apply(type::AnyData& val) const { apply(val.toThrift()); }

private:
using Base::assignOr;
using Base::data_;
Expand Down

0 comments on commit 4978417

Please sign in to comment.