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
|
// **********************************************************************
//
// Copyright (c) 2001
// Mutable Realms, Inc.
// Huntsville, AL, USA
//
// All Rights Reserved
//
// **********************************************************************
#ifndef GEN_H
#define GEN_H
#include <Slice/JavaUtil.h>
namespace Slice
{
class JavaVisitor : public JavaGenerator, public ParserVisitor
{
public:
virtual ~JavaVisitor();
protected:
JavaVisitor(const std::string&, const std::string&);
//
// Compose the parameter list for an operation
//
std::string getParams(const OperationPtr&, const std::string&);
//
// Compose the argument list for an operation
//
std::string getArgs(const OperationPtr&, const std::string&);
//
// Generate a throws clause containing only non-local exceptions
//
void writeThrowsClause(const std::string&, const ExceptionList&);
//
// Generate a throws clause for delegate operations containing only
// non-local exceptions
//
void writeDelegateThrowsClause(const std::string&, const ExceptionList&);
//
// Generate code to compute a hash code for a type
//
void writeHashCode(::IceUtil::Output&, const TypePtr&, const std::string&, int&,
const std::list<std::string>& = std::list<std::string>());
//
// Generate dispatch methods for a class or interface
//
void writeDispatch(::IceUtil::Output&, const ClassDefPtr&);
};
class Gen : public ::IceUtil::noncopyable
{
public:
Gen(const std::string&,
const std::string&,
const std::vector<std::string>&,
const std::string&,
const std::string&);
~Gen();
bool operator!() const; // Returns true if there was a constructor error
void generate(const UnitPtr&);
void generateTie(const UnitPtr&);
void generateImpl(const UnitPtr&);
void generateImplTie(const UnitPtr&);
private:
std::string _base;
std::vector<std::string> _includePaths;
std::string _package;
std::string _dir;
class OpsVisitor : public JavaVisitor
{
public:
OpsVisitor(const std::string&, const std::string&);
virtual bool visitClassDefStart(const ClassDefPtr&);
virtual void visitClassDefEnd(const ClassDefPtr&);
virtual void visitOperation(const OperationPtr&);
};
class TieVisitor : public JavaVisitor
{
public:
TieVisitor(const std::string&, const std::string&);
virtual bool visitClassDefStart(const ClassDefPtr&);
};
class TypesVisitor : public JavaVisitor
{
public:
TypesVisitor(const std::string&, const std::string&);
virtual bool visitClassDefStart(const ClassDefPtr&);
virtual void visitClassDefEnd(const ClassDefPtr&);
virtual bool visitExceptionStart(const ExceptionPtr&);
virtual void visitExceptionEnd(const ExceptionPtr&);
virtual bool visitStructStart(const StructPtr&);
virtual void visitStructEnd(const StructPtr&);
virtual void visitEnum(const EnumPtr&);
virtual void visitConstDef(const ConstDefPtr&);
virtual void visitDataMember(const DataMemberPtr&);
};
class HolderVisitor : public JavaVisitor
{
public:
HolderVisitor(const std::string&, const std::string&);
virtual bool visitClassDefStart(const ClassDefPtr&);
virtual bool visitStructStart(const StructPtr&);
virtual void visitSequence(const SequencePtr&);
virtual void visitDictionary(const DictionaryPtr&);
virtual void visitEnum(const EnumPtr&);
private:
void writeHolder(const TypePtr&);
};
class HelperVisitor : public JavaVisitor
{
public:
HelperVisitor(const std::string&, const std::string&);
virtual bool visitClassDefStart(const ClassDefPtr&);
virtual void visitSequence(const SequencePtr&);
virtual void visitDictionary(const DictionaryPtr&);
};
class ProxyVisitor : public JavaVisitor
{
public:
ProxyVisitor(const std::string&, const std::string&);
virtual bool visitClassDefStart(const ClassDefPtr&);
virtual void visitClassDefEnd(const ClassDefPtr&);
virtual void visitOperation(const OperationPtr&);
};
class DelegateVisitor : public JavaVisitor
{
public:
DelegateVisitor(const std::string&, const std::string&);
virtual bool visitClassDefStart(const ClassDefPtr&);
};
class DelegateMVisitor : public JavaVisitor
{
public:
DelegateMVisitor(const std::string&, const std::string&);
virtual bool visitClassDefStart(const ClassDefPtr&);
};
class DelegateDVisitor : public JavaVisitor
{
public:
DelegateDVisitor(const std::string&, const std::string&);
virtual bool visitClassDefStart(const ClassDefPtr&);
};
class DispatcherVisitor : public JavaVisitor
{
public:
DispatcherVisitor(const std::string&, const std::string&);
virtual bool visitClassDefStart(const ClassDefPtr&);
};
class BaseImplVisitor : public JavaVisitor
{
protected:
//
// Generate code to return a value
//
void writeReturn(::IceUtil::Output&, const TypePtr&);
//
// Generate an operation
//
void writeOperation(::IceUtil::Output&, const std::string&, const OperationPtr&, bool);
public:
BaseImplVisitor(const std::string&, const std::string&);
};
class ImplVisitor : public BaseImplVisitor
{
public:
ImplVisitor(const std::string&, const std::string&);
virtual bool visitClassDefStart(const ClassDefPtr&);
};
class ImplTieVisitor : public BaseImplVisitor
{
public:
ImplTieVisitor(const std::string&, const std::string&);
virtual bool visitClassDefStart(const ClassDefPtr&);
};
};
}
#endif
|