File indexing completed on 2025-01-30 10:25:23
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef UPB_MESSAGE_INTERNAL_MESSAGE_H_
0016 #define UPB_MESSAGE_INTERNAL_MESSAGE_H_
0017
0018 #include <stdlib.h>
0019 #include <string.h>
0020
0021 #include "upb/mem/arena.h"
0022 #include "upb/message/internal/extension.h"
0023 #include "upb/mini_table/message.h"
0024
0025
0026 #include "upb/port/def.inc"
0027
0028 #ifdef __cplusplus
0029 extern "C" {
0030 #endif
0031
0032 extern const float kUpb_FltInfinity;
0033 extern const double kUpb_Infinity;
0034 extern const double kUpb_NaN;
0035
0036
0037
0038
0039 typedef struct upb_Message_Internal {
0040
0041
0042 uint32_t size;
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056 uint32_t unknown_end;
0057 uint32_t ext_begin;
0058
0059
0060 } upb_Message_Internal;
0061
0062 #ifdef UPB_TRACING_ENABLED
0063 UPB_API void upb_Message_LogNewMessage(const upb_MiniTable* m,
0064 const upb_Arena* arena);
0065 UPB_API void upb_Message_SetNewMessageTraceHandler(
0066 void (*handler)(const upb_MiniTable*, const upb_Arena*));
0067 #endif
0068
0069
0070 UPB_INLINE struct upb_Message* _upb_Message_New(const upb_MiniTable* m,
0071 upb_Arena* a) {
0072 #ifdef UPB_TRACING_ENABLED
0073 upb_Message_LogNewMessage(m, a);
0074 #endif
0075
0076 const int size = m->UPB_PRIVATE(size);
0077 struct upb_Message* msg = (struct upb_Message*)upb_Arena_Malloc(a, size);
0078 if (UPB_UNLIKELY(!msg)) return NULL;
0079 memset(msg, 0, size);
0080 return msg;
0081 }
0082
0083
0084 void _upb_Message_DiscardUnknown_shallow(struct upb_Message* msg);
0085
0086
0087
0088 bool UPB_PRIVATE(_upb_Message_AddUnknown)(struct upb_Message* msg,
0089 const char* data, size_t len,
0090 upb_Arena* arena);
0091
0092 bool UPB_PRIVATE(_upb_Message_Realloc)(struct upb_Message* msg, size_t need,
0093 upb_Arena* arena);
0094
0095 #ifdef __cplusplus
0096 }
0097 #endif
0098
0099 #include "upb/port/undef.inc"
0100
0101 #endif