Skip to content
Permalink
Browse files

Down integrate to GitHub

  • Loading branch information...
rafi-kamal committed Aug 22, 2019
1 parent 893a7d3 commit 4f02f056b5cea99052bfdfb6698afe47a3cf2964
Showing with 5,271 additions and 7,824 deletions.
  1. +154 −182 conformance/binary_json_conformance_suite.cc
  2. +0 −26 conformance/conformance_cpp.cc
  3. +2 −2 conformance/conformance_objc.m
  4. +8 −11 conformance/conformance_test.cc
  5. +16 −10 conformance/conformance_test.h
  6. +15 −8 conformance/conformance_test_runner.cc
  7. BIN csharp/src/Google.Protobuf.Test/testprotos.pb
  8. +9 −0 java/core/src/main/java/com/google/protobuf/AbstractMessageLite.java
  9. +10 −0 java/core/src/main/java/com/google/protobuf/GeneratedMessageV3.java
  10. +318 −0 java/core/src/main/java/com/google/protobuf/UnsafeUtil.java
  11. +2 −2 java/util/src/main/java/com/google/protobuf/util/FieldMaskUtil.java
  12. +10 −2 java/util/src/test/java/com/google/protobuf/util/FieldMaskTreeTest.java
  13. +44 −163 js/binary/decoder.js
  14. +89 −0 js/binary/decoder_test.js
  15. +18 −4 js/binary/encoder.js
  16. +35 −1 js/binary/reader.js
  17. +10 −0 js/binary/reader_test.js
  18. +53 −14 js/binary/utils.js
  19. +47 −0 js/binary/utils_test.js
  20. +119 −11 js/binary/writer.js
  21. +120 −2 js/binary/writer_test.js
  22. +3 −3 js/compatibility_tests/v3.0.0/binary/proto_test.js
  23. +3 −3 js/compatibility_tests/v3.0.0/binary/utils_test.js
  24. +3 −2 js/compatibility_tests/v3.0.0/message_test.js
  25. +1 −1 js/compatibility_tests/v3.0.0/proto3_test.js
  26. +3 −3 js/compatibility_tests/v3.1.0/binary/proto_test.js
  27. +3 −3 js/compatibility_tests/v3.1.0/binary/utils_test.js
  28. +3 −2 js/compatibility_tests/v3.1.0/message_test.js
  29. +1 −1 js/compatibility_tests/v3.1.0/proto3_test.js
  30. +16 −6 js/map.js
  31. +78 −2 js/maps_test.js
  32. +0 −10 js/message.js
  33. +5 −5 js/package.json
  34. +50 −0 js/testbinary.proto
  35. +49 −0 python/google/protobuf/descriptor_pool.py
  36. +21 −1 python/google/protobuf/internal/decoder.py
  37. +2 −1 python/google/protobuf/internal/descriptor_test.py
  38. +3 −0 python/google/protobuf/internal/extension_dict.py
  39. +2 −3 python/google/protobuf/internal/python_message.py
  40. +39 −0 python/google/protobuf/internal/reflection_test.py
  41. +11 −10 python/google/protobuf/internal/text_format_test.py
  42. +24 −1 python/google/protobuf/internal/unknown_fields_test.py
  43. +4 −0 python/google/protobuf/pyext/extension_dict.cc
  44. +68 −59 python/google/protobuf/pyext/message.cc
  45. +6 −15 python/google/protobuf/pyext/message.h
  46. +13 −4 python/google/protobuf/symbol_database.py
  47. +5 −2 python/google/protobuf/text_format.py
  48. +0 −58 src/google/protobuf/any.pb.cc
  49. +0 −5 src/google/protobuf/any.pb.h
  50. +35 −345 src/google/protobuf/api.pb.cc
  51. +142 −40 src/google/protobuf/api.pb.h
  52. +1 −1 src/google/protobuf/arena.h
  53. +21 −13 src/google/protobuf/compiler/command_line_interface.cc
  54. +74 −1 src/google/protobuf/compiler/command_line_interface_unittest.cc
  55. +10 −11 src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc
  56. +61 −57 src/google/protobuf/compiler/cpp/cpp_enum_field.cc
  57. +0 −1 src/google/protobuf/compiler/cpp/cpp_enum_field.h
  58. +0 −11 src/google/protobuf/compiler/cpp/cpp_field.cc
  59. +0 −13 src/google/protobuf/compiler/cpp/cpp_field.h
  60. +1 −12 src/google/protobuf/compiler/cpp/cpp_file.cc
  61. +14 −16 src/google/protobuf/compiler/cpp/cpp_helpers.cc
  62. +1 −6 src/google/protobuf/compiler/cpp/cpp_helpers.h
  63. +27 −81 src/google/protobuf/compiler/cpp/cpp_map_field.cc
  64. +0 −1 src/google/protobuf/compiler/cpp/cpp_map_field.h
  65. +43 −331 src/google/protobuf/compiler/cpp/cpp_message.cc
  66. +74 −73 src/google/protobuf/compiler/cpp/cpp_message_field.cc
  67. +0 −2 src/google/protobuf/compiler/cpp/cpp_message_field.h
  68. +66 −68 src/google/protobuf/compiler/cpp/cpp_primitive_field.cc
  69. +0 −4 src/google/protobuf/compiler/cpp/cpp_primitive_field.h
  70. +31 −123 src/google/protobuf/compiler/cpp/cpp_string_field.cc
  71. +0 −3 src/google/protobuf/compiler/cpp/cpp_string_field.h
  72. +2 −1 src/google/protobuf/compiler/cpp/cpp_unittest.inc
  73. +1 −1 src/google/protobuf/compiler/importer_unittest.cc
  74. +2 −1 src/google/protobuf/compiler/java/java_file.cc
  75. +2 −1 src/google/protobuf/compiler/java/java_helpers.cc
  76. +1 −1 src/google/protobuf/compiler/java/java_helpers.h
  77. +7 −3 src/google/protobuf/compiler/java/java_message.cc
  78. +3 −4 src/google/protobuf/compiler/java/java_message_lite.cc
  79. +2 −1 src/google/protobuf/compiler/java/java_string_field.cc
  80. +7 −0 src/google/protobuf/compiler/js/js_generator.cc
  81. +3 −2 src/google/protobuf/compiler/mock_code_generator.cc
  82. +2 −1 src/google/protobuf/compiler/parser.cc
  83. +4 −5 src/google/protobuf/compiler/parser_unittest.cc
  84. +22 −329 src/google/protobuf/compiler/plugin.pb.cc
  85. +121 −48 src/google/protobuf/compiler/plugin.pb.h
  86. +3 −3 src/google/protobuf/compiler/python/python_generator.cc
  87. +20 −28 src/google/protobuf/descriptor.cc
  88. +275 −2,860 src/google/protobuf/descriptor.pb.cc
  89. +1,592 −467 src/google/protobuf/descriptor.pb.h
  90. +11 −7 src/google/protobuf/descriptor_unittest.cc
  91. +6 −64 src/google/protobuf/duration.pb.cc
  92. +24 −9 src/google/protobuf/duration.pb.h
  93. +0 −27 src/google/protobuf/empty.pb.cc
  94. +0 −5 src/google/protobuf/empty.pb.h
  95. +0 −3 src/google/protobuf/extension_set.cc
  96. +2 −9 src/google/protobuf/extension_set.h
  97. +0 −3 src/google/protobuf/extension_set_heavy.cc
  98. +0 −2 src/google/protobuf/extension_set_inl.h
  99. +2 −51 src/google/protobuf/field_mask.pb.cc
  100. +12 −7 src/google/protobuf/field_mask.pb.h
  101. +1 −1 src/google/protobuf/has_bits.h
  102. +0 −9 src/google/protobuf/implicit_weak_message.cc
  103. +0 −4 src/google/protobuf/implicit_weak_message.h
  104. +2 −1 src/google/protobuf/inlined_string_field.h
  105. +2 −2 src/google/protobuf/io/io_win32.cc
  106. +1 −2 src/google/protobuf/io/io_win32.h
  107. +61 −72 src/google/protobuf/io/io_win32_unittest.cc
  108. +0 −4 src/google/protobuf/lite_unittest.cc
  109. +0 −42 src/google/protobuf/map_entry_lite.h
  110. +5 −12 src/google/protobuf/map_field_lite.h
  111. +11 −3 src/google/protobuf/map_test.cc
  112. +2 −2 src/google/protobuf/map_type_handler.h
  113. +4 −9 src/google/protobuf/message.cc
  114. +1 −7 src/google/protobuf/message.h
  115. +0 −36 src/google/protobuf/message_lite.cc
  116. +0 −6 src/google/protobuf/message_lite.h
  117. +3 −1 src/google/protobuf/message_unittest.inc
  118. +1 −4 src/google/protobuf/parse_context.cc
  119. +19 −1 src/google/protobuf/parse_context.h
  120. +16 −0 src/google/protobuf/port_def.inc
  121. +1 −0 src/google/protobuf/port_undef.inc
  122. +31 −28 src/google/protobuf/reflection_ops.cc
  123. +0 −47 src/google/protobuf/source_context.pb.cc
  124. +0 −5 src/google/protobuf/source_context.pb.h
  125. +40 −248 src/google/protobuf/struct.pb.cc
  126. +150 −73 src/google/protobuf/struct.pb.h
  127. +8 −0 src/google/protobuf/stubs/common.h
  128. +1 −8 src/google/protobuf/stubs/port.h
  129. +90 −89 src/google/protobuf/test_messages_proto2.proto
  130. +88 −87 src/google/protobuf/test_messages_proto3.proto
  131. +2 −1 src/google/protobuf/test_util_lite.cc
  132. +1 −1 src/google/protobuf/testing/zcgunzip.cc
  133. +1 −1 src/google/protobuf/testing/zcgzip.cc
  134. +2 −2 src/google/protobuf/text_format.cc
  135. +7 −0 src/google/protobuf/text_format_unittest.cc
  136. +6 −64 src/google/protobuf/timestamp.pb.cc
  137. +24 −9 src/google/protobuf/timestamp.pb.h
  138. +68 −572 src/google/protobuf/type.pb.cc
  139. +276 −76 src/google/protobuf/type.pb.h
  140. +0 −3 src/google/protobuf/unknown_field_set.cc
  141. +0 −2 src/google/protobuf/unknown_field_set.h
  142. +2 −1 src/google/protobuf/util/field_mask_util.h
  143. +1 −1 src/google/protobuf/util/internal/datapiece.h
  144. +1 −1 src/google/protobuf/util/internal/default_value_objectwriter.h
  145. +2 −1 src/google/protobuf/util/internal/error_listener.h
  146. +1 −0 src/google/protobuf/util/internal/field_mask_utility.cc
  147. +1 −1 src/google/protobuf/util/internal/field_mask_utility.h
  148. +1 −1 src/google/protobuf/util/internal/json_stream_parser.h
  149. +0 −1 src/google/protobuf/util/internal/json_stream_parser_test.cc
  150. +2 −1 src/google/protobuf/util/internal/object_source.h
  151. +2 −1 src/google/protobuf/util/internal/object_writer.h
  152. +1 −1 src/google/protobuf/util/internal/protostream_objectsource.h
  153. +0 −1 src/google/protobuf/util/internal/protostream_objectsource_test.cc
  154. +1 −1 src/google/protobuf/util/internal/type_info.cc
  155. +2 −1 src/google/protobuf/util/internal/type_info.h
  156. +1 −1 src/google/protobuf/util/internal/utility.h
  157. +4 −0 src/google/protobuf/util/json_format_proto3.proto
  158. +18 −423 src/google/protobuf/wrappers.pb.cc
  159. +84 −59 src/google/protobuf/wrappers.pb.h

Large diffs are not rendered by default.

@@ -60,32 +60,6 @@ using std::string;
static const char kTypeUrlPrefix[] = "type.googleapis.com";

const char* kFailures[] = {
#if !GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
"Required.Proto2.ProtobufInput."
"PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE",
"Required.Proto2.ProtobufInput."
"PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE",
"Required.Proto2.ProtobufInput.PrematureEofInPackedField.BOOL",
"Required.Proto2.ProtobufInput.PrematureEofInPackedField.ENUM",
"Required.Proto2.ProtobufInput.PrematureEofInPackedField.INT32",
"Required.Proto2.ProtobufInput.PrematureEofInPackedField.INT64",
"Required.Proto2.ProtobufInput.PrematureEofInPackedField.SINT32",
"Required.Proto2.ProtobufInput.PrematureEofInPackedField.SINT64",
"Required.Proto2.ProtobufInput.PrematureEofInPackedField.UINT32",
"Required.Proto2.ProtobufInput.PrematureEofInPackedField.UINT64",
"Required.Proto3.ProtobufInput."
"PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE",
"Required.Proto3.ProtobufInput."
"PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE",
"Required.Proto3.ProtobufInput.PrematureEofInPackedField.BOOL",
"Required.Proto3.ProtobufInput.PrematureEofInPackedField.ENUM",
"Required.Proto3.ProtobufInput.PrematureEofInPackedField.INT32",
"Required.Proto3.ProtobufInput.PrematureEofInPackedField.INT64",
"Required.Proto3.ProtobufInput.PrematureEofInPackedField.SINT32",
"Required.Proto3.ProtobufInput.PrematureEofInPackedField.SINT64",
"Required.Proto3.ProtobufInput.PrematureEofInPackedField.UINT32",
"Required.Proto3.ProtobufInput.PrematureEofInPackedField.UINT64",
#endif
};

static string GetTypeUrl(const Descriptor* message) {
@@ -80,8 +80,8 @@ static void Die(NSString *format, ...) {
msgClass = [TestAllTypesProto2 class];
} else {
response.runtimeError =
[NSString stringWithFormat:
@"Protobuf request had an unknown message_type: %@", request.messageType];
[NSString stringWithFormat:@"Protobuf request had an unknown message_type: %@",
request.messageType];
break;
}
NSError *error = nil;
@@ -71,7 +71,7 @@ static string ToOctString(const string& binary_string) {
return oct_string;
}

}
} // namespace

namespace google {
namespace protobuf {
@@ -239,21 +239,18 @@ void ConformanceTestSuite::RunValidInputTest(

void ConformanceTestSuite::RunValidBinaryInputTest(
const ConformanceRequestSetting& setting,
const string& equivalent_wire_format,
bool require_same_wire_format) {
const string& equivalent_wire_format, bool require_same_wire_format) {
const ConformanceRequest& request = setting.GetRequest();
ConformanceResponse response;
RunTest(setting.GetTestName(), request, &response);
VerifyResponse(setting, equivalent_wire_format, response,
true, require_same_wire_format);
VerifyResponse(setting, equivalent_wire_format, response, true,
require_same_wire_format);
}

void ConformanceTestSuite::VerifyResponse(
const ConformanceRequestSetting& setting,
const string& equivalent_wire_format,
const ConformanceResponse& response,
bool need_report_success,
bool require_same_wire_format) {
const string& equivalent_wire_format, const ConformanceResponse& response,
bool need_report_success, bool require_same_wire_format) {
Message* test_message = setting.GetTestMessage();
const ConformanceRequest& request = setting.GetRequest();
const string& test_name = setting.GetTestName();
@@ -296,8 +293,8 @@ void ConformanceTestSuite::VerifyResponse(

if (require_same_wire_format) {
GOOGLE_DCHECK_EQ(response.result_case(),
ConformanceResponse::kProtobufPayload);
const string& protobuf_payload = response.protobuf_payload();
ConformanceResponse::kProtobufPayload);
const string& protobuf_payload = response.protobuf_payload();
check = equivalent_wire_format == protobuf_payload;
differences = StrCat("Expect: ", ToOctString(equivalent_wire_format),
", but got: ", ToOctString(protobuf_payload));
@@ -38,14 +38,15 @@
#ifndef CONFORMANCE_CONFORMANCE_TEST_H
#define CONFORMANCE_CONFORMANCE_TEST_H

#include <functional>
#include <string>

#include <google/protobuf/descriptor.h>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/util/type_resolver.h>
#include <google/protobuf/wire_format_lite.h>

#include <functional>
#include <string>
#include <vector>

#include "conformance.pb.h"

namespace conformance {
@@ -88,7 +89,13 @@ class ForkPipeRunner : public ConformanceTestRunner {
static int Run(int argc, char *argv[],
const std::vector<ConformanceTestSuite*>& suites);

ForkPipeRunner(const std::string &executable)
ForkPipeRunner(const std::string& executable,
const std::vector<string>& executable_args)
: child_pid_(-1),
executable_(executable),
executable_args_(executable_args) {}

explicit ForkPipeRunner(const std::string& executable)
: child_pid_(-1), executable_(executable) {}

virtual ~ForkPipeRunner() {}
@@ -108,6 +115,7 @@ class ForkPipeRunner : public ConformanceTestRunner {
int read_fd_;
pid_t child_pid_;
std::string executable_;
const std::vector<string> executable_args_;
std::string current_test_name_;
};

@@ -257,12 +265,10 @@ class ConformanceTestSuite {
const ConformanceRequestSetting& setting,
Message* test_message) = 0;

void VerifyResponse(
const ConformanceRequestSetting& setting,
const string& equivalent_wire_format,
const conformance::ConformanceResponse& response,
bool need_report_success,
bool require_same_wire_format);
void VerifyResponse(const ConformanceRequestSetting& setting,
const string& equivalent_wire_format,
const conformance::ConformanceResponse& response,
bool need_report_success, bool require_same_wire_format);

void ReportSuccess(const std::string& test_name);
void ReportFailure(const string& test_name,
@@ -195,7 +195,8 @@ int ForkPipeRunner::Run(
}
bool all_ok = true;
for (ConformanceTestSuite* suite : suites) {
char *program;
string program;
std::vector<string> program_args;
string failure_list_filename;
conformance::FailureSet failure_list;

@@ -221,15 +222,15 @@ int ForkPipeRunner::Run(
UsageError();
}
} else {
if (arg != argc - 1) {
fprintf(stderr, "Too many arguments.\n");
UsageError();
program += argv[arg];
while (arg < argc) {
program_args.push_back(argv[arg]);
arg++;
}
program = argv[arg];
}
}

ForkPipeRunner runner(program);
ForkPipeRunner runner(program, program_args);

std::string output;
all_ok = all_ok &&
@@ -295,8 +296,14 @@ void ForkPipeRunner::SpawnTestProgram() {
memcpy(executable.get(), executable_.c_str(), executable_.size());
executable[executable_.size()] = '\0';

char *const argv[] = {executable.get(), NULL};
CHECK_SYSCALL(execv(executable.get(), argv)); // Never returns.
std::vector<const char *> argv;
argv.push_back(executable.get());
for (int i = 0; i < executable_args_.size(); ++i) {
argv.push_back(executable_args_[i].c_str());
}
argv.push_back(nullptr);
// Never returns.
CHECK_SYSCALL(execv(executable.get(), const_cast<char **>(argv.data())));
}
}

Binary file not shown.
@@ -146,6 +146,15 @@ protected static void checkByteStringIsUtf8(ByteString byteString)
Builder.addAll(values, list);
}

/** Interface for an enum which signifies which field in a {@code oneof} was specified. */
protected interface InternalOneOfEnum {
/**
* Retrieves the field number of the field which was set in this {@code oneof}, or {@code 0} if
* none were.
*/
int getNumber();
}

/**
* A partial implementation of the {@link Message.Builder} interface which implements as many
* methods of that interface as possible in terms of other methods.
@@ -2365,6 +2365,11 @@ static MethodInvoker tryGetMethodHandleInvoke(ReflectionInvoker accessor) {
}
try {
return new MethodHandleInvoker(accessor);
} catch (NoClassDefFoundError e) {
// Fall back to reflection if MethodHandleInvoker isn't available,
// allowing clients that don't want to use method handles to opt out
// by deleting the class.
return accessor;
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
@@ -2703,6 +2708,11 @@ static MethodInvoker tryGetMethodHandleInvoke(ReflectionInvoker accessor) {
}
try {
return new MethodHandleInvoker(accessor);
} catch (NoClassDefFoundError e) {
// Fall back to reflection if MethodHandleInvoker isn't available,
// allowing clients that don't want to use method handles to opt out
// by deleting the class.
return accessor;
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}

0 comments on commit 4f02f05

Please sign in to comment.
You can’t perform that action at this time.