Skip to content

Commit ded459e

Browse files
hchokshimeta-codesync[bot]
authored andcommitted
Remove deprecated AST method t_interface::is_interaction
Summary: Replace usages with `is<t_interaction>`, which is the underlying implementation. Reviewed By: iahs Differential Revision: D84549238 fbshipit-source-id: ef26e5ffba411549fb2a3722a272569641471762
1 parent 2a5d0b6 commit ded459e

6 files changed

Lines changed: 23 additions & 26 deletions

File tree

third-party/thrift/src/thrift/compiler/ast/t_interface.cc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,6 @@ void t_interface::add_function(std::unique_ptr<t_function> func) {
3535
functions_.push_back(std::move(func));
3636
}
3737

38-
bool t_interface::is_interaction() const {
39-
return this->is<t_interaction>();
40-
}
41-
4238
t_interface::~t_interface() = default;
4339

4440
} // namespace apache::thrift::compiler

third-party/thrift/src/thrift/compiler/ast/t_interface.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ class t_interface : public t_type {
5757
const std::vector<t_function*>& get_functions() const {
5858
return old_functions_raw_;
5959
}
60-
61-
bool is_interaction() const;
6260
};
6361

6462
} // namespace apache::thrift::compiler

third-party/thrift/src/thrift/compiler/generate/mstch_objects.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ class mstch_service : public mstch_base {
465465
: mstch_base(ctx, pos),
466466
service_(s),
467467
containing_service_(containing_service) {
468-
assert(containing_service_ == nullptr || service_->is_interaction());
468+
assert(containing_service_ == nullptr || service_->is<t_interaction>());
469469

470470
register_methods(
471471
this,
@@ -553,7 +553,7 @@ class mstch_service : public mstch_base {
553553
mstch::node structured_annotations() {
554554
return mstch_base::structured_annotations(service_);
555555
}
556-
mstch::node is_interaction() { return service_->is_interaction(); }
556+
mstch::node is_interaction() { return service_->is<t_interaction>(); }
557557

558558
~mstch_service() override = default;
559559

@@ -570,7 +570,7 @@ class mstch_service : public mstch_base {
570570
return service_->get_functions();
571571
}
572572
const t_service* parent_service() const {
573-
return service_->is_interaction() ? containing_service_ : service_;
573+
return service_->is<t_interaction>() ? containing_service_ : service_;
574574
}
575575
};
576576

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

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5641,7 +5641,7 @@ void t_hack_generator::_generate_sendImplHelper(
56415641
const t_service* tservice) {
56425642
std::string long_name = php_servicename_mangle(mangled_services_, tservice);
56435643
const std::string& tservice_name =
5644-
(tservice->is_interaction()
5644+
(tservice->is<t_interaction>()
56455645
? "\"" + service_name_ + "\""
56465646
: long_name + "StaticMetadata::THRIFT_SVC_NAME");
56475647
out << "$this->sendImplHelper($args, " << "\"" << find_hack_name(tfunction)
@@ -6946,7 +6946,7 @@ void t_hack_generator::_generate_current_seq_id(
69466946
std::ofstream& out,
69476947
const t_service* tservice,
69486948
const t_function* tfunction) {
6949-
if (tservice->is_interaction()) {
6949+
if (tservice->is<t_interaction>()) {
69506950
indent(out) << "$currentseqid = $this->sendImpl_" << tfunction->name()
69516951
<< "(";
69526952

@@ -6970,7 +6970,7 @@ void t_hack_generator::_generate_sendImpl(
69706970
const std::string& rpc_function_name =
69716971
generate_rpc_function_name(tservice, tfunction);
69726972
const std::string& tservice_name =
6973-
(tservice->is_interaction() ? service_name_ : tservice->name());
6973+
(tservice->is<t_interaction>() ? service_name_ : tservice->name());
69746974

69756975
if (nullable_everything_) {
69766976
indent(out) << "protected function sendImpl_" << funname << "("
@@ -7199,7 +7199,7 @@ void t_hack_generator::_generate_service_client_child_fn(
71997199
find_hack_name(tfunction) + (legacy_arrays ? "__LEGACY_ARRAYS" : "");
72007200
std::string long_name = php_servicename_mangle(mangled_services_, tservice);
72017201
const std::string& tservice_name =
7202-
(tservice->is_interaction()
7202+
(tservice->is<t_interaction>()
72037203
? "\"" + service_name_ + "\""
72047204
: long_name + "StaticMetadata::THRIFT_SVC_NAME");
72057205
std::string return_typehint =
@@ -7246,11 +7246,11 @@ void t_hack_generator::_generate_service_client_child_fn(
72467246
}
72477247

72487248
indent(out) << "$rpc_options = $this->getAndResetOptions() ?? "
7249-
<< (tservice->is_interaction()
7249+
<< (tservice->is<t_interaction>()
72507250
? "new \\RpcOptions()"
72517251
: "\\ThriftClientBase::defaultOptions()")
72527252
<< ";\n";
7253-
if (tservice->is_interaction()) {
7253+
if (tservice->is<t_interaction>()) {
72547254
indent(out) << "$rpc_options = "
72557255
"$rpc_options->setInteractionId($this->interactionId);\n";
72567256
}
@@ -7308,7 +7308,7 @@ void t_hack_generator::_generate_service_client_stream_child_fn(
73087308
std::string funname =
73097309
tfunction->name() + (legacy_arrays ? "__LEGACY_ARRAYS" : "");
73107310
const std::string& tservice_name =
7311-
(tservice->is_interaction() ? service_name_ : tservice->name());
7311+
(tservice->is<t_interaction>() ? service_name_ : tservice->name());
73127312
std::string return_typehint = get_stream_function_return_typehint(tfunction);
73137313

73147314
generate_php_docstring(out, tfunction);
@@ -7327,11 +7327,11 @@ void t_hack_generator::_generate_service_client_stream_child_fn(
73277327
indent(out) << "}\n";
73287328

73297329
indent(out) << "$rpc_options = $this->getAndResetOptions() ?? "
7330-
<< (tservice->is_interaction()
7330+
<< (tservice->is<t_interaction>()
73317331
? "new \\RpcOptions()"
73327332
: "\\ThriftClientBase::defaultOptions()")
73337333
<< ";\n";
7334-
if (tservice->is_interaction()) {
7334+
if (tservice->is<t_interaction>()) {
73357335
indent(out) << "$rpc_options = "
73367336
"$rpc_options->setInteractionId($this->interactionId);\n";
73377337
}
@@ -7367,7 +7367,7 @@ void t_hack_generator::_generate_service_client_sink_child_fn(
73677367
std::string funname =
73687368
tfunction->name() + (legacy_arrays ? "__LEGACY_ARRAYS" : "");
73697369
const std::string& tservice_name =
7370-
(tservice->is_interaction() ? service_name_ : tservice->name());
7370+
(tservice->is<t_interaction>() ? service_name_ : tservice->name());
73717371

73727372
generate_php_docstring(out, tfunction);
73737373
std::string return_typehint = get_sink_function_return_typehint(tfunction);
@@ -7386,11 +7386,11 @@ void t_hack_generator::_generate_service_client_sink_child_fn(
73867386
indent(out) << "}\n";
73877387

73887388
indent(out) << "$rpc_options = $this->getAndResetOptions() ?? "
7389-
<< (tservice->is_interaction()
7389+
<< (tservice->is<t_interaction>()
73907390
? "new \\RpcOptions()"
73917391
: "\\ThriftClientBase::defaultOptions()")
73927392
<< ";\n";
7393-
if (tservice->is_interaction()) {
7393+
if (tservice->is<t_interaction>()) {
73947394
out << "$rpc_options->setInteractionId($this->interactionId);\n";
73957395
}
73967396

@@ -7551,7 +7551,8 @@ std::string t_hack_generator::argument_list(
75517551
*/
75527552
std::string t_hack_generator::generate_rpc_function_name(
75537553
const t_service* tservice, const t_function* tfunction) const {
7554-
std::string prefix = tservice->is_interaction() ? tservice->name() + "." : "";
7554+
std::string prefix =
7555+
tservice->is<t_interaction>() ? tservice->name() + "." : "";
75557556
return prefix + find_hack_name(tfunction);
75567557
}
75577558

@@ -7564,7 +7565,7 @@ std::string t_hack_generator::generate_function_helper_name(
75647565
const t_function* tfunction,
75657566
PhpFunctionNameSuffix suffix) {
75667567
std::string prefix;
7567-
if (tservice->is_interaction()) {
7568+
if (tservice->is<t_interaction>()) {
75687569
prefix = hack_name(service_name_, program_) + "_" + tservice->name();
75697570
} else {
75707571
prefix = hack_name(tservice);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ bool has_schema(source_manager& sm, const t_program& program) {
210210
}
211211

212212
bool generate_reduced_client(const t_interface& i) {
213-
return i.is_interaction();
213+
return i.is<t_interaction>();
214214
}
215215

216216
// Compute the set of types that appear anywhere in the service
@@ -1309,7 +1309,7 @@ class cpp_mstch_function : public mstch_function {
13091309

13101310
mstch::node prefixed_name() {
13111311
const std::string& name = cpp2::get_name(function_);
1312-
return interface().is_interaction()
1312+
return interface().is<t_interaction>()
13131313
? fmt::format("{}_{}", interface().name(), name)
13141314
: name;
13151315
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,9 @@ prototype<t_interface>::ptr t_whisker_generator::make_prototype_for_interface(
772772
auto def = prototype_builder<h_interface>::extends(proto.of<t_type>());
773773
def.property(
774774
"functions", mem_fn(&t_interface::functions, proto.of<t_function>()));
775-
def.property("interaction?", mem_fn(&t_interface::is_interaction));
775+
def.property("interaction?", [](const t_interface& self) {
776+
return self.is<t_interaction>();
777+
});
776778
return std::move(def).make();
777779
}
778780

0 commit comments

Comments
 (0)