File indexing completed on 2025-01-30 10:25:22
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef UPB_BASE_DESCRIPTOR_CONSTANTS_H_
0009 #define UPB_BASE_DESCRIPTOR_CONSTANTS_H_
0010
0011
0012 #include "upb/port/def.inc"
0013
0014
0015
0016
0017
0018 typedef enum {
0019 kUpb_CType_Bool = 1,
0020 kUpb_CType_Float = 2,
0021 kUpb_CType_Int32 = 3,
0022 kUpb_CType_UInt32 = 4,
0023 kUpb_CType_Enum = 5,
0024 kUpb_CType_Message = 6,
0025 kUpb_CType_Double = 7,
0026 kUpb_CType_Int64 = 8,
0027 kUpb_CType_UInt64 = 9,
0028 kUpb_CType_String = 10,
0029 kUpb_CType_Bytes = 11
0030 } upb_CType;
0031
0032
0033 typedef enum {
0034 kUpb_Label_Optional = 1,
0035 kUpb_Label_Required = 2,
0036 kUpb_Label_Repeated = 3
0037 } upb_Label;
0038
0039
0040 typedef enum {
0041 kUpb_FieldType_Double = 1,
0042 kUpb_FieldType_Float = 2,
0043 kUpb_FieldType_Int64 = 3,
0044 kUpb_FieldType_UInt64 = 4,
0045 kUpb_FieldType_Int32 = 5,
0046 kUpb_FieldType_Fixed64 = 6,
0047 kUpb_FieldType_Fixed32 = 7,
0048 kUpb_FieldType_Bool = 8,
0049 kUpb_FieldType_String = 9,
0050 kUpb_FieldType_Group = 10,
0051 kUpb_FieldType_Message = 11,
0052 kUpb_FieldType_Bytes = 12,
0053 kUpb_FieldType_UInt32 = 13,
0054 kUpb_FieldType_Enum = 14,
0055 kUpb_FieldType_SFixed32 = 15,
0056 kUpb_FieldType_SFixed64 = 16,
0057 kUpb_FieldType_SInt32 = 17,
0058 kUpb_FieldType_SInt64 = 18,
0059 } upb_FieldType;
0060
0061 #define kUpb_FieldType_SizeOf 19
0062
0063 #ifdef __cplusplus
0064 extern "C" {
0065 #endif
0066
0067
0068 UPB_INLINE upb_CType upb_FieldType_CType(upb_FieldType field_type) {
0069 static const upb_CType c_type[] = {
0070 kUpb_CType_Double,
0071 kUpb_CType_Float,
0072 kUpb_CType_Int64,
0073 kUpb_CType_UInt64,
0074 kUpb_CType_Int32,
0075 kUpb_CType_UInt64,
0076 kUpb_CType_UInt32,
0077 kUpb_CType_Bool,
0078 kUpb_CType_String,
0079 kUpb_CType_Message,
0080 kUpb_CType_Message,
0081 kUpb_CType_Bytes,
0082 kUpb_CType_UInt32,
0083 kUpb_CType_Enum,
0084 kUpb_CType_Int32,
0085 kUpb_CType_Int64,
0086 kUpb_CType_Int32,
0087 kUpb_CType_Int64,
0088 };
0089
0090
0091 return c_type[field_type - 1];
0092 }
0093
0094 UPB_INLINE bool upb_FieldType_IsPackable(upb_FieldType field_type) {
0095
0096 const unsigned kUnpackableTypes =
0097 (1 << kUpb_FieldType_String) |
0098 (1 << kUpb_FieldType_Bytes) |
0099 (1 << kUpb_FieldType_Message) |
0100 (1 << kUpb_FieldType_Group);
0101
0102 return (1 << field_type) & ~kUnpackableTypes;
0103 }
0104
0105 #ifdef __cplusplus
0106 }
0107 #endif
0108
0109 #include "upb/port/undef.inc"
0110
0111 #endif