2 //=============================================================================
4 * @file interface_ih.cpp
6 * Visitor generating code for Interfaces in the implementation header
8 * @author Yamuna Krishnamurthy (yamuna@cs.wustl.edu)
10 //=============================================================================
12 #include "interface.h"
14 be_visitor_interface_ih::be_visitor_interface_ih (be_visitor_context
*ctx
)
15 : be_visitor_interface (ctx
)
19 be_visitor_interface_ih::~be_visitor_interface_ih ()
24 be_visitor_interface_ih::visit_interface (be_interface
*node
)
26 if (node
->impl_hdr_gen () || node
->imported () || node
->is_abstract ())
31 TAO_OutStream
*os
= this->ctx_
->stream ();
32 static char namebuf
[NAMEBUFSIZE
];
35 ACE_OS::memset (namebuf
,
39 // Generate the skeleton class name.
41 ACE_OS::sprintf (namebuf
, "%s", node
->flat_name ());
43 if (be_global
->gen_impl_debug_info ())
45 TAO_INSERT_COMMENT (os
);
48 // Now generate the class definition.
49 *os
<< "class " << be_global
->stub_export_macro ()
50 << " " << be_global
->impl_class_prefix () << namebuf
51 << be_global
->impl_class_suffix () << be_idt_nl
<< ": public virtual ";
53 // Inherit from the base skeleton name, unless the interface
55 if (node
->is_local ())
57 *os
<< node
->full_name ();
61 *os
<< node
->full_skel_name ();
64 if (node
->is_local ())
66 *os
<< "," << be_idt_nl
67 << "public virtual ::CORBA::LocalObject"
73 << "public:" << be_idt_nl
74 << "// Constructor" << be_nl
75 << be_global
->impl_class_prefix () << namebuf
76 << be_global
->impl_class_suffix () << " ();" << be_nl_2
;
78 if (be_global
->gen_copy_ctor () && !node
->is_local ())
80 *os
<< "// Copy Constructor"<<be_nl
81 << be_global
->impl_class_prefix () << namebuf
82 << be_global
->impl_class_suffix () << " (const "
83 << be_global
->impl_class_prefix () << namebuf
84 << be_global
->impl_class_suffix () << "&);" <<be_nl
<<be_nl
;
87 if (be_global
->gen_assign_op ())
89 *os
<< "// Copy Assignment" << be_nl
90 << be_global
->impl_class_prefix () << namebuf
91 << be_global
->impl_class_suffix () << "& " << "operator=(const "
92 << be_global
->impl_class_prefix () << namebuf
93 << be_global
->impl_class_suffix () << "&);" << be_nl_2
;
96 *os
<< "// Destructor" << be_nl
97 << "virtual " << "~" << be_global
->impl_class_prefix () << namebuf
98 << be_global
->impl_class_suffix () << " ();";
101 // Generate code for elements in the scope (e.g., operations).
102 if (this->visit_scope (node
) == -1)
104 ACE_ERROR_RETURN ((LM_ERROR
,
105 "be_visitor_interface_ih::"
107 "codegen for scope failed\n"),
112 // Generate the code for the members of the derived classes.
114 node
->traverse_inheritance_graph (
115 be_visitor_interface_ih::method_helper
,
120 ACE_ERROR_RETURN ((LM_ERROR
,
121 "be_visitor_interface_tie_sh_ss::"
123 "traversal of inhertance graph failed\n"),
135 // Helper method to generate members within the scope of the base classes.
137 be_visitor_interface_ih::method_helper (be_interface
*derived
,
142 ACE_OS::strcmp (derived
->flat_name (), node
->flat_name ());
146 be_visitor_context ctx
;
147 ctx
.state (TAO_CodeGen::TAO_ROOT_IH
);
148 ctx
.interface (derived
);
150 be_visitor_interface_ih
visitor (&ctx
);
152 if (visitor
.visit_scope (node
) == -1)
154 ACE_ERROR_RETURN ((LM_ERROR
,
155 "be_visitor_interface_is::"