Back to home page

EIC code displayed by LXR

 
 

    


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

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_MESSAGE_INTERNAL_EXTENSION_H_
0009 #define UPB_MESSAGE_INTERNAL_EXTENSION_H_
0010 
0011 #include <stddef.h>
0012 
0013 #include "upb/mem/arena.h"
0014 #include "upb/message/value.h"
0015 #include "upb/mini_table/extension.h"
0016 
0017 // Must be last.
0018 #include "upb/port/def.inc"
0019 
0020 // The internal representation of an extension is self-describing: it contains
0021 // enough information that we can serialize it to binary format without needing
0022 // to look it up in a upb_ExtensionRegistry.
0023 //
0024 // This representation allocates 16 bytes to data on 64-bit platforms.
0025 // This is rather wasteful for scalars (in the extreme case of bool,
0026 // it wastes 15 bytes). We accept this because we expect messages to be
0027 // the most common extension type.
0028 typedef struct {
0029   const upb_MiniTableExtension* ext;
0030   upb_MessageValue data;
0031 } upb_Extension;
0032 
0033 #ifdef __cplusplus
0034 extern "C" {
0035 #endif
0036 
0037 // Adds the given extension data to the given message.
0038 // |ext| is copied into the message instance.
0039 // This logically replaces any previously-added extension with this number.
0040 upb_Extension* UPB_PRIVATE(_upb_Message_GetOrCreateExtension)(
0041     struct upb_Message* msg, const upb_MiniTableExtension* ext,
0042     upb_Arena* arena);
0043 
0044 // Returns an array of extensions for this message.
0045 // Note: the array is ordered in reverse relative to the order of creation.
0046 const upb_Extension* UPB_PRIVATE(_upb_Message_Getexts)(
0047     const struct upb_Message* msg, size_t* count);
0048 
0049 // Returns an extension for a message with a given mini table,
0050 // or NULL if no extension exists with this mini table.
0051 const upb_Extension* UPB_PRIVATE(_upb_Message_Getext)(
0052     const struct upb_Message* msg, const upb_MiniTableExtension* ext);
0053 
0054 #ifdef __cplusplus
0055 } /* extern "C" */
0056 #endif
0057 
0058 #include "upb/port/undef.inc"
0059 
0060 #endif /* UPB_MESSAGE_INTERNAL_EXTENSION_H_ */