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
309
310
311
312
313
314
315
316
317
|
// **********************************************************************
//
// Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************
#ifndef GEN_COMPAT_H
#define GEN_COMPAT_H
#include <Slice/Parser.h>
#include <Slice/JavaUtil.h>
#include <Slice/Checksum.h>
namespace Slice
{
class JavaCompatVisitor : public JavaCompatGenerator, public ParserVisitor
{
public:
virtual ~JavaCompatVisitor();
protected:
JavaCompatVisitor(const std::string&, int);
enum ParamDir { InParam, OutParam };
ParamDeclList getOutParams(const OperationPtr&);
//
// Compose the parameter lists for an operation.
//
std::vector<std::string> getParams(const OperationPtr&, const std::string&, bool, bool);
std::vector<std::string> getParamsProxy(const OperationPtr&, const std::string&, bool, bool, bool = false);
std::vector<std::string> getInOutParams(const OperationPtr&, const std::string&, ParamDir, bool, bool, bool = false);
std::vector<std::string> getParamsAsync(const OperationPtr&, const std::string&, bool, bool);
std::vector<std::string> getParamsAsyncCB(const OperationPtr&, const std::string&, bool, bool);
std::string getAsyncCallbackInterface(const OperationPtr&, const std::string&);
std::string getAsyncCallbackBaseClass(const OperationPtr&, bool);
std::string getLambdaResponseCB(const OperationPtr&, const std::string&);
std::vector<std::string> getParamsAsyncLambda(const OperationPtr&, const std::string&,
bool context = false, bool sentCB = false,
bool optionalMapping = false,
bool inParams = true,
bool internal = false);
std::vector<std::string> getArgsAsyncLambda(const OperationPtr&, const std::string&,
bool context = false,
bool sentCB = false);
//
// Compose the argument lists for an operation.
//
std::vector<std::string> getArgs(const OperationPtr&);
std::vector<std::string> getInOutArgs(const OperationPtr&, ParamDir, bool = false);
std::vector<std::string> getArgsAsync(const OperationPtr&);
std::vector<std::string> getArgsAsyncCB(const OperationPtr&);
void writeMarshalUnmarshalParams(::IceUtilInternal::Output&, const std::string&, const ParamDeclList&,
const OperationPtr&, int&, bool, bool, bool, const std::string& = "", bool = false);
//
// Generate a throws clause containing only checked exceptions.
// op is provided only when we want to check for the java:UserException metadata
//
void writeThrowsClause(const std::string&, const ExceptionList&, const OperationPtr& op = 0);
//
// Generate code to compute a hash code for a type.
//
void writeHashCode(::IceUtilInternal::Output&, const TypePtr&, const std::string&, int&,
const std::list<std::string>& = std::list<std::string>());
//
// Marshal/unmarshal a data member.
//
void writeMarshalDataMember(::IceUtilInternal::Output&, const std::string&, const DataMemberPtr&, int&, bool = false);
void writeUnmarshalDataMember(::IceUtilInternal::Output&, const std::string&, const DataMemberPtr&, int&,
bool, int&, bool = false);
void writeStreamMarshalDataMember(::IceUtilInternal::Output&, const std::string&, const DataMemberPtr&, int&);
void writeStreamUnmarshalDataMember(::IceUtilInternal::Output&, const std::string&, const DataMemberPtr&, int&,
bool, int&);
//
// Generate a patcher class.
//
void writePatcher(::IceUtilInternal::Output&, const std::string&, const DataMemberList&, const DataMemberList&);
//
// Generate dispatch and marshalling methods for a class or interface.
//
void writeDispatchAndMarshalling(::IceUtilInternal::Output&, const ClassDefPtr&);
//
// Write a constant or default value initializer.
//
void writeConstantValue(::IceUtilInternal::Output&, const TypePtr&, const SyntaxTreeBasePtr&, const std::string&,
const std::string&);
//
// Generate assignment statements for those data members that have default values.
//
void writeDataMemberInitializers(::IceUtilInternal::Output&, const DataMemberList&, const std::string&);
//
// Write doc comments.
//
static StringList splitComment(const ContainedPtr&);
static void writeDocComment(::IceUtilInternal::Output&, const ContainedPtr&,
const std::string&, const std::string& = "");
static void writeDocComment(::IceUtilInternal::Output&, const std::string&, const std::string&);
static void writeDocCommentOp(::IceUtilInternal::Output&, const OperationPtr&);
static void writeDocCommentAsync(::IceUtilInternal::Output&, const OperationPtr&,
ParamDir, const std::string& = "");
static void writeDocCommentAMI(::IceUtilInternal::Output&, const OperationPtr&, ParamDir, const std::string& = "",
const std::string& = "", const std::string& = "", const std::string& = "",
const std::string& = "");
static void writeDocCommentParam(::IceUtilInternal::Output&, const OperationPtr&, ParamDir, bool = true);
};
class GenCompat : private ::IceUtil::noncopyable
{
public:
GenCompat(const std::string&,
const std::string&,
const std::vector<std::string>&,
const std::string&,
bool,
int);
~GenCompat();
void generate(const UnitPtr&);
void generateImpl(const UnitPtr&);
void generateImplTie(const UnitPtr&);
static void writeChecksumClass(const std::string&, const std::string&, const ChecksumMap&);
private:
std::string _base;
std::vector<std::string> _includePaths;
std::string _dir;
bool _tie;
int _warningLevel;
class OpsVisitor : public JavaCompatVisitor
{
public:
OpsVisitor(const std::string&, int);
virtual bool visitClassDefStart(const ClassDefPtr&);
private:
void writeOperations(const ClassDefPtr&, bool);
};
class PackageVisitor : public JavaCompatVisitor
{
public:
PackageVisitor(const std::string&, int);
virtual bool visitModuleStart(const ModulePtr&);
};
class TypesVisitor : public JavaCompatVisitor
{
public:
TypesVisitor(const std::string&, int);
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 visitDataMember(const DataMemberPtr&);
virtual void visitEnum(const EnumPtr&);
virtual void visitConst(const ConstPtr&);
private:
//
// Verifies that a data member method does not conflict with an operation.
//
bool validateMethod(const OperationList&, const std::string&, int, const std::string&, const std::string&);
};
class CompactIdVisitor : public JavaCompatVisitor
{
public:
CompactIdVisitor(const std::string&, int);
virtual bool visitClassDefStart(const ClassDefPtr&);
};
class HolderVisitor : public JavaCompatVisitor
{
public:
HolderVisitor(const std::string&, int);
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 JavaCompatVisitor
{
public:
HelperVisitor(const std::string&, int);
virtual bool visitClassDefStart(const ClassDefPtr&);
virtual void visitSequence(const SequencePtr&);
virtual void visitDictionary(const DictionaryPtr&);
private:
void writeOperation(const ClassDefPtr&, const std::string&, const OperationPtr&, bool);
};
class ProxyVisitor : public JavaCompatVisitor
{
public:
ProxyVisitor(const std::string&, int);
virtual bool visitClassDefStart(const ClassDefPtr&);
virtual void visitClassDefEnd(const ClassDefPtr&);
virtual void visitOperation(const OperationPtr&);
};
class DispatcherVisitor : public JavaCompatVisitor
{
public:
DispatcherVisitor(const std::string&, bool, int);
virtual bool visitClassDefStart(const ClassDefPtr&);
private:
bool _tie;
};
class BaseImplVisitor : public JavaCompatVisitor
{
public:
BaseImplVisitor(const std::string&, int);
protected:
//
// Generate code to emit a local variable declaration and initialize it
// if necessary.
//
void writeDecl(::IceUtilInternal::Output&, const std::string&, const std::string&, const TypePtr&,
const StringList&, bool);
//
// Generate code to return a value.
//
void writeReturn(::IceUtilInternal::Output&, const TypePtr&, bool);
//
// Generate an operation.
//
void writeOperation(::IceUtilInternal::Output&, const std::string&, const OperationPtr&, bool);
};
class ImplVisitor : public BaseImplVisitor
{
public:
ImplVisitor(const std::string&, int);
virtual bool visitClassDefStart(const ClassDefPtr&);
};
class ImplTieVisitor : public BaseImplVisitor
{
public:
ImplTieVisitor(const std::string&, int);
virtual bool visitClassDefStart(const ClassDefPtr&);
};
class AsyncVisitor : public JavaCompatVisitor
{
public:
AsyncVisitor(const std::string&, int);
virtual void visitOperation(const OperationPtr&);
};
};
}
#endif
|