1 // Protocol Buffers - Google's data interchange format 2 // Copyright 2023 Google LLC. All rights reserved. 3 // 4 // Use of this source code is governed by a BSD-style 5 // license that can be found in the LICENSE file or at 6 // https://developers.google.com/open-source/licenses/bsd 7 8 #ifndef UPB_REFLECTION_DESC_STATE_INTERNAL_H_ 9 #define UPB_REFLECTION_DESC_STATE_INTERNAL_H_ 10 11 #include "upb/mem/arena.h" 12 #include "upb/mini_descriptor/internal/encode.h" 13 14 // Must be last. 15 #include "upb/port/def.inc" 16 17 // Manages the storage for mini descriptor strings as they are being encoded. 18 // TODO: Move some of this state directly into the encoder, maybe. 19 typedef struct { 20 upb_MtDataEncoder e; 21 size_t bufsize; 22 char* buf; 23 char* ptr; 24 } upb_DescState; 25 26 #ifdef __cplusplus 27 extern "C" { 28 #endif 29 _upb_DescState_Init(upb_DescState * d)30UPB_INLINE void _upb_DescState_Init(upb_DescState* d) { 31 d->bufsize = kUpb_MtDataEncoder_MinSize * 2; 32 d->buf = NULL; 33 d->ptr = NULL; 34 } 35 36 bool _upb_DescState_Grow(upb_DescState* d, upb_Arena* a); 37 38 #ifdef __cplusplus 39 } /* extern "C" */ 40 #endif 41 42 #include "upb/port/undef.inc" 43 44 #endif /* UPB_REFLECTION_DESC_STATE_INTERNAL_H_ */ 45