File: protobuf_generated_well_known_types_embed.cc

package info (click to toggle)
python-grpc-tools 1.14.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 13,912 kB
  • sloc: cpp: 168,018; makefile: 874; python: 210; sh: 57
file content (328 lines) | stat: -rw-r--r-- 13,839 bytes parent folder | download
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
318
319
320
321
322
323
324
325
326
327
328
// Copyright 2017 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// HACK: Embed the generated well_known_types_js.cc to make
// grpc-tools python package compilation easy.
#include <google/protobuf/compiler/js/well_known_types_embed.h>
struct FileToc well_known_types_js[] = {
{"any.js",
  "// Protocol Buffers - Google's data interchange format\n"
  "// Copyright 2008 Google Inc.  All rights reserved.\n"
  "// https://developers.google.com/protocol-buffers/\n"
  "//\n"
  "// Redistribution and use in source and binary forms, with or without\n"
  "// modification, are permitted provided that the following conditions are\n"
  "// met:\n"
  "//\n"
  "//     * Redistributions of source code must retain the above copyright\n"
  "// notice, this list of conditions and the following disclaimer.\n"
  "//     * Redistributions in binary form must reproduce the above\n"
  "// copyright notice, this list of conditions and the following disclaimer\n"
  "// in the documentation and/or other materials provided with the\n"
  "// distribution.\n"
  "//     * Neither the name of Google Inc. nor the names of its\n"
  "// contributors may be used to endorse or promote products derived from\n"
  "// this software without specific prior written permission.\n"
  "//\n"
  "// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n"
  "// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n"
  "// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n"
  "// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n"
  "// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n"
  "// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n"
  "// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n"
  "// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n"
  "// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n"
  "// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n"
  "// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n"
  "\n"
  "/* This code will be inserted into generated code for\n"
  " * google/protobuf/any.proto. */\n"
  "\n"
  "/**\n"
  " * Returns the type name contained in this instance, if any.\n"
  " * @return {string|undefined}\n"
  " */\n"
  "proto.google.protobuf.Any.prototype.getTypeName = function() {\n"
  "  return this.getTypeUrl().split('/').pop();\n"
  "};\n"
  "\n"
  "\n"
  "/**\n"
  " * Packs the given message instance into this Any.\n"
  " * @param {!Uint8Array} serialized The serialized data to pack.\n"
  " * @param {string} name The type name of this message object.\n"
  " * @param {string=} opt_typeUrlPrefix the type URL prefix.\n"
  " */\n"
  "proto.google.protobuf.Any.prototype.pack = function(serialized, name,\n"
  "                                                    opt_typeUrlPrefix) {\n"
  "  if (!opt_typeUrlPrefix) {\n"
  "    opt_typeUrlPrefix = 'type.googleapis.com/';\n"
  "  }\n"
  "\n"
  "  if (opt_typeUrlPrefix.substr(-1) != '/') {\n"
  "    this.setTypeUrl(opt_typeUrlPrefix + '/' + name);\n"
  "  } else {\n"
  "    this.setTypeUrl(opt_typeUrlPrefix + name);\n"
  "  }\n"
  "\n"
  "  this.setValue(serialized);\n"
  "};\n"
  "\n"
  "\n"
  "/**\n"
  " * @template T\n"
  " * Unpacks this Any into the given message object.\n"
  " * @param {function(Uint8Array):T} deserialize Function that will deserialize\n"
  " *     the binary data properly.\n"
  " * @param {string} name The expected type name of this message object.\n"
  " * @return {?T} If the name matched the expected name, returns the deserialized\n"
  " *     object, otherwise returns undefined.\n"
  " */\n"
  "proto.google.protobuf.Any.prototype.unpack = function(deserialize, name) {\n"
  "  if (this.getTypeName() == name) {\n"
  "    return deserialize(this.getValue_asU8());\n"
  "  } else {\n"
  "    return null;\n"
  "  }\n"
  "};\n"
},
{"struct.js",
  "// Protocol Buffers - Google's data interchange format\n"
  "// Copyright 2008 Google Inc.  All rights reserved.\n"
  "// https://developers.google.com/protocol-buffers/\n"
  "//\n"
  "// Redistribution and use in source and binary forms, with or without\n"
  "// modification, are permitted provided that the following conditions are\n"
  "// met:\n"
  "//\n"
  "//     * Redistributions of source code must retain the above copyright\n"
  "// notice, this list of conditions and the following disclaimer.\n"
  "//     * Redistributions in binary form must reproduce the above\n"
  "// copyright notice, this list of conditions and the following disclaimer\n"
  "// in the documentation and/or other materials provided with the\n"
  "// distribution.\n"
  "//     * Neither the name of Google Inc. nor the names of its\n"
  "// contributors may be used to endorse or promote products derived from\n"
  "// this software without specific prior written permission.\n"
  "//\n"
  "// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n"
  "// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n"
  "// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n"
  "// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n"
  "// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n"
  "// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n"
  "// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n"
  "// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n"
  "// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n"
  "// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n"
  "// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n"
  "\n"
  "/* This code will be inserted into generated code for\n"
  " * google/protobuf/struct.proto. */\n"
  "\n"
  "/**\n"
  " * Typedef representing plain JavaScript values that can go into a\n"
  " *     Struct.\n"
  " * @typedef {null|number|string|boolean|Array|Object}\n"
  " */\n"
  "proto.google.protobuf.JavaScriptValue;\n"
  "\n"
  "\n"
  "/**\n"
  " * Converts this Value object to a plain JavaScript value.\n"
  " * @return {?proto.google.protobuf.JavaScriptValue} a plain JavaScript\n"
  " *     value representing this Struct.\n"
  " */\n"
  "proto.google.protobuf.Value.prototype.toJavaScript = function() {\n"
  "  var kindCase = proto.google.protobuf.Value.KindCase;\n"
  "  switch (this.getKindCase()) {\n"
  "    case kindCase.NULL_VALUE:\n"
  "      return null;\n"
  "    case kindCase.NUMBER_VALUE:\n"
  "      return this.getNumberValue();\n"
  "    case kindCase.STRING_VALUE:\n"
  "      return this.getStringValue();\n"
  "    case kindCase.BOOL_VALUE:\n"
  "      return this.getBoolValue();\n"
  "    case kindCase.STRUCT_VALUE:\n"
  "      return this.getStructValue().toJavaScript();\n"
  "    case kindCase.LIST_VALUE:\n"
  "      return this.getListValue().toJavaScript();\n"
  "    default:\n"
  "      throw new Error('Unexpected struct type');\n"
  "  }\n"
  "};\n"
  "\n"
  "\n"
  "/**\n"
  " * Converts this JavaScript value to a new Value proto.\n"
  " * @param {!proto.google.protobuf.JavaScriptValue} value The value to\n"
  " *     convert.\n"
  " * @return {!proto.google.protobuf.Value} The newly constructed value.\n"
  " */\n"
  "proto.google.protobuf.Value.fromJavaScript = function(value) {\n"
  "  var ret = new proto.google.protobuf.Value();\n"
  "  switch (goog.typeOf(value)) {\n"
  "    case 'string':\n"
  "      ret.setStringValue(/** @type {string} */ (value));\n"
  "      break;\n"
  "    case 'number':\n"
  "      ret.setNumberValue(/** @type {number} */ (value));\n"
  "      break;\n"
  "    case 'boolean':\n"
  "      ret.setBoolValue(/** @type {boolean} */ (value));\n"
  "      break;\n"
  "    case 'null':\n"
  "      ret.setNullValue(proto.google.protobuf.NullValue.NULL_VALUE);\n"
  "      break;\n"
  "    case 'array':\n"
  "      ret.setListValue(proto.google.protobuf.ListValue.fromJavaScript(\n"
  "          /** @type{!Array} */ (value)));\n"
  "      break;\n"
  "    case 'object':\n"
  "      ret.setStructValue(proto.google.protobuf.Struct.fromJavaScript(\n"
  "          /** @type{!Object} */ (value)));\n"
  "      break;\n"
  "    default:\n"
  "      throw new Error('Unexpected struct type.');\n"
  "  }\n"
  "\n"
  "  return ret;\n"
  "};\n"
  "\n"
  "\n"
  "/**\n"
  " * Converts this ListValue object to a plain JavaScript array.\n"
  " * @return {!Array} a plain JavaScript array representing this List.\n"
  " */\n"
  "proto.google.protobuf.ListValue.prototype.toJavaScript = function() {\n"
  "  var ret = [];\n"
  "  var values = this.getValuesList();\n"
  "\n"
  "  for (var i = 0; i < values.length; i++) {\n"
  "    ret[i] = values[i].toJavaScript();\n"
  "  }\n"
  "\n"
  "  return ret;\n"
  "};\n"
  "\n"
  "\n"
  "/**\n"
  " * Constructs a ListValue protobuf from this plain JavaScript array.\n"
  " * @param {!Array} array a plain JavaScript array\n"
  " * @return {proto.google.protobuf.ListValue} a new ListValue object\n"
  " */\n"
  "proto.google.protobuf.ListValue.fromJavaScript = function(array) {\n"
  "  var ret = new proto.google.protobuf.ListValue();\n"
  "\n"
  "  for (var i = 0; i < array.length; i++) {\n"
  "    ret.addValues(proto.google.protobuf.Value.fromJavaScript(array[i]));\n"
  "  }\n"
  "\n"
  "  return ret;\n"
  "};\n"
  "\n"
  "\n"
  "/**\n"
  " * Converts this Struct object to a plain JavaScript object.\n"
  " * @return {!Object<string, !proto.google.protobuf.JavaScriptValue>} a plain\n"
  " *     JavaScript object representing this Struct.\n"
  " */\n"
  "proto.google.protobuf.Struct.prototype.toJavaScript = function() {\n"
  "  var ret = {};\n"
  "\n"
  "  this.getFieldsMap().forEach(function(value, key) {\n"
  "    ret[key] = value.toJavaScript();\n"
  "  });\n"
  "\n"
  "  return ret;\n"
  "};\n"
  "\n"
  "\n"
  "/**\n"
  " * Constructs a Struct protobuf from this plain JavaScript object.\n"
  " * @param {!Object} obj a plain JavaScript object\n"
  " * @return {proto.google.protobuf.Struct} a new Struct object\n"
  " */\n"
  "proto.google.protobuf.Struct.fromJavaScript = function(obj) {\n"
  "  var ret = new proto.google.protobuf.Struct();\n"
  "  var map = ret.getFieldsMap();\n"
  "\n"
  "  for (var property in obj) {\n"
  "    var val = obj[property];\n"
  "    map.set(property, proto.google.protobuf.Value.fromJavaScript(val));\n"
  "  }\n"
  "\n"
  "  return ret;\n"
  "};\n"
},
{"timestamp.js",
  "// Protocol Buffers - Google's data interchange format\n"
  "// Copyright 2008 Google Inc.  All rights reserved.\n"
  "// https://developers.google.com/protocol-buffers/\n"
  "//\n"
  "// Redistribution and use in source and binary forms, with or without\n"
  "// modification, are permitted provided that the following conditions are\n"
  "// met:\n"
  "//\n"
  "//     * Redistributions of source code must retain the above copyright\n"
  "// notice, this list of conditions and the following disclaimer.\n"
  "//     * Redistributions in binary form must reproduce the above\n"
  "// copyright notice, this list of conditions and the following disclaimer\n"
  "// in the documentation and/or other materials provided with the\n"
  "// distribution.\n"
  "//     * Neither the name of Google Inc. nor the names of its\n"
  "// contributors may be used to endorse or promote products derived from\n"
  "// this software without specific prior written permission.\n"
  "//\n"
  "// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n"
  "// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n"
  "// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n"
  "// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n"
  "// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n"
  "// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n"
  "// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n"
  "// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n"
  "// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n"
  "// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n"
  "// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n"
  "\n"
  "/* This code will be inserted into generated code for\n"
  " * google/protobuf/timestamp.proto. */\n"
  "\n"
  "/**\n"
  " * Returns a JavaScript 'Date' object corresponding to this Timestamp.\n"
  " * @return {!Date}\n"
  " */\n"
  "proto.google.protobuf.Timestamp.prototype.toDate = function() {\n"
  "  var seconds = this.getSeconds();\n"
  "  var nanos = this.getNanos();\n"
  "\n"
  "  return new Date((seconds * 1000) + (nanos / 1000000));\n"
  "};\n"
  "\n"
  "\n"
  "/**\n"
  " * Sets the value of this Timestamp object to be the given Date.\n"
  " * @param {!Date} value The value to set.\n"
  " */\n"
  "proto.google.protobuf.Timestamp.prototype.fromDate = function(value) {\n"
  "  var millis = value.getTime();\n"
  "  this.setSeconds(Math.floor(value.getTime() / 1000));\n"
  "  this.setNanos(value.getMilliseconds() * 1000000);\n"
  "};\n"
},
  {NULL, NULL}  // Terminate the list.
};