Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-17 09:32:30

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 // Users should include array.h or map.h instead.
0009 // IWYU pragma: private, include "upb/message/array.h"
0010 
0011 #ifndef UPB_MESSAGE_VALUE_H_
0012 #define UPB_MESSAGE_VALUE_H_
0013 
0014 #include <stdint.h>
0015 #include <string.h>
0016 
0017 #include "upb/base/string_view.h"
0018 #include "upb/message/internal/types.h"
0019 
0020 // Must be last.
0021 #include "upb/port/def.inc"
0022 
0023 #ifdef __cplusplus
0024 extern "C" {
0025 #endif
0026 
0027 typedef union {
0028   bool bool_val;
0029   float float_val;
0030   double double_val;
0031   int32_t int32_val;
0032   int64_t int64_val;
0033   uint32_t uint32_val;
0034   uint64_t uint64_val;
0035   const struct upb_Array* array_val;
0036   const struct upb_Map* map_val;
0037   const struct upb_Message* msg_val;
0038   upb_StringView str_val;
0039 
0040   // EXPERIMENTAL: A tagged upb_Message*.  Users must use this instead of
0041   // msg_val if unlinked sub-messages may possibly be in use.  See the
0042   // documentation in kUpb_DecodeOption_ExperimentalAllowUnlinked for more
0043   // information.
0044   uintptr_t tagged_msg_val;  // upb_TaggedMessagePtr
0045 
0046   // For an extension field, we are essentially treating ext->data (a
0047   // upb_MessageValue) as if it were a message with one field that lives at
0048   // offset 0. This works because upb_MessageValue is precisely one value that
0049   // can hold any type of data. Recall that an extension can be of any type
0050   // (scalar, repeated, or message). For a message extension, that will be a
0051   // single upb_Message* at offset 0 of the upb_MessageValue.
0052   struct upb_Message UPB_PRIVATE(ext_msg_val);
0053 } upb_MessageValue;
0054 
0055 UPB_API_INLINE upb_MessageValue upb_MessageValue_Zero(void) {
0056   upb_MessageValue zero;
0057   memset(&zero, 0, sizeof(zero));
0058   return zero;
0059 }
0060 
0061 typedef union {
0062   struct upb_Array* array;
0063   struct upb_Map* map;
0064   struct upb_Message* msg;
0065 } upb_MutableMessageValue;
0066 
0067 UPB_API_INLINE upb_MutableMessageValue upb_MutableMessageValue_Zero(void) {
0068   upb_MutableMessageValue zero;
0069   memset(&zero, 0, sizeof(zero));
0070   return zero;
0071 }
0072 
0073 #ifdef __cplusplus
0074 } /* extern "C" */
0075 #endif
0076 
0077 #include "upb/port/undef.inc"
0078 
0079 #endif /* UPB_MESSAGE_VALUE_H_ */