Merge commit 'f9d27c0b8c77ebaa42dd1d287e1ec7d0c3682ad4' into upb-update

pull/21645/head
Esun Kim 5 years ago
commit 7e32ac31ca
  1. 58
      third_party/upb/BUILD
  2. 15
      third_party/upb/CMakeLists.txt
  3. 1
      third_party/upb/bazel/upb_proto_library.bzl
  4. 2
      third_party/upb/bazel/workspace_deps.bzl
  5. 4
      third_party/upb/upb/decode.c
  6. 1
      third_party/upb/upb/port.c
  7. 4
      third_party/upb/upb/port_def.inc
  8. 3
      third_party/upb/upb/table.c

@ -54,6 +54,17 @@ config_setting(
# Public C/C++ libraries ####################################################### # Public C/C++ libraries #######################################################
cc_library(
name = "port",
textual_hdrs = [
"upb/port_def.inc",
"upb/port_undef.inc",
],
srcs = [
"upb/port.c",
],
)
cc_library( cc_library(
name = "upb", name = "upb",
srcs = [ srcs = [
@ -62,9 +73,6 @@ cc_library(
"upb/generated_util.h", "upb/generated_util.h",
"upb/msg.c", "upb/msg.c",
"upb/msg.h", "upb/msg.h",
"upb/port.c",
"upb/port_def.inc",
"upb/port_undef.inc",
"upb/table.c", "upb/table.c",
"upb/table.int.h", "upb/table.int.h",
"upb/upb.c", "upb/upb.c",
@ -79,6 +87,7 @@ cc_library(
"//conditions:default": COPTS, "//conditions:default": COPTS,
}), }),
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
deps = [":port"],
) )
# Common support routines used by generated code. This library has no # Common support routines used by generated code. This library has no
@ -92,17 +101,17 @@ cc_library(
hdrs = [ hdrs = [
"upb/generated_util.h", "upb/generated_util.h",
"upb/msg.h", "upb/msg.h",
"upb/port_def.inc",
"upb/port_undef.inc",
], ],
copts = select({ copts = select({
":windows": [], ":windows": [],
"//conditions:default": COPTS, "//conditions:default": COPTS,
}), }),
textual_hdrs = [
"upb/port_def.inc",
"upb/port_undef.inc",
],
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
deps = [":upb"], deps = [
":upb",
],
) )
upb_proto_library( upb_proto_library(
@ -128,6 +137,7 @@ cc_library(
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
deps = [ deps = [
":descriptor_upbproto", ":descriptor_upbproto",
":port",
":table", ":table",
":upb", ":upb",
], ],
@ -138,7 +148,10 @@ cc_library(
cc_library( cc_library(
name = "table", name = "table",
hdrs = ["upb/table.int.h"], hdrs = ["upb/table.int.h"],
deps = [":upb"], deps = [
":port",
":upb",
],
) )
# Legacy C/C++ Libraries (not recommended for new code) ######################## # Legacy C/C++ Libraries (not recommended for new code) ########################
@ -146,6 +159,7 @@ cc_library(
cc_library( cc_library(
name = "legacy_msg_reflection", name = "legacy_msg_reflection",
srcs = [ srcs = [
"upb/msg.h",
"upb/legacy_msg_reflection.c", "upb/legacy_msg_reflection.c",
], ],
hdrs = ["upb/legacy_msg_reflection.h"], hdrs = ["upb/legacy_msg_reflection.h"],
@ -154,6 +168,7 @@ cc_library(
"//conditions:default": COPTS, "//conditions:default": COPTS,
}), }),
deps = [ deps = [
":port",
":table", ":table",
":upb", ":upb",
], ],
@ -176,6 +191,7 @@ cc_library(
}), }),
deps = [ deps = [
":reflection", ":reflection",
":port",
":table", ":table",
":upb", ":upb",
], ],
@ -205,6 +221,7 @@ cc_library(
":descriptor_upbproto", ":descriptor_upbproto",
":handlers", ":handlers",
":reflection", ":reflection",
":port",
":table", ":table",
":upb", ":upb",
], ],
@ -240,6 +257,7 @@ cc_library(
deps = [ deps = [
":descriptor_upbproto", ":descriptor_upbproto",
":handlers", ":handlers",
":port",
":upb", ":upb",
], ],
) )
@ -259,9 +277,9 @@ cc_library(
"//conditions:default": CPPOPTS, "//conditions:default": CPPOPTS,
}), }),
deps = [ deps = [
"@absl//absl/base:core_headers", "@com_google_absl//absl/base:core_headers",
"@absl//absl/container:flat_hash_map", "@com_google_absl//absl/container:flat_hash_map",
"@absl//absl/strings", "@com_google_absl//absl/strings",
"@com_google_protobuf//:protobuf", "@com_google_protobuf//:protobuf",
"@com_google_protobuf//:protoc_lib", "@com_google_protobuf//:protoc_lib",
], ],
@ -286,6 +304,11 @@ cc_binary(
# C/C++ tests ################################################################## # C/C++ tests ##################################################################
upb_proto_reflection_library(
name = "descriptor_upbreflection",
deps = ["@com_google_protobuf//:descriptor_proto"],
)
cc_binary( cc_binary(
name = "benchmark", name = "benchmark",
testonly = 1, testonly = 1,
@ -313,6 +336,7 @@ cc_library(
}), }),
deps = [ deps = [
":handlers", ":handlers",
":port",
":upb", ":upb",
], ],
) )
@ -328,6 +352,7 @@ cc_test(
"//conditions:default": COPTS, "//conditions:default": COPTS,
}), }),
deps = [ deps = [
":port",
":upb", ":upb",
":upb_pb", ":upb_pb",
":upb_test", ":upb_test",
@ -358,6 +383,7 @@ cc_test(
}), }),
deps = [ deps = [
":handlers", ":handlers",
":port",
":test_decoder_upbproto", ":test_decoder_upbproto",
":upb", ":upb",
":upb_pb", ":upb_pb",
@ -386,6 +412,7 @@ cc_test(
}), }),
deps = [ deps = [
":handlers", ":handlers",
":port",
":reflection", ":reflection",
":test_cpp_upbproto", ":test_cpp_upbproto",
":upb", ":upb",
@ -402,6 +429,7 @@ cc_test(
"//conditions:default": CPPOPTS, "//conditions:default": CPPOPTS,
}), }),
deps = [ deps = [
":port",
":table", ":table",
":upb", ":upb",
":upb_test", ":upb_test",
@ -431,11 +459,6 @@ cc_binary(
) )
# copybara:strip_for_google3_begin # copybara:strip_for_google3_begin
upb_proto_reflection_library(
name = "descriptor_upbreflection",
deps = ["@com_google_protobuf//:descriptor_proto"],
)
cc_test( cc_test(
name = "test_encoder", name = "test_encoder",
srcs = ["tests/pb/test_encoder.cc"], srcs = ["tests/pb/test_encoder.cc"],
@ -563,6 +586,7 @@ upb_amalgamation(
":descriptor_upbproto", ":descriptor_upbproto",
":reflection", ":reflection",
":handlers", ":handlers",
":port",
":upb_pb", ":upb_pb",
":upb_json", ":upb_json",
], ],

@ -60,21 +60,22 @@ endif()
enable_testing() enable_testing()
add_library(port
upb/port.c)
add_library(upb add_library(upb
upb/decode.c upb/decode.c
upb/encode.c upb/encode.c
upb/generated_util.h upb/generated_util.h
upb/msg.c upb/msg.c
upb/msg.h upb/msg.h
upb/port.c
upb/port_def.inc
upb/port_undef.inc
upb/table.c upb/table.c
upb/table.int.h upb/table.int.h
upb/upb.c upb/upb.c
upb/decode.h upb/decode.h
upb/encode.h upb/encode.h
upb/upb.h) upb/upb.h)
target_link_libraries(upb
port)
add_library(generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me INTERFACE) add_library(generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me INTERFACE)
target_link_libraries(generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me INTERFACE target_link_libraries(generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me INTERFACE
upb) upb)
@ -85,15 +86,19 @@ add_library(reflection
upb/msgfactory.h) upb/msgfactory.h)
target_link_libraries(reflection target_link_libraries(reflection
descriptor_upbproto descriptor_upbproto
port
table table
upb) upb)
add_library(table INTERFACE) add_library(table INTERFACE)
target_link_libraries(table INTERFACE target_link_libraries(table INTERFACE
port
upb) upb)
add_library(legacy_msg_reflection add_library(legacy_msg_reflection
upb/msg.h
upb/legacy_msg_reflection.c upb/legacy_msg_reflection.c
upb/legacy_msg_reflection.h) upb/legacy_msg_reflection.h)
target_link_libraries(legacy_msg_reflection target_link_libraries(legacy_msg_reflection
port
table table
upb) upb)
add_library(handlers add_library(handlers
@ -104,6 +109,7 @@ add_library(handlers
upb/sink.h) upb/sink.h)
target_link_libraries(handlers target_link_libraries(handlers
reflection reflection
port
table table
upb) upb)
add_library(upb_pb add_library(upb_pb
@ -121,6 +127,7 @@ target_link_libraries(upb_pb
descriptor_upbproto descriptor_upbproto
handlers handlers
reflection reflection
port
table table
upb) upb)
add_library(upb_json add_library(upb_json
@ -135,6 +142,7 @@ add_library(upb_cc_bindings INTERFACE)
target_link_libraries(upb_cc_bindings INTERFACE target_link_libraries(upb_cc_bindings INTERFACE
descriptor_upbproto descriptor_upbproto
handlers handlers
port
upb) upb)
add_library(upb_test add_library(upb_test
tests/testmain.cc tests/testmain.cc
@ -142,6 +150,7 @@ add_library(upb_test
tests/upb_test.h) tests/upb_test.h)
target_link_libraries(upb_test target_link_libraries(upb_test
handlers handlers
port
upb) upb)

@ -279,6 +279,7 @@ _upb_proto_reflection_library_aspect = aspect(
), ),
"_upb": attr.label_list( "_upb": attr.label_list(
default = [ default = [
"//:generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me",
"//:upb", "//:upb",
"//:reflection", "//:reflection",
], ],

@ -8,7 +8,7 @@ def upb_deps():
) )
git_repository( git_repository(
name = "absl", name = "com_google_absl",
commit = "070f6e47b33a2909d039e620c873204f78809492", commit = "070f6e47b33a2909d039e620c873204f78809492",
remote = "https://github.com/abseil/abseil-cpp.git", remote = "https://github.com/abseil/abseil-cpp.git",
shallow_since = "1541627663 -0500", shallow_since = "1541627663 -0500",

@ -249,6 +249,10 @@ static upb_msg *upb_addmsg(upb_decframe *frame,
upb_msg *submsg; upb_msg *submsg;
upb_array *arr = upb_getorcreatearr(frame, field); upb_array *arr = upb_getorcreatearr(frame, field);
UPB_ASSERT(field->label == UPB_LABEL_REPEATED);
UPB_ASSERT(field->descriptortype == UPB_DESCRIPTOR_TYPE_MESSAGE ||
field->descriptortype == UPB_DESCRIPTOR_TYPE_GROUP);
*subm = frame->layout->submsgs[field->submsg_index]; *subm = frame->layout->submsgs[field->submsg_index];
submsg = upb_msg_new(*subm, frame->state->arena); submsg = upb_msg_new(*subm, frame->state->arena);
CHK(submsg); CHK(submsg);

@ -1,5 +1,4 @@
#include "upb/upb.h"
#include "upb/port_def.inc" #include "upb/port_def.inc"
#ifdef UPB_MSVC_VSNPRINTF #ifdef UPB_MSVC_VSNPRINTF

@ -20,9 +20,7 @@
* *
* This file is private and must not be included by users! * This file is private and must not be included by users!
*/ */
#ifndef UINTPTR_MAX #include <stdint.h>
#error must include stdint.h first
#endif
#if UINTPTR_MAX == 0xffffffff #if UINTPTR_MAX == 0xffffffff
#define UPB_SIZE(size32, size64) size32 #define UPB_SIZE(size32, size64) size32

@ -756,7 +756,8 @@ uint32_t upb_murmur_hash2(const void *key, size_t len, uint32_t seed) {
/* Mix 4 bytes at a time into the hash */ /* Mix 4 bytes at a time into the hash */
const uint8_t * data = (const uint8_t *)key; const uint8_t * data = (const uint8_t *)key;
while(len >= 4) { while(len >= 4) {
uint32_t k = *(uint32_t *)data; uint32_t k;
memcpy(&k, data, sizeof(k));
k *= m; k *= m;
k ^= k >> r; k ^= k >> r;

Loading…
Cancel
Save