grpc-dc 0.32.14 → 0.32.15
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/package.json +1 -1
- package/plugin/gen/generators.js +31 -9
package/package.json
CHANGED
package/plugin/gen/generators.js
CHANGED
|
@@ -2846,7 +2846,8 @@ function emitCFile(model, params) {
|
|
|
2846
2846
|
+ ' grpcdc_bytes out; int r = grpcdc_stream_recv(s->raw, &out, st);\n'
|
|
2847
2847
|
+ ' if (r == 1) { memset(resp, 0, sizeof(*resp)); ' + resp + '_unmarshal(resp, out.data, out.len); grpcdc_bytes_free(&out); }\n'
|
|
2848
2848
|
+ ' return r;\n}\n\n'
|
|
2849
|
-
+ 'static inline void ' + S + m.name + 'Client_close(' + S + m.name + 'Client *s) { grpcdc_stream_free(s->raw); }\n\n'
|
|
2849
|
+
+ 'static inline void ' + S + m.name + 'Client_close(' + S + m.name + 'Client *s) { grpcdc_stream_free(s->raw); }\n\n'
|
|
2850
|
+
+ 'static inline void ' + S + m.name + 'Client_cancel(' + S + m.name + 'Client *s) { grpcdc_stream_cancel(s->raw); }\n\n');
|
|
2850
2851
|
} else if (m.kind === 'client-streaming') {
|
|
2851
2852
|
parts.push('static inline grpcdc_status ' + S + 'Client_' + name + '(' + S + 'Client *c, const ' + req + ' *reqs, size_t req_count, ' + resp + ' *resp, const grpcdc_kv *md, size_t md_count, int64_t deadline_ms) {\n'
|
|
2852
2853
|
+ ' grpcdc_stream *raw; grpcdc_status st;\n'
|
|
@@ -2878,7 +2879,8 @@ function emitCFile(model, params) {
|
|
|
2878
2879
|
+ ' grpcdc_bytes out; int r = grpcdc_stream_recv(s->raw, &out, st);\n'
|
|
2879
2880
|
+ ' if (r == 1) { memset(resp, 0, sizeof(*resp)); ' + resp + '_unmarshal(resp, out.data, out.len); grpcdc_bytes_free(&out); }\n'
|
|
2880
2881
|
+ ' return r;\n}\n\n'
|
|
2881
|
-
+ 'static inline void ' + S + m.name + 'Client_close(' + S + m.name + 'Client *s) { grpcdc_stream_free(s->raw); }\n\n'
|
|
2882
|
+
+ 'static inline void ' + S + m.name + 'Client_close(' + S + m.name + 'Client *s) { grpcdc_stream_free(s->raw); }\n\n'
|
|
2883
|
+
+ 'static inline void ' + S + m.name + 'Client_cancel(' + S + m.name + 'Client *s) { grpcdc_stream_cancel(s->raw); }\n\n');
|
|
2882
2884
|
}
|
|
2883
2885
|
}
|
|
2884
2886
|
// server stream helper types
|
|
@@ -5259,6 +5261,8 @@ function cppClientStreamClass(m, svc) {
|
|
|
5259
5261
|
+ ' const grpcdc::Metadata& Headers() const { return stream_.headers().metadata; }\n\n'
|
|
5260
5262
|
+ ' /// Trailing metadata of the terminal status.\n'
|
|
5261
5263
|
+ ' const grpcdc::Metadata& Trailers() const { return stream_.trailers(); }\n\n'
|
|
5264
|
+
+ ' /// Abort this stream (sends RST, wakes a pending Recv).\n'
|
|
5265
|
+
+ ' void Cancel() { stream_.Cancel(); }\n\n'
|
|
5262
5266
|
+ ' private:\n'
|
|
5263
5267
|
+ ' grpcdc::Channel::ClientStream stream_;\n };\n\n';
|
|
5264
5268
|
}
|
|
@@ -6106,6 +6110,20 @@ function emitCppFile(model, params) {
|
|
|
6106
6110
|
const base = baseName(model.name);
|
|
6107
6111
|
const structName = pascalName(base) + 'GrpcDc';
|
|
6108
6112
|
const ns = xppNs(model.package);
|
|
6113
|
+
// Qualify cross-package method types (::pkg::...::Type) so stub
|
|
6114
|
+
// code resolves message types from other proto files.
|
|
6115
|
+
const qual = (full, plain) =>
|
|
6116
|
+
(!model.package || !full.includes('.') || full.startsWith(model.package + '.'))
|
|
6117
|
+
? plain
|
|
6118
|
+
: '::' + full.split('.').join('::');
|
|
6119
|
+
const services = model.services.map((svc) => ({
|
|
6120
|
+
...svc,
|
|
6121
|
+
methods: svc.methods.map((m) => ({
|
|
6122
|
+
...m,
|
|
6123
|
+
input: qual(m.inputFull, m.input),
|
|
6124
|
+
output: qual(m.outputFull, m.output),
|
|
6125
|
+
})),
|
|
6126
|
+
}));
|
|
6109
6127
|
const stub = {
|
|
6110
6128
|
name: base + '_grpc_dc.hpp',
|
|
6111
6129
|
content: '// @generated by protoc-gen-grpc-dc-cpp. DO NOT EDIT.\n'
|
|
@@ -6118,7 +6136,7 @@ function emitCppFile(model, params) {
|
|
|
6118
6136
|
+ 'namespace ' + ns + ' {\n\n'
|
|
6119
6137
|
+ '/// Generated gRPC-over-DataChannels stubs for ' + model.name + '.\n'
|
|
6120
6138
|
+ 'struct ' + structName + ' {\n'
|
|
6121
|
-
+
|
|
6139
|
+
+ services.map(cppService).join('')
|
|
6122
6140
|
+ '};\n\n'
|
|
6123
6141
|
+ '} // namespace ' + ns + '\n',
|
|
6124
6142
|
};
|
|
@@ -8048,7 +8066,7 @@ function dtpEncodeSingular(model, f, v, indent, support) {
|
|
|
8048
8066
|
}
|
|
8049
8067
|
switch (f.type) {
|
|
8050
8068
|
case 9: return proto2
|
|
8051
|
-
? indent + 'w.bytesField(' + n + ',
|
|
8069
|
+
? indent + 'w.bytesField(' + n + ', utf8.encode(' + v + '));\n'
|
|
8052
8070
|
: indent + 'w.stringField(' + n + ', ' + v + ');\n';
|
|
8053
8071
|
case 12: return proto2
|
|
8054
8072
|
? indent + 'w.bytesField(' + n + ', ' + v + ');\n'
|
|
@@ -8096,7 +8114,7 @@ function dtpEncodeField(model, f, support) {
|
|
|
8096
8114
|
+ ' w.bytesField(' + n + ', payload.toBytes());\n }\n';
|
|
8097
8115
|
}
|
|
8098
8116
|
switch (f.type) {
|
|
8099
|
-
case 9: return ' for (final x in ' + v + ') { w.bytesField(' + n + ',
|
|
8117
|
+
case 9: return ' for (final x in ' + v + ') { w.bytesField(' + n + ', utf8.encode(x)); }\n';
|
|
8100
8118
|
case 12: return ' for (final x in ' + v + ') { w.bytesField(' + n + ', x); }\n';
|
|
8101
8119
|
case 11: return ' for (final x in ' + v + ') { w.bytesField(' + n + ', x.marshalDc()); }\n';
|
|
8102
8120
|
default: throw new Error('unsupported repeated field type ' + f.type);
|
|
@@ -8123,7 +8141,7 @@ function dtpDecodeSingular(model, f, target, src, indent, support) {
|
|
|
8123
8141
|
return indent + target + ' = ' + conv + ';\n';
|
|
8124
8142
|
}
|
|
8125
8143
|
switch (f.type) {
|
|
8126
|
-
case 9: return indent + target + ' =
|
|
8144
|
+
case 9: return indent + target + ' = utf8.decode(' + src + ');\n';
|
|
8127
8145
|
case 12: return indent + target + ' = ' + src + ';\n';
|
|
8128
8146
|
case 11: {
|
|
8129
8147
|
const ref = dtpTypeRef(model, dtpResolve(model, f.typeName));
|
|
@@ -8192,7 +8210,7 @@ function dtpDecodeCase(model, f, support) {
|
|
|
8192
8210
|
+ tail;
|
|
8193
8211
|
}
|
|
8194
8212
|
switch (f.type) {
|
|
8195
|
-
case 9: return head + ' ' + v + '.add(
|
|
8213
|
+
case 9: return head + ' ' + v + '.add(utf8.decode(field.bytesValue));\n' + tail;
|
|
8196
8214
|
case 12: return head + ' ' + v + '.add(field.bytesValue);\n' + tail;
|
|
8197
8215
|
case 11: return head
|
|
8198
8216
|
+ ' final item = ' + dtpTypeRef(model, dtpResolve(model, f.typeName)) + '();\n'
|
|
@@ -8239,6 +8257,7 @@ function dtpMapHelpers(model, entry, support) {
|
|
|
8239
8257
|
|
|
8240
8258
|
function dtpSupportHead(p) {
|
|
8241
8259
|
return '// @generated by protoc-gen-grpc-dc-dart. DO NOT EDIT.\n'
|
|
8260
|
+
+ "import 'dart:convert';\n"
|
|
8242
8261
|
+ "import 'dart:typed_data';\n\n"
|
|
8243
8262
|
+ "import '../grpcdc/transport.dart';\n\n"
|
|
8244
8263
|
+ 'class ' + p + 'Writer {\n'
|
|
@@ -8246,7 +8265,7 @@ function dtpSupportHead(p) {
|
|
|
8246
8265
|
+ ' void varint(int value) { var v = BigInt.from(value) & ((BigInt.one << 64) - BigInt.one); final continuation = BigInt.from(0x80); while (v >= continuation) { _out.addByte(((v & BigInt.from(0x7f)) | continuation).toInt()); v = v >> 7; } _out.addByte(v.toInt()); }\n'
|
|
8247
8266
|
+ ' void tag(int field, int wire) { varint((field << 3) | wire); }\n'
|
|
8248
8267
|
+ ' void bytesField(int field, List<int> payload) { tag(field, 2); varint(payload.length); _out.add(payload); }\n'
|
|
8249
|
-
+ ' void stringField(int field, String value) { if (value.isEmpty) return; bytesField(field,
|
|
8268
|
+
+ ' void stringField(int field, String value) { if (value.isEmpty) return; bytesField(field, utf8.encode(value)); }\n'
|
|
8250
8269
|
+ ' void fixedUint32(int value) { final b = ByteData(4); b.setUint32(0, value, Endian.little); _out.add(b.buffer.asUint8List()); }\n'
|
|
8251
8270
|
+ ' void fixedInt32(int value) { final b = ByteData(4); b.setInt32(0, value, Endian.little); _out.add(b.buffer.asUint8List()); }\n'
|
|
8252
8271
|
+ ' void fixedUint64(int value) { final b = ByteData(8); b.setUint64(0, value, Endian.little); _out.add(b.buffer.asUint8List()); }\n'
|
|
@@ -8458,6 +8477,9 @@ function zigClientStreamClass(m, svc) {
|
|
|
8458
8477
|
+ ' /// Trailing metadata of the terminal status.\n'
|
|
8459
8478
|
+ ' pub fn trailers(self: *' + svc + m.name + 'Client) []const status_mod.TrailerPair {\n'
|
|
8460
8479
|
+ ' return self.stream.trailers;\n }\n\n'
|
|
8480
|
+
+ ' /// Abandon the call: RST so the server stops producing.\n'
|
|
8481
|
+
+ ' pub fn cancel(self: *' + svc + m.name + 'Client) void {\n'
|
|
8482
|
+
+ ' self.stream.cancel();\n }\n\n'
|
|
8461
8483
|
+ ' pub fn deinit(self: *' + svc + m.name + 'Client) void {\n'
|
|
8462
8484
|
+ ' self.stream.deinit();\n }\n};\n\n';
|
|
8463
8485
|
}
|
|
@@ -9692,7 +9714,7 @@ function emitLuaPbFile(model) {
|
|
|
9692
9714
|
for (const m of model.messages) collect(m);
|
|
9693
9715
|
const allMsgNames = (msg) => msg.mapEntry ? [] : [lpFlat(model.package, msg.fullName), ...msg.nested.flatMap(allMsgNames)];
|
|
9694
9716
|
const deps = [...new Set((model.dependencies || []).map((d) => baseName(d)))];
|
|
9695
|
-
const depRequires = deps.map((d) => 'local ' + lpFlat('', d + '_messages') + 'Messages = require("' + d + '_messages")\n').join('');
|
|
9717
|
+
const depRequires = deps.map((d) => 'local ' + lpFlat('', d + '_messages') + 'Messages = require("examples.' + d + '_messages")\n').join('');
|
|
9696
9718
|
const content = LP_SUPPORT
|
|
9697
9719
|
+ depRequires
|
|
9698
9720
|
+ (depRequires ? '\n' : '')
|