diff options
-rw-r--r-- | TAO/ChangeLog | 21 | ||||
-rw-r--r-- | TAO/TAO_IDL/be/be_global.cpp | 20 | ||||
-rw-r--r-- | TAO/TAO_IDL/be/be_produce.cpp | 11 | ||||
-rw-r--r-- | TAO/TAO_IDL/be/be_util.cpp | 5 | ||||
-rw-r--r-- | TAO/TAO_IDL/be/be_visitor_dds_ts_idl.cpp | 369 | ||||
-rw-r--r-- | TAO/TAO_IDL/be_include/be_global.h | 7 | ||||
-rw-r--r-- | TAO/TAO_IDL/be_include/be_visitor_dds_ts_idl.h | 59 | ||||
-rw-r--r-- | TAO/docs/compiler.html | 7 |
8 files changed, 496 insertions, 3 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog index 9ef40c6a8b8..b3ff1afe783 100644 --- a/TAO/ChangeLog +++ b/TAO/ChangeLog @@ -1,3 +1,24 @@ +Wed Nov 17 15:07:20 UTC 2010 Jeff Parsons <j.parsons@vanderbilt.edu> + + * TAO_IDL/be_include/be_visitor_dds_ts_idl.h: + * TAO_IDL/be/be_visitor_dds_ts_idl.cpp: + + New files, defining a new visitor that generates DDS + type support classes, triggered by the option -Gts. + At present, only the data writer and data reader + classes are generated, and no check is made that + the datatype is used by DDS (all structs, unions + and valuetypes are processed). Such a check will be + added at a later time. + + * TAO_IDL/be/be_util.cpp: + * TAO_IDL/be/be_global.cpp: + * TAO_IDL/be/be_produce.cpp: + * TAO_IDL/be_include/be_global.h: + * docs/compiler.html: + + Support code for the new visitor and command line option. + Wed Nov 17 09:31:45 UTC 2010 Vladimir Zykov <vladimir.zykov@prismtech.com> * TAO_IDL/be/be_codegen.cpp: diff --git a/TAO/TAO_IDL/be/be_global.cpp b/TAO/TAO_IDL/be/be_global.cpp index 5a0d304f69e..9531cd4854b 100644 --- a/TAO/TAO_IDL/be/be_global.cpp +++ b/TAO/TAO_IDL/be/be_global.cpp @@ -138,6 +138,7 @@ BE_GlobalData::BE_GlobalData (void) gen_ciao_exec_impl_ (false), gen_ciao_exec_reactor_impl_ (false), gen_ciao_conn_impl_ (false), + gen_dds_typesupport_idl_ (false), gen_ciao_valuefactory_reg_ (true), gen_stub_export_hdr_file_ (false), gen_skel_export_hdr_file_ (false), @@ -2395,6 +2396,18 @@ BE_GlobalData::gen_ciao_conn_impl (bool val) } bool +BE_GlobalData::gen_dds_typesupport_idl (void) const +{ + return this->gen_dds_typesupport_idl_; +} + +void +BE_GlobalData::gen_dds_typesupport_idl (bool val) +{ + this->gen_dds_typesupport_idl_ = val; +} + +bool BE_GlobalData::gen_ciao_valuefactory_reg (void) const { return this->gen_ciao_valuefactory_reg_; @@ -2926,6 +2939,13 @@ BE_GlobalData::parse_args (long &i, char **av) break; } + else if (av[i][2] == 't' && av[i][3] == 's') + { + // DDS type support IDL generation. + be_global->gen_dds_typesupport_idl (true); + + break; + } else if (av[i][2] == 'e' && av[i][3] == 'x') { // CIAO executor impl code generation. diff --git a/TAO/TAO_IDL/be/be_produce.cpp b/TAO/TAO_IDL/be/be_produce.cpp index e1adf705919..4a7556475c4 100644 --- a/TAO/TAO_IDL/be/be_produce.cpp +++ b/TAO/TAO_IDL/be/be_produce.cpp @@ -68,6 +68,7 @@ trademarks or registered trademarks of Sun Microsystems, Inc. #include "be_visitor_ami_pre_proc.h" #include "be_visitor_amh_pre_proc.h" #include "be_visitor_ccm_pre_proc.h" +#include "be_visitor_dds_ts_idl.h" #include "be_visitor_context.h" #include "be_root.h" #include "be_extern.h" @@ -116,6 +117,12 @@ BE_produce (void) { be_visitor_context ctx; + if (be_global->gen_dds_typesupport_idl ()) + { + be_visitor_dds_ts_idl root_dds_idl_visitor (&ctx); + BE_visit_root (root_dds_idl_visitor, "DDS type support IDL"); + } + if (!idl_global->ignore_idl3 ()) { be_visitor_ccm_pre_proc ccm_preproc_visitor (&ctx); @@ -224,8 +231,8 @@ BE_produce (void) if (be_global->gen_ciao_exec_idl ()) { ctx.state (TAO_CodeGen::TAO_ROOT_EX_IDL); - be_visitor_root_ex_idl root_svs_visitor (&ctx); - BE_visit_root (root_svs_visitor, "CIAO executor IDL"); + be_visitor_root_ex_idl root_ex_idl_visitor (&ctx); + BE_visit_root (root_ex_idl_visitor, "CIAO executor IDL"); } if (be_global->gen_ciao_exec_impl ()) diff --git a/TAO/TAO_IDL/be/be_util.cpp b/TAO/TAO_IDL/be/be_util.cpp index 8a2211edeb4..cf24c3d8026 100644 --- a/TAO/TAO_IDL/be/be_util.cpp +++ b/TAO/TAO_IDL/be/be_util.cpp @@ -663,6 +663,11 @@ be_util::usage (void) )); ACE_DEBUG (( LM_DEBUG, + ACE_TEXT (" -Gts\t\t\tgenerate DDS type support IDL ") + ACE_TEXT ("(not generated by default)\n") + )); + ACE_DEBUG (( + LM_DEBUG, ACE_TEXT (" -Gsc\t\t\tgenerate CIAO code for static ") ACE_TEXT ("configuration (not generated by default)\n") )); diff --git a/TAO/TAO_IDL/be/be_visitor_dds_ts_idl.cpp b/TAO/TAO_IDL/be/be_visitor_dds_ts_idl.cpp new file mode 100644 index 00000000000..446c36393ba --- /dev/null +++ b/TAO/TAO_IDL/be/be_visitor_dds_ts_idl.cpp @@ -0,0 +1,369 @@ + +//============================================================================= +/** + * @file be_visitor_dds_ts_idl.cpp + * + * $Id$ + * + * Visitor generating code for DDS type support IDL files. + * + * + * @author Jeff Parsons + */ +//============================================================================= + +// ******************************** +// Visitor for DDS type support IDL +// ******************************** + +#include "be_visitor_dds_ts_idl.h" +#include "be_visitor_context.h" +#include "be_root.h" +#include "be_structure.h" +#include "be_union.h" +#include "be_valuetype.h" +#include "be_extern.h" +#include "be_util.h" + +#include "utl_string.h" +#include "utl_identifier.h" + +be_visitor_dds_ts_idl::be_visitor_dds_ts_idl ( + be_visitor_context *ctx) + : be_visitor_scope (ctx), + os_ptr_ (0) +{ +} + +be_visitor_dds_ts_idl::~be_visitor_dds_ts_idl (void) +{ +} + +int +be_visitor_dds_ts_idl::visit_root (be_root *node) +{ + if (this->visit_scope (node) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("be_visitor_dds_ts_idl") + ACE_TEXT ("::visit_root - ") + ACE_TEXT ("codegen for scope failed\n")), + -1); + } + + return 0; +} + +int +be_visitor_dds_ts_idl::visit_module (be_module *node) +{ + if (this->visit_scope (node) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("be_visitor_dds_ts_idl") + ACE_TEXT ("::visit_module - ") + ACE_TEXT ("codegen for scope failed\n")), + -1); + } + + return 0; +} + +int +be_visitor_dds_ts_idl::visit_structure (be_structure *node) +{ + return this->process_node (node); +} + +int +be_visitor_dds_ts_idl::visit_union (be_union *node) +{ + return this->process_node (node); +} + +int +be_visitor_dds_ts_idl::visit_valuetype (be_valuetype *node) +{ + return this->process_node (node); +} + +int +be_visitor_dds_ts_idl::process_node (be_type *node) +{ + if (this->init_file (node) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("be_visitor_dds_ts_idl") + ACE_TEXT ("::process_node - ") + ACE_TEXT ("failed to initialize\n")), + -1); + } + + be_util::gen_nesting_open (*this->os_ptr_, node); + + this->gen_datawriter (node); + this->gen_datareader (node); + + be_util::gen_nesting_close (*this->os_ptr_, node); + + this->fini_file (); + + return 0; +} + +void +be_visitor_dds_ts_idl::gen_datawriter (be_type *node) +{ + TAO_OutStream &os_ (*this->os_ptr_); + const char *lname = node->local_name ()->get_string (); + + os_ << be_nl + << "local interface " << lname + << "DataWriter : ::DDS::DataWriter" << be_nl + << "{" << be_idt; + + os_ << be_nl + << "DDS::InstanceHandle_t register_instance (" << be_idt_nl + << "in " << lname << " instance_data);" << be_uidt; + + os_ << be_nl_2 + << "DDS::InstanceHandle_t register_instance_w_timestamp (" + << be_idt_nl + << "in " << lname << " instance_data," << be_nl + << "in DDS::Time_t source_timestamp);" << be_uidt; + + os_ << be_nl_2 + << "DDS::ReturnCode_t unregister_instance (" << be_idt_nl + << "in " << lname << " instance_data," << be_nl + << "in DDS::InstanceHandle_t handle);" << be_uidt; + + os_ << be_nl_2 + << "DDS::ReturnCode_t unregister_instance_w_timestamp (" + << be_idt_nl + << "in " << lname << " instance_data," << be_nl + << "in DDS::InstanceHandle_t handle," << be_nl + << "in DDS::Time_t source_timestamp);" << be_uidt; + + os_ << be_nl_2 + << "DDS::ReturnCode_t write (" << be_idt_nl + << "in " << lname << " instance_data," << be_nl + << "in DDS::InstanceHandle_t handle);" << be_uidt; + + os_ << be_nl_2 + << "DDS::ReturnCode_t write_w_timestamp (" << be_idt_nl + << "in " << lname << " instance_data," << be_nl + << "in DDS::InstanceHandle_t handle," << be_nl + << "in DDS::Time_t source_timestamp);" << be_uidt; + + os_ << be_nl_2 + << "DDS::ReturnCode_t dispose (" << be_idt_nl + << "in " << lname << " instance_data," << be_nl + << "in DDS::InstanceHandle_t instance_handle);" + << be_uidt; + + os_ << be_nl_2 + << "DDS::ReturnCode_t dispose_w_timestamp (" + << be_idt_nl + << "in " << lname << " instance_data," << be_nl + << "in DDS::InstanceHandle_t instance_handle," << be_nl + << "in DDS::Time_t source_timestamp);" << be_uidt; + + os_ << be_nl_2 + << "DDS::ReturnCode_t get_key_value (" << be_idt_nl + << "inout " << lname << " key_holder," << be_nl + << "in DDS::InstanceHandle_t handle);" << be_uidt; + + os_ << be_nl_2 + << "DDS::InstanceHandle_t lookup_instance (" + << be_idt_nl + << "in " << lname << " instance_data);" << be_uidt; + + os_ << be_uidt_nl + << "};"; +} + +void +be_visitor_dds_ts_idl::gen_datareader (be_type *node) +{ + TAO_OutStream &os_ (*this->os_ptr_); + const char *lname = node->local_name ()->get_string (); + + os_ << be_nl_2 + << "local interface " << lname + << "DataReader : ::DDS::DataReader" << be_nl + << "{" << be_idt; + + os_ << be_nl + << "DDS::ReturnCode_t read (" << be_idt_nl + << "inout " << lname << "Seq data_values," << be_nl + << "inout DDS::SampleInfoSeq sample_infos," << be_nl + << "in long max_samples," << be_nl + << "in DDS::SampleStateMask sample_states," << be_nl + << "in DDS::ViewStateMask view_states," << be_nl + << "in DDS::InstanceStateMask instance_states);" + << be_uidt; + + os_ << be_nl_2 + << "DDS::ReturnCode_t take (" << be_idt_nl + << "inout " << lname << "Seq data_values," << be_nl + << "inout DDS::SampleInfoSeq sample_infos," << be_nl + << "in long max_samples," << be_nl + << "in DDS::SampleStateMask sample_states," << be_nl + << "in DDS::ViewStateMask view_states," << be_nl + << "in DDS::InstanceStateMask instance_states);" + << be_uidt; + + os_ << be_nl_2 + << "DDS::ReturnCode_t read_w_condition (" << be_idt_nl + << "inout " << lname << "Seq data_values," << be_nl + << "inout DDS::SampleInfoSeq sample_infos," << be_nl + << "in long max_samples," << be_nl + << "in DDS::ReadCondition a_condition);" << be_uidt; + + os_ << be_nl_2 + << "DDS::ReturnCode_t take_w_condition (" << be_idt_nl + << "inout " << lname << "Seq data_values," << be_nl + << "inout DDS::SampleInfoSeq sample_infos," << be_nl + << "in long max_samples," << be_nl + << "in DDS::ReadCondition a_condition);" << be_uidt; + + os_ << be_nl_2 + << "DDS::ReturnCode_t read_next_sample (" << be_idt_nl + << "inout " << lname << " data_values," << be_nl + << "inout DDS::SampleInfo sample_info);" << be_uidt; + + os_ << be_nl_2 + << "DDS::ReturnCode_t take_next_sample (" << be_idt_nl + << "inout " << lname << " data_values," << be_nl + << "inout DDS::SampleInfo sample_info);" << be_uidt; + + os_ << be_nl_2 + << "DDS::ReturnCode_t read_instance (" << be_idt_nl + << "inout " << lname << "Seq data_values," << be_nl + << "inout DDS::SampleInfoSeq sample_infos," << be_nl + << "in long max_samples," << be_nl + << "in DDS::InstanceHandle_t a_handle," << be_nl + << "in DDS::SampleStateMask sample_states," << be_nl + << "in DDS::ViewStateMask view_states," << be_nl + << "in DDS::InstanceStateMask instance_states);" + << be_uidt; + + os_ << be_nl_2 + << "DDS::ReturnCode_t take_instance (" << be_idt_nl + << "inout " << lname << "Seq data_values," << be_nl + << "inout DDS::SampleInfoSeq sample_infos," << be_nl + << "in long max_samples," << be_nl + << "in DDS::InstanceHandle_t a_handle," << be_nl + << "in DDS::SampleStateMask sample_states," << be_nl + << "in DDS::ViewStateMask view_states," << be_nl + << "in DDS::InstanceStateMask instance_states);" + << be_uidt; + + os_ << be_nl_2 + << "DDS::ReturnCode_t read_next_instance (" << be_idt_nl + << "inout " << lname << "Seq data_values," << be_nl + << "inout DDS::SampleInfoSeq sample_infos," << be_nl + << "in long max_samples," << be_nl + << "in DDS::InstanceHandle_t previous_handle," << be_nl + << "in DDS::SampleStateMask sample_states," << be_nl + << "in DDS::ViewStateMask view_states," << be_nl + << "in DDS::InstanceStateMask instance_states);" + << be_uidt; + + os_ << be_nl_2 + << "DDS::ReturnCode_t take_next_instance (" << be_idt_nl + << "inout " << lname << "Seq data_values," << be_nl + << "inout DDS::SampleInfoSeq sample_infos," << be_nl + << "in long max_samples," << be_nl + << "in DDS::InstanceHandle_t previous_handle," << be_nl + << "in DDS::SampleStateMask sample_states," << be_nl + << "in DDS::ViewStateMask view_states," << be_nl + << "in DDS::InstanceStateMask instance_states);" + << be_uidt; + + os_ << be_nl_2 + << "DDS::ReturnCode_t read_next_instance_w_condition (" + << be_idt_nl + << "inout " << lname << "Seq data_values," << be_nl + << "inout DDS::SampleInfoSeq sample_infos," << be_nl + << "in long max_samples," << be_nl + << "in DDS::InstanceHandle_t previous_handle," << be_nl + << "in DDS::ReadCondition a_condition);" << be_uidt; + + os_ << be_nl_2 + << "DDS::ReturnCode_t take_next_instance_w_condition (" + << be_idt_nl + << "inout " << lname << "Seq data_values," << be_nl + << "inout DDS::SampleInfoSeq sample_infos," << be_nl + << "in long max_samples," << be_nl + << "in DDS::InstanceHandle_t previous_handle," << be_nl + << "in DDS::ReadCondition a_condition);" << be_uidt; + + os_ << be_nl_2 + << "DDS::ReturnCode_t return_loan (" << be_idt_nl + << "inout " << lname << "Seq data_values," << be_nl + << "inout DDS::SampleInfoSeq sample_infos);" + << be_uidt; + + os_ << be_nl_2 + << "DDS::ReturnCode_t get_key_value (" << be_idt_nl + << "inout " << lname << " key_holder," << be_nl + << "in DDS::InstanceHandle_t handle);" << be_uidt; + + os_ << be_nl_2 + << "DDS::InstanceHandle_t lookup_instance (" + << be_idt_nl + << "in " << lname << " instance_data);" << be_uidt; + + os_ << be_uidt_nl + << "};"; +} + +int +be_visitor_dds_ts_idl::init_file (be_decl *node) +{ + /// Open a uniquely-named IDL file for writing. + ACE_CString fname_noext (node->flat_name ()); + fname_noext += "TypeSupport"; + + ACE_CString fname (fname_noext); + fname += ".idl"; + + ACE_NEW_RETURN (this->os_ptr_, + TAO_OutStream, + -1); + + int status = this->os_ptr_->open (fname.c_str ()); + + if (status == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("be_visitor_root_ts_idl::init - ") + ACE_TEXT ("Error opening DDS type support ") + ACE_TEXT ("IDL file\n")), + -1); + } + + this->os_ptr_->gen_ifdef_macro (fname_noext.c_str (), + "IDL", + false); + + *this->os_ptr_ << be_nl_2 + << "#include <dds_rtf2_dcps.idl>" << be_nl_2 + << "#include \"" + << idl_global->filename ()->get_string () + << "\""; + + return 0; +} + +void +be_visitor_dds_ts_idl::fini_file (void) +{ + *this->os_ptr_ << be_nl_2 + << "#endif /* ifndef */\n" + << "\n"; + + delete this->os_ptr_; + this->os_ptr_ = 0; +} diff --git a/TAO/TAO_IDL/be_include/be_global.h b/TAO/TAO_IDL/be_include/be_global.h index 613b99e9b63..e736f62bdf2 100644 --- a/TAO/TAO_IDL/be_include/be_global.h +++ b/TAO/TAO_IDL/be_include/be_global.h @@ -825,6 +825,9 @@ public: bool gen_ciao_conn_impl (void) const; void gen_ciao_conn_impl (bool val); + bool gen_dds_typesupport_idl (void) const; + void gen_dds_typesupport_idl (bool val); + bool gen_ciao_valuefactory_reg (void) const; void gen_ciao_valuefactory_reg (bool val); @@ -1180,11 +1183,13 @@ private: bool gen_ciao_exec_impl_; bool gen_ciao_exec_reactor_impl_; - /// False by default, this flag triggers code generation /// for CCM connector implementations. bool gen_ciao_conn_impl_; + /// Used for DDS implementations other than OpenDDS. + bool gen_dds_typesupport_idl_; + /// Generate automatic valuetype factory registration in /// CIAO servants. bool gen_ciao_valuefactory_reg_; diff --git a/TAO/TAO_IDL/be_include/be_visitor_dds_ts_idl.h b/TAO/TAO_IDL/be_include/be_visitor_dds_ts_idl.h new file mode 100644 index 00000000000..16f84456c67 --- /dev/null +++ b/TAO/TAO_IDL/be_include/be_visitor_dds_ts_idl.h @@ -0,0 +1,59 @@ +/* -*- c++ -*- */ + +//============================================================================= +/** + * @file be_visitor_dds_ts_idl.h + * + * $Id$ + * + * Concrete visitor. + * This one provides code generation for + * DDS type support IDL files. + * + * + * @author Jeff Parsons + */ +//============================================================================= + +#ifndef _BE_VISITOR_DDS_TS_IDL_H_ +#define _BE_VISITOR_DDS_TS_IDL_H_ + +#include "be_visitor_scope.h" + +/** + * @class be_visitor_dds_ts_idl + * + * @brief be_visitor_dds_ts_idl + * + * This is a concrete visitor to generate the DDS type support IDL + */ +class be_visitor_dds_ts_idl : public be_visitor_scope +{ +public: + be_visitor_dds_ts_idl (be_visitor_context *ctx); + + ~be_visitor_dds_ts_idl (void); + + virtual int visit_root (be_root *node); + virtual int visit_module (be_module *node); + + /// The only types recognized so far as DDS datatypes. + virtual int visit_structure (be_structure *node); + virtual int visit_union (be_union *node); + virtual int visit_valuetype (be_valuetype *node); + +/// Common code for processing all datatypes. +private: + int process_node (be_type *node); + void gen_datawriter (be_type *node); + void gen_datareader (be_type *node); + + /// Manage streams and files. + int init_file (be_decl *node); + void fini_file (void); + +private: + TAO_OutStream *os_ptr_; +}; + +#endif /* _BE_VISITOR_DDS_TS_IDL_H_ */ diff --git a/TAO/docs/compiler.html b/TAO/docs/compiler.html index 553825e60a3..2add0d21c33 100644 --- a/TAO/docs/compiler.html +++ b/TAO/docs/compiler.html @@ -1024,6 +1024,13 @@ also receives other options that are specific to it.<p> for DDS connectors.</td> </tr> + <tr><a name="Gts"> + <td><tt>-Gts</tt></td> + + <td>Generate DDS type support IDL in a separate IDL file</td> + <td>Not used with OpenDDS, since OpenDDS's IDL processor does this already.</td> + </tr> + <tr><a name="Glem"> <td><tt>-Glem</tt></td> |