diff options
author | parsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2010-04-14 19:18:22 +0000 |
---|---|---|
committer | parsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2010-04-14 19:18:22 +0000 |
commit | 675eba7a48fff1620883d19dcb965c205d9088f4 (patch) | |
tree | e5215a5c8209d7626999e9f0fee85f4c9a41eabd /CIAO/tools | |
parent | c5eb9b8990af5ab3e08d44152ec951e106a48dbf (diff) | |
download | ATCD-675eba7a48fff1620883d19dcb965c205d9088f4.tar.gz |
ChangeLogTag: Wed Apr 14 19:13:15 UTC 2010 Jeff Parsons <j.parsons@vanderbilt.edu>
Diffstat (limited to 'CIAO/tools')
-rw-r--r-- | CIAO/tools/IDL3_to_IDL2/basic_visitor.cpp | 4 | ||||
-rw-r--r-- | CIAO/tools/IDL3_to_IDL2/be_sunsoft.cpp | 14 | ||||
-rw-r--r-- | CIAO/tools/IDL3_to_IDL2/idl3_to_idl2_visitor.cpp | 179 | ||||
-rw-r--r-- | CIAO/tools/IDL3_to_IDL2/idl3_to_idl2_visitor.h | 9 |
4 files changed, 171 insertions, 35 deletions
diff --git a/CIAO/tools/IDL3_to_IDL2/basic_visitor.cpp b/CIAO/tools/IDL3_to_IDL2/basic_visitor.cpp index fddb464b442..c566965ebba 100644 --- a/CIAO/tools/IDL3_to_IDL2/basic_visitor.cpp +++ b/CIAO/tools/IDL3_to_IDL2/basic_visitor.cpp @@ -968,7 +968,7 @@ basic_visitor::gen_params (UTL_Scope *s, int arg_count) { if (arg_count > 0) { - *os << be_idt << be_idt; + *os << be_idt; for (UTL_ScopeActiveIterator si (s, UTL_Scope::IK_decls); !si.is_done ();) @@ -988,7 +988,7 @@ basic_visitor::gen_params (UTL_Scope *s, int arg_count) } } - *os << be_uidt_nl << be_uidt; + *os << be_uidt; } } diff --git a/CIAO/tools/IDL3_to_IDL2/be_sunsoft.cpp b/CIAO/tools/IDL3_to_IDL2/be_sunsoft.cpp index e924ccea47d..17821dba5cb 100644 --- a/CIAO/tools/IDL3_to_IDL2/be_sunsoft.cpp +++ b/CIAO/tools/IDL3_to_IDL2/be_sunsoft.cpp @@ -12,10 +12,6 @@ #include "ace/OS_NS_string.h" #include "ace/OS_NS_ctype.h" -ACE_RCSID (be, - be_sunsoft, - "$Id$") - TAO_SunSoft_OutStream::TAO_SunSoft_OutStream (void) : TAO_OutStream () { @@ -55,20 +51,16 @@ TAO_SunSoft_OutStream::print (AST_Expression *expr) case AST_Expression::EV_ulong: this->TAO_OutStream::print (ACE_UINT32_FORMAT_SPECIFIER_ASCII "%c", ev->u.ulval, 'U'); break; - // The ACE_LACKS_LONGLONG_T guards have been removed around - // the next 2 cases since the macros now used should work - // whether native 64-bit integers are defined or not. + /// The next 2 cases differ from the tao_idl backend - the + /// ACE_(U)INT64_LITERAL macros have been removed since + /// we are generating IDL rather than C++. case AST_Expression::EV_longlong: - this->TAO_OutStream::print ("ACE_INT64_LITERAL ("); this->TAO_OutStream::print (ACE_INT64_FORMAT_SPECIFIER_ASCII, ev->u.llval); - this->TAO_OutStream::print (")"); break; case AST_Expression::EV_ulonglong: - this->TAO_OutStream::print ("ACE_UINT64_LITERAL ("); this->TAO_OutStream::print (ACE_UINT64_FORMAT_SPECIFIER_ASCII, ev->u.ullval); - this->TAO_OutStream::print (")"); break; case AST_Expression::EV_float: this->TAO_OutStream::print ("%f%c", ev->u.fval, 'F'); diff --git a/CIAO/tools/IDL3_to_IDL2/idl3_to_idl2_visitor.cpp b/CIAO/tools/IDL3_to_IDL2/idl3_to_idl2_visitor.cpp index 5cafe1e1467..fc6d6d9f4e2 100644 --- a/CIAO/tools/IDL3_to_IDL2/idl3_to_idl2_visitor.cpp +++ b/CIAO/tools/IDL3_to_IDL2/idl3_to_idl2_visitor.cpp @@ -6,7 +6,9 @@ #include "be_sunsoft.h" #include "be_extern.h" -#include "ast_component.h" +#include "ast_connector.h" +#include "ast_porttype.h" +#include "ast_mirror_port.h" #include "ast_component_fwd.h" #include "ast_provides.h" #include "ast_uses.h" @@ -134,7 +136,7 @@ idl3_to_idl2_visitor::visit_component (AST_Component *node) { return 0; } - + *os << be_nl << be_nl << "interface " << IdentifierHelper::try_escape (node->original_local_name ()).c_str (); @@ -199,7 +201,8 @@ idl3_to_idl2_visitor::visit_provides (AST_Provides *node) IdentifierHelper::orig_sn (n); *os << be_nl << be_nl - << impl_name.c_str () << " provide_" << orig_id << " ();"; + << impl_name.c_str () << " provide_" + << this->port_prefix_.c_str () << orig_id << " ();"; orig_id->destroy (); delete orig_id; @@ -219,39 +222,48 @@ idl3_to_idl2_visitor::visit_uses (AST_Uses *node) UTL_ScopedName *n = node->uses_type ()->name (); ACE_CString impl_name = IdentifierHelper::orig_sn (n); + + ACE_CString port_name (this->port_prefix_); + port_name += orig_id->get_string (); if (node->is_multiple ()) { - *os << "struct " << orig_id << "Connection" << be_nl + *os << "struct " << port_name.c_str () + << "Connection" << be_nl << "{" << be_idt_nl << impl_name.c_str () << " objref;" << be_nl << "Components::Cookie ck;" << be_uidt_nl << "};" << be_nl << be_nl << "typedef sequence<" << orig_id << "Connection> " - << orig_id << "Connections;" + << port_name.c_str () << "Connections;" << be_nl << be_nl - << "Components::Cookie connect_" << orig_id << " (in " - << impl_name.c_str () << " connection)" << be_idt_nl + << "Components::Cookie connect_" << port_name.c_str () + << " (in " << impl_name.c_str () << " connection)" + << be_idt_nl << "raises (Components::ExceededConnectionLimit, " - << "Components::InvalidConnection);" << be_uidt_nl << be_nl - << impl_name.c_str () << " disconnect_" << orig_id - << " (in Components::Cookie ck)" << be_idt_nl + << "Components::InvalidConnection);" + << be_uidt_nl << be_nl + << impl_name.c_str () << " disconnect_" + << port_name.c_str () << " (in Components::Cookie ck)" + << be_idt_nl << "raises (Components::InvalidConnection);" << be_uidt_nl << be_nl - << orig_id << "Connections get_connections_" << orig_id - << " ();"; + << port_name.c_str () << "Connections get_connections_" + << port_name.c_str () << " ();"; } else { - *os << "void connect_" << orig_id << " (in " + *os << "void connect_" << port_name.c_str () << " (in " << impl_name.c_str () << " conxn)" << be_idt_nl << "raises (Components::AlreadyConnected, " - << "Components::InvalidConnection);" << be_uidt_nl << be_nl - << impl_name.c_str () << " disconnect_" << orig_id - << " ()" << be_idt_nl - << "raises (Components::NoConnection);" << be_uidt_nl << be_nl - << impl_name.c_str () << " get_connection_" << orig_id - << " ();"; + << "Components::InvalidConnection);" + << be_uidt_nl << be_nl + << impl_name.c_str () << " disconnect_" + << port_name.c_str () << " ()" << be_idt_nl + << "raises (Components::NoConnection);" + << be_uidt_nl << be_nl + << impl_name.c_str () << " get_connection_" + << port_name.c_str () << " ();"; } orig_id->destroy (); @@ -338,24 +350,80 @@ idl3_to_idl2_visitor::visit_consumes (AST_Consumes *node) } int -idl3_to_idl2_visitor::visit_extended_port (AST_Extended_Port *) +idl3_to_idl2_visitor::visit_porttype (AST_PortType *node) { + /// We want to visit these nodes only by navigating from an + /// extended port or a mirror port. return 0; } int -idl3_to_idl2_visitor::visit_mirror_port (AST_Mirror_Port *) +idl3_to_idl2_visitor::visit_extended_port (AST_Extended_Port *node) { + AST_Decl::NodeType nt = + ScopeAsDecl (node->defined_in ())->node_type (); + + /// Skip if we are defined inside a porttype. + /// Depends on nested ports not being allowed. + if (nt == AST_Decl::NT_component || nt == AST_Decl::NT_connector) + { + this->port_prefix_ = node->local_name ()->get_string (); + this->port_prefix_ += '_'; + } + + if (this->visit_porttype_scope (node->port_type ()) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("idl3_to_idl2_visitor") + ACE_TEXT ("::visit_extended_port - ") + ACE_TEXT ("visit porttype scope failed\n")), + -1); + } + + /// Reset port prefix string. + this->port_prefix_ = ""; return 0; } int -idl3_to_idl2_visitor::visit_connector (AST_Connector *) +idl3_to_idl2_visitor::visit_mirror_port (AST_Mirror_Port *node) { + AST_Decl::NodeType nt = + ScopeAsDecl (node->defined_in ())->node_type (); + + /// Skip if we are defined inside a porttype. + /// Depends on nested ports not being allowed. + if (nt == AST_Decl::NT_component || nt == AST_Decl::NT_connector) + { + this->port_prefix_ = node->local_name ()->get_string (); + this->port_prefix_ += '_'; + } + + int status = + this->visit_porttype_scope_mirror (node->port_type ()); + + if (status == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("idl3_to_idl2_visitor") + ACE_TEXT ("::visit_mirror_port - ") + ACE_TEXT ("visit_porttype_scope") + ACE_TEXT ("_mirror failed\n")), + -1); + } + + /// Reset port prefix string. + this->port_prefix_ = ""; return 0; } int +idl3_to_idl2_visitor::visit_connector (AST_Connector *node) +{ + return this->visit_component (node); +} + +int idl3_to_idl2_visitor::visit_param_holder (AST_Param_Holder *) { return 0; @@ -728,3 +796,70 @@ idl3_to_idl2_visitor::tranfer_scope_elements (AST_Home *src, } } } + +int +idl3_to_idl2_visitor::visit_porttype_scope (AST_PortType *node) +{ + return this->visit_scope (node); +} + +int +idl3_to_idl2_visitor::visit_porttype_scope_mirror ( + AST_PortType *node) +{ + for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls); + !si.is_done (); + si.next ()) + { + AST_Decl *d = si.item (); + + switch (d->node_type ()) + { + case AST_Decl::NT_provides: + { + AST_Provides *p = + AST_Provides::narrow_from_decl (d); + + AST_Uses mirror_node (p->name (), + p->provides_type (), + false); + + if (this->visit_uses (&mirror_node) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("idl3_to_idl2_visitor") + ACE_TEXT ("::visit_porttype_mirror - ") + ACE_TEXT ("visit_uses() failed\n")), + -1); + } + + mirror_node.destroy (); + break; + } + case AST_Decl::NT_uses: + { + AST_Uses *u = + AST_Uses::narrow_from_decl (d); + + AST_Provides mirror_node (u->name (), + u->uses_type ()); + + if (this->visit_provides (&mirror_node) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("idl3_to_idl2_visitor") + ACE_TEXT ("::visit_porttype_mirror - ") + ACE_TEXT ("visit_provides() failed\n")), + -1); + } + + mirror_node.destroy (); + break; + } + default: + return d->ast_accept (this); + } + } + + return 0; +}
\ No newline at end of file diff --git a/CIAO/tools/IDL3_to_IDL2/idl3_to_idl2_visitor.h b/CIAO/tools/IDL3_to_IDL2/idl3_to_idl2_visitor.h index 48ee65811db..0dace676f12 100644 --- a/CIAO/tools/IDL3_to_IDL2/idl3_to_idl2_visitor.h +++ b/CIAO/tools/IDL3_to_IDL2/idl3_to_idl2_visitor.h @@ -53,6 +53,7 @@ public: virtual int visit_publishes (AST_Publishes *node); virtual int visit_emits (AST_Emits *node); virtual int visit_consumes (AST_Consumes *node); + virtual int visit_porttype (AST_PortType *node); virtual int visit_extended_port (AST_Extended_Port *node); virtual int visit_mirror_port (AST_Mirror_Port *node); virtual int visit_connector (AST_Connector *node); @@ -69,10 +70,18 @@ private: const char *local_name, const char *suffix, AST_Decl *parent); + void tranfer_scope_elements (AST_Home *src, AST_Interface &dst); + /// We don't want to visit a porttype when its declaration is + /// encountered but rather by navigating to it from an + /// extended port or a mirror port. + int visit_porttype_scope (AST_PortType *node); + int visit_porttype_scope_mirror (AST_PortType *node); + private: AST_Home *home_; + ACE_CString port_prefix_; }; #endif /* TAO_IDL3_TO_IDL2_VISITOR_H */ |