2 //=============================================================================
4 * @file be_structure.cpp
6 * Extension of class AST_Structure that provides additional means for C++
9 * @author Copyright 1994-1995 by Sun Microsystems
10 * @author Inc. and Aniruddha Gokhale
12 //=============================================================================
14 #include "be_structure.h"
16 #include "be_codegen.h"
17 #include "be_helper.h"
18 #include "be_visitor.h"
19 #include "be_extern.h"
21 #include "utl_identifier.h"
22 #include "idl_defines.h"
23 #include "global_extern.h"
25 be_structure::be_structure (UTL_ScopedName
*n
,
30 AST_Decl (AST_Decl::NT_struct
,
32 AST_Type (AST_Decl::NT_struct
,
34 AST_ConcreteType (AST_Decl::NT_struct
,
36 UTL_Scope (AST_Decl::NT_struct
),
40 be_scope (AST_Decl::NT_struct
),
41 be_decl (AST_Decl::NT_struct
,
43 be_type (AST_Decl::NT_struct
,
46 if (!this->imported ())
48 idl_global
->aggregate_seen_
= true;
52 be_structure::be_structure (AST_Decl::NodeType nt
,
75 if (!this->imported ())
77 idl_global
->aggregate_seen_
= true;
82 be_structure::redefine (AST_Structure
*from
)
84 be_structure
*bs
= dynamic_cast<be_structure
*> (from
);
85 this->common_varout_gen_
= bs
->common_varout_gen_
;
86 this->AST_Structure::redefine (from
);
91 be_structure::gen_ostream_operator (TAO_OutStream
*os
,
92 bool /* use_underscore */)
95 << "std::ostream& operator<< (" << be_idt
<< be_idt_nl
96 << "std::ostream &strm," << be_nl
97 << "const " << this->name () << " &";
99 long n
= this->pd_decls_used
;
101 // be_exception is a subclass and could be empty.
104 *os
<< "_tao_aggregate";
110 << "strm << \"" << this->name () << "(\"";
112 for (long i
= 0; i
< n
; ++i
)
114 be_field
*f
= dynamic_cast<be_field
*> (this->pd_decls
[i
]);
116 // We don't want any decls, just members.
130 ACE_CString
instance_name ("_tao_aggregate.");
131 instance_name
+= f
->local_name ()->get_string ();
132 AST_Decl::NodeType nt
= f
->field_type ()->node_type ();
133 bool member_use_underscore
=
134 nt
== AST_Decl::NT_array
|| nt
== AST_Decl::NT_sequence
;
135 f
->gen_member_ostream_operator (os
,
136 instance_name
.c_str (),
137 member_use_underscore
,
142 << " << \")\";" << be_nl_2
143 << "return strm;" << be_uidt_nl
148 be_structure::destroy (void)
150 // Call the destroy methods of our base classes.
151 this->be_scope::destroy ();
152 this->be_type::destroy ();
153 this->AST_Structure::destroy ();
157 be_structure::accept (be_visitor
*visitor
)
159 return visitor
->visit_structure (this);
162 IMPL_NARROW_FROM_DECL (be_structure
)
163 IMPL_NARROW_FROM_SCOPE (be_structure
)