• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_UTIL_DEF_TO_PROTO_H_
9 #define UPB_UTIL_DEF_TO_PROTO_H_
10 
11 #include "upb/reflection/def.h"
12 
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16 
17 // Functions for converting defs back to the equivalent descriptor proto.
18 // Ultimately the goal is that a round-trip proto->def->proto is lossless.  Each
19 // function returns a new proto created in arena `a`, or NULL if memory
20 // allocation failed.
21 google_protobuf_DescriptorProto* upb_MessageDef_ToProto(const upb_MessageDef* m,
22                                                         upb_Arena* a);
23 google_protobuf_EnumDescriptorProto* upb_EnumDef_ToProto(const upb_EnumDef* e,
24                                                          upb_Arena* a);
25 google_protobuf_EnumValueDescriptorProto* upb_EnumValueDef_ToProto(
26     const upb_EnumValueDef* e, upb_Arena* a);
27 google_protobuf_FieldDescriptorProto* upb_FieldDef_ToProto(
28     const upb_FieldDef* f, upb_Arena* a);
29 google_protobuf_OneofDescriptorProto* upb_OneofDef_ToProto(
30     const upb_OneofDef* o, upb_Arena* a);
31 google_protobuf_FileDescriptorProto* upb_FileDef_ToProto(const upb_FileDef* f,
32                                                          upb_Arena* a);
33 google_protobuf_MethodDescriptorProto* upb_MethodDef_ToProto(
34     const upb_MethodDef* m, upb_Arena* a);
35 google_protobuf_ServiceDescriptorProto* upb_ServiceDef_ToProto(
36     const upb_ServiceDef* s, upb_Arena* a);
37 
38 #ifdef __cplusplus
39 } /* extern "C" */
40 #endif
41 
42 #endif /* UPB_UTIL_DEF_TO_PROTO_H_ */
43