diff --git a/BUILD b/BUILD index cd515ba430..43de536048 100644 --- a/BUILD +++ b/BUILD @@ -326,15 +326,31 @@ cc_library( cc_library( name = "generated_reflection_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me", + srcs = [ + "upb/reflection/common.h", + "upb/reflection/def_pool.h", + "upb/reflection/def_type.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_def.h", + "upb/reflection/method_def.h", + "upb/reflection/oneof_def.h", + "upb/reflection/service_def.h", + ], hdrs = [ - "upb/def.h", "upb/port_def.inc", "upb/port_undef.inc", + "upb/reflection/def.h", ], copts = UPB_DEFAULT_COPTS, visibility = ["//visibility:public"], deps = [ + ":descriptor_upb_proto", ":reflection", + ":table_internal", ], ) diff --git a/benchmarks/benchmark.cc b/benchmarks/benchmark.cc index e752d3e7eb..e4c3a0cba1 100644 --- a/benchmarks/benchmark.cc +++ b/benchmarks/benchmark.cc @@ -35,7 +35,7 @@ #include "benchmarks/descriptor.upb.h" #include "benchmarks/descriptor.upbdefs.h" #include "benchmarks/descriptor_sv.pb.h" -#include "upb/def.hpp" +#include "upb/reflection/def.hpp" upb_StringView descriptor = benchmarks_descriptor_proto_upbdefinit.descriptor; namespace protobuf = ::google::protobuf; diff --git a/python/convert.c b/python/convert.c index b9df5019a1..b079bdcbf7 100644 --- a/python/convert.c +++ b/python/convert.c @@ -30,7 +30,7 @@ #include "python/message.h" #include "python/protobuf.h" #include "upb/map.h" -#include "upb/reflection.h" +#include "upb/reflection/message.h" #include "upb/util/compare.h" // Must be last. diff --git a/python/convert.h b/python/convert.h index d26aeb72a5..c02c1976a3 100644 --- a/python/convert.h +++ b/python/convert.h @@ -29,8 +29,8 @@ #define PYUPB_CONVERT_H__ #include "protobuf.h" -#include "upb/def.h" -#include "upb/reflection.h" +#include "upb/reflection/def.h" +#include "upb/reflection/message.h" // Converts `val` to a Python object according to the type information in `f`. // Any newly-created Python objects that reference non-primitive data from `val` diff --git a/python/descriptor.c b/python/descriptor.c index 4d238bc4b8..5e3a5fdfd6 100644 --- a/python/descriptor.c +++ b/python/descriptor.c @@ -32,7 +32,7 @@ #include "python/descriptor_pool.h" #include "python/message.h" #include "python/protobuf.h" -#include "upb/def.h" +#include "upb/reflection/def.h" #include "upb/util/def_to_proto.h" // ----------------------------------------------------------------------------- diff --git a/python/descriptor.h b/python/descriptor.h index b4229ef616..9bf6b4258d 100644 --- a/python/descriptor.h +++ b/python/descriptor.h @@ -31,7 +31,7 @@ #include #include "python/python_api.h" -#include "upb/def.h" +#include "upb/reflection/def.h" typedef enum { kPyUpb_Descriptor = 0, diff --git a/python/descriptor_containers.c b/python/descriptor_containers.c index 0f2d4ff023..c750a4a04f 100644 --- a/python/descriptor_containers.c +++ b/python/descriptor_containers.c @@ -29,7 +29,7 @@ #include "python/descriptor.h" #include "python/protobuf.h" -#include "upb/def.h" +#include "upb/reflection/def.h" // Implements __repr__ as str(dict(self)). static PyObject* PyUpb_DescriptorMap_Repr(PyObject* _self) { diff --git a/python/descriptor_containers.h b/python/descriptor_containers.h index 8c6b0d9b43..276aea558a 100644 --- a/python/descriptor_containers.h +++ b/python/descriptor_containers.h @@ -43,7 +43,7 @@ #include #include "protobuf.h" -#include "upb/def.h" +#include "upb/reflection/def.h" // ----------------------------------------------------------------------------- // PyUpb_GenericSequence diff --git a/python/descriptor_pool.c b/python/descriptor_pool.c index ea0e8132a6..4e9faaad2f 100644 --- a/python/descriptor_pool.c +++ b/python/descriptor_pool.c @@ -32,7 +32,7 @@ #include "python/descriptor.h" #include "python/message.h" #include "python/protobuf.h" -#include "upb/def.h" +#include "upb/reflection/def.h" #include "upb/util/def_to_proto.h" // ----------------------------------------------------------------------------- diff --git a/python/map.c b/python/map.c index c5c6e68309..dfadf41d82 100644 --- a/python/map.c +++ b/python/map.c @@ -30,8 +30,8 @@ #include "python/convert.h" #include "python/message.h" #include "python/protobuf.h" -#include "upb/def.h" #include "upb/map.h" +#include "upb/reflection/def.h" // ----------------------------------------------------------------------------- // MapContainer diff --git a/python/map.h b/python/map.h index aaa4e20385..e69ff9fe28 100644 --- a/python/map.h +++ b/python/map.h @@ -31,7 +31,7 @@ #include #include "python/python_api.h" -#include "upb/def.h" +#include "upb/reflection/def.h" // Creates a new repeated field stub for field `f` of message object `parent`. // Precondition: `parent` must be a stub. diff --git a/python/message.c b/python/message.c index e67bf2306b..175292280e 100644 --- a/python/message.c +++ b/python/message.c @@ -32,8 +32,8 @@ #include "python/extension_dict.h" #include "python/map.h" #include "python/repeated.h" -#include "upb/def.h" -#include "upb/reflection.h" +#include "upb/reflection/def.h" +#include "upb/reflection/message.h" #include "upb/text_encode.h" #include "upb/util/required_fields.h" diff --git a/python/message.h b/python/message.h index f296d5ce93..f10f15f02a 100644 --- a/python/message.h +++ b/python/message.h @@ -31,7 +31,7 @@ #include #include "python/protobuf.h" -#include "upb/reflection.h" +#include "upb/reflection/message.h" // Removes the wrapper object for this field from the unset subobject cache. void PyUpb_Message_CacheDelete(PyObject* _self, const upb_FieldDef* f); diff --git a/python/repeated.h b/python/repeated.h index 5d74bd2edb..8cd38721a5 100644 --- a/python/repeated.h +++ b/python/repeated.h @@ -31,7 +31,7 @@ #include #include "python/python_api.h" -#include "upb/def.h" +#include "upb/reflection/def.h" // Creates a new repeated field stub for field `f` of message object `parent`. // Precondition: `parent` must be a stub. diff --git a/upb/bindings/lua/def.c b/upb/bindings/lua/def.c index 602dbaf9a4..b28ed42cb2 100644 --- a/upb/bindings/lua/def.c +++ b/upb/bindings/lua/def.c @@ -25,7 +25,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "upb/def.h" +#include "upb/reflection/def.h" #include #include diff --git a/upb/bindings/lua/msg.c b/upb/bindings/lua/msg.c index 9c66c74b04..4e37e0cecc 100644 --- a/upb/bindings/lua/msg.c +++ b/upb/bindings/lua/msg.c @@ -43,7 +43,7 @@ #include "upb/json_encode.h" #include "upb/map.h" #include "upb/port_def.inc" -#include "upb/reflection.h" +#include "upb/reflection/message.h" #include "upb/text_encode.h" /* diff --git a/upb/bindings/lua/upb.h b/upb/bindings/lua/upb.h index e0dc79eb04..a06d964d55 100644 --- a/upb/bindings/lua/upb.h +++ b/upb/bindings/lua/upb.h @@ -33,9 +33,9 @@ #define UPB_LUA_UPB_H_ #include "lauxlib.h" -#include "upb/def.h" #include "upb/msg.h" -#include "upb/reflection.h" +#include "upb/reflection/def.h" +#include "upb/reflection/message.h" /* Lua changes its API in incompatible ways in every minor release. * This is some shim code to paper over the differences. */ diff --git a/upb/conformance_upb.c b/upb/conformance_upb.c index be5ce9c7dc..b08239b6ff 100644 --- a/upb/conformance_upb.c +++ b/upb/conformance_upb.c @@ -43,7 +43,7 @@ #include "upb/encode.h" #include "upb/json_decode.h" #include "upb/json_encode.h" -#include "upb/reflection.h" +#include "upb/reflection/message.h" #include "upb/text_encode.h" // Must be last. diff --git a/upb/json_decode.c b/upb/json_decode.c index 56775cb778..2342d688e1 100644 --- a/upb/json_decode.c +++ b/upb/json_decode.c @@ -39,7 +39,7 @@ #include "upb/internal/atoi.h" #include "upb/internal/unicode.h" #include "upb/map.h" -#include "upb/reflection.h" +#include "upb/reflection/message.h" // Must be last. #include "upb/port_def.inc" diff --git a/upb/json_decode.h b/upb/json_decode.h index c7b6839427..a5abad279f 100644 --- a/upb/json_decode.h +++ b/upb/json_decode.h @@ -28,7 +28,7 @@ #ifndef UPB_JSONDECODE_H_ #define UPB_JSONDECODE_H_ -#include "upb/def.h" +#include "upb/reflection/def.h" // Must be last. #include "upb/port_def.inc" diff --git a/upb/json_decode_test.cc b/upb/json_decode_test.cc index fcc65a9360..2d41e602d8 100644 --- a/upb/json_decode_test.cc +++ b/upb/json_decode_test.cc @@ -31,9 +31,9 @@ #include "google/protobuf/struct.upb.h" #include "gtest/gtest.h" -#include "upb/def.hpp" #include "upb/json_test.upb.h" #include "upb/json_test.upbdefs.h" +#include "upb/reflection/def.hpp" #include "upb/upb.hpp" static upb_test_Box* JsonDecode(const char* json, upb_Arena* a) { diff --git a/upb/json_encode.c b/upb/json_encode.c index 9c657dddcd..487ee11098 100644 --- a/upb/json_encode.c +++ b/upb/json_encode.c @@ -39,7 +39,7 @@ #include "upb/internal/encode.h" #include "upb/internal/vsnprintf_compat.h" #include "upb/map.h" -#include "upb/reflection.h" +#include "upb/reflection/message.h" // Must be last. #include "upb/port_def.inc" diff --git a/upb/json_encode.h b/upb/json_encode.h index 7d83206580..b2207a9807 100644 --- a/upb/json_encode.h +++ b/upb/json_encode.h @@ -28,7 +28,7 @@ #ifndef UPB_JSONENCODE_H_ #define UPB_JSONENCODE_H_ -#include "upb/def.h" +#include "upb/reflection/def.h" // Must be last. #include "upb/port_def.inc" diff --git a/upb/json_encode_test.cc b/upb/json_encode_test.cc index 7abd23a93b..0d14b4176d 100644 --- a/upb/json_encode_test.cc +++ b/upb/json_encode_test.cc @@ -25,12 +25,13 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "upb/json_encode.h" + #include "google/protobuf/struct.upb.h" #include "gtest/gtest.h" -#include "upb/def.hpp" -#include "upb/json_encode.h" #include "upb/json_test.upb.h" #include "upb/json_test.upbdefs.h" +#include "upb/reflection/def.hpp" #include "upb/upb.hpp" static std::string JsonEncode(const upb_test_Box* msg, int options) { diff --git a/upb/msg_test.cc b/upb/msg_test.cc index 9e1548ae9d..113972321a 100644 --- a/upb/msg_test.cc +++ b/upb/msg_test.cc @@ -28,12 +28,12 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" #include "google/protobuf/test_messages_proto3.upb.h" -#include "upb/def.hpp" #include "upb/fuzz_test_util.h" #include "upb/json_decode.h" #include "upb/json_encode.h" #include "upb/msg_test.upb.h" #include "upb/msg_test.upbdefs.h" +#include "upb/reflection/def.hpp" #include "upb/upb.hpp" // begin:google_only diff --git a/upb/test_cpp.cc b/upb/test_cpp.cc index 4d4aec6253..e70771420b 100644 --- a/upb/test_cpp.cc +++ b/upb/test_cpp.cc @@ -38,10 +38,10 @@ #include "google/protobuf/timestamp.upb.h" #include "google/protobuf/timestamp.upbdefs.h" #include "gtest/gtest.h" -#include "upb/def.h" -#include "upb/def.hpp" #include "upb/json_decode.h" #include "upb/json_encode.h" +#include "upb/reflection/def.h" +#include "upb/reflection/def.hpp" #include "upb/test_cpp.upb.h" #include "upb/test_cpp.upbdefs.h" #include "upb/upb.h" diff --git a/upb/text_encode.c b/upb/text_encode.c index 393b8d7615..d3e9f0145c 100644 --- a/upb/text_encode.c +++ b/upb/text_encode.c @@ -37,7 +37,7 @@ #include "upb/internal/encode.h" #include "upb/internal/vsnprintf_compat.h" #include "upb/map.h" -#include "upb/reflection.h" +#include "upb/reflection/message.h" // Must be last. #include "upb/port_def.inc" diff --git a/upb/text_encode.h b/upb/text_encode.h index 312db24e35..30f7404c80 100644 --- a/upb/text_encode.h +++ b/upb/text_encode.h @@ -28,7 +28,7 @@ #ifndef UPB_TEXTENCODE_H_ #define UPB_TEXTENCODE_H_ -#include "upb/def.h" +#include "upb/reflection/def.h" // Must be last. #include "upb/port_def.inc" diff --git a/upb/util/compare.h b/upb/util/compare.h index 92f6d83ab7..d99a7e956b 100644 --- a/upb/util/compare.h +++ b/upb/util/compare.h @@ -28,7 +28,7 @@ #ifndef UPB_UTIL_COMPARE_H_ #define UPB_UTIL_COMPARE_H_ -#include "upb/def.h" +#include "upb/reflection/def.h" #ifdef __cplusplus extern "C" { diff --git a/upb/util/def_to_proto.c b/upb/util/def_to_proto.c index ae9288c9e0..ab957db578 100644 --- a/upb/util/def_to_proto.c +++ b/upb/util/def_to_proto.c @@ -33,7 +33,7 @@ #include #include "upb/internal/vsnprintf_compat.h" -#include "upb/reflection.h" +#include "upb/reflection/message.h" /* Must be last. */ #include "upb/port_def.inc" diff --git a/upb/util/def_to_proto.h b/upb/util/def_to_proto.h index 24f65b9bfb..08c64532e9 100644 --- a/upb/util/def_to_proto.h +++ b/upb/util/def_to_proto.h @@ -28,7 +28,7 @@ #ifndef UPB_UTIL_DEF_TO_PROTO_H_ #define UPB_UTIL_DEF_TO_PROTO_H_ -#include "upb/def.h" +#include "upb/reflection/def.h" #ifdef __cplusplus extern "C" { diff --git a/upb/util/def_to_proto_test.cc b/upb/util/def_to_proto_test.cc index d8156e3989..b83e1c3623 100644 --- a/upb/util/def_to_proto_test.cc +++ b/upb/util/def_to_proto_test.cc @@ -27,13 +27,13 @@ #include "upb/util/def_to_proto.h" -#include "gmock/gmock.h" #include "google/protobuf/descriptor.pb.h" #include "google/protobuf/descriptor.upbdefs.h" #include "google/protobuf/dynamic_message.h" #include "google/protobuf/util/message_differencer.h" +#include "gmock/gmock.h" #include "gtest/gtest.h" -#include "upb/def.hpp" +#include "upb/reflection/def.hpp" #include "upb/upb.hpp" #include "upb/util/def_to_proto_test.upbdefs.h" diff --git a/upb/util/required_fields.c b/upb/util/required_fields.c index 260a5b1d09..2bc714509d 100644 --- a/upb/util/required_fields.c +++ b/upb/util/required_fields.c @@ -34,7 +34,7 @@ #include "upb/internal/vsnprintf_compat.h" #include "upb/map.h" -#include "upb/reflection.h" +#include "upb/reflection/message.h" // Must be last. #include "upb/port_def.inc" diff --git a/upb/util/required_fields.h b/upb/util/required_fields.h index 874914bd67..e58f7ca38f 100644 --- a/upb/util/required_fields.h +++ b/upb/util/required_fields.h @@ -28,8 +28,8 @@ #ifndef UPB_UTIL_REQUIRED_FIELDS_H_ #define UPB_UTIL_REQUIRED_FIELDS_H_ -#include "upb/def.h" -#include "upb/reflection.h" +#include "upb/reflection/def.h" +#include "upb/reflection/message.h" /* Must be last. */ #include "upb/port_def.inc" diff --git a/upb/util/required_fields_test.cc b/upb/util/required_fields_test.cc index 85504101e6..7d44ef7954 100644 --- a/upb/util/required_fields_test.cc +++ b/upb/util/required_fields_test.cc @@ -27,11 +27,11 @@ #include "upb/util/required_fields.h" -#include "absl/strings/string_view.h" #include "gmock/gmock.h" #include "gtest/gtest.h" -#include "upb/def.hpp" +#include "absl/strings/string_view.h" #include "upb/json_decode.h" +#include "upb/reflection/def.hpp" #include "upb/upb.hpp" #include "upb/util/required_fields_test.upb.h" #include "upb/util/required_fields_test.upbdefs.h" diff --git a/upbc/protoc-gen-upbdefs.cc b/upbc/protoc-gen-upbdefs.cc index 51b3b95927..e1924218d4 100644 --- a/upbc/protoc-gen-upbdefs.cc +++ b/upbc/protoc-gen-upbdefs.cc @@ -69,14 +69,14 @@ void WriteDefHeader(const protobuf::FileDescriptor* file, Output& output) { output( "#ifndef $0_UPBDEFS_H_\n" "#define $0_UPBDEFS_H_\n\n" - "#include \"upb/def.h\"\n" + "#include \"upb/reflection/def.h\"\n" "#include \"upb/port_def.inc\"\n" "#ifdef __cplusplus\n" "extern \"C\" {\n" "#endif\n\n", ToPreproc(file->name())); - output("#include \"upb/def.h\"\n"); + output("#include \"upb/reflection/def.h\"\n"); output("\n"); output("#include \"upb/port_def.inc\"\n"); output("\n"); @@ -102,7 +102,7 @@ void WriteDefHeader(const protobuf::FileDescriptor* file, Output& output) { void WriteDefSource(const protobuf::FileDescriptor* file, Output& output) { EmitFileWarning(file, output); - output("#include \"upb/def.h\"\n"); + output("#include \"upb/reflection/def.h\"\n"); output("#include \"$0\"\n", DefHeaderFilename(file->name())); output("#include \"$0\"\n", HeaderFilename(file)); output("\n");