summaryrefslogtreecommitdiff
path: root/TAO/TAO_IDL/be/be_visitor_root.cpp
blob: d483a1e5472fc28a24b64b82ff343b8a14632967 (plain)
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
//
// $Id$
//

// ============================================================================
//
// = LIBRARY
//    TAO IDL
//
// = FILENAME
//    be_visitor_root.cpp
//
// = DESCRIPTION
//    Visitors for generation of code for Root
//
// = AUTHOR
//    Aniruddha Gokhale
//
// ============================================================================

#include	"idl.h"
#include	"idl_extern.h"
#include	"be.h"

#include "be_visitor_root.h"

// Root visitor for client header
be_visitor_root_ch::be_visitor_root_ch (void)
{
  // retrieve a singleton instance of the code generator
  TAO_CodeGen *cg = TAO_CODEGEN::instance ();
  this->os_ = cg->client_header ();
}

be_visitor_root_ch::~be_visitor_root_ch (void)
{
}

int be_visitor_root_ch::visit_root (be_root *node)
{
  // retrieve a singleton instance of the code generator
  TAO_CodeGen *cg = TAO_CODEGEN::instance ();
  cg->push (TAO_CodeGen::TAO_ROOT_CH); // set the code generation state

  // open the client-side header file
  if (cg->client_header (idl_global->be_get_client_hdr_fname ()) == -1)
    {
      ACE_ERROR ((LM_ERROR, "be_root: Error opening client header\n"));
      return -1;
    }
  // delegate the task of code generation to the scope
  if (node->be_scope::gen_client_header () == -1)
    {
      ACE_ERROR ((LM_ERROR, "be_root: code generation for scope failed\n"));
      return -1;
    }
  cg->pop ();

  // at this point, we must be in the initial state
  ACE_ASSERT (cg->state () == TAO_CodeGen::TAO_INITIAL);

  (void) cg->end_client_header (); // generate the last #endif
  return 0;
}

int be_visitor_root_ch::visit_sequence (be_sequence *node)
{
  return 0;
}

// Root visitor for client inline

be_visitor_root_ci::be_visitor_root_ci (void)
{
  // retrieve a singleton instance of the code generator
  TAO_CodeGen *cg = TAO_CODEGEN::instance ();
  this->os_ = cg->client_inline ();
}

be_visitor_root_ci::~be_visitor_root_ci (void)
{
}

int be_visitor_root_ci::visit_root (be_root *node)
{
  // retrieve a singleton instance of the code generator
  TAO_CodeGen *cg = TAO_CODEGEN::instance ();
  cg->push (TAO_CodeGen::TAO_ROOT_CI); // set the code generation state

  // open the client-side inline file
  if (cg->client_inline (idl_global->be_get_client_inline_fname ()) == -1)
    {
      ACE_ERROR ((LM_ERROR, "be_root: Error opening client inline file\n"));
      return -1;
    }
  // delegate the task of code generation to the scope
  if (node->be_scope::gen_client_inline () == -1)
    {
      ACE_ERROR ((LM_ERROR, "be_root: code generation for scope failed\n"));
      return -1;
    }
  cg->pop ();

  // at this point, we must be in the initial state
  //  ACE_ASSERT (cg->state () == TAO_CodeGen::TAO_INITIAL);

  return 0;
}

int be_visitor_root_ci::visit_sequence (be_sequence *)
{
  return 0;
}

// Root visitor for client stubs

be_visitor_root_cs::be_visitor_root_cs (void)
{
  // retrieve a singleton instance of the code generator
  TAO_CodeGen *cg = TAO_CODEGEN::instance ();
  this->os_ = cg->client_stubs ();
}

be_visitor_root_cs::~be_visitor_root_cs (void)
{
}

int be_visitor_root_cs::visit_root (be_root *node)
{
  // retrieve a singleton instance of the code generator
  TAO_CodeGen *cg = TAO_CODEGEN::instance ();
  cg->push (TAO_CodeGen::TAO_ROOT_CS); // set the code generation state

  // open the client-side stub file
  if (cg->client_stubs (idl_global->be_get_client_stub_fname ()) == -1)
    {
      ACE_ERROR ((LM_ERROR, "be_root: Error opening client stubs file\n"));
      return -1;
    }
  // delegate the task of code generation to the scope
  if (node->be_scope::gen_client_stubs () == -1)
    {
      ACE_ERROR ((LM_ERROR, "be_root: code generation for scope failed\n"));
      return -1;
    }
  cg->pop ();

  // at this point, we must be in the initial state
  //  ACE_ASSERT (cg->state () == TAO_CodeGen::TAO_INITIAL);

  return 0;
}

int be_visitor_root_cs::visit_sequence (be_sequence *)
{
  return 0;
}

// Root visitor for server header

be_visitor_root_sh::be_visitor_root_sh (void)
{
  // retrieve a singleton instance of the code generator
  TAO_CodeGen *cg = TAO_CODEGEN::instance ();
  this->os_ = cg->server_header ();
}

be_visitor_root_sh::~be_visitor_root_sh (void)
{
}

int be_visitor_root_sh::visit_root (be_root *node)
{
  // retrieve a singleton instance of the code generator
  TAO_CodeGen *cg = TAO_CODEGEN::instance ();
  cg->push (TAO_CodeGen::TAO_ROOT_SH); // set the code generation state

  // open the server-side header file
  if (cg->server_header (idl_global->be_get_server_hdr_fname ()) == -1)
    {
      ACE_ERROR ((LM_ERROR, "be_root: Error opening server header\n"));
      return -1;
    }
  // delegate the task of code generation to the scope
  if (node->be_scope::gen_server_header () == -1)
    {
      ACE_ERROR ((LM_ERROR,
                  "be_root: server code generation for scope failed\n"));
      return -1;
    }

  cg->pop ();

  // at this point, we must be in the initial state
  //  ACE_ASSERT (cg->state () == TAO_CodeGen::TAO_INITIAL);

  (void) cg->end_server_header (); // generate the last #endif statement
  return 0;
}

int be_visitor_root_sh::visit_sequence (be_sequence *)
{
  return 0;
}

// Root visitor for server inline

be_visitor_root_si::be_visitor_root_si (void)
{
  // retrieve a singleton instance of the code generator
  TAO_CodeGen *cg = TAO_CODEGEN::instance ();
  this->os_ = cg->server_inline ();
}

be_visitor_root_si::~be_visitor_root_si (void)
{
}

int be_visitor_root_si::visit_root (be_root *node)
{
  // retrieve a singleton instance of the code generator
  TAO_CodeGen *cg = TAO_CODEGEN::instance ();
  cg->push (TAO_CodeGen::TAO_ROOT_SI); // set the code generation state

  // open the server-side inline file
  if (cg->server_inline (idl_global->be_get_server_inline_fname ()) == -1)
    {
      ACE_ERROR ((LM_ERROR, "be_root: Error opening server inline file\n"));
      return -1;
    }
  // delegate the task of code generation to the scope
  if (node->be_scope::gen_server_inline () == -1)
    {
      ACE_ERROR ((LM_ERROR, "be_root: code generation for scope failed\n"));
      return -1;
    }
  cg->pop ();

  // at this point, we must be in the initial state
  //  ACE_ASSERT (cg->state () == TAO_CodeGen::TAO_INITIAL);

  return 0;
}

int be_visitor_root_si::visit_sequence (be_sequence *)
{
  return 0;
}

// Root visitor for server server

be_visitor_root_ss::be_visitor_root_ss (void)
{
  // retrieve a singleton instance of the code generator
  TAO_CodeGen *cg = TAO_CODEGEN::instance ();
  this->os_ = cg->server_skeletons ();
}

be_visitor_root_ss::~be_visitor_root_ss (void)
{
}

int be_visitor_root_ss::visit_root (be_root *node)
{
  // retrieve a singleton instance of the code generator
  TAO_CodeGen *cg = TAO_CODEGEN::instance ();
  cg->push (TAO_CodeGen::TAO_ROOT_SS); // set the code generation state

  // open the server-side skeleton file
  if (cg->server_skeletons (idl_global->be_get_server_skeleton_fname ()) == -1)
    {
      ACE_ERROR ((LM_ERROR, "be_root: Error opening server skeletons file\n"));
      return -1;
    }
  // delegate the task of code generation to the scope
  if (node->be_scope::gen_server_skeletons () == -1)
    {
      ACE_ERROR ((LM_ERROR, "be_root: code generation for scope failed\n"));
      return -1;
    }
  cg->pop ();

  // at this point, we must be in the initial state
  //  ACE_ASSERT (cg->state () == TAO_CodeGen::TAO_INITIAL);

  return 0;
}

int be_visitor_root_ss::visit_sequence (be_sequence *)
{
  return 0;
}

#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
template class ACE_Singleton<be_visitor_root_ch, ACE_SYNCH_RECURSIVE_MUTEX>;
template class ACE_Singleton<be_visitor_root_ci, ACE_SYNCH_RECURSIVE_MUTEX>;
template class ACE_Singleton<be_visitor_root_cs, ACE_SYNCH_RECURSIVE_MUTEX>;
template class ACE_Singleton<be_visitor_root_sh, ACE_SYNCH_RECURSIVE_MUTEX>;
template class ACE_Singleton<be_visitor_root_si, ACE_SYNCH_RECURSIVE_MUTEX>;
template class ACE_Singleton<be_visitor_root_ss, ACE_SYNCH_RECURSIVE_MUTEX>;
#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
#pragma instantiate ACE_Singleton<be_visitor_root_ch, ACE_SYNCH_RECURSIVE_MUTEX>
#pragma instantiate ACE_Singleton<be_visitor_root_ci, ACE_SYNCH_RECURSIVE_MUTEX>
#pragma instantiate ACE_Singleton<be_visitor_root_cs, ACE_SYNCH_RECURSIVE_MUTEX>
#pragma instantiate ACE_Singleton<be_visitor_root_sh, ACE_SYNCH_RECURSIVE_MUTEX>
#pragma instantiate ACE_Singleton<be_visitor_root_si, ACE_SYNCH_RECURSIVE_MUTEX>
#pragma instantiate ACE_Singleton<be_visitor_root_ss, ACE_SYNCH_RECURSIVE_MUTEX>
#endif