1 /**
2  * Autogenerated by Thrift for src/module.thrift
3  *
4  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5  *  @generated @nocommit
6  */
7 #pragma once
8 
9 #include <thrift/lib/cpp2/gen/client_h.h>
10 
11 #include "thrift/compiler/test/fixtures/visitation/gen-cpp2/module_types.h"
12 #include "thrift/compiler/test/fixtures/visitation/gen-cpp2/reflection_dep_B_types.h"
13 #include "thrift/compiler/test/fixtures/visitation/gen-cpp2/reflection_dep_C_types.h"
14 #include "thrift/test/fatal_custom_types.h"
15 
16 namespace apache { namespace thrift {
17   class Cpp2RequestContext;
18   namespace detail { namespace ac { struct ClientRequestContext; }}
19   namespace transport { class THeader; }
20 }}
21 
22 namespace test_cpp2 { namespace cpp_reflection {
23 
24 class service3AsyncClient : public apache::thrift::GeneratedAsyncClient {
25  public:
26   using apache::thrift::GeneratedAsyncClient::GeneratedAsyncClient;
27 
getServiceName()28   char const* getServiceName() const noexcept override {
29     return "service3";
30   }
31 
32 
33   virtual void methodA(std::unique_ptr<apache::thrift::RequestCallback> callback);
34   virtual void methodA(apache::thrift::RpcOptions& rpcOptions, std::unique_ptr<apache::thrift::RequestCallback> callback);
35  protected:
36   void methodAImpl(apache::thrift::RpcOptions& rpcOptions, std::shared_ptr<apache::thrift::transport::THeader> header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback, bool stealRpcOptions = false);
37  public:
38 
39   virtual void sync_methodA();
40   virtual void sync_methodA(apache::thrift::RpcOptions& rpcOptions);
41 
42   virtual folly::Future<folly::Unit> future_methodA();
43   virtual folly::SemiFuture<folly::Unit> semifuture_methodA();
44   virtual folly::Future<folly::Unit> future_methodA(apache::thrift::RpcOptions& rpcOptions);
45   virtual folly::SemiFuture<folly::Unit> semifuture_methodA(apache::thrift::RpcOptions& rpcOptions);
46   virtual folly::Future<std::pair<folly::Unit, std::unique_ptr<apache::thrift::transport::THeader>>> header_future_methodA(apache::thrift::RpcOptions& rpcOptions);
47   virtual folly::SemiFuture<std::pair<folly::Unit, std::unique_ptr<apache::thrift::transport::THeader>>> header_semifuture_methodA(apache::thrift::RpcOptions& rpcOptions);
48 
49 #if FOLLY_HAS_COROUTINES
50   template <int = 0>
co_methodA()51   folly::coro::Task<void> co_methodA() {
52     return co_methodA<false>(nullptr);
53   }
54   template <int = 0>
co_methodA(apache::thrift::RpcOptions & rpcOptions)55   folly::coro::Task<void> co_methodA(apache::thrift::RpcOptions& rpcOptions) {
56     return co_methodA<true>(&rpcOptions);
57   }
58  private:
59   template <bool hasRpcOptions>
co_methodA(apache::thrift::RpcOptions * rpcOptions)60   folly::coro::Task<void> co_methodA(apache::thrift::RpcOptions* rpcOptions) {
61     const folly::CancellationToken& cancelToken =
62         co_await folly::coro::co_current_cancellation_token;
63     const bool cancellable = cancelToken.canBeCancelled();
64     apache::thrift::ClientReceiveState returnState;
65     apache::thrift::ClientSyncCallback<false> callback(&returnState);
66     auto protocolId = apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId();
67     auto [ctx, header] = methodACtx(rpcOptions);
68     using CancellableCallback = apache::thrift::CancellableRequestClientCallback<false>;
69     auto cancellableCallback = cancellable ? CancellableCallback::create(&callback, channel_) : nullptr;
70     static apache::thrift::RpcOptions defaultRpcOptions;
71     auto wrappedCallback = apache::thrift::RequestClientCallback::Ptr(cancellableCallback ? (apache::thrift::RequestClientCallback*)cancellableCallback.get() : &callback);
72     if constexpr (hasRpcOptions) {
73       methodAImpl(*rpcOptions, std::move(header), ctx.get(), std::move(wrappedCallback));
74     } else {
75       methodAImpl(defaultRpcOptions, std::move(header), ctx.get(), std::move(wrappedCallback));
76     }
77     if (cancellable) {
78       folly::CancellationCallback cb(cancelToken, [&] { CancellableCallback::cancel(std::move(cancellableCallback)); });
79       co_await callback.co_waitUntilDone();
80     } else {
81       co_await callback.co_waitUntilDone();
82     }
83     if (returnState.isException()) {
84       co_yield folly::coro::co_error(std::move(returnState.exception()));
85     }
86     returnState.resetProtocolId(protocolId);
87     returnState.resetCtx(std::move(ctx));
88     SCOPE_EXIT {
89       if (hasRpcOptions && returnState.header()) {
90         auto* rheader = returnState.header();
91         if (!rheader->getHeaders().empty()) {
92           rpcOptions->setReadHeaders(rheader->releaseHeaders());
93         }
94         rpcOptions->setRoutingData(rheader->releaseRoutingData());
95       }
96     };
97     if (auto ew = recv_wrapped_methodA(returnState)) {
98       co_yield folly::coro::co_error(std::move(ew));
99     }
100   }
101  public:
102 #endif // FOLLY_HAS_COROUTINES
103 
104   virtual void methodA(folly::Function<void (::apache::thrift::ClientReceiveState&&)> callback);
105 
106 
107   static folly::exception_wrapper recv_wrapped_methodA(::apache::thrift::ClientReceiveState& state);
108   static void recv_methodA(::apache::thrift::ClientReceiveState& state);
109   // Mock friendly virtual instance method
110   virtual void recv_instance_methodA(::apache::thrift::ClientReceiveState& state);
111   virtual folly::exception_wrapper recv_instance_wrapped_methodA(::apache::thrift::ClientReceiveState& state);
112  private:
113   template <typename Protocol_, typename RpcOptions>
114   void methodAT(Protocol_* prot, RpcOptions&& rpcOptions, std::shared_ptr<apache::thrift::transport::THeader> header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback);
115   std::pair<std::unique_ptr<::apache::thrift::ContextStack>, std::shared_ptr<::apache::thrift::transport::THeader>> methodACtx(apache::thrift::RpcOptions* rpcOptions);
116  public:
117   virtual void methodB(std::unique_ptr<apache::thrift::RequestCallback> callback, ::std::int32_t p_x, const ::test_cpp2::cpp_reflection::struct1& p_y, double p_z);
118   virtual void methodB(apache::thrift::RpcOptions& rpcOptions, std::unique_ptr<apache::thrift::RequestCallback> callback, ::std::int32_t p_x, const ::test_cpp2::cpp_reflection::struct1& p_y, double p_z);
119  protected:
120   void methodBImpl(apache::thrift::RpcOptions& rpcOptions, std::shared_ptr<apache::thrift::transport::THeader> header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback, ::std::int32_t p_x, const ::test_cpp2::cpp_reflection::struct1& p_y, double p_z, bool stealRpcOptions = false);
121  public:
122 
123   virtual void sync_methodB(::std::int32_t p_x, const ::test_cpp2::cpp_reflection::struct1& p_y, double p_z);
124   virtual void sync_methodB(apache::thrift::RpcOptions& rpcOptions, ::std::int32_t p_x, const ::test_cpp2::cpp_reflection::struct1& p_y, double p_z);
125 
126   virtual folly::Future<folly::Unit> future_methodB(::std::int32_t p_x, const ::test_cpp2::cpp_reflection::struct1& p_y, double p_z);
127   virtual folly::SemiFuture<folly::Unit> semifuture_methodB(::std::int32_t p_x, const ::test_cpp2::cpp_reflection::struct1& p_y, double p_z);
128   virtual folly::Future<folly::Unit> future_methodB(apache::thrift::RpcOptions& rpcOptions, ::std::int32_t p_x, const ::test_cpp2::cpp_reflection::struct1& p_y, double p_z);
129   virtual folly::SemiFuture<folly::Unit> semifuture_methodB(apache::thrift::RpcOptions& rpcOptions, ::std::int32_t p_x, const ::test_cpp2::cpp_reflection::struct1& p_y, double p_z);
130   virtual folly::Future<std::pair<folly::Unit, std::unique_ptr<apache::thrift::transport::THeader>>> header_future_methodB(apache::thrift::RpcOptions& rpcOptions, ::std::int32_t p_x, const ::test_cpp2::cpp_reflection::struct1& p_y, double p_z);
131   virtual folly::SemiFuture<std::pair<folly::Unit, std::unique_ptr<apache::thrift::transport::THeader>>> header_semifuture_methodB(apache::thrift::RpcOptions& rpcOptions, ::std::int32_t p_x, const ::test_cpp2::cpp_reflection::struct1& p_y, double p_z);
132 
133 #if FOLLY_HAS_COROUTINES
134   template <int = 0>
co_methodB(::std::int32_t p_x,const::test_cpp2::cpp_reflection::struct1 & p_y,double p_z)135   folly::coro::Task<void> co_methodB(::std::int32_t p_x, const ::test_cpp2::cpp_reflection::struct1& p_y, double p_z) {
136     return co_methodB<false>(nullptr, p_x, p_y, p_z);
137   }
138   template <int = 0>
co_methodB(apache::thrift::RpcOptions & rpcOptions,::std::int32_t p_x,const::test_cpp2::cpp_reflection::struct1 & p_y,double p_z)139   folly::coro::Task<void> co_methodB(apache::thrift::RpcOptions& rpcOptions, ::std::int32_t p_x, const ::test_cpp2::cpp_reflection::struct1& p_y, double p_z) {
140     return co_methodB<true>(&rpcOptions, p_x, p_y, p_z);
141   }
142  private:
143   template <bool hasRpcOptions>
co_methodB(apache::thrift::RpcOptions * rpcOptions,::std::int32_t p_x,const::test_cpp2::cpp_reflection::struct1 & p_y,double p_z)144   folly::coro::Task<void> co_methodB(apache::thrift::RpcOptions* rpcOptions, ::std::int32_t p_x, const ::test_cpp2::cpp_reflection::struct1& p_y, double p_z) {
145     const folly::CancellationToken& cancelToken =
146         co_await folly::coro::co_current_cancellation_token;
147     const bool cancellable = cancelToken.canBeCancelled();
148     apache::thrift::ClientReceiveState returnState;
149     apache::thrift::ClientSyncCallback<false> callback(&returnState);
150     auto protocolId = apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId();
151     auto [ctx, header] = methodBCtx(rpcOptions);
152     using CancellableCallback = apache::thrift::CancellableRequestClientCallback<false>;
153     auto cancellableCallback = cancellable ? CancellableCallback::create(&callback, channel_) : nullptr;
154     static apache::thrift::RpcOptions defaultRpcOptions;
155     auto wrappedCallback = apache::thrift::RequestClientCallback::Ptr(cancellableCallback ? (apache::thrift::RequestClientCallback*)cancellableCallback.get() : &callback);
156     if constexpr (hasRpcOptions) {
157       methodBImpl(*rpcOptions, std::move(header), ctx.get(), std::move(wrappedCallback), p_x, p_y, p_z);
158     } else {
159       methodBImpl(defaultRpcOptions, std::move(header), ctx.get(), std::move(wrappedCallback), p_x, p_y, p_z);
160     }
161     if (cancellable) {
162       folly::CancellationCallback cb(cancelToken, [&] { CancellableCallback::cancel(std::move(cancellableCallback)); });
163       co_await callback.co_waitUntilDone();
164     } else {
165       co_await callback.co_waitUntilDone();
166     }
167     if (returnState.isException()) {
168       co_yield folly::coro::co_error(std::move(returnState.exception()));
169     }
170     returnState.resetProtocolId(protocolId);
171     returnState.resetCtx(std::move(ctx));
172     SCOPE_EXIT {
173       if (hasRpcOptions && returnState.header()) {
174         auto* rheader = returnState.header();
175         if (!rheader->getHeaders().empty()) {
176           rpcOptions->setReadHeaders(rheader->releaseHeaders());
177         }
178         rpcOptions->setRoutingData(rheader->releaseRoutingData());
179       }
180     };
181     if (auto ew = recv_wrapped_methodB(returnState)) {
182       co_yield folly::coro::co_error(std::move(ew));
183     }
184   }
185  public:
186 #endif // FOLLY_HAS_COROUTINES
187 
188   virtual void methodB(folly::Function<void (::apache::thrift::ClientReceiveState&&)> callback, ::std::int32_t p_x, const ::test_cpp2::cpp_reflection::struct1& p_y, double p_z);
189 
190 
191   static folly::exception_wrapper recv_wrapped_methodB(::apache::thrift::ClientReceiveState& state);
192   static void recv_methodB(::apache::thrift::ClientReceiveState& state);
193   // Mock friendly virtual instance method
194   virtual void recv_instance_methodB(::apache::thrift::ClientReceiveState& state);
195   virtual folly::exception_wrapper recv_instance_wrapped_methodB(::apache::thrift::ClientReceiveState& state);
196  private:
197   template <typename Protocol_, typename RpcOptions>
198   void methodBT(Protocol_* prot, RpcOptions&& rpcOptions, std::shared_ptr<apache::thrift::transport::THeader> header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback, ::std::int32_t p_x, const ::test_cpp2::cpp_reflection::struct1& p_y, double p_z);
199   std::pair<std::unique_ptr<::apache::thrift::ContextStack>, std::shared_ptr<::apache::thrift::transport::THeader>> methodBCtx(apache::thrift::RpcOptions* rpcOptions);
200  public:
201   virtual void methodC(std::unique_ptr<apache::thrift::RequestCallback> callback);
202   virtual void methodC(apache::thrift::RpcOptions& rpcOptions, std::unique_ptr<apache::thrift::RequestCallback> callback);
203  protected:
204   void methodCImpl(apache::thrift::RpcOptions& rpcOptions, std::shared_ptr<apache::thrift::transport::THeader> header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback, bool stealRpcOptions = false);
205  public:
206 
207   virtual ::std::int32_t sync_methodC();
208   virtual ::std::int32_t sync_methodC(apache::thrift::RpcOptions& rpcOptions);
209 
210   virtual folly::Future<::std::int32_t> future_methodC();
211   virtual folly::SemiFuture<::std::int32_t> semifuture_methodC();
212   virtual folly::Future<::std::int32_t> future_methodC(apache::thrift::RpcOptions& rpcOptions);
213   virtual folly::SemiFuture<::std::int32_t> semifuture_methodC(apache::thrift::RpcOptions& rpcOptions);
214   virtual folly::Future<std::pair<::std::int32_t, std::unique_ptr<apache::thrift::transport::THeader>>> header_future_methodC(apache::thrift::RpcOptions& rpcOptions);
215   virtual folly::SemiFuture<std::pair<::std::int32_t, std::unique_ptr<apache::thrift::transport::THeader>>> header_semifuture_methodC(apache::thrift::RpcOptions& rpcOptions);
216 
217 #if FOLLY_HAS_COROUTINES
218   template <int = 0>
co_methodC()219   folly::coro::Task<::std::int32_t> co_methodC() {
220     return co_methodC<false>(nullptr);
221   }
222   template <int = 0>
co_methodC(apache::thrift::RpcOptions & rpcOptions)223   folly::coro::Task<::std::int32_t> co_methodC(apache::thrift::RpcOptions& rpcOptions) {
224     return co_methodC<true>(&rpcOptions);
225   }
226  private:
227   template <bool hasRpcOptions>
co_methodC(apache::thrift::RpcOptions * rpcOptions)228   folly::coro::Task<::std::int32_t> co_methodC(apache::thrift::RpcOptions* rpcOptions) {
229     const folly::CancellationToken& cancelToken =
230         co_await folly::coro::co_current_cancellation_token;
231     const bool cancellable = cancelToken.canBeCancelled();
232     apache::thrift::ClientReceiveState returnState;
233     apache::thrift::ClientSyncCallback<false> callback(&returnState);
234     auto protocolId = apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId();
235     auto [ctx, header] = methodCCtx(rpcOptions);
236     using CancellableCallback = apache::thrift::CancellableRequestClientCallback<false>;
237     auto cancellableCallback = cancellable ? CancellableCallback::create(&callback, channel_) : nullptr;
238     static apache::thrift::RpcOptions defaultRpcOptions;
239     auto wrappedCallback = apache::thrift::RequestClientCallback::Ptr(cancellableCallback ? (apache::thrift::RequestClientCallback*)cancellableCallback.get() : &callback);
240     if constexpr (hasRpcOptions) {
241       methodCImpl(*rpcOptions, std::move(header), ctx.get(), std::move(wrappedCallback));
242     } else {
243       methodCImpl(defaultRpcOptions, std::move(header), ctx.get(), std::move(wrappedCallback));
244     }
245     if (cancellable) {
246       folly::CancellationCallback cb(cancelToken, [&] { CancellableCallback::cancel(std::move(cancellableCallback)); });
247       co_await callback.co_waitUntilDone();
248     } else {
249       co_await callback.co_waitUntilDone();
250     }
251     if (returnState.isException()) {
252       co_yield folly::coro::co_error(std::move(returnState.exception()));
253     }
254     returnState.resetProtocolId(protocolId);
255     returnState.resetCtx(std::move(ctx));
256     SCOPE_EXIT {
257       if (hasRpcOptions && returnState.header()) {
258         auto* rheader = returnState.header();
259         if (!rheader->getHeaders().empty()) {
260           rpcOptions->setReadHeaders(rheader->releaseHeaders());
261         }
262         rpcOptions->setRoutingData(rheader->releaseRoutingData());
263       }
264     };
265     ::std::int32_t _return;
266     if (auto ew = recv_wrapped_methodC(_return, returnState)) {
267       co_yield folly::coro::co_error(std::move(ew));
268     }
269     co_return _return;
270   }
271  public:
272 #endif // FOLLY_HAS_COROUTINES
273 
274   virtual void methodC(folly::Function<void (::apache::thrift::ClientReceiveState&&)> callback);
275 
276 
277   static folly::exception_wrapper recv_wrapped_methodC(::std::int32_t& _return, ::apache::thrift::ClientReceiveState& state);
278   static ::std::int32_t recv_methodC(::apache::thrift::ClientReceiveState& state);
279   // Mock friendly virtual instance method
280   virtual ::std::int32_t recv_instance_methodC(::apache::thrift::ClientReceiveState& state);
281   virtual folly::exception_wrapper recv_instance_wrapped_methodC(::std::int32_t& _return, ::apache::thrift::ClientReceiveState& state);
282  private:
283   template <typename Protocol_, typename RpcOptions>
284   void methodCT(Protocol_* prot, RpcOptions&& rpcOptions, std::shared_ptr<apache::thrift::transport::THeader> header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback);
285   std::pair<std::unique_ptr<::apache::thrift::ContextStack>, std::shared_ptr<::apache::thrift::transport::THeader>> methodCCtx(apache::thrift::RpcOptions* rpcOptions);
286  public:
287   virtual void methodD(std::unique_ptr<apache::thrift::RequestCallback> callback, ::std::int32_t p_i, const ::test_cpp2::cpp_reflection::struct1& p_j, double p_k);
288   virtual void methodD(apache::thrift::RpcOptions& rpcOptions, std::unique_ptr<apache::thrift::RequestCallback> callback, ::std::int32_t p_i, const ::test_cpp2::cpp_reflection::struct1& p_j, double p_k);
289  protected:
290   void methodDImpl(apache::thrift::RpcOptions& rpcOptions, std::shared_ptr<apache::thrift::transport::THeader> header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback, ::std::int32_t p_i, const ::test_cpp2::cpp_reflection::struct1& p_j, double p_k, bool stealRpcOptions = false);
291  public:
292 
293   virtual ::std::int32_t sync_methodD(::std::int32_t p_i, const ::test_cpp2::cpp_reflection::struct1& p_j, double p_k);
294   virtual ::std::int32_t sync_methodD(apache::thrift::RpcOptions& rpcOptions, ::std::int32_t p_i, const ::test_cpp2::cpp_reflection::struct1& p_j, double p_k);
295 
296   virtual folly::Future<::std::int32_t> future_methodD(::std::int32_t p_i, const ::test_cpp2::cpp_reflection::struct1& p_j, double p_k);
297   virtual folly::SemiFuture<::std::int32_t> semifuture_methodD(::std::int32_t p_i, const ::test_cpp2::cpp_reflection::struct1& p_j, double p_k);
298   virtual folly::Future<::std::int32_t> future_methodD(apache::thrift::RpcOptions& rpcOptions, ::std::int32_t p_i, const ::test_cpp2::cpp_reflection::struct1& p_j, double p_k);
299   virtual folly::SemiFuture<::std::int32_t> semifuture_methodD(apache::thrift::RpcOptions& rpcOptions, ::std::int32_t p_i, const ::test_cpp2::cpp_reflection::struct1& p_j, double p_k);
300   virtual folly::Future<std::pair<::std::int32_t, std::unique_ptr<apache::thrift::transport::THeader>>> header_future_methodD(apache::thrift::RpcOptions& rpcOptions, ::std::int32_t p_i, const ::test_cpp2::cpp_reflection::struct1& p_j, double p_k);
301   virtual folly::SemiFuture<std::pair<::std::int32_t, std::unique_ptr<apache::thrift::transport::THeader>>> header_semifuture_methodD(apache::thrift::RpcOptions& rpcOptions, ::std::int32_t p_i, const ::test_cpp2::cpp_reflection::struct1& p_j, double p_k);
302 
303 #if FOLLY_HAS_COROUTINES
304   template <int = 0>
co_methodD(::std::int32_t p_i,const::test_cpp2::cpp_reflection::struct1 & p_j,double p_k)305   folly::coro::Task<::std::int32_t> co_methodD(::std::int32_t p_i, const ::test_cpp2::cpp_reflection::struct1& p_j, double p_k) {
306     return co_methodD<false>(nullptr, p_i, p_j, p_k);
307   }
308   template <int = 0>
co_methodD(apache::thrift::RpcOptions & rpcOptions,::std::int32_t p_i,const::test_cpp2::cpp_reflection::struct1 & p_j,double p_k)309   folly::coro::Task<::std::int32_t> co_methodD(apache::thrift::RpcOptions& rpcOptions, ::std::int32_t p_i, const ::test_cpp2::cpp_reflection::struct1& p_j, double p_k) {
310     return co_methodD<true>(&rpcOptions, p_i, p_j, p_k);
311   }
312  private:
313   template <bool hasRpcOptions>
co_methodD(apache::thrift::RpcOptions * rpcOptions,::std::int32_t p_i,const::test_cpp2::cpp_reflection::struct1 & p_j,double p_k)314   folly::coro::Task<::std::int32_t> co_methodD(apache::thrift::RpcOptions* rpcOptions, ::std::int32_t p_i, const ::test_cpp2::cpp_reflection::struct1& p_j, double p_k) {
315     const folly::CancellationToken& cancelToken =
316         co_await folly::coro::co_current_cancellation_token;
317     const bool cancellable = cancelToken.canBeCancelled();
318     apache::thrift::ClientReceiveState returnState;
319     apache::thrift::ClientSyncCallback<false> callback(&returnState);
320     auto protocolId = apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId();
321     auto [ctx, header] = methodDCtx(rpcOptions);
322     using CancellableCallback = apache::thrift::CancellableRequestClientCallback<false>;
323     auto cancellableCallback = cancellable ? CancellableCallback::create(&callback, channel_) : nullptr;
324     static apache::thrift::RpcOptions defaultRpcOptions;
325     auto wrappedCallback = apache::thrift::RequestClientCallback::Ptr(cancellableCallback ? (apache::thrift::RequestClientCallback*)cancellableCallback.get() : &callback);
326     if constexpr (hasRpcOptions) {
327       methodDImpl(*rpcOptions, std::move(header), ctx.get(), std::move(wrappedCallback), p_i, p_j, p_k);
328     } else {
329       methodDImpl(defaultRpcOptions, std::move(header), ctx.get(), std::move(wrappedCallback), p_i, p_j, p_k);
330     }
331     if (cancellable) {
332       folly::CancellationCallback cb(cancelToken, [&] { CancellableCallback::cancel(std::move(cancellableCallback)); });
333       co_await callback.co_waitUntilDone();
334     } else {
335       co_await callback.co_waitUntilDone();
336     }
337     if (returnState.isException()) {
338       co_yield folly::coro::co_error(std::move(returnState.exception()));
339     }
340     returnState.resetProtocolId(protocolId);
341     returnState.resetCtx(std::move(ctx));
342     SCOPE_EXIT {
343       if (hasRpcOptions && returnState.header()) {
344         auto* rheader = returnState.header();
345         if (!rheader->getHeaders().empty()) {
346           rpcOptions->setReadHeaders(rheader->releaseHeaders());
347         }
348         rpcOptions->setRoutingData(rheader->releaseRoutingData());
349       }
350     };
351     ::std::int32_t _return;
352     if (auto ew = recv_wrapped_methodD(_return, returnState)) {
353       co_yield folly::coro::co_error(std::move(ew));
354     }
355     co_return _return;
356   }
357  public:
358 #endif // FOLLY_HAS_COROUTINES
359 
360   virtual void methodD(folly::Function<void (::apache::thrift::ClientReceiveState&&)> callback, ::std::int32_t p_i, const ::test_cpp2::cpp_reflection::struct1& p_j, double p_k);
361 
362 
363   static folly::exception_wrapper recv_wrapped_methodD(::std::int32_t& _return, ::apache::thrift::ClientReceiveState& state);
364   static ::std::int32_t recv_methodD(::apache::thrift::ClientReceiveState& state);
365   // Mock friendly virtual instance method
366   virtual ::std::int32_t recv_instance_methodD(::apache::thrift::ClientReceiveState& state);
367   virtual folly::exception_wrapper recv_instance_wrapped_methodD(::std::int32_t& _return, ::apache::thrift::ClientReceiveState& state);
368  private:
369   template <typename Protocol_, typename RpcOptions>
370   void methodDT(Protocol_* prot, RpcOptions&& rpcOptions, std::shared_ptr<apache::thrift::transport::THeader> header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback, ::std::int32_t p_i, const ::test_cpp2::cpp_reflection::struct1& p_j, double p_k);
371   std::pair<std::unique_ptr<::apache::thrift::ContextStack>, std::shared_ptr<::apache::thrift::transport::THeader>> methodDCtx(apache::thrift::RpcOptions* rpcOptions);
372  public:
373   virtual void methodE(std::unique_ptr<apache::thrift::RequestCallback> callback);
374   virtual void methodE(apache::thrift::RpcOptions& rpcOptions, std::unique_ptr<apache::thrift::RequestCallback> callback);
375  protected:
376   void methodEImpl(apache::thrift::RpcOptions& rpcOptions, std::shared_ptr<apache::thrift::transport::THeader> header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback, bool stealRpcOptions = false);
377  public:
378 
379   virtual void sync_methodE(::test_cpp2::cpp_reflection::struct2& _return);
380   virtual void sync_methodE(apache::thrift::RpcOptions& rpcOptions, ::test_cpp2::cpp_reflection::struct2& _return);
381 
382   virtual folly::Future<::test_cpp2::cpp_reflection::struct2> future_methodE();
383   virtual folly::SemiFuture<::test_cpp2::cpp_reflection::struct2> semifuture_methodE();
384   virtual folly::Future<::test_cpp2::cpp_reflection::struct2> future_methodE(apache::thrift::RpcOptions& rpcOptions);
385   virtual folly::SemiFuture<::test_cpp2::cpp_reflection::struct2> semifuture_methodE(apache::thrift::RpcOptions& rpcOptions);
386   virtual folly::Future<std::pair<::test_cpp2::cpp_reflection::struct2, std::unique_ptr<apache::thrift::transport::THeader>>> header_future_methodE(apache::thrift::RpcOptions& rpcOptions);
387   virtual folly::SemiFuture<std::pair<::test_cpp2::cpp_reflection::struct2, std::unique_ptr<apache::thrift::transport::THeader>>> header_semifuture_methodE(apache::thrift::RpcOptions& rpcOptions);
388 
389 #if FOLLY_HAS_COROUTINES
390   template <int = 0>
co_methodE()391   folly::coro::Task<::test_cpp2::cpp_reflection::struct2> co_methodE() {
392     return co_methodE<false>(nullptr);
393   }
394   template <int = 0>
co_methodE(apache::thrift::RpcOptions & rpcOptions)395   folly::coro::Task<::test_cpp2::cpp_reflection::struct2> co_methodE(apache::thrift::RpcOptions& rpcOptions) {
396     return co_methodE<true>(&rpcOptions);
397   }
398  private:
399   template <bool hasRpcOptions>
co_methodE(apache::thrift::RpcOptions * rpcOptions)400   folly::coro::Task<::test_cpp2::cpp_reflection::struct2> co_methodE(apache::thrift::RpcOptions* rpcOptions) {
401     const folly::CancellationToken& cancelToken =
402         co_await folly::coro::co_current_cancellation_token;
403     const bool cancellable = cancelToken.canBeCancelled();
404     apache::thrift::ClientReceiveState returnState;
405     apache::thrift::ClientSyncCallback<false> callback(&returnState);
406     auto protocolId = apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId();
407     auto [ctx, header] = methodECtx(rpcOptions);
408     using CancellableCallback = apache::thrift::CancellableRequestClientCallback<false>;
409     auto cancellableCallback = cancellable ? CancellableCallback::create(&callback, channel_) : nullptr;
410     static apache::thrift::RpcOptions defaultRpcOptions;
411     auto wrappedCallback = apache::thrift::RequestClientCallback::Ptr(cancellableCallback ? (apache::thrift::RequestClientCallback*)cancellableCallback.get() : &callback);
412     if constexpr (hasRpcOptions) {
413       methodEImpl(*rpcOptions, std::move(header), ctx.get(), std::move(wrappedCallback));
414     } else {
415       methodEImpl(defaultRpcOptions, std::move(header), ctx.get(), std::move(wrappedCallback));
416     }
417     if (cancellable) {
418       folly::CancellationCallback cb(cancelToken, [&] { CancellableCallback::cancel(std::move(cancellableCallback)); });
419       co_await callback.co_waitUntilDone();
420     } else {
421       co_await callback.co_waitUntilDone();
422     }
423     if (returnState.isException()) {
424       co_yield folly::coro::co_error(std::move(returnState.exception()));
425     }
426     returnState.resetProtocolId(protocolId);
427     returnState.resetCtx(std::move(ctx));
428     SCOPE_EXIT {
429       if (hasRpcOptions && returnState.header()) {
430         auto* rheader = returnState.header();
431         if (!rheader->getHeaders().empty()) {
432           rpcOptions->setReadHeaders(rheader->releaseHeaders());
433         }
434         rpcOptions->setRoutingData(rheader->releaseRoutingData());
435       }
436     };
437     ::test_cpp2::cpp_reflection::struct2 _return;
438     if (auto ew = recv_wrapped_methodE(_return, returnState)) {
439       co_yield folly::coro::co_error(std::move(ew));
440     }
441     co_return _return;
442   }
443  public:
444 #endif // FOLLY_HAS_COROUTINES
445 
446   virtual void methodE(folly::Function<void (::apache::thrift::ClientReceiveState&&)> callback);
447 
448 
449   static folly::exception_wrapper recv_wrapped_methodE(::test_cpp2::cpp_reflection::struct2& _return, ::apache::thrift::ClientReceiveState& state);
450   static void recv_methodE(::test_cpp2::cpp_reflection::struct2& _return, ::apache::thrift::ClientReceiveState& state);
451   // Mock friendly virtual instance method
452   virtual void recv_instance_methodE(::test_cpp2::cpp_reflection::struct2& _return, ::apache::thrift::ClientReceiveState& state);
453   virtual folly::exception_wrapper recv_instance_wrapped_methodE(::test_cpp2::cpp_reflection::struct2& _return, ::apache::thrift::ClientReceiveState& state);
454  private:
455   template <typename Protocol_, typename RpcOptions>
456   void methodET(Protocol_* prot, RpcOptions&& rpcOptions, std::shared_ptr<apache::thrift::transport::THeader> header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback);
457   std::pair<std::unique_ptr<::apache::thrift::ContextStack>, std::shared_ptr<::apache::thrift::transport::THeader>> methodECtx(apache::thrift::RpcOptions* rpcOptions);
458  public:
459   virtual void methodF(std::unique_ptr<apache::thrift::RequestCallback> callback, ::std::int32_t p_l, const ::test_cpp2::cpp_reflection::struct1& p_m, double p_n);
460   virtual void methodF(apache::thrift::RpcOptions& rpcOptions, std::unique_ptr<apache::thrift::RequestCallback> callback, ::std::int32_t p_l, const ::test_cpp2::cpp_reflection::struct1& p_m, double p_n);
461  protected:
462   void methodFImpl(apache::thrift::RpcOptions& rpcOptions, std::shared_ptr<apache::thrift::transport::THeader> header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback, ::std::int32_t p_l, const ::test_cpp2::cpp_reflection::struct1& p_m, double p_n, bool stealRpcOptions = false);
463  public:
464 
465   virtual void sync_methodF(::test_cpp2::cpp_reflection::struct3& _return, ::std::int32_t p_l, const ::test_cpp2::cpp_reflection::struct1& p_m, double p_n);
466   virtual void sync_methodF(apache::thrift::RpcOptions& rpcOptions, ::test_cpp2::cpp_reflection::struct3& _return, ::std::int32_t p_l, const ::test_cpp2::cpp_reflection::struct1& p_m, double p_n);
467 
468   virtual folly::Future<::test_cpp2::cpp_reflection::struct3> future_methodF(::std::int32_t p_l, const ::test_cpp2::cpp_reflection::struct1& p_m, double p_n);
469   virtual folly::SemiFuture<::test_cpp2::cpp_reflection::struct3> semifuture_methodF(::std::int32_t p_l, const ::test_cpp2::cpp_reflection::struct1& p_m, double p_n);
470   virtual folly::Future<::test_cpp2::cpp_reflection::struct3> future_methodF(apache::thrift::RpcOptions& rpcOptions, ::std::int32_t p_l, const ::test_cpp2::cpp_reflection::struct1& p_m, double p_n);
471   virtual folly::SemiFuture<::test_cpp2::cpp_reflection::struct3> semifuture_methodF(apache::thrift::RpcOptions& rpcOptions, ::std::int32_t p_l, const ::test_cpp2::cpp_reflection::struct1& p_m, double p_n);
472   virtual folly::Future<std::pair<::test_cpp2::cpp_reflection::struct3, std::unique_ptr<apache::thrift::transport::THeader>>> header_future_methodF(apache::thrift::RpcOptions& rpcOptions, ::std::int32_t p_l, const ::test_cpp2::cpp_reflection::struct1& p_m, double p_n);
473   virtual folly::SemiFuture<std::pair<::test_cpp2::cpp_reflection::struct3, std::unique_ptr<apache::thrift::transport::THeader>>> header_semifuture_methodF(apache::thrift::RpcOptions& rpcOptions, ::std::int32_t p_l, const ::test_cpp2::cpp_reflection::struct1& p_m, double p_n);
474 
475 #if FOLLY_HAS_COROUTINES
476   template <int = 0>
co_methodF(::std::int32_t p_l,const::test_cpp2::cpp_reflection::struct1 & p_m,double p_n)477   folly::coro::Task<::test_cpp2::cpp_reflection::struct3> co_methodF(::std::int32_t p_l, const ::test_cpp2::cpp_reflection::struct1& p_m, double p_n) {
478     return co_methodF<false>(nullptr, p_l, p_m, p_n);
479   }
480   template <int = 0>
co_methodF(apache::thrift::RpcOptions & rpcOptions,::std::int32_t p_l,const::test_cpp2::cpp_reflection::struct1 & p_m,double p_n)481   folly::coro::Task<::test_cpp2::cpp_reflection::struct3> co_methodF(apache::thrift::RpcOptions& rpcOptions, ::std::int32_t p_l, const ::test_cpp2::cpp_reflection::struct1& p_m, double p_n) {
482     return co_methodF<true>(&rpcOptions, p_l, p_m, p_n);
483   }
484  private:
485   template <bool hasRpcOptions>
co_methodF(apache::thrift::RpcOptions * rpcOptions,::std::int32_t p_l,const::test_cpp2::cpp_reflection::struct1 & p_m,double p_n)486   folly::coro::Task<::test_cpp2::cpp_reflection::struct3> co_methodF(apache::thrift::RpcOptions* rpcOptions, ::std::int32_t p_l, const ::test_cpp2::cpp_reflection::struct1& p_m, double p_n) {
487     const folly::CancellationToken& cancelToken =
488         co_await folly::coro::co_current_cancellation_token;
489     const bool cancellable = cancelToken.canBeCancelled();
490     apache::thrift::ClientReceiveState returnState;
491     apache::thrift::ClientSyncCallback<false> callback(&returnState);
492     auto protocolId = apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId();
493     auto [ctx, header] = methodFCtx(rpcOptions);
494     using CancellableCallback = apache::thrift::CancellableRequestClientCallback<false>;
495     auto cancellableCallback = cancellable ? CancellableCallback::create(&callback, channel_) : nullptr;
496     static apache::thrift::RpcOptions defaultRpcOptions;
497     auto wrappedCallback = apache::thrift::RequestClientCallback::Ptr(cancellableCallback ? (apache::thrift::RequestClientCallback*)cancellableCallback.get() : &callback);
498     if constexpr (hasRpcOptions) {
499       methodFImpl(*rpcOptions, std::move(header), ctx.get(), std::move(wrappedCallback), p_l, p_m, p_n);
500     } else {
501       methodFImpl(defaultRpcOptions, std::move(header), ctx.get(), std::move(wrappedCallback), p_l, p_m, p_n);
502     }
503     if (cancellable) {
504       folly::CancellationCallback cb(cancelToken, [&] { CancellableCallback::cancel(std::move(cancellableCallback)); });
505       co_await callback.co_waitUntilDone();
506     } else {
507       co_await callback.co_waitUntilDone();
508     }
509     if (returnState.isException()) {
510       co_yield folly::coro::co_error(std::move(returnState.exception()));
511     }
512     returnState.resetProtocolId(protocolId);
513     returnState.resetCtx(std::move(ctx));
514     SCOPE_EXIT {
515       if (hasRpcOptions && returnState.header()) {
516         auto* rheader = returnState.header();
517         if (!rheader->getHeaders().empty()) {
518           rpcOptions->setReadHeaders(rheader->releaseHeaders());
519         }
520         rpcOptions->setRoutingData(rheader->releaseRoutingData());
521       }
522     };
523     ::test_cpp2::cpp_reflection::struct3 _return;
524     if (auto ew = recv_wrapped_methodF(_return, returnState)) {
525       co_yield folly::coro::co_error(std::move(ew));
526     }
527     co_return _return;
528   }
529  public:
530 #endif // FOLLY_HAS_COROUTINES
531 
532   virtual void methodF(folly::Function<void (::apache::thrift::ClientReceiveState&&)> callback, ::std::int32_t p_l, const ::test_cpp2::cpp_reflection::struct1& p_m, double p_n);
533 
534 
535   static folly::exception_wrapper recv_wrapped_methodF(::test_cpp2::cpp_reflection::struct3& _return, ::apache::thrift::ClientReceiveState& state);
536   static void recv_methodF(::test_cpp2::cpp_reflection::struct3& _return, ::apache::thrift::ClientReceiveState& state);
537   // Mock friendly virtual instance method
538   virtual void recv_instance_methodF(::test_cpp2::cpp_reflection::struct3& _return, ::apache::thrift::ClientReceiveState& state);
539   virtual folly::exception_wrapper recv_instance_wrapped_methodF(::test_cpp2::cpp_reflection::struct3& _return, ::apache::thrift::ClientReceiveState& state);
540  private:
541   template <typename Protocol_, typename RpcOptions>
542   void methodFT(Protocol_* prot, RpcOptions&& rpcOptions, std::shared_ptr<apache::thrift::transport::THeader> header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback, ::std::int32_t p_l, const ::test_cpp2::cpp_reflection::struct1& p_m, double p_n);
543   std::pair<std::unique_ptr<::apache::thrift::ContextStack>, std::shared_ptr<::apache::thrift::transport::THeader>> methodFCtx(apache::thrift::RpcOptions* rpcOptions);
544  public:
545 };
546 
547 }} // test_cpp2::cpp_reflection
548