Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / TAO_IDL / be / be_visitor_enum / enum_ch.cpp
blob7708d5e3d5ade97b0889606c4bc7d747537d1046
2 //=============================================================================
3 /**
4 * @file enum_ch.cpp
6 * Visitor generating code for Enums in the client header
8 * @author Aniruddha Gokhale
9 */
10 //=============================================================================
12 #include "enum.h"
13 #include "be_visitor_typecode/typecode_decl.h"
15 // ********************************************************************
16 // Visitor implementation for the Enum type
17 // This one for the client header file
18 // ********************************************************************
20 be_visitor_enum_ch::be_visitor_enum_ch (be_visitor_context *ctx)
21 : be_visitor_scope (ctx)
25 // Visit the enum_ch node and its scope.
26 int
27 be_visitor_enum_ch::visit_enum (be_enum *node)
29 if (node->cli_hdr_gen () || node->imported ())
31 return 0;
34 TAO_OutStream *os = this->ctx_->stream ();
36 // Comma to be generated by the scope visitor.
37 this->ctx_->comma (true);
39 TAO_INSERT_COMMENT (os);
41 *os << "enum " << node->local_name () << be_nl;
42 *os << "{" << be_idt_nl;
44 if (this->visit_scope (node) == 1)
46 ACE_ERROR_RETURN ((LM_ERROR,
47 ACE_TEXT ("be_visitor_enum_ch::")
48 ACE_TEXT ("visit_enum - ")
49 ACE_TEXT ("scope generation failed\n")),
50 -1);
53 *os << be_uidt_nl;
54 *os << "};" << be_nl_2;
56 // As per the ORBOS spec, we need the following typedef
57 *os << "typedef " << node->local_name () << " &" << node->local_name ()
58 << "_out;";
60 if (be_global->tc_support ())
62 be_visitor_context ctx (*this->ctx_);
63 be_visitor_typecode_decl visitor (&ctx);
65 if (node->accept (&visitor) == -1)
67 ACE_ERROR_RETURN ((LM_ERROR,
68 ACE_TEXT ("be_visitor_enum_ch::")
69 ACE_TEXT ("visit_enum - ")
70 ACE_TEXT ("TypeCode declaration failed\n" )),
71 -1);
75 node->cli_hdr_gen (true);
76 return 0;
79 int
80 be_visitor_enum_ch::post_process (be_decl *bd)
82 TAO_OutStream *os = this->ctx_->stream ();
84 // Am I the last one?
85 if (!this->last_node (bd))
87 *os << "," << be_nl;
90 return 0;
93 int
94 be_visitor_enum_ch::visit_enum_val (be_enum_val *node)
96 TAO_OutStream *os = this->ctx_->stream ();
98 *os << node->local_name ();
100 return 0;