From e987d3f40b421664e662e83c6c91930fa3e9c553 Mon Sep 17 00:00:00 2001 From: dai_y Date: Wed, 30 May 2007 20:30:12 +0000 Subject: Wed May 30 20:18:11 UTC 2007 Yan Dai --- TAO/ChangeLog | 28 +++++ TAO/TAO_IDL/be/be_codegen.cpp | 116 ++++++++++++++++++--- TAO/TAO_IDL/be/be_global.cpp | 43 +++++++- .../be/be_visitor_sequence/serializer_op_ch.cpp | 11 ++ .../be/be_visitor_sequence/serializer_op_cs.cpp | 13 ++- .../be_visitor_union_branch/serializer_op_cs.cpp | 4 +- TAO/TAO_IDL/be_include/be_global.h | 10 ++ 7 files changed, 202 insertions(+), 23 deletions(-) diff --git a/TAO/ChangeLog b/TAO/ChangeLog index af7a9919271..1f5ace5c536 100644 --- a/TAO/ChangeLog +++ b/TAO/ChangeLog @@ -1,3 +1,31 @@ +Wed May 30 20:18:11 UTC 2007 Yan Dai + + These changes support built in sequences in DDS. + The -Gdcpsonly option was added to just generate DDS specific + code for built in sequence. A DDS DCPS IDL file that includes + tao/*Seq.pidl will generate code to include the DDS version + of the generated code instead of TAO version sequence code + so it supports DDS serialization. + + * TAO_IDL/be/be_global.cpp: + * TAO_IDL/be_include/be_global.h: + + Added gen_dcps_type_support_only flag. + + * TAO_IDL/be/be_codegen.cpp: + * TAO_IDL/be/be_visitor_sequence/serializer_op_ch.cpp: + * TAO_IDL/be/be_visitor_sequence/serializer_op_cs.cpp: + + Generated code similar to before with -Gdcps except using #if 0 + to disable TAO specific code when -Gdcpsonly is given. + The DDS CORBA::*Seq generated code will include the + TAO CORBA::*Seq generated code so both TAO and DDS + functions will be available. + + * TAO_IDL/be/be_visitor_union_branch/serializer_op_cs.cpp: + + Fixed bugs that call strlen() without check if it's nil string. + Wed May 30 20:06:04 UTC 2007 Adam Mitz * TAO_IDL/be/be_visitor_root.cpp: diff --git a/TAO/TAO_IDL/be/be_codegen.cpp b/TAO/TAO_IDL/be/be_codegen.cpp index 5831464c96f..703ebe768f6 100644 --- a/TAO/TAO_IDL/be/be_codegen.cpp +++ b/TAO/TAO_IDL/be/be_codegen.cpp @@ -142,21 +142,67 @@ TAO_CodeGen::start_client_header (const char *fname) bool const got_pidl = (pidl_checker.substr (pidl_checker.length () - 5) == ".pidl"); - if (!got_pidl) + if (be_global->gen_dcps_type_support_only ()) { - // Generate the #ifndef clause. - this->gen_ifndef_string (fname, - this->client_header_, - "_TAO_IDL_", - "_H_"); + if (!got_pidl) + { + // Generate #ifndef string which is different from + // no dcps type support. + this->gen_ifndef_string (fname, + this->client_header_, + "_TAO_IDL_DDS_", + "_H_"); + } + else + { + // Generate the #ifndef clause. + this->gen_ifndef_string (fname, + this->client_header_, + "_TAO_PIDL_DDS_", + "_H_"); + } + + if (be_global->stub_export_include () != 0) + { + *this->client_header_ << "\n#include /**/ \"" + << be_global->stub_export_include () + << "\""; + } + + // DDS/DCPS marshaling. + this->gen_cond_file_include ( + true, + "dds/DCPS/Serializer.h", + this->client_header_ + ); + + // Generate the includes of tao version sequence header. + this->client_header_->print ("\n#include \"tao/%s\"", + fname); + + // Add #if 0 to disable TAO specific code + *this->client_header_ << be_nl << be_nl + << "#if 0 // disable TAO specific code" + << be_nl << be_nl; } else { - // Generate the #ifndef clause. - this->gen_ifndef_string (fname, - this->client_header_, - "_TAO_PIDL_", - "_H_"); + if (!got_pidl) + { + // Generate the #ifndef clause. + this->gen_ifndef_string (fname, + this->client_header_, + "_TAO_IDL_", + "_H_"); + } + else + { + // Generate the #ifndef clause. + this->gen_ifndef_string (fname, + this->client_header_, + "_TAO_PIDL_", + "_H_"); + } } if (be_global->pre_include () != 0) @@ -235,6 +281,20 @@ TAO_CodeGen::start_client_header (const char *fname) { char* idl_name = idl_global->included_idl_files ()[j]; + if (be_global->gen_dcps_type_support ()) + { + // When -Gdcps is enabled, if the "tao/*Seq.pidl" is + // included in a DDS idl file then the generated code + // will include the dds version idl generated code. + if (ACE_OS::strstr (idl_name, "tao/") == idl_name + && ACE_OS::strstr (idl_name, "Seq.pidl")) + { + idl_name[0] = 'd'; + idl_name[1] = 'd'; + idl_name[2] = 's'; + } + } + // Make a String out of it. UTL_String idl_name_str = idl_name; @@ -420,11 +480,22 @@ TAO_CodeGen::start_server_header (const char *fname) // Generate the ident string, if any. this->gen_ident_string (this->server_header_); - // Generate the #ifndef clause. - this->gen_ifndef_string (fname, - this->server_header_, - "_TAO_IDL_", - "_H_"); + if (be_global->gen_dcps_type_support_only ()) + { + // Generate the #ifndef clause. + this->gen_ifndef_string (fname, + this->server_header_, + "_TAO_IDL_DDS_", + "_H_"); + } + else + { + // Generate the #ifndef clause. + this->gen_ifndef_string (fname, + this->server_header_, + "_TAO_IDL_", + "_H_"); + } if (be_global->pre_include () != 0) { @@ -1161,6 +1232,13 @@ TAO_CodeGen::end_client_header (void) << "\"\n\n"; } + if (be_global->gen_dcps_type_support_only ()) + { + *this->client_header_ << be_nl << be_nl + << "#endif /* end of disabling TAO specific code */" + << be_nl << be_nl; + } + *this->client_header_ << "#endif /* ifndef */" << be_nl << be_nl; return 0; @@ -1820,6 +1898,12 @@ TAO_CodeGen::gen_stub_src_includes (void) this->gen_typecode_includes (this->client_stubs_); } + if (be_global->gen_dcps_type_support_only ()) + { + *this->client_stubs_ << "\n\n#if 0 // disable TAO specific code " + << be_nl << be_nl; + } + // Always generated. this->gen_standard_include (this->client_stubs_, "tao/CDR.h"); diff --git a/TAO/TAO_IDL/be/be_global.cpp b/TAO/TAO_IDL/be/be_global.cpp index 7018ad84b65..cb10bd490fa 100644 --- a/TAO/TAO_IDL/be/be_global.cpp +++ b/TAO/TAO_IDL/be/be_global.cpp @@ -90,6 +90,7 @@ BE_GlobalData::BE_GlobalData (void) gen_smart_proxies_ (false), gen_inline_constants_ (true), gen_dcps_type_support_ (false), + gen_dcps_type_support_only_ (false), gen_orb_h_include_ (true), gen_empty_anyop_header_ (false), lookup_strategy_ (TAO_PERFECT_HASH), @@ -1107,6 +1108,19 @@ BE_GlobalData::gen_dcps_type_support (void) const return this->gen_dcps_type_support_; } +void +BE_GlobalData::gen_dcps_type_support_only (bool val) +{ + this->gen_dcps_type_support_only_ = val; +} + +bool +BE_GlobalData::gen_dcps_type_support_only (void) const +{ + return this->gen_dcps_type_support_only_; +} + + void BE_GlobalData::gen_orb_h_include (bool val) { @@ -1995,10 +2009,29 @@ BE_GlobalData::parse_args (long &i, char **av) { if (av[i][3] == 'c') { - if (av[i][4] == 'p' && av[i][5] =='s' && '\0' == av[i][6]) + if (av[i][4] == 'p' && av[i][5] =='s') { - // DDS DCPS type support. - be_global->gen_dcps_type_support (true); + if ('\0' == av[i][6]) + { + // DDS DCPS type support. + be_global->gen_dcps_type_support (true); + } + else if (av[i][6] == 'o' && av[i][7] == 'n' + && av[i][8] == 'l' && av[i][9] == 'y' && '\0' == av[i][10]) + { + // DDS DCPS type only support + be_global->gen_dcps_type_support (true); + be_global->gen_dcps_type_support_only (true); + } + else + { + ACE_ERROR (( + LM_ERROR, + ACE_TEXT ("IDL: I don't understand ") + ACE_TEXT ("the '%s' option\n"), + av[i] + )); + } } else { @@ -2534,6 +2567,10 @@ BE_GlobalData::usage (void) const LM_DEBUG, ACE_TEXT (" -Gdcps \t\tGenerate code supporting DDS DCPS type definitions.\n") )); + ACE_DEBUG (( + LM_DEBUG, + ACE_TEXT (" -Gdcpsonly \t\t\tGenerate code only supporting DDS DCPS type serializer definitions.\n") + )); ACE_DEBUG (( LM_DEBUG, ACE_TEXT (" -GI[h|s|b|e|c|a|d]\tGenerate Implementation Files \n") diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/serializer_op_ch.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/serializer_op_ch.cpp index cc9216fa8fb..2a925960445 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/serializer_op_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/serializer_op_ch.cpp @@ -67,6 +67,12 @@ be_visitor_sequence_serializer_op_ch::visit_sequence (be_sequence *node) be_type *bt = be_type::narrow_from_decl (node); be_typedef *tdef = be_typedef::narrow_from_decl (bt); + if (be_global->gen_dcps_type_support_only ()) + { + *os << "\n#endif /* end of disabling TAO specific code */" + << be_nl << be_nl; + } + *os << be_nl << be_nl << "// TAO_IDL - Generated from" << be_nl << "// " << __FILE__ << ":" << __LINE__; @@ -112,6 +118,11 @@ be_visitor_sequence_serializer_op_ch::visit_sequence (be_sequence *node) << node->flat_name () << "_H_ */"; } + if (be_global->gen_dcps_type_support_only ()) + { + *os << be_nl << be_nl << "#if 0 // disable TAO specific code" + << be_nl << be_nl; + } node->cli_hdr_serializer_op_gen (1); return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/serializer_op_cs.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/serializer_op_cs.cpp index a34f26d4b4a..497ca12707e 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/serializer_op_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/serializer_op_cs.cpp @@ -92,6 +92,14 @@ be_visitor_sequence_serializer_op_cs::visit_sequence (be_sequence *node) } } + + if (be_global->gen_dcps_type_support_only ()) + { + *os << be_nl << be_nl + << "#endif /* end of disabling TAO specific code */" + << be_nl << be_nl; + } + *os << be_nl << be_nl << "// TAO_IDL - Generated from" << be_nl << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; @@ -987,8 +995,9 @@ switch (this->ctx_->sub_state ()) break; case AST_Decl::NT_string: case AST_Decl::NT_wstring: - *os << "the_length += _dcps_max_marshaled_size_ulong () + " - << "ACE_OS::strlen (_tao_sequence[i]);" << be_uidt_nl; + *os << "the_length += _dcps_max_marshaled_size_ulong () " << be_nl + << "+ (_tao_sequence[i] == 0 ? 0 : ACE_OS::strlen (_tao_sequence[i]));" + << be_uidt_nl; break; case AST_Decl::NT_interface: *os << "//DCPS - Sequence of interfaces is not supported" << be_nl; diff --git a/TAO/TAO_IDL/be/be_visitor_union_branch/serializer_op_cs.cpp b/TAO/TAO_IDL/be/be_visitor_union_branch/serializer_op_cs.cpp index 5992bc606e7..2c7d50f0365 100644 --- a/TAO/TAO_IDL/be/be_visitor_union_branch/serializer_op_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_union_branch/serializer_op_cs.cpp @@ -1035,8 +1035,8 @@ be_visitor_union_branch_serializer_op_cs::visit_string (be_string *node) break; case TAO_CodeGen::TAO_FIND_SIZE: *os << "result += _dcps_max_marshaled_size_ulong() + " << be_idt_nl - << "ACE_OS::strlen(_tao_union." - << f->local_name () << " ());" << be_uidt_nl; + << "(_tao_union." << f->local_name () << " () ? ACE_OS::strlen(_tao_union." + << f->local_name () << " ()) : 0);" << be_uidt_nl; break; case TAO_CodeGen::TAO_CDR_INPUT: if (node->width () == (long) sizeof (char)) diff --git a/TAO/TAO_IDL/be_include/be_global.h b/TAO/TAO_IDL/be_include/be_global.h index 5f83c6120c8..461f5321d81 100644 --- a/TAO/TAO_IDL/be_include/be_global.h +++ b/TAO/TAO_IDL/be_include/be_global.h @@ -468,6 +468,12 @@ public: bool gen_dcps_type_support (void) const; // Return the flag. + void gen_dcps_type_support_only (bool value); + // Set the flag. + + bool gen_dcps_type_support_only (void) const; + // Return the flag. + void gen_orb_h_include (bool value); // Set the flag. @@ -719,6 +725,10 @@ private: // Flag to indicate whether we are supporting DDS DCPS type definitions. // Includes Serializer operators (like TAO_Input/OutuptCDR). + bool gen_dcps_type_support_only_; + // Flag to indicate whether we are supporting DDS DCPS type only definitions. + // Only generate DDS Serializer operators for tao/*Seq.pidl. + bool gen_orb_h_include_; // Flag to indicate whether ORB.h include should be generated, needed for // regenerating the pidl files. -- cgit v1.2.1