1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
//
// $Id$
//
// ============================================================================
//
// = LIBRARY
// TAO IDL
//
// = FILENAME
// component_svh.cpp
//
// = DESCRIPTION
// Visitor generating code for Components in the servant header.
//
// = AUTHOR
// Jeff Parsons
//
// ============================================================================
// ******************************************************
// Component visitor for server header
// ******************************************************
be_visitor_component_svh::be_visitor_component_svh (be_visitor_context *ctx)
: be_visitor_component (ctx),
os_ (*ctx->stream ()),
export_macro_ (be_global->svnt_export_macro ())
{
/// All existing CIAO examples set the servant export values in the CIDL
/// compiler to equal the IDL compiler's skel export values. Below is a
/// partial effort to decouple them, should be completely decoupled
/// sometime. See comment in codegen.cpp, line 1173.
if (export_macro_ == "")
{
export_macro_ = be_global->skel_export_macro ();
}
}
be_visitor_component_svh::~be_visitor_component_svh (void)
{
}
int
be_visitor_component_svh::visit_component (be_component *node)
{
// Generate the facet servant class declaration.
be_visitor_facet_svh facet_visitor (this->ctx_);
if (facet_visitor.visit_component_scope (node) == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("be_visitor_component_svh::")
ACE_TEXT ("visit_component - ")
ACE_TEXT ("facet visitor failed\n")),
-1);
}
/// CIDL-generated namespace used 'CIDL_' + composition name.
/// Now we use 'CIAO_' + component's flat name.
os_ << be_nl << be_nl
<< "namespace CIAO_" << node->flat_name ()
<< "_Impl" << be_nl
<< "{" << be_idt;
// Generate the context class declaration.
be_visitor_context_svh context_visitor (this->ctx_);
if (context_visitor.visit_component (node) == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("be_visitor_component_svh::")
ACE_TEXT ("visit_component - ")
ACE_TEXT ("context visitor failed\n")),
-1);
}
// Generate the servant class declaration.
be_visitor_servant_svh servant_visitor (this->ctx_);
if (servant_visitor.visit_component (node) == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("be_visitor_component_svh::")
ACE_TEXT ("visit_component - ")
ACE_TEXT ("servant visitor failed\n")),
-1);
}
this->gen_entrypoint (node);
os_ << be_uidt_nl
<< "}";
return 0;
}
void
be_visitor_component_svh::gen_entrypoint (be_component *node)
{
os_ << be_nl << be_nl
<< "extern \"C\" " << export_macro_.c_str ()
<< " ::PortableServer::Servant" << be_nl
<< "create_" << node->flat_name ()
<< "_Servant (" << be_idt_nl
<< "::Components::EnterpriseComponent_ptr p," << be_nl
<< "::CIAO::Container_ptr c," << be_nl
<< "const char * ins_name);" << be_uidt;
}
|