Skip to content

Commit

Permalink
Reduce build-time by moving the definition of setter/getter to module…
Browse files Browse the repository at this point in the history
…_types.cpp (redo)

Reviewed By: iahs

Differential Revision: D67579926

fbshipit-source-id: 4cf726ef4e76f6a6b11861e980e32146a89dc8f4
  • Loading branch information
TJ Yin authored and facebook-github-bot committed Dec 24, 2024
1 parent ab8506c commit d8eba66
Show file tree
Hide file tree
Showing 135 changed files with 7,277 additions and 5,050 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,37 @@
limitations under the License.
}}{{#struct:fields?}}{{#struct:fields}}{{#field:type}}{{#field:has_deprecated_accessors?}}
{{#type:resolves_to_container_or_struct?}}
{{#field:optional?}}
{{#if field:optional?}}

const {{type:cpp_type}}* {{struct:cpp_underlying_name}}::get_{{field:cpp_name}}() const& {
return {{field:cpp_name}}_ref().has_value() ? std::addressof({{field:cpp_storage_name}}) : nullptr;
}

{{type:cpp_type}}* {{struct:cpp_underlying_name}}::get_{{field:cpp_name}}() & {
return {{field:cpp_name}}_ref().has_value() ? std::addressof({{field:cpp_storage_name}}) : nullptr;
}
{{#else}}
{{#if type:resolves_to_fixed_size?}}

{{type:cpp_type}} {{struct:cpp_underlying_name}}::get_{{field:cpp_name}}() const {
return {{field:cpp_storage_name}};
}
{{#else}}

{{/field:optional?}}
{{^field:optional?}}
const {{type:cpp_type}}& {{struct:cpp_underlying_name}}::get_{{field:cpp_name}}() const& {
return {{field:cpp_storage_name}};
}

{{type:cpp_type}} {{struct:cpp_underlying_name}}::get_{{field:cpp_name}}() && {
return std::move({{field:cpp_storage_name}});
return static_cast<{{type:cpp_type}}&&>({{field:cpp_storage_name}});
}
{{/if type:resolves_to_fixed_size?}}
{{/if field:optional?}}
{{#if type:resolves_to_fixed_size?}}

{{/field:optional?}}
{{/type:resolves_to_container_or_struct?}}
{{type:cpp_type}}& {{struct:cpp_underlying_name}}::set_{{field:cpp_name}}({{type:cpp_type}} {{field:cpp_name}}_) {
{{field:cpp_name}}_ref() = {{field:cpp_name}}_;
return {{field:cpp_storage_name}};
}
{{/if type:resolves_to_fixed_size?}}
{{/field:has_deprecated_accessors?}}{{/field:type}}{{/struct:fields}}{{/struct:fields?}}
Original file line number Diff line number Diff line change
Expand Up @@ -15,62 +15,23 @@
limitations under the License.
}}{{#struct:fields}}{{#field:type}}{{#field:has_deprecated_accessors?}}
{{^type:resolves_to_container_or_struct?}}
{{#if field:optional?}}

{{> common/field_docblock}}
[[deprecated("Use `FOO.{{field:cpp_name}}().value();` instead of `FOO.get_{{field:cpp_name}}();`")]]
const {{type:cpp_type}}* get_{{field:cpp_name}}() const& {
return {{field:cpp_name}}_ref().has_value() ? std::addressof({{field:cpp_storage_name}}) : nullptr;
}
const {{type:cpp_type}}* get_{{field:cpp_name}}() const&;

{{> common/field_docblock}}
[[deprecated("Use `FOO.{{field:cpp_name}}().value();` instead of `FOO.get_{{field:cpp_name}}();`")]]
{{type:cpp_type}}* get_{{field:cpp_name}}() & {
return {{field:cpp_name}}_ref().has_value() ? std::addressof({{field:cpp_storage_name}}) : nullptr;
}
{{type:cpp_type}}* get_{{field:cpp_name}}() &;

{{> common/field_docblock}}
[[deprecated("Use `FOO.{{field:cpp_name}}().value();` instead of `FOO.get_{{field:cpp_name}}();`")]]
{{type:cpp_type}}* get_{{field:cpp_name}}() && = delete;
{{#else}}
{{#if type:resolves_to_fixed_size?}}

{{> common/field_docblock}}
[[deprecated("Use `FOO.{{field:cpp_name}}().value();` instead of `FOO.get_{{field:cpp_name}}();`")]]
{{type:cpp_type}} get_{{field:cpp_name}}() const {
return {{field:cpp_storage_name}};
}
{{#else}}

{{> common/field_docblock}}
[[deprecated("Use `FOO.{{field:cpp_name}}().value();` instead of `FOO.get_{{field:cpp_name}}();`")]]
const {{type:cpp_type}}& get_{{field:cpp_name}}() const& {
return {{field:cpp_storage_name}};
}

{{> common/field_docblock}}
[[deprecated("Use `FOO.{{field:cpp_name}}().value();` instead of `FOO.get_{{field:cpp_name}}();`")]]
{{type:cpp_type}} get_{{field:cpp_name}}() && {
return std::move({{field:cpp_storage_name}});
}
{{/if type:resolves_to_fixed_size?}}
{{/if field:optional?}}
{{/type:resolves_to_container_or_struct?}}
{{#type:resolves_to_container_or_struct?}}
{{#if field:optional?}}

{{> common/field_docblock}}
[[deprecated("Use `FOO.{{field:cpp_name}}().value();` instead of `FOO.get_{{field:cpp_name}}();`")]]
const {{type:cpp_type}}* get_{{field:cpp_name}}() const&;

{{> common/field_docblock}}
[[deprecated("Use `FOO.{{field:cpp_name}}().value();` instead of `FOO.get_{{field:cpp_name}}();`")]]
{{type:cpp_type}}* get_{{field:cpp_name}}() &;

{{> common/field_docblock}}
[[deprecated("Use `FOO.{{field:cpp_name}}().value();` instead of `FOO.get_{{field:cpp_name}}();`")]]
{{type:cpp_type}}* get_{{field:cpp_name}}() && = delete;
{{type:cpp_type}} get_{{field:cpp_name}}() const;
{{#else}}

{{> common/field_docblock}}
Expand All @@ -80,16 +41,13 @@
{{> common/field_docblock}}
[[deprecated("Use `FOO.{{field:cpp_name}}().value();` instead of `FOO.get_{{field:cpp_name}}();`")]]
{{type:cpp_type}} get_{{field:cpp_name}}() &&;
{{/if field:optional?}}
{{/type:resolves_to_container_or_struct?}}
{{/if type:resolves_to_fixed_size?}}
{{/if field:optional?}}
{{#if type:resolves_to_fixed_size?}}

{{> common/field_docblock}}
[[deprecated("Use `FOO.{{field:cpp_name}}() = BAR;` instead of `FOO.set_{{field:cpp_name}}(BAR);`")]]
{{type:cpp_type}}& set_{{field:cpp_name}}({{type:cpp_type}} {{field:cpp_name}}_) {
{{field:cpp_name}}_ref() = {{field:cpp_name}}_;
return {{field:cpp_storage_name}};
}
{{type:cpp_type}}& set_{{field:cpp_name}}({{type:cpp_type}} {{field:cpp_name}}_);
{{#else}}

{{> common/field_docblock}}
Expand Down
Loading

0 comments on commit d8eba66

Please sign in to comment.