xref: /aosp_15_r20/external/grpc-grpc/third_party/upb/upb/reflection/internal/def_pool.h (revision cc02d7e222339f7a4f6ba5f422e6413f4bd931f2)
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_DEF_POOL_INTERNAL_H_
9 #define UPB_REFLECTION_DEF_POOL_INTERNAL_H_
10 
11 #include "upb/mini_descriptor/decode.h"
12 #include "upb/reflection/def_pool.h"
13 
14 // Must be last.
15 #include "upb/port/def.inc"
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
21 upb_Arena* _upb_DefPool_Arena(const upb_DefPool* s);
22 size_t _upb_DefPool_BytesLoaded(const upb_DefPool* s);
23 upb_ExtensionRegistry* _upb_DefPool_ExtReg(const upb_DefPool* s);
24 
25 bool _upb_DefPool_InsertExt(upb_DefPool* s, const upb_MiniTableExtension* ext,
26                             const upb_FieldDef* f);
27 bool _upb_DefPool_InsertSym(upb_DefPool* s, upb_StringView sym, upb_value v,
28                             upb_Status* status);
29 bool _upb_DefPool_LookupSym(const upb_DefPool* s, const char* sym, size_t size,
30                             upb_value* v);
31 
32 void** _upb_DefPool_ScratchData(const upb_DefPool* s);
33 size_t* _upb_DefPool_ScratchSize(const upb_DefPool* s);
34 void _upb_DefPool_SetPlatform(upb_DefPool* s, upb_MiniTablePlatform platform);
35 
36 // For generated code only: loads a generated descriptor.
37 typedef struct _upb_DefPool_Init {
38   struct _upb_DefPool_Init** deps;  // Dependencies of this file.
39   const upb_MiniTableFile* layout;
40   const char* filename;
41   upb_StringView descriptor;  // Serialized descriptor.
42 } _upb_DefPool_Init;
43 
44 bool _upb_DefPool_LoadDefInit(upb_DefPool* s, const _upb_DefPool_Init* init);
45 
46 // Should only be directly called by tests. This variant lets us suppress
47 // the use of compiled-in tables, forcing a rebuild of the tables at runtime.
48 bool _upb_DefPool_LoadDefInitEx(upb_DefPool* s, const _upb_DefPool_Init* init,
49                                 bool rebuild_minitable);
50 
51 #ifdef __cplusplus
52 } /* extern "C" */
53 #endif
54 
55 #include "upb/port/undef.inc"
56 
57 #endif /* UPB_REFLECTION_DEF_POOL_INTERNAL_H_ */
58