From 58e80b38831df7abf4023fe9aae7af923155121c Mon Sep 17 00:00:00 2001 From: harriss Date: Fri, 25 May 2007 16:56:03 +0000 Subject: works with gcc v 3.4.4 --- TAO/TAO_IDL/be/be_codegen.cpp | 17 ++++++++++++ TAO/TAO_IDL/be/be_visitor_native/native_ch.cpp | 36 ++++++++++++++++++++++++++ TAO/TAO_IDL/fe/fe_lookup.cpp | 4 +-- TAO/TAO_IDL/fe/lex.yy.cpp | 24 +++++++++++------ TAO/TAO_IDL/include/idl_global.h | 24 ++++++++++++++--- TAO/TAO_IDL/util/utl_global.cpp | 26 +++++++++++++++++++ 6 files changed, 117 insertions(+), 14 deletions(-) diff --git a/TAO/TAO_IDL/be/be_codegen.cpp b/TAO/TAO_IDL/be/be_codegen.cpp index 105e16b7c9c..5831464c96f 100644 --- a/TAO/TAO_IDL/be/be_codegen.cpp +++ b/TAO/TAO_IDL/be/be_codegen.cpp @@ -1643,6 +1643,23 @@ TAO_CodeGen::gen_stub_hdr_includes (void) this->client_header_ ); + // DDS/DCPS zero-copy read sequence type support. + if (idl_global->dcps_support_zero_copy_read ()) + { + // include needed for sample info template instantiation. + this->gen_cond_file_include ( + true, // for Infrastructure.idl as well as Foo types + "dds/DCPS/ZeroCopyInfoSeq_T.h", + this->client_header_ + ); + // include needed for type specific sample sequence template instantitation. + this->gen_cond_file_include ( + idl_global->dcps_gen_zero_copy_read (), + "dds/DCPS/ZeroCopySeq_T.h", + this->client_header_ + ); + } + // Non-abstract interface or keyword 'Object'. this->gen_cond_file_include ( idl_global->non_local_iface_seen_ diff --git a/TAO/TAO_IDL/be/be_visitor_native/native_ch.cpp b/TAO/TAO_IDL/be/be_visitor_native/native_ch.cpp index b92c9828434..f928ddf7bf0 100644 --- a/TAO/TAO_IDL/be/be_visitor_native/native_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_native/native_ch.cpp @@ -19,6 +19,7 @@ // ============================================================================ #include "be_visitor_typecode/typecode_decl.h" +#include "global_extern.h" ACE_RCSID (be_visitor_native, native_ch, @@ -58,6 +59,41 @@ be_visitor_native_ch::visit_native (be_native *node) *os << "typedef void *Cookie;" << be_nl; else if (ACE_OS::strcmp (node_name, "CORBA::VoidData") == 0) *os << "typedef void *VoidData;" << be_nl; + else if (idl_global->dcps_support_zero_copy_read () + && 0 == ACE_OS::strcmp (node->full_name (),"DDS::SampleInfoSeq")) + { + // DDS/DCPS zero-copy read sequence type support. + *os << be_nl << be_nl + << "typedef ::TAO::DCPS::ZeroCopyInfoSeq< " + << "SampleInfo" + << ", DCPS_ZERO_COPY_SEQ_DEFAULT_SIZE> " + << "SampleInfo" + << "Seq;" << be_nl; + } + else if (idl_global->dcps_support_zero_copy_read () + && ACE_OS::strlen (node_name) > 3 + && 0 == ACE_OS::strcmp (node_name + ACE_OS::strlen (node_name)-3, "Seq") ) + { + // DDS/DCPS zero-copy read sequence type support. + + // strip the "Seq" ending to get the sample's name + const int max_name_length = 2000; + if (ACE_OS::strlen (node_name)-3 >= max_name_length) + { + return -1; + } + char sample_name[max_name_length]; + ACE_OS::strncpy (sample_name, node_name, ACE_OS::strlen (node_name)-3); + sample_name[ACE_OS::strlen (node_name)-3] = '\0'; + + *os << be_nl << be_nl + << "typedef ::TAO::DCPS::ZeroCopyDataSeq< " + << sample_name + << ", DCPS_ZERO_COPY_SEQ_DEFAULT_SIZE> " + << node->local_name () + << ";" << be_nl; + } + node->cli_hdr_gen (true); return 0; diff --git a/TAO/TAO_IDL/fe/fe_lookup.cpp b/TAO/TAO_IDL/fe/fe_lookup.cpp index cea2130e68d..3cb9d8ecc52 100644 --- a/TAO/TAO_IDL/fe/fe_lookup.cpp +++ b/TAO/TAO_IDL/fe/fe_lookup.cpp @@ -4,7 +4,7 @@ #include "ace/OS_NS_string.h" /* C++ code produced by gperf version 2.8 (ACE version) */ -/* Command-line: /build/isisbuilds/Core/ACE_wrappers/bin/gperf -M -J -c -C -D -E -T -f 0 -a -o -t -p -K keyword_ -L C++ -Z TAO_IDL_CPP_Keyword_Table -N lookup -k1,2,$ fe/keywords.dat */ +/* Command-line: /tao_builds/harris_s/DOC_TAO_zero_copy/ACE/bin/gperf -M -J -c -C -D -E -T -f 0 -a -o -t -p -K keyword_ -L C++ -Z TAO_IDL_CPP_Keyword_Table -N lookup -k1,2,$ fe/keywords.dat */ unsigned int TAO_IDL_CPP_Keyword_Table::hash (const char *str, unsigned int len) { @@ -56,7 +56,7 @@ TAO_IDL_CPP_Keyword_Table::hash (const char *str, unsigned int len) return len + asso_values[(int) str[1]] + asso_values[(int) str[0]] + asso_values[(int) str[len - 1]]; } -const TAO_IDL_CPP_Keyword_Entry * +const struct TAO_IDL_CPP_Keyword_Entry * TAO_IDL_CPP_Keyword_Table::lookup (const char *str, unsigned int len) { enum diff --git a/TAO/TAO_IDL/fe/lex.yy.cpp b/TAO/TAO_IDL/fe/lex.yy.cpp index 268becd5a7d..e85bd732aab 100644 --- a/TAO/TAO_IDL/fe/lex.yy.cpp +++ b/TAO/TAO_IDL/fe/lex.yy.cpp @@ -1,4 +1,4 @@ -/* A lexical scanner generated by flex */ +//* A lexical scanner generated by flex */ /* Scanner skeleton version: * $Id$ @@ -2935,30 +2935,38 @@ idl_store_pragma (char *buf) } else if (ACE_OS::strncmp (buf + 8, "DCPS_DATA_TYPE", 14) == 0) { - char *foo_type = idl_get_pragma_string (buf); - idl_global->add_dcps_data_type(foo_type); + char *sample_type = idl_get_pragma_string (buf); + idl_global->add_dcps_data_type (sample_type); } else if (ACE_OS::strncmp (buf + 8, "DCPS_DATA_KEY", 13) == 0) { char *tmp = idl_get_pragma_string (buf); // split up data type and key strings - char *foo_type = tmp; - while (*tmp && !isspace(*tmp)) + char *sample_type = tmp; + while (*tmp && !isspace (*tmp)) tmp++; - while (isspace(*tmp)) + while (isspace (*tmp)) { *tmp = '\0'; tmp++; } char *key = tmp; - if (!idl_global->add_dcps_data_key(foo_type, key)) + if (!idl_global->add_dcps_data_key (sample_type, key)) { ACE_ERROR((LM_ERROR, "DCPS_DATA_TYPE \"%s\" not found for key \"%s\"\n", - foo_type, key)); + sample_type, key)); } } + else if (ACE_OS::strncmp (buf + 8, "DCPS_SUPPORT_ZERO_COPY_READ", 27) == 0) + { + idl_global->dcps_support_zero_copy_read (true); + } + else if (ACE_OS::strncmp (buf + 8, "DCPS_GEN_ZERO_COPY_READ", 23) == 0) + { + idl_global->dcps_gen_zero_copy_read (true); + } } /* diff --git a/TAO/TAO_IDL/include/idl_global.h b/TAO/TAO_IDL/include/idl_global.h index 75f9531c06b..82cc756ff62 100644 --- a/TAO/TAO_IDL/include/idl_global.h +++ b/TAO/TAO_IDL/include/idl_global.h @@ -401,7 +401,7 @@ public: virtual void reset_flag_seen (void); - // = Methods supporting DDS DCPS data type/key definition (from #pragma) + // = Types & methods supporting DDS DCPS data type/key definition (from #pragma) typedef ACE_Unbounded_Queue DCPS_Key_List; struct DCPS_Data_Type_Info { UTL_ScopedName *name_; @@ -416,11 +416,19 @@ public: ACE_Null_Mutex> DCPS_Type_Info_Map ; // FE calls when #pragma DCPS_DATA_TYPE is processed - virtual void add_dcps_data_type(const char* id); + virtual void add_dcps_data_type (const char* id); // FE calls when #pragma DCPS_DATA_KEY is processed - virtual bool add_dcps_data_key(const char* id, const char* key); + virtual bool add_dcps_data_key (const char* id, const char* key); // returns null if not matching; otherwise pointer to the info - virtual DCPS_Data_Type_Info* is_dcps_type(UTL_ScopedName* target); + virtual DCPS_Data_Type_Info* is_dcps_type (UTL_ScopedName* target); + // FE calls when #pragma DCPS_SUPPORT_ZERO_COPY_READ is processed + virtual void dcps_support_zero_copy_read (bool value); + // BE calls to check the status of zero-copy read support + virtual bool dcps_support_zero_copy_read (void) const; + // FE calls when #pragma DCPS_GEN_ZERO_COPY_READ is processed + virtual void dcps_gen_zero_copy_read (bool value); + // BE calls to check the status of zero-copy read support + virtual bool dcps_gen_zero_copy_read (void) const; // = Access methods to deal with other IDL files included in the main // IDL file. These IDL files are exactly the same strings that are @@ -696,6 +704,14 @@ private: DCPS_Type_Info_Map dcps_type_info_map_ ; // Map of #pragma DCPS_DATA_TYPE and DCPS_DATA_KEY infomation. + bool dcps_support_zero_copy_read_; + // Are we enabled to support DCPS zero-copy read. + // Need this flag to avoid generating wrong code for pre v0.12 DDS + // with new TAO_IDL compiler. + + bool dcps_gen_zero_copy_read_; + // Are we generating code insupport of DCPS zero-copy read data sequences? + ACE_Unbounded_Queueprimary_keys_; // List of valuetypes used as a primary key. diff --git a/TAO/TAO_IDL/util/utl_global.cpp b/TAO/TAO_IDL/util/utl_global.cpp index 882bc56a0b3..6c2b30ee0e1 100644 --- a/TAO/TAO_IDL/util/utl_global.cpp +++ b/TAO/TAO_IDL/util/utl_global.cpp @@ -145,6 +145,8 @@ IDL_GlobalData::IDL_GlobalData (void) pass_orb_idl_ (false), using_ifr_backend_ (false), ignore_idl3_ (false), + dcps_support_zero_copy_read_ (false), + dcps_gen_zero_copy_read_ (false), recursion_start_ (0) // Not used by all backends. { // Path for the perfect hash generator(gperf) program. @@ -1387,6 +1389,30 @@ IDL_GlobalData::ignore_idl3 (bool val) this->ignore_idl3_ = val; } +bool +IDL_GlobalData::dcps_support_zero_copy_read (void) const +{ + return this->dcps_support_zero_copy_read_; +} + +void +IDL_GlobalData::dcps_support_zero_copy_read (bool val) +{ + this->dcps_support_zero_copy_read_ = val; +} + +bool +IDL_GlobalData::dcps_gen_zero_copy_read (void) const +{ + return this->dcps_gen_zero_copy_read_; +} + +void +IDL_GlobalData::dcps_gen_zero_copy_read (bool val) +{ + this->dcps_gen_zero_copy_read_ = val; +} + // Return 0 on success, -1 failure. The corresponding to the // error that caused the GPERF execution is also set. int -- cgit v1.2.1