Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:13:18

0001 // Protocol Buffers - Google's data interchange format
0002 // Copyright 2023 Google LLC.  All rights reserved.
0003 //
0004 // Use of this source code is governed by a BSD-style
0005 // license that can be found in the LICENSE file or at
0006 // https://developers.google.com/open-source/licenses/bsd
0007 
0008 #ifndef UPB_REFLECTION_DEF_TYPE_H_
0009 #define UPB_REFLECTION_DEF_TYPE_H_
0010 
0011 #include "upb/hash/common.h"
0012 
0013 // Must be last.
0014 #include "upb/port/def.inc"
0015 
0016 // Inside a symtab we store tagged pointers to specific def types.
0017 typedef enum {
0018   UPB_DEFTYPE_MASK = 7,
0019 
0020   // Only inside symtab table.
0021   UPB_DEFTYPE_EXT = 0,
0022   UPB_DEFTYPE_MSG = 1,
0023   UPB_DEFTYPE_ENUM = 2,
0024   UPB_DEFTYPE_ENUMVAL = 3,
0025   UPB_DEFTYPE_SERVICE = 4,
0026 
0027   // Only inside message table.
0028   UPB_DEFTYPE_FIELD = 0,
0029   UPB_DEFTYPE_ONEOF = 1,
0030 } upb_deftype_t;
0031 
0032 #ifdef __cplusplus
0033 extern "C" {
0034 #endif
0035 
0036 // Our 3-bit pointer tagging requires all pointers to be multiples of 8.
0037 // The arena will always yield 8-byte-aligned addresses, however we put
0038 // the defs into arrays. For each element in the array to be 8-byte-aligned,
0039 // the sizes of each def type must also be a multiple of 8.
0040 //
0041 // If any of these asserts fail, we need to add or remove padding on 32-bit
0042 // machines (64-bit machines will have 8-byte alignment already due to
0043 // pointers, which all of these structs have).
0044 UPB_INLINE void _upb_DefType_CheckPadding(size_t size) {
0045   UPB_ASSERT((size & UPB_DEFTYPE_MASK) == 0);
0046 }
0047 
0048 upb_deftype_t _upb_DefType_Type(upb_value v);
0049 
0050 upb_value _upb_DefType_Pack(const void* ptr, upb_deftype_t type);
0051 
0052 const void* _upb_DefType_Unpack(upb_value v, upb_deftype_t type);
0053 
0054 #ifdef __cplusplus
0055 } /* extern "C" */
0056 #endif
0057 
0058 #include "upb/port/undef.inc"
0059 
0060 #endif /* UPB_REFLECTION_DEF_TYPE_H_ */