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_exh.cpp
blob8ba4b0082f3209088f02995ddcf0f009ca09187a
2 //=============================================================================
3 /**
4 * @file facet_exh.cpp
6 * Visitor generating code for facets in the exec impl header.
8 * @author Jeff Parsons
9 */
10 //=============================================================================
12 #include "component.h"
14 be_visitor_facet_exh::be_visitor_facet_exh (
15 be_visitor_context *ctx)
16 : be_visitor_component_scope (ctx)
17 // comment_start_border_ ("/**"),
18 // comment_end_border_ (" */")
20 // This is initialized in the base class to svnt_export_macro()
21 // or skel_export_macro(), since there are many more visitor
22 // classes generating servant code. So we can just override
23 // all that here.
24 export_macro_ = be_global->exec_export_macro ();
27 be_visitor_facet_exh::~be_visitor_facet_exh ()
31 int
32 be_visitor_facet_exh::visit_provides (be_provides *node)
34 be_type *impl = node->provides_type ();
35 const char *iname =
36 impl->original_local_name ()->get_string ();
38 ACE_CString lname_str (this->ctx_->port_prefix ());
39 lname_str += node->original_local_name ()->get_string ();
40 const char *lname = lname_str.c_str ();
42 AST_Decl *s = ScopeAsDecl (impl->defined_in ());
43 ACE_CString sname_str =
44 IdentifierHelper::orig_sn (s->name (), false);
45 const char *sname = sname_str.c_str ();
46 const char *global = (sname_str == "" ? "" : "::");
48 AST_Decl *c_scope = ScopeAsDecl (this->node_->defined_in ());
49 bool is_global = (c_scope->node_type () == AST_Decl::NT_root);
50 const char *smart_scope = (is_global ? "" : "::");
52 os_ << be_nl_2
53 << "/// Executor implementation class for "
54 << lname << " facet";
56 os_ << be_nl
57 << "class "
58 << lname << "_exec_i" << be_idt_nl
59 << ": public virtual " << global << sname << "::CCM_"
60 << iname << "," << be_idt_nl
61 << "public virtual ::CORBA::LocalObject"
62 << be_uidt << be_uidt_nl
63 << "{" << be_nl
64 << "public:" << be_idt_nl
65 << "/// Constructor" << be_nl
66 << "/// @param[in] ctx - Container context" << be_nl
67 << lname << "_exec_i (" << be_idt_nl
68 << smart_scope << c_scope->full_name () << "::CCM_"
69 << this->node_->local_name ()
70 << "_Context_ptr ctx);" << be_uidt_nl
71 << "/// Destructor" << be_nl
72 << "virtual ~" << lname << "_exec_i ();";
74 if (impl->node_type () == AST_Decl::NT_interface)
76 be_interface *intf =
77 dynamic_cast<be_interface*> (impl);
79 os_ << be_nl_2
80 << "/** @name Operations and attributes from "
81 << intf->full_name () << " */" << be_nl
82 << "//@{";
84 int const status =
85 intf->traverse_inheritance_graph (
86 be_visitor_facet_exh::method_helper,
87 &os_);
89 if (status == -1)
91 ACE_ERROR_RETURN ((LM_ERROR,
92 ACE_TEXT ("be_visitor_facet_exh::")
93 ACE_TEXT ("visit_provides - ")
94 ACE_TEXT ("traverse_inheritance_graph() ")
95 ACE_TEXT ("failed\n")),
96 -1);
99 os_ << be_nl << "//@}";
102 os_ << be_uidt << be_nl_2
103 << "private:" << be_idt_nl
104 << "/// Context for component instance. Used for all middleware communication." << be_nl
105 << smart_scope << c_scope->full_name () << "::CCM_"
106 << this->node_->local_name ()
107 << "_Context_var ciao_context_;" << be_uidt_nl
108 << "};";
110 return 0;
114 be_visitor_facet_exh::method_helper (be_interface *derived,
115 be_interface *node,
116 TAO_OutStream *os)
118 be_visitor_context ctx;
119 ctx.state (TAO_CodeGen::TAO_ROOT_IH);
120 ctx.interface (derived);
121 ctx.stream (os);
122 be_visitor_interface_ih visitor (&ctx);
124 if (visitor.visit_scope (node) == -1)
126 ACE_ERROR_RETURN ((LM_ERROR,
127 "be_visitor_facet_exh::method_helper "
128 "- visit_scope() failed\n"),
129 -1);
132 return 0;