google-protobuf 3.17.0-x64-mingw32 → 3.17.1-x64-mingw32
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.
Potentially problematic release.
This version of google-protobuf might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/ext/google/protobuf_c/map.c +5 -3
- data/ext/google/protobuf_c/map.h +2 -1
- data/ext/google/protobuf_c/message.c +12 -4
- data/ext/google/protobuf_c/protobuf.c +10 -0
- data/ext/google/protobuf_c/protobuf.h +4 -0
- data/ext/google/protobuf_c/repeated_field.c +4 -2
- data/ext/google/protobuf_c/repeated_field.h +2 -1
- data/ext/google/protobuf_c/ruby-upb.c +756 -812
- data/ext/google/protobuf_c/ruby-upb.h +288 -329
- data/lib/google/2.3/protobuf_c.so +0 -0
- data/lib/google/2.4/protobuf_c.so +0 -0
- data/lib/google/2.5/protobuf_c.so +0 -0
- data/lib/google/2.6/protobuf_c.so +0 -0
- data/lib/google/2.7/protobuf_c.so +0 -0
- data/lib/google/3.0/protobuf_c.so +0 -0
- data/tests/basic.rb +7 -0
- metadata +3 -3
@@ -1,26 +1,53 @@
|
|
1
1
|
/* Amalgamated source file */
|
2
|
-
|
3
|
-
*
|
4
|
-
*
|
5
|
-
*
|
6
|
-
*
|
7
|
-
*
|
8
|
-
*
|
9
|
-
*
|
10
|
-
*
|
11
|
-
*
|
12
|
-
*
|
13
|
-
*
|
14
|
-
*
|
15
|
-
*
|
16
|
-
*
|
17
|
-
*
|
18
|
-
*
|
19
|
-
*
|
20
|
-
*
|
21
|
-
*
|
22
|
-
*
|
23
|
-
|
2
|
+
/*
|
3
|
+
* Copyright (c) 2009-2021, Google LLC
|
4
|
+
* All rights reserved.
|
5
|
+
*
|
6
|
+
* Redistribution and use in source and binary forms, with or without
|
7
|
+
* modification, are permitted provided that the following conditions are met:
|
8
|
+
* * Redistributions of source code must retain the above copyright
|
9
|
+
* notice, this list of conditions and the following disclaimer.
|
10
|
+
* * Redistributions in binary form must reproduce the above copyright
|
11
|
+
* notice, this list of conditions and the following disclaimer in the
|
12
|
+
* documentation and/or other materials provided with the distribution.
|
13
|
+
* * Neither the name of Google LLC nor the
|
14
|
+
* names of its contributors may be used to endorse or promote products
|
15
|
+
* derived from this software without specific prior written permission.
|
16
|
+
*
|
17
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
18
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
19
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
20
|
+
* DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY
|
21
|
+
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
22
|
+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
23
|
+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
24
|
+
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
25
|
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
26
|
+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
27
|
+
*/
|
28
|
+
|
29
|
+
/*
|
30
|
+
* This is where we define macros used across upb.
|
31
|
+
*
|
32
|
+
* All of these macros are undef'd in port_undef.inc to avoid leaking them to
|
33
|
+
* users.
|
34
|
+
*
|
35
|
+
* The correct usage is:
|
36
|
+
*
|
37
|
+
* #include "upb/foobar.h"
|
38
|
+
* #include "upb/baz.h"
|
39
|
+
*
|
40
|
+
* // MUST be last included header.
|
41
|
+
* #include "upb/port_def.inc"
|
42
|
+
*
|
43
|
+
* // Code for this file.
|
44
|
+
* // <...>
|
45
|
+
*
|
46
|
+
* // Can be omitted for .c files, required for .h.
|
47
|
+
* #include "upb/port_undef.inc"
|
48
|
+
*
|
49
|
+
* This file is private and must not be included by users!
|
50
|
+
*/
|
24
51
|
|
25
52
|
#if !((defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
|
26
53
|
(defined(__cplusplus) && __cplusplus >= 201103L) || \
|
@@ -136,9 +163,40 @@
|
|
136
163
|
#define UPB_LONGJMP(buf, val) longjmp(buf, val)
|
137
164
|
#endif
|
138
165
|
|
166
|
+
/* UPB_PTRADD(ptr, ofs): add pointer while avoiding "NULL + 0" UB */
|
167
|
+
#define UPB_PTRADD(ptr, ofs) ((ofs) ? (ptr) + (ofs) : (ptr))
|
168
|
+
|
139
169
|
/* Configure whether fasttable is switched on or not. *************************/
|
140
170
|
|
141
|
-
#
|
171
|
+
#ifdef __has_attribute
|
172
|
+
#define UPB_HAS_ATTRIBUTE(x) __has_attribute(x)
|
173
|
+
#else
|
174
|
+
#define UPB_HAS_ATTRIBUTE(x) 0
|
175
|
+
#endif
|
176
|
+
|
177
|
+
#if UPB_HAS_ATTRIBUTE(musttail)
|
178
|
+
#define UPB_MUSTTAIL __attribute__((musttail))
|
179
|
+
#else
|
180
|
+
#define UPB_MUSTTAIL
|
181
|
+
#endif
|
182
|
+
|
183
|
+
#undef UPB_HAS_ATTRIBUTE
|
184
|
+
|
185
|
+
/* This check is not fully robust: it does not require that we have "musttail"
|
186
|
+
* support available. We need tail calls to avoid consuming arbitrary amounts
|
187
|
+
* of stack space.
|
188
|
+
*
|
189
|
+
* GCC/Clang can mostly be trusted to generate tail calls as long as
|
190
|
+
* optimization is enabled, but, debug builds will not generate tail calls
|
191
|
+
* unless "musttail" is available.
|
192
|
+
*
|
193
|
+
* We should probably either:
|
194
|
+
* 1. require that the compiler supports musttail.
|
195
|
+
* 2. add some fallback code for when musttail isn't available (ie. return
|
196
|
+
* instead of tail calling). This is safe and portable, but this comes at
|
197
|
+
* a CPU cost.
|
198
|
+
*/
|
199
|
+
#if (defined(__x86_64__) || defined(__aarch64__)) && defined(__GNUC__)
|
142
200
|
#define UPB_FASTTABLE_SUPPORTED 1
|
143
201
|
#else
|
144
202
|
#define UPB_FASTTABLE_SUPPORTED 0
|
@@ -149,7 +207,7 @@
|
|
149
207
|
* for example for testing or benchmarking. */
|
150
208
|
#if defined(UPB_ENABLE_FASTTABLE)
|
151
209
|
#if !UPB_FASTTABLE_SUPPORTED
|
152
|
-
#error fasttable is x86-64
|
210
|
+
#error fasttable is x86-64/ARM64 only and requires GCC or Clang.
|
153
211
|
#endif
|
154
212
|
#define UPB_FASTTABLE 1
|
155
213
|
/* Define UPB_TRY_ENABLE_FASTTABLE to use fasttable if possible.
|
@@ -193,55 +251,36 @@ void __asan_unpoison_memory_region(void const volatile *addr, size_t size);
|
|
193
251
|
((void)(addr), (void)(size))
|
194
252
|
#define UPB_UNPOISON_MEMORY_REGION(addr, size) \
|
195
253
|
((void)(addr), (void)(size))
|
196
|
-
#endif
|
254
|
+
#endif
|
255
|
+
|
256
|
+
/** upb/decode.h ************************************************************/
|
197
257
|
/*
|
198
|
-
|
199
|
-
*/
|
258
|
+
* upb_decode: parsing into a upb_msg using a upb_msglayout.
|
259
|
+
*/
|
200
260
|
|
201
261
|
#ifndef UPB_DECODE_H_
|
202
262
|
#define UPB_DECODE_H_
|
203
263
|
|
264
|
+
|
265
|
+
/** upb/msg.h ************************************************************/
|
204
266
|
/*
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
267
|
+
* Public APIs for message operations that do not require descriptors.
|
268
|
+
* These functions can be used even in build that does not want to depend on
|
269
|
+
* reflection or descriptors.
|
270
|
+
*
|
271
|
+
* Descriptor-based reflection functionality lives in reflection.h.
|
272
|
+
*/
|
210
273
|
|
211
274
|
#ifndef UPB_MSG_H_
|
212
275
|
#define UPB_MSG_H_
|
213
276
|
|
214
|
-
#include <
|
215
|
-
#include <stdlib.h>
|
216
|
-
#include <string.h>
|
217
|
-
|
218
|
-
/*
|
219
|
-
** upb_table
|
220
|
-
**
|
221
|
-
** This header is INTERNAL-ONLY! Its interfaces are not public or stable!
|
222
|
-
** This file defines very fast int->upb_value (inttable) and string->upb_value
|
223
|
-
** (strtable) hash tables.
|
224
|
-
**
|
225
|
-
** The table uses chained scatter with Brent's variation (inspired by the Lua
|
226
|
-
** implementation of hash tables). The hash function for strings is Austin
|
227
|
-
** Appleby's "MurmurHash."
|
228
|
-
**
|
229
|
-
** The inttable uses uintptr_t as its key, which guarantees it can be used to
|
230
|
-
** store pointers or integers of at least 32 bits (upb isn't really useful on
|
231
|
-
** systems where sizeof(void*) < 4).
|
232
|
-
**
|
233
|
-
** The table must be homogeneous (all values of the same type). In debug
|
234
|
-
** mode, we check this on insert and lookup.
|
235
|
-
*/
|
277
|
+
#include <stddef.h>
|
236
278
|
|
237
|
-
#ifndef UPB_TABLE_H_
|
238
|
-
#define UPB_TABLE_H_
|
239
279
|
|
240
|
-
|
241
|
-
#include <string.h>
|
280
|
+
/** upb/upb.h ************************************************************/
|
242
281
|
/*
|
243
|
-
|
244
|
-
*/
|
282
|
+
* This file contains shared definitions that are widely used across upb.
|
283
|
+
*/
|
245
284
|
|
246
285
|
#ifndef UPB_H_
|
247
286
|
#define UPB_H_
|
@@ -399,7 +438,7 @@ typedef struct {
|
|
399
438
|
upb_arena *upb_arena_init(void *mem, size_t n, upb_alloc *alloc);
|
400
439
|
void upb_arena_free(upb_arena *a);
|
401
440
|
bool upb_arena_addcleanup(upb_arena *a, void *ud, upb_cleanup_func *func);
|
402
|
-
|
441
|
+
bool upb_arena_fuse(upb_arena *a, upb_arena *b);
|
403
442
|
void *_upb_arena_slowmalloc(upb_arena *a, size_t size);
|
404
443
|
|
405
444
|
UPB_INLINE upb_alloc *upb_arena_alloc(upb_arena *a) { return (upb_alloc*)a; }
|
@@ -578,55 +617,134 @@ UPB_INLINE int _upb_lg2ceilsize(int x) {
|
|
578
617
|
|
579
618
|
#endif /* UPB_H_ */
|
580
619
|
|
620
|
+
#ifdef __cplusplus
|
621
|
+
extern "C" {
|
622
|
+
#endif
|
623
|
+
|
624
|
+
typedef void upb_msg;
|
625
|
+
|
626
|
+
/* For users these are opaque. They can be obtained from upb_msgdef_layout()
|
627
|
+
* but users cannot access any of the members. */
|
628
|
+
struct upb_msglayout;
|
629
|
+
typedef struct upb_msglayout upb_msglayout;
|
630
|
+
|
631
|
+
/* Adds unknown data (serialized protobuf data) to the given message. The data
|
632
|
+
* is copied into the message instance. */
|
633
|
+
void upb_msg_addunknown(upb_msg *msg, const char *data, size_t len,
|
634
|
+
upb_arena *arena);
|
635
|
+
|
636
|
+
/* Returns a reference to the message's unknown data. */
|
637
|
+
const char *upb_msg_getunknown(const upb_msg *msg, size_t *len);
|
638
|
+
|
639
|
+
#ifdef __cplusplus
|
640
|
+
} /* extern "C" */
|
641
|
+
#endif
|
642
|
+
|
643
|
+
#endif /* UPB_MSG_INT_H_ */
|
644
|
+
|
645
|
+
/* Must be last. */
|
581
646
|
|
582
647
|
#ifdef __cplusplus
|
583
648
|
extern "C" {
|
584
649
|
#endif
|
585
650
|
|
651
|
+
enum {
|
652
|
+
/* If set, strings will alias the input buffer instead of copying into the
|
653
|
+
* arena. */
|
654
|
+
UPB_DECODE_ALIAS = 1,
|
655
|
+
};
|
586
656
|
|
587
|
-
|
657
|
+
#define UPB_DECODE_MAXDEPTH(depth) ((depth) << 16)
|
588
658
|
|
589
|
-
|
590
|
-
*
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
659
|
+
bool _upb_decode(const char *buf, size_t size, upb_msg *msg,
|
660
|
+
const upb_msglayout *l, upb_arena *arena, int options);
|
661
|
+
|
662
|
+
UPB_INLINE
|
663
|
+
bool upb_decode(const char *buf, size_t size, upb_msg *msg,
|
664
|
+
const upb_msglayout *l, upb_arena *arena) {
|
665
|
+
return _upb_decode(buf, size, msg, l, arena, 0);
|
666
|
+
}
|
667
|
+
|
668
|
+
#ifdef __cplusplus
|
669
|
+
} /* extern "C" */
|
670
|
+
#endif
|
671
|
+
|
672
|
+
|
673
|
+
#endif /* UPB_DECODE_H_ */
|
674
|
+
|
675
|
+
/** upb/decode_internal.h ************************************************************/
|
676
|
+
/*
|
677
|
+
* Internal implementation details of the decoder that are shared between
|
678
|
+
* decode.c and decode_fast.c.
|
679
|
+
*/
|
680
|
+
|
681
|
+
#ifndef UPB_DECODE_INT_H_
|
682
|
+
#define UPB_DECODE_INT_H_
|
683
|
+
|
684
|
+
#include <setjmp.h>
|
685
|
+
|
686
|
+
|
687
|
+
/** upb/msg_internal.h ************************************************************//*
|
688
|
+
** Our memory representation for parsing tables and messages themselves.
|
689
|
+
** Functions in this file are used by generated code and possibly reflection.
|
690
|
+
**
|
691
|
+
** The definitions in this file are internal to upb.
|
692
|
+
**/
|
693
|
+
|
694
|
+
#ifndef UPB_MSG_INT_H_
|
695
|
+
#define UPB_MSG_INT_H_
|
696
|
+
|
697
|
+
#include <stdint.h>
|
698
|
+
#include <stdlib.h>
|
699
|
+
#include <string.h>
|
700
|
+
|
701
|
+
|
702
|
+
/** upb/table_internal.h ************************************************************/
|
703
|
+
/*
|
704
|
+
* upb_table
|
705
|
+
*
|
706
|
+
* This header is INTERNAL-ONLY! Its interfaces are not public or stable!
|
707
|
+
* This file defines very fast int->upb_value (inttable) and string->upb_value
|
708
|
+
* (strtable) hash tables.
|
709
|
+
*
|
710
|
+
* The table uses chained scatter with Brent's variation (inspired by the Lua
|
711
|
+
* implementation of hash tables). The hash function for strings is Austin
|
712
|
+
* Appleby's "MurmurHash."
|
713
|
+
*
|
714
|
+
* The inttable uses uintptr_t as its key, which guarantees it can be used to
|
715
|
+
* store pointers or integers of at least 32 bits (upb isn't really useful on
|
716
|
+
* systems where sizeof(void*) < 4).
|
717
|
+
*
|
718
|
+
* The table must be homogeneous (all values of the same type). In debug
|
719
|
+
* mode, we check this on insert and lookup.
|
720
|
+
*/
|
721
|
+
|
722
|
+
#ifndef UPB_TABLE_H_
|
723
|
+
#define UPB_TABLE_H_
|
724
|
+
|
725
|
+
#include <stdint.h>
|
726
|
+
#include <string.h>
|
727
|
+
|
728
|
+
|
729
|
+
#ifdef __cplusplus
|
730
|
+
extern "C" {
|
731
|
+
#endif
|
732
|
+
|
733
|
+
|
734
|
+
/* upb_value ******************************************************************/
|
605
735
|
|
606
736
|
typedef struct {
|
607
737
|
uint64_t val;
|
608
738
|
} upb_value;
|
609
739
|
|
610
|
-
/* Like strdup(), which isn't always available since it's not ANSI C. */
|
611
|
-
char *upb_strdup(const char *s, upb_alloc *a);
|
612
740
|
/* Variant that works with a length-delimited rather than NULL-delimited string,
|
613
741
|
* as supported by strtable. */
|
614
|
-
char *upb_strdup2(const char *s, size_t len,
|
615
|
-
|
616
|
-
UPB_INLINE char *upb_gstrdup(const char *s) {
|
617
|
-
return upb_strdup(s, &upb_alloc_global);
|
618
|
-
}
|
742
|
+
char *upb_strdup2(const char *s, size_t len, upb_arena *a);
|
619
743
|
|
620
744
|
UPB_INLINE void _upb_value_setval(upb_value *v, uint64_t val) {
|
621
745
|
v->val = val;
|
622
746
|
}
|
623
747
|
|
624
|
-
UPB_INLINE upb_value _upb_value_val(uint64_t val) {
|
625
|
-
upb_value ret;
|
626
|
-
_upb_value_setval(&ret, val);
|
627
|
-
return ret;
|
628
|
-
}
|
629
|
-
|
630
748
|
/* For each value ctype, define the following set of functions:
|
631
749
|
*
|
632
750
|
* // Get/set an int32 from a upb_value.
|
@@ -734,14 +852,7 @@ typedef struct {
|
|
734
852
|
uint32_t mask; /* Mask to turn hash value -> bucket. */
|
735
853
|
uint32_t max_count; /* Max count before we hit our load limit. */
|
736
854
|
uint8_t size_lg2; /* Size of the hashtable part is 2^size_lg2 entries. */
|
737
|
-
|
738
|
-
/* Hash table entries.
|
739
|
-
* Making this const isn't entirely accurate; what we really want is for it to
|
740
|
-
* have the same const-ness as the table it's inside. But there's no way to
|
741
|
-
* declare that in C. So we have to make it const so that we can statically
|
742
|
-
* initialize const hash tables. Then we cast away const when we have to.
|
743
|
-
*/
|
744
|
-
const upb_tabent *entries;
|
855
|
+
upb_tabent *entries;
|
745
856
|
} upb_table;
|
746
857
|
|
747
858
|
typedef struct {
|
@@ -755,8 +866,6 @@ typedef struct {
|
|
755
866
|
size_t array_count; /* Array part number of elements. */
|
756
867
|
} upb_inttable;
|
757
868
|
|
758
|
-
#define UPB_ARRAY_EMPTYENT -1
|
759
|
-
|
760
869
|
UPB_INLINE size_t upb_table_size(const upb_table *t) {
|
761
870
|
if (t->size_lg2 == 0)
|
762
871
|
return 0;
|
@@ -769,48 +878,10 @@ UPB_INLINE bool upb_tabent_isempty(const upb_tabent *e) {
|
|
769
878
|
return e->key == 0;
|
770
879
|
}
|
771
880
|
|
772
|
-
/* Used by some of the unit tests for generic hashing functionality. */
|
773
|
-
uint32_t upb_murmur_hash2(const void * key, size_t len, uint32_t seed);
|
774
|
-
|
775
|
-
UPB_INLINE uintptr_t upb_intkey(uintptr_t key) {
|
776
|
-
return key;
|
777
|
-
}
|
778
|
-
|
779
|
-
UPB_INLINE uint32_t upb_inthash(uintptr_t key) {
|
780
|
-
return (uint32_t)key;
|
781
|
-
}
|
782
|
-
|
783
|
-
static const upb_tabent *upb_getentry(const upb_table *t, uint32_t hash) {
|
784
|
-
return t->entries + (hash & t->mask);
|
785
|
-
}
|
786
|
-
|
787
|
-
UPB_INLINE bool upb_arrhas(upb_tabval key) {
|
788
|
-
return key.val != (uint64_t)-1;
|
789
|
-
}
|
790
|
-
|
791
881
|
/* Initialize and uninitialize a table, respectively. If memory allocation
|
792
882
|
* failed, false is returned that the table is uninitialized. */
|
793
|
-
bool
|
794
|
-
bool
|
795
|
-
size_t expected_size, upb_alloc *a);
|
796
|
-
void upb_inttable_uninit2(upb_inttable *table, upb_alloc *a);
|
797
|
-
void upb_strtable_uninit2(upb_strtable *table, upb_alloc *a);
|
798
|
-
|
799
|
-
UPB_INLINE bool upb_inttable_init(upb_inttable *table, upb_ctype_t ctype) {
|
800
|
-
return upb_inttable_init2(table, ctype, &upb_alloc_global);
|
801
|
-
}
|
802
|
-
|
803
|
-
UPB_INLINE bool upb_strtable_init(upb_strtable *table, upb_ctype_t ctype) {
|
804
|
-
return upb_strtable_init2(table, ctype, 4, &upb_alloc_global);
|
805
|
-
}
|
806
|
-
|
807
|
-
UPB_INLINE void upb_inttable_uninit(upb_inttable *table) {
|
808
|
-
upb_inttable_uninit2(table, &upb_alloc_global);
|
809
|
-
}
|
810
|
-
|
811
|
-
UPB_INLINE void upb_strtable_uninit(upb_strtable *table) {
|
812
|
-
upb_strtable_uninit2(table, &upb_alloc_global);
|
813
|
-
}
|
883
|
+
bool upb_inttable_init(upb_inttable *table, upb_arena *a);
|
884
|
+
bool upb_strtable_init(upb_strtable *table, size_t expected_size, upb_arena *a);
|
814
885
|
|
815
886
|
/* Returns the number of values in the table. */
|
816
887
|
size_t upb_inttable_count(const upb_inttable *t);
|
@@ -818,12 +889,6 @@ UPB_INLINE size_t upb_strtable_count(const upb_strtable *t) {
|
|
818
889
|
return t->t.count;
|
819
890
|
}
|
820
891
|
|
821
|
-
void upb_inttable_packedsize(const upb_inttable *t, size_t *size);
|
822
|
-
void upb_strtable_packedsize(const upb_strtable *t, size_t *size);
|
823
|
-
upb_inttable *upb_inttable_pack(const upb_inttable *t, void *p, size_t *ofs,
|
824
|
-
size_t size);
|
825
|
-
upb_strtable *upb_strtable_pack(const upb_strtable *t, void *p, size_t *ofs,
|
826
|
-
size_t size);
|
827
892
|
void upb_strtable_clear(upb_strtable *t);
|
828
893
|
|
829
894
|
/* Inserts the given key into the hashtable with the given value. The key must
|
@@ -833,26 +898,10 @@ void upb_strtable_clear(upb_strtable *t);
|
|
833
898
|
*
|
834
899
|
* If a table resize was required but memory allocation failed, false is
|
835
900
|
* returned and the table is unchanged. */
|
836
|
-
bool
|
837
|
-
|
838
|
-
bool
|
839
|
-
|
840
|
-
|
841
|
-
UPB_INLINE bool upb_inttable_insert(upb_inttable *t, uintptr_t key,
|
842
|
-
upb_value val) {
|
843
|
-
return upb_inttable_insert2(t, key, val, &upb_alloc_global);
|
844
|
-
}
|
845
|
-
|
846
|
-
UPB_INLINE bool upb_strtable_insert2(upb_strtable *t, const char *key,
|
847
|
-
size_t len, upb_value val) {
|
848
|
-
return upb_strtable_insert3(t, key, len, val, &upb_alloc_global);
|
849
|
-
}
|
850
|
-
|
851
|
-
/* For NULL-terminated strings. */
|
852
|
-
UPB_INLINE bool upb_strtable_insert(upb_strtable *t, const char *key,
|
853
|
-
upb_value val) {
|
854
|
-
return upb_strtable_insert2(t, key, strlen(key), val);
|
855
|
-
}
|
901
|
+
bool upb_inttable_insert(upb_inttable *t, uintptr_t key, upb_value val,
|
902
|
+
upb_arena *a);
|
903
|
+
bool upb_strtable_insert(upb_strtable *t, const char *key, size_t len,
|
904
|
+
upb_value val, upb_arena *a);
|
856
905
|
|
857
906
|
/* Looks up key in this table, returning "true" if the key was found.
|
858
907
|
* If v is non-NULL, copies the value for this key into *v. */
|
@@ -869,74 +918,21 @@ UPB_INLINE bool upb_strtable_lookup(const upb_strtable *t, const char *key,
|
|
869
918
|
/* Removes an item from the table. Returns true if the remove was successful,
|
870
919
|
* and stores the removed item in *val if non-NULL. */
|
871
920
|
bool upb_inttable_remove(upb_inttable *t, uintptr_t key, upb_value *val);
|
872
|
-
bool
|
873
|
-
upb_value *val
|
874
|
-
|
875
|
-
UPB_INLINE bool upb_strtable_remove2(upb_strtable *t, const char *key,
|
876
|
-
size_t len, upb_value *val) {
|
877
|
-
return upb_strtable_remove3(t, key, len, val, &upb_alloc_global);
|
878
|
-
}
|
879
|
-
|
880
|
-
/* For NULL-terminated strings. */
|
881
|
-
UPB_INLINE bool upb_strtable_remove(upb_strtable *t, const char *key,
|
882
|
-
upb_value *v) {
|
883
|
-
return upb_strtable_remove2(t, key, strlen(key), v);
|
884
|
-
}
|
921
|
+
bool upb_strtable_remove(upb_strtable *t, const char *key, size_t len,
|
922
|
+
upb_value *val);
|
885
923
|
|
886
924
|
/* Updates an existing entry in an inttable. If the entry does not exist,
|
887
925
|
* returns false and does nothing. Unlike insert/remove, this does not
|
888
926
|
* invalidate iterators. */
|
889
927
|
bool upb_inttable_replace(upb_inttable *t, uintptr_t key, upb_value val);
|
890
928
|
|
891
|
-
/* Convenience routines for inttables with pointer keys. */
|
892
|
-
bool upb_inttable_insertptr2(upb_inttable *t, const void *key, upb_value val,
|
893
|
-
upb_alloc *a);
|
894
|
-
bool upb_inttable_removeptr(upb_inttable *t, const void *key, upb_value *val);
|
895
|
-
bool upb_inttable_lookupptr(
|
896
|
-
const upb_inttable *t, const void *key, upb_value *val);
|
897
|
-
|
898
|
-
UPB_INLINE bool upb_inttable_insertptr(upb_inttable *t, const void *key,
|
899
|
-
upb_value val) {
|
900
|
-
return upb_inttable_insertptr2(t, key, val, &upb_alloc_global);
|
901
|
-
}
|
902
|
-
|
903
929
|
/* Optimizes the table for the current set of entries, for both memory use and
|
904
930
|
* lookup time. Client should call this after all entries have been inserted;
|
905
931
|
* inserting more entries is legal, but will likely require a table resize. */
|
906
|
-
void
|
907
|
-
|
908
|
-
UPB_INLINE void upb_inttable_compact(upb_inttable *t) {
|
909
|
-
upb_inttable_compact2(t, &upb_alloc_global);
|
910
|
-
}
|
911
|
-
|
912
|
-
/* A special-case inlinable version of the lookup routine for 32-bit
|
913
|
-
* integers. */
|
914
|
-
UPB_INLINE bool upb_inttable_lookup32(const upb_inttable *t, uint32_t key,
|
915
|
-
upb_value *v) {
|
916
|
-
*v = upb_value_int32(0); /* Silence compiler warnings. */
|
917
|
-
if (key < t->array_size) {
|
918
|
-
upb_tabval arrval = t->array[key];
|
919
|
-
if (upb_arrhas(arrval)) {
|
920
|
-
_upb_value_setval(v, arrval.val);
|
921
|
-
return true;
|
922
|
-
} else {
|
923
|
-
return false;
|
924
|
-
}
|
925
|
-
} else {
|
926
|
-
const upb_tabent *e;
|
927
|
-
if (t->t.entries == NULL) return false;
|
928
|
-
for (e = upb_getentry(&t->t, upb_inthash(key)); true; e = e->next) {
|
929
|
-
if ((uint32_t)e->key == key) {
|
930
|
-
_upb_value_setval(v, e->val.val);
|
931
|
-
return true;
|
932
|
-
}
|
933
|
-
if (e->next == NULL) return false;
|
934
|
-
}
|
935
|
-
}
|
936
|
-
}
|
932
|
+
void upb_inttable_compact(upb_inttable *t, upb_arena *a);
|
937
933
|
|
938
934
|
/* Exposed for testing only. */
|
939
|
-
bool upb_strtable_resize(upb_strtable *t, size_t size_lg2,
|
935
|
+
bool upb_strtable_resize(upb_strtable *t, size_t size_lg2, upb_arena *a);
|
940
936
|
|
941
937
|
/* Iterators ******************************************************************/
|
942
938
|
|
@@ -1032,10 +1028,6 @@ bool upb_inttable_iter_isequal(const upb_inttable_iter *i1,
|
|
1032
1028
|
extern "C" {
|
1033
1029
|
#endif
|
1034
1030
|
|
1035
|
-
#define PTR_AT(msg, ofs, type) (type*)((const char*)msg + ofs)
|
1036
|
-
|
1037
|
-
typedef void upb_msg;
|
1038
|
-
|
1039
1031
|
/** upb_msglayout *************************************************************/
|
1040
1032
|
|
1041
1033
|
/* upb_msglayout represents the memory layout of a given upb_msgdef. The
|
@@ -1070,7 +1062,7 @@ typedef struct {
|
|
1070
1062
|
_upb_field_parser *field_parser;
|
1071
1063
|
} _upb_fasttable_entry;
|
1072
1064
|
|
1073
|
-
|
1065
|
+
struct upb_msglayout {
|
1074
1066
|
const struct upb_msglayout *const* submsgs;
|
1075
1067
|
const upb_msglayout_field *fields;
|
1076
1068
|
/* Must be aligned to sizeof(void*). Doesn't include internal members like
|
@@ -1082,7 +1074,7 @@ typedef struct upb_msglayout {
|
|
1082
1074
|
/* To constant-initialize the tables of variable length, we need a flexible
|
1083
1075
|
* array member, and we need to compile in C99 mode. */
|
1084
1076
|
_upb_fasttable_entry fasttable[];
|
1085
|
-
}
|
1077
|
+
};
|
1086
1078
|
|
1087
1079
|
/** upb_msg *******************************************************************/
|
1088
1080
|
|
@@ -1137,21 +1129,18 @@ void _upb_msg_discardunknown_shallow(upb_msg *msg);
|
|
1137
1129
|
bool _upb_msg_addunknown(upb_msg *msg, const char *data, size_t len,
|
1138
1130
|
upb_arena *arena);
|
1139
1131
|
|
1140
|
-
/* Returns a reference to the message's unknown data. */
|
1141
|
-
const char *upb_msg_getunknown(const upb_msg *msg, size_t *len);
|
1142
|
-
|
1143
1132
|
/** Hasbit access *************************************************************/
|
1144
1133
|
|
1145
1134
|
UPB_INLINE bool _upb_hasbit(const upb_msg *msg, size_t idx) {
|
1146
|
-
return (*
|
1135
|
+
return (*UPB_PTR_AT(msg, idx / 8, const char) & (1 << (idx % 8))) != 0;
|
1147
1136
|
}
|
1148
1137
|
|
1149
1138
|
UPB_INLINE void _upb_sethas(const upb_msg *msg, size_t idx) {
|
1150
|
-
(*
|
1139
|
+
(*UPB_PTR_AT(msg, idx / 8, char)) |= (char)(1 << (idx % 8));
|
1151
1140
|
}
|
1152
1141
|
|
1153
1142
|
UPB_INLINE void _upb_clearhas(const upb_msg *msg, size_t idx) {
|
1154
|
-
(*
|
1143
|
+
(*UPB_PTR_AT(msg, idx / 8, char)) &= (char)(~(1 << (idx % 8)));
|
1155
1144
|
}
|
1156
1145
|
|
1157
1146
|
UPB_INLINE size_t _upb_msg_hasidx(const upb_msglayout_field *f) {
|
@@ -1177,11 +1166,11 @@ UPB_INLINE void _upb_clearhas_field(const upb_msg *msg,
|
|
1177
1166
|
/** Oneof case access *********************************************************/
|
1178
1167
|
|
1179
1168
|
UPB_INLINE uint32_t *_upb_oneofcase(upb_msg *msg, size_t case_ofs) {
|
1180
|
-
return
|
1169
|
+
return UPB_PTR_AT(msg, case_ofs, uint32_t);
|
1181
1170
|
}
|
1182
1171
|
|
1183
1172
|
UPB_INLINE uint32_t _upb_getoneofcase(const void *msg, size_t case_ofs) {
|
1184
|
-
return *
|
1173
|
+
return *UPB_PTR_AT(msg, case_ofs, uint32_t);
|
1185
1174
|
}
|
1186
1175
|
|
1187
1176
|
UPB_INLINE size_t _upb_oneofcase_ofs(const upb_msglayout_field *f) {
|
@@ -1200,7 +1189,7 @@ UPB_INLINE uint32_t _upb_getoneofcase_field(const upb_msg *msg,
|
|
1200
1189
|
}
|
1201
1190
|
|
1202
1191
|
UPB_INLINE bool _upb_has_submsg_nohasbit(const upb_msg *msg, size_t ofs) {
|
1203
|
-
return *
|
1192
|
+
return *UPB_PTR_AT(msg, ofs, const upb_msg*) != NULL;
|
1204
1193
|
}
|
1205
1194
|
|
1206
1195
|
UPB_INLINE bool _upb_isrepeated(const upb_msglayout_field *field) {
|
@@ -1277,7 +1266,7 @@ UPB_INLINE bool _upb_array_resize(upb_array *arr, size_t size,
|
|
1277
1266
|
|
1278
1267
|
UPB_INLINE const void *_upb_array_accessor(const void *msg, size_t ofs,
|
1279
1268
|
size_t *size) {
|
1280
|
-
const upb_array *arr = *
|
1269
|
+
const upb_array *arr = *UPB_PTR_AT(msg, ofs, const upb_array*);
|
1281
1270
|
if (arr) {
|
1282
1271
|
if (size) *size = arr->len;
|
1283
1272
|
return _upb_array_constptr(arr);
|
@@ -1289,7 +1278,7 @@ UPB_INLINE const void *_upb_array_accessor(const void *msg, size_t ofs,
|
|
1289
1278
|
|
1290
1279
|
UPB_INLINE void *_upb_array_mutable_accessor(void *msg, size_t ofs,
|
1291
1280
|
size_t *size) {
|
1292
|
-
upb_array *arr = *
|
1281
|
+
upb_array *arr = *UPB_PTR_AT(msg, ofs, upb_array*);
|
1293
1282
|
if (arr) {
|
1294
1283
|
if (size) *size = arr->len;
|
1295
1284
|
return _upb_array_ptr(arr);
|
@@ -1302,7 +1291,7 @@ UPB_INLINE void *_upb_array_mutable_accessor(void *msg, size_t ofs,
|
|
1302
1291
|
UPB_INLINE void *_upb_array_resize_accessor2(void *msg, size_t ofs, size_t size,
|
1303
1292
|
int elem_size_lg2,
|
1304
1293
|
upb_arena *arena) {
|
1305
|
-
upb_array **arr_ptr =
|
1294
|
+
upb_array **arr_ptr = UPB_PTR_AT(msg, ofs, upb_array *);
|
1306
1295
|
upb_array *arr = *arr_ptr;
|
1307
1296
|
if (!arr || arr->size < size) {
|
1308
1297
|
return _upb_array_resize_fallback(arr_ptr, size, elem_size_lg2, arena);
|
@@ -1315,7 +1304,7 @@ UPB_INLINE bool _upb_array_append_accessor2(void *msg, size_t ofs,
|
|
1315
1304
|
int elem_size_lg2,
|
1316
1305
|
const void *value,
|
1317
1306
|
upb_arena *arena) {
|
1318
|
-
upb_array **arr_ptr =
|
1307
|
+
upb_array **arr_ptr = UPB_PTR_AT(msg, ofs, upb_array *);
|
1319
1308
|
size_t elem_size = 1 << elem_size_lg2;
|
1320
1309
|
upb_array *arr = *arr_ptr;
|
1321
1310
|
void *ptr;
|
@@ -1323,7 +1312,7 @@ UPB_INLINE bool _upb_array_append_accessor2(void *msg, size_t ofs,
|
|
1323
1312
|
return _upb_array_append_fallback(arr_ptr, value, elem_size_lg2, arena);
|
1324
1313
|
}
|
1325
1314
|
ptr = _upb_array_ptr(arr);
|
1326
|
-
memcpy(
|
1315
|
+
memcpy(UPB_PTR_AT(ptr, arr->len * elem_size, char), value, elem_size);
|
1327
1316
|
arr->len++;
|
1328
1317
|
return true;
|
1329
1318
|
}
|
@@ -1470,20 +1459,19 @@ UPB_INLINE void* _upb_map_next(const upb_map *map, size_t *iter) {
|
|
1470
1459
|
}
|
1471
1460
|
|
1472
1461
|
UPB_INLINE bool _upb_map_set(upb_map *map, const void *key, size_t key_size,
|
1473
|
-
void *val, size_t val_size, upb_arena *
|
1462
|
+
void *val, size_t val_size, upb_arena *a) {
|
1474
1463
|
upb_strview strkey = _upb_map_tokey(key, key_size);
|
1475
1464
|
upb_value tabval = {0};
|
1476
|
-
if (!_upb_map_tovalue(val, val_size, &tabval,
|
1477
|
-
upb_alloc *a = upb_arena_alloc(arena);
|
1465
|
+
if (!_upb_map_tovalue(val, val_size, &tabval, a)) return false;
|
1478
1466
|
|
1479
1467
|
/* TODO(haberman): add overwrite operation to minimize number of lookups. */
|
1480
|
-
|
1481
|
-
return
|
1468
|
+
upb_strtable_remove(&map->table, strkey.data, strkey.size, NULL);
|
1469
|
+
return upb_strtable_insert(&map->table, strkey.data, strkey.size, tabval, a);
|
1482
1470
|
}
|
1483
1471
|
|
1484
1472
|
UPB_INLINE bool _upb_map_delete(upb_map *map, const void *key, size_t key_size) {
|
1485
1473
|
upb_strview k = _upb_map_tokey(key, key_size);
|
1486
|
-
return
|
1474
|
+
return upb_strtable_remove(&map->table, k.data, k.size, NULL);
|
1487
1475
|
}
|
1488
1476
|
|
1489
1477
|
UPB_INLINE void _upb_map_clear(upb_map *map) {
|
@@ -1515,7 +1503,7 @@ UPB_INLINE void *_upb_msg_map_next(const upb_msg *msg, size_t ofs,
|
|
1515
1503
|
UPB_INLINE bool _upb_msg_map_set(upb_msg *msg, size_t ofs, const void *key,
|
1516
1504
|
size_t key_size, void *val, size_t val_size,
|
1517
1505
|
upb_arena *arena) {
|
1518
|
-
upb_map **map =
|
1506
|
+
upb_map **map = UPB_PTR_AT(msg, ofs, upb_map *);
|
1519
1507
|
if (!*map) {
|
1520
1508
|
*map = _upb_map_new(arena, key_size, val_size);
|
1521
1509
|
}
|
@@ -1548,8 +1536,7 @@ UPB_INLINE void _upb_msg_map_key(const void* msg, void* key, size_t size) {
|
|
1548
1536
|
|
1549
1537
|
UPB_INLINE void _upb_msg_map_value(const void* msg, void* val, size_t size) {
|
1550
1538
|
const upb_tabent *ent = (const upb_tabent*)msg;
|
1551
|
-
upb_value v;
|
1552
|
-
_upb_value_setval(&v, ent->val.val);
|
1539
|
+
upb_value v = {ent->val.val};
|
1553
1540
|
_upb_map_fromvalue(v, val, size);
|
1554
1541
|
}
|
1555
1542
|
|
@@ -1612,55 +1599,14 @@ UPB_INLINE bool _upb_sortedmap_next(_upb_mapsorter *s, const upb_map *map,
|
|
1612
1599
|
return true;
|
1613
1600
|
}
|
1614
1601
|
|
1615
|
-
#undef PTR_AT
|
1616
|
-
|
1617
|
-
#ifdef __cplusplus
|
1618
|
-
} /* extern "C" */
|
1619
|
-
#endif
|
1620
|
-
|
1621
|
-
|
1622
|
-
#endif /* UPB_MSG_H_ */
|
1623
|
-
|
1624
|
-
/* Must be last. */
|
1625
|
-
|
1626
|
-
#ifdef __cplusplus
|
1627
|
-
extern "C" {
|
1628
|
-
#endif
|
1629
|
-
|
1630
|
-
enum {
|
1631
|
-
/* If set, strings will alias the input buffer instead of copying into the
|
1632
|
-
* arena. */
|
1633
|
-
UPB_DECODE_ALIAS = 1,
|
1634
|
-
};
|
1635
|
-
|
1636
|
-
#define UPB_DECODE_MAXDEPTH(depth) ((depth) << 16)
|
1637
|
-
|
1638
|
-
bool _upb_decode(const char *buf, size_t size, upb_msg *msg,
|
1639
|
-
const upb_msglayout *l, upb_arena *arena, int options);
|
1640
|
-
|
1641
|
-
UPB_INLINE
|
1642
|
-
bool upb_decode(const char *buf, size_t size, upb_msg *msg,
|
1643
|
-
const upb_msglayout *l, upb_arena *arena) {
|
1644
|
-
return _upb_decode(buf, size, msg, l, arena, 0);
|
1645
|
-
}
|
1646
|
-
|
1647
1602
|
#ifdef __cplusplus
|
1648
1603
|
} /* extern "C" */
|
1649
1604
|
#endif
|
1650
1605
|
|
1651
1606
|
|
1652
|
-
#endif
|
1653
|
-
/*
|
1654
|
-
** Internal implementation details of the decoder that are shared between
|
1655
|
-
** decode.c and decode_fast.c.
|
1656
|
-
*/
|
1657
|
-
|
1658
|
-
#ifndef UPB_DECODE_INT_H_
|
1659
|
-
#define UPB_DECODE_INT_H_
|
1660
|
-
|
1661
|
-
#include <setjmp.h>
|
1662
|
-
|
1607
|
+
#endif /* UPB_MSG_INT_H_ */
|
1663
1608
|
|
1609
|
+
/** upb/upb_internal.h ************************************************************/
|
1664
1610
|
#ifndef UPB_INT_H_
|
1665
1611
|
#define UPB_INT_H_
|
1666
1612
|
|
@@ -1670,7 +1616,10 @@ typedef struct mem_block mem_block;
|
|
1670
1616
|
|
1671
1617
|
struct upb_arena {
|
1672
1618
|
_upb_arena_head head;
|
1673
|
-
|
1619
|
+
/* Stores cleanup metadata for this arena.
|
1620
|
+
* - a pointer to the current cleanup counter.
|
1621
|
+
* - a boolean indicating if there is an unowned initial block. */
|
1622
|
+
uintptr_t cleanup_metadata;
|
1674
1623
|
|
1675
1624
|
/* Allocator to allocate arena blocks. We are responsible for freeing these
|
1676
1625
|
* when we are destroyed. */
|
@@ -1792,10 +1741,11 @@ bool decode_isdone(upb_decstate *d, const char **ptr) {
|
|
1792
1741
|
}
|
1793
1742
|
}
|
1794
1743
|
|
1744
|
+
#if UPB_FASTTABLE
|
1795
1745
|
UPB_INLINE
|
1796
1746
|
const char *fastdecode_tagdispatch(upb_decstate *d, const char *ptr,
|
1797
1747
|
upb_msg *msg, intptr_t table,
|
1798
|
-
uint64_t hasbits,
|
1748
|
+
uint64_t hasbits, uint64_t tag) {
|
1799
1749
|
const upb_msglayout *table_p = decode_totablep(table);
|
1800
1750
|
uint8_t mask = table;
|
1801
1751
|
uint64_t data;
|
@@ -1803,8 +1753,10 @@ const char *fastdecode_tagdispatch(upb_decstate *d, const char *ptr,
|
|
1803
1753
|
UPB_ASSUME((idx & 7) == 0);
|
1804
1754
|
idx >>= 3;
|
1805
1755
|
data = table_p->fasttable[idx].field_data ^ tag;
|
1806
|
-
return table_p->fasttable[idx].field_parser(d, ptr, msg, table,
|
1756
|
+
UPB_MUSTTAIL return table_p->fasttable[idx].field_parser(d, ptr, msg, table,
|
1757
|
+
hasbits, data);
|
1807
1758
|
}
|
1759
|
+
#endif
|
1808
1760
|
|
1809
1761
|
UPB_INLINE uint32_t fastdecode_loadtag(const char* ptr) {
|
1810
1762
|
uint16_t tag;
|
@@ -1837,9 +1789,11 @@ UPB_INLINE void decode_poplimit(upb_decstate *d, const char *ptr,
|
|
1837
1789
|
|
1838
1790
|
|
1839
1791
|
#endif /* UPB_DECODE_INT_H_ */
|
1792
|
+
|
1793
|
+
/** upb/encode.h ************************************************************/
|
1840
1794
|
/*
|
1841
|
-
|
1842
|
-
*/
|
1795
|
+
* upb_encode: parsing into a upb_msg using a upb_msglayout.
|
1796
|
+
*/
|
1843
1797
|
|
1844
1798
|
#ifndef UPB_ENCODE_H_
|
1845
1799
|
#define UPB_ENCODE_H_
|
@@ -1880,6 +1834,8 @@ UPB_INLINE char *upb_encode(const void *msg, const upb_msglayout *l,
|
|
1880
1834
|
#endif
|
1881
1835
|
|
1882
1836
|
#endif /* UPB_ENCODE_H_ */
|
1837
|
+
|
1838
|
+
/** upb/decode_fast.h ************************************************************/
|
1883
1839
|
// These are the specialized field parser functions for the fast parser.
|
1884
1840
|
// Generated tables will refer to these by name.
|
1885
1841
|
//
|
@@ -2005,7 +1961,8 @@ TAGBYTES(r)
|
|
2005
1961
|
#undef UPB_PARSE_PARAMS
|
2006
1962
|
|
2007
1963
|
#endif /* UPB_DECODE_FAST_H_ */
|
2008
|
-
|
1964
|
+
|
1965
|
+
/** google/protobuf/descriptor.upb.h ************************************************************//* This file was generated by upbc (the upb compiler) from the input
|
2009
1966
|
* file:
|
2010
1967
|
*
|
2011
1968
|
* google/protobuf/descriptor.proto
|
@@ -3884,18 +3841,20 @@ UPB_INLINE void google_protobuf_GeneratedCodeInfo_Annotation_set_end(google_prot
|
|
3884
3841
|
|
3885
3842
|
|
3886
3843
|
#endif /* GOOGLE_PROTOBUF_DESCRIPTOR_PROTO_UPB_H_ */
|
3844
|
+
|
3845
|
+
/** upb/def.h ************************************************************/
|
3887
3846
|
/*
|
3888
|
-
|
3889
|
-
|
3890
|
-
|
3891
|
-
|
3892
|
-
|
3893
|
-
|
3894
|
-
|
3895
|
-
|
3896
|
-
|
3897
|
-
|
3898
|
-
*/
|
3847
|
+
* Defs are upb's internal representation of the constructs that can appear
|
3848
|
+
* in a .proto file:
|
3849
|
+
*
|
3850
|
+
* - upb_msgdef: describes a "message" construct.
|
3851
|
+
* - upb_fielddef: describes a message field.
|
3852
|
+
* - upb_filedef: describes a .proto file and its defs.
|
3853
|
+
* - upb_enumdef: describes an enum.
|
3854
|
+
* - upb_oneofdef: describes a oneof.
|
3855
|
+
*
|
3856
|
+
* TODO: definitions of services.
|
3857
|
+
*/
|
3899
3858
|
|
3900
3859
|
#ifndef UPB_DEF_H_
|
3901
3860
|
#define UPB_DEF_H_
|
@@ -3991,9 +3950,6 @@ const upb_msgdef *upb_fielddef_msgsubdef(const upb_fielddef *f);
|
|
3991
3950
|
const upb_enumdef *upb_fielddef_enumsubdef(const upb_fielddef *f);
|
3992
3951
|
const upb_msglayout_field *upb_fielddef_layout(const upb_fielddef *f);
|
3993
3952
|
|
3994
|
-
/* Internal only. */
|
3995
|
-
uint32_t upb_fielddef_selectorbase(const upb_fielddef *f);
|
3996
|
-
|
3997
3953
|
/* upb_oneofdef ***************************************************************/
|
3998
3954
|
|
3999
3955
|
typedef upb_inttable_iter upb_oneof_iter;
|
@@ -4078,10 +4034,6 @@ UPB_INLINE const upb_fielddef *upb_msgdef_ntofz(const upb_msgdef *m,
|
|
4078
4034
|
return upb_msgdef_ntof(m, name, strlen(name));
|
4079
4035
|
}
|
4080
4036
|
|
4081
|
-
/* Internal-only. */
|
4082
|
-
size_t upb_msgdef_selectorcount(const upb_msgdef *m);
|
4083
|
-
uint32_t upb_msgdef_submsgfieldcount(const upb_msgdef *m);
|
4084
|
-
|
4085
4037
|
/* Lookup of either field or oneof by name. Returns whether either was found.
|
4086
4038
|
* If the return is true, then the found def will be set, and the non-found
|
4087
4039
|
* one set to NULL. */
|
@@ -4197,6 +4149,7 @@ bool _upb_symtab_loaddefinit(upb_symtab *s, const upb_def_init *init);
|
|
4197
4149
|
|
4198
4150
|
#endif /* UPB_DEF_H_ */
|
4199
4151
|
|
4152
|
+
/** upb/reflection.h ************************************************************/
|
4200
4153
|
#ifndef UPB_REFLECTION_H_
|
4201
4154
|
#define UPB_REFLECTION_H_
|
4202
4155
|
|
@@ -4278,17 +4231,9 @@ bool upb_msg_next(const upb_msg *msg, const upb_msgdef *m,
|
|
4278
4231
|
const upb_symtab *ext_pool, const upb_fielddef **f,
|
4279
4232
|
upb_msgval *val, size_t *iter);
|
4280
4233
|
|
4281
|
-
/* Adds unknown data (serialized protobuf data) to the given message. The data
|
4282
|
-
* is copied into the message instance. */
|
4283
|
-
void upb_msg_addunknown(upb_msg *msg, const char *data, size_t len,
|
4284
|
-
upb_arena *arena);
|
4285
|
-
|
4286
4234
|
/* Clears all unknown field data from this message and all submessages. */
|
4287
4235
|
bool upb_msg_discardunknown(upb_msg *msg, const upb_msgdef *m, int maxdepth);
|
4288
4236
|
|
4289
|
-
/* Returns a reference to the message's unknown data. */
|
4290
|
-
const char *upb_msg_getunknown(const upb_msg *msg, size_t *len);
|
4291
|
-
|
4292
4237
|
/** upb_array *****************************************************************/
|
4293
4238
|
|
4294
4239
|
/* Creates a new array on the given arena that holds elements of this type. */
|
@@ -4370,6 +4315,7 @@ void upb_mapiter_setvalue(upb_map *map, size_t iter, upb_msgval value);
|
|
4370
4315
|
|
4371
4316
|
#endif /* UPB_REFLECTION_H_ */
|
4372
4317
|
|
4318
|
+
/** upb/json_decode.h ************************************************************/
|
4373
4319
|
#ifndef UPB_JSONDECODE_H_
|
4374
4320
|
#define UPB_JSONDECODE_H_
|
4375
4321
|
|
@@ -4392,6 +4338,7 @@ bool upb_json_decode(const char *buf, size_t size, upb_msg *msg,
|
|
4392
4338
|
|
4393
4339
|
#endif /* UPB_JSONDECODE_H_ */
|
4394
4340
|
|
4341
|
+
/** upb/json_encode.h ************************************************************/
|
4395
4342
|
#ifndef UPB_JSONENCODE_H_
|
4396
4343
|
#define UPB_JSONENCODE_H_
|
4397
4344
|
|
@@ -4426,27 +4373,39 @@ size_t upb_json_encode(const upb_msg *msg, const upb_msgdef *m,
|
|
4426
4373
|
#endif
|
4427
4374
|
|
4428
4375
|
#endif /* UPB_JSONENCODE_H_ */
|
4376
|
+
|
4377
|
+
/** upb/port_undef.inc ************************************************************/
|
4429
4378
|
/* See port_def.inc. This should #undef all macros #defined there. */
|
4430
4379
|
|
4431
|
-
#undef UPB_MAPTYPE_STRING
|
4432
4380
|
#undef UPB_SIZE
|
4433
4381
|
#undef UPB_PTR_AT
|
4434
4382
|
#undef UPB_READ_ONEOF
|
4435
4383
|
#undef UPB_WRITE_ONEOF
|
4384
|
+
#undef UPB_MAPTYPE_STRING
|
4436
4385
|
#undef UPB_INLINE
|
4437
4386
|
#undef UPB_ALIGN_UP
|
4438
4387
|
#undef UPB_ALIGN_DOWN
|
4439
4388
|
#undef UPB_ALIGN_MALLOC
|
4440
4389
|
#undef UPB_ALIGN_OF
|
4390
|
+
#undef UPB_LIKELY
|
4391
|
+
#undef UPB_UNLIKELY
|
4441
4392
|
#undef UPB_FORCEINLINE
|
4442
4393
|
#undef UPB_NOINLINE
|
4443
4394
|
#undef UPB_NORETURN
|
4395
|
+
#undef UPB_PRINTF
|
4444
4396
|
#undef UPB_MAX
|
4445
4397
|
#undef UPB_MIN
|
4446
4398
|
#undef UPB_UNUSED
|
4447
4399
|
#undef UPB_ASSUME
|
4448
4400
|
#undef UPB_ASSERT
|
4449
4401
|
#undef UPB_UNREACHABLE
|
4402
|
+
#undef UPB_SETJMP
|
4403
|
+
#undef UPB_LONGJMP
|
4404
|
+
#undef UPB_PTRADD
|
4405
|
+
#undef UPB_MUSTTAIL
|
4406
|
+
#undef UPB_FASTTABLE_SUPPORTED
|
4407
|
+
#undef UPB_FASTTABLE
|
4408
|
+
#undef UPB_FASTTABLE_INIT
|
4450
4409
|
#undef UPB_POISON_MEMORY_REGION
|
4451
4410
|
#undef UPB_UNPOISON_MEMORY_REGION
|
4452
4411
|
#undef UPB_ASAN
|