Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / TAO_IDL / be / be_visitor_component / facet_exs.cpp
blob1c401ba88db57bbfb7e118e0ba377ebf90344398
2 //=============================================================================
3 /**
4 * @file facet_exs.cpp
6 * Visitor generating code for facets in the exec impl source.
8 * @author Jeff Parsons
9 */
10 //=============================================================================
12 #include "component.h"
14 be_visitor_facet_exs::be_visitor_facet_exs (
15 be_visitor_context *ctx)
16 : be_visitor_component_scope (ctx),
17 op_scope_ (nullptr),
18 comment_start_border_ ("/**"),
19 comment_end_border_ (" */")
23 be_visitor_facet_exs::~be_visitor_facet_exs ()
27 int
28 be_visitor_facet_exs::visit_operation (be_operation *node)
30 AST_Decl::NodeType nt =
31 ScopeAsDecl (node->defined_in ())->node_type ();
33 // Components have implied IDL operations added to the AST, but
34 // we are interested only in supported interface operations.
35 if (nt == AST_Decl::NT_component || nt == AST_Decl::NT_connector)
37 return 0;
40 be_visitor_operation_exs v (this->ctx_);
41 v.scope (this->op_scope_);
42 return v.visit_operation (node);
45 int
46 be_visitor_facet_exs::visit_attribute (be_attribute *node)
48 AST_Decl::NodeType nt = this->node_->node_type ();
50 // Executor attribute code generated for porttype attributes
51 // always in connectors and only for mirrorports in components.
52 if (this->in_ext_port_ && nt == AST_Decl::NT_component)
54 return 0;
57 be_decl *attr_scope =
58 dynamic_cast<be_decl*> (ScopeAsDecl (node->defined_in ()));
60 nt = attr_scope->node_type ();
62 // Components have implied IDL operations added to the AST, but
63 // we are interested only in supported interface operations.
64 if (nt == AST_Decl::NT_component || nt == AST_Decl::NT_connector)
66 return 0;
69 be_visitor_attribute v (this->ctx_);
70 v.op_scope (this->op_scope_);
71 return v.visit_attribute (node);
74 int
75 be_visitor_facet_exs::visit_provides (be_provides *node)
77 be_type *impl = node->provides_type ();
79 ACE_CString lname_str (this->ctx_->port_prefix ());
80 lname_str += node->original_local_name ()->get_string ();
81 const char *lname = lname_str.c_str ();
83 os_ << be_nl_2
84 << comment_start_border_ << be_nl
85 << " * Facet Executor Implementation Class: "
86 << lname << "_exec_i" << be_nl
87 << comment_end_border_;
89 AST_Decl *c_scope = ScopeAsDecl (this->node_->defined_in ());
90 bool is_global = (c_scope->node_type () == AST_Decl::NT_root);
91 const char *smart_scope = (is_global ? "" : "::");
93 os_ << be_nl_2
94 << lname << "_exec_i::" << lname
95 << "_exec_i (" << be_idt << be_idt << be_idt_nl
96 << smart_scope << c_scope->full_name () << "::CCM_"
97 << this->node_->local_name () << "_Context_ptr ctx)"
98 << be_uidt << be_uidt_nl
99 << ": ciao_context_ (" << be_idt << be_idt_nl
100 << smart_scope << c_scope->full_name ()
101 << "::CCM_" << this->node_->local_name ()
102 << "_Context::_duplicate (ctx))"
103 << be_uidt << be_uidt << be_uidt_nl
104 << "{" << be_nl
105 << "}";
107 os_ << be_nl_2
108 << lname << "_exec_i::~" << lname
109 << "_exec_i ()" << be_nl
110 << "{" << be_nl
111 << "}";
113 this->op_scope_ = node;
115 if (impl->node_type () == AST_Decl::NT_interface)
117 be_interface *intf =
118 dynamic_cast<be_interface*> (impl);
120 os_ << be_nl_2
121 << "// Operations from ::" << intf->full_name ();
123 /// The overload of traverse_inheritance_graph() used here
124 /// doesn't automatically prime the queues.
125 intf->get_insert_queue ().reset ();
126 intf->get_del_queue ().reset ();
127 intf->get_insert_queue ().enqueue_tail (intf);
129 Component_Exec_Op_Attr_Generator op_attr_gen (this);
131 int status =
132 intf->traverse_inheritance_graph (op_attr_gen,
133 &os_,
134 false,
135 false);
137 if (status == -1)
139 ACE_ERROR_RETURN ((LM_ERROR,
140 ACE_TEXT ("be_visitor_facet_exs::")
141 ACE_TEXT ("visit_provides - ")
142 ACE_TEXT ("traverse_inheritance_graph() ")
143 ACE_TEXT ("failed\n")),
144 -1);
148 return 0;