Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(60)

Side by Side Diff: third_party/protobuf/src/google/protobuf/compiler/js/well_known_types_embed.cc

Issue 2495533002: third_party/protobuf: Update to HEAD (83d681ee2c) (Closed)
Patch Set: Make chrome settings proto generated file a component Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 #include <google/protobuf/compiler/js/well_known_types_embed.h>
2 struct FileToc well_known_types_js[] = {
3 {"any.js",
4 "// Protocol Buffers - Google's data interchange format\n"
5 "// Copyright 2008 Google Inc. All rights reserved.\n"
6 "// https://developers.google.com/protocol-buffers/\n"
7 "//\n"
8 "// Redistribution and use in source and binary forms, with or without\n"
9 "// modification, are permitted provided that the following conditions are\n"
10 "// met:\n"
11 "//\n"
12 "// * Redistributions of source code must retain the above copyright\n"
13 "// notice, this list of conditions and the following disclaimer.\n"
14 "// * Redistributions in binary form must reproduce the above\n"
15 "// copyright notice, this list of conditions and the following disclaimer\n"
16 "// in the documentation and/or other materials provided with the\n"
17 "// distribution.\n"
18 "// * Neither the name of Google Inc. nor the names of its\n"
19 "// contributors may be used to endorse or promote products derived from\n"
20 "// this software without specific prior written permission.\n"
21 "//\n"
22 "// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n"
23 "// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n"
24 "// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n"
25 "// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n"
26 "// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n"
27 "// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n"
28 "// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n"
29 "// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n"
30 "// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n"
31 "// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n"
32 "// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n"
33 "\n"
34 "/* This code will be inserted into generated code for\n"
35 " * google/protobuf/any.proto. */\n"
36 "\n"
37 "/**\n"
38 " * Returns the type name contained in this instance, if any.\n"
39 " * @return {string|undefined}\n"
40 " */\n"
41 "proto.google.protobuf.Any.prototype.getTypeName = function() {\n"
42 " return this.getTypeUrl().split('/').pop();\n"
43 "};\n"
44 "\n"
45 "\n"
46 "/**\n"
47 " * Packs the given message instance into this Any.\n"
48 " * @param {!Uint8Array} serialized The serialized data to pack.\n"
49 " * @param {string} name The type name of this message object.\n"
50 " * @param {string=} opt_typeUrlPrefix the type URL prefix.\n"
51 " */\n"
52 "proto.google.protobuf.Any.prototype.pack = function(serialized, name,\n"
53 " opt_typeUrlPrefix) {\n"
54 " if (!opt_typeUrlPrefix) {\n"
55 " opt_typeUrlPrefix = 'type.googleapis.com/';\n"
56 " }\n"
57 "\n"
58 " if (opt_typeUrlPrefix.substr(-1) != '/') {\n"
59 " this.setTypeUrl(opt_typeUrlPrefix + '/' + name);\n"
60 " } else {\n"
61 " this.setTypeUrl(opt_typeUrlPrefix + name);\n"
62 " }\n"
63 "\n"
64 " this.setValue(serialized);\n"
65 "};\n"
66 "\n"
67 "\n"
68 "/**\n"
69 " * @template T\n"
70 " * Unpacks this Any into the given message object.\n"
71 " * @param {function(Uint8Array):T} deserialize Function that will deserialize \n"
72 " * the binary data properly.\n"
73 " * @param {string} name The expected type name of this message object.\n"
74 " * @return {?T} If the name matched the expected name, returns the deserializ ed\n"
75 " * object, otherwise returns undefined.\n"
76 " */\n"
77 "proto.google.protobuf.Any.prototype.unpack = function(deserialize, name) {\n"
78 " if (this.getTypeName() == name) {\n"
79 " return deserialize(this.getValue_asU8());\n"
80 " } else {\n"
81 " return null;\n"
82 " }\n"
83 "};\n"
84 },
85 {"timestamp.js",
86 "// Protocol Buffers - Google's data interchange format\n"
87 "// Copyright 2008 Google Inc. All rights reserved.\n"
88 "// https://developers.google.com/protocol-buffers/\n"
89 "//\n"
90 "// Redistribution and use in source and binary forms, with or without\n"
91 "// modification, are permitted provided that the following conditions are\n"
92 "// met:\n"
93 "//\n"
94 "// * Redistributions of source code must retain the above copyright\n"
95 "// notice, this list of conditions and the following disclaimer.\n"
96 "// * Redistributions in binary form must reproduce the above\n"
97 "// copyright notice, this list of conditions and the following disclaimer\n"
98 "// in the documentation and/or other materials provided with the\n"
99 "// distribution.\n"
100 "// * Neither the name of Google Inc. nor the names of its\n"
101 "// contributors may be used to endorse or promote products derived from\n"
102 "// this software without specific prior written permission.\n"
103 "//\n"
104 "// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n"
105 "// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n"
106 "// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n"
107 "// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n"
108 "// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n"
109 "// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n"
110 "// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n"
111 "// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n"
112 "// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n"
113 "// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n"
114 "// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n"
115 "\n"
116 "/* This code will be inserted into generated code for\n"
117 " * google/protobuf/timestamp.proto. */\n"
118 "\n"
119 "/**\n"
120 " * Returns a JavaScript 'Date' object corresponding to this Timestamp.\n"
121 " * @return {!Date}\n"
122 " */\n"
123 "proto.google.protobuf.Timestamp.prototype.toDate = function() {\n"
124 " // The '|| 0' clauses are necessary for as long as\n"
125 " // broken_proto3_semantics are specified for this rule inside Google.\n"
126 " var seconds = this.getSeconds() || 0;\n"
127 " var nanos = this.getNanos() || 0;\n"
128 "\n"
129 " return new Date((seconds * 1000) + (nanos / 1000000));\n"
130 "};\n"
131 "\n"
132 "\n"
133 "/**\n"
134 " * Sets the value of this Timestamp object to be the given Date.\n"
135 " * @param {!Date} value The value to set.\n"
136 " */\n"
137 "proto.google.protobuf.Timestamp.prototype.fromDate = function(value) {\n"
138 " var millis = value.getTime();\n"
139 " this.setSeconds(Math.floor(value.getTime() / 1000));\n"
140 " this.setNanos(value.getMilliseconds() * 1000000);\n"
141 "};\n"
142 },
143 {"struct.js",
144 "// Protocol Buffers - Google's data interchange format\n"
145 "// Copyright 2008 Google Inc. All rights reserved.\n"
146 "// https://developers.google.com/protocol-buffers/\n"
147 "//\n"
148 "// Redistribution and use in source and binary forms, with or without\n"
149 "// modification, are permitted provided that the following conditions are\n"
150 "// met:\n"
151 "//\n"
152 "// * Redistributions of source code must retain the above copyright\n"
153 "// notice, this list of conditions and the following disclaimer.\n"
154 "// * Redistributions in binary form must reproduce the above\n"
155 "// copyright notice, this list of conditions and the following disclaimer\n"
156 "// in the documentation and/or other materials provided with the\n"
157 "// distribution.\n"
158 "// * Neither the name of Google Inc. nor the names of its\n"
159 "// contributors may be used to endorse or promote products derived from\n"
160 "// this software without specific prior written permission.\n"
161 "//\n"
162 "// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n"
163 "// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n"
164 "// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n"
165 "// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n"
166 "// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n"
167 "// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n"
168 "// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n"
169 "// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n"
170 "// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n"
171 "// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n"
172 "// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n"
173 "\n"
174 "/* This code will be inserted into generated code for\n"
175 " * google/protobuf/struct.proto. */\n"
176 "\n"
177 "/**\n"
178 " * Typedef representing plain JavaScript values that can go into a\n"
179 " * Struct.\n"
180 " * @typedef {null|number|string|boolean|Array|Object}\n"
181 " */\n"
182 "proto.google.protobuf.JavaScriptValue;\n"
183 "\n"
184 "\n"
185 "/**\n"
186 " * Converts this Value object to a plain JavaScript value.\n"
187 " * @return {?proto.google.protobuf.JavaScriptValue} a plain JavaScript\n"
188 " * value representing this Struct.\n"
189 " */\n"
190 "proto.google.protobuf.Value.prototype.toJavaScript = function() {\n"
191 " var kindCase = proto.google.protobuf.Value.KindCase;\n"
192 " switch (this.getKindCase()) {\n"
193 " case kindCase.NULL_VALUE:\n"
194 " return null;\n"
195 " case kindCase.NUMBER_VALUE:\n"
196 " return this.getNumberValue();\n"
197 " case kindCase.STRING_VALUE:\n"
198 " return this.getStringValue();\n"
199 " case kindCase.BOOL_VALUE:\n"
200 " return this.getBoolValue();\n"
201 " case kindCase.STRUCT_VALUE:\n"
202 " return this.getStructValue().toJavaScript();\n"
203 " case kindCase.LIST_VALUE:\n"
204 " return this.getListValue().toJavaScript();\n"
205 " default:\n"
206 " throw new Error('Unexpected struct type');\n"
207 " }\n"
208 "};\n"
209 "\n"
210 "\n"
211 "/**\n"
212 " * Converts this JavaScript value to a new Value proto.\n"
213 " * @param {!proto.google.protobuf.JavaScriptValue} value The value to\n"
214 " * convert.\n"
215 " * @return {!proto.google.protobuf.Value} The newly constructed value.\n"
216 " */\n"
217 "proto.google.protobuf.Value.fromJavaScript = function(value) {\n"
218 " var ret = new proto.google.protobuf.Value();\n"
219 " switch (goog.typeOf(value)) {\n"
220 " case 'string':\n"
221 " ret.setStringValue(/** @type {string} */ (value));\n"
222 " break;\n"
223 " case 'number':\n"
224 " ret.setNumberValue(/** @type {number} */ (value));\n"
225 " break;\n"
226 " case 'boolean':\n"
227 " ret.setBoolValue(/** @type {boolean} */ (value));\n"
228 " break;\n"
229 " case 'null':\n"
230 " ret.setNullValue(proto.google.protobuf.NullValue.NULL_VALUE);\n"
231 " break;\n"
232 " case 'array':\n"
233 " ret.setListValue(proto.google.protobuf.ListValue.fromJavaScript(\n"
234 " /** @type{!Array} */ (value)));\n"
235 " break;\n"
236 " case 'object':\n"
237 " ret.setStructValue(proto.google.protobuf.Struct.fromJavaScript(\n"
238 " /** @type{!Object} */ (value)));\n"
239 " break;\n"
240 " default:\n"
241 " throw new Error('Unexpected struct type.');\n"
242 " }\n"
243 "\n"
244 " return ret;\n"
245 "};\n"
246 "\n"
247 "\n"
248 "/**\n"
249 " * Converts this ListValue object to a plain JavaScript array.\n"
250 " * @return {!Array} a plain JavaScript array representing this List.\n"
251 " */\n"
252 "proto.google.protobuf.ListValue.prototype.toJavaScript = function() {\n"
253 " var ret = [];\n"
254 " var values = this.getValuesList();\n"
255 "\n"
256 " for (var i = 0; i < values.length; i++) {\n"
257 " ret[i] = values[i].toJavaScript();\n"
258 " }\n"
259 "\n"
260 " return ret;\n"
261 "};\n"
262 "\n"
263 "\n"
264 "/**\n"
265 " * Constructs a ListValue protobuf from this plain JavaScript array.\n"
266 " * @param {!Array} array a plain JavaScript array\n"
267 " * @return {proto.google.protobuf.ListValue} a new ListValue object\n"
268 " */\n"
269 "proto.google.protobuf.ListValue.fromJavaScript = function(array) {\n"
270 " var ret = new proto.google.protobuf.ListValue();\n"
271 "\n"
272 " for (var i = 0; i < array.length; i++) {\n"
273 " ret.addValues(proto.google.protobuf.Value.fromJavaScript(array[i]));\n"
274 " }\n"
275 "\n"
276 " return ret;\n"
277 "};\n"
278 "\n"
279 "\n"
280 "/**\n"
281 " * Converts this Struct object to a plain JavaScript object.\n"
282 " * @return {!Object<string, !proto.google.protobuf.JavaScriptValue>} a plain\ n"
283 " * JavaScript object representing this Struct.\n"
284 " */\n"
285 "proto.google.protobuf.Struct.prototype.toJavaScript = function() {\n"
286 " var ret = {};\n"
287 "\n"
288 " this.getFieldsMap().forEach(function(value, key) {\n"
289 " ret[key] = value.toJavaScript();\n"
290 " });\n"
291 "\n"
292 " return ret;\n"
293 "};\n"
294 "\n"
295 "\n"
296 "/**\n"
297 " * Constructs a Struct protobuf from this plain JavaScript object.\n"
298 " * @param {!Object} obj a plain JavaScript object\n"
299 " * @return {proto.google.protobuf.Struct} a new Struct object\n"
300 " */\n"
301 "proto.google.protobuf.Struct.fromJavaScript = function(obj) {\n"
302 " var ret = new proto.google.protobuf.Struct();\n"
303 " var map = ret.getFieldsMap();\n"
304 "\n"
305 " for (var property in obj) {\n"
306 " var val = obj[property];\n"
307 " map.set(property, proto.google.protobuf.Value.fromJavaScript(val));\n"
308 " }\n"
309 "\n"
310 " return ret;\n"
311 "};\n"
312 },
313 {NULL, NULL} // Terminate the list.
314 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698