From ff7bdad231d037802fd457ee4fd65e0291d366d7 Mon Sep 17 00:00:00 2001 From: Bo Yang Date: Sun, 23 Aug 2015 10:45:14 -0700 Subject: Fix bugs on windows --- src/google/protobuf/util/internal/datapiece.h | 14 +++++----- .../util/internal/default_value_objectwriter.h | 2 +- .../protobuf/util/internal/json_objectwriter.cc | 9 +++++-- src/google/protobuf/util/internal/type_info.h | 2 +- src/google/protobuf/util/internal/utility.cc | 2 +- src/google/protobuf/util/json_util.h | 4 +-- src/google/protobuf/util/time_util.h | 31 ++++++++++++++-------- src/google/protobuf/util/type_resolver_util.h | 2 +- 8 files changed, 40 insertions(+), 26 deletions(-) (limited to 'src/google/protobuf/util') diff --git a/src/google/protobuf/util/internal/datapiece.h b/src/google/protobuf/util/internal/datapiece.h index 30947252..2ab3fa88 100644 --- a/src/google/protobuf/util/internal/datapiece.h +++ b/src/google/protobuf/util/internal/datapiece.h @@ -193,13 +193,13 @@ class LIBPROTOBUF_EXPORT DataPiece { // Stored piece of data. union { - const int32 i32_; - const int64 i64_; - const uint32 u32_; - const uint64 u64_; - const double double_; - const float float_; - const bool bool_; + int32 i32_; + int64 i64_; + uint32 u32_; + uint64 u64_; + double double_; + float float_; + bool bool_; StringPiecePod str_; }; }; diff --git a/src/google/protobuf/util/internal/default_value_objectwriter.h b/src/google/protobuf/util/internal/default_value_objectwriter.h index 2468c8d9..d4547601 100644 --- a/src/google/protobuf/util/internal/default_value_objectwriter.h +++ b/src/google/protobuf/util/internal/default_value_objectwriter.h @@ -57,7 +57,7 @@ namespace converter { // ObjectWriter when EndObject() is called on the root object. It also writes // out all non-repeated primitive fields that haven't been explicitly rendered // with their default values (0 for numbers, "" for strings, etc). -class DefaultValueObjectWriter : public ObjectWriter { +class LIBPROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter { public: DefaultValueObjectWriter(TypeResolver* type_resolver, const google::protobuf::Type& type, diff --git a/src/google/protobuf/util/internal/json_objectwriter.cc b/src/google/protobuf/util/internal/json_objectwriter.cc index d88a81f9..f81e3306 100644 --- a/src/google/protobuf/util/internal/json_objectwriter.cc +++ b/src/google/protobuf/util/internal/json_objectwriter.cc @@ -37,6 +37,7 @@ #include #include #include +#include #include namespace google { @@ -115,7 +116,9 @@ JsonObjectWriter* JsonObjectWriter::RenderUint64(StringPiece name, JsonObjectWriter* JsonObjectWriter::RenderDouble(StringPiece name, double value) { - if (isfinite(value)) return RenderSimple(name, SimpleDtoa(value)); + if (google::protobuf::MathLimits::IsFinite(value)) { + return RenderSimple(name, SimpleDtoa(value)); + } // Render quoted with NaN/Infinity-aware DoubleAsString. return RenderString(name, DoubleAsString(value)); @@ -123,7 +126,9 @@ JsonObjectWriter* JsonObjectWriter::RenderDouble(StringPiece name, JsonObjectWriter* JsonObjectWriter::RenderFloat(StringPiece name, float value) { - if (isfinite(value)) return RenderSimple(name, SimpleFtoa(value)); + if (google::protobuf::MathLimits::IsFinite(value)) { + return RenderSimple(name, SimpleFtoa(value)); + } // Render quoted with NaN/Infinity-aware FloatAsString. return RenderString(name, FloatAsString(value)); diff --git a/src/google/protobuf/util/internal/type_info.h b/src/google/protobuf/util/internal/type_info.h index e394e8cf..d8133176 100644 --- a/src/google/protobuf/util/internal/type_info.h +++ b/src/google/protobuf/util/internal/type_info.h @@ -44,7 +44,7 @@ namespace util { namespace converter { // Internal helper class for type resolving. Note that this class is not // thread-safe and should only be accessed in one thread. -class TypeInfo { +class LIBPROTOBUF_EXPORT TypeInfo { public: TypeInfo() {} virtual ~TypeInfo() {} diff --git a/src/google/protobuf/util/internal/utility.cc b/src/google/protobuf/util/internal/utility.cc index 2d63de00..d4ac6f77 100644 --- a/src/google/protobuf/util/internal/utility.cc +++ b/src/google/protobuf/util/internal/utility.cc @@ -311,7 +311,7 @@ string DoubleAsString(double value) { } string FloatAsString(float value) { - if (isfinite(value)) return SimpleFtoa(value); + if (google::protobuf::MathLimits::IsFinite(value)) return SimpleFtoa(value); return DoubleAsString(value); } diff --git a/src/google/protobuf/util/json_util.h b/src/google/protobuf/util/json_util.h index 614564cc..1718bfb5 100644 --- a/src/google/protobuf/util/json_util.h +++ b/src/google/protobuf/util/json_util.h @@ -80,7 +80,7 @@ inline util::Status BinaryToJsonStream( JsonOptions()); } -util::Status BinaryToJsonString( +LIBPROTOBUF_EXPORT util::Status BinaryToJsonString( TypeResolver* resolver, const string& type_url, const string& binary_input, @@ -107,7 +107,7 @@ util::Status JsonToBinaryStream( io::ZeroCopyInputStream* json_input, io::ZeroCopyOutputStream* binary_output); -util::Status JsonToBinaryString( +LIBPROTOBUF_EXPORT util::Status JsonToBinaryString( TypeResolver* resolver, const string& type_url, const string& json_input, diff --git a/src/google/protobuf/util/time_util.h b/src/google/protobuf/util/time_util.h index 11268157..58dbf8e6 100644 --- a/src/google/protobuf/util/time_util.h +++ b/src/google/protobuf/util/time_util.h @@ -31,13 +31,17 @@ #ifndef GOOGLE_PROTOBUF_UTIL_TIME_UTIL_H__ #define GOOGLE_PROTOBUF_UTIL_TIME_UTIL_H__ -#include - #include #include #include +#ifdef _MSC_VER +#include +#else +#include +#endif #include +#include #include namespace google { @@ -85,6 +89,9 @@ class LIBPROTOBUF_EXPORT TimeUtil { static string ToString(const Duration& duration); static bool FromString(const string& value, Duration* timestamp); +#ifdef GetCurrentTime +#undef GetCurrentTime // Visual Studio has macro GetCurrentTime +#endif // Gets the current UTC time. static Timestamp GetCurrentTime(); // Returns the Time representing "1970-01-01 00:00:00". @@ -153,12 +160,12 @@ namespace protobuf { // Overloaded operators for Duration. // // Assignment operators. -Duration& operator+=(Duration& d1, const Duration& d2); // NOLINT -Duration& operator-=(Duration& d1, const Duration& d2); // NOLINT -Duration& operator*=(Duration& d, int64 r); // NOLINT -Duration& operator*=(Duration& d, double r); // NOLINT -Duration& operator/=(Duration& d, int64 r); // NOLINT -Duration& operator/=(Duration& d, double r); // NOLINT +LIBPROTOBUF_EXPORT Duration& operator+=(Duration& d1, const Duration& d2); // NOLINT +LIBPROTOBUF_EXPORT Duration& operator-=(Duration& d1, const Duration& d2); // NOLINT +LIBPROTOBUF_EXPORT Duration& operator*=(Duration& d, int64 r); // NOLINT +LIBPROTOBUF_EXPORT Duration& operator*=(Duration& d, double r); // NOLINT +LIBPROTOBUF_EXPORT Duration& operator/=(Duration& d, int64 r); // NOLINT +LIBPROTOBUF_EXPORT Duration& operator/=(Duration& d, double r); // NOLINT // Overload for other integer types. template Duration& operator*=(Duration& d, T r) { // NOLINT @@ -170,7 +177,7 @@ Duration& operator/=(Duration& d, T r) { // NOLINT int64 x = r; return d /= x; } -Duration& operator%=(Duration& d1, const Duration& d2); // NOLINT +LIBPROTOBUF_EXPORT Duration& operator%=(Duration& d1, const Duration& d2); // NOLINT // Relational operators. inline bool operator<(const Duration& d1, const Duration& d2) { if (d1.seconds() == d2.seconds()) { @@ -221,7 +228,7 @@ template inline Duration operator/(Duration d, T r) { return d /= r; } -int64 operator/(const Duration& d1, const Duration& d2); +LIBPROTOBUF_EXPORT int64 operator/(const Duration& d1, const Duration& d2); inline Duration operator%(const Duration& d1, const Duration& d2) { Duration result = d1; @@ -236,7 +243,9 @@ inline ostream& operator<<(ostream& out, const Duration& d) { // Overloaded operators for Timestamp // // Assignement operators. +LIBPROTOBUF_EXPORT Timestamp& operator+=(Timestamp& t, const Duration& d); // NOLINT +LIBPROTOBUF_EXPORT Timestamp& operator-=(Timestamp& t, const Duration& d); // NOLINT // Relational operators. inline bool operator<(const Timestamp& t1, const Timestamp& t2) { @@ -273,7 +282,7 @@ inline Timestamp operator-(const Timestamp& t, const Duration& d) { Timestamp result = t; return result -= d; } -Duration operator-(const Timestamp& t1, const Timestamp& t2); +LIBPROTOBUF_EXPORT Duration operator-(const Timestamp& t1, const Timestamp& t2); inline ostream& operator<<(ostream& out, const Timestamp& t) { out << google::protobuf::util::TimeUtil::ToString(t); diff --git a/src/google/protobuf/util/type_resolver_util.h b/src/google/protobuf/util/type_resolver_util.h index 00cf9c13..c0ef3c1a 100644 --- a/src/google/protobuf/util/type_resolver_util.h +++ b/src/google/protobuf/util/type_resolver_util.h @@ -42,7 +42,7 @@ class TypeResolver; // Creates a TypeResolver that serves type information in the given descriptor // pool. Caller takes ownership of the returned TypeResolver. -TypeResolver* NewTypeResolverForDescriptorPool( +LIBPROTOBUF_EXPORT TypeResolver* NewTypeResolverForDescriptorPool( const string& url_prefix, const DescriptorPool* pool); } // namespace util -- cgit v1.2.3