Commit 5da0b468 authored by Feng Xiao's avatar Feng Xiao

Merge pull request #734 from TeBoring/beta-1

Fix bugs on windows
parents ed91f89f ff7bdad2
...@@ -604,11 +604,16 @@ EXTRA_DIST = $(@DIST_LANG@_EXTRA_DIST) \ ...@@ -604,11 +604,16 @@ EXTRA_DIST = $(@DIST_LANG@_EXTRA_DIST) \
CHANGES.txt \ CHANGES.txt \
update_file_lists.sh \ update_file_lists.sh \
cmake/CMakeLists.txt \ cmake/CMakeLists.txt \
cmake/README.md \
cmake/extract_includes.bat.in \
cmake/install.cmake \
cmake/libprotobuf.cmake \ cmake/libprotobuf.cmake \
cmake/libprotobuf-lite.cmake \ cmake/libprotobuf-lite.cmake \
cmake/libprotoc.cmake \ cmake/libprotoc.cmake \
cmake/protobuf-config-version.cmake.in \
cmake/protobuf-config.cmake.in \
cmake/protobuf-module.cmake.in \
cmake/protoc.cmake \ cmake/protoc.cmake \
cmake/README.md \
cmake/tests.cmake \ cmake/tests.cmake \
editors/README.txt \ editors/README.txt \
editors/proto.vim \ editors/proto.vim \
......
...@@ -36,7 +36,6 @@ set(tests_protos ...@@ -36,7 +36,6 @@ set(tests_protos
google/protobuf/unittest_drop_unknown_fields.proto google/protobuf/unittest_drop_unknown_fields.proto
google/protobuf/unittest_embed_optimize_for.proto google/protobuf/unittest_embed_optimize_for.proto
google/protobuf/unittest_empty.proto google/protobuf/unittest_empty.proto
google/protobuf/unittest_enormous_descriptor.proto
google/protobuf/unittest_import.proto google/protobuf/unittest_import.proto
google/protobuf/unittest_import_public.proto google/protobuf/unittest_import_public.proto
google/protobuf/unittest_lite_imports_nonlite.proto google/protobuf/unittest_lite_imports_nonlite.proto
......
...@@ -32,6 +32,9 @@ ...@@ -32,6 +32,9 @@
#define GOOGLE_PROTOBUF_ARENA_H__ #define GOOGLE_PROTOBUF_ARENA_H__
#include <limits> #include <limits>
#ifdef max
#undef max // Visual Studio defines this macro
#endif
#if __cplusplus >= 201103L #if __cplusplus >= 201103L
#include <google/protobuf/stubs/type_traits.h> #include <google/protobuf/stubs/type_traits.h>
#endif #endif
......
...@@ -55,7 +55,9 @@ ...@@ -55,7 +55,9 @@
#include <google/protobuf/unittest.pb.h> #include <google/protobuf/unittest.pb.h>
#include <google/protobuf/unittest_optimize_for.pb.h> #include <google/protobuf/unittest_optimize_for.pb.h>
#include <google/protobuf/unittest_embed_optimize_for.pb.h> #include <google/protobuf/unittest_embed_optimize_for.pb.h>
#if !defined(_MSC_VER) // Too large for visual studio to compile
#include <google/protobuf/unittest_enormous_descriptor.pb.h> #include <google/protobuf/unittest_enormous_descriptor.pb.h>
#endif
#include <google/protobuf/unittest_no_generic_services.pb.h> #include <google/protobuf/unittest_no_generic_services.pb.h>
#include <google/protobuf/test_util.h> #include <google/protobuf/test_util.h>
#include <google/protobuf/compiler/cpp/cpp_helpers.h> #include <google/protobuf/compiler/cpp/cpp_helpers.h>
...@@ -133,6 +135,7 @@ TEST(GeneratedDescriptorTest, IdenticalDescriptors) { ...@@ -133,6 +135,7 @@ TEST(GeneratedDescriptorTest, IdenticalDescriptors) {
generated_decsriptor_proto.DebugString()); generated_decsriptor_proto.DebugString());
} }
#if !defined(_MSC_VER)
// Test that generated code has proper descriptors: // Test that generated code has proper descriptors:
// Touch a descriptor generated from an enormous message to validate special // Touch a descriptor generated from an enormous message to validate special
// handling for descriptors exceeding the C++ standard's recommended minimum // handling for descriptors exceeding the C++ standard's recommended minimum
...@@ -143,6 +146,7 @@ TEST(GeneratedDescriptorTest, EnormousDescriptor) { ...@@ -143,6 +146,7 @@ TEST(GeneratedDescriptorTest, EnormousDescriptor) {
EXPECT_TRUE(generated_descriptor != NULL); EXPECT_TRUE(generated_descriptor != NULL);
} }
#endif
#endif // !PROTOBUF_TEST_NO_DESCRIPTORS #endif // !PROTOBUF_TEST_NO_DESCRIPTORS
......
...@@ -417,12 +417,12 @@ class LIBPROTOBUF_EXPORT GeneratedMessageReflection : public Reflection { ...@@ -417,12 +417,12 @@ class LIBPROTOBUF_EXPORT GeneratedMessageReflection : public Reflection {
protected: protected:
void* MutableRawRepeatedField( void* MutableRawRepeatedField(
Message* message, const FieldDescriptor* field, FieldDescriptor::CppType, Message* message, const FieldDescriptor* field, FieldDescriptor::CppType,
int ctype, const Descriptor* desc) const override; int ctype, const Descriptor* desc) const;
const void* GetRawRepeatedField( const void* GetRawRepeatedField(
const Message& message, const FieldDescriptor* field, const Message& message, const FieldDescriptor* field,
FieldDescriptor::CppType, int ctype, FieldDescriptor::CppType, int ctype,
const Descriptor* desc) const override; const Descriptor* desc) const;
virtual MessageFactory* GetMessageFactory() const; virtual MessageFactory* GetMessageFactory() const;
......
...@@ -592,7 +592,7 @@ class Map { ...@@ -592,7 +592,7 @@ class Map {
typedef MapAllocator<std::pair<const Key, MapPair<Key, T>*> > Allocator; typedef MapAllocator<std::pair<const Key, MapPair<Key, T>*> > Allocator;
// Iterators // Iterators
class LIBPROTOBUF_EXPORT const_iterator class const_iterator
: public std::iterator<std::forward_iterator_tag, value_type, ptrdiff_t, : public std::iterator<std::forward_iterator_tag, value_type, ptrdiff_t,
const value_type*, const value_type&> { const value_type*, const value_type&> {
typedef typename hash_map<Key, value_type*, hash<Key>, equal_to<Key>, typedef typename hash_map<Key, value_type*, hash<Key>, equal_to<Key>,
...@@ -853,6 +853,29 @@ struct hash<google::protobuf::MapKey> { ...@@ -853,6 +853,29 @@ struct hash<google::protobuf::MapKey> {
return 0; return 0;
} }
} }
bool
operator()(const google::protobuf::MapKey& map_key1,
const google::protobuf::MapKey& map_key2) const {
switch (map_key1.type()) {
#define COMPARE_CPPTYPE(CPPTYPE, CPPTYPE_METHOD) \
case google::protobuf::FieldDescriptor::CPPTYPE_##CPPTYPE: \
return map_key1.Get##CPPTYPE_METHOD##Value() < \
map_key2.Get##CPPTYPE_METHOD##Value();
COMPARE_CPPTYPE(STRING, String)
COMPARE_CPPTYPE(INT64, Int64)
COMPARE_CPPTYPE(INT32, Int32)
COMPARE_CPPTYPE(UINT64, UInt64)
COMPARE_CPPTYPE(UINT32, UInt32)
COMPARE_CPPTYPE(BOOL, Bool)
#undef COMPARE_CPPTYPE
case google::protobuf::FieldDescriptor::CPPTYPE_DOUBLE:
case google::protobuf::FieldDescriptor::CPPTYPE_FLOAT:
case google::protobuf::FieldDescriptor::CPPTYPE_ENUM:
case google::protobuf::FieldDescriptor::CPPTYPE_MESSAGE:
GOOGLE_LOG(FATAL) << "Can't get here.";
return true;
}
}
}; };
GOOGLE_PROTOBUF_HASH_NAMESPACE_DECLARATION_END GOOGLE_PROTOBUF_HASH_NAMESPACE_DECLARATION_END
......
...@@ -292,7 +292,7 @@ class MapEntryLite : public MessageLite { ...@@ -292,7 +292,7 @@ class MapEntryLite : public MessageLite {
// only takes references of given key and value. // only takes references of given key and value.
template <typename K, typename V, WireFormatLite::FieldType k_wire_type, template <typename K, typename V, WireFormatLite::FieldType k_wire_type,
WireFormatLite::FieldType v_wire_type, int default_enum> WireFormatLite::FieldType v_wire_type, int default_enum>
class LIBPROTOBUF_EXPORT MapEntryWrapper class MapEntryWrapper
: public MapEntryLite<K, V, k_wire_type, v_wire_type, default_enum> { : public MapEntryLite<K, V, k_wire_type, v_wire_type, default_enum> {
typedef MapEntryLite<K, V, k_wire_type, v_wire_type, default_enum> Base; typedef MapEntryLite<K, V, k_wire_type, v_wire_type, default_enum> Base;
typedef typename Base::KeyMapEntryAccessorType KeyMapEntryAccessorType; typedef typename Base::KeyMapEntryAccessorType KeyMapEntryAccessorType;
...@@ -326,7 +326,7 @@ class MapEntryLite : public MessageLite { ...@@ -326,7 +326,7 @@ class MapEntryLite : public MessageLite {
// the temporary. // the temporary.
template <typename K, typename V, WireFormatLite::FieldType k_wire_type, template <typename K, typename V, WireFormatLite::FieldType k_wire_type,
WireFormatLite::FieldType v_wire_type, int default_enum> WireFormatLite::FieldType v_wire_type, int default_enum>
class LIBPROTOBUF_EXPORT MapEnumEntryWrapper class MapEnumEntryWrapper
: public MapEntryLite<K, V, k_wire_type, v_wire_type, default_enum> { : public MapEntryLite<K, V, k_wire_type, v_wire_type, default_enum> {
typedef MapEntryLite<K, V, k_wire_type, v_wire_type, default_enum> Base; typedef MapEntryLite<K, V, k_wire_type, v_wire_type, default_enum> Base;
typedef typename Base::KeyMapEntryAccessorType KeyMapEntryAccessorType; typedef typename Base::KeyMapEntryAccessorType KeyMapEntryAccessorType;
......
...@@ -160,7 +160,7 @@ DynamicMapField::DynamicMapField(const Message* default_entry, ...@@ -160,7 +160,7 @@ DynamicMapField::DynamicMapField(const Message* default_entry,
DynamicMapField::~DynamicMapField() { DynamicMapField::~DynamicMapField() {
// DynamicMapField owns map values. Need to delete them before clearing // DynamicMapField owns map values. Need to delete them before clearing
// the map. // the map.
for (typename Map<MapKey, MapValueRef>::iterator iter = map_.begin(); for (Map<MapKey, MapValueRef>::iterator iter = map_.begin();
iter != map_.end(); ++iter) { iter != map_.end(); ++iter) {
iter->second.DeleteData(); iter->second.DeleteData();
} }
...@@ -174,7 +174,7 @@ int DynamicMapField::size() const { ...@@ -174,7 +174,7 @@ int DynamicMapField::size() const {
bool DynamicMapField::ContainsMapKey( bool DynamicMapField::ContainsMapKey(
const MapKey& map_key) const { const MapKey& map_key) const {
const Map<MapKey, MapValueRef>& map = GetMap(); const Map<MapKey, MapValueRef>& map = GetMap();
typename Map<MapKey, MapValueRef>::const_iterator iter = map.find(map_key); Map<MapKey, MapValueRef>::const_iterator iter = map.find(map_key);
return iter != map.end(); return iter != map.end();
} }
...@@ -246,7 +246,7 @@ Map<MapKey, MapValueRef>* DynamicMapField::MutableMap() { ...@@ -246,7 +246,7 @@ Map<MapKey, MapValueRef>* DynamicMapField::MutableMap() {
} }
void DynamicMapField::SetMapIteratorValue(MapIterator* map_iter) const { void DynamicMapField::SetMapIteratorValue(MapIterator* map_iter) const {
typename Map<MapKey, MapValueRef>::const_iterator iter = Map<MapKey, MapValueRef>::const_iterator iter =
TypeDefinedMapFieldBase<MapKey, MapValueRef>::InternalGetIterator( TypeDefinedMapFieldBase<MapKey, MapValueRef>::InternalGetIterator(
map_iter); map_iter);
if (iter == map_.end()) return; if (iter == map_.end()) return;
...@@ -272,7 +272,7 @@ void DynamicMapField::SyncRepeatedFieldWithMapNoLock() const { ...@@ -272,7 +272,7 @@ void DynamicMapField::SyncRepeatedFieldWithMapNoLock() const {
MapFieldBase::repeated_field_->Clear(); MapFieldBase::repeated_field_->Clear();
for (typename Map<MapKey, MapValueRef>::const_iterator it = map_.begin(); for (Map<MapKey, MapValueRef>::const_iterator it = map_.begin();
it != map_.end(); ++it) { it != map_.end(); ++it) {
Message* new_entry = default_entry_->New(); Message* new_entry = default_entry_->New();
MapFieldBase::repeated_field_->AddAllocated(new_entry); MapFieldBase::repeated_field_->AddAllocated(new_entry);
...@@ -350,12 +350,12 @@ void DynamicMapField::SyncMapWithRepeatedFieldNoLock() const { ...@@ -350,12 +350,12 @@ void DynamicMapField::SyncMapWithRepeatedFieldNoLock() const {
default_entry_->GetDescriptor()->FindFieldByName("value"); default_entry_->GetDescriptor()->FindFieldByName("value");
// DynamicMapField owns map values. Need to delete them before clearing // DynamicMapField owns map values. Need to delete them before clearing
// the map. // the map.
for (typename Map<MapKey, MapValueRef>::iterator iter = map->begin(); for (Map<MapKey, MapValueRef>::iterator iter = map->begin();
iter != map->end(); ++iter) { iter != map->end(); ++iter) {
iter->second.DeleteData(); iter->second.DeleteData();
} }
map->clear(); map->clear();
for (typename RepeatedPtrField<Message>::iterator it = for (RepeatedPtrField<Message>::iterator it =
MapFieldBase::repeated_field_->begin(); MapFieldBase::repeated_field_->begin();
it != MapFieldBase::repeated_field_->end(); ++it) { it != MapFieldBase::repeated_field_->end(); ++it) {
MapKey map_key; MapKey map_key;
...@@ -424,7 +424,7 @@ int DynamicMapField::SpaceUsedExcludingSelfNoLock() const { ...@@ -424,7 +424,7 @@ int DynamicMapField::SpaceUsedExcludingSelfNoLock() const {
size += sizeof(map_); size += sizeof(map_);
int map_size = map_.size(); int map_size = map_.size();
if (map_size) { if (map_size) {
typename Map<MapKey, MapValueRef>::const_iterator it = map_.begin(); Map<MapKey, MapValueRef>::const_iterator it = map_.begin();
size += sizeof(it->first) * map_size; size += sizeof(it->first) * map_size;
size += sizeof(it->second) * map_size; size += sizeof(it->second) * map_size;
// If key is string, add the allocated space. // If key is string, add the allocated space.
......
...@@ -153,7 +153,9 @@ void TypeDefinedMapFieldBase<Key, T>::CopyIterator( ...@@ -153,7 +153,9 @@ void TypeDefinedMapFieldBase<Key, T>::CopyIterator(
const MapIterator& that_iter) const { const MapIterator& that_iter) const {
InternalGetIterator(this_iter) = InternalGetIterator(&that_iter); InternalGetIterator(this_iter) = InternalGetIterator(&that_iter);
this_iter->key_.SetType(that_iter.key_.type()); this_iter->key_.SetType(that_iter.key_.type());
this_iter->value_.SetType(that_iter.value_.type()); // MapValueRef::type() fails when containing data is null. However, if
// this_iter points to MapEnd, data can be null.
this_iter->value_.SetType((FieldDescriptor::CppType)that_iter.value_.type_);
SetMapIteratorValue(this_iter); SetMapIteratorValue(this_iter);
} }
......
...@@ -103,8 +103,8 @@ ...@@ -103,8 +103,8 @@
# define GOOGLE_PROTOBUF_HAS_CXX11_HASH # define GOOGLE_PROTOBUF_HAS_CXX11_HASH
# define GOOGLE_PROTOBUF_HASH_COMPARE std::hash_compare # define GOOGLE_PROTOBUF_HASH_COMPARE std::hash_compare
# elif _MSC_VER >= 1500 // Since Visual Studio 2008 # elif _MSC_VER >= 1500 // Since Visual Studio 2008
# define GOOGLE_PROTOBUF_HAS_TR1 # undef GOOGLE_PROTOBUF_HAVE_HASH_MAP
# define GOOGLE_PROTOBUF_HASH_COMPARE stdext::hash_compare # undef GOOGLE_PROTOBUF_HAVE_HASH_SET
# elif _MSC_VER >= 1310 # elif _MSC_VER >= 1310
# define GOOGLE_PROTOBUF_HASH_NAMESPACE stdext # define GOOGLE_PROTOBUF_HASH_NAMESPACE stdext
# include <hash_map> # include <hash_map>
...@@ -143,20 +143,10 @@ ...@@ -143,20 +143,10 @@
# define GOOGLE_PROTOBUF_HASH_SET_CLASS unordered_set # define GOOGLE_PROTOBUF_HASH_SET_CLASS unordered_set
#endif #endif
#ifndef GOOGLE_PROTOBUF_HASH_NAMESPACE
# define GOOGLE_PROTOBUF_HASH_NAMESPACE_DECLARATION_START
# define GOOGLE_PROTOBUF_HASH_NAMESPACE_DECLARATION_END
#elif !defined(GOOGLE_PROTOBUF_HAS_CXX11_HASH) && \
defined(GOOGLE_PROTOBUF_HAS_TR1)
# define GOOGLE_PROTOBUF_HASH_NAMESPACE_DECLARATION_START \ # define GOOGLE_PROTOBUF_HASH_NAMESPACE_DECLARATION_START \
namespace std { \ namespace google { \
namespace tr1 { namespace protobuf {
# define GOOGLE_PROTOBUF_HASH_NAMESPACE_DECLARATION_END }} # define GOOGLE_PROTOBUF_HASH_NAMESPACE_DECLARATION_END }}
#else
# define GOOGLE_PROTOBUF_HASH_NAMESPACE_DECLARATION_START \
namespace GOOGLE_PROTOBUF_HASH_NAMESPACE {
# define GOOGLE_PROTOBUF_HASH_NAMESPACE_DECLARATION_END }
#endif
#undef GOOGLE_PROTOBUF_HAS_CXX11_HASH #undef GOOGLE_PROTOBUF_HAS_CXX11_HASH
#undef GOOGLE_PROTOBUF_HAS_TR1 #undef GOOGLE_PROTOBUF_HAS_TR1
......
...@@ -48,7 +48,7 @@ struct uint128_pod; ...@@ -48,7 +48,7 @@ struct uint128_pod;
#endif #endif
// An unsigned 128-bit integer type. Thread-compatible. // An unsigned 128-bit integer type. Thread-compatible.
class uint128 { class LIBPROTOBUF_EXPORT uint128 {
public: public:
UINT128_CONSTEXPR uint128(); // Sets to 0, but don't trust on this behavior. UINT128_CONSTEXPR uint128(); // Sets to 0, but don't trust on this behavior.
UINT128_CONSTEXPR uint128(uint64 top, uint64 bottom); UINT128_CONSTEXPR uint128(uint64 top, uint64 bottom);
...@@ -84,7 +84,8 @@ class uint128 { ...@@ -84,7 +84,8 @@ class uint128 {
friend uint64 Uint128High64(const uint128& v); friend uint64 Uint128High64(const uint128& v);
// We add "std::" to avoid including all of port.h. // We add "std::" to avoid including all of port.h.
friend std::ostream& operator<<(std::ostream& o, const uint128& b); LIBPROTOBUF_EXPORT friend std::ostream& operator<<(std::ostream& o,
const uint128& b);
private: private:
static void DivModImpl(uint128 dividend, uint128 divisor, static void DivModImpl(uint128 dividend, uint128 divisor,
...@@ -115,10 +116,11 @@ struct uint128_pod { ...@@ -115,10 +116,11 @@ struct uint128_pod {
uint64 lo; uint64 lo;
}; };
extern const uint128_pod kuint128max; LIBPROTOBUF_EXPORT extern const uint128_pod kuint128max;
// allow uint128 to be logged // allow uint128 to be logged
extern std::ostream& operator<<(std::ostream& o, const uint128& b); LIBPROTOBUF_EXPORT extern std::ostream& operator<<(std::ostream& o,
const uint128& b);
// Methods to access low and high pieces of 128-bit value. // Methods to access low and high pieces of 128-bit value.
// Defined externally from uint128 to facilitate conversion // Defined externally from uint128 to facilitate conversion
......
...@@ -45,9 +45,21 @@ bool IsNan(T value) { ...@@ -45,9 +45,21 @@ bool IsNan(T value) {
return false; return false;
} }
template<> template<>
inline bool IsNan(float value) { return isnan(value); } inline bool IsNan(float value) {
#ifdef _MSC_VER
return _isnan(value);
#else
return isnan(value);
#endif
}
template<> template<>
inline bool IsNan(double value) { return isnan(value); } inline bool IsNan(double value) {
#ifdef _MSC_VER
return _isnan(value);
#else
return isnan(value);
#endif
}
template<typename T> template<typename T>
bool AlmostEquals(T a, T b) { bool AlmostEquals(T a, T b) {
......
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
#include <google/protobuf/stubs/status.h> #include <google/protobuf/stubs/status.h>
#include <ostream> #include <ostream>
#include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <string> #include <string>
#include <utility> #include <utility>
......
...@@ -193,13 +193,13 @@ class LIBPROTOBUF_EXPORT DataPiece { ...@@ -193,13 +193,13 @@ class LIBPROTOBUF_EXPORT DataPiece {
// Stored piece of data. // Stored piece of data.
union { union {
const int32 i32_; int32 i32_;
const int64 i64_; int64 i64_;
const uint32 u32_; uint32 u32_;
const uint64 u64_; uint64 u64_;
const double double_; double double_;
const float float_; float float_;
const bool bool_; bool bool_;
StringPiecePod str_; StringPiecePod str_;
}; };
}; };
......
...@@ -57,7 +57,7 @@ namespace converter { ...@@ -57,7 +57,7 @@ namespace converter {
// ObjectWriter when EndObject() is called on the root object. It also writes // ObjectWriter when EndObject() is called on the root object. It also writes
// out all non-repeated primitive fields that haven't been explicitly rendered // out all non-repeated primitive fields that haven't been explicitly rendered
// with their default values (0 for numbers, "" for strings, etc). // with their default values (0 for numbers, "" for strings, etc).
class DefaultValueObjectWriter : public ObjectWriter { class LIBPROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter {
public: public:
DefaultValueObjectWriter(TypeResolver* type_resolver, DefaultValueObjectWriter(TypeResolver* type_resolver,
const google::protobuf::Type& type, const google::protobuf::Type& type,
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include <google/protobuf/stubs/common.h> #include <google/protobuf/stubs/common.h>
#include <google/protobuf/util/internal/utility.h> #include <google/protobuf/util/internal/utility.h>
#include <google/protobuf/util/internal/json_escaping.h> #include <google/protobuf/util/internal/json_escaping.h>
#include <google/protobuf/stubs/mathlimits.h>
#include <google/protobuf/stubs/strutil.h> #include <google/protobuf/stubs/strutil.h>
namespace google { namespace google {
...@@ -115,7 +116,9 @@ JsonObjectWriter* JsonObjectWriter::RenderUint64(StringPiece name, ...@@ -115,7 +116,9 @@ JsonObjectWriter* JsonObjectWriter::RenderUint64(StringPiece name,
JsonObjectWriter* JsonObjectWriter::RenderDouble(StringPiece name, JsonObjectWriter* JsonObjectWriter::RenderDouble(StringPiece name,
double value) { double value) {
if (isfinite(value)) return RenderSimple(name, SimpleDtoa(value)); if (google::protobuf::MathLimits<double>::IsFinite(value)) {
return RenderSimple(name, SimpleDtoa(value));
}
// Render quoted with NaN/Infinity-aware DoubleAsString. // Render quoted with NaN/Infinity-aware DoubleAsString.
return RenderString(name, DoubleAsString(value)); return RenderString(name, DoubleAsString(value));
...@@ -123,7 +126,9 @@ JsonObjectWriter* JsonObjectWriter::RenderDouble(StringPiece name, ...@@ -123,7 +126,9 @@ JsonObjectWriter* JsonObjectWriter::RenderDouble(StringPiece name,
JsonObjectWriter* JsonObjectWriter::RenderFloat(StringPiece name, JsonObjectWriter* JsonObjectWriter::RenderFloat(StringPiece name,
float value) { float value) {
if (isfinite(value)) return RenderSimple(name, SimpleFtoa(value)); if (google::protobuf::MathLimits<float>::IsFinite(value)) {
return RenderSimple(name, SimpleFtoa(value));
}
// Render quoted with NaN/Infinity-aware FloatAsString. // Render quoted with NaN/Infinity-aware FloatAsString.
return RenderString(name, FloatAsString(value)); return RenderString(name, FloatAsString(value));
......
...@@ -44,7 +44,7 @@ namespace util { ...@@ -44,7 +44,7 @@ namespace util {
namespace converter { namespace converter {
// Internal helper class for type resolving. Note that this class is not // Internal helper class for type resolving. Note that this class is not
// thread-safe and should only be accessed in one thread. // thread-safe and should only be accessed in one thread.
class TypeInfo { class LIBPROTOBUF_EXPORT TypeInfo {
public: public:
TypeInfo() {} TypeInfo() {}
virtual ~TypeInfo() {} virtual ~TypeInfo() {}
......
...@@ -307,7 +307,7 @@ string DoubleAsString(double value) { ...@@ -307,7 +307,7 @@ string DoubleAsString(double value) {
} }
string FloatAsString(float value) { string FloatAsString(float value) {
if (isfinite(value)) return SimpleFtoa(value); if (google::protobuf::MathLimits<float>::IsFinite(value)) return SimpleFtoa(value);
return DoubleAsString(value); return DoubleAsString(value);
} }
......
...@@ -80,7 +80,7 @@ inline util::Status BinaryToJsonStream( ...@@ -80,7 +80,7 @@ inline util::Status BinaryToJsonStream(
JsonOptions()); JsonOptions());
} }
util::Status BinaryToJsonString( LIBPROTOBUF_EXPORT util::Status BinaryToJsonString(
TypeResolver* resolver, TypeResolver* resolver,
const string& type_url, const string& type_url,
const string& binary_input, const string& binary_input,
...@@ -107,7 +107,7 @@ util::Status JsonToBinaryStream( ...@@ -107,7 +107,7 @@ util::Status JsonToBinaryStream(
io::ZeroCopyInputStream* json_input, io::ZeroCopyInputStream* json_input,
io::ZeroCopyOutputStream* binary_output); io::ZeroCopyOutputStream* binary_output);
util::Status JsonToBinaryString( LIBPROTOBUF_EXPORT util::Status JsonToBinaryString(
TypeResolver* resolver, TypeResolver* resolver,
const string& type_url, const string& type_url,
const string& json_input, const string& json_input,
......
...@@ -31,13 +31,17 @@ ...@@ -31,13 +31,17 @@
#ifndef GOOGLE_PROTOBUF_UTIL_TIME_UTIL_H__ #ifndef GOOGLE_PROTOBUF_UTIL_TIME_UTIL_H__
#define GOOGLE_PROTOBUF_UTIL_TIME_UTIL_H__ #define GOOGLE_PROTOBUF_UTIL_TIME_UTIL_H__
#include <sys/time.h>
#include <ctime> #include <ctime>
#include <ostream> #include <ostream>
#include <string> #include <string>
#ifdef _MSC_VER
#include <winsock2.h>
#else
#include <sys/time.h>
#endif
#include <google/protobuf/duration.pb.h> #include <google/protobuf/duration.pb.h>
#include <google/protobuf/stubs/port.h>
#include <google/protobuf/timestamp.pb.h> #include <google/protobuf/timestamp.pb.h>
namespace google { namespace google {
...@@ -85,6 +89,9 @@ class LIBPROTOBUF_EXPORT TimeUtil { ...@@ -85,6 +89,9 @@ class LIBPROTOBUF_EXPORT TimeUtil {
static string ToString(const Duration& duration); static string ToString(const Duration& duration);
static bool FromString(const string& value, Duration* timestamp); static bool FromString(const string& value, Duration* timestamp);
#ifdef GetCurrentTime
#undef GetCurrentTime // Visual Studio has macro GetCurrentTime
#endif
// Gets the current UTC time. // Gets the current UTC time.
static Timestamp GetCurrentTime(); static Timestamp GetCurrentTime();
// Returns the Time representing "1970-01-01 00:00:00". // Returns the Time representing "1970-01-01 00:00:00".
...@@ -153,12 +160,12 @@ namespace protobuf { ...@@ -153,12 +160,12 @@ namespace protobuf {
// Overloaded operators for Duration. // Overloaded operators for Duration.
// //
// Assignment operators. // Assignment operators.
Duration& operator+=(Duration& d1, const Duration& d2); // NOLINT LIBPROTOBUF_EXPORT Duration& operator+=(Duration& d1, const Duration& d2); // NOLINT
Duration& operator-=(Duration& d1, const Duration& d2); // NOLINT LIBPROTOBUF_EXPORT Duration& operator-=(Duration& d1, const Duration& d2); // NOLINT
Duration& operator*=(Duration& d, int64 r); // NOLINT LIBPROTOBUF_EXPORT Duration& operator*=(Duration& d, int64 r); // NOLINT
Duration& operator*=(Duration& d, double r); // NOLINT LIBPROTOBUF_EXPORT Duration& operator*=(Duration& d, double r); // NOLINT
Duration& operator/=(Duration& d, int64 r); // NOLINT LIBPROTOBUF_EXPORT Duration& operator/=(Duration& d, int64 r); // NOLINT
Duration& operator/=(Duration& d, double r); // NOLINT LIBPROTOBUF_EXPORT Duration& operator/=(Duration& d, double r); // NOLINT
// Overload for other integer types. // Overload for other integer types.
template <typename T> template <typename T>
Duration& operator*=(Duration& d, T r) { // NOLINT Duration& operator*=(Duration& d, T r) { // NOLINT
...@@ -170,7 +177,7 @@ Duration& operator/=(Duration& d, T r) { // NOLINT ...@@ -170,7 +177,7 @@ Duration& operator/=(Duration& d, T r) { // NOLINT
int64 x = r; int64 x = r;
return d /= x; return d /= x;
} }
Duration& operator%=(Duration& d1, const Duration& d2); // NOLINT LIBPROTOBUF_EXPORT Duration& operator%=(Duration& d1, const Duration& d2); // NOLINT
// Relational operators. // Relational operators.
inline bool operator<(const Duration& d1, const Duration& d2) { inline bool operator<(const Duration& d1, const Duration& d2) {
if (d1.seconds() == d2.seconds()) { if (d1.seconds() == d2.seconds()) {
...@@ -221,7 +228,7 @@ template<typename T> ...@@ -221,7 +228,7 @@ template<typename T>
inline Duration operator/(Duration d, T r) { inline Duration operator/(Duration d, T r) {
return d /= 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) { inline Duration operator%(const Duration& d1, const Duration& d2) {
Duration result = d1; Duration result = d1;
...@@ -236,7 +243,9 @@ inline ostream& operator<<(ostream& out, const Duration& d) { ...@@ -236,7 +243,9 @@ inline ostream& operator<<(ostream& out, const Duration& d) {
// Overloaded operators for Timestamp // Overloaded operators for Timestamp
// //
// Assignement operators. // Assignement operators.
LIBPROTOBUF_EXPORT
Timestamp& operator+=(Timestamp& t, const Duration& d); // NOLINT Timestamp& operator+=(Timestamp& t, const Duration& d); // NOLINT
LIBPROTOBUF_EXPORT
Timestamp& operator-=(Timestamp& t, const Duration& d); // NOLINT Timestamp& operator-=(Timestamp& t, const Duration& d); // NOLINT
// Relational operators. // Relational operators.
inline bool operator<(const Timestamp& t1, const Timestamp& t2) { inline bool operator<(const Timestamp& t1, const Timestamp& t2) {
...@@ -273,7 +282,7 @@ inline Timestamp operator-(const Timestamp& t, const Duration& d) { ...@@ -273,7 +282,7 @@ inline Timestamp operator-(const Timestamp& t, const Duration& d) {
Timestamp result = t; Timestamp result = t;
return result -= d; 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) { inline ostream& operator<<(ostream& out, const Timestamp& t) {
out << google::protobuf::util::TimeUtil::ToString(t); out << google::protobuf::util::TimeUtil::ToString(t);
......
...@@ -42,7 +42,7 @@ class TypeResolver; ...@@ -42,7 +42,7 @@ class TypeResolver;
// Creates a TypeResolver that serves type information in the given descriptor // Creates a TypeResolver that serves type information in the given descriptor
// pool. Caller takes ownership of the returned TypeResolver. // pool. Caller takes ownership of the returned TypeResolver.
TypeResolver* NewTypeResolverForDescriptorPool( LIBPROTOBUF_EXPORT TypeResolver* NewTypeResolverForDescriptorPool(
const string& url_prefix, const DescriptorPool* pool); const string& url_prefix, const DescriptorPool* pool);
} // namespace util } // namespace util
......
...@@ -27,6 +27,10 @@ get_source_files() { ...@@ -27,6 +27,10 @@ get_source_files() {
get_variable_value $@ | grep "cc$" get_variable_value $@ | grep "cc$"
} }
get_proto_files_blacklisted() {
get_proto_files $@ | sed '/^google\/protobuf\/unittest_enormous_descriptor.proto$/d'
}
get_proto_files() { get_proto_files() {
get_variable_value $@ | grep "pb.cc$" | sed "s/pb.cc/proto/" get_variable_value $@ | grep "pb.cc$" | sed "s/pb.cc/proto/"
} }
...@@ -53,6 +57,7 @@ LIBPROTOBUF_SOURCES=$(get_source_files $MAKEFILE libprotobuf_la_SOURCES) ...@@ -53,6 +57,7 @@ LIBPROTOBUF_SOURCES=$(get_source_files $MAKEFILE libprotobuf_la_SOURCES)
LIBPROTOC_SOURCES=$(get_source_files $MAKEFILE libprotoc_la_SOURCES) LIBPROTOC_SOURCES=$(get_source_files $MAKEFILE libprotoc_la_SOURCES)
LITE_PROTOS=$(get_proto_files $MAKEFILE protoc_lite_outputs) LITE_PROTOS=$(get_proto_files $MAKEFILE protoc_lite_outputs)
PROTOS=$(get_proto_files $MAKEFILE protoc_outputs) PROTOS=$(get_proto_files $MAKEFILE protoc_outputs)
PROTOS_BLACKLISTED=$(get_proto_files_blacklisted $MAKEFILE protoc_outputs)
WKT_PROTOS=$(get_variable_value $MAKEFILE nobase_dist_proto_DATA) WKT_PROTOS=$(get_variable_value $MAKEFILE nobase_dist_proto_DATA)
COMMON_TEST_SOURCES=$(get_source_files $MAKEFILE COMMON_TEST_SOURCES) COMMON_TEST_SOURCES=$(get_source_files $MAKEFILE COMMON_TEST_SOURCES)
COMMON_LITE_TEST_SOURCES=$(get_source_files $MAKEFILE COMMON_LITE_TEST_SOURCES) COMMON_LITE_TEST_SOURCES=$(get_source_files $MAKEFILE COMMON_LITE_TEST_SOURCES)
...@@ -112,7 +117,7 @@ set_cmake_value $CMAKE_DIR/libprotobuf-lite.cmake libprotobuf_lite_files $CMAKE_ ...@@ -112,7 +117,7 @@ set_cmake_value $CMAKE_DIR/libprotobuf-lite.cmake libprotobuf_lite_files $CMAKE_
set_cmake_value $CMAKE_DIR/libprotobuf.cmake libprotobuf_files $CMAKE_PREFIX $LIBPROTOBUF_SOURCES set_cmake_value $CMAKE_DIR/libprotobuf.cmake libprotobuf_files $CMAKE_PREFIX $LIBPROTOBUF_SOURCES
set_cmake_value $CMAKE_DIR/libprotoc.cmake libprotoc_files $CMAKE_PREFIX $LIBPROTOC_SOURCES set_cmake_value $CMAKE_DIR/libprotoc.cmake libprotoc_files $CMAKE_PREFIX $LIBPROTOC_SOURCES
set_cmake_value $CMAKE_DIR/tests.cmake lite_test_protos "" $LITE_PROTOS set_cmake_value $CMAKE_DIR/tests.cmake lite_test_protos "" $LITE_PROTOS
set_cmake_value $CMAKE_DIR/tests.cmake tests_protos "" $PROTOS set_cmake_value $CMAKE_DIR/tests.cmake tests_protos "" $PROTOS_BLACKLISTED
set_cmake_value $CMAKE_DIR/tests.cmake common_test_files $CMAKE_PREFIX $COMMON_TEST_SOURCES set_cmake_value $CMAKE_DIR/tests.cmake common_test_files $CMAKE_PREFIX $COMMON_TEST_SOURCES
set_cmake_value $CMAKE_DIR/tests.cmake common_lite_test_files $CMAKE_PREFIX $COMMON_LITE_TEST_SOURCES set_cmake_value $CMAKE_DIR/tests.cmake common_lite_test_files $CMAKE_PREFIX $COMMON_LITE_TEST_SOURCES
set_cmake_value $CMAKE_DIR/tests.cmake tests_files $CMAKE_PREFIX $TEST_SOURCES set_cmake_value $CMAKE_DIR/tests.cmake tests_files $CMAKE_PREFIX $TEST_SOURCES
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment