diff options
author | gokhale <gokhale@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-03-10 23:03:00 +0000 |
---|---|---|
committer | gokhale <gokhale@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-03-10 23:03:00 +0000 |
commit | 32360c6e89f2217cb572673c127baaa1ba8baa0a (patch) | |
tree | d4bab30beb9170069ea90668d2736b6897bfb044 /TAO/TAO_IDL/be/be_visitor_constant.cpp | |
parent | b1365894b34b0b321a08a524189302068fbd3cce (diff) | |
download | ATCD-32360c6e89f2217cb572673c127baaa1ba8baa0a.tar.gz |
*** empty log message ***
Diffstat (limited to 'TAO/TAO_IDL/be/be_visitor_constant.cpp')
-rw-r--r-- | TAO/TAO_IDL/be/be_visitor_constant.cpp | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/TAO/TAO_IDL/be/be_visitor_constant.cpp b/TAO/TAO_IDL/be/be_visitor_constant.cpp new file mode 100644 index 00000000000..f2b2d722164 --- /dev/null +++ b/TAO/TAO_IDL/be/be_visitor_constant.cpp @@ -0,0 +1,100 @@ +// +// $Id$ +// + +// ============================================================================ +// +// = LIBRARY +// TAO IDL +// +// = FILENAME +// be_visitor_constant.cpp +// +// = DESCRIPTION +// Visitors for generation of code for Constant +// +// = AUTHOR +// Aniruddha Gokhale +// +// ============================================================================ + +#include "idl.h" +#include "idl_extern.h" +#include "be.h" + +#include "be_visitor_constant.h" + +// ******************************************************************** +// Visitor implementation for the Constant type +// This one for the client header file +// ******************************************************************** + +be_visitor_constant_ch::be_visitor_constant_ch (be_visitor_context *ctx) + : be_visitor_decl (ctx) +{ +} + +be_visitor_constant_ch::~be_visitor_constant_ch (void) +{ +} + +// visit the Constant_Ch node and its scope +int +be_visitor_constant_ch::visit_constant (be_constant *node) +{ + TAO_OutStream *os = this->ctx_->stream (); + + if (!node->cli_hdr_gen ()) + { + // if we are defined in the outermost scope, then the value is assigned + // to us here itself, else it will be in the *.cpp file + + os->indent (); // start from whatever indentation level we were at + *os << "static const " << node->exprtype_to_string () + << " " << node->local_name (); + if (!node->is_nested ()) + { + // We were defined at the outermost scope. So we put the value in the + // header itself + *os << " = " << node->constant_value (); + } + *os << ";\n\n"; + node->cli_hdr_gen (I_TRUE); + } + return 0; +} + +// ******************************************************************** +// Visitor implementation for the Constant type +// This one for the client stubs file +// ******************************************************************** + +be_visitor_constant_cs::be_visitor_constant_cs (be_visitor_context *ctx) + : be_visitor_decl (ctx) +{ +} + +be_visitor_constant_cs::~be_visitor_constant_cs (void) +{ +} + +// visit the Constant_cs node and its scope +int +be_visitor_constant_cs::visit_constant (be_constant *node) +{ + TAO_OutStream *os = this->ctx_->stream (); + + if (!node->cli_hdr_gen ()) + { + if (node->is_nested ()) + { + // for those constants not defined in the outer most scope, they get + // assigned to their values in the impl file + os->indent (); // start from whatever indentation level we were at + *os << "const " << node->exprtype_to_string () << " " << node->name () + << " = " << node->constant_value () << ";\n\n"; + } + node->cli_stub_gen (I_TRUE); + } + return 0; +} |