Skip to content

Commit

Permalink
add comment to setters of union field
Browse files Browse the repository at this point in the history
Summary: see task

Reviewed By: yoney, donsbot

Differential Revision: D61804773

fbshipit-source-id: c92f54525c6420e13fbddc4a7d9d29a5f45cf511
  • Loading branch information
Philippe Bidinger authored and facebook-github-bot committed Aug 27, 2024
1 parent 00d0e6e commit 70cfe2d
Show file tree
Hide file tree
Showing 21 changed files with 385 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
{{#type:resolves_to_base_or_enum?}}

{{^type:string_or_binary?}}
template <typename... A, std::enable_if_t<!sizeof...(A), int> = 0>
{{ > common/field_docblock}} template <typename... A, std::enable_if_t<!sizeof...(A), int> = 0>
{{!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...>;
Expand All @@ -40,7 +40,7 @@
}
{{/type:string_or_binary?}}
{{#type:string_or_binary?}}
template <typename... A, std::enable_if_t<!sizeof...(A), int> = 0>
{{ > common/field_docblock}} template <typename... A, std::enable_if_t<!sizeof...(A), int> = 0>
{{!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...>;
Expand All @@ -55,7 +55,7 @@
return value_.{{field:cpp_name}};
}

template <typename... A, std::enable_if_t<!sizeof...(A), int> = 0>
{{ > common/field_docblock}} template <typename... A, std::enable_if_t<!sizeof...(A), int> = 0>
{{!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...>;
Expand All @@ -71,7 +71,7 @@
}

{{!deprecated}}
template<typename... T, typename = ::apache::thrift::safe_overload_t<{{field:cpp_type}}, T...>> {{field:cpp_storage_type}}& set_{{field:cpp_name}}(T&&... t) {
{{ > common/field_docblock}} 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 @@ -85,7 +85,7 @@
{{/type:string_or_binary?}}

{{#field:cpp_ref?}}
{{!deprecated}}{{field:cpp_storage_type}}& set_{{field:cpp_name}}({{field:cpp_storage_type}} t) {
{{ > common/field_docblock}} {{!deprecated}}{{field:cpp_storage_type}}& set_{{field:cpp_name}}({{field:cpp_storage_type}} t) {
__fbthrift_clear();
type_ = folly::to_underlying(Type::{{field:cpp_name}});
::new (std::addressof(value_.{{field:cpp_name}})) {{field:cpp_storage_type}}(std::move(t));
Expand All @@ -97,7 +97,7 @@
{{^field:cpp_ref?}}

{{^field:cpp_noncopyable?}}
template <typename... A, std::enable_if_t<!sizeof...(A), int> = 0>
{{ > common/field_docblock}} template <typename... A, std::enable_if_t<!sizeof...(A), int> = 0>
{{!deprecated}}
{{field:cpp_storage_type}}& set_{{field:cpp_name}}({{field:cpp_type}} const &t) {
using T0 = {{field:cpp_storage_type}};
Expand All @@ -109,7 +109,7 @@
}
{{/field:cpp_noncopyable?}}

template <typename... A, std::enable_if_t<!sizeof...(A), int> = 0>
{{ > common/field_docblock}} template <typename... A, std::enable_if_t<!sizeof...(A), int> = 0>
{{!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...>;
Expand All @@ -120,7 +120,7 @@
}

{{!deprecated}}
template<typename... T, typename = ::apache::thrift::safe_overload_t<{{field:cpp_type}}, T...>> {{field:cpp_storage_type}}& set_{{field:cpp_name}}(T&&... t) {
{{ > common/field_docblock}} 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)...);
Expand All @@ -132,7 +132,7 @@
{{!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) {
{{ > common/field_docblock}} 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
Original file line number Diff line number Diff line change
Expand Up @@ -1506,6 +1506,7 @@ class Baz final {
bool operator==(const Baz&) const;
bool operator<(const Baz&) const;

/** Glean { "field": "intField" } */
template <typename... A, std::enable_if_t<!sizeof...(A), int> = 0>
::apache::thrift::adapt_detail::adapted_field_t<::my::Adapter1, 1, ::facebook::thrift::test::i32_5137, Baz>& set_intField(::apache::thrift::adapt_detail::adapted_field_t<::my::Adapter1, 1, ::facebook::thrift::test::i32_5137, Baz> t = ::apache::thrift::adapt_detail::adapted_field_t<::my::Adapter1, 1, ::facebook::thrift::test::i32_5137, Baz>()) {
using T0 = ::apache::thrift::adapt_detail::adapted_field_t<::my::Adapter1, 1, ::facebook::thrift::test::i32_5137, Baz>;
Expand All @@ -1517,6 +1518,7 @@ class Baz final {
}


/** Glean { "field": "setField" } */
template <typename... A, std::enable_if_t<!sizeof...(A), int> = 0>
::facebook::thrift::test::SetWithAdapter& set_setField(::facebook::thrift::test::SetWithAdapter const &t) {
using T0 = ::facebook::thrift::test::SetWithAdapter;
Expand All @@ -1527,6 +1529,7 @@ class Baz final {
return value_.setField;
}

/** Glean { "field": "setField" } */
template <typename... A, std::enable_if_t<!sizeof...(A), int> = 0>
::facebook::thrift::test::SetWithAdapter& set_setField(::facebook::thrift::test::SetWithAdapter&& t) {
using T0 = ::facebook::thrift::test::SetWithAdapter;
Expand All @@ -1537,13 +1540,15 @@ class Baz final {
return value_.setField;
}

/** Glean { "field": "setField" } */
template<typename... T, typename = ::apache::thrift::safe_overload_t<::facebook::thrift::test::SetWithAdapter, T...>> ::facebook::thrift::test::SetWithAdapter& set_setField(T&&... t) {
__fbthrift_clear();
type_ = folly::to_underlying(Type::setField);
::new (std::addressof(value_.setField)) ::facebook::thrift::test::SetWithAdapter(std::forward<T>(t)...);
return value_.setField;
}

/** Glean { "field": "mapField" } */
template <typename... A, std::enable_if_t<!sizeof...(A), int> = 0>
::apache::thrift::adapt_detail::adapted_field_t<::my::Adapter3, 6, ::facebook::thrift::test::map_string_ListWithElemAdapter_withAdapter_8454, Baz>& set_mapField(::apache::thrift::adapt_detail::adapted_field_t<::my::Adapter3, 6, ::facebook::thrift::test::map_string_ListWithElemAdapter_withAdapter_8454, Baz> const &t) {
using T0 = ::apache::thrift::adapt_detail::adapted_field_t<::my::Adapter3, 6, ::facebook::thrift::test::map_string_ListWithElemAdapter_withAdapter_8454, Baz>;
Expand All @@ -1554,6 +1559,7 @@ class Baz final {
return value_.mapField;
}

/** Glean { "field": "mapField" } */
template <typename... A, std::enable_if_t<!sizeof...(A), int> = 0>
::apache::thrift::adapt_detail::adapted_field_t<::my::Adapter3, 6, ::facebook::thrift::test::map_string_ListWithElemAdapter_withAdapter_8454, Baz>& set_mapField(::apache::thrift::adapt_detail::adapted_field_t<::my::Adapter3, 6, ::facebook::thrift::test::map_string_ListWithElemAdapter_withAdapter_8454, Baz>&& t) {
using T0 = ::apache::thrift::adapt_detail::adapted_field_t<::my::Adapter3, 6, ::facebook::thrift::test::map_string_ListWithElemAdapter_withAdapter_8454, Baz>;
Expand All @@ -1564,13 +1570,15 @@ class Baz final {
return value_.mapField;
}

/** Glean { "field": "mapField" } */
template<typename... T, typename = ::apache::thrift::safe_overload_t<::apache::thrift::adapt_detail::adapted_field_t<::my::Adapter3, 6, ::facebook::thrift::test::map_string_ListWithElemAdapter_withAdapter_8454, Baz>, T...>> ::apache::thrift::adapt_detail::adapted_field_t<::my::Adapter3, 6, ::facebook::thrift::test::map_string_ListWithElemAdapter_withAdapter_8454, Baz>& set_mapField(T&&... t) {
__fbthrift_clear();
type_ = folly::to_underlying(Type::mapField);
::new (std::addressof(value_.mapField)) ::apache::thrift::adapt_detail::adapted_field_t<::my::Adapter3, 6, ::facebook::thrift::test::map_string_ListWithElemAdapter_withAdapter_8454, Baz>(std::forward<T>(t)...);
return value_.mapField;
}

/** Glean { "field": "binaryField" } */
template <typename... A, std::enable_if_t<!sizeof...(A), int> = 0>
::apache::thrift::adapt_detail::adapted_field_t<::my::Adapter1, 8, ::facebook::thrift::test::binary_5673, Baz>& set_binaryField(::apache::thrift::adapt_detail::adapted_field_t<::my::Adapter1, 8, ::facebook::thrift::test::binary_5673, Baz> const &t) {
using T0 = ::apache::thrift::adapt_detail::adapted_field_t<::my::Adapter1, 8, ::facebook::thrift::test::binary_5673, Baz>;
Expand All @@ -1581,6 +1589,7 @@ class Baz final {
return value_.binaryField;
}

/** Glean { "field": "binaryField" } */
template <typename... A, std::enable_if_t<!sizeof...(A), int> = 0>
::apache::thrift::adapt_detail::adapted_field_t<::my::Adapter1, 8, ::facebook::thrift::test::binary_5673, Baz>& set_binaryField(::apache::thrift::adapt_detail::adapted_field_t<::my::Adapter1, 8, ::facebook::thrift::test::binary_5673, Baz>&& t) {
using T0 = ::apache::thrift::adapt_detail::adapted_field_t<::my::Adapter1, 8, ::facebook::thrift::test::binary_5673, Baz>;
Expand All @@ -1591,6 +1600,7 @@ class Baz final {
return value_.binaryField;
}

/** Glean { "field": "binaryField" } */
template<typename... T, typename = ::apache::thrift::safe_overload_t<::apache::thrift::adapt_detail::adapted_field_t<::my::Adapter1, 8, ::facebook::thrift::test::binary_5673, Baz>, T...>> ::apache::thrift::adapt_detail::adapted_field_t<::my::Adapter1, 8, ::facebook::thrift::test::binary_5673, Baz>& set_binaryField(T&&... t) {
__fbthrift_clear();
type_ = folly::to_underlying(Type::binaryField);
Expand All @@ -1599,6 +1609,7 @@ class Baz final {
}


/** Glean { "field": "longField" } */
template <typename... A, std::enable_if_t<!sizeof...(A), int> = 0>
::facebook::thrift::test::MyI64& set_longField(::facebook::thrift::test::MyI64 t = ::facebook::thrift::test::MyI64()) {
using T0 = ::facebook::thrift::test::MyI64;
Expand Down Expand Up @@ -6646,6 +6657,7 @@ class ThriftAdaptTestUnion final {
bool operator==(const ThriftAdaptTestUnion&) const;
bool operator<(const ThriftAdaptTestUnion&) const;

/** Glean { "field": "delay" } */
template <typename... A, std::enable_if_t<!sizeof...(A), int> = 0>
::facebook::thrift::test::DurationMs& set_delay(::facebook::thrift::test::DurationMs t = ::facebook::thrift::test::DurationMs()) {
using T0 = ::facebook::thrift::test::DurationMs;
Expand All @@ -6657,6 +6669,7 @@ class ThriftAdaptTestUnion final {
}


/** Glean { "field": "custom" } */
template <typename... A, std::enable_if_t<!sizeof...(A), int> = 0>
::facebook::thrift::test::CustomProtocolType& set_custom(::facebook::thrift::test::CustomProtocolType const &t) {
using T0 = ::facebook::thrift::test::CustomProtocolType;
Expand All @@ -6667,6 +6680,7 @@ class ThriftAdaptTestUnion final {
return value_.custom;
}

/** Glean { "field": "custom" } */
template <typename... A, std::enable_if_t<!sizeof...(A), int> = 0>
::facebook::thrift::test::CustomProtocolType& set_custom(::facebook::thrift::test::CustomProtocolType&& t) {
using T0 = ::facebook::thrift::test::CustomProtocolType;
Expand All @@ -6677,6 +6691,7 @@ class ThriftAdaptTestUnion final {
return value_.custom;
}

/** Glean { "field": "custom" } */
template<typename... T, typename = ::apache::thrift::safe_overload_t<::facebook::thrift::test::CustomProtocolType, T...>> ::facebook::thrift::test::CustomProtocolType& set_custom(T&&... t) {
__fbthrift_clear();
type_ = folly::to_underlying(Type::custom);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ class RefUnion final {
bool operator==(const RefUnion&) const;
bool operator<(const RefUnion&) const;

/** Glean { "field": "field1" } */
template <typename... A, std::enable_if_t<!sizeof...(A), int> = 0>
::std::shared_ptr<::apache::thrift::adapt_detail::adapted_field_t<::my::Adapter1, 1, ::std::string, RefUnion>>& set_field1(::apache::thrift::adapt_detail::adapted_field_t<::my::Adapter1, 1, ::std::string, RefUnion> const &t) {
using T0 = ::std::shared_ptr<::apache::thrift::adapt_detail::adapted_field_t<::my::Adapter1, 1, ::std::string, RefUnion>>;
Expand All @@ -178,6 +179,7 @@ class RefUnion final {
return value_.field1;
}

/** Glean { "field": "field1" } */
template <typename... A, std::enable_if_t<!sizeof...(A), int> = 0>
::std::shared_ptr<::apache::thrift::adapt_detail::adapted_field_t<::my::Adapter1, 1, ::std::string, RefUnion>>& set_field1(::apache::thrift::adapt_detail::adapted_field_t<::my::Adapter1, 1, ::std::string, RefUnion>&& t) {
using T0 = ::std::shared_ptr<::apache::thrift::adapt_detail::adapted_field_t<::my::Adapter1, 1, ::std::string, RefUnion>>;
Expand All @@ -188,13 +190,15 @@ class RefUnion final {
return value_.field1;
}

/** Glean { "field": "field1" } */
template<typename... T, typename = ::apache::thrift::safe_overload_t<::apache::thrift::adapt_detail::adapted_field_t<::my::Adapter1, 1, ::std::string, RefUnion>, T...>> ::std::shared_ptr<::apache::thrift::adapt_detail::adapted_field_t<::my::Adapter1, 1, ::std::string, RefUnion>>& set_field1(T&&... t) {
__fbthrift_clear();
type_ = folly::to_underlying(Type::field1);
::new (std::addressof(value_.field1)) ::std::shared_ptr<::apache::thrift::adapt_detail::adapted_field_t<::my::Adapter1, 1, ::std::string, RefUnion>>(new ::std::shared_ptr<::apache::thrift::adapt_detail::adapted_field_t<::my::Adapter1, 1, ::std::string, RefUnion>>::element_type(std::forward<T>(t)...));
return value_.field1;
}

/** Glean { "field": "field1" } */
::std::shared_ptr<::apache::thrift::adapt_detail::adapted_field_t<::my::Adapter1, 1, ::std::string, RefUnion>>& set_field1(::std::shared_ptr<::apache::thrift::adapt_detail::adapted_field_t<::my::Adapter1, 1, ::std::string, RefUnion>> t) {
__fbthrift_clear();
type_ = folly::to_underlying(Type::field1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ class MyUnion final {
bool operator==(const MyUnion&) const;
bool operator<(const MyUnion&) const;

/** Glean { "field": "myString" } */
template <typename... A, std::enable_if_t<!sizeof...(A), int> = 0>
::std::string& set_myString(::std::string const &t) {
using T0 = ::std::string;
Expand All @@ -366,6 +367,7 @@ class MyUnion final {
return value_.myString;
}

/** Glean { "field": "myString" } */
template <typename... A, std::enable_if_t<!sizeof...(A), int> = 0>
::std::string& set_myString(::std::string&& t) {
using T0 = ::std::string;
Expand All @@ -376,6 +378,7 @@ class MyUnion final {
return value_.myString;
}

/** Glean { "field": "myString" } */
template<typename... T, typename = ::apache::thrift::safe_overload_t<::std::string, T...>> ::std::string& set_myString(T&&... t) {
__fbthrift_clear();
type_ = folly::to_underlying(Type::myString);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2050,6 +2050,7 @@ class MyUnion final {
bool operator==(const MyUnion&) const;
bool operator<(const MyUnion&) const;

/** Glean { "field": "first" } */
template <typename... A, std::enable_if_t<!sizeof...(A), int> = 0>
::test::fixtures::basic-structured-annotations::annotated_inline_string& set_first(::test::fixtures::basic-structured-annotations::annotated_inline_string const &t) {
using T0 = ::test::fixtures::basic-structured-annotations::annotated_inline_string;
Expand All @@ -2060,6 +2061,7 @@ class MyUnion final {
return value_.first;
}

/** Glean { "field": "first" } */
template <typename... A, std::enable_if_t<!sizeof...(A), int> = 0>
::test::fixtures::basic-structured-annotations::annotated_inline_string& set_first(::test::fixtures::basic-structured-annotations::annotated_inline_string&& t) {
using T0 = ::test::fixtures::basic-structured-annotations::annotated_inline_string;
Expand All @@ -2070,6 +2072,7 @@ class MyUnion final {
return value_.first;
}

/** Glean { "field": "first" } */
template<typename... T, typename = ::apache::thrift::safe_overload_t<::test::fixtures::basic-structured-annotations::annotated_inline_string, T...>> ::test::fixtures::basic-structured-annotations::annotated_inline_string& set_first(T&&... t) {
__fbthrift_clear();
type_ = folly::to_underlying(Type::first);
Expand All @@ -2078,6 +2081,7 @@ class MyUnion final {
}


/** Glean { "field": "second" } */
template <typename... A, std::enable_if_t<!sizeof...(A), int> = 0>
::test::fixtures::basic-structured-annotations::annotated_inline_i64& set_second(::test::fixtures::basic-structured-annotations::annotated_inline_i64 t = ::test::fixtures::basic-structured-annotations::annotated_inline_i64()) {
using T0 = ::test::fixtures::basic-structured-annotations::annotated_inline_i64;
Expand Down
Loading

0 comments on commit 70cfe2d

Please sign in to comment.