google-protobuf 3.19.6-x86-mingw32 → 3.20.0.rc.1-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of google-protobuf might be problematic. Click here for more details.

@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 Yibo Cai
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,395 @@
1
+
2
+ /*
3
+ * http://www.unicode.org/versions/Unicode6.0.0/ch03.pdf - page 94
4
+ *
5
+ * Table 3-7. Well-Formed UTF-8 Byte Sequences
6
+ *
7
+ * +--------------------+------------+-------------+------------+-------------+
8
+ * | Code Points | First Byte | Second Byte | Third Byte | Fourth Byte |
9
+ * +--------------------+------------+-------------+------------+-------------+
10
+ * | U+0000..U+007F | 00..7F | | | |
11
+ * +--------------------+------------+-------------+------------+-------------+
12
+ * | U+0080..U+07FF | C2..DF | 80..BF | | |
13
+ * +--------------------+------------+-------------+------------+-------------+
14
+ * | U+0800..U+0FFF | E0 | A0..BF | 80..BF | |
15
+ * +--------------------+------------+-------------+------------+-------------+
16
+ * | U+1000..U+CFFF | E1..EC | 80..BF | 80..BF | |
17
+ * +--------------------+------------+-------------+------------+-------------+
18
+ * | U+D000..U+D7FF | ED | 80..9F | 80..BF | |
19
+ * +--------------------+------------+-------------+------------+-------------+
20
+ * | U+E000..U+FFFF | EE..EF | 80..BF | 80..BF | |
21
+ * +--------------------+------------+-------------+------------+-------------+
22
+ * | U+10000..U+3FFFF | F0 | 90..BF | 80..BF | 80..BF |
23
+ * +--------------------+------------+-------------+------------+-------------+
24
+ * | U+40000..U+FFFFF | F1..F3 | 80..BF | 80..BF | 80..BF |
25
+ * +--------------------+------------+-------------+------------+-------------+
26
+ * | U+100000..U+10FFFF | F4 | 80..8F | 80..BF | 80..BF |
27
+ * +--------------------+------------+-------------+------------+-------------+
28
+ */
29
+
30
+ /* Return 0 - success, >0 - index(1 based) of first error char */
31
+ int utf8_naive(const unsigned char* data, int len) {
32
+ int err_pos = 1;
33
+
34
+ while (len) {
35
+ int bytes;
36
+ const unsigned char byte1 = data[0];
37
+
38
+ /* 00..7F */
39
+ if (byte1 <= 0x7F) {
40
+ bytes = 1;
41
+ /* C2..DF, 80..BF */
42
+ } else if (len >= 2 && byte1 >= 0xC2 && byte1 <= 0xDF &&
43
+ (signed char)data[1] <= (signed char)0xBF) {
44
+ bytes = 2;
45
+ } else if (len >= 3) {
46
+ const unsigned char byte2 = data[1];
47
+
48
+ /* Is byte2, byte3 between 0x80 ~ 0xBF */
49
+ const int byte2_ok = (signed char)byte2 <= (signed char)0xBF;
50
+ const int byte3_ok = (signed char)data[2] <= (signed char)0xBF;
51
+
52
+ if (byte2_ok && byte3_ok &&
53
+ /* E0, A0..BF, 80..BF */
54
+ ((byte1 == 0xE0 && byte2 >= 0xA0) ||
55
+ /* E1..EC, 80..BF, 80..BF */
56
+ (byte1 >= 0xE1 && byte1 <= 0xEC) ||
57
+ /* ED, 80..9F, 80..BF */
58
+ (byte1 == 0xED && byte2 <= 0x9F) ||
59
+ /* EE..EF, 80..BF, 80..BF */
60
+ (byte1 >= 0xEE && byte1 <= 0xEF))) {
61
+ bytes = 3;
62
+ } else if (len >= 4) {
63
+ /* Is byte4 between 0x80 ~ 0xBF */
64
+ const int byte4_ok = (signed char)data[3] <= (signed char)0xBF;
65
+
66
+ if (byte2_ok && byte3_ok && byte4_ok &&
67
+ /* F0, 90..BF, 80..BF, 80..BF */
68
+ ((byte1 == 0xF0 && byte2 >= 0x90) ||
69
+ /* F1..F3, 80..BF, 80..BF, 80..BF */
70
+ (byte1 >= 0xF1 && byte1 <= 0xF3) ||
71
+ /* F4, 80..8F, 80..BF, 80..BF */
72
+ (byte1 == 0xF4 && byte2 <= 0x8F))) {
73
+ bytes = 4;
74
+ } else {
75
+ return err_pos;
76
+ }
77
+ } else {
78
+ return err_pos;
79
+ }
80
+ } else {
81
+ return err_pos;
82
+ }
83
+
84
+ len -= bytes;
85
+ err_pos += bytes;
86
+ data += bytes;
87
+ }
88
+
89
+ return 0;
90
+ }
91
+
92
+ #ifdef __SSE4_1__
93
+
94
+ #include <stdint.h>
95
+ #include <stdio.h>
96
+ #include <x86intrin.h>
97
+
98
+ int utf8_naive(const unsigned char* data, int len);
99
+
100
+ static const int8_t _first_len_tbl[] = {
101
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 3,
102
+ };
103
+
104
+ static const int8_t _first_range_tbl[] = {
105
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 8, 8, 8,
106
+ };
107
+
108
+ static const int8_t _range_min_tbl[] = {
109
+ 0x00, 0x80, 0x80, 0x80, 0xA0, 0x80, 0x90, 0x80,
110
+ 0xC2, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F,
111
+ };
112
+ static const int8_t _range_max_tbl[] = {
113
+ 0x7F, 0xBF, 0xBF, 0xBF, 0xBF, 0x9F, 0xBF, 0x8F,
114
+ 0xF4, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
115
+ };
116
+
117
+ static const int8_t _df_ee_tbl[] = {
118
+ 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0,
119
+ };
120
+ static const int8_t _ef_fe_tbl[] = {
121
+ 0, 3, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
122
+ };
123
+
124
+ /* Return 0 on success, -1 on error */
125
+ int utf8_range2(const unsigned char* data, int len) {
126
+ if (len >= 32) {
127
+ __m128i prev_input = _mm_set1_epi8(0);
128
+ __m128i prev_first_len = _mm_set1_epi8(0);
129
+
130
+ const __m128i first_len_tbl =
131
+ _mm_loadu_si128((const __m128i*)_first_len_tbl);
132
+ const __m128i first_range_tbl =
133
+ _mm_loadu_si128((const __m128i*)_first_range_tbl);
134
+ const __m128i range_min_tbl =
135
+ _mm_loadu_si128((const __m128i*)_range_min_tbl);
136
+ const __m128i range_max_tbl =
137
+ _mm_loadu_si128((const __m128i*)_range_max_tbl);
138
+ const __m128i df_ee_tbl = _mm_loadu_si128((const __m128i*)_df_ee_tbl);
139
+ const __m128i ef_fe_tbl = _mm_loadu_si128((const __m128i*)_ef_fe_tbl);
140
+
141
+ __m128i error = _mm_set1_epi8(0);
142
+
143
+ while (len >= 32) {
144
+ /***************************** block 1 ****************************/
145
+ const __m128i input_a = _mm_loadu_si128((const __m128i*)data);
146
+
147
+ __m128i high_nibbles =
148
+ _mm_and_si128(_mm_srli_epi16(input_a, 4), _mm_set1_epi8(0x0F));
149
+
150
+ __m128i first_len_a = _mm_shuffle_epi8(first_len_tbl, high_nibbles);
151
+
152
+ __m128i range_a = _mm_shuffle_epi8(first_range_tbl, high_nibbles);
153
+
154
+ range_a = _mm_or_si128(range_a,
155
+ _mm_alignr_epi8(first_len_a, prev_first_len, 15));
156
+
157
+ __m128i tmp;
158
+ tmp = _mm_alignr_epi8(first_len_a, prev_first_len, 14);
159
+ tmp = _mm_subs_epu8(tmp, _mm_set1_epi8(1));
160
+ range_a = _mm_or_si128(range_a, tmp);
161
+
162
+ tmp = _mm_alignr_epi8(first_len_a, prev_first_len, 13);
163
+ tmp = _mm_subs_epu8(tmp, _mm_set1_epi8(2));
164
+ range_a = _mm_or_si128(range_a, tmp);
165
+
166
+ __m128i shift1, pos, range2;
167
+ shift1 = _mm_alignr_epi8(input_a, prev_input, 15);
168
+ pos = _mm_sub_epi8(shift1, _mm_set1_epi8(0xEF));
169
+ tmp = _mm_subs_epu8(pos, _mm_set1_epi8(0xF0));
170
+ range2 = _mm_shuffle_epi8(df_ee_tbl, tmp);
171
+ tmp = _mm_adds_epu8(pos, _mm_set1_epi8(0x70));
172
+ range2 = _mm_add_epi8(range2, _mm_shuffle_epi8(ef_fe_tbl, tmp));
173
+
174
+ range_a = _mm_add_epi8(range_a, range2);
175
+
176
+ __m128i minv = _mm_shuffle_epi8(range_min_tbl, range_a);
177
+ __m128i maxv = _mm_shuffle_epi8(range_max_tbl, range_a);
178
+
179
+ tmp = _mm_or_si128(_mm_cmplt_epi8(input_a, minv),
180
+ _mm_cmpgt_epi8(input_a, maxv));
181
+ error = _mm_or_si128(error, tmp);
182
+
183
+ /***************************** block 2 ****************************/
184
+ const __m128i input_b = _mm_loadu_si128((const __m128i*)(data + 16));
185
+
186
+ high_nibbles =
187
+ _mm_and_si128(_mm_srli_epi16(input_b, 4), _mm_set1_epi8(0x0F));
188
+
189
+ __m128i first_len_b = _mm_shuffle_epi8(first_len_tbl, high_nibbles);
190
+
191
+ __m128i range_b = _mm_shuffle_epi8(first_range_tbl, high_nibbles);
192
+
193
+ range_b =
194
+ _mm_or_si128(range_b, _mm_alignr_epi8(first_len_b, first_len_a, 15));
195
+
196
+ tmp = _mm_alignr_epi8(first_len_b, first_len_a, 14);
197
+ tmp = _mm_subs_epu8(tmp, _mm_set1_epi8(1));
198
+ range_b = _mm_or_si128(range_b, tmp);
199
+
200
+ tmp = _mm_alignr_epi8(first_len_b, first_len_a, 13);
201
+ tmp = _mm_subs_epu8(tmp, _mm_set1_epi8(2));
202
+ range_b = _mm_or_si128(range_b, tmp);
203
+
204
+ shift1 = _mm_alignr_epi8(input_b, input_a, 15);
205
+ pos = _mm_sub_epi8(shift1, _mm_set1_epi8(0xEF));
206
+ tmp = _mm_subs_epu8(pos, _mm_set1_epi8(0xF0));
207
+ range2 = _mm_shuffle_epi8(df_ee_tbl, tmp);
208
+ tmp = _mm_adds_epu8(pos, _mm_set1_epi8(0x70));
209
+ range2 = _mm_add_epi8(range2, _mm_shuffle_epi8(ef_fe_tbl, tmp));
210
+
211
+ range_b = _mm_add_epi8(range_b, range2);
212
+
213
+ minv = _mm_shuffle_epi8(range_min_tbl, range_b);
214
+ maxv = _mm_shuffle_epi8(range_max_tbl, range_b);
215
+
216
+ tmp = _mm_or_si128(_mm_cmplt_epi8(input_b, minv),
217
+ _mm_cmpgt_epi8(input_b, maxv));
218
+ error = _mm_or_si128(error, tmp);
219
+
220
+ /************************ next iteration **************************/
221
+ prev_input = input_b;
222
+ prev_first_len = first_len_b;
223
+
224
+ data += 32;
225
+ len -= 32;
226
+ }
227
+
228
+ if (!_mm_testz_si128(error, error)) return -1;
229
+
230
+ int32_t token4 = _mm_extract_epi32(prev_input, 3);
231
+ const int8_t* token = (const int8_t*)&token4;
232
+ int lookahead = 0;
233
+ if (token[3] > (int8_t)0xBF)
234
+ lookahead = 1;
235
+ else if (token[2] > (int8_t)0xBF)
236
+ lookahead = 2;
237
+ else if (token[1] > (int8_t)0xBF)
238
+ lookahead = 3;
239
+
240
+ data -= lookahead;
241
+ len += lookahead;
242
+ }
243
+
244
+ return utf8_naive(data, len);
245
+ }
246
+
247
+ #endif
248
+
249
+ #ifdef __ARM_NEON
250
+
251
+ #include <arm_neon.h>
252
+ #include <stdint.h>
253
+ #include <stdio.h>
254
+
255
+ int utf8_naive(const unsigned char* data, int len);
256
+
257
+ static const uint8_t _first_len_tbl[] = {
258
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 3,
259
+ };
260
+
261
+ static const uint8_t _first_range_tbl[] = {
262
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 8, 8, 8,
263
+ };
264
+
265
+ static const uint8_t _range_min_tbl[] = {
266
+ 0x00, 0x80, 0x80, 0x80, 0xA0, 0x80, 0x90, 0x80,
267
+ 0xC2, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
268
+ };
269
+ static const uint8_t _range_max_tbl[] = {
270
+ 0x7F, 0xBF, 0xBF, 0xBF, 0xBF, 0x9F, 0xBF, 0x8F,
271
+ 0xF4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
272
+ };
273
+
274
+ static const uint8_t _range_adjust_tbl[] = {
275
+ 2, 3, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0,
276
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0,
277
+ };
278
+
279
+ /* Return 0 on success, -1 on error */
280
+ int utf8_range2(const unsigned char* data, int len) {
281
+ if (len >= 32) {
282
+ uint8x16_t prev_input = vdupq_n_u8(0);
283
+ uint8x16_t prev_first_len = vdupq_n_u8(0);
284
+
285
+ const uint8x16_t first_len_tbl = vld1q_u8(_first_len_tbl);
286
+ const uint8x16_t first_range_tbl = vld1q_u8(_first_range_tbl);
287
+ const uint8x16_t range_min_tbl = vld1q_u8(_range_min_tbl);
288
+ const uint8x16_t range_max_tbl = vld1q_u8(_range_max_tbl);
289
+ const uint8x16x2_t range_adjust_tbl = vld2q_u8(_range_adjust_tbl);
290
+
291
+ const uint8x16_t const_1 = vdupq_n_u8(1);
292
+ const uint8x16_t const_2 = vdupq_n_u8(2);
293
+ const uint8x16_t const_e0 = vdupq_n_u8(0xE0);
294
+
295
+ uint8x16_t error1 = vdupq_n_u8(0);
296
+ uint8x16_t error2 = vdupq_n_u8(0);
297
+ uint8x16_t error3 = vdupq_n_u8(0);
298
+ uint8x16_t error4 = vdupq_n_u8(0);
299
+
300
+ while (len >= 32) {
301
+ /******************* two blocks interleaved **********************/
302
+
303
+ #if defined(__GNUC__) && !defined(__clang__) && (__GNUC__ < 8)
304
+ /* gcc doesn't support vldq1_u8_x2 until version 8 */
305
+ const uint8x16_t input_a = vld1q_u8(data);
306
+ const uint8x16_t input_b = vld1q_u8(data + 16);
307
+ #else
308
+ /* Forces a double load on Clang */
309
+ const uint8x16x2_t input_pair = vld1q_u8_x2(data);
310
+ const uint8x16_t input_a = input_pair.val[0];
311
+ const uint8x16_t input_b = input_pair.val[1];
312
+ #endif
313
+
314
+ const uint8x16_t high_nibbles_a = vshrq_n_u8(input_a, 4);
315
+ const uint8x16_t high_nibbles_b = vshrq_n_u8(input_b, 4);
316
+
317
+ const uint8x16_t first_len_a = vqtbl1q_u8(first_len_tbl, high_nibbles_a);
318
+ const uint8x16_t first_len_b = vqtbl1q_u8(first_len_tbl, high_nibbles_b);
319
+
320
+ uint8x16_t range_a = vqtbl1q_u8(first_range_tbl, high_nibbles_a);
321
+ uint8x16_t range_b = vqtbl1q_u8(first_range_tbl, high_nibbles_b);
322
+
323
+ range_a = vorrq_u8(range_a, vextq_u8(prev_first_len, first_len_a, 15));
324
+ range_b = vorrq_u8(range_b, vextq_u8(first_len_a, first_len_b, 15));
325
+
326
+ uint8x16_t tmp1_a, tmp2_a, tmp1_b, tmp2_b;
327
+ tmp1_a = vextq_u8(prev_first_len, first_len_a, 14);
328
+ tmp1_a = vqsubq_u8(tmp1_a, const_1);
329
+ range_a = vorrq_u8(range_a, tmp1_a);
330
+
331
+ tmp1_b = vextq_u8(first_len_a, first_len_b, 14);
332
+ tmp1_b = vqsubq_u8(tmp1_b, const_1);
333
+ range_b = vorrq_u8(range_b, tmp1_b);
334
+
335
+ tmp2_a = vextq_u8(prev_first_len, first_len_a, 13);
336
+ tmp2_a = vqsubq_u8(tmp2_a, const_2);
337
+ range_a = vorrq_u8(range_a, tmp2_a);
338
+
339
+ tmp2_b = vextq_u8(first_len_a, first_len_b, 13);
340
+ tmp2_b = vqsubq_u8(tmp2_b, const_2);
341
+ range_b = vorrq_u8(range_b, tmp2_b);
342
+
343
+ uint8x16_t shift1_a = vextq_u8(prev_input, input_a, 15);
344
+ uint8x16_t pos_a = vsubq_u8(shift1_a, const_e0);
345
+ range_a = vaddq_u8(range_a, vqtbl2q_u8(range_adjust_tbl, pos_a));
346
+
347
+ uint8x16_t shift1_b = vextq_u8(input_a, input_b, 15);
348
+ uint8x16_t pos_b = vsubq_u8(shift1_b, const_e0);
349
+ range_b = vaddq_u8(range_b, vqtbl2q_u8(range_adjust_tbl, pos_b));
350
+
351
+ uint8x16_t minv_a = vqtbl1q_u8(range_min_tbl, range_a);
352
+ uint8x16_t maxv_a = vqtbl1q_u8(range_max_tbl, range_a);
353
+
354
+ uint8x16_t minv_b = vqtbl1q_u8(range_min_tbl, range_b);
355
+ uint8x16_t maxv_b = vqtbl1q_u8(range_max_tbl, range_b);
356
+
357
+ error1 = vorrq_u8(error1, vcltq_u8(input_a, minv_a));
358
+ error2 = vorrq_u8(error2, vcgtq_u8(input_a, maxv_a));
359
+
360
+ error3 = vorrq_u8(error3, vcltq_u8(input_b, minv_b));
361
+ error4 = vorrq_u8(error4, vcgtq_u8(input_b, maxv_b));
362
+
363
+ /************************ next iteration *************************/
364
+ prev_input = input_b;
365
+ prev_first_len = first_len_b;
366
+
367
+ data += 32;
368
+ len -= 32;
369
+ }
370
+ error1 = vorrq_u8(error1, error2);
371
+ error1 = vorrq_u8(error1, error3);
372
+ error1 = vorrq_u8(error1, error4);
373
+
374
+ if (vmaxvq_u8(error1)) return -1;
375
+
376
+ uint32_t token4;
377
+ vst1q_lane_u32(&token4, vreinterpretq_u32_u8(prev_input), 3);
378
+
379
+ const int8_t* token = (const int8_t*)&token4;
380
+ int lookahead = 0;
381
+ if (token[3] > (int8_t)0xBF)
382
+ lookahead = 1;
383
+ else if (token[2] > (int8_t)0xBF)
384
+ lookahead = 2;
385
+ else if (token[1] > (int8_t)0xBF)
386
+ lookahead = 3;
387
+
388
+ data -= lookahead;
389
+ len += lookahead;
390
+ }
391
+
392
+ return utf8_naive(data, len);
393
+ }
394
+
395
+ #endif
@@ -0,0 +1,9 @@
1
+
2
+ #if defined(__ARM_NEON) || defined(__SSE4_1__)
3
+ int utf8_range2(const unsigned char* data, int len);
4
+ #else
5
+ int utf8_naive(const unsigned char* data, int len);
6
+ static inline int utf8_range2(const unsigned char* data, int len) {
7
+ return utf8_naive(data, len);
8
+ }
9
+ #endif
@@ -33,7 +33,8 @@
33
33
  // On x86-64 Linux with glibc, we link against the 2.2.5 version of memcpy so
34
34
  // that we avoid depending on the 2.14 version of the symbol. This way,
35
35
  // distributions that are using pre-2.14 versions of glibc can successfully use
36
- // the gem we distribute (https://github.com/protocolbuffers/protobuf/issues/2783).
36
+ // the gem we distribute
37
+ // (https://github.com/protocolbuffers/protobuf/issues/2783).
37
38
  //
38
39
  // This wrapper is enabled by passing the linker flags -Wl,-wrap,memcpy in
39
40
  // extconf.rb.
@@ -41,11 +42,11 @@
41
42
  #if defined(__x86_64__) && defined(__GNU_LIBRARY__)
42
43
  __asm__(".symver memcpy,memcpy@GLIBC_2.2.5");
43
44
  void *__wrap_memcpy(void *dest, const void *src, size_t n) {
44
- return memcpy(dest, src, n);
45
+ return memcpy(dest, src, n);
45
46
  }
46
47
  #else
47
48
  void *__wrap_memcpy(void *dest, const void *src, size_t n) {
48
- return memmove(dest, src, n);
49
+ return memmove(dest, src, n);
49
50
  }
50
51
  #endif
51
52
  #endif
Binary file
Binary file
Binary file
Binary file
@@ -2,7 +2,14 @@
2
2
  #
3
3
  # Code that implements the DSL for defining proto messages.
4
4
 
5
- require 'google/protobuf/descriptor_pb'
5
+ # Suppress warning: loading in progress, circular require considered harmful.
6
+ # This circular require is intentional to avoid missing dependency.
7
+ begin
8
+ old_verbose, $VERBOSE = $VERBOSE, nil
9
+ require 'google/protobuf/descriptor_pb'
10
+ ensure
11
+ $VERBOSE = old_verbose
12
+ end
6
13
 
7
14
  module Google
8
15
  module Protobuf
@@ -192,12 +192,13 @@ deprecated (:false
192
192
  deprecated (:false
193
193
  map_entry (C
194
194
  uninterpreted_option� ( 2$.google.protobuf.UninterpretedOption* �����JJJJ J 
195
- "�
195
+ "�
196
196
  FieldOptions:
197
197
  ctype (2#.google.protobuf.FieldOptions.CType:STRING
198
198
  packed (?
199
199
  jstype (2$.google.protobuf.FieldOptions.JSType: JS_NORMAL
200
- lazy (:false
200
+ lazy (:false
201
+ unverified_lazy (:false
201
202
 
202
203
  deprecated (:false
203
204
  weak
@@ -44,8 +44,8 @@ module Google
44
44
  self.class.encode_json(self, options)
45
45
  end
46
46
 
47
- def to_proto
48
- self.class.encode(self)
47
+ def to_proto(options = {})
48
+ self.class.encode(self, options)
49
49
  end
50
50
 
51
51
  end
@@ -82,16 +82,16 @@ module Google
82
82
  end
83
83
  end
84
84
 
85
+ def self.from_time(time)
86
+ new.from_time(time)
87
+ end
88
+
85
89
  def from_time(time)
86
90
  self.seconds = time.to_i
87
91
  self.nanos = time.nsec
88
92
  self
89
93
  end
90
94
 
91
- def self.from_time(time)
92
- new.from_time(time)
93
- end
94
-
95
95
  def to_i
96
96
  self.seconds
97
97
  end
@@ -137,10 +137,14 @@ module Google
137
137
  end
138
138
  end
139
139
 
140
+ def self.from_ruby(value)
141
+ self.new.from_ruby(value)
142
+ end
143
+
140
144
  def from_ruby(value)
141
145
  case value
142
146
  when NilClass
143
- self.null_value = 0
147
+ self.null_value = :NULL_VALUE
144
148
  when Numeric
145
149
  self.number_value = value
146
150
  when String
@@ -160,6 +164,8 @@ module Google
160
164
  else
161
165
  raise UnexpectedStructType
162
166
  end
167
+
168
+ self
163
169
  end
164
170
  end
165
171
 
@@ -230,6 +236,5 @@ module Google
230
236
  ret
231
237
  end
232
238
  end
233
-
234
239
  end
235
240
  end
@@ -59,16 +59,16 @@ require 'google/protobuf/repeated_field'
59
59
  module Google
60
60
  module Protobuf
61
61
 
62
- def self.encode(msg)
63
- msg.to_proto
62
+ def self.encode(msg, options = {})
63
+ msg.to_proto(options)
64
64
  end
65
65
 
66
66
  def self.encode_json(msg, options = {})
67
67
  msg.to_json(options)
68
68
  end
69
69
 
70
- def self.decode(klass, proto)
71
- klass.decode(proto)
70
+ def self.decode(klass, proto, options = {})
71
+ klass.decode(proto, options)
72
72
  end
73
73
 
74
74
  def self.decode_json(klass, json, options = {})
data/tests/basic.rb CHANGED
@@ -644,5 +644,19 @@ module BasicTest
644
644
  assert_equal 2, m.map_string_int32.size
645
645
  assert_equal 1, m.map_string_msg.size
646
646
  end
647
+
648
+ def test_string_with_singleton_class_enabled
649
+ str = 'foobar'
650
+ # NOTE: Accessing a singleton class of an object changes its low level class representation
651
+ # as far as the C API's CLASS_OF() method concerned, exposing the issue
652
+ str.singleton_class
653
+ m = proto_module::TestMessage.new(
654
+ optional_string: str,
655
+ optional_bytes: str
656
+ )
657
+
658
+ assert_equal str, m.optional_string
659
+ assert_equal str, m.optional_bytes
660
+ end
647
661
  end
648
662
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-protobuf
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.19.6
4
+ version: 3.20.0.rc.1
5
5
  platform: x86-mingw32
6
6
  authors:
7
7
  - Protobuf Authors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-29 00:00:00.000000000 Z
11
+ date: 2022-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler-dock
@@ -79,6 +79,9 @@ files:
79
79
  - ext/google/protobuf_c/repeated_field.h
80
80
  - ext/google/protobuf_c/ruby-upb.c
81
81
  - ext/google/protobuf_c/ruby-upb.h
82
+ - ext/google/protobuf_c/third_party/utf8_range/LICENSE
83
+ - ext/google/protobuf_c/third_party/utf8_range/utf8_range.c
84
+ - ext/google/protobuf_c/third_party/utf8_range/utf8_range.h
82
85
  - ext/google/protobuf_c/wrap_memcpy.c
83
86
  - lib/google/2.5/protobuf_c.so
84
87
  - lib/google/2.6/protobuf_c.so
@@ -107,7 +110,7 @@ homepage: https://developers.google.com/protocol-buffers
107
110
  licenses:
108
111
  - BSD-3-Clause
109
112
  metadata:
110
- source_code_uri: https://github.com/protocolbuffers/protobuf/tree/v3.19.6/ruby
113
+ source_code_uri: https://github.com/protocolbuffers/protobuf/tree/v3.20.0-rc1/ruby
111
114
  post_install_message:
112
115
  rdoc_options: []
113
116
  require_paths:
@@ -122,9 +125,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
122
125
  version: 3.1.dev
123
126
  required_rubygems_version: !ruby/object:Gem::Requirement
124
127
  requirements:
125
- - - ">="
128
+ - - ">"
126
129
  - !ruby/object:Gem::Version
127
- version: '0'
130
+ version: 1.3.1
128
131
  requirements: []
129
132
  rubygems_version: 3.2.3
130
133
  signing_key: