Remove redundant void from tao_idl
[ACE_TAO.git] / TAO / TAO_IDL / be / be_visitor_exception / exception_ch.cpp
blobba44fc159c21a0bba110ec0fedd97f0397f86320
2 //=============================================================================
3 /**
4 * @file exception_ch.cpp
6 * Visitor generating code for Exception in the client header
8 * @author Aniruddha Gokhale
9 */
10 //=============================================================================
12 #include "exception.h"
13 #include "be_visitor_typecode/typecode_decl.h"
14 #include "global_extern.h"
15 #include "utl_err.h"
17 // ******************************************************
18 // For client header.
19 // ******************************************************
21 be_visitor_exception_ch::be_visitor_exception_ch (be_visitor_context *ctx)
22 : be_visitor_exception (ctx)
26 be_visitor_exception_ch::~be_visitor_exception_ch ()
30 // Visit the Exception node and its scope.
31 int be_visitor_exception_ch::visit_exception (be_exception *node)
33 if (node->cli_hdr_gen () || node->imported ())
35 return 0;
38 TAO_OutStream *os = this->ctx_->stream ();
40 TAO_INSERT_COMMENT (os);
42 *os << be_nl_2 << "class " << be_global->stub_export_macro ()
43 << " " << node->local_name ()
44 << " : public ::CORBA::UserException" << be_nl;
45 *os << "{" << be_nl
46 << "public:" << be_idt;
48 // Generate code for field members.
49 if (this->visit_scope (node) == -1)
51 ACE_ERROR_RETURN ((LM_ERROR,
52 ACE_TEXT ("be_visitor_exception_ch::")
53 ACE_TEXT ("visit_exception - ")
54 ACE_TEXT ("codegen for scope failed\n")),
55 -1);
58 // Constructors and destructor.
59 *os << be_nl_2
60 << node->local_name () << " (void);" << be_nl
61 << node->local_name () << " (const " << node->local_name ()
62 << " &);" << be_nl
63 << "~" << node->local_name () << " (void);\n" << be_nl;
65 // Assignment operator.
66 *os << node->local_name () << " &operator= (const "
67 << node->local_name () << " &);" << be_nl_2;
69 if (be_global->any_support ())
71 *os << "static void _tao_any_destructor (void *);" << be_nl_2;
74 *os << "static " << node->local_name ()
75 << " *_downcast ( ::CORBA::Exception *);" << be_nl
76 << "static const " << node->local_name ()
77 << " *_downcast ( ::CORBA::Exception const *);" << be_nl_2;
79 *os << "static ::CORBA::Exception *_alloc (void);" << be_nl_2;
81 *os << "virtual ::CORBA::Exception *"
82 << "_tao_duplicate (void) const;\n" << be_nl
83 << "virtual void _raise (void) const;\n" << be_nl
84 << "virtual void _tao_encode (TAO_OutputCDR &cdr) const;" << be_nl
85 << "virtual void _tao_decode (TAO_InputCDR &cdr);";
87 // Generate constructor that takes each member as a parameter. We need a
88 // new state. Such a constructor exists if we have members.
89 if (node->member_count () > 0)
91 be_visitor_context ctx (*this->ctx_);
92 ctx.state (TAO_CodeGen::TAO_EXCEPTION_CTOR_CH);
93 be_visitor_exception_ctor visitor (&ctx);
95 if (node->accept (&visitor) == -1)
97 ACE_ERROR_RETURN ((LM_ERROR,
98 ACE_TEXT ("be_visitor_exception::")
99 ACE_TEXT ("visit_exception - ")
100 ACE_TEXT ("codegen for ctor failed\n")),
101 -1);
105 if (be_global->tc_support ())
107 *os << be_nl_2
108 << "virtual ::CORBA::TypeCode_ptr _tao_type (void) const;";
111 *os << be_uidt_nl << "};";
113 if (be_global->tc_support ())
115 be_visitor_context ctx (*this->ctx_);
116 be_visitor_typecode_decl visitor (&ctx);
118 if (node->accept (&visitor) == -1)
120 ACE_ERROR_RETURN ((LM_ERROR,
121 ACE_TEXT ("be_visitor_exception_ch::")
122 ACE_TEXT ("visit_exception - ")
123 ACE_TEXT ("TypeCode declaration failed\n")),
124 -1);
128 node->cli_hdr_gen (1);
129 return 0;