WPILibC++ 2027.0.0-alpha-3
Loading...
Searching...
No Matches
descriptor_constants.h
Go to the documentation of this file.
1// Protocol Buffers - Google's data interchange format
2// Copyright 2023 Google LLC. All rights reserved.
3//
4// Use of this source code is governed by a BSD-style
5// license that can be found in the LICENSE file or at
6// https://developers.google.com/open-source/licenses/bsd
7
8#ifndef UPB_BASE_DESCRIPTOR_CONSTANTS_H_
9#define UPB_BASE_DESCRIPTOR_CONSTANTS_H_
10
11// Must be last.
12#include "upb/port/def.inc"
13
14// The types a field can have. Note that this list is not identical to the
15// types defined in descriptor.proto, which gives INT32 and SINT32 separate
16// types (we distinguish the two with the "integer encoding" enum below).
17// This enum is an internal convenience only and has no meaning outside of upb.
31
32// The repeated-ness of each field; this matches descriptor.proto.
38
39// Descriptor types, as defined in descriptor.proto.
60
61#define kUpb_FieldType_SizeOf 19
62
63#ifdef __cplusplus
64extern "C" {
65#endif
66
67// Convert from upb_FieldType to upb_CType
69 static const upb_CType c_type[] = {
70 kUpb_CType_Double, // kUpb_FieldType_Double
71 kUpb_CType_Float, // kUpb_FieldType_Float
72 kUpb_CType_Int64, // kUpb_FieldType_Int64
73 kUpb_CType_UInt64, // kUpb_FieldType_UInt64
74 kUpb_CType_Int32, // kUpb_FieldType_Int32
75 kUpb_CType_UInt64, // kUpb_FieldType_Fixed64
76 kUpb_CType_UInt32, // kUpb_FieldType_Fixed32
77 kUpb_CType_Bool, // kUpb_FieldType_Bool
78 kUpb_CType_String, // kUpb_FieldType_String
79 kUpb_CType_Message, // kUpb_FieldType_Group
80 kUpb_CType_Message, // kUpb_FieldType_Message
81 kUpb_CType_Bytes, // kUpb_FieldType_Bytes
82 kUpb_CType_UInt32, // kUpb_FieldType_UInt32
83 kUpb_CType_Enum, // kUpb_FieldType_Enum
84 kUpb_CType_Int32, // kUpb_FieldType_SFixed32
85 kUpb_CType_Int64, // kUpb_FieldType_SFixed64
86 kUpb_CType_Int32, // kUpb_FieldType_SInt32
87 kUpb_CType_Int64, // kUpb_FieldType_SInt64
88 };
89
90 // -1 here because the enum is one-based but the table is zero-based.
91 return c_type[field_type - 1];
92}
93
95 // clang-format off
96 const unsigned kUnpackableTypes =
101 // clang-format on
102 return (1 << field_type) & ~kUnpackableTypes;
103}
104
105#ifdef __cplusplus
106} /* extern "C" */
107#endif
108
109#include "upb/port/undef.inc"
110
111#endif /* UPB_BASE_DESCRIPTOR_CONSTANTS_H_ */
#define UPB_INLINE
Definition def.inc:144
upb_CType
Definition descriptor_constants.h:18
@ kUpb_CType_UInt64
Definition descriptor_constants.h:27
@ kUpb_CType_UInt32
Definition descriptor_constants.h:22
@ kUpb_CType_Float
Definition descriptor_constants.h:20
@ kUpb_CType_Double
Definition descriptor_constants.h:25
@ kUpb_CType_Enum
Definition descriptor_constants.h:23
@ kUpb_CType_Bool
Definition descriptor_constants.h:19
@ kUpb_CType_Message
Definition descriptor_constants.h:24
@ kUpb_CType_Int32
Definition descriptor_constants.h:21
@ kUpb_CType_Bytes
Definition descriptor_constants.h:29
@ kUpb_CType_Int64
Definition descriptor_constants.h:26
@ kUpb_CType_String
Definition descriptor_constants.h:28
upb_FieldType
Definition descriptor_constants.h:40
@ kUpb_FieldType_Group
Definition descriptor_constants.h:50
@ kUpb_FieldType_SInt32
Definition descriptor_constants.h:57
@ kUpb_FieldType_Fixed64
Definition descriptor_constants.h:46
@ kUpb_FieldType_UInt64
Definition descriptor_constants.h:44
@ kUpb_FieldType_String
Definition descriptor_constants.h:49
@ kUpb_FieldType_Enum
Definition descriptor_constants.h:54
@ kUpb_FieldType_SInt64
Definition descriptor_constants.h:58
@ kUpb_FieldType_UInt32
Definition descriptor_constants.h:53
@ kUpb_FieldType_SFixed64
Definition descriptor_constants.h:56
@ kUpb_FieldType_Float
Definition descriptor_constants.h:42
@ kUpb_FieldType_Bool
Definition descriptor_constants.h:48
@ kUpb_FieldType_Message
Definition descriptor_constants.h:51
@ kUpb_FieldType_Double
Definition descriptor_constants.h:41
@ kUpb_FieldType_Int64
Definition descriptor_constants.h:43
@ kUpb_FieldType_Int32
Definition descriptor_constants.h:45
@ kUpb_FieldType_Fixed32
Definition descriptor_constants.h:47
@ kUpb_FieldType_SFixed32
Definition descriptor_constants.h:55
@ kUpb_FieldType_Bytes
Definition descriptor_constants.h:52
upb_Label
Definition descriptor_constants.h:33
@ kUpb_Label_Optional
Definition descriptor_constants.h:34
@ kUpb_Label_Repeated
Definition descriptor_constants.h:36
@ kUpb_Label_Required
Definition descriptor_constants.h:35
UPB_INLINE bool upb_FieldType_IsPackable(upb_FieldType field_type)
Definition descriptor_constants.h:94
UPB_INLINE upb_CType upb_FieldType_CType(upb_FieldType field_type)
Definition descriptor_constants.h:68