compiler/cpp/src/generate/t_hs_generator.cc
/**
 * Generates a service server definition.
 *
 * @param tservice The service to generate a server for.
 */
Generates a service server definition.
@param tservice The service to generate a server for.
Generates a service server definition . @param tservice The service to generate a server for .
void t_hs_generator::generate_service_server(t_service* tservice) {
  vector<t_function*> functions = tservice->get_functions();
  vector<t_function*>::iterator f_iter;
  for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter)
    generate_process_function(tservice, *f_iter);
  indent(f_service_) << "proc_ handler (iprot,oprot) (name,typ,seqid) = case name of" << endl;
  indent_up();
  for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
    string fname = (*f_iter)->get_name();
    indent(f_service_) << "\"" << fname << "\" -> process_" << decapitalize(fname) << " (seqid,iprot,oprot,handler)" << endl;
  }
  indent(f_service_) << "_ -> ";
  if (tservice->get_extends() != NULL) {
    f_service_ << type_name(tservice->get_extends()) << ".proc_ handler (iprot,oprot) (name,typ,seqid)" << endl;
  } else {
    f_service_ << "do" << endl;
    indent_up();
    indent(f_service_) << "skip iprot T_STRUCT" << endl;
    indent(f_service_) << "readMessageEnd iprot" << endl;
    indent(f_service_) << "writeMessageBegin oprot (name,M_EXCEPTION,seqid)" << endl;
    indent(f_service_) << "writeAppExn oprot (AppExn AE_UNKNOWN_METHOD (\"Unknown function \" ++ TL.unpack name))" << endl;
    indent(f_service_) << "writeMessageEnd oprot" << endl;
    indent(f_service_) << "tFlush (getTransport oprot)" << endl;
    indent_down();
  }
  indent_down();
  indent(f_service_) << "process handler (iprot, oprot) = do" << endl;
  indent_up();
  indent(f_service_) << "(name, typ, seqid) <- readMessageBegin iprot" << endl;
  indent(f_service_) << "proc_ handler (iprot,oprot) (name,typ,seqid)" << endl;
  indent(f_service_) << "return True" << endl;
  indent_down();
}
void t_hs_generator :: generate_service_server ( t_service * tservice ) { vector < t_function * > functions = tservice -> get_functions ( ) ; vector < t_function * > :: iterator f_iter ; for ( f_iter = functions . begin ( ) ; f_iter != functions . end ( ) ; ++ f_iter ) generate_process_function ( tservice , * f_iter ) ; indent ( f_service_ ) << " " << endl ; indent_up ( ) ; for ( f_iter = functions . begin ( ) ; f_iter != functions . end ( ) ; ++ f_iter ) { string fname = ( * f_iter ) -> get_name ( ) ; indent ( f_service_ ) << " \" " << fname << " \" " << decapitalize ( fname ) << " " << endl ; } indent ( f_service_ ) << " " ; if ( tservice -> get_extends ( ) != NULL ) { f_service_ << type_name ( tservice -> get_extends ( ) ) << " " << endl ; } else { f_service_ << " " << endl ; indent_up ( ) ; indent ( f_service_ ) << " " << endl ; indent ( f_service_ ) << " " << endl ; indent ( f_service_ ) << " " << endl ; indent ( f_service_ ) << " \" \" " << endl ; indent ( f_service_ ) << " " << endl ; indent ( f_service_ ) << " " << endl ; indent_down ( ) ; } indent_down ( ) ; indent ( f_service_ ) << " " << endl ; indent_up ( ) ; indent ( f_service_ ) << " " << endl ; indent ( f_service_ ) << " " << endl ; indent ( f_service_ ) << " " << endl ; indent_down ( ) ; }
Generates a service server definition.
Generates a service server definition .
// Generate the dispatch methods // Generate the process subfunctions // Generate the server implementation