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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
//
// $Id$
//
// ============================================================================
//
// = LIBRARY
// TAO IDL
//
// = FILENAME
// ami_handler_fwd_ch.cpp
//
// = DESCRIPTION
// Visitor generating fwd declaration code for the AMI Handler
// interface.
//
// = AUTHOR
// Aniruddha Gokhale and Alexander Babu Arulanthu
// <alex@cs.wustl.edu>
//
// ============================================================================
#include "idl.h"
#include "idl_extern.h"
#include "be.h"
#include "be_visitor_interface_fwd.h"
ACE_RCSID(be_visitor_interface_ami_handler_fwd, ami_handler_fwd_ch, "$Id$")
// ********************************************************************
// Visitor implementation generating fwd declaration code for the AMI
// Handler interface.
// ********************************************************************
be_visitor_interface_ami_handler_fwd_ch::be_visitor_interface_ami_handler_fwd_ch (be_visitor_context *ctx)
: be_visitor_decl (ctx)
{
}
be_visitor_interface_ami_handler_fwd_ch::~be_visitor_interface_ami_handler_fwd_ch (void)
{
}
// visit the interface node and its scope
int
be_visitor_interface_ami_handler_fwd_ch::visit_interface (be_interface *node)
{
// Grab the out stream.
TAO_OutStream *os = this->ctx_->stream ();
// Generate code, if the client header is not generated already.
if (!node->cli_hdr_gen () && !node->imported ())
{
// start from the current indentation.
os->indent ();
// Generate forward declaration class.
*os << "class "
<< "AMI_" << node->local_name () << "_Handler" << ";"
<< be_nl;
// Create a string "AMI_<interface name>_Handler". We can use
// this for defining all _Var, _out,etc.
char *interface_name = 0;
ACE_NEW_RETURN (interface_name,
char [ACE_OS::strlen ("AMI_") +
ACE_OS::strlen (node->flatname ()) +
ACE_OS::strlen ("_Handler") +
// end of string
1],
0);
ACE_OS::sprintf (interface_name,
"AMI_%s_Handler",
node->flatname ());
// Generate the ifdefined macro for the _ptr type.
os->gen_ifdef_macro (interface_name, "_ptr");
// Generate the _ptr declaration
*os << "typedef "
<< "AMI_" << node->local_name () << "_Handler"
<< " *"
<< "AMI_" << node->local_name () << "_Handler" << "_ptr;"
<< be_nl;
// Generate the endif.
os->gen_endif ();
// Generate the var class.
// Enclose under an ifdef macro
os->gen_ifdef_macro (interface_name, "_var");
// Generate the _var declaration.
if (node->gen_var_defn (interface_name) == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_interface_ami_handler_fwd_ch::"
"visit_interface_fwd - "
"codegen for _var failed\n"), -1);
}
// Gen an endif.
os->gen_endif ();
// Generate the our class.
// Enclose under an ifdef macro.
os->gen_ifdef_macro (interface_name, "_out");
// Generate the _out declaration - ORBOS/97-05-15 pg 16-20
// spec.
if (node->gen_out_defn (interface_name) == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_interface_ami_handler_fwd_ch::"
"visit_interface_fwd - "
"codegen for _out failed\n"), -1);
}
// Generate the endif macro.
os->gen_endif ();
}
return 0;
}
|