Переглянути джерело

change some files to pass MSVC 2013

jieluo@google.com 11 роки тому
батько
коміт
7ee0f3edc7

+ 6 - 0
src/google/protobuf/descriptor.cc

@@ -204,9 +204,11 @@ struct PointerIntegerPairHash {
     return reinterpret_cast<intptr_t>(p.first) * ((1 << 16) - 1) + p.second;
   }
 
+#ifdef _MSC_VER
   // Used only by MSVC and platforms where hash_map is not available.
   static const size_t bucket_size = 4;
   static const size_t min_buckets = 8;
+#endif
   inline bool operator()(const PairType& a, const PairType& b) const {
     return a.first < b.first ||
           (a.first == b.first && a.second < b.second);
@@ -226,6 +228,10 @@ struct PointerStringPairHash {
   }
 
   // Used only by MSVC and platforms where hash_map is not available.
+  // These two lines produce unused warning, but do not delete them
+  // unless hash_map is available on MSVC and platforms.
+  static const size_t bucket_size = 4;
+  static const size_t min_buckets = 8;
   inline bool operator()(const PointerStringPair& a,
                          const PointerStringPair& b) const {
     if (a.first < b.first) return true;

+ 12 - 12
src/google/protobuf/extension_set_unittest.cc

@@ -812,8 +812,8 @@ TEST(ExtensionSetTest, RepeatedFields) {
   ASSERT_EQ(110, SumAllExtensions<double>(
       message, unittest::repeated_double_extension, 0));
 
-  typename RepeatedPtrField< ::std::string>::iterator string_iter;
-  typename RepeatedPtrField< ::std::string>::iterator string_end;
+  RepeatedPtrField< ::std::string>::iterator string_iter;
+  RepeatedPtrField< ::std::string>::iterator string_end;
   for (string_iter = message.MutableRepeatedExtension(
           unittest::repeated_string_extension)->begin(),
        string_end  = message.MutableRepeatedExtension(
@@ -821,8 +821,8 @@ TEST(ExtensionSetTest, RepeatedFields) {
        string_iter != string_end; ++string_iter) {
     *string_iter += "test";
   }
-  typename RepeatedPtrField< ::std::string>::const_iterator string_const_iter;
-  typename RepeatedPtrField< ::std::string>::const_iterator string_const_end;
+  RepeatedPtrField< ::std::string>::const_iterator string_const_iter;
+  RepeatedPtrField< ::std::string>::const_iterator string_const_end;
   for (string_const_iter = message.GetRepeatedExtension(
            unittest::repeated_string_extension).begin(),
        string_const_end  = message.GetRepeatedExtension(
@@ -831,8 +831,8 @@ TEST(ExtensionSetTest, RepeatedFields) {
     ASSERT_TRUE(*string_iter == "testtest");
   }
 
-  typename RepeatedField<unittest::TestAllTypes_NestedEnum>::iterator enum_iter;
-  typename RepeatedField<unittest::TestAllTypes_NestedEnum>::iterator enum_end;
+  RepeatedField<unittest::TestAllTypes_NestedEnum>::iterator enum_iter;
+  RepeatedField<unittest::TestAllTypes_NestedEnum>::iterator enum_end;
   for (enum_iter = message.MutableRepeatedExtension(
            unittest::repeated_nested_enum_extension)->begin(),
        enum_end  = message.MutableRepeatedExtension(
@@ -840,9 +840,9 @@ TEST(ExtensionSetTest, RepeatedFields) {
        enum_iter != enum_end; ++enum_iter) {
     *enum_iter = unittest::TestAllTypes::NestedEnum_MAX;
   }
-  typename RepeatedField<unittest::TestAllTypes_NestedEnum>::const_iterator
+  RepeatedField<unittest::TestAllTypes_NestedEnum>::const_iterator
       enum_const_iter;
-  typename RepeatedField<unittest::TestAllTypes_NestedEnum>::const_iterator
+  RepeatedField<unittest::TestAllTypes_NestedEnum>::const_iterator
       enum_const_end;
   for (enum_const_iter = message.GetRepeatedExtension(
            unittest::repeated_nested_enum_extension).begin(),
@@ -852,9 +852,9 @@ TEST(ExtensionSetTest, RepeatedFields) {
     ASSERT_EQ(*enum_const_iter, unittest::TestAllTypes::NestedEnum_MAX);
   }
 
-  typename RepeatedPtrField<unittest::TestAllTypes_NestedMessage>::iterator
+  RepeatedPtrField<unittest::TestAllTypes_NestedMessage>::iterator
       msg_iter;
-  typename RepeatedPtrField<unittest::TestAllTypes_NestedMessage>::iterator
+  RepeatedPtrField<unittest::TestAllTypes_NestedMessage>::iterator
       msg_end;
   for (msg_iter = message.MutableRepeatedExtension(
            unittest::repeated_nested_message_extension)->begin(),
@@ -863,9 +863,9 @@ TEST(ExtensionSetTest, RepeatedFields) {
        msg_iter != msg_end; ++msg_iter) {
     msg_iter->set_bb(1234);
   }
-  typename RepeatedPtrField<unittest::TestAllTypes_NestedMessage>::
+  RepeatedPtrField<unittest::TestAllTypes_NestedMessage>::
       const_iterator msg_const_iter;
-  typename RepeatedPtrField<unittest::TestAllTypes_NestedMessage>::
+  RepeatedPtrField<unittest::TestAllTypes_NestedMessage>::
       const_iterator msg_const_end;
   for (msg_const_iter = message.GetRepeatedExtension(
            unittest::repeated_nested_message_extension).begin(),

+ 4 - 0
src/google/protobuf/repeated_field.h

@@ -46,6 +46,10 @@
 #ifndef GOOGLE_PROTOBUF_REPEATED_FIELD_H__
 #define GOOGLE_PROTOBUF_REPEATED_FIELD_H__
 
+#ifdef _MSC_VER
+#include <algorithm>
+#endif
+
 #include <string>
 #include <iterator>
 #include <google/protobuf/stubs/common.h>

+ 4 - 0
src/google/protobuf/wire_format_lite_inl.h

@@ -36,6 +36,10 @@
 #ifndef GOOGLE_PROTOBUF_WIRE_FORMAT_LITE_INL_H__
 #define GOOGLE_PROTOBUF_WIRE_FORMAT_LITE_INL_H__
 
+#ifdef _MSC_VER
+#include <algorithm>
+#endif
+
 #include <string>
 #include <google/protobuf/stubs/common.h>
 #include <google/protobuf/message_lite.h>

+ 1 - 0
vsprojects/extract_includes.bat

@@ -35,6 +35,7 @@ copy ..\src\google\protobuf\wire_format_lite_inl.h include\google\protobuf\wire_
 copy ..\src\google\protobuf\io\coded_stream.h include\google\protobuf\io\coded_stream.h
 copy ..\src\google\protobuf\io\gzip_stream.h include\google\protobuf\io\gzip_stream.h
 copy ..\src\google\protobuf\io\printer.h include\google\protobuf\io\printer.h
+copy ..\src\google\protobuf\io\strtod.h include\google\protobuf\io\strtod.h
 copy ..\src\google\protobuf\io\tokenizer.h include\google\protobuf\io\tokenizer.h
 copy ..\src\google\protobuf\io\zero_copy_stream.h include\google\protobuf\io\zero_copy_stream.h
 copy ..\src\google\protobuf\io\zero_copy_stream_impl.h include\google\protobuf\io\zero_copy_stream_impl.h

+ 10 - 2
vsprojects/libprotobuf.vcproj

@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?>
+<?xml version="1.0" encoding="UTF-8"?>
 <VisualStudioProject
 	ProjectType="Visual C++"
 	Version="9.00"
@@ -195,6 +195,10 @@
 				RelativePath="..\src\google\protobuf\io\gzip_stream.h"
 				>
 			</File>
+			<File
+			        RelativePath="..\src\google\protobuf\io\strtod.h"
+				>
+			</File>
 			<File
 				RelativePath="..\src\google\protobuf\stubs\hash.h"
 				>
@@ -204,7 +208,7 @@
 				>
 			</File>
 			<File
-				RelativePath="..\src\google\protobuf\stubs\map-util.h"
+				RelativePath="..\src\google\protobuf\stubs\map_util.h"
 				>
 			</File>
 			<File
@@ -367,6 +371,10 @@
 				RelativePath="..\src\google\protobuf\io\gzip_stream.cc"
 				>
 			</File>
+			<File
+			        RelativePath="..\src\google\protobuf\io\strtod.cc"
+				>
+			</File>
 			<File
 				RelativePath="..\src\google\protobuf\compiler\importer.cc"
 				>

+ 33 - 1
vsprojects/libprotoc.vcproj

@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?>
+<?xml version="1.0" encoding="UTF-8"?>
 <VisualStudioProject
 	ProjectType="Visual C++"
 	Version="9.00"
@@ -247,10 +247,18 @@
 				RelativePath="..\src\google\protobuf\compiler\java\java_generator.h"
 				>
 			</File>
+			<File
+				RelativePath="..\src\google\protobuf\compiler\java\java_generator_factory.h"
+				>
+			</File>
 			<File
 				RelativePath="..\src\google\protobuf\compiler\java\java_helpers.h"
 				>
 			</File>
+			<File
+				RelativePath="..\src\google\protobuf\compiler\java\java_lazy_message_field.h"
+				>
+			</File>
 			<File
 				RelativePath="..\src\google\protobuf\compiler\java\java_message.h"
 				>
@@ -259,6 +267,10 @@
 				RelativePath="..\src\google\protobuf\compiler\java\java_message_field.h"
 				>
 			</File>
+			<File
+				RelativePath="..\src\google\protobuf\compiler\java\java_name_resolver.h"
+				>
+			</File>
 			<File
 				RelativePath="..\src\google\protobuf\compiler\java\java_primitive_field.h"
 				>
@@ -267,6 +279,10 @@
 				RelativePath="..\src\google\protobuf\compiler\java\java_service.h"
 				>
 			</File>
+			<File
+				RelativePath="..\src\google\protobuf\compiler\java\java_shared_code_generator.h"
+				>
+			</File>
 			<File
 				RelativePath="..\src\google\protobuf\compiler\java\java_string_field.h"
 				>
@@ -391,10 +407,18 @@
 				RelativePath="..\src\google\protobuf\compiler\java\java_generator.cc"
 				>
 			</File>
+			<File
+				RelativePath="..\src\google\protobuf\compiler\java\java_generator_factory.cc"
+				>
+			</File>
 			<File
 				RelativePath="..\src\google\protobuf\compiler\java\java_helpers.cc"
 				>
 			</File>
+			<File
+				RelativePath="..\src\google\protobuf\compiler\java\java_lazy_message_field.cc"
+				>
+			</File>
 			<File
 				RelativePath="..\src\google\protobuf\compiler\java\java_message.cc"
 				>
@@ -403,6 +427,10 @@
 				RelativePath="..\src\google\protobuf\compiler\java\java_message_field.cc"
 				>
 			</File>
+			<File
+				RelativePath="..\src\google\protobuf\compiler\java\java_name_resolver.cc"
+				>
+			</File>
 			<File
 				RelativePath="..\src\google\protobuf\compiler\java\java_primitive_field.cc"
 				>
@@ -411,6 +439,10 @@
 				RelativePath="..\src\google\protobuf\compiler\java\java_service.cc"
 				>
 			</File>
+			<File
+				RelativePath="..\src\google\protobuf\compiler\java\java_shared_code_generator.cc"
+				>
+			</File>
 			<File
 				RelativePath="..\src\google\protobuf\compiler\java\java_string_field.cc"
 				>