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 () << " (void);" << 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
;
97 *os
<< "// Destructor" << be_nl
98 << "virtual " << "~" << be_global
->impl_class_prefix () << namebuf
99 << be_global
->impl_class_suffix () << " (void);";
102 // Generate code for elements in the scope (e.g., operations).
103 if (this->visit_scope (node
) == -1)
105 ACE_ERROR_RETURN ((LM_ERROR
,
106 "be_visitor_interface_ih::"
108 "codegen for scope failed\n"),
113 // Generate the code for the members of the derived classes.
115 node
->traverse_inheritance_graph (
116 be_visitor_interface_ih::method_helper
,
121 ACE_ERROR_RETURN ((LM_ERROR
,
122 "be_visitor_interface_tie_sh_ss::"
124 "traversal of inhertance graph failed\n"),
136 // Helper method to generate members within the scope of the base classes.
138 be_visitor_interface_ih::method_helper (be_interface
*derived
,
143 ACE_OS::strcmp (derived
->flat_name (), node
->flat_name ());
147 be_visitor_context ctx
;
148 ctx
.state (TAO_CodeGen::TAO_ROOT_IH
);
149 ctx
.interface (derived
);
151 be_visitor_interface_ih
visitor (&ctx
);
153 if (visitor
.visit_scope (node
) == -1)
155 ACE_ERROR_RETURN ((LM_ERROR
,
156 "be_visitor_interface_is::"