1 //=============================================================================
3 * @file be_visitor_template_export.cpp
5 * This visitor generates template instantiations with export macro
7 * @author Jeff Parsons <j.parsons@vanderbilt.edu>
9 //=============================================================================
11 #include "be_visitor_template_export.h"
12 #include "be_visitor_context.h"
14 #include "be_module.h"
15 #include "be_typedef.h"
16 #include "be_sequence.h"
17 #include "be_extern.h"
18 #include "be_helper.h"
19 #include "be_predefined_type.h"
20 #include "ace/Log_Msg.h"
22 be_visitor_template_export::be_visitor_template_export (
23 be_visitor_context
*ctx
)
24 : be_visitor_scope (ctx
)
28 be_visitor_template_export::~be_visitor_template_export ()
33 be_visitor_template_export::visit_root (be_root
*node
)
35 TAO_OutStream
*os
= this->ctx_
->stream ();
37 TAO_INSERT_COMMENT (os
);
39 *os
<< "#if defined ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION_EXPORT";
41 if (this->visit_scope (node
) == -1)
43 ACE_ERROR_RETURN ((LM_ERROR
,
44 "be_visitor_template_export::"
45 "visit_root - visit scope failed\n"),
49 *os
<< be_nl
<< "#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION_EXPORT */";
55 be_visitor_template_export::visit_module (be_module
*node
)
57 if (this->visit_scope (node
) == -1)
59 ACE_ERROR_RETURN ((LM_ERROR
,
60 "be_visitor_template_export::"
61 "visit_module - visit scope failed\n"),
69 be_visitor_template_export::visit_sequence (be_sequence
*node
)
71 TAO_OutStream
*os
= this->ctx_
->stream ();
73 be_type
*bt
= dynamic_cast<be_type
*> (node
->base_type ());
75 // TAO provides extensions for octet sequences, first find out if
76 // the base type is an octet (or an alias for octet).
77 be_predefined_type
*predef
= nullptr;
79 if (bt
->base_node_type () == AST_Type::NT_pre_defined
)
82 dynamic_cast<be_typedef
*> (bt
);
86 predef
= dynamic_cast<be_predefined_type
*> (bt
);
91 dynamic_cast<be_predefined_type
*> (
92 alias
->primitive_base_type ()
97 // When it is a sequence add a special guard
98 if (predef
!= nullptr && predef
->pt () == AST_PredefinedType::PT_octet
99 && node
->unbounded ())
101 *os
<< "\n#if (TAO_NO_COPY_OCTET_SEQUENCES == 0)";
104 *os
<< be_idt
<< be_nl
105 << "template class " << be_global
->stub_export_macro ()
108 if (node
->gen_base_class_name (os
,
110 this->ctx_
->scope ()->decl ()) == -1)
112 ACE_ERROR_RETURN ((LM_ERROR
,
113 "(%N:%l) be_visitor_template_export::"
115 "Base class name generation failed\n"),
119 *os
<< ";" << be_uidt
;
121 if (predef
!= nullptr && predef
->pt () == AST_PredefinedType::PT_octet
122 && node
->unbounded ())
124 *os
<< "\n#endif /* TAO_NO_COPY_OCTET_SEQUENCE == 0 */";
131 be_visitor_template_export::visit_typedef (be_typedef
*node
)
133 this->ctx_
->alias (node
);
134 be_type
*bt
= node
->primitive_base_type ();
136 if (bt
->accept (this) == -1)
138 ACE_ERROR_RETURN ((LM_ERROR
,
139 "be_visitor_template_export::"
141 "visit base type failed\n"),
145 this->ctx_
->alias (nullptr);