Changes to attempt to silence bcc64x
[ACE_TAO.git] / TAO / TAO_IDL / be / be_visitor_constant / constant_cs.cpp
blob3be50d11c83065762a408a35953e1ed8ed91e9f5
2 //=============================================================================
3 /**
4 * @file constant_cs.cpp
6 * Visitor for code generation of Constant code in the client stubs file.
8 * @author Aniruddha Gokhale
9 */
10 //=============================================================================
12 #include "constant.h"
14 be_visitor_constant_cs::be_visitor_constant_cs (be_visitor_context *ctx)
15 : be_visitor_decl (ctx)
19 be_visitor_constant_cs::~be_visitor_constant_cs ()
23 // visit the Constant_cs node and its scope
24 int
25 be_visitor_constant_cs::visit_constant (be_constant *node)
27 if (node->cli_stub_gen ()
28 || node->imported ()
29 || !node->is_nested ())
31 return 0;
34 AST_Decl::NodeType snt = node->defined_in ()->scope_node_type ();
35 bool in_class = (snt != AST_Decl::NT_root
36 && snt != AST_Decl::NT_module);
37 if (be_global->gen_inline_constants () && !in_class)
39 // No storage is required in the source file for these
40 return 0;
43 AST_Expression::ExprType etype = node->et ();
44 bool const forbidden_in_class = (in_class
45 && (etype == AST_Expression::EV_string
46 || etype == AST_Expression::EV_wstring
47 || etype == AST_Expression::EV_float
48 || etype == AST_Expression::EV_double
49 || etype == AST_Expression::EV_longdouble));
51 TAO_OutStream *os = this->ctx_->stream ();
53 TAO_INSERT_COMMENT (os);
55 *os << be_nl_2;
56 *os << "const ";
58 if (node->et () == AST_Expression::EV_enum)
60 *os << node->enum_full_name ();
62 else
64 *os << exprtype_to_cpp_corba_type (node->et ());
67 *os << " " << node->name ();
68 if (!be_global->gen_inline_constants () || forbidden_in_class)
70 // For those constants not defined in the outermost scope,
71 // or in a module, they get assigned to their values in the source file.
72 *os << " = " << node->constant_value ();
74 *os << ";";
76 node->cli_stub_gen (true);
77 return 0;