0002-Fix-build-with-protobuf-3.6.x.patch 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. From 67e5187e96baac2e16d88ac01471c5ce7cdc3c53 Mon Sep 17 00:00:00 2001
  2. From: ilovezfs <ilovezfs@icloud.com>
  3. Date: Wed, 20 Jun 2018 08:08:53 -0700
  4. Subject: [PATCH] Fix build with protobuf 3.6.x
  5. Adapt to changes from https://github.com/google/protobuf/pull/4387.
  6. scoped_ptr and scoped_array were removed in favor of std::unique_ptr
  7. Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  8. [Retrieved from: https://github.com/protobuf-c/protobuf-c/pull/328]
  9. ---
  10. protoc-c/c_field.cc | 2 +-
  11. protoc-c/c_field.h | 2 +-
  12. protoc-c/c_file.cc | 8 ++++----
  13. protoc-c/c_file.h | 8 ++++----
  14. protoc-c/c_generator.cc | 4 ++--
  15. protoc-c/c_helpers.cc | 2 +-
  16. protoc-c/c_message.cc | 6 +++---
  17. protoc-c/c_message.h | 6 +++---
  18. 8 files changed, 19 insertions(+), 19 deletions(-)
  19. diff --git a/protoc-c/c_field.cc b/protoc-c/c_field.cc
  20. index 9fa56ef..eaa38d2 100644
  21. --- a/protoc-c/c_field.cc
  22. +++ b/protoc-c/c_field.cc
  23. @@ -189,7 +189,7 @@ void FieldGenerator::GenerateDescriptorInitializerGeneric(io::Printer* printer,
  24. FieldGeneratorMap::FieldGeneratorMap(const Descriptor* descriptor)
  25. : descriptor_(descriptor),
  26. field_generators_(
  27. - new scoped_ptr<FieldGenerator>[descriptor->field_count()]) {
  28. + new std::unique_ptr<FieldGenerator>[descriptor->field_count()]) {
  29. // Construct all the FieldGenerators.
  30. for (int i = 0; i < descriptor->field_count(); i++) {
  31. field_generators_[i].reset(MakeGenerator(descriptor->field(i)));
  32. diff --git a/protoc-c/c_field.h b/protoc-c/c_field.h
  33. index 91f1a03..efd5a29 100644
  34. --- a/protoc-c/c_field.h
  35. +++ b/protoc-c/c_field.h
  36. @@ -117,7 +117,7 @@ class FieldGeneratorMap {
  37. private:
  38. const Descriptor* descriptor_;
  39. - scoped_array<scoped_ptr<FieldGenerator> > field_generators_;
  40. + std::unique_ptr<std::unique_ptr<FieldGenerator>[] > field_generators_;
  41. static FieldGenerator* MakeGenerator(const FieldDescriptor* field);
  42. diff --git a/protoc-c/c_file.cc b/protoc-c/c_file.cc
  43. index 9851768..6dae516 100644
  44. --- a/protoc-c/c_file.cc
  45. +++ b/protoc-c/c_file.cc
  46. @@ -83,13 +83,13 @@ FileGenerator::FileGenerator(const FileDescriptor* file,
  47. const string& dllexport_decl)
  48. : file_(file),
  49. message_generators_(
  50. - new scoped_ptr<MessageGenerator>[file->message_type_count()]),
  51. + new std::unique_ptr<MessageGenerator>[file->message_type_count()]),
  52. enum_generators_(
  53. - new scoped_ptr<EnumGenerator>[file->enum_type_count()]),
  54. + new std::unique_ptr<EnumGenerator>[file->enum_type_count()]),
  55. service_generators_(
  56. - new scoped_ptr<ServiceGenerator>[file->service_count()]),
  57. + new std::unique_ptr<ServiceGenerator>[file->service_count()]),
  58. extension_generators_(
  59. - new scoped_ptr<ExtensionGenerator>[file->extension_count()]) {
  60. + new std::unique_ptr<ExtensionGenerator>[file->extension_count()]) {
  61. for (int i = 0; i < file->message_type_count(); i++) {
  62. message_generators_[i].reset(
  63. diff --git a/protoc-c/c_file.h b/protoc-c/c_file.h
  64. index ed38ce4..e86cc44 100644
  65. --- a/protoc-c/c_file.h
  66. +++ b/protoc-c/c_file.h
  67. @@ -98,10 +98,10 @@ class FileGenerator {
  68. private:
  69. const FileDescriptor* file_;
  70. - scoped_array<scoped_ptr<MessageGenerator> > message_generators_;
  71. - scoped_array<scoped_ptr<EnumGenerator> > enum_generators_;
  72. - scoped_array<scoped_ptr<ServiceGenerator> > service_generators_;
  73. - scoped_array<scoped_ptr<ExtensionGenerator> > extension_generators_;
  74. + std::unique_ptr<std::unique_ptr<MessageGenerator>[] > message_generators_;
  75. + std::unique_ptr<std::unique_ptr<EnumGenerator>[] > enum_generators_;
  76. + std::unique_ptr<std::unique_ptr<ServiceGenerator>[] > service_generators_;
  77. + std::unique_ptr<std::unique_ptr<ExtensionGenerator>[] > extension_generators_;
  78. // E.g. if the package is foo.bar, package_parts_ is {"foo", "bar"}.
  79. vector<string> package_parts_;
  80. diff --git a/protoc-c/c_generator.cc b/protoc-c/c_generator.cc
  81. index a0d0cb6..fe3ad26 100644
  82. --- a/protoc-c/c_generator.cc
  83. +++ b/protoc-c/c_generator.cc
  84. @@ -149,7 +149,7 @@ bool CGenerator::Generate(const FileDescriptor* file,
  85. // Generate header.
  86. {
  87. - scoped_ptr<io::ZeroCopyOutputStream> output(
  88. + std::unique_ptr<io::ZeroCopyOutputStream> output(
  89. output_directory->Open(basename + ".h"));
  90. io::Printer printer(output.get(), '$');
  91. file_generator.GenerateHeader(&printer);
  92. @@ -157,7 +157,7 @@ bool CGenerator::Generate(const FileDescriptor* file,
  93. // Generate cc file.
  94. {
  95. - scoped_ptr<io::ZeroCopyOutputStream> output(
  96. + std::unique_ptr<io::ZeroCopyOutputStream> output(
  97. output_directory->Open(basename + ".c"));
  98. io::Printer printer(output.get(), '$');
  99. file_generator.GenerateSource(&printer);
  100. diff --git a/protoc-c/c_helpers.cc b/protoc-c/c_helpers.cc
  101. index b79b5b0..f2ab448 100644
  102. --- a/protoc-c/c_helpers.cc
  103. +++ b/protoc-c/c_helpers.cc
  104. @@ -559,7 +559,7 @@ static int CEscapeInternal(const char* src, int src_len, char* dest,
  105. }
  106. string CEscape(const string& src) {
  107. const int dest_length = src.size() * 4 + 1; // Maximum possible expansion
  108. - scoped_array<char> dest(new char[dest_length]);
  109. + std::unique_ptr<char[]> dest(new char[dest_length]);
  110. const int len = CEscapeInternal(src.data(), src.size(),
  111. dest.get(), dest_length, false);
  112. GOOGLE_DCHECK_GE(len, 0);
  113. diff --git a/protoc-c/c_message.cc b/protoc-c/c_message.cc
  114. index 6b22c71..85a946e 100755
  115. --- a/protoc-c/c_message.cc
  116. +++ b/protoc-c/c_message.cc
  117. @@ -83,11 +83,11 @@ MessageGenerator::MessageGenerator(const Descriptor* descriptor,
  118. : descriptor_(descriptor),
  119. dllexport_decl_(dllexport_decl),
  120. field_generators_(descriptor),
  121. - nested_generators_(new scoped_ptr<MessageGenerator>[
  122. + nested_generators_(new std::unique_ptr<MessageGenerator>[
  123. descriptor->nested_type_count()]),
  124. - enum_generators_(new scoped_ptr<EnumGenerator>[
  125. + enum_generators_(new std::unique_ptr<EnumGenerator>[
  126. descriptor->enum_type_count()]),
  127. - extension_generators_(new scoped_ptr<ExtensionGenerator>[
  128. + extension_generators_(new std::unique_ptr<ExtensionGenerator>[
  129. descriptor->extension_count()]) {
  130. for (int i = 0; i < descriptor->nested_type_count(); i++) {
  131. diff --git a/protoc-c/c_message.h b/protoc-c/c_message.h
  132. index 8b115d1..63aa97a 100644
  133. --- a/protoc-c/c_message.h
  134. +++ b/protoc-c/c_message.h
  135. @@ -126,9 +126,9 @@ class MessageGenerator {
  136. const Descriptor* descriptor_;
  137. string dllexport_decl_;
  138. FieldGeneratorMap field_generators_;
  139. - scoped_array<scoped_ptr<MessageGenerator> > nested_generators_;
  140. - scoped_array<scoped_ptr<EnumGenerator> > enum_generators_;
  141. - scoped_array<scoped_ptr<ExtensionGenerator> > extension_generators_;
  142. + std::unique_ptr<std::unique_ptr<MessageGenerator>[] > nested_generators_;
  143. + std::unique_ptr<std::unique_ptr<EnumGenerator>[] > enum_generators_;
  144. + std::unique_ptr<std::unique_ptr<ExtensionGenerator>[] > extension_generators_;
  145. GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageGenerator);
  146. };