[Bf-blender-cvs] [161393805f6] master: Update Google libraries
Sergey Sharybin
noreply at git.blender.org
Thu Mar 22 16:19:38 CET 2018
Commit: 161393805f606089959f04b7656bd33b9b91311f
Author: Sergey Sharybin
Date: Wed Mar 21 17:17:34 2018 +0100
Branches: master
https://developer.blender.org/rB161393805f606089959f04b7656bd33b9b91311f
Update Google libraries
This commit updates:
- gflags 2.2.0 -> 2.2.1
- glog 0.3.4 -> 0.3.4
- gmock 1.7.0 -> 1.8.0
- gtest 1.7.0 -> 1.8.0
===================================================================
M extern/gflags/CMakeLists.txt
M extern/gflags/README.blender
M extern/gflags/src/gflags.cc
R092 extern/gflags/src/config.h extern/gflags/src/gflags/config.h
M extern/gflags/src/gflags/gflags.h
M extern/gflags/src/gflags/gflags_declare.h
M extern/gflags/src/gflags/gflags_gflags.h
M extern/gflags/src/gflags_completions.cc
M extern/gflags/src/gflags_reporting.cc
M extern/gflags/src/mutex.h
M extern/gflags/src/util.h
M extern/gflags/src/windows_port.h
M extern/glog/AUTHORS
M extern/glog/README.blender
M extern/glog/src/config.h
M extern/glog/src/demangle.h
M extern/glog/src/glog/logging.h
M extern/glog/src/glog/raw_logging.h
A extern/glog/src/glog/stl_logging.h
M extern/glog/src/logging.cc
M extern/glog/src/raw_logging.cc
M extern/glog/src/symbolize.cc
M extern/glog/src/utilities.cc
M extern/glog/src/utilities.h
M extern/glog/src/vlog_is_on.cc
M extern/glog/src/windows/config.h
M extern/glog/src/windows/glog/logging.h
A extern/glog/src/windows/glog/stl_logging.h
M extern/glog/src/windows/port.h
A extern/gmock/CHANGES
A extern/gmock/CONTRIBUTORS
M extern/gmock/README.blender
M extern/gtest/README.blender
A extern/gtest/README.md
M extern/gtest/include/gtest/gtest-printers.h
M extern/gtest/include/gtest/gtest.h
M extern/gtest/include/gtest/internal/gtest-internal.h
M extern/gtest/include/gtest/internal/gtest-port.h
===================================================================
diff --git a/extern/gflags/CMakeLists.txt b/extern/gflags/CMakeLists.txt
index 8977fcca457..a473e6ffb40 100644
--- a/extern/gflags/CMakeLists.txt
+++ b/extern/gflags/CMakeLists.txt
@@ -35,7 +35,7 @@ set(SRC
src/gflags_completions.cc
src/gflags_reporting.cc
- src/config.h
+ src/gflags/config.h
src/gflags/gflags_completions.h
src/gflags/gflags_declare.h
src/gflags/gflags_gflags.h
diff --git a/extern/gflags/README.blender b/extern/gflags/README.blender
index b48d4d5d110..1f6f0111776 100644
--- a/extern/gflags/README.blender
+++ b/extern/gflags/README.blender
@@ -1,25 +1,23 @@
Project: Google Flags
URL: https://github.com/gflags/gflags
License: New BSD
-Upstream version: 2.2.0 (9db82895)
+Upstream version: 2.2.1 (46f73f88b18)
Local modifications:
-- Flattened the tree and only included files needed for libmv.
+- Flattened the tree and only included files needed for Blender.
- config.h was originally generated on linux machine with some
further tweaks:
* OS_WINDOWS need to be conditinally defined from inside #ifdef WIN32
- * Same applies yo HAVE_SHLWAPI_H
+ * Same applies to HAVE_SHLWAPI_H
* Disabeld HAVE_FNMATCH_H
-
-- Removed attribute(unused) from FlagSaver.
+ * Forced disabled GFLAGS_IS_A_DLL
- Applied some modifications from fork https://github.com/Nazg-Gul/gflags.git
(see https://github.com/gflags/gflags/pull/129)
-- Avoid attempt of acquiring mutex lock in FlagRegistry::GlobalRegistry when
- doing static flags initialization. See d81dd2d in Blender repository.
-
- Made `google::{anonymous}::FlagValue::ValueSize() const` inlined, so it does
- not trigger strict compiler warning.
\ No newline at end of file
+ not trigger strict compiler warning.
+
+- Did the same for CommandLineFlagParser::ValidateFlags().
diff --git a/extern/gflags/src/gflags.cc b/extern/gflags/src/gflags.cc
index 6dcc5170bcc..60965d3d201 100644
--- a/extern/gflags/src/gflags.cc
+++ b/extern/gflags/src/gflags.cc
@@ -88,7 +88,7 @@
// are, similarly, mostly hooks into the functionality described above.
#include "config.h"
-#include "gflags.h"
+#include "gflags/gflags.h"
#include <assert.h>
#include <ctype.h>
@@ -96,6 +96,7 @@
#if defined(HAVE_FNMATCH_H)
# include <fnmatch.h>
#elif defined(HAVE_SHLWAPI_H)
+# define NO_SHLWAPI_ISOS
# include <shlwapi.h>
#endif
#include <stdarg.h> // For va_list and related operations
@@ -170,12 +171,10 @@ enum DieWhenReporting { DIE, DO_NOT_DIE };
// Report Error and exit if requested.
static void ReportError(DieWhenReporting should_die, const char* format, ...) {
- char error_message[255];
va_list ap;
va_start(ap, format);
- vsnprintf(error_message, sizeof(error_message), format, ap);
+ vfprintf(stderr, format, ap);
va_end(ap);
- fprintf(stderr, "%s", error_message);
fflush(stderr); // should be unnecessary, but cygwin's rxvt buffers stderr
if (should_die == DIE) gflags_exitfunc(1);
}
@@ -191,29 +190,37 @@ static void ReportError(DieWhenReporting should_die, const char* format, ...) {
class CommandLineFlag;
class FlagValue {
public:
- FlagValue(void* valbuf, const char* type, bool transfer_ownership_of_value);
+ enum ValueType {
+ FV_BOOL = 0,
+ FV_INT32 = 1,
+ FV_UINT32 = 2,
+ FV_INT64 = 3,
+ FV_UINT64 = 4,
+ FV_DOUBLE = 5,
+ FV_STRING = 6,
+ FV_MAX_INDEX = 6,
+ };
+
+ template <typename FlagType>
+ FlagValue(FlagType* valbuf, bool transfer_ownership_of_value);
~FlagValue();
bool ParseFrom(const char* spec);
string ToString() const;
+ ValueType Type() const { return static_cast<ValueType>(type_); }
+
private:
friend class CommandLineFlag; // for many things, including Validate()
friend class GFLAGS_NAMESPACE::FlagSaverImpl; // calls New()
friend class FlagRegistry; // checks value_buffer_ for flags_by_ptr_ map
- template <typename T> friend T GetFromEnv(const char*, const char*, T);
+ template <typename T> friend T GetFromEnv(const char*, T);
friend bool TryParseLocked(const CommandLineFlag*, FlagValue*,
const char*, string*); // for New(), CopyFrom()
- enum ValueType {
- FV_BOOL = 0,
- FV_INT32 = 1,
- FV_INT64 = 2,
- FV_UINT64 = 3,
- FV_DOUBLE = 4,
- FV_STRING = 5,
- FV_MAX_INDEX = 5,
- };
+ template <typename FlagType>
+ struct FlagValueTraits;
+
const char* TypeName() const;
bool Equal(const FlagValue& x) const;
FlagValue* New() const; // creates a new one with default value
@@ -226,14 +233,33 @@ class FlagValue {
// (*validate_fn)(bool) for a bool flag).
bool Validate(const char* flagname, ValidateFnProto validate_fn_proto) const;
- void* value_buffer_; // points to the buffer holding our data
- int8 type_; // how to interpret value_
- bool owns_value_; // whether to free value on destruct
+ void* const value_buffer_; // points to the buffer holding our data
+ const int8 type_; // how to interpret value_
+ const bool owns_value_; // whether to free value on destruct
FlagValue(const FlagValue&); // no copying!
void operator=(const FlagValue&);
};
+// Map the given C++ type to a value of the ValueType enum at compile time.
+#define DEFINE_FLAG_TRAITS(type, value) \
+ template <> \
+ struct FlagValue::FlagValueTraits<type> { \
+ static const ValueType kValueType = value; \
+ }
+
+// Define full template specializations of the FlagValueTraits template
+// for all supported flag types.
+DEFINE_FLAG_TRAITS(bool, FV_BOOL);
+DEFINE_FLAG_TRAITS(int32, FV_INT32);
+DEFINE_FLAG_TRAITS(uint32, FV_UINT32);
+DEFINE_FLAG_TRAITS(int64, FV_INT64);
+DEFINE_FLAG_TRAITS(uint64, FV_UINT64);
+DEFINE_FLAG_TRAITS(double, FV_DOUBLE);
+DEFINE_FLAG_TRAITS(std::string, FV_STRING);
+
+#undef DEFINE_FLAG_TRAITS
+
// This could be a templated method of FlagValue, but doing so adds to the
// size of the .o. Since there's no type-safety here anyway, macro is ok.
@@ -241,16 +267,12 @@ class FlagValue {
#define OTHER_VALUE_AS(fv, type) *reinterpret_cast<type*>(fv.value_buffer_)
#define SET_VALUE_AS(type, value) VALUE_AS(type) = (value)
-FlagValue::FlagValue(void* valbuf, const char* type,
+template <typename FlagType>
+FlagValue::FlagValue(FlagType* valbuf,
bool transfer_ownership_of_value)
: value_buffer_(valbuf),
+ type_(FlagValueTraits<FlagType>::kValueType),
owns_value_(transfer_ownership_of_value) {
- for (type_ = 0; type_ <= FV_MAX_INDEX; ++type_) {
- if (!strcmp(type, TypeName())) {
- break;
- }
- }
- assert(type_ <= FV_MAX_INDEX); // Unknown typename
}
FlagValue::~FlagValue() {
@@ -260,6 +282,7 @@ FlagValue::~FlagValue() {
switch (type_) {
case FV_BOOL: delete reinterpret_cast<bool*>(value_buffer_); break;
case FV_INT32: delete reinterpret_cast<int32*>(value_buffer_); break;
+ case FV_UINT32: delete reinterpret_cast<uint32*>(value_buffer_); break;
case FV_INT64: delete reinterpret_cast<int64*>(value_buffer_); break;
case FV_UINT64: delete reinterpret_cast<uint64*>(value_buffer_); break;
case FV_DOUBLE: delete reinterpret_cast<double*>(value_buffer_); break;
@@ -308,6 +331,16 @@ bool FlagValue::ParseFrom(const char* value) {
SET_VALUE_AS(int32, static_cast<int32>(r));
return true;
}
+ case FV_UINT32: {
+ while (*value == ' ') value++;
+ if (*value == '-') return false; // negative number
+ const uint64 r = strtou64(value, &end, base);
+ if (errno || end != value + strlen(value)) return false; // bad parse
+ if (static_cast<uint32>(r) != r) // worked, but number out of range
+ return false;
+ SET_VALUE_AS(uint32, static_cast<uint32>(r));
+ return true;
+ }
case FV_INT64: {
const int64 r = strto64(value, &end, base);
if (errno || end != value + strlen(value)) return false; // bad parse
@@ -343,6 +376,9 @@ string FlagValue::ToString() const {
case FV_INT32:
snprintf(intbuf, sizeof(intbuf), "%" PRId32, VALUE_AS(int32));
return intbuf;
+ case FV_UINT32:
+ snprintf(intbuf, sizeof(intbuf), "%" PRIu32, VALUE_AS(uint32));
+ return intbuf;
case FV_INT64:
snprintf(intbuf, sizeof(intbuf), "%" PRId64, VALUE_AS(int64));
return intbuf;
@@ -369,6 +405,9 @@ bool FlagValue::Validate(const char* flagname,
case FV_INT32:
return reinterpret_cast<bool (*)(const char*, int32)>(
validate_fn_proto)(flagname, VALUE_AS(int32));
+ case FV_UINT32:
+ return reinterpret_cast<bool (*)(const char*, uint32)>(
+ validate_fn_proto)(flagname, VALUE_AS(uint32));
case FV_INT64:
return reinterpret_cast<bool (*)(const char*, int64)>(
validate_fn_proto)(flagname, VALUE_AS(int64));
@@ -391,6 +430,7 @@ const char* FlagValue::TypeName() const {
static const char types[] =
"bool\0xx"
"int32\0x"
+ "uint32\0"
"int64\0x"
"uint64\0"
"double\0"
@@ -409,6 +449,7 @@ bool FlagValue::Equal(const FlagValue& x) const {
switch (type_) {
case FV_BOOL: return VALUE_AS(bool) == OTHER_VALUE_AS(x, bool);
case FV_INT32: return VALUE_AS(int32) == OTHER_VALUE_AS(x, int32);
+ case FV_UINT32: return VALUE_AS(uint32) == OTHER_VALUE_AS(x, uint32);
case FV_INT64: return VALUE_AS(int64) == OTHER_VALUE_AS(x, int64);
case FV_UINT64: return VALUE_AS(uint64) == OTHER_VALUE_AS(x, uint64);
case FV_DOUBLE: return VALUE_AS(double) == OTHER_VALUE_AS(x, double);
@@ -418,14 +459,14 @@ bool FlagValue::Equal(const FlagValue& x) const {
}
FlagValue* FlagValue::New() const {
- const char *type = TypeName();
switch (type_) {
- case FV_BOOL: return new FlagValue(new bool(false), type, true);
- case FV_INT32: return new FlagValue(new int32(0), type, true);
- case FV_INT64: return new FlagValue(new int64(0), type, true);
- case FV_UINT64: return new FlagValue(new uint64(0), type, true);
- case FV_DOUBLE: return new FlagValue(new double(0.0), type, true);
- case FV_STRING: return new FlagValue(new string, type, true);
+ case FV_BOOL: return new FlagValue(new bool(false), true)
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list