diff options
Diffstat (limited to 'TAO/TAO_IDL/be/be_codegen.cpp')
-rw-r--r-- | TAO/TAO_IDL/be/be_codegen.cpp | 790 |
1 files changed, 325 insertions, 465 deletions
diff --git a/TAO/TAO_IDL/be/be_codegen.cpp b/TAO/TAO_IDL/be/be_codegen.cpp index 812b008e371..473ea1e7229 100644 --- a/TAO/TAO_IDL/be/be_codegen.cpp +++ b/TAO/TAO_IDL/be/be_codegen.cpp @@ -22,8 +22,9 @@ ACE_RCSID(be, be_codegen, "$Id$") -TAO_IDL_BE_Export TAO_CodeGen *tao_cg = 0; +TAO_CodeGen *tao_cg = 0; +/* BE global Data */ TAO_CodeGen::TAO_CodeGen (void) : client_header_ (0), client_stubs_ (0), @@ -39,7 +40,8 @@ TAO_CodeGen::TAO_CodeGen (void) gperf_input_stream_ (0), gperf_input_filename_ (0), curr_os_ (0), - visitor_factory_ (0) + visitor_factory_ (0), + strategy_ (TAO_PERFECT_HASH) { } @@ -66,7 +68,7 @@ be_visitor * TAO_CodeGen::make_visitor (be_visitor_context *ctx) { - if (this->visitor_factory_ == 0) + if (!this->visitor_factory_) { ACE_ERROR_RETURN ((LM_ERROR, "TAO_CodeGen::make_visitor - " @@ -77,14 +79,14 @@ TAO_CodeGen::make_visitor (be_visitor_context *ctx) return this->visitor_factory_->make_visitor (ctx); } -// Change the string to all upper case. +// change the string to all upcase const char * TAO_CodeGen::upcase (const char *str) { static char upcase_str [NAMEBUFSIZE]; ACE_OS::memset (upcase_str, '\0', NAMEBUFSIZE); - // Convert letters in str to upper case. + // convert letters in str to upcase for (unsigned int i=0; i < ACE_OS::strlen (str); i++) { if (isalpha (str [i])) @@ -93,14 +95,14 @@ TAO_CodeGen::upcase (const char *str) } else { - // Copy it as it is. + // copy it as it is upcase_str[i] = str[i]; } } return upcase_str; } -// Set the client header stream. +// set the client header stream int TAO_CodeGen::start_client_header (const char *fname) { @@ -108,24 +110,21 @@ TAO_CodeGen::start_client_header (const char *fname) // idl_global. We need to make sure the validity of those files. idl_global->validate_included_idl_files (); - // Retrieve the singleton instance to the outstream factory. + // retrieve the singleton instance to the outstream factory TAO_OutStream_Factory *factory = TAO_OUTSTREAM_FACTORY::instance (); - // Retrieve a specialized instance. + // retrieve a specialized instance this->client_header_ = factory->make_outstream (); - if (!this->client_header_) { return -1; } if (this->client_header_->open (fname, TAO_OutStream::TAO_CLI_HDR) == -1) - { - return -1; - } + return -1; else { - // Now generate the #if !defined clause. + // now generate the #if !defined clause static char macro_name [NAMEBUFSIZE]; ACE_OS::memset (macro_name, '\0', NAMEBUFSIZE); @@ -142,7 +141,7 @@ TAO_CodeGen::start_client_header (const char *fname) } ACE_OS::sprintf (macro_name, "_TAO_IDL_"); - // Convert letters in fname to upper case. + // convert letters in fname to upcase for (int i=0; i < (suffix - fname); i++) { if (isalpha (fname [i])) @@ -155,43 +154,50 @@ TAO_CodeGen::start_client_header (const char *fname) ACE_OS::strcat (macro_name, "_H_"); - // Generate the #ifndef ... #define statements. + // generate the #ifndef ... #define statements this->client_header_->print ("#ifndef %s\n", macro_name); this->client_header_->print ("#define %s\n\n", macro_name); - - if (be_global->pre_include () != 0) + if (idl_global->pre_include () != 0) { *this->client_header_ << "#include \"" - << be_global->pre_include () + << idl_global->pre_include () << "\"\n"; } // Including standard files - // Switch between changing or non-changing standard include files + // switch between changing or non-changing standard include files // include files, so that #include statements can be // generated with ""s or <>s respectively, for the standard include - // files (e.g. tao/corba.h). + // files (e.g. tao/corba.h) *this->client_header_ << "#include "; - if (be_global->changing_standard_include_files () == 1) - { - *this->client_header_ << "\""; - } + if (idl_global->changing_standard_include_files () == 1) + *this->client_header_ << "\""; else - { - *this->client_header_ << "<"; - } + *this->client_header_ << "<"; *this->client_header_ << "tao/corba.h"; - if (be_global->changing_standard_include_files () == 1) - { - *this->client_header_ << "\"\n"; - } + if (idl_global->changing_standard_include_files () == 1) + *this->client_header_ << "\"\n"; else + *this->client_header_ << ">\n"; + + // If the IDL file contains any exceptions, we'll be + // generating iostream operators. The following is mainly + // for VxWorks. + + if (idl_global->gen_except_ostream_op () != 0) { - *this->client_header_ << ">\n"; + *this->client_header_ << "\n#if defined (ACE_HAS_MINIMUM_IOSTREAMH_INCLUSION)\n"; + + if (idl_global->changing_standard_include_files () == 1) + *this->client_header_ << "#include \"ace/streams.h\"\n"; + else + *this->client_header_ << "#include <ace/streams.h>\n"; + + *this->client_header_ << "#endif /* ACE_HAS_MINIMUM_IOSTREAMH_INCLUSION */\n"; } // Some compilers don't optimize the #ifndef header include @@ -202,61 +208,45 @@ TAO_CodeGen::start_client_header (const char *fname) // Other include files. - if (be_global->stub_export_include () != 0) + if (idl_global->stub_export_include () != 0) { *this->client_header_ << "#include \"" - << be_global->stub_export_include () + << idl_global->stub_export_include () << "\"\n"; } // Include the Messaging files if AMI is enabled. - if (be_global->ami_call_back () == I_TRUE) + if (idl_global->ami_call_back () == I_TRUE) { // Include Messaging skeleton file. *this->client_header_ << "#include "; - if (be_global->changing_standard_include_files () == 1) - { - *this->client_header_ << "\""; - } + if (idl_global->changing_standard_include_files () == 1) + *this->client_header_ << "\""; else - { - *this->client_header_ << "<"; - } + *this->client_header_ << "<"; - *this->client_header_ << "tao/MessagingC.h"; + *this->client_header_ << "tao/MessagingS.h"; - if (be_global->changing_standard_include_files () == 1) - { - *this->client_header_ << "\"\n"; - } + if (idl_global->changing_standard_include_files () == 1) + *this->client_header_ << "\"\n"; else - { - *this->client_header_ << ">\n"; - } + *this->client_header_ << ">\n"; // Including Asynch Invocation file. *this->client_header_ << "#include "; - if (be_global->changing_standard_include_files () == 1) - { - *this->client_header_ << "\""; - } + if (idl_global->changing_standard_include_files () == 1) + *this->client_header_ << "\""; else - { - *this->client_header_ << "<"; - } + *this->client_header_ << "<"; *this->client_header_ << "tao/Asynch_Invocation.h"; - if (be_global->changing_standard_include_files () == 1) - { - *this->client_header_ << "\"\n"; - } + if (idl_global->changing_standard_include_files () == 1) + *this->client_header_ << "\"\n"; else - { - *this->client_header_ << ">\n"; - } + *this->client_header_ << ">\n"; } // We must include all the skeleton headers corresponding to @@ -280,7 +270,7 @@ TAO_CodeGen::start_client_header (const char *fname) // Get the clnt header from the IDL file name. const char* client_hdr = - BE_GlobalData::be_get_client_hdr (&idl_name_str, 1); + IDL_GlobalData::be_get_client_hdr (&idl_name_str, 1); // Sanity check and then print. if (client_hdr != 0) @@ -297,22 +287,22 @@ TAO_CodeGen::start_client_header (const char *fname) } *this->client_header_ << "\n"; - // Generate the TAO_EXPORT_MACRO macro. + // generate the TAO_EXPORT_MACRO macro *this->client_header_ << "#if defined (TAO_EXPORT_MACRO)\n"; *this->client_header_ << "#undef TAO_EXPORT_MACRO\n"; *this->client_header_ << "#endif\n"; *this->client_header_ << "#define TAO_EXPORT_MACRO " - << be_global->stub_export_macro () + << idl_global->stub_export_macro () << be_nl << be_nl; - // Generate export macro for nested classes. + // Generate export macro for nested classes *this->client_header_ << "#if defined (TAO_EXPORT_NESTED_CLASSES)\n" << "# if defined (TAO_EXPORT_NESTED_MACRO)\n" << "# undef TAO_EXPORT_NESTED_MACRO\n" << "# endif /* defined (TAO_EXPORT_NESTED_MACRO) */\n" << "# define TAO_EXPORT_NESTED_MACRO " - << be_global->stub_export_macro () + << idl_global->stub_export_macro () << be_nl << "#endif /* TAO_EXPORT_NESTED_CLASSES */\n\n"; @@ -321,34 +311,30 @@ TAO_CodeGen::start_client_header (const char *fname) << "#pragma warning(push)\n" << "#endif /* _MSC_VER >= 1200 */\n" << "#pragma warning(disable:4250)\n"; - if (be_global->use_raw_throw ()) - { - *this->client_header_ << "#pragma warning(disable:4290)\n"; - } - + if (idl_global->use_raw_throw ()) + *this->client_header_ << "#pragma warning(disable:4290)\n"; *this->client_header_ << "#endif /* _MSC_VER */\n\n"; return 0; } } -// Get the client header stream. +// get the client header stream TAO_OutStream * TAO_CodeGen::client_header (void) { return this->client_header_; } -// Set the client stub stream. +// set the client stub stream int TAO_CodeGen::start_client_stubs (const char *fname) { - // Retrieve the singleton instance to the outstream factory. + // retrieve the singleton instance to the outstream factory TAO_OutStream_Factory *factory = TAO_OUTSTREAM_FACTORY::instance (); - // Retrieve a specialized instance. + // retrieve a specialized instance this->client_stubs_ = factory->make_outstream (); - if (!this->client_stubs_) { return -1; @@ -359,48 +345,42 @@ TAO_CodeGen::start_client_stubs (const char *fname) return -1; } - // Generate the include statement for the precompiled header file. - if (be_global->pch_include ()) - { - *this->client_stubs_ << "#include \"" - << be_global->pch_include () - << "\"\n\n"; - } + // generate the include statement for the precompiled header file. + if (idl_global->pch_include ()) + *this->client_stubs_ << "#include \"" + << idl_global->pch_include () << "\"\n\n"; - // Generate the include statement for the client header. We just + // generate the include statement for the client header. We just // need to put only the base names. Path info is not required. - *this->client_stubs_ << "#include \"" - << be_global->be_get_client_hdr_fname (1) - << "\"\n\n"; + *this->client_stubs_ << "#include \"" << + idl_global->be_get_client_hdr_fname (1) << "\"\n\n"; - // Generate the code that includes the inline file if not included in the - // header file. + // generate the code that includes the inline file if not included in the + // header file *this->client_stubs_ << "#if !defined (__ACE_INLINE__)\n"; - *this->client_stubs_ << "#include \"" - << be_global->be_get_client_inline_fname (1) - << "\"\n"; + *this->client_stubs_ << "#include \"" << + idl_global->be_get_client_inline_fname (1) << "\"\n"; *this->client_stubs_ << "#endif /* !defined INLINE */\n\n"; return 0; } -// Get the client stubs stream. +// get the client stubs stream TAO_OutStream * TAO_CodeGen::client_stubs (void) { return this->client_stubs_; } -// Set the client inline stream. +// set the client inline stream int TAO_CodeGen::start_client_inline (const char *fname) { - // Retrieve the singleton instance to the outstream factory. + // retrieve the singleton instance to the outstream factory TAO_OutStream_Factory *factory = TAO_OUTSTREAM_FACTORY::instance (); - // Retrieve a specialized instance. + // retrieve a specialized instance this->client_inline_ = factory->make_outstream (); - if (!this->client_inline_) { return -1; @@ -409,14 +389,14 @@ TAO_CodeGen::start_client_inline (const char *fname) return this->client_inline_->open (fname, TAO_OutStream::TAO_CLI_INL); } -// Get the client inline stream. +// get the client inline stream TAO_OutStream * TAO_CodeGen::client_inline (void) { return this->client_inline_; } -// Set the server header stream. +// set the server header stream. int TAO_CodeGen::start_server_header (const char *fname) { @@ -424,122 +404,89 @@ TAO_CodeGen::start_server_header (const char *fname) // idl_global. We need to make sure the validity of those files. idl_global->validate_included_idl_files (); - // Retrieve the singleton instance to the outstream factory. + // retrieve the singleton instance to the outstream factory TAO_OutStream_Factory *factory = TAO_OUTSTREAM_FACTORY::instance (); - // Retrieve a specialized instance. + // retrieve a specialized instance this->server_header_ = factory->make_outstream (); - if (!this->server_header_) { return -1; } if (this->server_header_->open (fname, TAO_OutStream::TAO_SVR_HDR) == -1) - { - return -1; - } + return -1; else { - // Now generate the #if !defined clause. + // now generate the #if !defined clause static char macro_name [NAMEBUFSIZE]; ACE_OS::memset (macro_name, '\0', NAMEBUFSIZE); const char *suffix = ACE_OS::strrchr (fname, '.'); - if (suffix == 0) { // File seems to have no extension, so let us take the name // as it is. if (fname == 0) - { - // Bad file name. - return -1; - } + // bad file name + return -1; else - { - suffix = fname; - } + suffix = fname; } ACE_OS::sprintf (macro_name, "_TAO_IDL_"); - // Convert letters in fname to upper case. + // convert letters in fname to upcase for (int i=0; i < (suffix - fname); i++) - { - if (isalpha (fname [i])) - { - macro_name[i+9] = (char) toupper (fname [i]); - } - else if (isdigit (fname [i])) - { - macro_name[i+9] = fname[i]; - } - else - { - macro_name[i+9] = '_'; - } - } + if (isalpha (fname [i])) + macro_name[i+9] = (char) toupper (fname [i]); + else if (isdigit (fname [i])) + macro_name[i+9] = fname[i]; + else + macro_name[i+9] = '_'; ACE_OS::strcat (macro_name, "_H_"); this->server_header_->print ("#ifndef %s\n", macro_name); this->server_header_->print ("#define %s\n\n", macro_name); - - if (be_global->pre_include () != 0) + if (idl_global->pre_include () != 0) { *this->server_header_ << "#include \"" - << be_global->pre_include () + << idl_global->pre_include () << "\"\n"; } // Include the Messaging files if AMI is enabled. - if (be_global->ami_call_back () == I_TRUE) + if (idl_global->ami_call_back () == I_TRUE) { // Include Messaging skeleton file. *this->server_header_ << "#include "; - if (be_global->changing_standard_include_files () == 1) - { - *this->server_header_ << "\""; - } + if (idl_global->changing_standard_include_files () == 1) + *this->server_header_ << "\""; else - { - *this->server_header_ << "<"; - } + *this->server_header_ << "<"; - *this->server_header_ << "tao/PortableServer/MessagingS.h"; + *this->server_header_ << "tao/MessagingS.h"; - if (be_global->changing_standard_include_files () == 1) - { - *this->server_header_ << "\"\n"; - } + if (idl_global->changing_standard_include_files () == 1) + *this->server_header_ << "\"\n"; else - { - *this->server_header_ << ">\n"; - } + *this->server_header_ << ">\n"; // Including Asynch Invocation file. *this->server_header_ << "#include "; - if (be_global->changing_standard_include_files () == 1) - { - *this->server_header_ << "\""; - } + if (idl_global->changing_standard_include_files () == 1) + *this->server_header_ << "\""; else - { - *this->server_header_ << "<"; - } + *this->server_header_ << "<"; *this->server_header_ << "tao/Asynch_Invocation.h"; - if (be_global->changing_standard_include_files () == 1) - { - *this->server_header_ << "\"\n"; - } + if (idl_global->changing_standard_include_files () == 1) + *this->server_header_ << "\"\n"; else - { - *this->server_header_ << ">\n"; - } + *this->server_header_ << ">\n"; } // We must include all the skeleton headers corresponding to @@ -550,24 +497,22 @@ TAO_CodeGen::start_server_header (const char *fname) for (size_t j = 0; j < idl_global->n_included_idl_files (); ++j) - { - char* idl_name = - idl_global->included_idl_files ()[j]; - - // String'ifying the name. - UTL_String idl_name_str (idl_name); + { + char* idl_name = + idl_global->included_idl_files ()[j]; - const char* server_hdr = - BE_GlobalData::be_get_server_hdr (&idl_name_str, 1); + // String'ifying the name. + UTL_String idl_name_str (idl_name); - this->server_header_->print ("#include \"%s\"\n", - server_hdr); - } + const char* server_hdr = + IDL_GlobalData::be_get_server_hdr (&idl_name_str, 1); - // The server header should include the client header. - *this->server_header_ << "#include \"" - << be_global->be_get_client_hdr_fname (1) - << "\"\n\n"; + this->server_header_->print ("#include \"%s\"\n", + server_hdr); + } + // the server header should include the client header + *this->server_header_ << "#include \"" << + idl_global->be_get_client_hdr_fname (1) << "\"\n\n"; // Some compilers don't optimize the #ifndef header include // protection, but do optimize based on #pragma once. @@ -575,51 +520,37 @@ TAO_CodeGen::start_server_header (const char *fname) << "# pragma once\n" << "#endif /* ACE_LACKS_PRAGMA_ONCE */\n\n"; - // Include the definitions for the PortableServer namespace, - // this forces the application to link the POA library, a good - // thing, because we need the definitions there, it also - // registers the POA factory with the Service_Configurator, so - // the ORB can automatically find it. - *this->server_header_ - << "#include \"tao/PortableServer/PortableServer.h\"\n" - << "#include \"tao/PortableServer/Servant_Base.h\"\n" - << "#include \"tao/PortableServer/Collocated_Object.h\"\n" - << "\n"; - *this->server_header_ << "#if defined(_MSC_VER)\n" << "#if (_MSC_VER >= 1200)\n" << "#pragma warning(push)\n" << "#endif /* _MSC_VER >= 1200 */\n" << "#pragma warning(disable:4250)\n"; - if (be_global->use_raw_throw ()) - { - *this->server_header_ << "#pragma warning(disable:4290)\n"; - } - + if (idl_global->use_raw_throw ()) + *this->server_header_ << "#pragma warning(disable:4290)\n"; *this->server_header_ << "#endif /* _MSC_VER */\n\n"; - if (be_global->skel_export_include () != 0) + if (idl_global->skel_export_include () != 0) { *this->server_header_ << "#include \"" - << be_global->skel_export_include () + << idl_global->skel_export_include () << "\"\n"; - // Generate the TAO_EXPORT_MACRO macro. + // generate the TAO_EXPORT_MACRO macro *this->server_header_ << "#if defined (TAO_EXPORT_MACRO)\n"; *this->server_header_ << "#undef TAO_EXPORT_MACRO\n"; *this->server_header_ << "#endif\n"; *this->server_header_ << "#define TAO_EXPORT_MACRO " - << be_global->skel_export_macro () + << idl_global->skel_export_macro () << be_nl; - // Generate export macro for nested classes. + // Generate export macro for nested classes *this->server_header_ << "#if defined (TAO_EXPORT_NESTED_CLASSES)\n" << "# if defined (TAO_EXPORT_NESTED_MACRO)\n" << "# undef TAO_EXPORT_NESTED_MACRO\n" << "# endif /* defined (TAO_EXPORT_NESTED_MACRO) */\n" << "# define TAO_EXPORT_NESTED_MACRO " - << be_global->skel_export_macro () + << idl_global->skel_export_macro () << be_nl << "#endif /* TAO_EXPORT_NESTED_CLASSES */\n"; } @@ -628,84 +559,64 @@ TAO_CodeGen::start_server_header (const char *fname) } } -// Get the server header stream. +// get the server header stream TAO_OutStream * TAO_CodeGen::server_header (void) { return this->server_header_; } -// Set the server header stream. +// set the server header stream int TAO_CodeGen::start_server_template_header (const char *fname) { - // Retrieve the singleton instance to the outstream factory. + // retrieve the singleton instance to the outstream factory TAO_OutStream_Factory *factory = TAO_OUTSTREAM_FACTORY::instance (); - // Retrieve a specialized instance. + // retrieve a specialized instance this->server_template_header_ = factory->make_outstream (); - if (!this->server_template_header_) - { - return -1; - } + return -1; if (this->server_template_header_->open (fname, TAO_OutStream::TAO_SVR_TMPL_HDR) - == -1) - { - return -1; - } + == -1) + return -1; else { - // Now generate the #if !defined clause. + // now generate the #if !defined clause static char macro_name [NAMEBUFSIZE]; ACE_OS::memset (macro_name, '\0', NAMEBUFSIZE); const char *suffix = ACE_OS::strrchr (fname, '.'); - if (suffix == 0) { // File seems to have no extension, so let us take the name // as it is. if (fname == 0) - { - // Bad file name. - return -1; - } + // bad file name + return -1; else - { - suffix = fname; - } + suffix = fname; } ACE_OS::sprintf (macro_name, "_TAO_IDL_"); - - // Convert letters in fname to upper case. + // convert letters in fname to upcase for (int i=0; i < (suffix - fname); i++) - { - if (isalpha (fname [i])) - { + if (isalpha (fname [i])) macro_name[i+9] = (char) toupper (fname [i]); - } - else if (isdigit (fname [i])) - { - macro_name[i+9] = fname[i]; - } - else - { - macro_name[i+9] = '_'; - } - } + else if (isdigit (fname [i])) + macro_name[i+9] = fname[i]; + else + macro_name[i+9] = '_'; ACE_OS::strcat (macro_name, "_H_"); this->server_template_header_->print ("#ifndef %s\n", macro_name); this->server_template_header_->print ("#define %s\n\n", macro_name); - - if (be_global->pre_include () != 0) + if (idl_global->pre_include () != 0) { *this->server_template_header_ << "#include \"" - << be_global->pre_include () + << idl_global->pre_include () << "\"\n"; } @@ -714,35 +625,30 @@ TAO_CodeGen::start_server_template_header (const char *fname) << "#pragma warning(push)\n" << "#endif /* _MSC_VER >= 1200 */\n" << "#pragma warning(disable:4250)\n"; - - if (be_global->use_raw_throw ()) - { - *this->server_template_header_ << "#pragma warning(disable:4290)\n"; - } - + if (idl_global->use_raw_throw ()) + *this->server_template_header_ << "#pragma warning(disable:4290)\n"; *this->server_template_header_ << "#endif /* _MSC_VER */\n\n"; return 0; } } -// Get the server header stream. +// get the server header stream TAO_OutStream * TAO_CodeGen::server_template_header (void) { return this->server_template_header_; } -// Set the server skeletons stream. +// set the server skeletons stream int TAO_CodeGen::start_server_skeletons (const char *fname) { - // Retrieve the singleton instance to the outstream factory. + // retrieve the singleton instance to the outstream factory TAO_OutStream_Factory *factory = TAO_OUTSTREAM_FACTORY::instance (); - // Retrieve a specialized instance. + // retrieve a specialized instance this->server_skeletons_ = factory->make_outstream (); - if (!this->server_skeletons_) { return -1; @@ -753,29 +659,20 @@ TAO_CodeGen::start_server_skeletons (const char *fname) return -1; } - // Generate the include statement for the precompiled header file. - if (be_global->pch_include ()) - { - *this->server_skeletons_ << "#include \"" - << be_global->pch_include () - << "\"\n\n"; - } + // generate the include statement for the precompiled header file. + if (idl_global->pch_include ()) + *this->server_skeletons_ << "#include \"" + << idl_global->pch_include () << "\"\n\n"; + + // generate the include statement for the server header + *this->server_skeletons_ << "#include \"" << + idl_global->be_get_server_hdr_fname (1) << "\"\n\n"; - // Generate the include statement for the server header. - *this->server_skeletons_ - << "#include \"" - << be_global->be_get_server_hdr_fname (1) - << "\"\n" - << "#include \"tao/PortableServer/Object_Adapter.h\"\n" - << "#include \"tao/PortableServer/Operation_Table.h\"\n" - << "\n"; - - // Generate the code that includes the inline file if not included in the - // header file. + // generate the code that includes the inline file if not included in the + // header file *this->server_skeletons_ << "#if !defined (__ACE_INLINE__)\n"; - *this->server_skeletons_ << "#include \"" - << be_global->be_get_server_inline_fname (1) - << "\"\n"; + *this->server_skeletons_ << "#include \"" << + idl_global->be_get_server_inline_fname (1) << "\"\n"; *this->server_skeletons_ << "#endif /* !defined INLINE */\n\n"; return 0; @@ -792,12 +689,11 @@ TAO_CodeGen::server_skeletons (void) int TAO_CodeGen::start_server_template_skeletons (const char *fname) { - // Retrieve the singleton instance to the outstream factory. + // retrieve the singleton instance to the outstream factory TAO_OutStream_Factory *factory = TAO_OUTSTREAM_FACTORY::instance (); - // Retrieve a specialized instance. + // retrieve a specialized instance this->server_template_skeletons_ = factory->make_outstream (); - if (!this->server_template_skeletons_) { return -1; @@ -805,93 +701,72 @@ TAO_CodeGen::start_server_template_skeletons (const char *fname) if (this->server_template_skeletons_->open (fname, TAO_OutStream::TAO_SVR_TMPL_IMPL) - == -1) - { - return -1; - } + == -1) + return -1; else { - // Now generate the #if !defined clause. + // now generate the #if !defined clause static char macro_name [NAMEBUFSIZE]; ACE_OS::memset (macro_name, '\0', NAMEBUFSIZE); const char *suffix = ACE_OS::strrchr (fname, '.'); - if (suffix == 0) { // File seems to have no extension, so let us take the name // as it is. if (fname == 0) - { - // Bad file name. - return -1; - } + // bad file name + return -1; else - { - suffix = fname; - } + suffix = fname; } ACE_OS::sprintf (macro_name, "_TAO_IDL_"); - - // Convert letters in fname to upper case. + // convert letters in fname to upcase for (int i=0; i < (suffix - fname); i++) - { - if (isalpha (fname [i])) - { - macro_name[i+9] = (char) toupper (fname [i]); - } - else if (isdigit (fname [i])) - { - macro_name[i+9] = fname[i]; - } - else - { - macro_name[i+9] = '_'; - } - } + if (isalpha (fname [i])) + macro_name[i+9] = (char) toupper (fname [i]); + else if (isdigit (fname [i])) + macro_name[i+9] = fname[i]; + else + macro_name[i+9] = '_'; ACE_OS::strcat (macro_name, "_CPP_"); this->server_template_skeletons_->print ("#ifndef %s\n", macro_name); this->server_template_skeletons_->print ("#define %s\n\n", macro_name); - // Generate the include statement for the server header. - *this->server_template_skeletons_ - << "#include \"" - << be_global->be_get_server_template_hdr_fname (1) - << "\"\n\n"; + // generate the include statement for the server header + *this->server_template_skeletons_ << "#include \"" << + idl_global->be_get_server_template_hdr_fname (1) << "\"\n\n"; - // Generate the code that includes the inline file if not included in the - // header file. + // generate the code that includes the inline file if not included in the + // header file *this->server_template_skeletons_ << "#if !defined (__ACE_INLINE__)\n"; - *this->server_template_skeletons_ - << "#include \"" - << be_global->be_get_server_template_inline_fname (1) - << "\"\n"; + *this->server_template_skeletons_ << "#include \"" << + idl_global->be_get_server_template_inline_fname (1) << "\"\n"; *this->server_template_skeletons_ << "#endif /* !defined INLINE */\n\n"; return 0; } } -// Get the server template skeletons stream. +// get the server template skeletons stream TAO_OutStream * TAO_CodeGen::server_template_skeletons (void) { return this->server_template_skeletons_; } -// Set the server inline stream. +// set the server inline stream int TAO_CodeGen::start_server_inline (const char *fname) { - // Retrieve the singleton instance to the outstream factory. + // retrieve the singleton instance to the outstream factory TAO_OutStream_Factory *factory = TAO_OUTSTREAM_FACTORY::instance (); - // Retrieve a specialized instance. + // retrieve a specialized instance this->server_inline_ = factory->make_outstream (); - if (!this->server_inline_) { return -1; @@ -900,23 +775,22 @@ TAO_CodeGen::start_server_inline (const char *fname) return this->server_inline_->open (fname, TAO_OutStream::TAO_SVR_INL); } -// Get the server inline stream. +// get the server inline stream TAO_OutStream * TAO_CodeGen::server_inline (void) { return this->server_inline_; } -// Set the server template inline stream. +// set the server template inline stream int TAO_CodeGen::start_server_template_inline (const char *fname) { - // Retrieve the singleton instance to the outstream factory. + // retrieve the singleton instance to the outstream factory TAO_OutStream_Factory *factory = TAO_OUTSTREAM_FACTORY::instance (); - // Retrieve a specialized instance. + // retrieve a specialized instance this->server_template_inline_ = factory->make_outstream (); - if (!this->server_template_inline_) { return -1; @@ -925,7 +799,7 @@ TAO_CodeGen::start_server_template_inline (const char *fname) return this->server_template_inline_->open (fname, TAO_OutStream::TAO_SVR_INL); } -// Get the server template inline stream. +// get the server template inline stream TAO_OutStream * TAO_CodeGen::server_template_inline (void) { @@ -933,7 +807,7 @@ TAO_CodeGen::server_template_inline (void) } -// Set the server header stream. +// set the server header stream. int TAO_CodeGen::start_implementation_header (const char *fname) { @@ -943,71 +817,80 @@ TAO_CodeGen::start_implementation_header (const char *fname) idl_global->validate_included_idl_files (); - // Retrieve the singleton instance to the outstream factory. + // retrieve the singleton instance to the outstream factory TAO_OutStream_Factory *factory = TAO_OUTSTREAM_FACTORY::instance (); - // Retrieve a specialized instance. + // retrieve a specialized instance this->implementation_header_ = factory->make_outstream (); - if (!this->implementation_header_) { return -1; } - if (this->implementation_header_->open (fname, - TAO_OutStream::TAO_IMPL_HDR) - == -1) - { - return -1; - } + if (this->implementation_header_->open (fname, TAO_OutStream::TAO_IMPL_HDR) == -1) + return -1; else { - // Now generate the #ifndef clause. + // now generate the #ifndef clause static char macro_name [NAMEBUFSIZE]; ACE_OS::memset (macro_name, '\0', NAMEBUFSIZE); const char *suffix = ACE_OS::strrchr (fname, '.'); - if (suffix == 0) { // File seems to have no extension, so let us take the name // as it is. if (fname == 0) - { - // Bad file name. - return -1; - } + // bad file name + return -1; else - { - suffix = fname; - } + suffix = fname; } for (int i=0; i < (suffix - fname); i++) - { - if (isalpha (fname [i])) - { - macro_name[i] = (char) toupper (fname [i]); - } - else if (isdigit (fname [i])) - { - macro_name[i] = fname[i]; - } - else - { - macro_name[i] = '_'; - } - } + if (isalpha (fname [i])) + macro_name[i] = (char) toupper (fname [i]); + else if (isdigit (fname [i])) + macro_name[i] = fname[i]; + else + macro_name[i] = '_'; ACE_OS::strcat (macro_name, "_H_"); this->implementation_header_->print ("#ifndef %s\n", macro_name); this->implementation_header_->print ("#define %s\n\n", macro_name); + // @@ (JP) I think the code below can be safely left out. It has + // been modified but not checked, so I'll leave it here for a + // while to make sure it's really safe to leave out. 2000/01/22 +#if 0 + // We must include all the client headers corresponding to + // IDL files included by the current IDL file. + // We will use the included IDL file names as they appeared + // in the original main IDL file, not the ones which went + // thru CC preprocessor. + for (size_t j = 0; + j < idl_global->n_included_idl_files (); + ++j) + { + char* idl_name = + idl_global->included_idl_files ()[j]; + + // Stringifying the name. + UTL_String idl_name_str (idl_name); + + const char* implementation_hdr = + IDL_GlobalData::be_get_client_hdr (&idl_name_str, 1); + + this->implementation_header_->print ("#include \"%s\"\n", + implementation_hdr); + } +#endif + const char* server_hdr = - BE_GlobalData::be_get_server_hdr_fname (1); + IDL_GlobalData::be_get_server_hdr_fname (1); - *this->implementation_header_<< "#include \"" << server_hdr <<"\"\n\n"; + *this->implementation_header_<< "#include \""<<server_hdr<<"\"\n\n"; *this->implementation_header_ << "#if !defined (ACE_LACKS_PRAGMA_ONCE)\n" @@ -1019,7 +902,7 @@ TAO_CodeGen::start_implementation_header (const char *fname) } -// Get the implementation header stream. +// get the implementation header stream TAO_OutStream * TAO_CodeGen::implementation_header (void) { @@ -1027,7 +910,7 @@ TAO_CodeGen::implementation_header (void) } -// Set the implementation skeleton stream. +// set the implementation skeleton stream. int TAO_CodeGen::start_implementation_skeleton (const char *fname) { @@ -1035,25 +918,23 @@ TAO_CodeGen::start_implementation_skeleton (const char *fname) // idl_global. We need to make sure the validity of those files. idl_global->validate_included_idl_files (); - // Retrieve the singleton instance to the outstream factory. + // retrieve the singleton instance to the outstream factory TAO_OutStream_Factory *factory = TAO_OUTSTREAM_FACTORY::instance (); - // Retrieve a specialized instance. + // retrieve a specialized instance this->implementation_skeleton_ = factory->make_outstream (); - if (!this->implementation_skeleton_) { return -1; } - if (this->implementation_skeleton_->open (fname, - TAO_OutStream::TAO_IMPL_SKEL) - == -1) - { - return -1; - } + if (this->implementation_skeleton_->open (fname, TAO_OutStream::TAO_IMPL_SKEL) == -1) + return -1; else { + + + static char macro_name [NAMEBUFSIZE]; ACE_OS::memset (macro_name, '\0', NAMEBUFSIZE); @@ -1065,31 +946,22 @@ TAO_CodeGen::start_implementation_skeleton (const char *fname) // File seems to have no extension, so let us take the name // as it is. if (fname == 0) - { - // Bad file name. - return -1; - } + // bad file name + return -1; else - { - suffix = fname; - } + suffix = fname; } - // Convert letters in fname to upper case. + // convert letters in fname to upcase for (int i=0; i < (suffix - fname); i++) - { - if (isalpha (fname [i])) - { - macro_name[i] = fname [i]; - } - else - { - macro_name[i] = fname[i]; - } - } + if (isalpha (fname [i])) + macro_name[i] = fname [i]; + else + macro_name[i] = fname[i]; + const char* impl_hdr = - BE_GlobalData::be_get_implementation_hdr_fname (); + IDL_GlobalData::be_get_implementation_hdr_fname (); this->implementation_skeleton_->print ("#include \"%s\"\n\n", impl_hdr); @@ -1098,40 +970,37 @@ TAO_CodeGen::start_implementation_skeleton (const char *fname) } -// Get the implementation header stream. +// get the implementation header stream TAO_OutStream * TAO_CodeGen::implementation_skeleton (void) { return this->implementation_skeleton_; } -// Put the last #endif in the client and server headers. +// put the last #endif in the client and server headers int TAO_CodeGen::end_client_header (void) { - // Generate the <<= and >>= operators here. + // generate the <<= and >>= operators here - // Insert the code to include the inline file. + // insert the code to include the inline file *this->client_header_ << "\n#if defined (__ACE_INLINE__)\n"; - *this->client_header_ << "#include \"" - << be_global->be_get_client_inline_fname (1) - << "\"\n"; + *this->client_header_ << "#include \"" << + idl_global->be_get_client_inline_fname (1) << "\"\n"; *this->client_header_ << "#endif /* defined INLINE */\n\n"; *this->client_header_ << "#if defined(_MSC_VER) && (_MSC_VER >= 1200)\n" << "#pragma warning(pop)\n" << "#endif /* _MSC_VER */\n"; - // Code to put the last #endif. + // code to put the last #endif *this->client_header_ << "\n"; - - if (be_global->post_include () != 0) + if (idl_global->post_include () != 0) { *this->client_header_ << "#include \"" - << be_global->post_include () + << idl_global->post_include () << "\"\n"; } - *this->client_header_ << "#endif /* ifndef */\n"; return 0; } @@ -1139,35 +1008,32 @@ TAO_CodeGen::end_client_header (void) int TAO_CodeGen::end_server_header (void) { - // Insert the template header. - if (be_global->gen_tie_classes ()) + // insert the template header + if (idl_global->gen_tie_classes ()) { *this->server_header_ << "#include \"" - << be_global->be_get_server_template_hdr_fname (1) + << idl_global->be_get_server_template_hdr_fname (1) << "\"\n"; } - // Insert the code to include the inline file. + // insert the code to include the inline file *this->server_header_ << "\n#if defined (__ACE_INLINE__)\n"; - *this->server_header_ << "#include \"" - << be_global->be_get_server_inline_fname (1) - << "\"\n"; + *this->server_header_ << "#include \"" << + idl_global->be_get_server_inline_fname (1) << "\"\n"; *this->server_header_ << "#endif /* defined INLINE */\n\n"; *this->server_header_ << "#if defined(_MSC_VER) && (_MSC_VER >= 1200)\n" << "#pragma warning(pop)\n" << "#endif /* _MSC_VER */\n"; - // Code to put the last #endif. + // code to put the last #endif *this->server_header_ << "\n"; - - if (be_global->post_include () != 0) + if (idl_global->post_include () != 0) { *this->server_header_ << "#include \"" - << be_global->post_include () + << idl_global->post_include () << "\"\n"; } - *this->server_header_ << "#endif /* ifndef */\n"; return 0; } @@ -1179,42 +1045,32 @@ TAO_CodeGen::end_implementation_header (const char *fname) ACE_OS::memset (macro_name, '\0', NAMEBUFSIZE); const char *suffix = ACE_OS::strrchr (fname, '.'); - if (suffix == 0) { // File seems to have no extension, so let us take the name // as it is. if (fname == 0) - { - // Bad file name. - return -1; - } + // bad file name + return -1; else - { - suffix = fname; - } + suffix = fname; } - // Convert letters in fname to upper case. + + // convert letters in fname to upcase for (int i=0; i < (suffix - fname); i++) - { - if (isalpha (fname [i])) - { - macro_name[i] = (char) toupper (fname [i]); - } - else if (isdigit (fname [i])) - { - macro_name[i] = fname[i]; - } - else - { - macro_name[i] = '_'; - } - } + if (isalpha (fname [i])) + macro_name[i] = (char) toupper (fname [i]); + else if (isdigit (fname [i])) + macro_name[i] = fname[i]; + else + macro_name[i] = '_'; ACE_OS::strcat (macro_name, "_H_"); - // Code to put the last #endif. + + // code to put the last #endif + //*this->implementation_header_ << "\n#endif /* %s */\n"; this->implementation_header_->print ("\n#endif /* %s */\n", macro_name); return 0; } @@ -1222,46 +1078,38 @@ TAO_CodeGen::end_implementation_header (const char *fname) int TAO_CodeGen::end_server_template_header (void) { - // Insert the code to include the inline file. + // insert the code to include the inline file *this->server_template_header_ << "\n#if defined (__ACE_INLINE__)\n"; - *this->server_template_header_ - << "#include \"" - << be_global->be_get_server_template_inline_fname (1) - << "\"\n"; + *this->server_template_header_ << "#include \"" << + idl_global->be_get_server_template_inline_fname (1) << "\"\n"; *this->server_template_header_ << "#endif /* defined INLINE */\n\n"; - // Insert the code to include the template source file. + // insert the code to include the template source file *this->server_template_header_ - << "\n#if defined (ACE_TEMPLATES_REQUIRE_SOURCE)\n"; - *this->server_template_header_ - << "#include \"" - << be_global->be_get_server_template_skeleton_fname (1) - << "\"\n"; + << "\n#if defined (ACE_TEMPLATES_REQUIRE_SOURCE)\n"; + *this->server_template_header_ << "#include \"" << + idl_global->be_get_server_template_skeleton_fname (1) << "\"\n"; *this->server_template_header_ << "#endif /* defined REQUIRED SOURCE */\n\n"; - // Insert the code to include the template pragma. - *this->server_template_header_ - << "\n#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)\n"; + // insert the code to include the template pragma *this->server_template_header_ - << "#pragma implementation (\"" - << be_global->be_get_server_template_skeleton_fname (1) - << "\")\n"; + << "\n#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)\n"; + *this->server_template_header_ << "#pragma implementation (\"" << + idl_global->be_get_server_template_skeleton_fname (1) << "\")\n"; *this->server_template_header_ << "#endif /* defined REQUIRED PRAGMA */\n\n"; *this->server_template_header_ << "#if defined(_MSC_VER) && (_MSC_VER >= 1200)\n" << "#pragma warning(pop)\n" << "#endif /* _MSC_VER */\n"; - // Code to put the last #endif. + // code to put the last #endif *this->server_template_header_ << "\n"; - - if (be_global->post_include () != 0) + if (idl_global->post_include () != 0) { *this->server_template_header_ << "#include \"" - << be_global->post_include () + << idl_global->post_include () << "\"\n"; } - *this->server_template_header_ << "#endif /* ifndef */\n"; return 0; } @@ -1269,7 +1117,7 @@ TAO_CodeGen::end_server_template_header (void) int TAO_CodeGen::end_server_template_skeletons (void) { - // Code to put the last #endif. + // code to put the last #endif *this->server_template_skeletons_ << "\n#endif /* ifndef */\n"; return 0; } @@ -1298,7 +1146,7 @@ TAO_CodeGen::gperf_input_stream (void) void TAO_CodeGen::gperf_input_filename (char *filename) { - delete [] this->gperf_input_filename_; + delete[] this->gperf_input_filename_; this->gperf_input_filename_ = ACE::strnew (filename); } @@ -1340,6 +1188,18 @@ TAO_CodeGen::config_visitor_factory (void) this->visitor_factory_ = TAO_COMPILED_VISITOR_FACTORY::instance (); } +void +TAO_CodeGen::lookup_strategy (LOOKUP_STRATEGY s) +{ + this->strategy_ = s; +} + +TAO_CodeGen::LOOKUP_STRATEGY +TAO_CodeGen::lookup_strategy (void) const +{ + return this->strategy_; +} + #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Singleton<TAO_CodeGen, ACE_SYNCH_RECURSIVE_MUTEX>; template class ACE_Singleton<TAO_OutStream_Factory, ACE_SYNCH_RECURSIVE_MUTEX>; |