1 /*
2 * Copyright (c) 2009-2022, Google LLC
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of Google LLC nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT,
20 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28 #ifndef UPB_MINI_TABLE_COMMON_INTERNAL_H_
29 #define UPB_MINI_TABLE_COMMON_INTERNAL_H_
30
31 #include "upb/base/descriptor_constants.h"
32
33 // Must be last.
34 #include "upb/port/def.inc"
35
36 typedef enum {
37 kUpb_EncodedType_Double = 0,
38 kUpb_EncodedType_Float = 1,
39 kUpb_EncodedType_Fixed32 = 2,
40 kUpb_EncodedType_Fixed64 = 3,
41 kUpb_EncodedType_SFixed32 = 4,
42 kUpb_EncodedType_SFixed64 = 5,
43 kUpb_EncodedType_Int32 = 6,
44 kUpb_EncodedType_UInt32 = 7,
45 kUpb_EncodedType_SInt32 = 8,
46 kUpb_EncodedType_Int64 = 9,
47 kUpb_EncodedType_UInt64 = 10,
48 kUpb_EncodedType_SInt64 = 11,
49 kUpb_EncodedType_OpenEnum = 12,
50 kUpb_EncodedType_Bool = 13,
51 kUpb_EncodedType_Bytes = 14,
52 kUpb_EncodedType_String = 15,
53 kUpb_EncodedType_Group = 16,
54 kUpb_EncodedType_Message = 17,
55 kUpb_EncodedType_ClosedEnum = 18,
56
57 kUpb_EncodedType_RepeatedBase = 20,
58 } upb_EncodedType;
59
60 typedef enum {
61 kUpb_EncodedFieldModifier_FlipPacked = 1 << 0,
62 kUpb_EncodedFieldModifier_IsRequired = 1 << 1,
63 kUpb_EncodedFieldModifier_IsProto3Singular = 1 << 2,
64 } upb_EncodedFieldModifier;
65
66 enum {
67 kUpb_EncodedValue_MinField = ' ',
68 kUpb_EncodedValue_MaxField = 'I',
69 kUpb_EncodedValue_MinModifier = 'L',
70 kUpb_EncodedValue_MaxModifier = '[',
71 kUpb_EncodedValue_End = '^',
72 kUpb_EncodedValue_MinSkip = '_',
73 kUpb_EncodedValue_MaxSkip = '~',
74 kUpb_EncodedValue_OneofSeparator = '~',
75 kUpb_EncodedValue_FieldSeparator = '|',
76 kUpb_EncodedValue_MinOneofField = ' ',
77 kUpb_EncodedValue_MaxOneofField = 'b',
78 kUpb_EncodedValue_MaxEnumMask = 'A',
79 };
80
81 enum {
82 kUpb_EncodedVersion_EnumV1 = '!',
83 kUpb_EncodedVersion_ExtensionV1 = '#',
84 kUpb_EncodedVersion_MapV1 = '%',
85 kUpb_EncodedVersion_MessageV1 = '$',
86 kUpb_EncodedVersion_MessageSetV1 = '&',
87 };
88
89 #ifdef __cplusplus
90 extern "C" {
91 #endif
92
_upb_ToBase92(int8_t ch)93 UPB_INLINE char _upb_ToBase92(int8_t ch) {
94 extern const char _kUpb_ToBase92[];
95 UPB_ASSERT(0 <= ch && ch < 92);
96 return _kUpb_ToBase92[ch];
97 }
98
_upb_FromBase92(uint8_t ch)99 UPB_INLINE char _upb_FromBase92(uint8_t ch) {
100 extern const int8_t _kUpb_FromBase92[];
101 if (' ' > ch || ch > '~') return -1;
102 return _kUpb_FromBase92[ch - ' '];
103 }
104
105 #ifdef __cplusplus
106 } /* extern "C" */
107 #endif
108
109 #include "upb/port/undef.inc"
110
111 #endif /* UPB_MINI_TABLE_COMMON_INTERNAL_H_ */
112