Skip to content

Commit

Permalink
Remove field:cpp_deprecated_accessor_type
Browse files Browse the repository at this point in the history
Summary: This is duplicated with field:cpp_storage_type

Reviewed By: Mizuchi

Differential Revision: D50073193

fbshipit-source-id: 24d6283adb51499b5a9253e5400ee1cfe4359d75
  • Loading branch information
thedavekwon authored and facebook-github-bot committed Oct 10, 2023
1 parent 6e41566 commit e4409fe
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 28 deletions.
12 changes: 0 additions & 12 deletions thrift/compiler/generate/t_mstch_cpp2_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1691,8 +1691,6 @@ class cpp_mstch_field : public mstch_field {
{"field:cpp_type", &cpp_mstch_field::cpp_type},
{"field:cpp_storage_name", &cpp_mstch_field::cpp_storage_name},
{"field:cpp_storage_type", &cpp_mstch_field::cpp_storage_type},
{"field:cpp_deprecated_accessor_type",
&cpp_mstch_field::cpp_deprecated_accessor_type},
{"field:has_deprecated_accessors?",
&cpp_mstch_field::has_deprecated_accessors},
{"field:serialization_next_field_key",
Expand Down Expand Up @@ -1779,16 +1777,6 @@ class cpp_mstch_field : public mstch_field {
mstch::node eligible_for_storage_name_mangling() {
return is_eligible_for_storage_name_mangling();
}
mstch::node cpp_deprecated_accessor_type() {
// The type to use for pre-field_ref backwards compatiblity functions.
// These leaked the internal storage type directly.
//
// TODO(afuller): Remove this once all non-field_ref based accessors have
// been removed.
assert(field_context_->strct);
return cpp_context_->resolver().get_storage_type(
*field_, *field_context_->strct);
}
mstch::node has_deprecated_accessors() {
return !cpp2::is_explicit_ref(field_) && !cpp2::is_lazy(field_) &&
!gen::cpp::type_resolver::find_first_adapter(*field_) &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@

%><%#struct:fields%><%#field:type%><%#type:resolves_to_container_or_struct?%><%#field:cpp_ref?%>

<%field:cpp_deprecated_accessor_type%>& <%struct:cpp_underlying_name%>::set_<%field:cpp_name%>(<%field:cpp_type%> const &t) {
<%!deprecated%><%field:cpp_storage_type%>& <%struct:cpp_underlying_name%>::set_<%field:cpp_name%>(<%field:cpp_type%> const &t) {
__fbthrift_clear();
type_ = folly::to_underlying(Type::<%field:cpp_name%>);
::new (std::addressof(value_.<%field:cpp_name%>)) <%field:cpp_storage_type%>(<%^field:boxed_ref?%>new <%/field:boxed_ref?%><%field:cpp_storage_type%>::element_type(t));
return value_.<%field:cpp_name%>;
}

<%field:cpp_deprecated_accessor_type%>& <%struct:cpp_underlying_name%>::set_<%field:cpp_name%>(<%field:cpp_type%>&& t) {
<%!deprecated%><%field:cpp_storage_type%>& <%struct:cpp_underlying_name%>::set_<%field:cpp_name%>(<%field:cpp_type%>&& t) {
__fbthrift_clear();
type_ = folly::to_underlying(Type::<%field:cpp_name%>);
::new (std::addressof(value_.<%field:cpp_name%>)) <%field:cpp_storage_type%>(<%^field:boxed_ref?%>new <%/field:boxed_ref?%><%field:cpp_storage_type%>::element_type(std::move(t)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
See the License for the specific language governing permissions and
limitations under the License.

%><%#struct:fields%>, <%field:cpp_deprecated_accessor_type%> <%field:cpp_name%>__arg<%/struct:fields%>
%><%#struct:fields%>, <%field:cpp_storage_type%> <%field:cpp_name%>__arg<%/struct:fields%>
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<%^struct:legacy_api?%>
private:
<%/struct:legacy_api?%>
<%^field:boxed_ref?%><%field:cpp_deprecated_accessor_type%><%/field:boxed_ref?%><%#field:boxed_ref?%><%type:cpp_type%><%/field:boxed_ref?%> const& get_<%field:cpp_name%>() const {
<%!deprecated%><%^field:boxed_ref?%><%field:cpp_storage_type%><%/field:boxed_ref?%><%#field:boxed_ref?%><%type:cpp_type%><%/field:boxed_ref?%> const& get_<%field:cpp_name%>() const {
if (getType() != Type::<%field:cpp_name%>) {
::apache::thrift::detail::throw_on_bad_union_field_access();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
limitations under the License.

%><%#struct:legacy_api?%><%#struct:fields%>
<%field:cpp_deprecated_accessor_type%> move_<%field:cpp_name%>() {
<%!deprecated%><%field:cpp_storage_type%> move_<%field:cpp_name%>() {
assert(getType() == Type::<%field:cpp_name%>);
return std::move(value_.<%field:cpp_name%>);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
limitations under the License.

%><%#struct:legacy_api?%><%#struct:fields%>
<%field:cpp_deprecated_accessor_type%>& mutable_<%field:cpp_name%>() {
<%!deprecated%><%field:cpp_storage_type%>& mutable_<%field:cpp_name%>() {
assert(getType() == Type::<%field:cpp_name%>);
return value_.<%field:cpp_name%>;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

<%^type:string_or_binary?%>
template <typename... A, std::enable_if_t<!sizeof...(A), int> = 0>
<%field:cpp_deprecated_accessor_type%>& set_<%field:cpp_name%>(<%field:cpp_type%> t = <%field:cpp_type%>()) {
<%!deprecated%><%field:cpp_storage_type%>& set_<%field:cpp_name%>(<%field:cpp_type%> t = <%field:cpp_type%>()) {
using T0 = <%field:cpp_storage_type%>;
using T = folly::type_t<T0, A...>;
__fbthrift_clear();
Expand All @@ -41,7 +41,7 @@
<%/type:string_or_binary?%>
<%#type:string_or_binary?%>
template <typename... A, std::enable_if_t<!sizeof...(A), int> = 0>
<%field:cpp_deprecated_accessor_type%>& set_<%field:cpp_name%>(<%field:cpp_type%> const &t) {
<%!deprecated%><%field:cpp_storage_type%>& set_<%field:cpp_name%>(<%field:cpp_type%> const &t) {
using T0 = <%field:cpp_storage_type%>;
using T = folly::type_t<T0, A...>;
__fbthrift_clear();
Expand All @@ -56,7 +56,7 @@
}

template <typename... A, std::enable_if_t<!sizeof...(A), int> = 0>
<%field:cpp_deprecated_accessor_type%>& set_<%field:cpp_name%>(<%field:cpp_type%>&& t) {
<%!deprecated%><%field:cpp_storage_type%>& set_<%field:cpp_name%>(<%field:cpp_type%>&& t) {
using T0 = <%field:cpp_storage_type%>;
using T = folly::type_t<T0, A...>;
__fbthrift_clear();
Expand All @@ -70,7 +70,8 @@
return value_.<%field:cpp_name%>;
}

template<typename... T, typename = ::apache::thrift::safe_overload_t<<%field:cpp_type%>, T...>> <%field:cpp_deprecated_accessor_type%>& set_<%field:cpp_name%>(T&&... t) {
<%!deprecated%>
template<typename... T, typename = ::apache::thrift::safe_overload_t<<%field:cpp_type%>, T...>> <%field:cpp_storage_type%>& set_<%field:cpp_name%>(T&&... t) {
__fbthrift_clear();
type_ = folly::to_underlying(Type::<%field:cpp_name%>);
<%#field:cpp_ref?%>
Expand All @@ -88,7 +89,8 @@

<%^field:cpp_noncopyable?%>
template <typename... A, std::enable_if_t<!sizeof...(A), int> = 0>
<%field:cpp_deprecated_accessor_type%>& set_<%field:cpp_name%>(<%field:cpp_type%> const &t) {
<%!deprecated%>
<%field:cpp_storage_type%>& set_<%field:cpp_name%>(<%field:cpp_type%> const &t) {
using T0 = <%field:cpp_storage_type%>;
using T = folly::type_t<T0, A...>;
__fbthrift_clear();
Expand All @@ -99,7 +101,7 @@
<%/field:cpp_noncopyable?%>

template <typename... A, std::enable_if_t<!sizeof...(A), int> = 0>
<%field:cpp_deprecated_accessor_type%>& set_<%field:cpp_name%>(<%field:cpp_type%>&& t) {
<%!deprecated%><%field:cpp_storage_type%>& set_<%field:cpp_name%>(<%field:cpp_type%>&& t) {
using T0 = <%field:cpp_storage_type%>;
using T = folly::type_t<T0, A...>;
__fbthrift_clear();
Expand All @@ -108,17 +110,19 @@
return value_.<%field:cpp_name%>;
}

template<typename... T, typename = ::apache::thrift::safe_overload_t<<%field:cpp_type%>, T...>> <%field:cpp_deprecated_accessor_type%>& set_<%field:cpp_name%>(T&&... t) {
<%!deprecated%>
template<typename... T, typename = ::apache::thrift::safe_overload_t<<%field:cpp_type%>, T...>> <%field:cpp_storage_type%>& set_<%field:cpp_name%>(T&&... t) {
__fbthrift_clear();
type_ = folly::to_underlying(Type::<%field:cpp_name%>);
::new (std::addressof(value_.<%field:cpp_name%>)) <%field:cpp_type%>(std::forward<T>(t)...);
return value_.<%field:cpp_name%>;
}
<%/field:cpp_ref?%>
<%#field:cpp_ref?%>
<%field:cpp_deprecated_accessor_type%>& set_<%field:cpp_name%>(<%field:cpp_type%> const &t);
<%field:cpp_deprecated_accessor_type%>& set_<%field:cpp_name%>(<%field:cpp_type%>&& t);
template<typename... T, typename = ::apache::thrift::safe_overload_t<<%field:cpp_type%>, T...>> <%field:cpp_deprecated_accessor_type%>& set_<%field:cpp_name%>(T&&... t) {
<%!deprecated%><%field:cpp_storage_type%>& set_<%field:cpp_name%>(<%field:cpp_type%> const &t);
<%!deprecated%><%field:cpp_storage_type%>& set_<%field:cpp_name%>(<%field:cpp_type%>&& t);
<%!deprecated%>
template<typename... T, typename = ::apache::thrift::safe_overload_t<<%field:cpp_type%>, T...>> <%field:cpp_storage_type%>& set_<%field:cpp_name%>(T&&... t) {
// defer resolution of ref_ in case ref_::element_type would here be incomplete
using ref_ = folly::conditional_t<(sizeof...(T) < size_t(-1)), <%field:cpp_storage_type%>, void>;
__fbthrift_clear();
Expand Down

0 comments on commit e4409fe

Please sign in to comment.