* @param tfunction The function
*/
void t_cocoa_generator::generate_function_helpers(t_function* tfunction) {
- if (tfunction->is_async()) {
+ if (tfunction->is_oneway()) {
return;
}
scope_down(out);
out << endl;
- if (!(*f_iter)->is_async()) {
+ if (!(*f_iter)->is_oneway()) {
t_struct noargs(program_);
t_function recv_function((*f_iter)->get_returntype(),
string("recv_") + (*f_iter)->get_name(),
}
out << "];" << endl;
- if (!(*f_iter)->is_async()) {
+ if (!(*f_iter)->is_oneway()) {
out << indent();
if (!(*f_iter)->get_returntype()->is_void()) {
out << "return ";
(*f_iter)->get_arglist());
indent(f_header_) << function_signature(*f_iter) << ";" << endl;
indent(f_header_) << function_signature(&send_function) << ";" << endl;
- if (!(*f_iter)->is_async()) {
+ if (!(*f_iter)->is_oneway()) {
t_struct noargs(program_);
t_function recv_function((*f_iter)->get_returntype(),
string("recv_") + (*f_iter)->get_name(),
}
f_service_ << ");" << endl;
- if (!(*f_iter)->is_async()) {
+ if (!(*f_iter)->is_oneway()) {
f_service_ << indent();
if (!(*f_iter)->get_returntype()->is_void()) {
if (is_complex_type((*f_iter)->get_returntype())) {
f_service_ << endl;
// Generate recv function only if not an async function
- if (!(*f_iter)->is_async()) {
+ if (!(*f_iter)->is_oneway()) {
t_struct noargs(program_);
t_function recv_function((*f_iter)->get_returntype(),
string("recv_") + (*f_iter)->get_name(),
*/
void t_cpp_generator::generate_function_helpers(t_service* tservice,
t_function* tfunction) {
- if (tfunction->is_async()) {
+ if (tfunction->is_oneway()) {
return;
}
vector<t_field*>::const_iterator x_iter;
// Declare result
- if (!tfunction->is_async()) {
+ if (!tfunction->is_oneway()) {
f_service_ <<
indent() << resultname << " result;" << endl;
}
bool first = true;
f_service_ << indent();
- if (!tfunction->is_async() && !tfunction->get_returntype()->is_void()) {
+ if (!tfunction->is_oneway() && !tfunction->get_returntype()->is_void()) {
if (is_complex_type(tfunction->get_returntype())) {
first = false;
f_service_ << "iface_->" << tfunction->get_name() << "(result.success";
f_service_ << ");" << endl;
// Set isset on success field
- if (!tfunction->is_async() && !tfunction->get_returntype()->is_void()) {
+ if (!tfunction->is_oneway() && !tfunction->get_returntype()->is_void()) {
f_service_ <<
indent() << "result.__isset.success = true;" << endl;
}
indent_down();
f_service_ << indent() << "}";
- if (!tfunction->is_async()) {
+ if (!tfunction->is_oneway()) {
for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
f_service_ << " catch (" << type_name((*x_iter)->get_type()) << " &" << (*x_iter)->get_name() << ") {" << endl;
- if (!tfunction->is_async()) {
+ if (!tfunction->is_oneway()) {
indent_up();
f_service_ <<
indent() << "result." << (*x_iter)->get_name() << " = " << (*x_iter)->get_name() << ";" << endl <<
f_service_ << " catch (const std::exception& e) {" << endl;
- if (!tfunction->is_async()) {
+ if (!tfunction->is_oneway()) {
indent_up();
f_service_ <<
indent() << "apache::thrift::TApplicationException x(e.what());" << endl <<
f_service_ << indent() << "}" << endl;
// Shortcut out here for async functions
- if (tfunction->is_async()) {
+ if (tfunction->is_oneway()) {
f_service_ <<
indent() << "return;" << endl;
indent_down();
}
f_service_ << ");" << endl;
- if (!(*f_iter)->is_async()) {
+ if (!(*f_iter)->is_oneway()) {
f_service_ << indent();
if (!(*f_iter)->get_returntype()->is_void()) {
f_service_ << "return ";
scope_down(f_service_);
f_service_ << endl;
- if (!(*f_iter)->is_async()) {
+ if (!(*f_iter)->is_oneway()) {
string resultname = (*f_iter)->get_name() + "_result";
t_struct noargs(program_);
}
void t_csharp_generator::generate_function_helpers(t_function* tfunction) {
- if (tfunction->is_async()) {
+ if (tfunction->is_oneway()) {
return;
}
const std::vector<t_field*>& xceptions = xs->get_members();
vector<t_field*>::const_iterator x_iter;
- if (!tfunction->is_async()) {
+ if (!tfunction->is_oneway()) {
f_service_ <<
indent() << resultname << " result = new " << resultname << "();" << endl;
}
vector<t_field*>::const_iterator f_iter;
f_service_ << indent();
- if (!tfunction->is_async() && !tfunction->get_returntype()->is_void()) {
+ if (!tfunction->is_oneway() && !tfunction->get_returntype()->is_void()) {
f_service_ << "result.Success = ";
}
f_service_ <<
}
f_service_ << ");" << endl;
- if (!tfunction->is_async() && xceptions.size() > 0) {
+ if (!tfunction->is_oneway() && xceptions.size() > 0) {
indent_down();
f_service_ << indent() << "}";
for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
f_service_ << " catch (" << type_name((*x_iter)->get_type(), false, false) << " " << (*x_iter)->get_name() << ") {" << endl;
- if (!tfunction->is_async()) {
+ if (!tfunction->is_oneway()) {
indent_up();
f_service_ <<
indent() << "result." << prop_name(*x_iter) << " = " << (*x_iter)->get_name() << ";" << endl;
f_service_ << endl;
}
- if (tfunction->is_async()) {
+ if (tfunction->is_oneway()) {
f_service_ <<
indent() << "return;" << endl;
scope_down(f_service_);
if (!tfunction->get_returntype()->is_void())
indent(f_service_) <<
generate_type_term(tfunction->get_returntype(), false) << ";" << endl;
- else if (tfunction->is_async())
+ else if (tfunction->is_oneway())
indent(f_service_) << "async_void;" << endl;
else
indent(f_service_) << "{struct, []}" << ";" << endl;
f_client_ << endl;
- if (!(*f_iter)->is_async()) {
+ if (!(*f_iter)->is_oneway()) {
f_client_ << indent();
f_client_ <<
"recv_" << funname << " ip" << endl;
indent_down();
- if (!(*f_iter)->is_async()) {
+ if (!(*f_iter)->is_oneway()) {
std::string resultname = capitalize((*f_iter)->get_name() + "_result");
t_struct noargs(program_);
const std::vector<t_field*>& xceptions = xs->get_members();
vector<t_field*>::const_iterator x_iter;
int n = xceptions.size();
- if (!tfunction->is_async()){
+ if (!tfunction->is_oneway()){
if(!tfunction->get_returntype()->is_void()){
n++;
}
f_service_ << "(do" << endl;
indent_up();
f_service_ << indent();
- if (!tfunction->is_async() && !tfunction->get_returntype()->is_void()){
+ if (!tfunction->is_oneway() && !tfunction->get_returntype()->is_void()){
f_service_ << "res <- ";
}
f_service_ << "Iface." << tfunction->get_name() << " handler";
}
- if (!tfunction->is_async() && !tfunction->get_returntype()->is_void()){
+ if (!tfunction->is_oneway() && !tfunction->get_returntype()->is_void()){
f_service_ << endl;
indent(f_service_) << "return rs{f_"<<resultname<<"_success= Just res}";
- } else if (!tfunction->is_async()){
+ } else if (!tfunction->is_oneway()){
f_service_ << endl;
indent(f_service_) << "return rs";
}
f_service_ << ")" << endl;
indent_down();
- if (xceptions.size() > 0 && !tfunction->is_async()) {
+ if (xceptions.size() > 0 && !tfunction->is_oneway()) {
for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
indent(f_service_) << "(\\e -> " <<endl;
indent_up();
- if(!tfunction->is_async()){
+ if(!tfunction->is_oneway()){
f_service_ <<
indent() << "return rs{f_"<<resultname<<"_" << (*x_iter)->get_name() << " =Just e}";
} else {
// Shortcut out here for async functions
- if (tfunction->is_async()) {
+ if (tfunction->is_oneway()) {
f_service_ <<
indent() << "return ()" << endl;
indent_down();
}
f_service_ << ");" << endl;
- if (!(*f_iter)->is_async()) {
+ if (!(*f_iter)->is_oneway()) {
f_service_ << indent();
if (!(*f_iter)->get_returntype()->is_void()) {
f_service_ << "return ";
scope_down(f_service_);
f_service_ << endl;
- if (!(*f_iter)->is_async()) {
+ if (!(*f_iter)->is_oneway()) {
string resultname = (*f_iter)->get_name() + "_result";
t_struct noargs(program_);
* @param tfunction The function
*/
void t_java_generator::generate_function_helpers(t_function* tfunction) {
- if (tfunction->is_async()) {
+ if (tfunction->is_oneway()) {
return;
}
vector<t_field*>::const_iterator x_iter;
// Declare result for non async function
- if (!tfunction->is_async()) {
+ if (!tfunction->is_oneway()) {
f_service_ <<
indent() << resultname << " result = new " << resultname << "();" << endl;
}
vector<t_field*>::const_iterator f_iter;
f_service_ << indent();
- if (!tfunction->is_async() && !tfunction->get_returntype()->is_void()) {
+ if (!tfunction->is_oneway() && !tfunction->get_returntype()->is_void()) {
f_service_ << "result.success = ";
}
f_service_ <<
f_service_ << ");" << endl;
// Set isset on success field
- if (!tfunction->is_async() && !tfunction->get_returntype()->is_void() && !type_can_be_null(tfunction->get_returntype())) {
+ if (!tfunction->is_oneway() && !tfunction->get_returntype()->is_void() && !type_can_be_null(tfunction->get_returntype())) {
f_service_ <<
indent() << "result.__isset.success = true;" << endl;
}
- if (!tfunction->is_async() && xceptions.size() > 0) {
+ if (!tfunction->is_oneway() && xceptions.size() > 0) {
indent_down();
f_service_ << indent() << "}";
for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
f_service_ << " catch (" << type_name((*x_iter)->get_type(), false, false) << " " << (*x_iter)->get_name() << ") {" << endl;
- if (!tfunction->is_async()) {
+ if (!tfunction->is_oneway()) {
indent_up();
f_service_ <<
indent() << "result." << (*x_iter)->get_name() << " = " << (*x_iter)->get_name() << ";" << endl;
}
// Shortcut out here for async functions
- if (tfunction->is_async()) {
+ if (tfunction->is_oneway()) {
f_service_ <<
indent() << "return;" << endl;
scope_down(f_service_);
}
f_service_ << ";" << endl;
- if (!(*f_iter)->is_async()) {
+ if (!(*f_iter)->is_oneway()) {
f_service_ << indent();
f_service_ <<
"self#recv_" << funname << endl;
indent_down();
indent_down();
- if (!(*f_iter)->is_async()) {
+ if (!(*f_iter)->is_oneway()) {
std::string resultname = decapitalize((*f_iter)->get_name() + "_result");
t_struct noargs(program_);
vector<t_field*>::const_iterator x_iter;
// Declare result for non async function
- if (!tfunction->is_async()) {
+ if (!tfunction->is_oneway()) {
f_service_ <<
indent() << "let result = new " << resultname << " in" << endl;
indent_up();
f_service_ << indent();
- if (!tfunction->is_async() && !tfunction->get_returntype()->is_void()) {
+ if (!tfunction->is_oneway() && !tfunction->get_returntype()->is_void()) {
f_service_ << "result#set_success ";
}
f_service_ <<
indent() << "| " << capitalize(type_name((*x_iter)->get_type())) << " " << (*x_iter)->get_name() << " -> " << endl;
indent_up();
indent_up();
- if(!tfunction->is_async()){
+ if(!tfunction->is_oneway()){
f_service_ <<
indent() << "result#set_" << (*x_iter)->get_name() << " " << (*x_iter)->get_name() << endl;
} else {
// Shortcut out here for async functions
- if (tfunction->is_async()) {
+ if (tfunction->is_oneway()) {
f_service_ <<
indent() << "()" << endl;
indent_down();
vector<t_field*>::const_iterator x_iter;
// Declare result for non async function
- if (!tfunction->is_async()) {
+ if (!tfunction->is_oneway()) {
f_service_ <<
indent() << "my $result = new " << resultname << "();" << endl;
}
vector<t_field*>::const_iterator f_iter;
f_service_ << indent();
- if (!tfunction->is_async() && !tfunction->get_returntype()->is_void()) {
+ if (!tfunction->is_oneway() && !tfunction->get_returntype()->is_void()) {
f_service_ << "$result->{success} = ";
}
f_service_ <<
}
f_service_ << ");" << endl;
- if (!tfunction->is_async() && xceptions.size() > 0) {
+ if (!tfunction->is_oneway() && xceptions.size() > 0) {
indent_down();
for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
f_service_ <<
indent() << "}; if( UNIVERSAL::isa($@,'"<<(*x_iter)->get_type()->get_name()<<"') ){ "<<endl;
- if (!tfunction->is_async()) {
+ if (!tfunction->is_oneway()) {
indent_up();
f_service_ <<
indent() << "$result->{" << (*x_iter)->get_name() << "} = $@;" << endl;
}
// Shortcut out here for async functions
- if (tfunction->is_async()) {
+ if (tfunction->is_oneway()) {
f_service_ <<
indent() << "return;" << endl;
indent_down();
}
f_service_ << ");" << endl;
- if (!(*f_iter)->is_async()) {
+ if (!(*f_iter)->is_oneway()) {
f_service_ << indent();
if (!(*f_iter)->get_returntype()->is_void()) {
f_service_ << "return ";
f_service_ << "}" << endl;
- if (!(*f_iter)->is_async()) {
+ if (!(*f_iter)->is_oneway()) {
std::string resultname = perl_namespace(tservice->get_program()) + service_name_ + "_" + (*f_iter)->get_name() + "_result";
t_struct noargs(program_);
vector<t_field*>::const_iterator x_iter;
// Declare result for non async function
- if (!tfunction->is_async()) {
+ if (!tfunction->is_oneway()) {
f_service_ <<
indent() << "$result = new " << resultname << "();" << endl;
}
vector<t_field*>::const_iterator f_iter;
f_service_ << indent();
- if (!tfunction->is_async() && !tfunction->get_returntype()->is_void()) {
+ if (!tfunction->is_oneway() && !tfunction->get_returntype()->is_void()) {
f_service_ << "$result->success = ";
}
f_service_ <<
}
f_service_ << ");" << endl;
- if (!tfunction->is_async() && xceptions.size() > 0) {
+ if (!tfunction->is_oneway() && xceptions.size() > 0) {
indent_down();
for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
f_service_ <<
indent() << "} catch (" << php_namespace((*x_iter)->get_type()->get_program()) << (*x_iter)->get_type()->get_name() << " $" << (*x_iter)->get_name() << ") {" << endl;
- if (!tfunction->is_async()) {
+ if (!tfunction->is_oneway()) {
indent_up();
f_service_ <<
indent() << "$result->" << (*x_iter)->get_name() << " = $" << (*x_iter)->get_name() << ";" << endl;
}
// Shortcut out here for async functions
- if (tfunction->is_async()) {
+ if (tfunction->is_oneway()) {
f_service_ <<
indent() << "return;" << endl;
indent_down();
* @param tfunction The function
*/
void t_php_generator::generate_php_function_helpers(t_function* tfunction) {
- if (!tfunction->is_async()) {
+ if (!tfunction->is_oneway()) {
t_struct result(program_, service_name_ + "_" + tfunction->get_name() + "_result");
t_field success(tfunction->get_returntype(), "success", 0);
if (!tfunction->get_returntype()->is_void()) {
}
out << ");" << endl;
- if (!(*f_iter)->is_async()) {
+ if (!(*f_iter)->is_oneway()) {
out << indent();
if (!(*f_iter)->get_returntype()->is_void()) {
out << "return ";
scope_down(out);
- if (!(*f_iter)->is_async()) {
+ if (!(*f_iter)->is_oneway()) {
std::string resultname = php_namespace(tservice->get_program()) + service_name_ + "_" + (*f_iter)->get_name() + "_result";
t_struct noargs(program_);
* @param tfunction The function
*/
void t_py_generator::generate_py_function_helpers(t_function* tfunction) {
- if (!tfunction->is_async()) {
+ if (!tfunction->is_oneway()) {
t_struct result(program_, tfunction->get_name() + "_result");
t_field success(tfunction->get_returntype(), "success", 0);
if (!tfunction->get_returntype()->is_void()) {
indent_up();
if (gen_twisted_) {
indent(f_service_) << "self._seqid += 1" << endl;
- if (!(*f_iter)->is_async()) {
+ if (!(*f_iter)->is_oneway()) {
indent(f_service_) <<
"d = self._reqs[self._seqid] = defer.Deferred()" << endl;
}
}
f_service_ << ")" << endl;
- if (!(*f_iter)->is_async()) {
+ if (!(*f_iter)->is_oneway()) {
f_service_ << indent();
if (gen_twisted_) {
f_service_ << "return d" << endl;
indent_down();
- if (!(*f_iter)->is_async()) {
+ if (!(*f_iter)->is_oneway()) {
std::string resultname = (*f_iter)->get_name() + "_result";
// Open function
f_service_ <<
vector<t_field*>::const_iterator x_iter;
// Declare result for non async function
- if (!tfunction->is_async()) {
+ if (!tfunction->is_oneway()) {
f_service_ <<
indent() << "result = " << resultname << "()" << endl;
}
f_service_ << ")" << endl;
// Shortcut out here for async functions
- if (tfunction->is_async()) {
+ if (tfunction->is_oneway()) {
f_service_ <<
indent() << "return d" << endl;
indent_down();
f_service_ << endl;
// Try block for a function with exceptions
- if (!tfunction->is_async() && xceptions.size() > 0) {
+ if (!tfunction->is_oneway() && xceptions.size() > 0) {
indent(f_service_) <<
"def write_results_exception_" << tfunction->get_name() <<
"(self, error, result, seqid, oprot):" << endl;
for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
f_service_ <<
indent() << "except " << type_name((*x_iter)->get_type()) << ", " << (*x_iter)->get_name() << ":" << endl;
- if (!tfunction->is_async()) {
+ if (!tfunction->is_oneway()) {
indent_up();
f_service_ <<
indent() << "result." << (*x_iter)->get_name() << " = " << (*x_iter)->get_name() << endl;
vector<t_field*>::const_iterator f_iter;
f_service_ << indent();
- if (!tfunction->is_async() && !tfunction->get_returntype()->is_void()) {
+ if (!tfunction->is_oneway() && !tfunction->get_returntype()->is_void()) {
f_service_ << "result.success = ";
}
f_service_ <<
}
f_service_ << ")" << endl;
- if (!tfunction->is_async() && xceptions.size() > 0) {
+ if (!tfunction->is_oneway() && xceptions.size() > 0) {
indent_down();
for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
f_service_ <<
indent() << "except " << type_name((*x_iter)->get_type()) << ", " << (*x_iter)->get_name() << ":" << endl;
- if (!tfunction->is_async()) {
+ if (!tfunction->is_oneway()) {
indent_up();
f_service_ <<
indent() << "result." << (*x_iter)->get_name() << " = " << (*x_iter)->get_name() << endl;
}
// Shortcut out here for async functions
- if (tfunction->is_async()) {
+ if (tfunction->is_oneway()) {
f_service_ <<
indent() << "return" << endl;
indent_down();
}
f_service_ << ")" << endl;
- if (!(*f_iter)->is_async()) {
+ if (!(*f_iter)->is_oneway()) {
f_service_ << indent();
if (!(*f_iter)->get_returntype()->is_void()) {
f_service_ << "return ";
indent_down();
indent(f_service_) << "end" << endl;
- if (!(*f_iter)->is_async()) {
+ if (!(*f_iter)->is_oneway()) {
std::string resultname = capitalize((*f_iter)->get_name() + "_result");
t_struct noargs(program_);
vector<t_field*>::const_iterator x_iter;
// Declare result for non async function
- if (!tfunction->is_async()) {
+ if (!tfunction->is_oneway()) {
f_service_ <<
indent() << "result = " << resultname << ".new()" << endl;
}
vector<t_field*>::const_iterator f_iter;
f_service_ << indent();
- if (!tfunction->is_async() && !tfunction->get_returntype()->is_void()) {
+ if (!tfunction->is_oneway() && !tfunction->get_returntype()->is_void()) {
f_service_ << "result.success = ";
}
f_service_ <<
}
f_service_ << ")" << endl;
- if (!tfunction->is_async() && xceptions.size() > 0) {
+ if (!tfunction->is_oneway() && xceptions.size() > 0) {
indent_down();
for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
f_service_ <<
indent() << "rescue " << full_type_name((*x_iter)->get_type()) << " => " << (*x_iter)->get_name() << endl;
- if (!tfunction->is_async()) {
+ if (!tfunction->is_oneway()) {
indent_up();
f_service_ <<
indent() << "result." << (*x_iter)->get_name() << " = " << (*x_iter)->get_name() << endl;
}
// Shortcut out here for async functions
- if (tfunction->is_async()) {
+ if (tfunction->is_oneway()) {
f_service_ <<
indent() << "return" << endl;
indent_down();
f_ << function_types_comment(*f_iter) << endl <<
indent() << "self send" << capitalize(signature) << "." << endl;
- if (!(*f_iter)->is_async()) {
+ if (!(*f_iter)->is_oneway()) {
f_ << indent() << "^ self recv" << capitalize(funname) << " success " << endl;
}
st_close_method(f_);
generate_send_method(*f_iter);
- if (!(*f_iter)->is_async()) {
+ if (!(*f_iter)->is_oneway()) {
generate_recv_method(*f_iter);
}
}
t_function(t_type* returntype,
std::string name,
t_struct* arglist,
- bool async=false) :
+ bool oneway=false) :
returntype_(returntype),
name_(name),
arglist_(arglist),
- async_(async) {
+ oneway_(oneway) {
xceptions_ = new t_struct(NULL);
}
std::string name,
t_struct* arglist,
t_struct* xceptions,
- bool async=false) :
+ bool oneway=false) :
returntype_(returntype),
name_(name),
arglist_(arglist),
xceptions_(xceptions),
- async_(async)
+ oneway_(oneway)
{
- if (async_ && !xceptions_->get_members().empty()) {
+ if (oneway_ && !xceptions_->get_members().empty()) {
throw std::string("Async methods can't throw exceptions.");
}
}
return xceptions_;
}
- bool is_async() const {
- return async_;
+ bool is_oneway() const {
+ return oneway_;
}
private:
std::string name_;
t_struct* arglist_;
t_struct* xceptions_;
- bool async_;
+ bool oneway_;
};
#endif