typia 7.0.0-dev.20240921 → 7.0.0-dev.20240922
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/programmers/notations/NotationGeneralProgrammer.js +355 -369
- package/lib/programmers/notations/NotationGeneralProgrammer.js.map +1 -1
- package/lib/programmers/protobuf/ProtobufDecodeProgrammer.js +264 -239
- package/lib/programmers/protobuf/ProtobufDecodeProgrammer.js.map +1 -1
- package/lib/programmers/protobuf/ProtobufEncodeProgrammer.js +424 -368
- package/lib/programmers/protobuf/ProtobufEncodeProgrammer.js.map +1 -1
- package/lib/programmers/protobuf/ProtobufMessageProgrammer.js +106 -85
- package/lib/programmers/protobuf/ProtobufMessageProgrammer.js.map +1 -1
- package/package.json +1 -1
- package/src/programmers/notations/NotationGeneralProgrammer.ts +610 -528
- package/src/programmers/protobuf/ProtobufDecodeProgrammer.ts +421 -358
- package/src/programmers/protobuf/ProtobufEncodeProgrammer.ts +752 -613
- package/src/programmers/protobuf/ProtobufMessageProgrammer.ts +96 -63
|
@@ -80,10 +80,14 @@ var ProtobufDecodeProgrammer;
|
|
|
80
80
|
return {
|
|
81
81
|
functions: Object.fromEntries(collection
|
|
82
82
|
.objects()
|
|
83
|
-
.filter(function (
|
|
84
|
-
.map(function (
|
|
85
|
-
"".concat(PREFIX, "o").concat(
|
|
86
|
-
StatementFactory_1.StatementFactory.constant(props.importer.useLocal("".concat(PREFIX, "o").concat(
|
|
83
|
+
.filter(function (object) { return ProtobufUtil_1.ProtobufUtil.isStaticObject(object); })
|
|
84
|
+
.map(function (object) { return [
|
|
85
|
+
"".concat(PREFIX, "o").concat(object.index),
|
|
86
|
+
StatementFactory_1.StatementFactory.constant(props.importer.useLocal("".concat(PREFIX, "o").concat(object.index)), write_object_function({
|
|
87
|
+
context: props.context,
|
|
88
|
+
importer: props.importer,
|
|
89
|
+
object: object,
|
|
90
|
+
})),
|
|
87
91
|
]; })),
|
|
88
92
|
statements: [],
|
|
89
93
|
arrow: typescript_1.default.factory.createArrowFunction(undefined, undefined, [
|
|
@@ -92,7 +96,10 @@ var ProtobufDecodeProgrammer;
|
|
|
92
96
|
typescript_1.default.factory.createTypeReferenceNode((_a = props.name) !== null && _a !== void 0 ? _a : TypeFactory_1.TypeFactory.getFullName(props.context.checker)(props.type)),
|
|
93
97
|
]), undefined, typescript_1.default.factory.createBlock([
|
|
94
98
|
StatementFactory_1.StatementFactory.constant("reader", typescript_1.default.factory.createNewExpression(props.importer.use("Reader"), undefined, [typescript_1.default.factory.createIdentifier("input")])),
|
|
95
|
-
typescript_1.default.factory.createReturnStatement(decode_regular_object(
|
|
99
|
+
typescript_1.default.factory.createReturnStatement(decode_regular_object({
|
|
100
|
+
top: true,
|
|
101
|
+
object: meta.objects[0],
|
|
102
|
+
})),
|
|
96
103
|
], true)),
|
|
97
104
|
};
|
|
98
105
|
};
|
|
@@ -105,60 +112,59 @@ var ProtobufDecodeProgrammer;
|
|
|
105
112
|
result: result,
|
|
106
113
|
});
|
|
107
114
|
};
|
|
108
|
-
var write_object_function = function (
|
|
109
|
-
return
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
};
|
|
115
|
+
var write_object_function = function (props) {
|
|
116
|
+
return typescript_1.default.factory.createArrowFunction(undefined, undefined, [
|
|
117
|
+
IdentifierFactory_1.IdentifierFactory.parameter("reader"),
|
|
118
|
+
IdentifierFactory_1.IdentifierFactory.parameter("length", TypeFactory_1.TypeFactory.keyword("number"), ExpressionFactory_1.ExpressionFactory.number(-1)),
|
|
119
|
+
], TypeFactory_1.TypeFactory.keyword("any"), undefined, typescript_1.default.factory.createBlock(__spreadArray(__spreadArray([
|
|
120
|
+
typescript_1.default.factory.createExpressionStatement(typescript_1.default.factory.createBinaryExpression(typescript_1.default.factory.createIdentifier("length"), typescript_1.default.factory.createToken(typescript_1.default.SyntaxKind.EqualsToken), typescript_1.default.factory.createConditionalExpression(typescript_1.default.factory.createLessThan(typescript_1.default.factory.createIdentifier("length"), ExpressionFactory_1.ExpressionFactory.number(0)), undefined, typescript_1.default.factory.createCallExpression(IdentifierFactory_1.IdentifierFactory.access(READER())("size"), undefined, undefined), undefined, typescript_1.default.factory.createAdd(typescript_1.default.factory.createCallExpression(IdentifierFactory_1.IdentifierFactory.access(READER())("index"), undefined, undefined), typescript_1.default.factory.createIdentifier("length")))))
|
|
121
|
+
], __read(write_object_function_body({
|
|
122
|
+
context: props.context,
|
|
123
|
+
importer: props.importer,
|
|
124
|
+
condition: typescript_1.default.factory.createLessThan(typescript_1.default.factory.createCallExpression(IdentifierFactory_1.IdentifierFactory.access(READER())("index"), undefined, undefined), typescript_1.default.factory.createIdentifier("length")),
|
|
125
|
+
tag: "tag",
|
|
126
|
+
output: "output",
|
|
127
|
+
properties: props.object.properties,
|
|
128
|
+
})), false), [
|
|
129
|
+
typescript_1.default.factory.createReturnStatement(typescript_1.default.factory.createIdentifier("output")),
|
|
130
|
+
], false), true));
|
|
125
131
|
};
|
|
126
|
-
var write_object_function_body = function (
|
|
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
|
-
], false))),
|
|
132
|
+
var write_object_function_body = function (props) {
|
|
133
|
+
var index = 1;
|
|
134
|
+
var clauses = props.properties
|
|
135
|
+
.map(function (p) {
|
|
136
|
+
var clause = decode_property({
|
|
137
|
+
context: props.context,
|
|
138
|
+
importer: props.importer,
|
|
139
|
+
index: index,
|
|
140
|
+
accessor: IdentifierFactory_1.IdentifierFactory.access(typescript_1.default.factory.createIdentifier(props.output))(p.key.getSoleLiteral()),
|
|
141
|
+
metadata: p.value,
|
|
142
|
+
});
|
|
143
|
+
index += ProtobufUtil_1.ProtobufUtil.size(p.value);
|
|
144
|
+
return clause;
|
|
145
|
+
})
|
|
146
|
+
.flat();
|
|
147
|
+
return [
|
|
148
|
+
StatementFactory_1.StatementFactory.constant(props.output, typescript_1.default.factory.createAsExpression(typescript_1.default.factory.createObjectLiteralExpression(props.properties
|
|
149
|
+
.filter(function (p) {
|
|
150
|
+
return !(props.context.compilerOptions.exactOptionalPropertyTypes ===
|
|
151
|
+
true && p.value.optional === true);
|
|
152
|
+
})
|
|
153
|
+
.map(function (p) {
|
|
154
|
+
return typescript_1.default.factory.createPropertyAssignment(IdentifierFactory_1.IdentifierFactory.identifier(p.key.getSoleLiteral()), write_property_default_value(p.value));
|
|
155
|
+
}), true), TypeFactory_1.TypeFactory.keyword("any"))),
|
|
156
|
+
typescript_1.default.factory.createWhileStatement(props.condition, typescript_1.default.factory.createBlock([
|
|
157
|
+
StatementFactory_1.StatementFactory.constant(props.tag, typescript_1.default.factory.createCallExpression(IdentifierFactory_1.IdentifierFactory.access(READER())("uint32"), undefined, undefined)),
|
|
158
|
+
typescript_1.default.factory.createSwitchStatement(typescript_1.default.factory.createUnsignedRightShift(typescript_1.default.factory.createIdentifier(props.tag), ExpressionFactory_1.ExpressionFactory.number(3)), typescript_1.default.factory.createCaseBlock(__spreadArray(__spreadArray([], __read(clauses), false), [
|
|
159
|
+
typescript_1.default.factory.createDefaultClause([
|
|
160
|
+
typescript_1.default.factory.createExpressionStatement(typescript_1.default.factory.createCallExpression(IdentifierFactory_1.IdentifierFactory.access(READER())("skipType"), undefined, [
|
|
161
|
+
typescript_1.default.factory.createBitwiseAnd(typescript_1.default.factory.createIdentifier(props.tag), ExpressionFactory_1.ExpressionFactory.number(7)),
|
|
157
162
|
])),
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
163
|
+
typescript_1.default.factory.createBreakStatement(),
|
|
164
|
+
]),
|
|
165
|
+
], false))),
|
|
166
|
+
])),
|
|
167
|
+
];
|
|
162
168
|
};
|
|
163
169
|
var write_property_default_value = function (value) {
|
|
164
170
|
return typescript_1.default.factory.createAsExpression(value.nullable
|
|
@@ -189,212 +195,231 @@ var ProtobufDecodeProgrammer;
|
|
|
189
195
|
/* -----------------------------------------------------------
|
|
190
196
|
DECODERS
|
|
191
197
|
----------------------------------------------------------- */
|
|
192
|
-
var decode_property = function (
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
typescript_1.default.factory.createExpressionStatement(typescript_1.default.factory.createBinaryExpression(accessor, typescript_1.default.factory.createToken(typescript_1.default.SyntaxKind.EqualsToken), v)),
|
|
207
|
-
typescript_1.default.factory.createBreakStatement(),
|
|
208
|
-
]));
|
|
209
|
-
}; };
|
|
210
|
-
var required = meta.isRequired() && !meta.nullable;
|
|
211
|
-
try {
|
|
212
|
-
for (var _e = __values(ProtobufUtil_1.ProtobufUtil.getAtomics(meta)), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
213
|
-
var atomic = _f.value;
|
|
214
|
-
emplace(atomic)(decode_atomic(meta)(atomic));
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
218
|
-
finally {
|
|
219
|
-
try {
|
|
220
|
-
if (_f && !_f.done && (_a = _e.return)) _a.call(_e);
|
|
221
|
-
}
|
|
222
|
-
finally { if (e_1) throw e_1.error; }
|
|
223
|
-
}
|
|
224
|
-
if (meta.natives.length)
|
|
225
|
-
emplace("bytes")(decode_bytes("bytes"));
|
|
226
|
-
try {
|
|
227
|
-
for (var _g = __values(meta.arrays), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
228
|
-
var array = _h.value;
|
|
229
|
-
emplace("Array<".concat(array.type.value.getName(), ">"))(decode_array(accessor, array, required));
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
233
|
-
finally {
|
|
234
|
-
try {
|
|
235
|
-
if (_h && !_h.done && (_b = _g.return)) _b.call(_g);
|
|
236
|
-
}
|
|
237
|
-
finally { if (e_2) throw e_2.error; }
|
|
238
|
-
}
|
|
239
|
-
try {
|
|
240
|
-
for (var _j = __values(meta.maps), _k = _j.next(); !_k.done; _k = _j.next()) {
|
|
241
|
-
var map = _k.value;
|
|
242
|
-
emplace("Map<string, ".concat(map.value.getName(), ">"))(decode_map(project)(importer)(accessor, map, required));
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
246
|
-
finally {
|
|
247
|
-
try {
|
|
248
|
-
if (_k && !_k.done && (_c = _j.return)) _c.call(_j);
|
|
249
|
-
}
|
|
250
|
-
finally { if (e_3) throw e_3.error; }
|
|
251
|
-
}
|
|
252
|
-
try {
|
|
253
|
-
for (var _l = __values(meta.objects), _m = _l.next(); !_m.done; _m = _l.next()) {
|
|
254
|
-
var obj = _m.value;
|
|
255
|
-
emplace(obj.name)(ProtobufUtil_1.ProtobufUtil.isStaticObject(obj)
|
|
256
|
-
? decode_regular_object(false)(obj)
|
|
257
|
-
: decode_dynamic_object(project)(importer)(accessor, obj, required));
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
261
|
-
finally {
|
|
262
|
-
try {
|
|
263
|
-
if (_m && !_m.done && (_d = _l.return)) _d.call(_l);
|
|
264
|
-
}
|
|
265
|
-
finally { if (e_4) throw e_4.error; }
|
|
266
|
-
}
|
|
267
|
-
return clauses;
|
|
268
|
-
};
|
|
269
|
-
};
|
|
198
|
+
var decode_property = function (props) {
|
|
199
|
+
var e_1, _a, e_2, _b, e_3, _c, e_4, _d;
|
|
200
|
+
var clauses = [];
|
|
201
|
+
var emplace = function (name, value) {
|
|
202
|
+
return clauses.push(typescript_1.default.factory.createCaseClause(ExpressionFactory_1.ExpressionFactory.number(props.index++), Array.isArray(value)
|
|
203
|
+
? __spreadArray(__spreadArray([
|
|
204
|
+
typescript_1.default.factory.createExpressionStatement(typescript_1.default.factory.createIdentifier("// type: ".concat(name)))
|
|
205
|
+
], __read(value), false), [
|
|
206
|
+
typescript_1.default.factory.createBreakStatement(),
|
|
207
|
+
], false) : [
|
|
208
|
+
typescript_1.default.factory.createExpressionStatement(typescript_1.default.factory.createIdentifier("// ".concat(name))),
|
|
209
|
+
typescript_1.default.factory.createExpressionStatement(typescript_1.default.factory.createBinaryExpression(props.accessor, typescript_1.default.factory.createToken(typescript_1.default.SyntaxKind.EqualsToken), value)),
|
|
210
|
+
typescript_1.default.factory.createBreakStatement(),
|
|
211
|
+
]));
|
|
270
212
|
};
|
|
213
|
+
var required = props.metadata.isRequired() && !props.metadata.nullable;
|
|
214
|
+
try {
|
|
215
|
+
for (var _e = __values(ProtobufUtil_1.ProtobufUtil.getAtomics(props.metadata)), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
216
|
+
var atomic = _f.value;
|
|
217
|
+
emplace(atomic, decode_atomic({
|
|
218
|
+
metadata: props.metadata,
|
|
219
|
+
type: atomic,
|
|
220
|
+
}));
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
224
|
+
finally {
|
|
225
|
+
try {
|
|
226
|
+
if (_f && !_f.done && (_a = _e.return)) _a.call(_e);
|
|
227
|
+
}
|
|
228
|
+
finally { if (e_1) throw e_1.error; }
|
|
229
|
+
}
|
|
230
|
+
if (props.metadata.natives.length)
|
|
231
|
+
emplace("bytes", decode_bytes("bytes"));
|
|
232
|
+
try {
|
|
233
|
+
for (var _g = __values(props.metadata.arrays), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
234
|
+
var array = _h.value;
|
|
235
|
+
emplace("Array<".concat(array.type.value.getName(), ">"), decode_array({
|
|
236
|
+
accessor: props.accessor,
|
|
237
|
+
array: array,
|
|
238
|
+
required: required,
|
|
239
|
+
}));
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
243
|
+
finally {
|
|
244
|
+
try {
|
|
245
|
+
if (_h && !_h.done && (_b = _g.return)) _b.call(_g);
|
|
246
|
+
}
|
|
247
|
+
finally { if (e_2) throw e_2.error; }
|
|
248
|
+
}
|
|
249
|
+
try {
|
|
250
|
+
for (var _j = __values(props.metadata.maps), _k = _j.next(); !_k.done; _k = _j.next()) {
|
|
251
|
+
var entry = _k.value;
|
|
252
|
+
emplace("Map<string, ".concat(entry.value.getName(), ">"), decode_map({
|
|
253
|
+
context: props.context,
|
|
254
|
+
importer: props.importer,
|
|
255
|
+
accessor: props.accessor,
|
|
256
|
+
entry: entry,
|
|
257
|
+
required: required,
|
|
258
|
+
}));
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
262
|
+
finally {
|
|
263
|
+
try {
|
|
264
|
+
if (_k && !_k.done && (_c = _j.return)) _c.call(_j);
|
|
265
|
+
}
|
|
266
|
+
finally { if (e_3) throw e_3.error; }
|
|
267
|
+
}
|
|
268
|
+
try {
|
|
269
|
+
for (var _l = __values(props.metadata.objects), _m = _l.next(); !_m.done; _m = _l.next()) {
|
|
270
|
+
var object = _m.value;
|
|
271
|
+
emplace(object.name, ProtobufUtil_1.ProtobufUtil.isStaticObject(object)
|
|
272
|
+
? decode_regular_object({
|
|
273
|
+
top: false,
|
|
274
|
+
object: object,
|
|
275
|
+
})
|
|
276
|
+
: decode_dynamic_object({
|
|
277
|
+
context: props.context,
|
|
278
|
+
importer: props.importer,
|
|
279
|
+
accessor: props.accessor,
|
|
280
|
+
object: object,
|
|
281
|
+
required: required,
|
|
282
|
+
}));
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
286
|
+
finally {
|
|
287
|
+
try {
|
|
288
|
+
if (_m && !_m.done && (_d = _l.return)) _d.call(_l);
|
|
289
|
+
}
|
|
290
|
+
finally { if (e_4) throw e_4.error; }
|
|
291
|
+
}
|
|
292
|
+
return clauses;
|
|
271
293
|
};
|
|
272
|
-
var decode_atomic = function (
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
: call;
|
|
283
|
-
};
|
|
294
|
+
var decode_atomic = function (props) {
|
|
295
|
+
if (props.type === "string")
|
|
296
|
+
return decode_bytes("string");
|
|
297
|
+
var call = typescript_1.default.factory.createCallExpression(IdentifierFactory_1.IdentifierFactory.access(typescript_1.default.factory.createIdentifier("reader"))(props.type), undefined, undefined);
|
|
298
|
+
if (props.type !== "int64" && props.type !== "uint64")
|
|
299
|
+
return call;
|
|
300
|
+
var isNumber = ProtobufUtil_1.ProtobufUtil.getNumbers(props.metadata).some(function (n) { return n === props.type; });
|
|
301
|
+
return isNumber
|
|
302
|
+
? typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier("Number"), undefined, [call])
|
|
303
|
+
: call;
|
|
284
304
|
};
|
|
285
305
|
var decode_bytes = function (method) {
|
|
286
306
|
return typescript_1.default.factory.createCallExpression(IdentifierFactory_1.IdentifierFactory.access(typescript_1.default.factory.createIdentifier("reader"))(method), undefined, undefined);
|
|
287
307
|
};
|
|
288
|
-
var decode_array = function (
|
|
308
|
+
var decode_array = function (props) {
|
|
289
309
|
var statements = [];
|
|
290
|
-
if (required === false)
|
|
291
|
-
statements.push(typescript_1.default.factory.createBinaryExpression(accessor, typescript_1.default.factory.createToken(typescript_1.default.SyntaxKind.QuestionQuestionEqualsToken), typescript_1.default.factory.createAsExpression(typescript_1.default.factory.createArrayLiteralExpression(), typescript_1.default.factory.createTypeReferenceNode("any[]"))));
|
|
292
|
-
var atomics = ProtobufUtil_1.ProtobufUtil.getAtomics(array.type.value);
|
|
310
|
+
if (props.required === false)
|
|
311
|
+
statements.push(typescript_1.default.factory.createBinaryExpression(props.accessor, typescript_1.default.factory.createToken(typescript_1.default.SyntaxKind.QuestionQuestionEqualsToken), typescript_1.default.factory.createAsExpression(typescript_1.default.factory.createArrayLiteralExpression(), typescript_1.default.factory.createTypeReferenceNode("any[]"))));
|
|
312
|
+
var atomics = ProtobufUtil_1.ProtobufUtil.getAtomics(props.array.type.value);
|
|
293
313
|
var decoder = atomics.length
|
|
294
|
-
? function () {
|
|
295
|
-
|
|
314
|
+
? function () {
|
|
315
|
+
return decode_atomic({
|
|
316
|
+
metadata: props.array.type.value,
|
|
317
|
+
type: atomics[0],
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
: props.array.type.value.natives.length
|
|
296
321
|
? function () { return decode_bytes("bytes"); }
|
|
297
|
-
: array.type.value.objects.length
|
|
298
|
-
? function () {
|
|
322
|
+
: props.array.type.value.objects.length
|
|
323
|
+
? function () {
|
|
324
|
+
return decode_regular_object({
|
|
325
|
+
top: false,
|
|
326
|
+
object: props.array.type.value.objects[0],
|
|
327
|
+
});
|
|
328
|
+
}
|
|
299
329
|
: null;
|
|
300
330
|
if (decoder === null)
|
|
301
331
|
throw new Error("Never reach here.");
|
|
302
332
|
else if (atomics.length && atomics[0] !== "string") {
|
|
303
333
|
statements.push(typescript_1.default.factory.createIfStatement(typescript_1.default.factory.createStrictEquality(ExpressionFactory_1.ExpressionFactory.number(2), typescript_1.default.factory.createBitwiseAnd(typescript_1.default.factory.createIdentifier("tag"), ExpressionFactory_1.ExpressionFactory.number(7))), typescript_1.default.factory.createBlock([
|
|
304
334
|
StatementFactory_1.StatementFactory.constant("piece", typescript_1.default.factory.createAdd(typescript_1.default.factory.createCallExpression(IdentifierFactory_1.IdentifierFactory.access(READER())("uint32"), undefined, undefined), typescript_1.default.factory.createCallExpression(IdentifierFactory_1.IdentifierFactory.access(READER())("index"), undefined, undefined))),
|
|
305
|
-
typescript_1.default.factory.createWhileStatement(typescript_1.default.factory.createLessThan(typescript_1.default.factory.createCallExpression(IdentifierFactory_1.IdentifierFactory.access(READER())("index"), undefined, undefined), typescript_1.default.factory.createIdentifier("piece")), typescript_1.default.factory.createExpressionStatement(typescript_1.default.factory.createCallExpression(IdentifierFactory_1.IdentifierFactory.access(accessor)("push"), undefined, [decoder()]))),
|
|
306
|
-
], true), typescript_1.default.factory.createExpressionStatement(typescript_1.default.factory.createCallExpression(IdentifierFactory_1.IdentifierFactory.access(accessor)("push"), undefined, [decoder()]))));
|
|
335
|
+
typescript_1.default.factory.createWhileStatement(typescript_1.default.factory.createLessThan(typescript_1.default.factory.createCallExpression(IdentifierFactory_1.IdentifierFactory.access(READER())("index"), undefined, undefined), typescript_1.default.factory.createIdentifier("piece")), typescript_1.default.factory.createExpressionStatement(typescript_1.default.factory.createCallExpression(IdentifierFactory_1.IdentifierFactory.access(props.accessor)("push"), undefined, [decoder()]))),
|
|
336
|
+
], true), typescript_1.default.factory.createExpressionStatement(typescript_1.default.factory.createCallExpression(IdentifierFactory_1.IdentifierFactory.access(props.accessor)("push"), undefined, [decoder()]))));
|
|
307
337
|
}
|
|
308
338
|
else
|
|
309
|
-
statements.push(typescript_1.default.factory.createCallExpression(IdentifierFactory_1.IdentifierFactory.access(accessor)("push"), undefined, [decoder()]));
|
|
339
|
+
statements.push(typescript_1.default.factory.createCallExpression(IdentifierFactory_1.IdentifierFactory.access(props.accessor)("push"), undefined, [decoder()]));
|
|
310
340
|
return statements.map(function (stmt) {
|
|
311
341
|
return typescript_1.default.isExpression(stmt) ? typescript_1.default.factory.createExpressionStatement(stmt) : stmt;
|
|
312
342
|
});
|
|
313
343
|
};
|
|
314
|
-
var decode_regular_object = function (
|
|
315
|
-
return
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
]
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
])), false));
|
|
323
|
-
};
|
|
344
|
+
var decode_regular_object = function (props) {
|
|
345
|
+
return typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier("".concat(PREFIX, "o").concat(props.object.index)), undefined, __spreadArray([
|
|
346
|
+
typescript_1.default.factory.createIdentifier("reader")
|
|
347
|
+
], __read((props.top
|
|
348
|
+
? []
|
|
349
|
+
: [
|
|
350
|
+
typescript_1.default.factory.createCallExpression(IdentifierFactory_1.IdentifierFactory.access(READER())("uint32"), undefined, undefined),
|
|
351
|
+
])), false));
|
|
324
352
|
};
|
|
325
|
-
var decode_dynamic_object = function (
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
};
|
|
353
|
+
var decode_dynamic_object = function (props) {
|
|
354
|
+
var top = props.object.properties[0];
|
|
355
|
+
return decode_entry({
|
|
356
|
+
context: props.context,
|
|
357
|
+
importer: props.importer,
|
|
358
|
+
initializer: function () {
|
|
359
|
+
return typescript_1.default.factory.createBinaryExpression(props.accessor, typescript_1.default.factory.createToken(typescript_1.default.SyntaxKind.QuestionQuestionEqualsToken), typescript_1.default.factory.createObjectLiteralExpression());
|
|
360
|
+
},
|
|
361
|
+
setter: function () {
|
|
362
|
+
return typescript_1.default.factory.createBinaryExpression(typescript_1.default.factory.createElementAccessExpression(props.accessor, typescript_1.default.factory.createIdentifier("entry.key")), typescript_1.default.factory.createToken(typescript_1.default.SyntaxKind.EqualsToken), typescript_1.default.factory.createIdentifier("entry.value"));
|
|
363
|
+
},
|
|
364
|
+
entry: MetadataProperty_1.MetadataProperty.create(__assign(__assign({}, top), { key: (function () {
|
|
365
|
+
var key = Metadata_1.Metadata.initialize();
|
|
366
|
+
key.atomics.push(MetadataAtomic_1.MetadataAtomic.create({
|
|
367
|
+
type: "string",
|
|
368
|
+
tags: [],
|
|
369
|
+
}));
|
|
370
|
+
return key;
|
|
371
|
+
})() })),
|
|
372
|
+
required: props.required,
|
|
373
|
+
});
|
|
346
374
|
};
|
|
347
|
-
var decode_map = function (
|
|
348
|
-
return
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
};
|
|
375
|
+
var decode_map = function (props) {
|
|
376
|
+
return decode_entry({
|
|
377
|
+
context: props.context,
|
|
378
|
+
importer: props.importer,
|
|
379
|
+
initializer: function () {
|
|
380
|
+
return typescript_1.default.factory.createBinaryExpression(props.accessor, typescript_1.default.factory.createToken(typescript_1.default.SyntaxKind.QuestionQuestionEqualsToken), typescript_1.default.factory.createNewExpression(typescript_1.default.factory.createIdentifier("Map"), [TypeFactory_1.TypeFactory.keyword("any"), TypeFactory_1.TypeFactory.keyword("any")], []));
|
|
381
|
+
},
|
|
382
|
+
setter: function () {
|
|
383
|
+
return typescript_1.default.factory.createCallExpression(IdentifierFactory_1.IdentifierFactory.access(props.accessor)("set"), undefined, [
|
|
384
|
+
typescript_1.default.factory.createIdentifier("entry.key"),
|
|
385
|
+
typescript_1.default.factory.createIdentifier("entry.value"),
|
|
386
|
+
]);
|
|
387
|
+
},
|
|
388
|
+
entry: props.entry,
|
|
389
|
+
required: props.required,
|
|
390
|
+
});
|
|
363
391
|
};
|
|
364
|
-
var decode_entry = function (
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
};
|
|
396
|
-
};
|
|
397
|
-
};
|
|
392
|
+
var decode_entry = function (props) {
|
|
393
|
+
var statements = __spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read((props.required
|
|
394
|
+
? []
|
|
395
|
+
: [typescript_1.default.factory.createExpressionStatement(props.initializer())])), false), [
|
|
396
|
+
StatementFactory_1.StatementFactory.constant("piece", typescript_1.default.factory.createAdd(typescript_1.default.factory.createCallExpression(IdentifierFactory_1.IdentifierFactory.access(READER())("uint32"), undefined, undefined), typescript_1.default.factory.createCallExpression(IdentifierFactory_1.IdentifierFactory.access(READER())("index"), undefined, undefined)))
|
|
397
|
+
], false), __read(write_object_function_body({
|
|
398
|
+
context: props.context,
|
|
399
|
+
importer: props.importer,
|
|
400
|
+
condition: typescript_1.default.factory.createLessThan(typescript_1.default.factory.createCallExpression(IdentifierFactory_1.IdentifierFactory.access(READER())("index"), undefined, undefined), typescript_1.default.factory.createIdentifier("piece")),
|
|
401
|
+
tag: "kind",
|
|
402
|
+
output: "entry",
|
|
403
|
+
properties: [
|
|
404
|
+
MetadataProperty_1.MetadataProperty.create({
|
|
405
|
+
key: MetadataFactory_1.MetadataFactory.soleLiteral("key"),
|
|
406
|
+
value: props.entry.key,
|
|
407
|
+
description: null,
|
|
408
|
+
jsDocTags: [],
|
|
409
|
+
}),
|
|
410
|
+
MetadataProperty_1.MetadataProperty.create({
|
|
411
|
+
key: MetadataFactory_1.MetadataFactory.soleLiteral("value"),
|
|
412
|
+
value: props.entry.value,
|
|
413
|
+
description: null,
|
|
414
|
+
jsDocTags: [],
|
|
415
|
+
}),
|
|
416
|
+
],
|
|
417
|
+
})), false), [
|
|
418
|
+
typescript_1.default.factory.createExpressionStatement(props.setter()),
|
|
419
|
+
], false);
|
|
420
|
+
return [
|
|
421
|
+
typescript_1.default.factory.createExpressionStatement(ExpressionFactory_1.ExpressionFactory.selfCall(typescript_1.default.factory.createBlock(statements, true))),
|
|
422
|
+
];
|
|
398
423
|
};
|
|
399
424
|
})(ProtobufDecodeProgrammer || (exports.ProtobufDecodeProgrammer = ProtobufDecodeProgrammer = {}));
|
|
400
425
|
var PREFIX = "$pd";
|