create reflection_internal library

internal declarations are now physically removed from the public headers

PiperOrigin-RevId: 478921131
pull/13171/head
Eric Salo 2 years ago committed by Copybara-Service
parent 52c1598554
commit 44916d7d27
  1. 68
      BUILD
  2. 1
      python/BUILD
  3. 1
      python/extension_dict.c
  4. 3
      upb/reflection/def_builder.c
  5. 10
      upb/reflection/def_builder_internal.h
  6. 3
      upb/reflection/def_builder_test.cc
  7. 17
      upb/reflection/def_pool.c
  8. 33
      upb/reflection/def_pool.h
  9. 77
      upb/reflection/def_pool_internal.h
  10. 2
      upb/reflection/desc_state.c
  11. 6
      upb/reflection/desc_state_internal.h
  12. 15
      upb/reflection/enum_def.c
  13. 11
      upb/reflection/enum_def.h
  14. 55
      upb/reflection/enum_def_internal.h
  15. 11
      upb/reflection/enum_value_def.c
  16. 13
      upb/reflection/enum_value_def.h
  17. 57
      upb/reflection/enum_value_def_internal.h
  18. 11
      upb/reflection/extension_range.c
  19. 10
      upb/reflection/extension_range.h
  20. 54
      upb/reflection/extension_range_internal.h
  21. 21
      upb/reflection/field_def.c
  22. 24
      upb/reflection/field_def.h
  23. 68
      upb/reflection/field_def_internal.h
  24. 15
      upb/reflection/file_def.c
  25. 13
      upb/reflection/file_def.h
  26. 57
      upb/reflection/file_def_internal.h
  27. 5
      upb/reflection/message.c
  28. 19
      upb/reflection/message_def.c
  29. 18
      upb/reflection/message_def.h
  30. 62
      upb/reflection/message_def_internal.h
  31. 7
      upb/reflection/method_def.c
  32. 9
      upb/reflection/method_def.h
  33. 53
      upb/reflection/method_def_internal.h
  34. 11
      upb/reflection/oneof_def.c
  35. 13
      upb/reflection/oneof_def.h
  36. 57
      upb/reflection/oneof_def_internal.h
  37. 11
      upb/reflection/service_def.c
  38. 9
      upb/reflection/service_def.h
  39. 53
      upb/reflection/service_def_internal.h
  40. 1
      upb/util/BUILD
  41. 2
      upb/util/def_to_proto.c
  42. 1
      upbc/protoc-gen-upbdefs.cc

68
BUILD

@ -346,12 +346,14 @@ cc_library(
"upb/port_def.inc",
"upb/port_undef.inc",
"upb/reflection/def.h",
"upb/reflection/def_pool_internal.h",
],
copts = UPB_DEFAULT_COPTS,
visibility = ["//visibility:public"],
deps = [
":descriptor_upb_proto",
":reflection",
":reflection_internal",
":table_internal",
],
)
@ -397,32 +399,42 @@ cc_library(
srcs = [
"upb/reflection/common.h",
"upb/reflection/def_builder.c",
"upb/reflection/def_builder.h",
"upb/reflection/def_builder_internal.h",
"upb/reflection/def_pool.c",
"upb/reflection/def_pool.h",
"upb/reflection/def_pool_internal.h",
"upb/reflection/def_type.c",
"upb/reflection/def_type.h",
"upb/reflection/desc_state.c",
"upb/reflection/desc_state.h",
"upb/reflection/desc_state_internal.h",
"upb/reflection/enum_def.c",
"upb/reflection/enum_def.h",
"upb/reflection/enum_def_internal.h",
"upb/reflection/enum_value_def.c",
"upb/reflection/enum_value_def.h",
"upb/reflection/enum_value_def_internal.h",
"upb/reflection/extension_range.c",
"upb/reflection/extension_range.h",
"upb/reflection/extension_range_internal.h",
"upb/reflection/field_def.c",
"upb/reflection/field_def.h",
"upb/reflection/field_def_internal.h",
"upb/reflection/file_def.c",
"upb/reflection/file_def.h",
"upb/reflection/file_def_internal.h",
"upb/reflection/message.c",
"upb/reflection/message_def.c",
"upb/reflection/message_def.h",
"upb/reflection/message_def_internal.h",
"upb/reflection/method_def.c",
"upb/reflection/method_def.h",
"upb/reflection/method_def_internal.h",
"upb/reflection/oneof_def.c",
"upb/reflection/oneof_def.h",
"upb/reflection/oneof_def_internal.h",
"upb/reflection/service_def.c",
"upb/reflection/service_def.h",
"upb/reflection/service_def_internal.h",
],
hdrs = [
"upb/def.h",
@ -447,6 +459,51 @@ cc_library(
],
)
cc_library(
name = "reflection_internal",
srcs = [
"upb/reflection/common.h",
"upb/reflection/def_builder_internal.h",
"upb/reflection/def_pool.h",
"upb/reflection/def_type.h",
"upb/reflection/desc_state_internal.h",
"upb/reflection/enum_def.h",
"upb/reflection/enum_value_def.h",
"upb/reflection/extension_range.h",
"upb/reflection/field_def.h",
"upb/reflection/file_def.h",
"upb/reflection/message.h",
"upb/reflection/message_def.h",
"upb/reflection/method_def.h",
"upb/reflection/oneof_def.h",
"upb/reflection/service_def.h",
],
hdrs = [
"upb/reflection/def_pool_internal.h",
"upb/reflection/enum_def_internal.h",
"upb/reflection/enum_value_def_internal.h",
"upb/reflection/extension_range_internal.h",
"upb/reflection/field_def_internal.h",
"upb/reflection/file_def_internal.h",
"upb/reflection/message_def_internal.h",
"upb/reflection/method_def_internal.h",
"upb/reflection/oneof_def_internal.h",
"upb/reflection/service_def_internal.h",
],
copts = UPB_DEFAULT_COPTS,
visibility = ["//visibility:public"],
deps = [
":collections",
":descriptor_upb_proto",
":mini_table",
":mini_table_internal",
":port",
":reflection",
":table_internal",
":upb",
],
)
cc_library(
name = "textformat",
srcs = [
@ -498,15 +555,15 @@ cc_test(
name = "def_builder_test",
srcs = [
"upb/reflection/common.h",
"upb/reflection/def_builder.h",
"upb/reflection/def_builder_internal.h",
"upb/reflection/def_builder_test.cc",
"upb/reflection/def_pool.h",
"upb/reflection/def_type.h",
],
deps = [
":descriptor_upb_proto",
":port",
":reflection",
":reflection_internal",
":table_internal",
":upb",
"@com_google_googletest//:gtest_main",
@ -985,6 +1042,7 @@ upb_amalgamation(
":mini_table",
":port",
":reflection",
":reflection_internal",
":upb",
],
strip_import_prefix = ["src"],
@ -1019,6 +1077,7 @@ upb_amalgamation(
":mini_table",
":port",
":reflection",
":reflection_internal",
":table_internal",
":unicode_internal",
":upb",
@ -1056,6 +1115,7 @@ upb_amalgamation(
":mini_table",
":port",
":reflection",
":reflection_internal",
":table_internal",
":unicode_internal",
":upb",

@ -207,6 +207,7 @@ py_extension(
"//:descriptor_upb_proto_reflection",
"//:port",
"//:reflection",
"//:reflection_internal",
"//:table_internal",
"//:textformat",
"//:upb",

@ -29,6 +29,7 @@
#include "python/message.h"
#include "python/protobuf.h"
#include "upb/reflection/def_pool_internal.h"
// -----------------------------------------------------------------------------
// ExtensionDict

@ -25,10 +25,9 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "upb/reflection/def_builder.h"
#include <string.h>
#include "upb/reflection/def_builder_internal.h"
#include "upb/reflection/def_pool.h"
#include "upb/reflection/def_type.h"
#include "upb/reflection/field_def.h"

@ -25,11 +25,11 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef UPB_REFLECTION_DEF_BUILDER_H_
#define UPB_REFLECTION_DEF_BUILDER_H_
#ifndef UPB_REFLECTION_DEF_BUILDER_INTERNAL_H_
#define UPB_REFLECTION_DEF_BUILDER_INTERNAL_H_
#include "upb/reflection/common.h"
#include "upb/reflection/def_pool.h"
#include "upb/reflection/def_pool_internal.h"
#include "upb/reflection/def_type.h"
// Must be last.
@ -37,7 +37,7 @@
// We want to copy the options verbatim into the destination options proto.
// We use serialize+parse as our deep copy.
#define UBP_DEF_SET_OPTIONS(target, desc_type, options_type, proto) \
#define UPB_DEF_SET_OPTIONS(target, desc_type, options_type, proto) \
if (google_protobuf_##desc_type##_has_options(proto)) { \
size_t size; \
char* pb = google_protobuf_##options_type##_serialize( \
@ -170,4 +170,4 @@ UPB_INLINE void _upb_DefBuilder_CheckIdentFull(upb_DefBuilder* ctx,
#include "upb/port_undef.inc"
#endif /* UPB_REFLECTION_DEF_BUILDER_H_ */
#endif /* UPB_REFLECTION_DEF_BUILDER_INTERNAL_H_ */

@ -25,10 +25,9 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "upb/reflection/def_builder.h"
#include "gtest/gtest.h"
#include "upb/reflection/def.hpp"
#include "upb/reflection/def_builder_internal.h"
// Must be last.
#include "upb/port_def.inc"

@ -25,16 +25,15 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "upb/reflection/def_pool.h"
#include "upb/reflection/def_builder.h"
#include "upb/reflection/def_builder_internal.h"
#include "upb/reflection/def_pool_internal.h"
#include "upb/reflection/def_type.h"
#include "upb/reflection/enum_def.h"
#include "upb/reflection/enum_value_def.h"
#include "upb/reflection/field_def.h"
#include "upb/reflection/file_def.h"
#include "upb/reflection/message_def.h"
#include "upb/reflection/service_def.h"
#include "upb/reflection/enum_def_internal.h"
#include "upb/reflection/enum_value_def_internal.h"
#include "upb/reflection/field_def_internal.h"
#include "upb/reflection/file_def_internal.h"
#include "upb/reflection/message_def_internal.h"
#include "upb/reflection/service_def_internal.h"
// Must be last.
#include "upb/port_def.inc"

@ -94,39 +94,6 @@ const upb_FieldDef** upb_DefPool_GetAllExtensions(const upb_DefPool* s,
const upb_MessageDef* m,
size_t* count);
// EVERYTHING BELOW THIS LINE IS INTERNAL - DO NOT USE /////////////////////////
upb_Arena* _upb_DefPool_Arena(const upb_DefPool* s);
size_t _upb_DefPool_BytesLoaded(const upb_DefPool* s);
upb_ExtensionRegistry* _upb_DefPool_ExtReg(const upb_DefPool* s);
const upb_FieldDef* _upb_DefPool_FindExtensionByMiniTable(
const upb_DefPool* s, const upb_MiniTable_Extension* ext);
bool _upb_DefPool_InsertExt(upb_DefPool* s, const upb_MiniTable_Extension* ext,
upb_FieldDef* f);
bool _upb_DefPool_InsertSym(upb_DefPool* s, upb_StringView sym, upb_value v,
upb_Status* status);
bool _upb_DefPool_LookupSym(const upb_DefPool* s, const char* sym, size_t size,
upb_value* v);
void** _upb_DefPool_ScratchData(const upb_DefPool* s);
size_t* _upb_DefPool_ScratchSize(const upb_DefPool* s);
// For generated code only: loads a generated descriptor.
typedef struct _upb_DefPool_Init {
struct _upb_DefPool_Init** deps; // Dependencies of this file.
const upb_MiniTable_File* layout;
const char* filename;
upb_StringView descriptor; // Serialized descriptor.
} _upb_DefPool_Init;
bool _upb_DefPool_LoadDefInit(upb_DefPool* s, const _upb_DefPool_Init* init);
// Should only be directly called by tests. This variant lets us suppress
// the use of compiled-in tables, forcing a rebuild of the tables at runtime.
bool _upb_DefPool_LoadDefInitEx(upb_DefPool* s, const _upb_DefPool_Init* init,
bool rebuild_minitable);
#ifdef __cplusplus
} /* extern "C" */
#endif

@ -0,0 +1,77 @@
/*
* Copyright (c) 2009-2021, Google LLC
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Google LLC nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef UPB_REFLECTION_DEF_POOL_INTERNAL_H_
#define UPB_REFLECTION_DEF_POOL_INTERNAL_H_
#include "upb/reflection/def_pool.h"
// Must be last.
#include "upb/port_def.inc"
#ifdef __cplusplus
extern "C" {
#endif
upb_Arena* _upb_DefPool_Arena(const upb_DefPool* s);
size_t _upb_DefPool_BytesLoaded(const upb_DefPool* s);
upb_ExtensionRegistry* _upb_DefPool_ExtReg(const upb_DefPool* s);
const upb_FieldDef* _upb_DefPool_FindExtensionByMiniTable(
const upb_DefPool* s, const upb_MiniTable_Extension* ext);
bool _upb_DefPool_InsertExt(upb_DefPool* s, const upb_MiniTable_Extension* ext,
upb_FieldDef* f);
bool _upb_DefPool_InsertSym(upb_DefPool* s, upb_StringView sym, upb_value v,
upb_Status* status);
bool _upb_DefPool_LookupSym(const upb_DefPool* s, const char* sym, size_t size,
upb_value* v);
void** _upb_DefPool_ScratchData(const upb_DefPool* s);
size_t* _upb_DefPool_ScratchSize(const upb_DefPool* s);
// For generated code only: loads a generated descriptor.
typedef struct _upb_DefPool_Init {
struct _upb_DefPool_Init** deps; // Dependencies of this file.
const upb_MiniTable_File* layout;
const char* filename;
upb_StringView descriptor; // Serialized descriptor.
} _upb_DefPool_Init;
bool _upb_DefPool_LoadDefInit(upb_DefPool* s, const _upb_DefPool_Init* init);
// Should only be directly called by tests. This variant lets us suppress
// the use of compiled-in tables, forcing a rebuild of the tables at runtime.
bool _upb_DefPool_LoadDefInitEx(upb_DefPool* s, const _upb_DefPool_Init* init,
bool rebuild_minitable);
#ifdef __cplusplus
} /* extern "C" */
#endif
#include "upb/port_undef.inc"
#endif /* UPB_REFLECTION_DEF_POOL_INTERNAL_H_ */

@ -25,7 +25,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "upb/reflection/desc_state.h"
#include "upb/reflection/desc_state_internal.h"
// Must be last.
#include "upb/port_def.inc"

@ -25,8 +25,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef UPB_REFLECTION_DESC_STATE_H_
#define UPB_REFLECTION_DESC_STATE_H_
#ifndef UPB_REFLECTION_DESC_STATE_INTERNAL_H_
#define UPB_REFLECTION_DESC_STATE_INTERNAL_H_
#include "upb/mini_table.h"
@ -60,4 +60,4 @@ bool _upb_DescState_Grow(upb_DescState* d, upb_Arena* a);
#include "upb/port_undef.inc"
#endif /* UPB_REFLECTION_DESC_STATE_H_ */
#endif /* UPB_REFLECTION_DESC_STATE_INTERNAL_H_ */

@ -25,17 +25,16 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "upb/reflection/enum_def.h"
#include <stdio.h>
#include "upb/mini_table.h"
#include "upb/reflection/def_builder.h"
#include "upb/reflection/def_builder_internal.h"
#include "upb/reflection/def_type.h"
#include "upb/reflection/desc_state.h"
#include "upb/reflection/enum_value_def.h"
#include "upb/reflection/file_def.h"
#include "upb/reflection/message_def.h"
#include "upb/reflection/desc_state_internal.h"
#include "upb/reflection/enum_def_internal.h"
#include "upb/reflection/enum_value_def_internal.h"
#include "upb/reflection/file_def_internal.h"
#include "upb/reflection/message_def_internal.h"
// Must be last.
#include "upb/port_def.inc"
@ -235,7 +234,7 @@ static void create_enumdef(upb_DefBuilder* ctx, const char* prefix,
e->full_name);
}
UBP_DEF_SET_OPTIONS(e->opts, EnumDescriptorProto, EnumOptions, enum_proto);
UPB_DEF_SET_OPTIONS(e->opts, EnumDescriptorProto, EnumOptions, enum_proto);
upb_inttable_compact(&e->iton, ctx->arena);

@ -63,17 +63,6 @@ const google_protobuf_EnumOptions* upb_EnumDef_Options(const upb_EnumDef* e);
const upb_EnumValueDef* upb_EnumDef_Value(const upb_EnumDef* e, int i);
int upb_EnumDef_ValueCount(const upb_EnumDef* e);
// EVERYTHING BELOW THIS LINE IS INTERNAL - DO NOT USE /////////////////////////
upb_EnumDef* _upb_EnumDef_At(const upb_EnumDef* e, int i);
bool _upb_EnumDef_Insert(upb_EnumDef* e, upb_EnumValueDef* v, upb_Arena* a);
const upb_MiniTable_Enum* _upb_EnumDef_MiniTable(const upb_EnumDef* e);
// Allocate and initialize an array of |n| enum defs.
upb_EnumDef* _upb_EnumDefs_New(upb_DefBuilder* ctx, int n,
const google_protobuf_EnumDescriptorProto* const* protos,
const upb_MessageDef* containing_type);
#ifdef __cplusplus
} /* extern "C" */
#endif

@ -0,0 +1,55 @@
/*
* Copyright (c) 2009-2021, Google LLC
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Google LLC nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef UPB_REFLECTION_ENUM_DEF_INTERNAL_H_
#define UPB_REFLECTION_ENUM_DEF_INTERNAL_H_
#include "upb/reflection/enum_def.h"
// Must be last.
#include "upb/port_def.inc"
#ifdef __cplusplus
extern "C" {
#endif
upb_EnumDef* _upb_EnumDef_At(const upb_EnumDef* e, int i);
bool _upb_EnumDef_Insert(upb_EnumDef* e, upb_EnumValueDef* v, upb_Arena* a);
const upb_MiniTable_Enum* _upb_EnumDef_MiniTable(const upb_EnumDef* e);
// Allocate and initialize an array of |n| enum defs.
upb_EnumDef* _upb_EnumDefs_New(upb_DefBuilder* ctx, int n,
const google_protobuf_EnumDescriptorProto* const* protos,
const upb_MessageDef* containing_type);
#ifdef __cplusplus
} /* extern "C" */
#endif
#include "upb/port_undef.inc"
#endif /* UPB_REFLECTION_ENUM_DEF_INTERNAL_H_ */

@ -25,12 +25,11 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "upb/reflection/enum_value_def.h"
#include "upb/reflection/def_builder.h"
#include "upb/reflection/def_builder_internal.h"
#include "upb/reflection/def_type.h"
#include "upb/reflection/enum_def.h"
#include "upb/reflection/file_def.h"
#include "upb/reflection/enum_def_internal.h"
#include "upb/reflection/enum_value_def_internal.h"
#include "upb/reflection/file_def_internal.h"
// Must be last.
#include "upb/port_def.inc"
@ -106,7 +105,7 @@ static void create_enumvaldef(upb_DefBuilder* ctx, const char* prefix,
_upb_DefBuilder_Add(ctx, v->full_name,
_upb_DefType_Pack(v, UPB_DEFTYPE_ENUMVAL));
UBP_DEF_SET_OPTIONS(v->opts, EnumValueDescriptorProto, EnumValueOptions,
UPB_DEF_SET_OPTIONS(v->opts, EnumValueDescriptorProto, EnumValueOptions,
val_proto);
bool ok = _upb_EnumDef_Insert(e, v, ctx->arena);

@ -48,19 +48,6 @@ int32_t upb_EnumValueDef_Number(const upb_EnumValueDef* v);
const google_protobuf_EnumValueOptions* upb_EnumValueDef_Options(
const upb_EnumValueDef* v);
// EVERYTHING BELOW THIS LINE IS INTERNAL - DO NOT USE /////////////////////////
upb_EnumValueDef* _upb_EnumValueDef_At(const upb_EnumValueDef* v, int i);
// Allocate and initialize an array of |n| enum value defs owned by |e|.
upb_EnumValueDef* _upb_EnumValueDefs_New(
upb_DefBuilder* ctx, const char* prefix, int n,
const google_protobuf_EnumValueDescriptorProto* const* protos, upb_EnumDef* e,
bool* is_sorted);
const upb_EnumValueDef** _upb_EnumValueDefs_Sorted(const upb_EnumValueDef* v,
int n, upb_Arena* a);
#ifdef __cplusplus
} /* extern "C" */
#endif

@ -0,0 +1,57 @@
/*
* Copyright (c) 2009-2021, Google LLC
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Google LLC nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef UPB_REFLECTION_ENUM_VALUE_DEF_INTERNAL_H_
#define UPB_REFLECTION_ENUM_VALUE_DEF_INTERNAL_H_
#include "upb/reflection/enum_value_def.h"
// Must be last.
#include "upb/port_def.inc"
#ifdef __cplusplus
extern "C" {
#endif
upb_EnumValueDef* _upb_EnumValueDef_At(const upb_EnumValueDef* v, int i);
// Allocate and initialize an array of |n| enum value defs owned by |e|.
upb_EnumValueDef* _upb_EnumValueDefs_New(
upb_DefBuilder* ctx, const char* prefix, int n,
const google_protobuf_EnumValueDescriptorProto* const* protos, upb_EnumDef* e,
bool* is_sorted);
const upb_EnumValueDef** _upb_EnumValueDefs_Sorted(const upb_EnumValueDef* v,
int n, upb_Arena* a);
#ifdef __cplusplus
} /* extern "C" */
#endif
#include "upb/port_undef.inc"
#endif /* UPB_REFLECTION_ENUM_VALUE_DEF_INTERNAL_H_ */

@ -25,11 +25,10 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "upb/reflection/extension_range.h"
#include "upb/reflection/def_builder.h"
#include "upb/reflection/field_def.h"
#include "upb/reflection/message_def.h"
#include "upb/reflection/def_builder_internal.h"
#include "upb/reflection/extension_range_internal.h"
#include "upb/reflection/field_def_internal.h"
#include "upb/reflection/message_def_internal.h"
// Must be last.
#include "upb/port_def.inc"
@ -86,7 +85,7 @@ upb_ExtensionRange* _upb_ExtensionRanges_New(
r[i].start = start;
r[i].end = end;
UBP_DEF_SET_OPTIONS(r[i].opts, DescriptorProto_ExtensionRange,
UPB_DEF_SET_OPTIONS(r[i].opts, DescriptorProto_ExtensionRange,
ExtensionRangeOptions, protos[i]);
}

@ -46,16 +46,6 @@ bool upb_ExtensionRange_HasOptions(const upb_ExtensionRange* r);
const google_protobuf_ExtensionRangeOptions* upb_ExtensionRange_Options(
const upb_ExtensionRange* r);
// EVERYTHING BELOW THIS LINE IS INTERNAL - DO NOT USE /////////////////////////
upb_ExtensionRange* _upb_ExtensionRange_At(const upb_ExtensionRange* r, int i);
// Allocate and initialize an array of |n| extension ranges owned by |m|.
upb_ExtensionRange* _upb_ExtensionRanges_New(
upb_DefBuilder* ctx, int n,
const google_protobuf_DescriptorProto_ExtensionRange* const* protos,
const upb_MessageDef* m);
#ifdef __cplusplus
} /* extern "C" */
#endif

@ -0,0 +1,54 @@
/*
* Copyright (c) 2009-2021, Google LLC
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Google LLC nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef UPB_REFLECTION_EXTENSION_RANGE_INTERNAL_H_
#define UPB_REFLECTION_EXTENSION_RANGE_INTERNAL_H_
#include "upb/reflection/extension_range.h"
// Must be last.
#include "upb/port_def.inc"
#ifdef __cplusplus
extern "C" {
#endif
upb_ExtensionRange* _upb_ExtensionRange_At(const upb_ExtensionRange* r, int i);
// Allocate and initialize an array of |n| extension ranges owned by |m|.
upb_ExtensionRange* _upb_ExtensionRanges_New(
upb_DefBuilder* ctx, int n,
const google_protobuf_DescriptorProto_ExtensionRange* const* protos,
const upb_MessageDef* m);
#ifdef __cplusplus
} /* extern "C" */
#endif
#include "upb/port_undef.inc"
#endif /* UPB_REFLECTION_EXTENSION_RANGE_INTERNAL_H_ */

@ -25,22 +25,21 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "upb/reflection/field_def.h"
#include <ctype.h>
#include <errno.h>
#include "upb/mini_table.h"
#include "upb/reflection/def_builder.h"
#include "upb/reflection/def_builder_internal.h"
#include "upb/reflection/def_pool.h"
#include "upb/reflection/def_type.h"
#include "upb/reflection/desc_state.h"
#include "upb/reflection/enum_def.h"
#include "upb/reflection/enum_value_def.h"
#include "upb/reflection/extension_range.h"
#include "upb/reflection/file_def.h"
#include "upb/reflection/message_def.h"
#include "upb/reflection/oneof_def.h"
#include "upb/reflection/desc_state_internal.h"
#include "upb/reflection/enum_def_internal.h"
#include "upb/reflection/enum_value_def_internal.h"
#include "upb/reflection/extension_range_internal.h"
#include "upb/reflection/field_def_internal.h"
#include "upb/reflection/file_def_internal.h"
#include "upb/reflection/message_def_internal.h"
#include "upb/reflection/oneof_def_internal.h"
// Must be last.
#include "upb/port_def.inc"
@ -643,7 +642,7 @@ static void _upb_FieldDef_Create(upb_DefBuilder* ctx, const char* prefix,
if (!ok) _upb_DefBuilder_OomErr(ctx);
}
UBP_DEF_SET_OPTIONS(f->opts, FieldDescriptorProto, FieldOptions, field_proto);
UPB_DEF_SET_OPTIONS(f->opts, FieldDescriptorProto, FieldOptions, field_proto);
if (google_protobuf_FieldOptions_has_packed(f->opts)) {
f->is_packed_ = google_protobuf_FieldOptions_packed(f->opts);

@ -81,30 +81,6 @@ const google_protobuf_FieldOptions* upb_FieldDef_Options(const upb_FieldDef* f);
const upb_OneofDef* upb_FieldDef_RealContainingOneof(const upb_FieldDef* f);
upb_FieldType upb_FieldDef_Type(const upb_FieldDef* f);
// EVERYTHING BELOW THIS LINE IS INTERNAL - DO NOT USE /////////////////////////
upb_FieldDef* _upb_FieldDef_At(const upb_FieldDef* f, int i);
const upb_MiniTable_Extension* _upb_FieldDef_ExtensionMiniTable(
const upb_FieldDef* f);
bool _upb_FieldDef_IsClosedEnum(const upb_FieldDef* f);
bool _upb_FieldDef_IsProto3Optional(const upb_FieldDef* f);
int _upb_FieldDef_LayoutIndex(const upb_FieldDef* f);
uint64_t _upb_FieldDef_Modifiers(const upb_FieldDef* f);
void _upb_FieldDef_Resolve(upb_DefBuilder* ctx, const char* prefix,
upb_FieldDef* f);
// Allocate and initialize an array of |n| field defs.
upb_FieldDef* _upb_FieldDefs_New(
upb_DefBuilder* ctx, int n,
const google_protobuf_FieldDescriptorProto* const* protos, const char* prefix,
upb_MessageDef* m, bool* is_sorted);
// Allocate and return a list of pointers to the |n| field defs in |ff|,
// sorted by field number.
const upb_FieldDef** _upb_FieldDefs_Sorted(const upb_FieldDef* f, int n,
upb_Arena* a);
#ifdef __cplusplus
} /* extern "C" */
#endif

@ -0,0 +1,68 @@
/*
* Copyright (c) 2009-2021, Google LLC
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Google LLC nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef UPB_REFLECTION_FIELD_DEF_INTERNAL_H_
#define UPB_REFLECTION_FIELD_DEF_INTERNAL_H_
#include "upb/reflection/field_def.h"
// Must be last.
#include "upb/port_def.inc"
#ifdef __cplusplus
extern "C" {
#endif
upb_FieldDef* _upb_FieldDef_At(const upb_FieldDef* f, int i);
const upb_MiniTable_Extension* _upb_FieldDef_ExtensionMiniTable(
const upb_FieldDef* f);
bool _upb_FieldDef_IsClosedEnum(const upb_FieldDef* f);
bool _upb_FieldDef_IsProto3Optional(const upb_FieldDef* f);
int _upb_FieldDef_LayoutIndex(const upb_FieldDef* f);
uint64_t _upb_FieldDef_Modifiers(const upb_FieldDef* f);
void _upb_FieldDef_Resolve(upb_DefBuilder* ctx, const char* prefix,
upb_FieldDef* f);
// Allocate and initialize an array of |n| field defs.
upb_FieldDef* _upb_FieldDefs_New(
upb_DefBuilder* ctx, int n,
const google_protobuf_FieldDescriptorProto* const* protos, const char* prefix,
upb_MessageDef* m, bool* is_sorted);
// Allocate and return a list of pointers to the |n| field defs in |ff|,
// sorted by field number.
const upb_FieldDef** _upb_FieldDefs_Sorted(const upb_FieldDef* f, int n,
upb_Arena* a);
#ifdef __cplusplus
} /* extern "C" */
#endif
#include "upb/port_undef.inc"
#endif /* UPB_REFLECTION_FIELD_DEF_INTERNAL_H_ */

@ -25,14 +25,13 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "upb/reflection/file_def.h"
#include "upb/reflection/def_builder.h"
#include "upb/reflection/def_builder_internal.h"
#include "upb/reflection/def_pool.h"
#include "upb/reflection/enum_def.h"
#include "upb/reflection/field_def.h"
#include "upb/reflection/message_def.h"
#include "upb/reflection/service_def.h"
#include "upb/reflection/enum_def_internal.h"
#include "upb/reflection/field_def_internal.h"
#include "upb/reflection/file_def_internal.h"
#include "upb/reflection/message_def_internal.h"
#include "upb/reflection/service_def_internal.h"
// Must be last.
#include "upb/port_def.inc"
@ -254,7 +253,7 @@ void _upb_FileDef_Create(upb_DefBuilder* ctx,
}
// Read options.
UBP_DEF_SET_OPTIONS(file->opts, FileDescriptorProto, FileOptions, file_proto);
UPB_DEF_SET_OPTIONS(file->opts, FileDescriptorProto, FileOptions, file_proto);
// Verify dependencies.
strs = google_protobuf_FileDescriptorProto_dependency(file_proto, &n);

@ -67,19 +67,6 @@ int upb_FileDef_TopLevelMessageCount(const upb_FileDef* f);
const upb_FileDef* upb_FileDef_WeakDependency(const upb_FileDef* f, int i);
int upb_FileDef_WeakDependencyCount(const upb_FileDef* f);
// EVERYTHING BELOW THIS LINE IS INTERNAL - DO NOT USE /////////////////////////
const upb_MiniTable_Extension* _upb_FileDef_ExtensionMiniTable(
const upb_FileDef* f, int i);
const int32_t* _upb_FileDef_PublicDependencyIndexes(const upb_FileDef* f);
const int32_t* _upb_FileDef_WeakDependencyIndexes(const upb_FileDef* f);
// upb_FileDef_Package() returns "" if f->package is NULL, this does not.
const char* _upb_FileDef_RawPackage(const upb_FileDef* f);
void _upb_FileDef_Create(upb_DefBuilder* ctx,
const google_protobuf_FileDescriptorProto* file_proto);
#ifdef __cplusplus
} /* extern "C" */
#endif

@ -0,0 +1,57 @@
/*
* Copyright (c) 2009-2021, Google LLC
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Google LLC nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef UPB_REFLECTION_FILE_DEF_INTERNAL_H_
#define UPB_REFLECTION_FILE_DEF_INTERNAL_H_
#include "upb/reflection/file_def.h"
// Must be last.
#include "upb/port_def.inc"
#ifdef __cplusplus
extern "C" {
#endif
const upb_MiniTable_Extension* _upb_FileDef_ExtensionMiniTable(
const upb_FileDef* f, int i);
const int32_t* _upb_FileDef_PublicDependencyIndexes(const upb_FileDef* f);
const int32_t* _upb_FileDef_WeakDependencyIndexes(const upb_FileDef* f);
// upb_FileDef_Package() returns "" if f->package is NULL, this does not.
const char* _upb_FileDef_RawPackage(const upb_FileDef* f);
void _upb_FileDef_Create(upb_DefBuilder* ctx,
const google_protobuf_FileDescriptorProto* file_proto);
#ifdef __cplusplus
} /* extern "C" */
#endif
#include "upb/port_undef.inc"
#endif /* UPB_REFLECTION_FILE_DEF_INTERNAL_H_ */

@ -32,10 +32,9 @@
#include "upb/internal/table.h"
#include "upb/map.h"
#include "upb/msg.h"
#include "upb/reflection/def_builder.h"
#include "upb/reflection/def_pool.h"
#include "upb/reflection/def_pool_internal.h"
#include "upb/reflection/def_type.h"
#include "upb/reflection/field_def.h"
#include "upb/reflection/field_def_internal.h"
#include "upb/reflection/message_def.h"
#include "upb/reflection/oneof_def.h"

@ -25,17 +25,16 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "upb/reflection/message_def.h"
#include "upb/mini_table.h"
#include "upb/reflection/def_builder.h"
#include "upb/reflection/def_builder_internal.h"
#include "upb/reflection/def_type.h"
#include "upb/reflection/desc_state.h"
#include "upb/reflection/enum_def.h"
#include "upb/reflection/extension_range.h"
#include "upb/reflection/field_def.h"
#include "upb/reflection/file_def.h"
#include "upb/reflection/oneof_def.h"
#include "upb/reflection/desc_state_internal.h"
#include "upb/reflection/enum_def_internal.h"
#include "upb/reflection/extension_range_internal.h"
#include "upb/reflection/field_def_internal.h"
#include "upb/reflection/file_def_internal.h"
#include "upb/reflection/message_def_internal.h"
#include "upb/reflection/oneof_def_internal.h"
// Must be last.
#include "upb/port_def.inc"
@ -558,7 +557,7 @@ static void create_msgdef(upb_DefBuilder* ctx, const char* prefix,
ctx, sizeof(*m->layout) + sizeof(_upb_FastTable_Entry));
}
UBP_DEF_SET_OPTIONS(m->opts, DescriptorProto, MessageOptions, msg_proto);
UPB_DEF_SET_OPTIONS(m->opts, DescriptorProto, MessageOptions, msg_proto);
m->oneof_count = n_oneof;
m->oneofs = _upb_OneofDefs_New(ctx, n_oneof, oneofs, m);

@ -155,24 +155,6 @@ const google_protobuf_MessageOptions* upb_MessageDef_Options(const upb_MessageDe
upb_Syntax upb_MessageDef_Syntax(const upb_MessageDef* m);
upb_WellKnown upb_MessageDef_WellKnownType(const upb_MessageDef* m);
// EVERYTHING BELOW THIS LINE IS INTERNAL - DO NOT USE /////////////////////////
upb_MessageDef* _upb_MessageDef_At(const upb_MessageDef* m, int i);
bool _upb_MessageDef_InMessageSet(const upb_MessageDef* m);
bool _upb_MessageDef_Insert(upb_MessageDef* m, const char* name, size_t size,
upb_value v, upb_Arena* a);
void _upb_MessageDef_InsertField(upb_DefBuilder* ctx, upb_MessageDef* m,
const upb_FieldDef* f);
bool _upb_MessageDef_IsValidExtensionNumber(const upb_MessageDef* m, int n);
void _upb_MessageDef_LinkMiniTable(upb_DefBuilder* ctx,
const upb_MessageDef* m);
void _upb_MessageDef_Resolve(upb_DefBuilder* ctx, upb_MessageDef* m);
// Allocate and initialize an array of |n| message defs.
upb_MessageDef* _upb_MessageDefs_New(
upb_DefBuilder* ctx, int n, const google_protobuf_DescriptorProto* const* protos,
const upb_MessageDef* containing_type);
#ifdef __cplusplus
} /* extern "C" */
#endif

@ -0,0 +1,62 @@
/*
* Copyright (c) 2009-2021, Google LLC
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Google LLC nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef UPB_REFLECTION_MESSAGE_DEF_INTERNAL_H_
#define UPB_REFLECTION_MESSAGE_DEF_INTERNAL_H_
#include "upb/reflection/message_def.h"
// Must be last.
#include "upb/port_def.inc"
#ifdef __cplusplus
extern "C" {
#endif
upb_MessageDef* _upb_MessageDef_At(const upb_MessageDef* m, int i);
bool _upb_MessageDef_InMessageSet(const upb_MessageDef* m);
bool _upb_MessageDef_Insert(upb_MessageDef* m, const char* name, size_t size,
upb_value v, upb_Arena* a);
void _upb_MessageDef_InsertField(upb_DefBuilder* ctx, upb_MessageDef* m,
const upb_FieldDef* f);
bool _upb_MessageDef_IsValidExtensionNumber(const upb_MessageDef* m, int n);
void _upb_MessageDef_LinkMiniTable(upb_DefBuilder* ctx,
const upb_MessageDef* m);
void _upb_MessageDef_Resolve(upb_DefBuilder* ctx, upb_MessageDef* m);
// Allocate and initialize an array of |n| message defs.
upb_MessageDef* _upb_MessageDefs_New(
upb_DefBuilder* ctx, int n, const google_protobuf_DescriptorProto* const* protos,
const upb_MessageDef* containing_type);
#ifdef __cplusplus
} /* extern "C" */
#endif
#include "upb/port_undef.inc"
#endif /* UPB_REFLECTION_MESSAGE_DEF_INTERNAL_H_ */

@ -25,10 +25,9 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "upb/reflection/method_def.h"
#include "upb/reflection/def_builder.h"
#include "upb/reflection/def_builder_internal.h"
#include "upb/reflection/def_type.h"
#include "upb/reflection/method_def_internal.h"
#include "upb/reflection/service_def.h"
// Must be last.
@ -106,7 +105,7 @@ static void create_method(upb_DefBuilder* ctx,
ctx, m->full_name, m->full_name,
google_protobuf_MethodDescriptorProto_output_type(method_proto), UPB_DEFTYPE_MSG);
UBP_DEF_SET_OPTIONS(m->opts, MethodDescriptorProto, MethodOptions,
UPB_DEF_SET_OPTIONS(m->opts, MethodDescriptorProto, MethodOptions,
method_proto);
}

@ -50,15 +50,6 @@ const upb_MessageDef* upb_MethodDef_OutputType(const upb_MethodDef* m);
bool upb_MethodDef_ServerStreaming(const upb_MethodDef* m);
const upb_ServiceDef* upb_MethodDef_Service(const upb_MethodDef* m);
// EVERYTHING BELOW THIS LINE IS INTERNAL - DO NOT USE /////////////////////////
upb_MethodDef* _upb_MethodDef_At(const upb_MethodDef* m, int i);
// Allocate and initialize an array of |n| method defs owned by |s|.
upb_MethodDef* _upb_MethodDefs_New(
upb_DefBuilder* ctx, int n,
const google_protobuf_MethodDescriptorProto* const* protos, upb_ServiceDef* s);
#ifdef __cplusplus
} /* extern "C" */
#endif

@ -0,0 +1,53 @@
/*
* Copyright (c) 2009-2021, Google LLC
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Google LLC nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef UPB_REFLECTION_METHOD_DEF_INTERNAL_H_
#define UPB_REFLECTION_METHOD_DEF_INTERNAL_H_
#include "upb/reflection/method_def.h"
// Must be last.
#include "upb/port_def.inc"
#ifdef __cplusplus
extern "C" {
#endif
upb_MethodDef* _upb_MethodDef_At(const upb_MethodDef* m, int i);
// Allocate and initialize an array of |n| method defs owned by |s|.
upb_MethodDef* _upb_MethodDefs_New(
upb_DefBuilder* ctx, int n,
const google_protobuf_MethodDescriptorProto* const* protos, upb_ServiceDef* s);
#ifdef __cplusplus
} /* extern "C" */
#endif
#include "upb/port_undef.inc"
#endif /* UPB_REFLECTION_METHOD_DEF_INTERNAL_H_ */

@ -25,17 +25,16 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "upb/reflection/oneof_def.h"
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include "upb/mini_table.h"
#include "upb/reflection/def_builder.h"
#include "upb/reflection/def_builder_internal.h"
#include "upb/reflection/def_type.h"
#include "upb/reflection/field_def.h"
#include "upb/reflection/message_def.h"
#include "upb/reflection/field_def_internal.h"
#include "upb/reflection/message_def_internal.h"
#include "upb/reflection/oneof_def_internal.h"
// Must be last.
#include "upb/port_def.inc"
@ -175,7 +174,7 @@ static void create_oneofdef(upb_DefBuilder* ctx, upb_MessageDef* m,
o->field_count = 0;
o->synthetic = false;
UBP_DEF_SET_OPTIONS(o->opts, OneofDescriptorProto, OneofOptions, oneof_proto);
UPB_DEF_SET_OPTIONS(o->opts, OneofDescriptorProto, OneofOptions, oneof_proto);
if (upb_MessageDef_FindByNameWithSize(m, name.data, name.size, NULL, NULL)) {
_upb_DefBuilder_Errf(ctx, "duplicate oneof name (%s)", o->full_name);

@ -57,19 +57,6 @@ const char* upb_OneofDef_Name(const upb_OneofDef* o);
int upb_OneofDef_numfields(const upb_OneofDef* o);
const google_protobuf_OneofOptions* upb_OneofDef_Options(const upb_OneofDef* o);
// EVERYTHING BELOW THIS LINE IS INTERNAL - DO NOT USE /////////////////////////
upb_OneofDef* _upb_OneofDef_At(const upb_OneofDef* o, int i);
bool _upb_OneofDef_Insert(upb_OneofDef* o, const upb_FieldDef* f,
const char* name, size_t size, upb_Arena* a);
// Allocate and initialize an array of |n| oneof defs owned by |m|.
upb_OneofDef* _upb_OneofDefs_New(
upb_DefBuilder* ctx, int n,
const google_protobuf_OneofDescriptorProto* const* protos, upb_MessageDef* m);
size_t _upb_OneofDefs_Finalize(upb_DefBuilder* ctx, upb_MessageDef* m);
#ifdef __cplusplus
} /* extern "C" */
#endif

@ -0,0 +1,57 @@
/*
* Copyright (c) 2009-2021, Google LLC
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Google LLC nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef UPB_REFLECTION_ONEOF_DEF_INTERNAL_H_
#define UPB_REFLECTION_ONEOF_DEF_INTERNAL_H_
#include "upb/reflection/oneof_def.h"
// Must be last.
#include "upb/port_def.inc"
#ifdef __cplusplus
extern "C" {
#endif
upb_OneofDef* _upb_OneofDef_At(const upb_OneofDef* o, int i);
bool _upb_OneofDef_Insert(upb_OneofDef* o, const upb_FieldDef* f,
const char* name, size_t size, upb_Arena* a);
// Allocate and initialize an array of |n| oneof defs owned by |m|.
upb_OneofDef* _upb_OneofDefs_New(
upb_DefBuilder* ctx, int n,
const google_protobuf_OneofDescriptorProto* const* protos, upb_MessageDef* m);
size_t _upb_OneofDefs_Finalize(upb_DefBuilder* ctx, upb_MessageDef* m);
#ifdef __cplusplus
} /* extern "C" */
#endif
#include "upb/port_undef.inc"
#endif /* UPB_REFLECTION_ONEOF_DEF_INTERNAL_H_ */

@ -25,12 +25,11 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "upb/reflection/service_def.h"
#include "upb/reflection/def_builder.h"
#include "upb/reflection/def_builder_internal.h"
#include "upb/reflection/def_type.h"
#include "upb/reflection/file_def.h"
#include "upb/reflection/method_def.h"
#include "upb/reflection/file_def_internal.h"
#include "upb/reflection/method_def_internal.h"
#include "upb/reflection/service_def_internal.h"
// Must be last.
#include "upb/port_def.inc"
@ -111,7 +110,7 @@ static void create_service(upb_DefBuilder* ctx,
s->method_count = n;
s->methods = _upb_MethodDefs_New(ctx, n, methods, s);
UBP_DEF_SET_OPTIONS(s->opts, ServiceDescriptorProto, ServiceOptions,
UPB_DEF_SET_OPTIONS(s->opts, ServiceDescriptorProto, ServiceOptions,
svc_proto);
}

@ -50,15 +50,6 @@ int upb_ServiceDef_MethodCount(const upb_ServiceDef* s);
const char* upb_ServiceDef_Name(const upb_ServiceDef* s);
const google_protobuf_ServiceOptions* upb_ServiceDef_Options(const upb_ServiceDef* s);
// EVERYTHING BELOW THIS LINE IS INTERNAL - DO NOT USE /////////////////////////
upb_ServiceDef* _upb_ServiceDef_At(const upb_ServiceDef* s, int i);
// Allocate and initialize an array of |n| service defs.
upb_ServiceDef* _upb_ServiceDefs_New(
upb_DefBuilder* ctx, int n,
const google_protobuf_ServiceDescriptorProto* const* protos);
#ifdef __cplusplus
} /* extern "C" */
#endif

@ -0,0 +1,53 @@
/*
* Copyright (c) 2009-2021, Google LLC
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Google LLC nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef UPB_REFLECTION_SERVICE_DEF_INTERNAL_H_
#define UPB_REFLECTION_SERVICE_DEF_INTERNAL_H_
#include "upb/reflection/service_def.h"
// Must be last.
#include "upb/port_def.inc"
#ifdef __cplusplus
extern "C" {
#endif
upb_ServiceDef* _upb_ServiceDef_At(const upb_ServiceDef* s, int i);
// Allocate and initialize an array of |n| service defs.
upb_ServiceDef* _upb_ServiceDefs_New(
upb_DefBuilder* ctx, int n,
const google_protobuf_ServiceDescriptorProto* const* protos);
#ifdef __cplusplus
} /* extern "C" */
#endif
#include "upb/port_undef.inc"
#endif /* UPB_REFLECTION_SERVICE_DEF_INTERNAL_H_ */

@ -16,6 +16,7 @@ cc_library(
deps = [
"//:port",
"//:reflection",
"//:reflection_internal",
],
)

@ -33,6 +33,8 @@
#include <stdio.h>
#include "upb/internal/vsnprintf_compat.h"
#include "upb/reflection/field_def_internal.h"
#include "upb/reflection/file_def_internal.h"
#include "upb/reflection/message.h"
/* Must be last. */

@ -70,6 +70,7 @@ void WriteDefHeader(const protobuf::FileDescriptor* file, Output& output) {
"#ifndef $0_UPBDEFS_H_\n"
"#define $0_UPBDEFS_H_\n\n"
"#include \"upb/reflection/def.h\"\n"
"#include \"upb/reflection/def_pool_internal.h\"\n"
"#include \"upb/port_def.inc\"\n"
"#ifdef __cplusplus\n"
"extern \"C\" {\n"

Loading…
Cancel
Save