Skip to content

Commit 78bf666

Browse files
hchokshimeta-codesync[bot]
authored andcommitted
Replace 'program_name' property with program prototype's 'name` in cpp2 generator
Summary: Replace `foo:program_name` property with Whisker program prototype's `name` property (`foo:program.name`). `service:program` is always non-null. `type:program` is null for primitives. Reviewed By: iahs Differential Revision: D90034984 fbshipit-source-id: 3663bda06346ae22e9eca0e41b4752a3d85af7dc
1 parent d78bc90 commit 78bf666

7 files changed

Lines changed: 12 additions & 16 deletions

File tree

third-party/thrift/src/thrift/compiler/generate/t_mstch_cpp2_generator.cc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -590,10 +590,6 @@ class t_mstch_cpp2_generator : public t_mstch_generator {
590590
auto base = t_whisker_generator::make_prototype_for_type(proto);
591591
auto def = whisker::dsl::prototype_builder<h_type>::extends(base);
592592

593-
def.property("program_name", [](const t_type& type) {
594-
return type.program() ? type.program()->name() : "";
595-
});
596-
597593
def.property("qualified_namespace", [](const t_type& type) {
598594
return cpp2::get_gen_unprefixed_namespace(*type.program());
599595
});

third-party/thrift/src/thrift/compiler/generate/templates/cpp2/ServiceAsyncClient.h.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020

2121
#include <thrift/lib/cpp2/gen/client_h.h>
2222

23-
#include "{{service:include_prefix}}{{service:program_name}}_types.h"
23+
#include "{{service:include_prefix}}{{service:program.name}}_types.h"
2424
{{#service:extends}}
2525
#if __has_include("{{service:include_prefix}}{{service:name}}AsyncClient.h")
2626
#include "{{service:include_prefix}}{{service:name}}AsyncClient.h"
2727
#else
28-
#include "{{service:include_prefix}}{{service:program_name}}_clients.h"
28+
#include "{{service:include_prefix}}{{service:program.name}}_clients.h"
2929
#endif
3030
{{/service:extends}}
3131
{{#service:thrift_includes}}

third-party/thrift/src/thrift/compiler/generate/templates/cpp2/common/metadata.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
{{#else if value.structured?}}
2929
{{#let ttype = value.type.true_type}}
30-
cvStruct("{{ttype.program_name}}.{{ttype.name}}", { {{!}}
30+
cvStruct("{{ttype.program.name}}.{{ttype.name}}", { {{!}}
3131
{{#each (array.enumerate value.structured_elements with_last=true) as |i elem last?|}}
3232
{"{{elem.field.name}}", {{#partial cv_metadata value=elem.value}} }{{#if (not last?)}}, {{/if}}
3333
{{/each}}

third-party/thrift/src/thrift/compiler/generate/templates/cpp2/metadata/type_gen.mustache

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
limitations under the License.
1616
1717
}}{{#if type:typedef?}}{{!
18-
}}std::make_unique<Typedef>("{{type:program_name}}.{{type:cpp_name}}", {{#type:typedef_type}}{{> metadata/type_gen}}{{/type:typedef_type}}, std::vector<ThriftConstStruct>{ {{!
18+
}}std::make_unique<Typedef>("{{type:program.name}}.{{type:cpp_name}}", {{#type:typedef_type}}{{> metadata/type_gen}}{{/type:typedef_type}}, std::vector<ThriftConstStruct>{ {{!
1919
}}{{#type:typedef}}{{#each typedef:self.structured_annotations as |annot|}}{{!
2020
}}{{#if annot.type.structured?}}{{#partial metadata.structured_annotation value=annot.value}}, {{/if}}{{!
2121
}}{{/each}}{{/type:typedef}} }){{!
@@ -37,9 +37,9 @@
3737
}}{{#type:list?}}std::make_unique<List>({{#type:list_elem_type}}{{> metadata/type_gen}}{{/type:list_elem_type}}){{/type:list?}}{{!
3838
}}{{#type:set?}}std::make_unique<Set>({{#type:set_elem_type}}{{> metadata/type_gen}}{{/type:set_elem_type}}){{/type:set?}}{{!
3939
}}{{#type:map?}}std::make_unique<Map>({{#type:key_type}}{{> metadata/type_gen}}{{/type:key_type}}, {{#type:value_type}}{{> metadata/type_gen}}{{/type:value_type}}){{/type:map?}}{{!
40-
}}{{#type:enum?}}std::make_unique<Enum<{{type:cpp_standard_type}}>>("{{type:program_name}}.{{#type:enum}}{{enum:name}}{{/type:enum}}"){{/type:enum?}}{{!
40+
}}{{#type:enum?}}std::make_unique<Enum<{{type:cpp_standard_type}}>>("{{type:program.name}}.{{#type:enum}}{{enum:name}}{{/type:enum}}"){{/type:enum?}}{{!
4141
}}{{#type:structured?}}{{!
42-
}}{{#type:union?}}std::make_unique<Union<{{type:cpp_standard_type}}>>("{{type:program_name}}.{{type:name}}"){{/type:union?}}{{!
43-
}}{{^type:union?}}std::make_unique<Struct<{{type:cpp_standard_type}}>>("{{type:program_name}}.{{type:name}}"){{/type:union?}}{{!
42+
}}{{#type:union?}}std::make_unique<Union<{{type:cpp_standard_type}}>>("{{type:program.name}}.{{type:name}}"){{/type:union?}}{{!
43+
}}{{^type:union?}}std::make_unique<Struct<{{type:cpp_standard_type}}>>("{{type:program.name}}.{{type:name}}"){{/type:union?}}{{!
4444
}}{{/type:structured?}}{{!
4545
}}{{/type:primitive?}}{{/if type:typedef?}}

third-party/thrift/src/thrift/compiler/generate/templates/cpp2/service.cpp.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020

2121
#include "{{service:include_prefix}}{{service:name}}.h"
2222
#include "{{service:include_prefix}}{{service:name}}.tcc"
23-
#include "{{service:include_prefix}}{{service:program_name}}_metadata.h"
23+
#include "{{service:include_prefix}}{{service:program.name}}_metadata.h"
2424
{{#service:has_service_schema}}
25-
#include "{{service:include_prefix}}{{service:program_name}}_constants.h"
25+
#include "{{service:include_prefix}}{{service:program.name}}_constants.h"
2626
{{/service:has_service_schema}}
2727
#include <thrift/lib/cpp2/gen/service_cpp.h>
2828

third-party/thrift/src/thrift/compiler/generate/templates/cpp2/service.h.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121
#include <thrift/lib/cpp2/gen/service_h.h>
2222

2323
#include "{{service:include_prefix}}{{service:name}}AsyncClient.h"
24-
#include "{{service:include_prefix}}{{service:program_name}}_types.h"
24+
#include "{{service:include_prefix}}{{service:program.name}}_types.h"
2525
{{#service:extends}}
2626
#if __has_include("{{service:include_prefix}}{{service:name}}.h")
2727
#include "{{service:include_prefix}}{{service:name}}.h"
2828
#else
29-
#include "{{service:include_prefix}}{{service:program_name}}_handlers.h"
29+
#include "{{service:include_prefix}}{{service:program.name}}_handlers.h"
3030
#endif
3131
{{/service:extends}}
3232
{{#service:thrift_includes}}

third-party/thrift/src/thrift/compiler/generate/templates/cpp2/types_custom_protocol.h.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
*/
2727

2828
#include "{{service:include_prefix}}{{service:name}}.tcc"
29-
#include "{{service:include_prefix}}{{service:program_name}}_types_custom_protocol.h"
29+
#include "{{service:include_prefix}}{{service:program.name}}_types_custom_protocol.h"
3030
{{#service:extends}}
3131
#include "{{service:include_prefix}}{{service:name}}_custom_protocol.h"
3232
{{/service:extends}}

0 commit comments

Comments
 (0)