Merge branch 'master' into blender2.8
This commit is contained in:
2
extern/gflags/CMakeLists.txt
vendored
2
extern/gflags/CMakeLists.txt
vendored
@@ -35,7 +35,7 @@ set(SRC
|
|||||||
src/gflags_completions.cc
|
src/gflags_completions.cc
|
||||||
src/gflags_reporting.cc
|
src/gflags_reporting.cc
|
||||||
|
|
||||||
src/config.h
|
src/gflags/config.h
|
||||||
src/gflags/gflags_completions.h
|
src/gflags/gflags_completions.h
|
||||||
src/gflags/gflags_declare.h
|
src/gflags/gflags_declare.h
|
||||||
src/gflags/gflags_gflags.h
|
src/gflags/gflags_gflags.h
|
||||||
|
|||||||
14
extern/gflags/README.blender
vendored
14
extern/gflags/README.blender
vendored
@@ -1,25 +1,23 @@
|
|||||||
Project: Google Flags
|
Project: Google Flags
|
||||||
URL: https://github.com/gflags/gflags
|
URL: https://github.com/gflags/gflags
|
||||||
License: New BSD
|
License: New BSD
|
||||||
Upstream version: 2.2.0 (9db82895)
|
Upstream version: 2.2.1 (46f73f88b18)
|
||||||
Local modifications:
|
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
|
- config.h was originally generated on linux machine with some
|
||||||
further tweaks:
|
further tweaks:
|
||||||
|
|
||||||
* OS_WINDOWS need to be conditinally defined from inside #ifdef WIN32
|
* 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
|
* Disabeld HAVE_FNMATCH_H
|
||||||
|
* Forced disabled GFLAGS_IS_A_DLL
|
||||||
- Removed attribute(unused) from FlagSaver.
|
|
||||||
|
|
||||||
- Applied some modifications from fork https://github.com/Nazg-Gul/gflags.git
|
- Applied some modifications from fork https://github.com/Nazg-Gul/gflags.git
|
||||||
(see https://github.com/gflags/gflags/pull/129)
|
(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
|
- Made `google::{anonymous}::FlagValue::ValueSize() const` inlined, so it does
|
||||||
not trigger strict compiler warning.
|
not trigger strict compiler warning.
|
||||||
|
|
||||||
|
- Did the same for CommandLineFlagParser::ValidateFlags().
|
||||||
|
|||||||
302
extern/gflags/src/gflags.cc
vendored
302
extern/gflags/src/gflags.cc
vendored
@@ -88,7 +88,7 @@
|
|||||||
// are, similarly, mostly hooks into the functionality described above.
|
// are, similarly, mostly hooks into the functionality described above.
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "gflags.h"
|
#include "gflags/gflags.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
@@ -96,6 +96,7 @@
|
|||||||
#if defined(HAVE_FNMATCH_H)
|
#if defined(HAVE_FNMATCH_H)
|
||||||
# include <fnmatch.h>
|
# include <fnmatch.h>
|
||||||
#elif defined(HAVE_SHLWAPI_H)
|
#elif defined(HAVE_SHLWAPI_H)
|
||||||
|
# define NO_SHLWAPI_ISOS
|
||||||
# include <shlwapi.h>
|
# include <shlwapi.h>
|
||||||
#endif
|
#endif
|
||||||
#include <stdarg.h> // For va_list and related operations
|
#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.
|
// Report Error and exit if requested.
|
||||||
static void ReportError(DieWhenReporting should_die, const char* format, ...) {
|
static void ReportError(DieWhenReporting should_die, const char* format, ...) {
|
||||||
char error_message[255];
|
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
vsnprintf(error_message, sizeof(error_message), format, ap);
|
vfprintf(stderr, format, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
fprintf(stderr, "%s", error_message);
|
|
||||||
fflush(stderr); // should be unnecessary, but cygwin's rxvt buffers stderr
|
fflush(stderr); // should be unnecessary, but cygwin's rxvt buffers stderr
|
||||||
if (should_die == DIE) gflags_exitfunc(1);
|
if (should_die == DIE) gflags_exitfunc(1);
|
||||||
}
|
}
|
||||||
@@ -191,29 +190,37 @@ static void ReportError(DieWhenReporting should_die, const char* format, ...) {
|
|||||||
class CommandLineFlag;
|
class CommandLineFlag;
|
||||||
class FlagValue {
|
class FlagValue {
|
||||||
public:
|
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();
|
~FlagValue();
|
||||||
|
|
||||||
bool ParseFrom(const char* spec);
|
bool ParseFrom(const char* spec);
|
||||||
string ToString() const;
|
string ToString() const;
|
||||||
|
|
||||||
|
ValueType Type() const { return static_cast<ValueType>(type_); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class CommandLineFlag; // for many things, including Validate()
|
friend class CommandLineFlag; // for many things, including Validate()
|
||||||
friend class GFLAGS_NAMESPACE::FlagSaverImpl; // calls New()
|
friend class GFLAGS_NAMESPACE::FlagSaverImpl; // calls New()
|
||||||
friend class FlagRegistry; // checks value_buffer_ for flags_by_ptr_ map
|
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*,
|
friend bool TryParseLocked(const CommandLineFlag*, FlagValue*,
|
||||||
const char*, string*); // for New(), CopyFrom()
|
const char*, string*); // for New(), CopyFrom()
|
||||||
|
|
||||||
enum ValueType {
|
template <typename FlagType>
|
||||||
FV_BOOL = 0,
|
struct FlagValueTraits;
|
||||||
FV_INT32 = 1,
|
|
||||||
FV_INT64 = 2,
|
|
||||||
FV_UINT64 = 3,
|
|
||||||
FV_DOUBLE = 4,
|
|
||||||
FV_STRING = 5,
|
|
||||||
FV_MAX_INDEX = 5,
|
|
||||||
};
|
|
||||||
const char* TypeName() const;
|
const char* TypeName() const;
|
||||||
bool Equal(const FlagValue& x) const;
|
bool Equal(const FlagValue& x) const;
|
||||||
FlagValue* New() const; // creates a new one with default value
|
FlagValue* New() const; // creates a new one with default value
|
||||||
@@ -226,14 +233,33 @@ class FlagValue {
|
|||||||
// (*validate_fn)(bool) for a bool flag).
|
// (*validate_fn)(bool) for a bool flag).
|
||||||
bool Validate(const char* flagname, ValidateFnProto validate_fn_proto) const;
|
bool Validate(const char* flagname, ValidateFnProto validate_fn_proto) const;
|
||||||
|
|
||||||
void* value_buffer_; // points to the buffer holding our data
|
void* const value_buffer_; // points to the buffer holding our data
|
||||||
int8 type_; // how to interpret value_
|
const int8 type_; // how to interpret value_
|
||||||
bool owns_value_; // whether to free value on destruct
|
const bool owns_value_; // whether to free value on destruct
|
||||||
|
|
||||||
FlagValue(const FlagValue&); // no copying!
|
FlagValue(const FlagValue&); // no copying!
|
||||||
void operator=(const FlagValue&);
|
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
|
// 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.
|
// 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 OTHER_VALUE_AS(fv, type) *reinterpret_cast<type*>(fv.value_buffer_)
|
||||||
#define SET_VALUE_AS(type, value) VALUE_AS(type) = (value)
|
#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)
|
bool transfer_ownership_of_value)
|
||||||
: value_buffer_(valbuf),
|
: value_buffer_(valbuf),
|
||||||
|
type_(FlagValueTraits<FlagType>::kValueType),
|
||||||
owns_value_(transfer_ownership_of_value) {
|
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() {
|
FlagValue::~FlagValue() {
|
||||||
@@ -260,6 +282,7 @@ FlagValue::~FlagValue() {
|
|||||||
switch (type_) {
|
switch (type_) {
|
||||||
case FV_BOOL: delete reinterpret_cast<bool*>(value_buffer_); break;
|
case FV_BOOL: delete reinterpret_cast<bool*>(value_buffer_); break;
|
||||||
case FV_INT32: delete reinterpret_cast<int32*>(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_INT64: delete reinterpret_cast<int64*>(value_buffer_); break;
|
||||||
case FV_UINT64: delete reinterpret_cast<uint64*>(value_buffer_); break;
|
case FV_UINT64: delete reinterpret_cast<uint64*>(value_buffer_); break;
|
||||||
case FV_DOUBLE: delete reinterpret_cast<double*>(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));
|
SET_VALUE_AS(int32, static_cast<int32>(r));
|
||||||
return true;
|
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: {
|
case FV_INT64: {
|
||||||
const int64 r = strto64(value, &end, base);
|
const int64 r = strto64(value, &end, base);
|
||||||
if (errno || end != value + strlen(value)) return false; // bad parse
|
if (errno || end != value + strlen(value)) return false; // bad parse
|
||||||
@@ -343,6 +376,9 @@ string FlagValue::ToString() const {
|
|||||||
case FV_INT32:
|
case FV_INT32:
|
||||||
snprintf(intbuf, sizeof(intbuf), "%" PRId32, VALUE_AS(int32));
|
snprintf(intbuf, sizeof(intbuf), "%" PRId32, VALUE_AS(int32));
|
||||||
return intbuf;
|
return intbuf;
|
||||||
|
case FV_UINT32:
|
||||||
|
snprintf(intbuf, sizeof(intbuf), "%" PRIu32, VALUE_AS(uint32));
|
||||||
|
return intbuf;
|
||||||
case FV_INT64:
|
case FV_INT64:
|
||||||
snprintf(intbuf, sizeof(intbuf), "%" PRId64, VALUE_AS(int64));
|
snprintf(intbuf, sizeof(intbuf), "%" PRId64, VALUE_AS(int64));
|
||||||
return intbuf;
|
return intbuf;
|
||||||
@@ -369,6 +405,9 @@ bool FlagValue::Validate(const char* flagname,
|
|||||||
case FV_INT32:
|
case FV_INT32:
|
||||||
return reinterpret_cast<bool (*)(const char*, int32)>(
|
return reinterpret_cast<bool (*)(const char*, int32)>(
|
||||||
validate_fn_proto)(flagname, VALUE_AS(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:
|
case FV_INT64:
|
||||||
return reinterpret_cast<bool (*)(const char*, int64)>(
|
return reinterpret_cast<bool (*)(const char*, int64)>(
|
||||||
validate_fn_proto)(flagname, VALUE_AS(int64));
|
validate_fn_proto)(flagname, VALUE_AS(int64));
|
||||||
@@ -391,6 +430,7 @@ const char* FlagValue::TypeName() const {
|
|||||||
static const char types[] =
|
static const char types[] =
|
||||||
"bool\0xx"
|
"bool\0xx"
|
||||||
"int32\0x"
|
"int32\0x"
|
||||||
|
"uint32\0"
|
||||||
"int64\0x"
|
"int64\0x"
|
||||||
"uint64\0"
|
"uint64\0"
|
||||||
"double\0"
|
"double\0"
|
||||||
@@ -409,6 +449,7 @@ bool FlagValue::Equal(const FlagValue& x) const {
|
|||||||
switch (type_) {
|
switch (type_) {
|
||||||
case FV_BOOL: return VALUE_AS(bool) == OTHER_VALUE_AS(x, bool);
|
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_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_INT64: return VALUE_AS(int64) == OTHER_VALUE_AS(x, int64);
|
||||||
case FV_UINT64: return VALUE_AS(uint64) == OTHER_VALUE_AS(x, uint64);
|
case FV_UINT64: return VALUE_AS(uint64) == OTHER_VALUE_AS(x, uint64);
|
||||||
case FV_DOUBLE: return VALUE_AS(double) == OTHER_VALUE_AS(x, double);
|
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 {
|
FlagValue* FlagValue::New() const {
|
||||||
const char *type = TypeName();
|
|
||||||
switch (type_) {
|
switch (type_) {
|
||||||
case FV_BOOL: return new FlagValue(new bool(false), type, true);
|
case FV_BOOL: return new FlagValue(new bool(false), true);
|
||||||
case FV_INT32: return new FlagValue(new int32(0), type, true);
|
case FV_INT32: return new FlagValue(new int32(0), true);
|
||||||
case FV_INT64: return new FlagValue(new int64(0), type, true);
|
case FV_UINT32: return new FlagValue(new uint32(0), true);
|
||||||
case FV_UINT64: return new FlagValue(new uint64(0), type, true);
|
case FV_INT64: return new FlagValue(new int64(0), true);
|
||||||
case FV_DOUBLE: return new FlagValue(new double(0.0), type, true);
|
case FV_UINT64: return new FlagValue(new uint64(0), true);
|
||||||
case FV_STRING: return new FlagValue(new string, type, true);
|
case FV_DOUBLE: return new FlagValue(new double(0.0), true);
|
||||||
|
case FV_STRING: return new FlagValue(new string, true);
|
||||||
default: assert(false); return NULL; // unknown type
|
default: assert(false); return NULL; // unknown type
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -435,6 +476,7 @@ void FlagValue::CopyFrom(const FlagValue& x) {
|
|||||||
switch (type_) {
|
switch (type_) {
|
||||||
case FV_BOOL: SET_VALUE_AS(bool, OTHER_VALUE_AS(x, bool)); break;
|
case FV_BOOL: SET_VALUE_AS(bool, OTHER_VALUE_AS(x, bool)); break;
|
||||||
case FV_INT32: SET_VALUE_AS(int32, OTHER_VALUE_AS(x, int32)); break;
|
case FV_INT32: SET_VALUE_AS(int32, OTHER_VALUE_AS(x, int32)); break;
|
||||||
|
case FV_UINT32: SET_VALUE_AS(uint32, OTHER_VALUE_AS(x, uint32)); break;
|
||||||
case FV_INT64: SET_VALUE_AS(int64, OTHER_VALUE_AS(x, int64)); break;
|
case FV_INT64: SET_VALUE_AS(int64, OTHER_VALUE_AS(x, int64)); break;
|
||||||
case FV_UINT64: SET_VALUE_AS(uint64, OTHER_VALUE_AS(x, uint64)); break;
|
case FV_UINT64: SET_VALUE_AS(uint64, OTHER_VALUE_AS(x, uint64)); break;
|
||||||
case FV_DOUBLE: SET_VALUE_AS(double, OTHER_VALUE_AS(x, double)); break;
|
case FV_DOUBLE: SET_VALUE_AS(double, OTHER_VALUE_AS(x, double)); break;
|
||||||
@@ -451,6 +493,7 @@ inline int FlagValue::ValueSize() const {
|
|||||||
static const uint8 valuesize[] = {
|
static const uint8 valuesize[] = {
|
||||||
sizeof(bool),
|
sizeof(bool),
|
||||||
sizeof(int32),
|
sizeof(int32),
|
||||||
|
sizeof(uint32),
|
||||||
sizeof(int64),
|
sizeof(int64),
|
||||||
sizeof(uint64),
|
sizeof(uint64),
|
||||||
sizeof(double),
|
sizeof(double),
|
||||||
@@ -487,11 +530,14 @@ class CommandLineFlag {
|
|||||||
ValidateFnProto validate_function() const { return validate_fn_proto_; }
|
ValidateFnProto validate_function() const { return validate_fn_proto_; }
|
||||||
const void* flag_ptr() const { return current_->value_buffer_; }
|
const void* flag_ptr() const { return current_->value_buffer_; }
|
||||||
|
|
||||||
|
FlagValue::ValueType Type() const { return defvalue_->Type(); }
|
||||||
|
|
||||||
void FillCommandLineFlagInfo(struct CommandLineFlagInfo* result);
|
void FillCommandLineFlagInfo(struct CommandLineFlagInfo* result);
|
||||||
|
|
||||||
// If validate_fn_proto_ is non-NULL, calls it on value, returns result.
|
// If validate_fn_proto_ is non-NULL, calls it on value, returns result.
|
||||||
bool Validate(const FlagValue& value) const;
|
bool Validate(const FlagValue& value) const;
|
||||||
bool ValidateCurrent() const { return Validate(*current_); }
|
bool ValidateCurrent() const { return Validate(*current_); }
|
||||||
|
bool Modified() const { return modified_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// for SetFlagLocked() and setting flags_by_ptr_
|
// for SetFlagLocked() and setting flags_by_ptr_
|
||||||
@@ -545,7 +591,7 @@ const char* CommandLineFlag::CleanFileName() const {
|
|||||||
const char* clean_name = filename() + strlen(filename()) - 1;
|
const char* clean_name = filename() + strlen(filename()) - 1;
|
||||||
while ( clean_name > filename() ) {
|
while ( clean_name > filename() ) {
|
||||||
if (*clean_name == PATH_SEPARATOR) {
|
if (*clean_name == PATH_SEPARATOR) {
|
||||||
if (strncmp(clean_name, kRootDir, sizeof(kRootDir)-1) == 0) {
|
if (sizeof(kRootDir) > 1 && strncmp(clean_name, kRootDir, sizeof(kRootDir)-1) == 0) {
|
||||||
clean_name += sizeof(kRootDir)-1; // past root-dir
|
clean_name += sizeof(kRootDir)-1; // past root-dir
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -664,7 +710,7 @@ class FlagRegistry {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
friend class GFLAGS_NAMESPACE::FlagSaverImpl; // reads all the flags in order to copy them
|
friend class GFLAGS_NAMESPACE::FlagSaverImpl; // reads all the flags in order to copy them
|
||||||
friend class CommandLineFlagParser; // for ValidateAllFlags
|
friend class CommandLineFlagParser; // for ValidateUnmodifiedFlags
|
||||||
friend void GFLAGS_NAMESPACE::GetAllFlags(vector<CommandLineFlagInfo>*);
|
friend void GFLAGS_NAMESPACE::GetAllFlags(vector<CommandLineFlagInfo>*);
|
||||||
|
|
||||||
// The map from name to flag, for FindFlagLocked().
|
// The map from name to flag, for FindFlagLocked().
|
||||||
@@ -680,7 +726,6 @@ class FlagRegistry {
|
|||||||
static FlagRegistry* global_registry_; // a singleton registry
|
static FlagRegistry* global_registry_; // a singleton registry
|
||||||
|
|
||||||
Mutex lock_;
|
Mutex lock_;
|
||||||
static Mutex global_registry_lock_;
|
|
||||||
|
|
||||||
static void InitGlobalRegistry();
|
static void InitGlobalRegistry();
|
||||||
|
|
||||||
@@ -725,7 +770,12 @@ void FlagRegistry::RegisterFlag(CommandLineFlag* flag) {
|
|||||||
CommandLineFlag* FlagRegistry::FindFlagLocked(const char* name) {
|
CommandLineFlag* FlagRegistry::FindFlagLocked(const char* name) {
|
||||||
FlagConstIterator i = flags_.find(name);
|
FlagConstIterator i = flags_.find(name);
|
||||||
if (i == flags_.end()) {
|
if (i == flags_.end()) {
|
||||||
return NULL;
|
// If the name has dashes in it, try again after replacing with
|
||||||
|
// underscores.
|
||||||
|
if (strchr(name, '-') == NULL) return NULL;
|
||||||
|
string name_rep = name;
|
||||||
|
std::replace(name_rep.begin(), name_rep.end(), '-', '_');
|
||||||
|
return FindFlagLocked(name_rep.c_str());
|
||||||
} else {
|
} else {
|
||||||
return i->second;
|
return i->second;
|
||||||
}
|
}
|
||||||
@@ -777,7 +827,7 @@ CommandLineFlag* FlagRegistry::SplitArgumentLocked(const char* arg,
|
|||||||
kError, key->c_str());
|
kError, key->c_str());
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (strcmp(flag->type_name(), "bool") != 0) {
|
if (flag->Type() != FlagValue::FV_BOOL) {
|
||||||
// 'x' exists but is not boolean, so we're not in the exception case.
|
// 'x' exists but is not boolean, so we're not in the exception case.
|
||||||
*error_message = StringPrintf(
|
*error_message = StringPrintf(
|
||||||
"%sboolean value (%s) specified for %s command line flag\n",
|
"%sboolean value (%s) specified for %s command line flag\n",
|
||||||
@@ -791,7 +841,7 @@ CommandLineFlag* FlagRegistry::SplitArgumentLocked(const char* arg,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Assign a value if this is a boolean flag
|
// Assign a value if this is a boolean flag
|
||||||
if (*v == NULL && strcmp(flag->type_name(), "bool") == 0) {
|
if (*v == NULL && flag->Type() == FlagValue::FV_BOOL) {
|
||||||
*v = "1"; // the --nox case was already handled, so this is the --x case
|
*v = "1"; // the --nox case was already handled, so this is the --x case
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -878,19 +928,13 @@ bool FlagRegistry::SetFlagLocked(CommandLineFlag* flag,
|
|||||||
|
|
||||||
// Get the singleton FlagRegistry object
|
// Get the singleton FlagRegistry object
|
||||||
FlagRegistry* FlagRegistry::global_registry_ = NULL;
|
FlagRegistry* FlagRegistry::global_registry_ = NULL;
|
||||||
Mutex FlagRegistry::global_registry_lock_(Mutex::LINKER_INITIALIZED);
|
|
||||||
|
|
||||||
FlagRegistry* FlagRegistry::GlobalRegistry() {
|
FlagRegistry* FlagRegistry::GlobalRegistry() {
|
||||||
if (GetArgvSum() != 0) {
|
static Mutex lock(Mutex::LINKER_INITIALIZED);
|
||||||
MutexLock acquire_lock(&global_registry_lock_);
|
MutexLock acquire_lock(&lock);
|
||||||
if (!global_registry_) {
|
if (!global_registry_) {
|
||||||
global_registry_ = new FlagRegistry;
|
global_registry_ = new FlagRegistry;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if (!global_registry_) {
|
|
||||||
global_registry_ = new FlagRegistry;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return global_registry_;
|
return global_registry_;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -926,8 +970,10 @@ class CommandLineFlagParser {
|
|||||||
// In gflags_reporting.cc:HandleCommandLineHelpFlags().
|
// In gflags_reporting.cc:HandleCommandLineHelpFlags().
|
||||||
|
|
||||||
// Stage 3: validate all the commandline flags that have validators
|
// Stage 3: validate all the commandline flags that have validators
|
||||||
// registered.
|
// registered and were not set/modified by ParseNewCommandLineFlags.
|
||||||
|
void ValidateFlags(bool all);
|
||||||
void ValidateAllFlags();
|
void ValidateAllFlags();
|
||||||
|
void ValidateUnmodifiedFlags();
|
||||||
|
|
||||||
// Stage 4: report any errors and return true if any were found.
|
// Stage 4: report any errors and return true if any were found.
|
||||||
bool ReportErrors();
|
bool ReportErrors();
|
||||||
@@ -1014,9 +1060,6 @@ static string ReadFileIntoString(const char* filename) {
|
|||||||
|
|
||||||
uint32 CommandLineFlagParser::ParseNewCommandLineFlags(int* argc, char*** argv,
|
uint32 CommandLineFlagParser::ParseNewCommandLineFlags(int* argc, char*** argv,
|
||||||
bool remove_flags) {
|
bool remove_flags) {
|
||||||
const char *program_name = strrchr((*argv)[0], PATH_SEPARATOR); // nix path
|
|
||||||
program_name = (program_name == NULL ? (*argv)[0] : program_name+1);
|
|
||||||
|
|
||||||
int first_nonopt = *argc; // for non-options moved to the end
|
int first_nonopt = *argc; // for non-options moved to the end
|
||||||
|
|
||||||
registry_->Lock();
|
registry_->Lock();
|
||||||
@@ -1056,7 +1099,7 @@ uint32 CommandLineFlagParser::ParseNewCommandLineFlags(int* argc, char*** argv,
|
|||||||
|
|
||||||
if (value == NULL) {
|
if (value == NULL) {
|
||||||
// Boolean options are always assigned a value by SplitArgumentLocked()
|
// Boolean options are always assigned a value by SplitArgumentLocked()
|
||||||
assert(strcmp(flag->type_name(), "bool") != 0);
|
assert(flag->Type() != FlagValue::FV_BOOL);
|
||||||
if (i+1 >= first_nonopt) {
|
if (i+1 >= first_nonopt) {
|
||||||
// This flag needs a value, but there is nothing available
|
// This flag needs a value, but there is nothing available
|
||||||
error_flags_[key] = (string(kError) + "flag '" + (*argv)[i] + "'"
|
error_flags_[key] = (string(kError) + "flag '" + (*argv)[i] + "'"
|
||||||
@@ -1081,7 +1124,7 @@ uint32 CommandLineFlagParser::ParseNewCommandLineFlags(int* argc, char*** argv,
|
|||||||
// "-lat -30.5" would trigger the warning. The common cases we
|
// "-lat -30.5" would trigger the warning. The common cases we
|
||||||
// want to solve talk about true and false as values.
|
// want to solve talk about true and false as values.
|
||||||
if (value[0] == '-'
|
if (value[0] == '-'
|
||||||
&& strcmp(flag->type_name(), "string") == 0
|
&& flag->Type() == FlagValue::FV_STRING
|
||||||
&& (strstr(flag->help(), "true")
|
&& (strstr(flag->help(), "true")
|
||||||
|| strstr(flag->help(), "false"))) {
|
|| strstr(flag->help(), "false"))) {
|
||||||
LOG(WARNING) << "Did you really mean to set flag '"
|
LOG(WARNING) << "Did you really mean to set flag '"
|
||||||
@@ -1193,22 +1236,34 @@ string CommandLineFlagParser::ProcessSingleOptionLocked(
|
|||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommandLineFlagParser::ValidateAllFlags() {
|
void CommandLineFlagParser::ValidateFlags(bool all) {
|
||||||
FlagRegistryLock frl(registry_);
|
FlagRegistryLock frl(registry_);
|
||||||
for (FlagRegistry::FlagConstIterator i = registry_->flags_.begin();
|
for (FlagRegistry::FlagConstIterator i = registry_->flags_.begin();
|
||||||
i != registry_->flags_.end(); ++i) {
|
i != registry_->flags_.end(); ++i) {
|
||||||
if (!i->second->ValidateCurrent()) {
|
if ((all || !i->second->Modified()) && !i->second->ValidateCurrent()) {
|
||||||
// only set a message if one isn't already there. (If there's
|
// only set a message if one isn't already there. (If there's
|
||||||
// an error message, our job is done, even if it's not exactly
|
// an error message, our job is done, even if it's not exactly
|
||||||
// the same error.)
|
// the same error.)
|
||||||
if (error_flags_[i->second->name()].empty())
|
if (error_flags_[i->second->name()].empty()) {
|
||||||
error_flags_[i->second->name()] =
|
error_flags_[i->second->name()] =
|
||||||
string(kError) + "--" + i->second->name() +
|
string(kError) + "--" + i->second->name() +
|
||||||
" must be set on the commandline"
|
" must be set on the commandline";
|
||||||
" (default value fails validation)\n";
|
if (!i->second->Modified()) {
|
||||||
|
error_flags_[i->second->name()] += " (default value fails validation)";
|
||||||
|
}
|
||||||
|
error_flags_[i->second->name()] += "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void CommandLineFlagParser::ValidateAllFlags() {
|
||||||
|
ValidateFlags(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CommandLineFlagParser::ValidateUnmodifiedFlags() {
|
||||||
|
ValidateFlags(false);
|
||||||
|
}
|
||||||
|
|
||||||
bool CommandLineFlagParser::ReportErrors() {
|
bool CommandLineFlagParser::ReportErrors() {
|
||||||
// error_flags_ indicates errors we saw while parsing.
|
// error_flags_ indicates errors we saw while parsing.
|
||||||
@@ -1261,7 +1316,11 @@ string CommandLineFlagParser::ProcessOptionsFromStringLocked(
|
|||||||
for (; line_end; flagfile_contents = line_end + 1) {
|
for (; line_end; flagfile_contents = line_end + 1) {
|
||||||
while (*flagfile_contents && isspace(*flagfile_contents))
|
while (*flagfile_contents && isspace(*flagfile_contents))
|
||||||
++flagfile_contents;
|
++flagfile_contents;
|
||||||
|
// Windows uses "\r\n"
|
||||||
|
line_end = strchr(flagfile_contents, '\r');
|
||||||
|
if (line_end == NULL)
|
||||||
line_end = strchr(flagfile_contents, '\n');
|
line_end = strchr(flagfile_contents, '\n');
|
||||||
|
|
||||||
size_t len = line_end ? line_end - flagfile_contents
|
size_t len = line_end ? line_end - flagfile_contents
|
||||||
: strlen(flagfile_contents);
|
: strlen(flagfile_contents);
|
||||||
string line(flagfile_contents, len);
|
string line(flagfile_contents, len);
|
||||||
@@ -1341,10 +1400,10 @@ string CommandLineFlagParser::ProcessOptionsFromStringLocked(
|
|||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
T GetFromEnv(const char *varname, const char* type, T dflt) {
|
T GetFromEnv(const char *varname, T dflt) {
|
||||||
std::string valstr;
|
std::string valstr;
|
||||||
if (SafeGetEnv(varname, valstr)) {
|
if (SafeGetEnv(varname, valstr)) {
|
||||||
FlagValue ifv(new T, type, true);
|
FlagValue ifv(new T, true);
|
||||||
if (!ifv.ParseFrom(valstr.c_str())) {
|
if (!ifv.ParseFrom(valstr.c_str())) {
|
||||||
ReportError(DIE, "ERROR: error parsing env variable '%s' with value '%s'\n",
|
ReportError(DIE, "ERROR: error parsing env variable '%s' with value '%s'\n",
|
||||||
varname, valstr.c_str());
|
varname, valstr.c_str());
|
||||||
@@ -1395,22 +1454,48 @@ bool AddFlagValidator(const void* flag_ptr, ValidateFnProto validate_fn_proto) {
|
|||||||
// values in a global destructor.
|
// values in a global destructor.
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
FlagRegisterer::FlagRegisterer(const char* name, const char* type,
|
namespace {
|
||||||
const char* help, const char* filename,
|
void RegisterCommandLineFlag(const char* name,
|
||||||
void* current_storage, void* defvalue_storage) {
|
const char* help,
|
||||||
|
const char* filename,
|
||||||
|
FlagValue* current,
|
||||||
|
FlagValue* defvalue) {
|
||||||
if (help == NULL)
|
if (help == NULL)
|
||||||
help = "";
|
help = "";
|
||||||
// FlagValue expects the type-name to not include any namespace
|
|
||||||
// components, so we get rid of those, if any.
|
|
||||||
if (strchr(type, ':'))
|
|
||||||
type = strrchr(type, ':') + 1;
|
|
||||||
FlagValue* current = new FlagValue(current_storage, type, false);
|
|
||||||
FlagValue* defvalue = new FlagValue(defvalue_storage, type, false);
|
|
||||||
// Importantly, flag_ will never be deleted, so storage is always good.
|
// Importantly, flag_ will never be deleted, so storage is always good.
|
||||||
CommandLineFlag* flag = new CommandLineFlag(name, help, filename,
|
CommandLineFlag* flag =
|
||||||
current, defvalue);
|
new CommandLineFlag(name, help, filename, current, defvalue);
|
||||||
FlagRegistry::GlobalRegistry()->RegisterFlag(flag); // default registry
|
FlagRegistry::GlobalRegistry()->RegisterFlag(flag); // default registry
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename FlagType>
|
||||||
|
FlagRegisterer::FlagRegisterer(const char* name,
|
||||||
|
const char* help,
|
||||||
|
const char* filename,
|
||||||
|
FlagType* current_storage,
|
||||||
|
FlagType* defvalue_storage) {
|
||||||
|
FlagValue* const current = new FlagValue(current_storage, false);
|
||||||
|
FlagValue* const defvalue = new FlagValue(defvalue_storage, false);
|
||||||
|
RegisterCommandLineFlag(name, help, filename, current, defvalue);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Force compiler to generate code for the given template specialization.
|
||||||
|
#define INSTANTIATE_FLAG_REGISTERER_CTOR(type) \
|
||||||
|
template GFLAGS_DLL_DECL FlagRegisterer::FlagRegisterer( \
|
||||||
|
const char* name, const char* help, const char* filename, \
|
||||||
|
type* current_storage, type* defvalue_storage)
|
||||||
|
|
||||||
|
// Do this for all supported flag types.
|
||||||
|
INSTANTIATE_FLAG_REGISTERER_CTOR(bool);
|
||||||
|
INSTANTIATE_FLAG_REGISTERER_CTOR(int32);
|
||||||
|
INSTANTIATE_FLAG_REGISTERER_CTOR(uint32);
|
||||||
|
INSTANTIATE_FLAG_REGISTERER_CTOR(int64);
|
||||||
|
INSTANTIATE_FLAG_REGISTERER_CTOR(uint64);
|
||||||
|
INSTANTIATE_FLAG_REGISTERER_CTOR(double);
|
||||||
|
INSTANTIATE_FLAG_REGISTERER_CTOR(std::string);
|
||||||
|
|
||||||
|
#undef INSTANTIATE_FLAG_REGISTERER_CTOR
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
// GetAllFlags()
|
// GetAllFlags()
|
||||||
@@ -1460,82 +1545,73 @@ void GetAllFlags(vector<CommandLineFlagInfo>* OUTPUT) {
|
|||||||
|
|
||||||
// These values are not protected by a Mutex because they are normally
|
// These values are not protected by a Mutex because they are normally
|
||||||
// set only once during program startup.
|
// set only once during program startup.
|
||||||
static const char* argv0 = "UNKNOWN"; // just the program name
|
static string argv0("UNKNOWN"); // just the program name
|
||||||
static const char* cmdline = ""; // the entire command-line
|
static string cmdline; // the entire command-line
|
||||||
|
static string program_usage;
|
||||||
static vector<string> argvs;
|
static vector<string> argvs;
|
||||||
static uint32 argv_sum = 0;
|
static uint32 argv_sum = 0;
|
||||||
static const char* program_usage = NULL;
|
|
||||||
|
|
||||||
void SetArgv(int argc, const char** argv) {
|
void SetArgv(int argc, const char** argv) {
|
||||||
static bool called_set_argv = false;
|
static bool called_set_argv = false;
|
||||||
if (called_set_argv) // we already have an argv for you
|
if (called_set_argv) return;
|
||||||
return;
|
|
||||||
|
|
||||||
called_set_argv = true;
|
called_set_argv = true;
|
||||||
|
|
||||||
assert(argc > 0); // every program has at least a progname
|
assert(argc > 0); // every program has at least a name
|
||||||
argv0 = strdup(argv[0]); // small memory leak, but fn only called once
|
argv0 = argv[0];
|
||||||
assert(argv0);
|
|
||||||
|
|
||||||
string cmdline_string; // easier than doing strcats
|
cmdline.clear();
|
||||||
for (int i = 0; i < argc; i++) {
|
for (int i = 0; i < argc; i++) {
|
||||||
if (i != 0) {
|
if (i != 0) cmdline += " ";
|
||||||
cmdline_string += " ";
|
cmdline += argv[i];
|
||||||
}
|
|
||||||
cmdline_string += argv[i];
|
|
||||||
argvs.push_back(argv[i]);
|
argvs.push_back(argv[i]);
|
||||||
}
|
}
|
||||||
cmdline = strdup(cmdline_string.c_str()); // another small memory leak
|
|
||||||
assert(cmdline);
|
|
||||||
|
|
||||||
// Compute a simple sum of all the chars in argv
|
// Compute a simple sum of all the chars in argv
|
||||||
for (const char* c = cmdline; *c; c++)
|
argv_sum = 0;
|
||||||
|
for (string::const_iterator c = cmdline.begin(); c != cmdline.end(); ++c) {
|
||||||
argv_sum += *c;
|
argv_sum += *c;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const vector<string>& GetArgvs() { return argvs; }
|
const vector<string>& GetArgvs() { return argvs; }
|
||||||
const char* GetArgv() { return cmdline; }
|
const char* GetArgv() { return cmdline.c_str(); }
|
||||||
const char* GetArgv0() { return argv0; }
|
const char* GetArgv0() { return argv0.c_str(); }
|
||||||
uint32 GetArgvSum() { return argv_sum; }
|
uint32 GetArgvSum() { return argv_sum; }
|
||||||
const char* ProgramInvocationName() { // like the GNU libc fn
|
const char* ProgramInvocationName() { // like the GNU libc fn
|
||||||
return GetArgv0();
|
return GetArgv0();
|
||||||
}
|
}
|
||||||
const char* ProgramInvocationShortName() { // like the GNU libc fn
|
const char* ProgramInvocationShortName() { // like the GNU libc fn
|
||||||
const char* slash = strrchr(argv0, '/');
|
size_t pos = argv0.rfind('/');
|
||||||
#ifdef OS_WINDOWS
|
#ifdef OS_WINDOWS
|
||||||
if (!slash) slash = strrchr(argv0, '\\');
|
if (pos == string::npos) pos = argv0.rfind('\\');
|
||||||
#endif
|
#endif
|
||||||
return slash ? slash + 1 : argv0;
|
return (pos == string::npos ? argv0.c_str() : (argv0.c_str() + pos + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetUsageMessage(const string& usage) {
|
void SetUsageMessage(const string& usage) {
|
||||||
if (program_usage != NULL)
|
program_usage = usage;
|
||||||
ReportError(DIE, "ERROR: SetUsageMessage() called twice\n");
|
|
||||||
program_usage = strdup(usage.c_str()); // small memory leak
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* ProgramUsage() {
|
const char* ProgramUsage() {
|
||||||
if (program_usage) {
|
if (program_usage.empty()) {
|
||||||
return program_usage;
|
|
||||||
}
|
|
||||||
return "Warning: SetUsageMessage() never called";
|
return "Warning: SetUsageMessage() never called";
|
||||||
}
|
}
|
||||||
|
return program_usage.c_str();
|
||||||
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
// SetVersionString()
|
// SetVersionString()
|
||||||
// VersionString()
|
// VersionString()
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
static const char* version_string = NULL;
|
static string version_string;
|
||||||
|
|
||||||
void SetVersionString(const string& version) {
|
void SetVersionString(const string& version) {
|
||||||
if (version_string != NULL)
|
version_string = version;
|
||||||
ReportError(DIE, "ERROR: SetVersionString() called twice\n");
|
|
||||||
version_string = strdup(version.c_str()); // small memory leak
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* VersionString() {
|
const char* VersionString() {
|
||||||
return version_string ? version_string : "";
|
return version_string.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1796,6 +1872,7 @@ bool ReadFromFlagsFile(const string& filename, const char* prog_name,
|
|||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
// BoolFromEnv()
|
// BoolFromEnv()
|
||||||
// Int32FromEnv()
|
// Int32FromEnv()
|
||||||
|
// Uint32FromEnv()
|
||||||
// Int64FromEnv()
|
// Int64FromEnv()
|
||||||
// Uint64FromEnv()
|
// Uint64FromEnv()
|
||||||
// DoubleFromEnv()
|
// DoubleFromEnv()
|
||||||
@@ -1807,19 +1884,22 @@ bool ReadFromFlagsFile(const string& filename, const char* prog_name,
|
|||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
bool BoolFromEnv(const char *v, bool dflt) {
|
bool BoolFromEnv(const char *v, bool dflt) {
|
||||||
return GetFromEnv(v, "bool", dflt);
|
return GetFromEnv(v, dflt);
|
||||||
}
|
}
|
||||||
int32 Int32FromEnv(const char *v, int32 dflt) {
|
int32 Int32FromEnv(const char *v, int32 dflt) {
|
||||||
return GetFromEnv(v, "int32", dflt);
|
return GetFromEnv(v, dflt);
|
||||||
|
}
|
||||||
|
uint32 Uint32FromEnv(const char *v, uint32 dflt) {
|
||||||
|
return GetFromEnv(v, dflt);
|
||||||
}
|
}
|
||||||
int64 Int64FromEnv(const char *v, int64 dflt) {
|
int64 Int64FromEnv(const char *v, int64 dflt) {
|
||||||
return GetFromEnv(v, "int64", dflt);
|
return GetFromEnv(v, dflt);
|
||||||
}
|
}
|
||||||
uint64 Uint64FromEnv(const char *v, uint64 dflt) {
|
uint64 Uint64FromEnv(const char *v, uint64 dflt) {
|
||||||
return GetFromEnv(v, "uint64", dflt);
|
return GetFromEnv(v, dflt);
|
||||||
}
|
}
|
||||||
double DoubleFromEnv(const char *v, double dflt) {
|
double DoubleFromEnv(const char *v, double dflt) {
|
||||||
return GetFromEnv(v, "double", dflt);
|
return GetFromEnv(v, dflt);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
@@ -1855,6 +1935,10 @@ bool RegisterFlagValidator(const int32* flag,
|
|||||||
bool (*validate_fn)(const char*, int32)) {
|
bool (*validate_fn)(const char*, int32)) {
|
||||||
return AddFlagValidator(flag, reinterpret_cast<ValidateFnProto>(validate_fn));
|
return AddFlagValidator(flag, reinterpret_cast<ValidateFnProto>(validate_fn));
|
||||||
}
|
}
|
||||||
|
bool RegisterFlagValidator(const uint32* flag,
|
||||||
|
bool (*validate_fn)(const char*, uint32)) {
|
||||||
|
return AddFlagValidator(flag, reinterpret_cast<ValidateFnProto>(validate_fn));
|
||||||
|
}
|
||||||
bool RegisterFlagValidator(const int64* flag,
|
bool RegisterFlagValidator(const int64* flag,
|
||||||
bool (*validate_fn)(const char*, int64)) {
|
bool (*validate_fn)(const char*, int64)) {
|
||||||
return AddFlagValidator(flag, reinterpret_cast<ValidateFnProto>(validate_fn));
|
return AddFlagValidator(flag, reinterpret_cast<ValidateFnProto>(validate_fn));
|
||||||
@@ -1910,7 +1994,7 @@ static uint32 ParseCommandLineFlagsInternal(int* argc, char*** argv,
|
|||||||
HandleCommandLineHelpFlags(); // may cause us to exit on --help, etc.
|
HandleCommandLineHelpFlags(); // may cause us to exit on --help, etc.
|
||||||
|
|
||||||
// See if any of the unset flags fail their validation checks
|
// See if any of the unset flags fail their validation checks
|
||||||
parser.ValidateAllFlags();
|
parser.ValidateUnmodifiedFlags();
|
||||||
|
|
||||||
if (parser.ReportErrors()) // may cause us to exit on illegal flags
|
if (parser.ReportErrors()) // may cause us to exit on illegal flags
|
||||||
gflags_exitfunc(1);
|
gflags_exitfunc(1);
|
||||||
|
|||||||
@@ -2,11 +2,15 @@
|
|||||||
|
|
||||||
// Note: This header file is only used internally. It is not part of public interface!
|
// Note: This header file is only used internally. It is not part of public interface!
|
||||||
|
|
||||||
|
#ifndef GFLAGS_CONFIG_H_
|
||||||
|
#define GFLAGS_CONFIG_H_
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// System checks
|
// System checks
|
||||||
|
|
||||||
// Define if you build this library for a MS Windows OS.
|
// Define if you build this library for a MS Windows OS.
|
||||||
#ifdef WIN32
|
#ifdef _WIN32
|
||||||
# define OS_WINDOWS
|
# define OS_WINDOWS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -58,19 +62,19 @@
|
|||||||
#define PACKAGE_NAME gflags
|
#define PACKAGE_NAME gflags
|
||||||
|
|
||||||
// Define to the full name and version of this package.
|
// Define to the full name and version of this package.
|
||||||
#define PACKAGE_STRING gflags 2.2.0
|
#define PACKAGE_STRING gflags 2.2.1
|
||||||
|
|
||||||
// Define to the one symbol short name of this package.
|
// Define to the one symbol short name of this package.
|
||||||
#define PACKAGE_TARNAME gflags-2.2.0
|
#define PACKAGE_TARNAME gflags-2.2.1
|
||||||
|
|
||||||
// Define to the version of this package.
|
// Define to the version of this package.
|
||||||
#define PACKAGE_VERSION 2.2.0
|
#define PACKAGE_VERSION 2.2.1
|
||||||
|
|
||||||
// Version number of package.
|
// Version number of package.
|
||||||
#define VERSION PACKAGE_VERSION
|
#define VERSION PACKAGE_VERSION
|
||||||
|
|
||||||
// Define to the address where bug reports for this package should be sent.
|
// Define to the address where bug reports for this package should be sent.
|
||||||
#define PACKAGE_BUGREPORT https://github.com/schuhschuh/gflags/issues
|
#define PACKAGE_BUGREPORT https://github.com/gflags/gflags/issues
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// Path separator
|
// Path separator
|
||||||
@@ -112,3 +116,6 @@
|
|||||||
# endif
|
# endif
|
||||||
# include "windows_port.h"
|
# include "windows_port.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif // GFLAGS_CONFIG_H_
|
||||||
49
extern/gflags/src/gflags/gflags.h
vendored
49
extern/gflags/src/gflags/gflags.h
vendored
@@ -81,12 +81,12 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "gflags_declare.h" // IWYU pragma: export
|
#include "gflags/gflags_declare.h" // IWYU pragma: export
|
||||||
|
|
||||||
|
|
||||||
// We always want to export variables defined in user code
|
// We always want to export variables defined in user code
|
||||||
#ifndef GFLAGS_DLL_DEFINE_FLAG
|
#ifndef GFLAGS_DLL_DEFINE_FLAG
|
||||||
# ifdef _MSC_VER
|
# if GFLAGS_IS_A_DLL && defined(_MSC_VER)
|
||||||
# define GFLAGS_DLL_DEFINE_FLAG __declspec(dllexport)
|
# define GFLAGS_DLL_DEFINE_FLAG __declspec(dllexport)
|
||||||
# else
|
# else
|
||||||
# define GFLAGS_DLL_DEFINE_FLAG
|
# define GFLAGS_DLL_DEFINE_FLAG
|
||||||
@@ -128,6 +128,7 @@ namespace GFLAGS_NAMESPACE {
|
|||||||
// validator is already registered for this flag).
|
// validator is already registered for this flag).
|
||||||
extern GFLAGS_DLL_DECL bool RegisterFlagValidator(const bool* flag, bool (*validate_fn)(const char*, bool));
|
extern GFLAGS_DLL_DECL bool RegisterFlagValidator(const bool* flag, bool (*validate_fn)(const char*, bool));
|
||||||
extern GFLAGS_DLL_DECL bool RegisterFlagValidator(const int32* flag, bool (*validate_fn)(const char*, int32));
|
extern GFLAGS_DLL_DECL bool RegisterFlagValidator(const int32* flag, bool (*validate_fn)(const char*, int32));
|
||||||
|
extern GFLAGS_DLL_DECL bool RegisterFlagValidator(const uint32* flag, bool (*validate_fn)(const char*, uint32));
|
||||||
extern GFLAGS_DLL_DECL bool RegisterFlagValidator(const int64* flag, bool (*validate_fn)(const char*, int64));
|
extern GFLAGS_DLL_DECL bool RegisterFlagValidator(const int64* flag, bool (*validate_fn)(const char*, int64));
|
||||||
extern GFLAGS_DLL_DECL bool RegisterFlagValidator(const uint64* flag, bool (*validate_fn)(const char*, uint64));
|
extern GFLAGS_DLL_DECL bool RegisterFlagValidator(const uint64* flag, bool (*validate_fn)(const char*, uint64));
|
||||||
extern GFLAGS_DLL_DECL bool RegisterFlagValidator(const double* flag, bool (*validate_fn)(const char*, double));
|
extern GFLAGS_DLL_DECL bool RegisterFlagValidator(const double* flag, bool (*validate_fn)(const char*, double));
|
||||||
@@ -284,7 +285,7 @@ class GFLAGS_DLL_DECL FlagSaver {
|
|||||||
|
|
||||||
FlagSaver(const FlagSaver&); // no copying!
|
FlagSaver(const FlagSaver&); // no copying!
|
||||||
void operator=(const FlagSaver&);
|
void operator=(const FlagSaver&);
|
||||||
};
|
}__attribute((unused));
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
// Some deprecated or hopefully-soon-to-be-deprecated functions.
|
// Some deprecated or hopefully-soon-to-be-deprecated functions.
|
||||||
@@ -313,6 +314,7 @@ extern GFLAGS_DLL_DECL bool ReadFromFlagsFile(const std::string& filename, const
|
|||||||
|
|
||||||
extern GFLAGS_DLL_DECL bool BoolFromEnv(const char *varname, bool defval);
|
extern GFLAGS_DLL_DECL bool BoolFromEnv(const char *varname, bool defval);
|
||||||
extern GFLAGS_DLL_DECL int32 Int32FromEnv(const char *varname, int32 defval);
|
extern GFLAGS_DLL_DECL int32 Int32FromEnv(const char *varname, int32 defval);
|
||||||
|
extern GFLAGS_DLL_DECL uint32 Uint32FromEnv(const char *varname, uint32 defval);
|
||||||
extern GFLAGS_DLL_DECL int64 Int64FromEnv(const char *varname, int64 defval);
|
extern GFLAGS_DLL_DECL int64 Int64FromEnv(const char *varname, int64 defval);
|
||||||
extern GFLAGS_DLL_DECL uint64 Uint64FromEnv(const char *varname, uint64 defval);
|
extern GFLAGS_DLL_DECL uint64 Uint64FromEnv(const char *varname, uint64 defval);
|
||||||
extern GFLAGS_DLL_DECL double DoubleFromEnv(const char *varname, double defval);
|
extern GFLAGS_DLL_DECL double DoubleFromEnv(const char *varname, double defval);
|
||||||
@@ -429,9 +431,14 @@ extern GFLAGS_DLL_DECL void ShutDownCommandLineFlags();
|
|||||||
|
|
||||||
class GFLAGS_DLL_DECL FlagRegisterer {
|
class GFLAGS_DLL_DECL FlagRegisterer {
|
||||||
public:
|
public:
|
||||||
FlagRegisterer(const char* name, const char* type,
|
// We instantiate this template ctor for all supported types,
|
||||||
|
// so it is possible to place implementation of the FlagRegisterer ctor in
|
||||||
|
// .cc file.
|
||||||
|
// Calling this constructor with unsupported type will produce linker error.
|
||||||
|
template <typename FlagType>
|
||||||
|
FlagRegisterer(const char* name,
|
||||||
const char* help, const char* filename,
|
const char* help, const char* filename,
|
||||||
void* current_storage, void* defvalue_storage);
|
FlagType* current_storage, FlagType* defvalue_storage);
|
||||||
};
|
};
|
||||||
|
|
||||||
// If your application #defines STRIP_FLAG_HELP to a non-zero value
|
// If your application #defines STRIP_FLAG_HELP to a non-zero value
|
||||||
@@ -473,7 +480,7 @@ extern GFLAGS_DLL_DECL const char kStrippedFlagHelp[];
|
|||||||
GFLAGS_DLL_DEFINE_FLAG type FLAGS_##name = FLAGS_nono##name; \
|
GFLAGS_DLL_DEFINE_FLAG type FLAGS_##name = FLAGS_nono##name; \
|
||||||
type FLAGS_no##name = FLAGS_nono##name; \
|
type FLAGS_no##name = FLAGS_nono##name; \
|
||||||
static GFLAGS_NAMESPACE::FlagRegisterer o_##name( \
|
static GFLAGS_NAMESPACE::FlagRegisterer o_##name( \
|
||||||
#name, #type, MAYBE_STRIPPED_HELP(help), __FILE__, \
|
#name, MAYBE_STRIPPED_HELP(help), __FILE__, \
|
||||||
&FLAGS_##name, &FLAGS_no##name); \
|
&FLAGS_##name, &FLAGS_no##name); \
|
||||||
} \
|
} \
|
||||||
using fL##shorttype::FLAGS_##name
|
using fL##shorttype::FLAGS_##name
|
||||||
@@ -508,6 +515,10 @@ GFLAGS_DLL_DECL bool IsBoolFlag(bool from);
|
|||||||
DEFINE_VARIABLE(GFLAGS_NAMESPACE::int32, I, \
|
DEFINE_VARIABLE(GFLAGS_NAMESPACE::int32, I, \
|
||||||
name, val, txt)
|
name, val, txt)
|
||||||
|
|
||||||
|
#define DEFINE_uint32(name,val, txt) \
|
||||||
|
DEFINE_VARIABLE(GFLAGS_NAMESPACE::uint32, U, \
|
||||||
|
name, val, txt)
|
||||||
|
|
||||||
#define DEFINE_int64(name, val, txt) \
|
#define DEFINE_int64(name, val, txt) \
|
||||||
DEFINE_VARIABLE(GFLAGS_NAMESPACE::int64, I64, \
|
DEFINE_VARIABLE(GFLAGS_NAMESPACE::int64, I64, \
|
||||||
name, val, txt)
|
name, val, txt)
|
||||||
@@ -538,6 +549,26 @@ inline clstring* dont_pass0toDEFINE_string(char *stringspot,
|
|||||||
}
|
}
|
||||||
inline clstring* dont_pass0toDEFINE_string(char *stringspot,
|
inline clstring* dont_pass0toDEFINE_string(char *stringspot,
|
||||||
int value);
|
int value);
|
||||||
|
|
||||||
|
// Auxiliary class used to explicitly call destructor of string objects
|
||||||
|
// allocated using placement new during static program deinitialization.
|
||||||
|
// The destructor MUST be an inline function such that the explicit
|
||||||
|
// destruction occurs in the same compilation unit as the placement new.
|
||||||
|
class StringFlagDestructor {
|
||||||
|
void *current_storage_;
|
||||||
|
void *defvalue_storage_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
StringFlagDestructor(void *current, void *defvalue)
|
||||||
|
: current_storage_(current), defvalue_storage_(defvalue) {}
|
||||||
|
|
||||||
|
~StringFlagDestructor() {
|
||||||
|
reinterpret_cast<clstring*>(current_storage_ )->~clstring();
|
||||||
|
reinterpret_cast<clstring*>(defvalue_storage_)->~clstring();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace fLS
|
} // namespace fLS
|
||||||
|
|
||||||
// We need to define a var named FLAGS_no##name so people don't define
|
// We need to define a var named FLAGS_no##name so people don't define
|
||||||
@@ -550,13 +581,15 @@ inline clstring* dont_pass0toDEFINE_string(char *stringspot,
|
|||||||
#define DEFINE_string(name, val, txt) \
|
#define DEFINE_string(name, val, txt) \
|
||||||
namespace fLS { \
|
namespace fLS { \
|
||||||
using ::fLS::clstring; \
|
using ::fLS::clstring; \
|
||||||
|
using ::fLS::StringFlagDestructor; \
|
||||||
static union { void* align; char s[sizeof(clstring)]; } s_##name[2]; \
|
static union { void* align; char s[sizeof(clstring)]; } s_##name[2]; \
|
||||||
clstring* const FLAGS_no##name = ::fLS:: \
|
clstring* const FLAGS_no##name = ::fLS:: \
|
||||||
dont_pass0toDEFINE_string(s_##name[0].s, \
|
dont_pass0toDEFINE_string(s_##name[0].s, \
|
||||||
val); \
|
val); \
|
||||||
static GFLAGS_NAMESPACE::FlagRegisterer o_##name( \
|
static GFLAGS_NAMESPACE::FlagRegisterer o_##name( \
|
||||||
#name, "string", MAYBE_STRIPPED_HELP(txt), __FILE__, \
|
#name, MAYBE_STRIPPED_HELP(txt), __FILE__, \
|
||||||
s_##name[0].s, new (s_##name[1].s) clstring(*FLAGS_no##name)); \
|
FLAGS_no##name, new (s_##name[1].s) clstring(*FLAGS_no##name)); \
|
||||||
|
static StringFlagDestructor d_##name(s_##name[0].s, s_##name[1].s); \
|
||||||
extern GFLAGS_DLL_DEFINE_FLAG clstring& FLAGS_##name; \
|
extern GFLAGS_DLL_DEFINE_FLAG clstring& FLAGS_##name; \
|
||||||
using fLS::FLAGS_##name; \
|
using fLS::FLAGS_##name; \
|
||||||
clstring& FLAGS_##name = *FLAGS_no##name; \
|
clstring& FLAGS_##name = *FLAGS_no##name; \
|
||||||
|
|||||||
20
extern/gflags/src/gflags/gflags_declare.h
vendored
20
extern/gflags/src/gflags/gflags_declare.h
vendored
@@ -45,18 +45,27 @@
|
|||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// Windows DLL import/export.
|
// Windows DLL import/export.
|
||||||
|
|
||||||
// We always want to import the symbols of the gflags library
|
// Whether gflags library is a DLL.
|
||||||
|
//
|
||||||
|
// Set to 1 by default when the shared gflags library was built on Windows.
|
||||||
|
// Must be overwritten when this header file is used with the optionally also
|
||||||
|
// built static library instead; set by CMake's INTERFACE_COMPILE_DEFINITIONS.
|
||||||
|
#ifndef GFLAGS_IS_A_DLL
|
||||||
|
# define GFLAGS_IS_A_DLL 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// We always want to import the symbols of the gflags library.
|
||||||
#ifndef GFLAGS_DLL_DECL
|
#ifndef GFLAGS_DLL_DECL
|
||||||
# if 1 && defined(_MSC_VER)
|
# if GFLAGS_IS_A_DLL && defined(_MSC_VER)
|
||||||
# define GFLAGS_DLL_DECL __declspec(dllimport)
|
# define GFLAGS_DLL_DECL __declspec(dllimport)
|
||||||
# else
|
# else
|
||||||
# define GFLAGS_DLL_DECL
|
# define GFLAGS_DLL_DECL
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// We always want to import variables declared in user code
|
// We always want to import variables declared in user code.
|
||||||
#ifndef GFLAGS_DLL_DECLARE_FLAG
|
#ifndef GFLAGS_DLL_DECLARE_FLAG
|
||||||
# ifdef _MSC_VER
|
# if GFLAGS_IS_A_DLL && defined(_MSC_VER)
|
||||||
# define GFLAGS_DLL_DECLARE_FLAG __declspec(dllimport)
|
# define GFLAGS_DLL_DECLARE_FLAG __declspec(dllimport)
|
||||||
# else
|
# else
|
||||||
# define GFLAGS_DLL_DECLARE_FLAG
|
# define GFLAGS_DLL_DECLARE_FLAG
|
||||||
@@ -120,6 +129,9 @@ typedef std::string clstring;
|
|||||||
#define DECLARE_int32(name) \
|
#define DECLARE_int32(name) \
|
||||||
DECLARE_VARIABLE(::GFLAGS_NAMESPACE::int32, I, name)
|
DECLARE_VARIABLE(::GFLAGS_NAMESPACE::int32, I, name)
|
||||||
|
|
||||||
|
#define DECLARE_uint32(name) \
|
||||||
|
DECLARE_VARIABLE(::GFLAGS_NAMESPACE::uint32, U, name)
|
||||||
|
|
||||||
#define DECLARE_int64(name) \
|
#define DECLARE_int64(name) \
|
||||||
DECLARE_VARIABLE(::GFLAGS_NAMESPACE::int64, I64, name)
|
DECLARE_VARIABLE(::GFLAGS_NAMESPACE::int64, I64, name)
|
||||||
|
|
||||||
|
|||||||
1
extern/gflags/src/gflags/gflags_gflags.h
vendored
1
extern/gflags/src/gflags/gflags_gflags.h
vendored
@@ -77,6 +77,7 @@ using GFLAGS_NAMESPACE::AppendFlagsIntoFile;
|
|||||||
using GFLAGS_NAMESPACE::ReadFromFlagsFile;
|
using GFLAGS_NAMESPACE::ReadFromFlagsFile;
|
||||||
using GFLAGS_NAMESPACE::BoolFromEnv;
|
using GFLAGS_NAMESPACE::BoolFromEnv;
|
||||||
using GFLAGS_NAMESPACE::Int32FromEnv;
|
using GFLAGS_NAMESPACE::Int32FromEnv;
|
||||||
|
using GFLAGS_NAMESPACE::Uint32FromEnv;
|
||||||
using GFLAGS_NAMESPACE::Int64FromEnv;
|
using GFLAGS_NAMESPACE::Int64FromEnv;
|
||||||
using GFLAGS_NAMESPACE::Uint64FromEnv;
|
using GFLAGS_NAMESPACE::Uint64FromEnv;
|
||||||
using GFLAGS_NAMESPACE::DoubleFromEnv;
|
using GFLAGS_NAMESPACE::DoubleFromEnv;
|
||||||
|
|||||||
15
extern/gflags/src/gflags_completions.cc
vendored
15
extern/gflags/src/gflags_completions.cc
vendored
@@ -46,11 +46,6 @@
|
|||||||
// 5a) Force bash to place most-relevent groups at the top of the list
|
// 5a) Force bash to place most-relevent groups at the top of the list
|
||||||
// 5b) Trim most flag's descriptions to fit on a single terminal line
|
// 5b) Trim most flag's descriptions to fit on a single terminal line
|
||||||
|
|
||||||
|
|
||||||
#include "gflags_completions.h"
|
|
||||||
|
|
||||||
#include "config.h"
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h> // for strlen
|
#include <string.h> // for strlen
|
||||||
@@ -60,7 +55,11 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "gflags.h"
|
#include "gflags_completions.h"
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
#include "gflags/gflags.h"
|
||||||
|
#include "gflags/gflags_completions.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
using std::set;
|
using std::set;
|
||||||
@@ -122,7 +121,7 @@ static void CategorizeAllMatchingFlags(
|
|||||||
NotableFlags *notable_flags);
|
NotableFlags *notable_flags);
|
||||||
|
|
||||||
static void TryFindModuleAndPackageDir(
|
static void TryFindModuleAndPackageDir(
|
||||||
const vector<CommandLineFlagInfo> all_flags,
|
const vector<CommandLineFlagInfo> &all_flags,
|
||||||
string *module,
|
string *module,
|
||||||
string *package_dir);
|
string *package_dir);
|
||||||
|
|
||||||
@@ -472,7 +471,7 @@ static void PushNameWithSuffix(vector<string>* suffixes, const char* suffix) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void TryFindModuleAndPackageDir(
|
static void TryFindModuleAndPackageDir(
|
||||||
const vector<CommandLineFlagInfo> all_flags,
|
const vector<CommandLineFlagInfo> &all_flags,
|
||||||
string *module,
|
string *module,
|
||||||
string *package_dir) {
|
string *package_dir) {
|
||||||
module->clear();
|
module->clear();
|
||||||
|
|||||||
7
extern/gflags/src/gflags_reporting.cc
vendored
7
extern/gflags/src/gflags_reporting.cc
vendored
@@ -56,8 +56,8 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "gflags.h"
|
#include "gflags/gflags.h"
|
||||||
#include "gflags_completions.h"
|
#include "gflags/gflags_completions.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -126,7 +126,8 @@ string DescribeOneFlag(const CommandLineFlagInfo& flag) {
|
|||||||
string final_string = "";
|
string final_string = "";
|
||||||
int chars_in_line = 0; // how many chars in current line so far?
|
int chars_in_line = 0; // how many chars in current line so far?
|
||||||
while (1) {
|
while (1) {
|
||||||
assert(chars_left == strlen(c_string)); // Unless there's a \0 in there?
|
assert(static_cast<size_t>(chars_left)
|
||||||
|
== strlen(c_string)); // Unless there's a \0 in there?
|
||||||
const char* newline = strchr(c_string, '\n');
|
const char* newline = strchr(c_string, '\n');
|
||||||
if (newline == NULL && chars_in_line+chars_left < kLineLength) {
|
if (newline == NULL && chars_in_line+chars_left < kLineLength) {
|
||||||
// The whole remainder of the string fits on this line
|
// The whole remainder of the string fits on this line
|
||||||
|
|||||||
6
extern/gflags/src/mutex.h
vendored
6
extern/gflags/src/mutex.h
vendored
@@ -106,7 +106,7 @@
|
|||||||
#ifndef GFLAGS_MUTEX_H_
|
#ifndef GFLAGS_MUTEX_H_
|
||||||
#define GFLAGS_MUTEX_H_
|
#define GFLAGS_MUTEX_H_
|
||||||
|
|
||||||
#include "gflags_declare.h" // to figure out pthreads support
|
#include "gflags/gflags_declare.h" // to figure out pthreads support
|
||||||
|
|
||||||
#if defined(NO_THREADS)
|
#if defined(NO_THREADS)
|
||||||
typedef int MutexType; // to keep a lock-count
|
typedef int MutexType; // to keep a lock-count
|
||||||
@@ -166,7 +166,7 @@ class Mutex {
|
|||||||
// It inhibits work being done by the destructor, which makes it
|
// It inhibits work being done by the destructor, which makes it
|
||||||
// safer for code that tries to acqiure this mutex in their global
|
// safer for code that tries to acqiure this mutex in their global
|
||||||
// destructor.
|
// destructor.
|
||||||
inline Mutex(LinkerInitialized);
|
explicit inline Mutex(LinkerInitialized);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
inline ~Mutex();
|
inline ~Mutex();
|
||||||
@@ -197,7 +197,7 @@ class Mutex {
|
|||||||
inline void SetIsSafe() { is_safe_ = true; }
|
inline void SetIsSafe() { is_safe_ = true; }
|
||||||
|
|
||||||
// Catch the error of writing Mutex when intending MutexLock.
|
// Catch the error of writing Mutex when intending MutexLock.
|
||||||
Mutex(Mutex* /*ignored*/) {}
|
explicit Mutex(Mutex* /*ignored*/) {}
|
||||||
// Disallow "evil" constructors
|
// Disallow "evil" constructors
|
||||||
Mutex(const Mutex&);
|
Mutex(const Mutex&);
|
||||||
void operator=(const Mutex&);
|
void operator=(const Mutex&);
|
||||||
|
|||||||
1
extern/gflags/src/util.h
vendored
1
extern/gflags/src/util.h
vendored
@@ -37,7 +37,6 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <config.h>
|
|
||||||
#ifdef HAVE_INTTYPES_H
|
#ifdef HAVE_INTTYPES_H
|
||||||
# include <inttypes.h>
|
# include <inttypes.h>
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
6
extern/gflags/src/windows_port.h
vendored
6
extern/gflags/src/windows_port.h
vendored
@@ -69,10 +69,8 @@ extern GFLAGS_DLL_DECL int snprintf(char *str, size_t size,
|
|||||||
extern int GFLAGS_DLL_DECL safe_vsnprintf(char *str, size_t size,
|
extern int GFLAGS_DLL_DECL safe_vsnprintf(char *str, size_t size,
|
||||||
const char *format, va_list ap);
|
const char *format, va_list ap);
|
||||||
#define vsnprintf(str, size, format, ap) safe_vsnprintf(str, size, format, ap)
|
#define vsnprintf(str, size, format, ap) safe_vsnprintf(str, size, format, ap)
|
||||||
#if defined(_MSC_VER) && (_MSC_VER < 1400)
|
|
||||||
#define va_copy(dst, src) (dst) = (src)
|
#define va_copy(dst, src) (dst) = (src)
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
#endif /* #if !defined(__MINGW32__) && !defined(__MINGW64__) */
|
#endif /* #if !defined(__MINGW32__) && !defined(__MINGW64__) */
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
@@ -111,7 +109,9 @@ inline void setenv(const char* name, const char* value, int) {
|
|||||||
#define unlink _unlink
|
#define unlink _unlink
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !(defined(_MSC_VER) && _MSC_VER >= 1400)
|
#if defined(_MSC_VER) && _MSC_VER >= 1800
|
||||||
|
#include <inttypes.h>
|
||||||
|
#else
|
||||||
#define PRId32 "d"
|
#define PRId32 "d"
|
||||||
#define PRIu32 "u"
|
#define PRIu32 "u"
|
||||||
#define PRId64 "I64d"
|
#define PRId64 "I64d"
|
||||||
|
|||||||
6
extern/glog/AUTHORS
vendored
6
extern/glog/AUTHORS
vendored
@@ -8,11 +8,15 @@
|
|||||||
#
|
#
|
||||||
# Please keep the list sorted.
|
# Please keep the list sorted.
|
||||||
|
|
||||||
|
Abhishek Dasgupta <abhi2743@gmail.com>
|
||||||
Abhishek Parmar <abhishek@orng.net>
|
Abhishek Parmar <abhishek@orng.net>
|
||||||
|
Andy Ying <andy@trailofbits.com>
|
||||||
Brian Silverman <bsilver16384@gmail.com>
|
Brian Silverman <bsilver16384@gmail.com>
|
||||||
Google Inc.
|
Google Inc.
|
||||||
|
Guillaume Dumont <dumont.guillaume@gmail.com>
|
||||||
Michael Tanner <michael@tannertaxpro.com>
|
Michael Tanner <michael@tannertaxpro.com>
|
||||||
|
MiniLight <MiniLightAR@Gmail.com>
|
||||||
romange <romange@users.noreply.github.com>
|
romange <romange@users.noreply.github.com>
|
||||||
Sergiu Dotenco <sergiu.dotenco@th-nuernberg.de>
|
Sergiu Deitsch <sergiu.deitsch@gmail.com>
|
||||||
tbennun <tbennun@gmail.com>
|
tbennun <tbennun@gmail.com>
|
||||||
Teddy Reed <teddy@prosauce.org>
|
Teddy Reed <teddy@prosauce.org>
|
||||||
|
|||||||
4
extern/glog/README.blender
vendored
4
extern/glog/README.blender
vendored
@@ -1,9 +1,7 @@
|
|||||||
Project: Google Logging
|
Project: Google Logging
|
||||||
URL: https://github.com/google/glog
|
URL: https://github.com/google/glog
|
||||||
License: New BSD
|
License: New BSD
|
||||||
Upstream version: 0.3.4, 4d391fe
|
Upstream version: 0.3.5, a6a166db069
|
||||||
Local modifications:
|
Local modifications:
|
||||||
* Added per-platform config.h files so no configuration-time
|
* Added per-platform config.h files so no configuration-time
|
||||||
checks for functions and so are needed.
|
checks for functions and so are needed.
|
||||||
* Applied changes from a fork https://github.com/Nazg-Gul/glog
|
|
||||||
(see https://github.com/google/glog/pull/81)
|
|
||||||
|
|||||||
2
extern/glog/src/config.h
vendored
2
extern/glog/src/config.h
vendored
@@ -14,6 +14,4 @@
|
|||||||
#include "windows/config.h"
|
#include "windows/config.h"
|
||||||
#elif defined(__GNU__)
|
#elif defined(__GNU__)
|
||||||
#include "config_hurd.h"
|
#include "config_hurd.h"
|
||||||
#elif defined(__HAIKU__)
|
|
||||||
#include "config_haiku.h"
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
1
extern/glog/src/demangle.h
vendored
1
extern/glog/src/demangle.h
vendored
@@ -71,6 +71,7 @@
|
|||||||
#define BASE_DEMANGLE_H_
|
#define BASE_DEMANGLE_H_
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "glog/logging.h"
|
||||||
|
|
||||||
_START_GOOGLE_NAMESPACE_
|
_START_GOOGLE_NAMESPACE_
|
||||||
|
|
||||||
|
|||||||
6
extern/glog/src/glog/logging.h
vendored
6
extern/glog/src/glog/logging.h
vendored
@@ -33,10 +33,6 @@
|
|||||||
// Pretty much everybody needs to #include this file so that they can
|
// Pretty much everybody needs to #include this file so that they can
|
||||||
// log various happenings.
|
// log various happenings.
|
||||||
//
|
//
|
||||||
#ifdef WIN32
|
|
||||||
# include "windows/glog/logging.h"
|
|
||||||
#else // WIN32
|
|
||||||
|
|
||||||
#ifndef _LOGGING_H_
|
#ifndef _LOGGING_H_
|
||||||
#define _LOGGING_H_
|
#define _LOGGING_H_
|
||||||
|
|
||||||
@@ -1627,5 +1623,3 @@ GOOGLE_GLOG_DLL_DECL void InstallFailureWriter(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif // _LOGGING_H_
|
#endif // _LOGGING_H_
|
||||||
|
|
||||||
#endif // WIN32
|
|
||||||
|
|||||||
7
extern/glog/src/glog/raw_logging.h
vendored
7
extern/glog/src/glog/raw_logging.h
vendored
@@ -32,9 +32,6 @@
|
|||||||
// Thread-safe logging routines that do not allocate any memory or
|
// Thread-safe logging routines that do not allocate any memory or
|
||||||
// acquire any locks, and can therefore be used by low-level memory
|
// acquire any locks, and can therefore be used by low-level memory
|
||||||
// allocation and synchronization code.
|
// allocation and synchronization code.
|
||||||
#ifdef WIN32
|
|
||||||
# include "windows/glog/raw_logging.h"
|
|
||||||
#else // WIN32
|
|
||||||
|
|
||||||
#ifndef BASE_RAW_LOGGING_H_
|
#ifndef BASE_RAW_LOGGING_H_
|
||||||
#define BASE_RAW_LOGGING_H_
|
#define BASE_RAW_LOGGING_H_
|
||||||
@@ -176,7 +173,7 @@ GOOGLE_GLOG_DLL_DECL void RawLog__(LogSeverity severity,
|
|||||||
const char* file,
|
const char* file,
|
||||||
int line,
|
int line,
|
||||||
const char* format, ...)
|
const char* format, ...)
|
||||||
;
|
__attribute__((__format__ (__printf__, 4, 5)));
|
||||||
|
|
||||||
// Hack to propagate time information into this module so that
|
// Hack to propagate time information into this module so that
|
||||||
// this module does not have to directly call localtime_r(),
|
// this module does not have to directly call localtime_r(),
|
||||||
@@ -186,5 +183,3 @@ GOOGLE_GLOG_DLL_DECL void RawLog__SetLastTime(const struct tm& t, int usecs);
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif // BASE_RAW_LOGGING_H_
|
#endif // BASE_RAW_LOGGING_H_
|
||||||
|
|
||||||
#endif // WIN32
|
|
||||||
|
|||||||
220
extern/glog/src/glog/stl_logging.h
vendored
Normal file
220
extern/glog/src/glog/stl_logging.h
vendored
Normal file
@@ -0,0 +1,220 @@
|
|||||||
|
// Copyright (c) 2003, Google Inc.
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
//
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Google Inc. nor the names of its
|
||||||
|
// contributors may be used to endorse or promote products derived from
|
||||||
|
// this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
// Stream output operators for STL containers; to be used for logging *only*.
|
||||||
|
// Inclusion of this file lets you do:
|
||||||
|
//
|
||||||
|
// list<string> x;
|
||||||
|
// LOG(INFO) << "data: " << x;
|
||||||
|
// vector<int> v1, v2;
|
||||||
|
// CHECK_EQ(v1, v2);
|
||||||
|
//
|
||||||
|
// If you want to use this header file with hash maps or slist, you
|
||||||
|
// need to define macros before including this file:
|
||||||
|
//
|
||||||
|
// - GLOG_STL_LOGGING_FOR_UNORDERED - <unordered_map> and <unordered_set>
|
||||||
|
// - GLOG_STL_LOGGING_FOR_TR1_UNORDERED - <tr1/unordered_(map|set)>
|
||||||
|
// - GLOG_STL_LOGGING_FOR_EXT_HASH - <ext/hash_(map|set)>
|
||||||
|
// - GLOG_STL_LOGGING_FOR_EXT_SLIST - <ext/slist>
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef UTIL_GTL_STL_LOGGING_INL_H_
|
||||||
|
#define UTIL_GTL_STL_LOGGING_INL_H_
|
||||||
|
|
||||||
|
#if !1
|
||||||
|
# error We do not support stl_logging for this compiler
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <deque>
|
||||||
|
#include <list>
|
||||||
|
#include <map>
|
||||||
|
#include <ostream>
|
||||||
|
#include <set>
|
||||||
|
#include <utility>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#ifdef GLOG_STL_LOGGING_FOR_UNORDERED
|
||||||
|
# include <unordered_map>
|
||||||
|
# include <unordered_set>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef GLOG_STL_LOGGING_FOR_TR1_UNORDERED
|
||||||
|
# include <tr1/unordered_map>
|
||||||
|
# include <tr1/unordered_set>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef GLOG_STL_LOGGING_FOR_EXT_HASH
|
||||||
|
# include <ext/hash_set>
|
||||||
|
# include <ext/hash_map>
|
||||||
|
#endif
|
||||||
|
#ifdef GLOG_STL_LOGGING_FOR_EXT_SLIST
|
||||||
|
# include <ext/slist>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Forward declare these two, and define them after all the container streams
|
||||||
|
// operators so that we can recurse from pair -> container -> container -> pair
|
||||||
|
// properly.
|
||||||
|
template<class First, class Second>
|
||||||
|
std::ostream& operator<<(std::ostream& out, const std::pair<First, Second>& p);
|
||||||
|
|
||||||
|
namespace google {
|
||||||
|
|
||||||
|
template<class Iter>
|
||||||
|
void PrintSequence(std::ostream& out, Iter begin, Iter end);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#define OUTPUT_TWO_ARG_CONTAINER(Sequence) \
|
||||||
|
template<class T1, class T2> \
|
||||||
|
inline std::ostream& operator<<(std::ostream& out, \
|
||||||
|
const Sequence<T1, T2>& seq) { \
|
||||||
|
google::PrintSequence(out, seq.begin(), seq.end()); \
|
||||||
|
return out; \
|
||||||
|
}
|
||||||
|
|
||||||
|
OUTPUT_TWO_ARG_CONTAINER(std::vector)
|
||||||
|
OUTPUT_TWO_ARG_CONTAINER(std::deque)
|
||||||
|
OUTPUT_TWO_ARG_CONTAINER(std::list)
|
||||||
|
#ifdef GLOG_STL_LOGGING_FOR_EXT_SLIST
|
||||||
|
OUTPUT_TWO_ARG_CONTAINER(__gnu_cxx::slist)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#undef OUTPUT_TWO_ARG_CONTAINER
|
||||||
|
|
||||||
|
#define OUTPUT_THREE_ARG_CONTAINER(Sequence) \
|
||||||
|
template<class T1, class T2, class T3> \
|
||||||
|
inline std::ostream& operator<<(std::ostream& out, \
|
||||||
|
const Sequence<T1, T2, T3>& seq) { \
|
||||||
|
google::PrintSequence(out, seq.begin(), seq.end()); \
|
||||||
|
return out; \
|
||||||
|
}
|
||||||
|
|
||||||
|
OUTPUT_THREE_ARG_CONTAINER(std::set)
|
||||||
|
OUTPUT_THREE_ARG_CONTAINER(std::multiset)
|
||||||
|
|
||||||
|
#undef OUTPUT_THREE_ARG_CONTAINER
|
||||||
|
|
||||||
|
#define OUTPUT_FOUR_ARG_CONTAINER(Sequence) \
|
||||||
|
template<class T1, class T2, class T3, class T4> \
|
||||||
|
inline std::ostream& operator<<(std::ostream& out, \
|
||||||
|
const Sequence<T1, T2, T3, T4>& seq) { \
|
||||||
|
google::PrintSequence(out, seq.begin(), seq.end()); \
|
||||||
|
return out; \
|
||||||
|
}
|
||||||
|
|
||||||
|
OUTPUT_FOUR_ARG_CONTAINER(std::map)
|
||||||
|
OUTPUT_FOUR_ARG_CONTAINER(std::multimap)
|
||||||
|
#ifdef GLOG_STL_LOGGING_FOR_UNORDERED
|
||||||
|
OUTPUT_FOUR_ARG_CONTAINER(std::unordered_set)
|
||||||
|
OUTPUT_FOUR_ARG_CONTAINER(std::unordered_multiset)
|
||||||
|
#endif
|
||||||
|
#ifdef GLOG_STL_LOGGING_FOR_TR1_UNORDERED
|
||||||
|
OUTPUT_FOUR_ARG_CONTAINER(std::tr1::unordered_set)
|
||||||
|
OUTPUT_FOUR_ARG_CONTAINER(std::tr1::unordered_multiset)
|
||||||
|
#endif
|
||||||
|
#ifdef GLOG_STL_LOGGING_FOR_EXT_HASH
|
||||||
|
OUTPUT_FOUR_ARG_CONTAINER(__gnu_cxx::hash_set)
|
||||||
|
OUTPUT_FOUR_ARG_CONTAINER(__gnu_cxx::hash_multiset)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#undef OUTPUT_FOUR_ARG_CONTAINER
|
||||||
|
|
||||||
|
#define OUTPUT_FIVE_ARG_CONTAINER(Sequence) \
|
||||||
|
template<class T1, class T2, class T3, class T4, class T5> \
|
||||||
|
inline std::ostream& operator<<(std::ostream& out, \
|
||||||
|
const Sequence<T1, T2, T3, T4, T5>& seq) { \
|
||||||
|
google::PrintSequence(out, seq.begin(), seq.end()); \
|
||||||
|
return out; \
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef GLOG_STL_LOGGING_FOR_UNORDERED
|
||||||
|
OUTPUT_FIVE_ARG_CONTAINER(std::unordered_map)
|
||||||
|
OUTPUT_FIVE_ARG_CONTAINER(std::unordered_multimap)
|
||||||
|
#endif
|
||||||
|
#ifdef GLOG_STL_LOGGING_FOR_TR1_UNORDERED
|
||||||
|
OUTPUT_FIVE_ARG_CONTAINER(std::tr1::unordered_map)
|
||||||
|
OUTPUT_FIVE_ARG_CONTAINER(std::tr1::unordered_multimap)
|
||||||
|
#endif
|
||||||
|
#ifdef GLOG_STL_LOGGING_FOR_EXT_HASH
|
||||||
|
OUTPUT_FIVE_ARG_CONTAINER(__gnu_cxx::hash_map)
|
||||||
|
OUTPUT_FIVE_ARG_CONTAINER(__gnu_cxx::hash_multimap)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#undef OUTPUT_FIVE_ARG_CONTAINER
|
||||||
|
|
||||||
|
template<class First, class Second>
|
||||||
|
inline std::ostream& operator<<(std::ostream& out,
|
||||||
|
const std::pair<First, Second>& p) {
|
||||||
|
out << '(' << p.first << ", " << p.second << ')';
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace google {
|
||||||
|
|
||||||
|
template<class Iter>
|
||||||
|
inline void PrintSequence(std::ostream& out, Iter begin, Iter end) {
|
||||||
|
// Output at most 100 elements -- appropriate if used for logging.
|
||||||
|
for (int i = 0; begin != end && i < 100; ++i, ++begin) {
|
||||||
|
if (i > 0) out << ' ';
|
||||||
|
out << *begin;
|
||||||
|
}
|
||||||
|
if (begin != end) {
|
||||||
|
out << " ...";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Note that this is technically undefined behavior! We are adding things into
|
||||||
|
// the std namespace for a reason though -- we are providing new operations on
|
||||||
|
// types which are themselves defined with this namespace. Without this, these
|
||||||
|
// operator overloads cannot be found via ADL. If these definitions are not
|
||||||
|
// found via ADL, they must be #included before they're used, which requires
|
||||||
|
// this header to be included before apparently independent other headers.
|
||||||
|
//
|
||||||
|
// For example, base/logging.h defines various template functions to implement
|
||||||
|
// CHECK_EQ(x, y) and stream x and y into the log in the event the check fails.
|
||||||
|
// It does so via the function template MakeCheckOpValueString:
|
||||||
|
// template<class T>
|
||||||
|
// void MakeCheckOpValueString(strstream* ss, const T& v) {
|
||||||
|
// (*ss) << v;
|
||||||
|
// }
|
||||||
|
// Because 'glog/logging.h' is included before 'glog/stl_logging.h',
|
||||||
|
// subsequent CHECK_EQ(v1, v2) for vector<...> typed variable v1 and v2 can only
|
||||||
|
// find these operator definitions via ADL.
|
||||||
|
//
|
||||||
|
// Even this solution has problems -- it may pull unintended operators into the
|
||||||
|
// namespace as well, allowing them to also be found via ADL, and creating code
|
||||||
|
// that only works with a particular order of includes. Long term, we need to
|
||||||
|
// move all of the *definitions* into namespace std, bet we need to ensure no
|
||||||
|
// one references them first. This lets us take that step. We cannot define them
|
||||||
|
// in both because that would create ambiguous overloads when both are found.
|
||||||
|
namespace std { using ::operator<<; }
|
||||||
|
|
||||||
|
#endif // UTIL_GTL_STL_LOGGING_INL_H_
|
||||||
10
extern/glog/src/logging.cc
vendored
10
extern/glog/src/logging.cc
vendored
@@ -260,6 +260,9 @@ static bool TerminalSupportsColor() {
|
|||||||
!strcmp(term, "xterm-color") ||
|
!strcmp(term, "xterm-color") ||
|
||||||
!strcmp(term, "xterm-256color") ||
|
!strcmp(term, "xterm-256color") ||
|
||||||
!strcmp(term, "screen-256color") ||
|
!strcmp(term, "screen-256color") ||
|
||||||
|
!strcmp(term, "konsole") ||
|
||||||
|
!strcmp(term, "konsole-16color") ||
|
||||||
|
!strcmp(term, "konsole-256color") ||
|
||||||
!strcmp(term, "screen") ||
|
!strcmp(term, "screen") ||
|
||||||
!strcmp(term, "linux") ||
|
!strcmp(term, "linux") ||
|
||||||
!strcmp(term, "cygwin");
|
!strcmp(term, "cygwin");
|
||||||
@@ -301,7 +304,7 @@ static GLogColor SeverityToColor(LogSeverity severity) {
|
|||||||
#ifdef OS_WINDOWS
|
#ifdef OS_WINDOWS
|
||||||
|
|
||||||
// Returns the character attribute for the given color.
|
// Returns the character attribute for the given color.
|
||||||
static WORD GetColorAttribute(GLogColor color) {
|
WORD GetColorAttribute(GLogColor color) {
|
||||||
switch (color) {
|
switch (color) {
|
||||||
case COLOR_RED: return FOREGROUND_RED;
|
case COLOR_RED: return FOREGROUND_RED;
|
||||||
case COLOR_GREEN: return FOREGROUND_GREEN;
|
case COLOR_GREEN: return FOREGROUND_GREEN;
|
||||||
@@ -313,7 +316,7 @@ static WORD GetColorAttribute(GLogColor color) {
|
|||||||
#else
|
#else
|
||||||
|
|
||||||
// Returns the ANSI color code for the given color.
|
// Returns the ANSI color code for the given color.
|
||||||
static const char* GetAnsiColorCode(GLogColor color) {
|
const char* GetAnsiColorCode(GLogColor color) {
|
||||||
switch (color) {
|
switch (color) {
|
||||||
case COLOR_RED: return "1";
|
case COLOR_RED: return "1";
|
||||||
case COLOR_GREEN: return "2";
|
case COLOR_GREEN: return "2";
|
||||||
@@ -825,6 +828,7 @@ void LogDestination::DeleteLogDestinations() {
|
|||||||
}
|
}
|
||||||
MutexLock l(&sink_mutex_);
|
MutexLock l(&sink_mutex_);
|
||||||
delete sinks_;
|
delete sinks_;
|
||||||
|
sinks_ = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@@ -1677,7 +1681,6 @@ void LogToStderr() {
|
|||||||
namespace base {
|
namespace base {
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
bool GetExitOnDFatal();
|
|
||||||
bool GetExitOnDFatal() {
|
bool GetExitOnDFatal() {
|
||||||
MutexLock l(&log_mutex);
|
MutexLock l(&log_mutex);
|
||||||
return exit_on_dfatal;
|
return exit_on_dfatal;
|
||||||
@@ -1693,7 +1696,6 @@ bool GetExitOnDFatal() {
|
|||||||
// and the stack trace is not recorded. The LOG(FATAL) *will* still
|
// and the stack trace is not recorded. The LOG(FATAL) *will* still
|
||||||
// exit the program. Since this function is used only in testing,
|
// exit the program. Since this function is used only in testing,
|
||||||
// these differences are acceptable.
|
// these differences are acceptable.
|
||||||
void SetExitOnDFatal(bool value);
|
|
||||||
void SetExitOnDFatal(bool value) {
|
void SetExitOnDFatal(bool value) {
|
||||||
MutexLock l(&log_mutex);
|
MutexLock l(&log_mutex);
|
||||||
exit_on_dfatal = value;
|
exit_on_dfatal = value;
|
||||||
|
|||||||
3
extern/glog/src/raw_logging.cc
vendored
3
extern/glog/src/raw_logging.cc
vendored
@@ -59,8 +59,7 @@
|
|||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Hurd does not have SYS_write.
|
#if defined(HAVE_SYSCALL_H) || defined(HAVE_SYS_SYSCALL_H)
|
||||||
#if (defined(HAVE_SYSCALL_H) || defined(HAVE_SYS_SYSCALL_H)) && !defined(__GNU__)
|
|
||||||
# define safe_write(fd, s, len) syscall(SYS_write, fd, s, len)
|
# define safe_write(fd, s, len) syscall(SYS_write, fd, s, len)
|
||||||
#else
|
#else
|
||||||
// Not so safe, but what can you do?
|
// Not so safe, but what can you do?
|
||||||
|
|||||||
37
extern/glog/src/symbolize.cc
vendored
37
extern/glog/src/symbolize.cc
vendored
@@ -327,7 +327,7 @@ FindSymbol(uint64_t pc, const int fd, char *out, int out_size,
|
|||||||
// false.
|
// false.
|
||||||
static bool GetSymbolFromObjectFile(const int fd, uint64_t pc,
|
static bool GetSymbolFromObjectFile(const int fd, uint64_t pc,
|
||||||
char *out, int out_size,
|
char *out, int out_size,
|
||||||
uint64_t map_start_address) {
|
uint64_t map_base_address) {
|
||||||
// Read the ELF header.
|
// Read the ELF header.
|
||||||
ElfW(Ehdr) elf_header;
|
ElfW(Ehdr) elf_header;
|
||||||
if (!ReadFromOffsetExact(fd, &elf_header, sizeof(elf_header), 0)) {
|
if (!ReadFromOffsetExact(fd, &elf_header, sizeof(elf_header), 0)) {
|
||||||
@@ -336,7 +336,28 @@ static bool GetSymbolFromObjectFile(const int fd, uint64_t pc,
|
|||||||
|
|
||||||
uint64_t symbol_offset = 0;
|
uint64_t symbol_offset = 0;
|
||||||
if (elf_header.e_type == ET_DYN) { // DSO needs offset adjustment.
|
if (elf_header.e_type == ET_DYN) { // DSO needs offset adjustment.
|
||||||
symbol_offset = map_start_address;
|
ElfW(Phdr) phdr;
|
||||||
|
// We need to find the PT_LOAD segment corresponding to the read-execute
|
||||||
|
// file mapping in order to correctly perform the offset adjustment.
|
||||||
|
for (unsigned i = 0; i != elf_header.e_phnum; ++i) {
|
||||||
|
if (!ReadFromOffsetExact(fd, &phdr, sizeof(phdr),
|
||||||
|
elf_header.e_phoff + i * sizeof(phdr)))
|
||||||
|
return false;
|
||||||
|
if (phdr.p_type == PT_LOAD &&
|
||||||
|
(phdr.p_flags & (PF_R | PF_X)) == (PF_R | PF_X)) {
|
||||||
|
// Find the mapped address corresponding to virtual address zero. We do
|
||||||
|
// this by first adding p_offset. This gives us the mapped address of
|
||||||
|
// the start of the segment, or in other words the mapped address
|
||||||
|
// corresponding to the virtual address of the segment. (Note that this
|
||||||
|
// is distinct from the start address, as p_offset is not guaranteed to
|
||||||
|
// be page aligned.) We then subtract p_vaddr, which takes us to virtual
|
||||||
|
// address zero.
|
||||||
|
symbol_offset = map_base_address + phdr.p_offset - phdr.p_vaddr;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (symbol_offset == 0)
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ElfW(Shdr) symtab, strtab;
|
ElfW(Shdr) symtab, strtab;
|
||||||
@@ -569,8 +590,8 @@ OpenObjectFileContainingPcAndGetStartAddress(uint64_t pc,
|
|||||||
return -1; // Malformed line.
|
return -1; // Malformed line.
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check flags. We are only interested in "r-x" maps.
|
// Check flags. We are only interested in "r*x" maps.
|
||||||
if (memcmp(flags_start, "r-x", 3) != 0) { // Not a "r-x" map.
|
if (flags_start[0] != 'r' || flags_start[2] != 'x') {
|
||||||
continue; // We skip this map.
|
continue; // We skip this map.
|
||||||
}
|
}
|
||||||
++cursor; // Skip ' '.
|
++cursor; // Skip ' '.
|
||||||
@@ -634,7 +655,7 @@ OpenObjectFileContainingPcAndGetStartAddress(uint64_t pc,
|
|||||||
// bytes. Output will be truncated as needed, and a NUL character is always
|
// bytes. Output will be truncated as needed, and a NUL character is always
|
||||||
// appended.
|
// appended.
|
||||||
// NOTE: code from sandbox/linux/seccomp-bpf/demo.cc.
|
// NOTE: code from sandbox/linux/seccomp-bpf/demo.cc.
|
||||||
static char *itoa_r(intptr_t i, char *buf, size_t sz, int base, size_t padding) {
|
char *itoa_r(intptr_t i, char *buf, size_t sz, int base, size_t padding) {
|
||||||
// Make sure we can write at least one NUL byte.
|
// Make sure we can write at least one NUL byte.
|
||||||
size_t n = 1;
|
size_t n = 1;
|
||||||
if (n > sz)
|
if (n > sz)
|
||||||
@@ -696,7 +717,7 @@ static char *itoa_r(intptr_t i, char *buf, size_t sz, int base, size_t padding)
|
|||||||
|
|
||||||
// Safely appends string |source| to string |dest|. Never writes past the
|
// Safely appends string |source| to string |dest|. Never writes past the
|
||||||
// buffer size |dest_size| and guarantees that |dest| is null-terminated.
|
// buffer size |dest_size| and guarantees that |dest| is null-terminated.
|
||||||
static void SafeAppendString(const char* source, char* dest, int dest_size) {
|
void SafeAppendString(const char* source, char* dest, int dest_size) {
|
||||||
int dest_string_length = strlen(dest);
|
int dest_string_length = strlen(dest);
|
||||||
SAFE_ASSERT(dest_string_length < dest_size);
|
SAFE_ASSERT(dest_string_length < dest_size);
|
||||||
dest += dest_string_length;
|
dest += dest_string_length;
|
||||||
@@ -709,7 +730,7 @@ static void SafeAppendString(const char* source, char* dest, int dest_size) {
|
|||||||
// Converts a 64-bit value into a hex string, and safely appends it to |dest|.
|
// Converts a 64-bit value into a hex string, and safely appends it to |dest|.
|
||||||
// Never writes past the buffer size |dest_size| and guarantees that |dest| is
|
// Never writes past the buffer size |dest_size| and guarantees that |dest| is
|
||||||
// null-terminated.
|
// null-terminated.
|
||||||
static void SafeAppendHexNumber(uint64_t value, char* dest, int dest_size) {
|
void SafeAppendHexNumber(uint64_t value, char* dest, int dest_size) {
|
||||||
// 64-bit numbers in hex can have up to 16 digits.
|
// 64-bit numbers in hex can have up to 16 digits.
|
||||||
char buf[17] = {'\0'};
|
char buf[17] = {'\0'};
|
||||||
SafeAppendString(itoa_r(value, buf, sizeof(buf), 16, 0), dest, dest_size);
|
SafeAppendString(itoa_r(value, buf, sizeof(buf), 16, 0), dest, dest_size);
|
||||||
@@ -782,7 +803,7 @@ static ATTRIBUTE_NOINLINE bool SymbolizeAndDemangle(void *pc, char *out,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!GetSymbolFromObjectFile(wrapped_object_fd.get(), pc0,
|
if (!GetSymbolFromObjectFile(wrapped_object_fd.get(), pc0,
|
||||||
out, out_size, start_address)) {
|
out, out_size, base_address)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
2
extern/glog/src/utilities.cc
vendored
2
extern/glog/src/utilities.cc
vendored
@@ -84,7 +84,7 @@ static void DebugWriteToStderr(const char* data, void *) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void DebugWriteToString(const char* data, void *arg) {
|
void DebugWriteToString(const char* data, void *arg) {
|
||||||
reinterpret_cast<string*>(arg)->append(data);
|
reinterpret_cast<string*>(arg)->append(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
4
extern/glog/src/utilities.h
vendored
4
extern/glog/src/utilities.h
vendored
@@ -101,9 +101,7 @@
|
|||||||
// correctly when GetStackTrace() is called with max_depth == 0.
|
// correctly when GetStackTrace() is called with max_depth == 0.
|
||||||
// Some code may do that.
|
// Some code may do that.
|
||||||
|
|
||||||
#if defined(__MINGW32__) || defined(__FreeBSD__)
|
#if defined(HAVE_LIB_UNWIND)
|
||||||
# undef STACKTRACE_H
|
|
||||||
#elif defined(HAVE_LIB_UNWIND)
|
|
||||||
# define STACKTRACE_H "stacktrace_libunwind-inl.h"
|
# define STACKTRACE_H "stacktrace_libunwind-inl.h"
|
||||||
#elif !defined(NO_FRAME_POINTER)
|
#elif !defined(NO_FRAME_POINTER)
|
||||||
# if defined(__i386__) && __GNUC__ >= 2
|
# if defined(__i386__) && __GNUC__ >= 2
|
||||||
|
|||||||
6
extern/glog/src/vlog_is_on.cc
vendored
6
extern/glog/src/vlog_is_on.cc
vendored
@@ -62,12 +62,6 @@ _START_GOOGLE_NAMESPACE_
|
|||||||
|
|
||||||
namespace glog_internal_namespace_ {
|
namespace glog_internal_namespace_ {
|
||||||
|
|
||||||
// Used by logging_unittests.cc so can't make it static here.
|
|
||||||
GOOGLE_GLOG_DLL_DECL bool SafeFNMatch_(const char* pattern,
|
|
||||||
size_t patt_len,
|
|
||||||
const char* str,
|
|
||||||
size_t str_len);
|
|
||||||
|
|
||||||
// Implementation of fnmatch that does not need 0-termination
|
// Implementation of fnmatch that does not need 0-termination
|
||||||
// of arguments and does not allocate any memory,
|
// of arguments and does not allocate any memory,
|
||||||
// but we only support "*" and "?" wildcards, not the "[...]" patterns.
|
// but we only support "*" and "?" wildcards, not the "[...]" patterns.
|
||||||
|
|||||||
7
extern/glog/src/windows/config.h
vendored
7
extern/glog/src/windows/config.h
vendored
@@ -1,8 +1,5 @@
|
|||||||
/* src/config.h.in. Generated from configure.ac by autoheader. */
|
/* src/config.h.in. Generated from configure.ac by autoheader. */
|
||||||
|
|
||||||
/* define if you have google gflags library */
|
|
||||||
#define HAVE_LIB_GFLAGS 1
|
|
||||||
|
|
||||||
/* Namespace for Google classes */
|
/* Namespace for Google classes */
|
||||||
#define GOOGLE_NAMESPACE google
|
#define GOOGLE_NAMESPACE google
|
||||||
|
|
||||||
@@ -12,10 +9,6 @@
|
|||||||
/* Puts following code inside the Google namespace */
|
/* Puts following code inside the Google namespace */
|
||||||
#define _START_GOOGLE_NAMESPACE_ namespace google {
|
#define _START_GOOGLE_NAMESPACE_ namespace google {
|
||||||
|
|
||||||
#if defined(__MINGW32__) || (defined(_MSC_VER) && (_MSC_VER >= 1900))
|
|
||||||
# define HAVE_SNPRINTF
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Always the empty-string on non-windows systems. On windows, should be
|
/* Always the empty-string on non-windows systems. On windows, should be
|
||||||
"__declspec(dllexport)". This way, when we compile the dll, we export our
|
"__declspec(dllexport)". This way, when we compile the dll, we export our
|
||||||
functions/classes. It's safe to define this here because config.h is only
|
functions/classes. It's safe to define this here because config.h is only
|
||||||
|
|||||||
117
extern/glog/src/windows/glog/logging.h
vendored
117
extern/glog/src/windows/glog/logging.h
vendored
@@ -52,14 +52,6 @@
|
|||||||
#endif
|
#endif
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
// Annoying stuff for windows -- makes sure clients can import these functions
|
|
||||||
#ifndef GOOGLE_GLOG_DLL_DECL
|
|
||||||
# if defined(_WIN32) && !defined(__CYGWIN__)
|
|
||||||
# define GOOGLE_GLOG_DLL_DECL __declspec(dllimport)
|
|
||||||
# else
|
|
||||||
# define GOOGLE_GLOG_DLL_DECL
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
#define GLOG_MSVC_PUSH_DISABLE_WARNING(n) __pragma(warning(push)) \
|
#define GLOG_MSVC_PUSH_DISABLE_WARNING(n) __pragma(warning(push)) \
|
||||||
__pragma(warning(disable:n))
|
__pragma(warning(disable:n))
|
||||||
@@ -69,35 +61,38 @@
|
|||||||
#define GLOG_MSVC_POP_WARNING()
|
#define GLOG_MSVC_POP_WARNING()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Annoying stuff for windows -- makes sure clients can import these functions
|
||||||
|
#ifndef GOOGLE_GLOG_DLL_DECL
|
||||||
|
# if defined(_WIN32) && !defined(__CYGWIN__)
|
||||||
|
# define GOOGLE_GLOG_DLL_DECL __declspec(dllimport)
|
||||||
|
# else
|
||||||
|
# define GOOGLE_GLOG_DLL_DECL
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
// We care a lot about number of bits things take up. Unfortunately,
|
// We care a lot about number of bits things take up. Unfortunately,
|
||||||
// systems define their bit-specific ints in a lot of different ways.
|
// systems define their bit-specific ints in a lot of different ways.
|
||||||
// We use our own way, and have a typedef to get there.
|
// We use our own way, and have a typedef to get there.
|
||||||
// Note: these commands below may look like "#if 1" or "#if 0", but
|
// Note: these commands below may look like "#if 1" or "#if 0", but
|
||||||
// that's because they were constructed that way at ./configure time.
|
// that's because they were constructed that way at ./configure time.
|
||||||
// Look at logging.h.in to see how they're calculated (based on your config).
|
// Look at logging.h.in to see how they're calculated (based on your config).
|
||||||
#ifdef __MINGW32__
|
#if 0
|
||||||
#include <stdint.h> // the normal place uint16_t is defined
|
#include <stdint.h> // the normal place uint16_t is defined
|
||||||
#endif
|
#endif
|
||||||
#ifdef __MINGW32__
|
#if 0
|
||||||
#include <sys/types.h> // the normal place u_int16_t is defined
|
#include <sys/types.h> // the normal place u_int16_t is defined
|
||||||
#endif
|
#endif
|
||||||
#ifdef __MINGW32__
|
#if 0
|
||||||
#include <inttypes.h> // a third place for uint16_t or u_int16_t
|
#include <inttypes.h> // a third place for uint16_t or u_int16_t
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 1
|
#if 0
|
||||||
#include <gflags/gflags.h>
|
#include <gflags/gflags.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
|
||||||
# include <stdlib.h>
|
|
||||||
# include <unistd.h>
|
|
||||||
# define _exit(x) exit(x)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace google {
|
namespace google {
|
||||||
|
|
||||||
#if defined(__MINGW32__) // the C99 format
|
#if 0 // the C99 format
|
||||||
typedef int32_t int32;
|
typedef int32_t int32;
|
||||||
typedef uint32_t uint32;
|
typedef uint32_t uint32;
|
||||||
typedef int64_t int64;
|
typedef int64_t int64;
|
||||||
@@ -107,7 +102,7 @@ typedef int32_t int32;
|
|||||||
typedef u_int32_t uint32;
|
typedef u_int32_t uint32;
|
||||||
typedef int64_t int64;
|
typedef int64_t int64;
|
||||||
typedef u_int64_t uint64;
|
typedef u_int64_t uint64;
|
||||||
#elif defined(_MSC_VER) // the windows (vc7) format
|
#elif 1 // the windows (vc7) format
|
||||||
typedef __int32 int32;
|
typedef __int32 int32;
|
||||||
typedef unsigned __int32 uint32;
|
typedef unsigned __int32 uint32;
|
||||||
typedef __int64 int64;
|
typedef __int64 int64;
|
||||||
@@ -139,15 +134,28 @@ typedef unsigned __int64 uint64;
|
|||||||
#ifndef GOOGLE_PREDICT_BRANCH_NOT_TAKEN
|
#ifndef GOOGLE_PREDICT_BRANCH_NOT_TAKEN
|
||||||
#if 0
|
#if 0
|
||||||
#define GOOGLE_PREDICT_BRANCH_NOT_TAKEN(x) (__builtin_expect(x, 0))
|
#define GOOGLE_PREDICT_BRANCH_NOT_TAKEN(x) (__builtin_expect(x, 0))
|
||||||
#define GOOGLE_PREDICT_FALSE(x) (__builtin_expect(x, 0))
|
|
||||||
#define GOOGLE_PREDICT_TRUE(x) (__builtin_expect(!!(x), 1))
|
|
||||||
#else
|
#else
|
||||||
#define GOOGLE_PREDICT_BRANCH_NOT_TAKEN(x) x
|
#define GOOGLE_PREDICT_BRANCH_NOT_TAKEN(x) x
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GOOGLE_PREDICT_FALSE
|
||||||
|
#if 0
|
||||||
|
#define GOOGLE_PREDICT_FALSE(x) (__builtin_expect(x, 0))
|
||||||
|
#else
|
||||||
#define GOOGLE_PREDICT_FALSE(x) x
|
#define GOOGLE_PREDICT_FALSE(x) x
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GOOGLE_PREDICT_TRUE
|
||||||
|
#if 0
|
||||||
|
#define GOOGLE_PREDICT_TRUE(x) (__builtin_expect(!!(x), 1))
|
||||||
|
#else
|
||||||
#define GOOGLE_PREDICT_TRUE(x) x
|
#define GOOGLE_PREDICT_TRUE(x) x
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// Make a bunch of macros for logging. The way to log things is to stream
|
// Make a bunch of macros for logging. The way to log things is to stream
|
||||||
// things to LOG(<a particular severity level>). E.g.,
|
// things to LOG(<a particular severity level>). E.g.,
|
||||||
//
|
//
|
||||||
@@ -357,6 +365,9 @@ DECLARE_int32(minloglevel);
|
|||||||
// default logging directory.
|
// default logging directory.
|
||||||
DECLARE_string(log_dir);
|
DECLARE_string(log_dir);
|
||||||
|
|
||||||
|
// Set the log file mode.
|
||||||
|
DECLARE_int32(logfile_mode);
|
||||||
|
|
||||||
// Sets the path of the directory into which to put additional links
|
// Sets the path of the directory into which to put additional links
|
||||||
// to the log files.
|
// to the log files.
|
||||||
DECLARE_string(log_link);
|
DECLARE_string(log_link);
|
||||||
@@ -424,9 +435,15 @@ DECLARE_bool(stop_logging_if_full_disk);
|
|||||||
#define LOG_TO_STRING_FATAL(message) google::NullStreamFatal()
|
#define LOG_TO_STRING_FATAL(message) google::NullStreamFatal()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON)
|
||||||
|
#define DCHECK_IS_ON() 0
|
||||||
|
#else
|
||||||
|
#define DCHECK_IS_ON() 1
|
||||||
|
#endif
|
||||||
|
|
||||||
// For DFATAL, we want to use LogMessage (as opposed to
|
// For DFATAL, we want to use LogMessage (as opposed to
|
||||||
// LogMessageFatal), to be consistent with the original behavior.
|
// LogMessageFatal), to be consistent with the original behavior.
|
||||||
#ifdef NDEBUG
|
#if !DCHECK_IS_ON()
|
||||||
#define COMPACT_GOOGLE_LOG_DFATAL COMPACT_GOOGLE_LOG_ERROR
|
#define COMPACT_GOOGLE_LOG_DFATAL COMPACT_GOOGLE_LOG_ERROR
|
||||||
#elif GOOGLE_STRIP_LOG <= 3
|
#elif GOOGLE_STRIP_LOG <= 3
|
||||||
#define COMPACT_GOOGLE_LOG_DFATAL google::LogMessage( \
|
#define COMPACT_GOOGLE_LOG_DFATAL google::LogMessage( \
|
||||||
@@ -552,7 +569,7 @@ class LogSink; // defined below
|
|||||||
// vector<string> *outvec;
|
// vector<string> *outvec;
|
||||||
// The cast is to disambiguate NULL arguments.
|
// The cast is to disambiguate NULL arguments.
|
||||||
#define LOG_STRING(severity, outvec) \
|
#define LOG_STRING(severity, outvec) \
|
||||||
LOG_TO_STRING_##severity(static_cast<vector<string>*>(outvec)).stream()
|
LOG_TO_STRING_##severity(static_cast<std::vector<std::string>*>(outvec)).stream()
|
||||||
|
|
||||||
#define LOG_IF(severity, condition) \
|
#define LOG_IF(severity, condition) \
|
||||||
!(condition) ? (void) 0 : google::LogMessageVoidify() & LOG(severity)
|
!(condition) ? (void) 0 : google::LogMessageVoidify() & LOG(severity)
|
||||||
@@ -565,7 +582,7 @@ class LogSink; // defined below
|
|||||||
SYSLOG_IF(FATAL, !(condition)) << "Assert failed: " #condition
|
SYSLOG_IF(FATAL, !(condition)) << "Assert failed: " #condition
|
||||||
|
|
||||||
// CHECK dies with a fatal error if condition is not true. It is *not*
|
// CHECK dies with a fatal error if condition is not true. It is *not*
|
||||||
// controlled by NDEBUG, so the check will be executed regardless of
|
// controlled by DCHECK_IS_ON(), so the check will be executed regardless of
|
||||||
// compilation mode. Therefore, it is safe to do things like:
|
// compilation mode. Therefore, it is safe to do things like:
|
||||||
// CHECK(fp->Write(x) == 4)
|
// CHECK(fp->Write(x) == 4)
|
||||||
#define CHECK(condition) \
|
#define CHECK(condition) \
|
||||||
@@ -715,7 +732,7 @@ DEFINE_CHECK_OP_IMPL(Check_GT, > )
|
|||||||
#if defined(STATIC_ANALYSIS)
|
#if defined(STATIC_ANALYSIS)
|
||||||
// Only for static analysis tool to know that it is equivalent to assert
|
// Only for static analysis tool to know that it is equivalent to assert
|
||||||
#define CHECK_OP_LOG(name, op, val1, val2, log) CHECK((val1) op (val2))
|
#define CHECK_OP_LOG(name, op, val1, val2, log) CHECK((val1) op (val2))
|
||||||
#elif !defined(NDEBUG)
|
#elif DCHECK_IS_ON()
|
||||||
// In debug mode, avoid constructing CheckOpStrings if possible,
|
// In debug mode, avoid constructing CheckOpStrings if possible,
|
||||||
// to reduce the overhead of CHECK statments by 2x.
|
// to reduce the overhead of CHECK statments by 2x.
|
||||||
// Real DCHECK-heavy tests have seen 1.5x speedups.
|
// Real DCHECK-heavy tests have seen 1.5x speedups.
|
||||||
@@ -744,7 +761,7 @@ typedef std::string _Check_string;
|
|||||||
google::GetReferenceableValue(val2), \
|
google::GetReferenceableValue(val2), \
|
||||||
#val1 " " #op " " #val2)) \
|
#val1 " " #op " " #val2)) \
|
||||||
log(__FILE__, __LINE__, _result).stream()
|
log(__FILE__, __LINE__, _result).stream()
|
||||||
#endif // STATIC_ANALYSIS, !NDEBUG
|
#endif // STATIC_ANALYSIS, DCHECK_IS_ON()
|
||||||
|
|
||||||
#if GOOGLE_STRIP_LOG <= 3
|
#if GOOGLE_STRIP_LOG <= 3
|
||||||
#define CHECK_OP(name, op, val1, val2) \
|
#define CHECK_OP(name, op, val1, val2) \
|
||||||
@@ -969,7 +986,7 @@ const LogSeverity GLOG_0 = GLOG_ERROR;
|
|||||||
|
|
||||||
// Plus some debug-logging macros that get compiled to nothing for production
|
// Plus some debug-logging macros that get compiled to nothing for production
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#if DCHECK_IS_ON()
|
||||||
|
|
||||||
#define DLOG(severity) LOG(severity)
|
#define DLOG(severity) LOG(severity)
|
||||||
#define DVLOG(verboselevel) VLOG(verboselevel)
|
#define DVLOG(verboselevel) VLOG(verboselevel)
|
||||||
@@ -979,7 +996,7 @@ const LogSeverity GLOG_0 = GLOG_ERROR;
|
|||||||
LOG_IF_EVERY_N(severity, condition, n)
|
LOG_IF_EVERY_N(severity, condition, n)
|
||||||
#define DLOG_ASSERT(condition) LOG_ASSERT(condition)
|
#define DLOG_ASSERT(condition) LOG_ASSERT(condition)
|
||||||
|
|
||||||
// debug-only checking. not executed in NDEBUG mode.
|
// debug-only checking. executed if DCHECK_IS_ON().
|
||||||
#define DCHECK(condition) CHECK(condition)
|
#define DCHECK(condition) CHECK(condition)
|
||||||
#define DCHECK_EQ(val1, val2) CHECK_EQ(val1, val2)
|
#define DCHECK_EQ(val1, val2) CHECK_EQ(val1, val2)
|
||||||
#define DCHECK_NE(val1, val2) CHECK_NE(val1, val2)
|
#define DCHECK_NE(val1, val2) CHECK_NE(val1, val2)
|
||||||
@@ -993,7 +1010,7 @@ const LogSeverity GLOG_0 = GLOG_ERROR;
|
|||||||
#define DCHECK_STRNE(str1, str2) CHECK_STRNE(str1, str2)
|
#define DCHECK_STRNE(str1, str2) CHECK_STRNE(str1, str2)
|
||||||
#define DCHECK_STRCASENE(str1, str2) CHECK_STRCASENE(str1, str2)
|
#define DCHECK_STRCASENE(str1, str2) CHECK_STRCASENE(str1, str2)
|
||||||
|
|
||||||
#else // NDEBUG
|
#else // !DCHECK_IS_ON()
|
||||||
|
|
||||||
#define DLOG(severity) \
|
#define DLOG(severity) \
|
||||||
true ? (void) 0 : google::LogMessageVoidify() & LOG(severity)
|
true ? (void) 0 : google::LogMessageVoidify() & LOG(severity)
|
||||||
@@ -1074,7 +1091,7 @@ const LogSeverity GLOG_0 = GLOG_ERROR;
|
|||||||
while (false) \
|
while (false) \
|
||||||
GLOG_MSVC_POP_WARNING() CHECK_STRCASENE(str1, str2)
|
GLOG_MSVC_POP_WARNING() CHECK_STRCASENE(str1, str2)
|
||||||
|
|
||||||
#endif // NDEBUG
|
#endif // DCHECK_IS_ON()
|
||||||
|
|
||||||
// Log only in verbose mode.
|
// Log only in verbose mode.
|
||||||
|
|
||||||
@@ -1164,6 +1181,8 @@ public:
|
|||||||
char* str() const { return pbase(); }
|
char* str() const { return pbase(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
LogStream(const LogStream&);
|
||||||
|
LogStream& operator=(const LogStream&);
|
||||||
base_logging::LogStreamBuf streambuf_;
|
base_logging::LogStreamBuf streambuf_;
|
||||||
int ctr_; // Counter hack (for the LOG_EVERY_X() macro)
|
int ctr_; // Counter hack (for the LOG_EVERY_X() macro)
|
||||||
LogStream *self_; // Consistency check hack
|
LogStream *self_; // Consistency check hack
|
||||||
@@ -1231,7 +1250,7 @@ public:
|
|||||||
void SendToSyslogAndLog(); // Actually dispatch to syslog and the logs
|
void SendToSyslogAndLog(); // Actually dispatch to syslog and the logs
|
||||||
|
|
||||||
// Call abort() or similar to perform LOG(FATAL) crash.
|
// Call abort() or similar to perform LOG(FATAL) crash.
|
||||||
static void Fail() ;
|
static void __declspec(noreturn) Fail();
|
||||||
|
|
||||||
std::ostream& stream();
|
std::ostream& stream();
|
||||||
|
|
||||||
@@ -1279,7 +1298,7 @@ class GOOGLE_GLOG_DLL_DECL LogMessageFatal : public LogMessage {
|
|||||||
public:
|
public:
|
||||||
LogMessageFatal(const char* file, int line);
|
LogMessageFatal(const char* file, int line);
|
||||||
LogMessageFatal(const char* file, int line, const CheckOpString& result);
|
LogMessageFatal(const char* file, int line, const CheckOpString& result);
|
||||||
~LogMessageFatal() ;
|
__declspec(noreturn) ~LogMessageFatal();
|
||||||
};
|
};
|
||||||
|
|
||||||
// A non-macro interface to the log facility; (useful
|
// A non-macro interface to the log facility; (useful
|
||||||
@@ -1294,6 +1313,35 @@ inline void LogAtLevel(int const severity, std::string const &msg) {
|
|||||||
// LOG macros, 2. this macro can be used as C++ stream.
|
// LOG macros, 2. this macro can be used as C++ stream.
|
||||||
#define LOG_AT_LEVEL(severity) google::LogMessage(__FILE__, __LINE__, severity).stream()
|
#define LOG_AT_LEVEL(severity) google::LogMessage(__FILE__, __LINE__, severity).stream()
|
||||||
|
|
||||||
|
// Check if it's compiled in C++11 mode.
|
||||||
|
//
|
||||||
|
// GXX_EXPERIMENTAL_CXX0X is defined by gcc and clang up to at least
|
||||||
|
// gcc-4.7 and clang-3.1 (2011-12-13). __cplusplus was defined to 1
|
||||||
|
// in gcc before 4.7 (Crosstool 16) and clang before 3.1, but is
|
||||||
|
// defined according to the language version in effect thereafter.
|
||||||
|
// Microsoft Visual Studio 14 (2015) sets __cplusplus==199711 despite
|
||||||
|
// reasonably good C++11 support, so we set LANG_CXX for it and
|
||||||
|
// newer versions (_MSC_VER >= 1900).
|
||||||
|
#if (defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L || \
|
||||||
|
(defined(_MSC_VER) && _MSC_VER >= 1900))
|
||||||
|
// Helper for CHECK_NOTNULL().
|
||||||
|
//
|
||||||
|
// In C++11, all cases can be handled by a single function. Since the value
|
||||||
|
// category of the argument is preserved (also for rvalue references),
|
||||||
|
// member initializer lists like the one below will compile correctly:
|
||||||
|
//
|
||||||
|
// Foo()
|
||||||
|
// : x_(CHECK_NOTNULL(MethodReturningUniquePtr())) {}
|
||||||
|
template <typename T>
|
||||||
|
T CheckNotNull(const char* file, int line, const char* names, T&& t) {
|
||||||
|
if (t == nullptr) {
|
||||||
|
LogMessageFatal(file, line, new std::string(names));
|
||||||
|
}
|
||||||
|
return std::forward<T>(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
// A small helper for CHECK_NOTNULL().
|
// A small helper for CHECK_NOTNULL().
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T* CheckNotNull(const char *file, int line, const char *names, T* t) {
|
T* CheckNotNull(const char *file, int line, const char *names, T* t) {
|
||||||
@@ -1302,6 +1350,7 @@ T* CheckNotNull(const char *file, int line, const char *names, T* t) {
|
|||||||
}
|
}
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Allow folks to put a counter in the LOG_EVERY_X()'ed messages. This
|
// Allow folks to put a counter in the LOG_EVERY_X()'ed messages. This
|
||||||
// only works if ostream is a LogStream. If the ostream is not a
|
// only works if ostream is a LogStream. If the ostream is not a
|
||||||
@@ -1583,7 +1632,7 @@ class GOOGLE_GLOG_DLL_DECL NullStreamFatal : public NullStream {
|
|||||||
NullStreamFatal() { }
|
NullStreamFatal() { }
|
||||||
NullStreamFatal(const char* file, int line, const CheckOpString& result) :
|
NullStreamFatal(const char* file, int line, const CheckOpString& result) :
|
||||||
NullStream(file, line, result) { }
|
NullStream(file, line, result) { }
|
||||||
~NullStreamFatal() { _exit(1); }
|
__declspec(noreturn) ~NullStreamFatal() throw () { _exit(1); }
|
||||||
};
|
};
|
||||||
|
|
||||||
// Install a signal handler that will dump signal information and a stack
|
// Install a signal handler that will dump signal information and a stack
|
||||||
|
|||||||
224
extern/glog/src/windows/glog/stl_logging.h
vendored
Normal file
224
extern/glog/src/windows/glog/stl_logging.h
vendored
Normal file
@@ -0,0 +1,224 @@
|
|||||||
|
// This file is automatically generated from src/glog/stl_logging.h.in
|
||||||
|
// using src/windows/preprocess.sh.
|
||||||
|
// DO NOT EDIT!
|
||||||
|
|
||||||
|
// Copyright (c) 2003, Google Inc.
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
//
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Google Inc. nor the names of its
|
||||||
|
// contributors may be used to endorse or promote products derived from
|
||||||
|
// this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
// Stream output operators for STL containers; to be used for logging *only*.
|
||||||
|
// Inclusion of this file lets you do:
|
||||||
|
//
|
||||||
|
// list<string> x;
|
||||||
|
// LOG(INFO) << "data: " << x;
|
||||||
|
// vector<int> v1, v2;
|
||||||
|
// CHECK_EQ(v1, v2);
|
||||||
|
//
|
||||||
|
// If you want to use this header file with hash_compare maps or slist, you
|
||||||
|
// need to define macros before including this file:
|
||||||
|
//
|
||||||
|
// - GLOG_STL_LOGGING_FOR_UNORDERED - <unordered_map> and <unordered_set>
|
||||||
|
// - GLOG_STL_LOGGING_FOR_TR1_UNORDERED - <tr1/unordered_(map|set)>
|
||||||
|
// - GLOG_STL_LOGGING_FOR_EXT_HASH - <ext/hash_(map|set)>
|
||||||
|
// - GLOG_STL_LOGGING_FOR_EXT_SLIST - <ext/slist>
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef UTIL_GTL_STL_LOGGING_INL_H_
|
||||||
|
#define UTIL_GTL_STL_LOGGING_INL_H_
|
||||||
|
|
||||||
|
#if !1
|
||||||
|
# error We do not support stl_logging for this compiler
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <deque>
|
||||||
|
#include <list>
|
||||||
|
#include <map>
|
||||||
|
#include <ostream>
|
||||||
|
#include <set>
|
||||||
|
#include <utility>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#ifdef GLOG_STL_LOGGING_FOR_UNORDERED
|
||||||
|
# include <unordered_map>
|
||||||
|
# include <unordered_set>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef GLOG_STL_LOGGING_FOR_TR1_UNORDERED
|
||||||
|
# include <tr1/unordered_map>
|
||||||
|
# include <tr1/unordered_set>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef GLOG_STL_LOGGING_FOR_EXT_HASH
|
||||||
|
# include <ext/hash_set>
|
||||||
|
# include <ext/hash_map>
|
||||||
|
#endif
|
||||||
|
#ifdef GLOG_STL_LOGGING_FOR_EXT_SLIST
|
||||||
|
# include <ext/slist>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Forward declare these two, and define them after all the container streams
|
||||||
|
// operators so that we can recurse from pair -> container -> container -> pair
|
||||||
|
// properly.
|
||||||
|
template<class First, class Second>
|
||||||
|
std::ostream& operator<<(std::ostream& out, const std::pair<First, Second>& p);
|
||||||
|
|
||||||
|
namespace google {
|
||||||
|
|
||||||
|
template<class Iter>
|
||||||
|
void PrintSequence(std::ostream& out, Iter begin, Iter end);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#define OUTPUT_TWO_ARG_CONTAINER(Sequence) \
|
||||||
|
template<class T1, class T2> \
|
||||||
|
inline std::ostream& operator<<(std::ostream& out, \
|
||||||
|
const Sequence<T1, T2>& seq) { \
|
||||||
|
google::PrintSequence(out, seq.begin(), seq.end()); \
|
||||||
|
return out; \
|
||||||
|
}
|
||||||
|
|
||||||
|
OUTPUT_TWO_ARG_CONTAINER(std::vector)
|
||||||
|
OUTPUT_TWO_ARG_CONTAINER(std::deque)
|
||||||
|
OUTPUT_TWO_ARG_CONTAINER(std::list)
|
||||||
|
#ifdef GLOG_STL_LOGGING_FOR_EXT_SLIST
|
||||||
|
OUTPUT_TWO_ARG_CONTAINER(__gnu_cxx::slist)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#undef OUTPUT_TWO_ARG_CONTAINER
|
||||||
|
|
||||||
|
#define OUTPUT_THREE_ARG_CONTAINER(Sequence) \
|
||||||
|
template<class T1, class T2, class T3> \
|
||||||
|
inline std::ostream& operator<<(std::ostream& out, \
|
||||||
|
const Sequence<T1, T2, T3>& seq) { \
|
||||||
|
google::PrintSequence(out, seq.begin(), seq.end()); \
|
||||||
|
return out; \
|
||||||
|
}
|
||||||
|
|
||||||
|
OUTPUT_THREE_ARG_CONTAINER(std::set)
|
||||||
|
OUTPUT_THREE_ARG_CONTAINER(std::multiset)
|
||||||
|
|
||||||
|
#undef OUTPUT_THREE_ARG_CONTAINER
|
||||||
|
|
||||||
|
#define OUTPUT_FOUR_ARG_CONTAINER(Sequence) \
|
||||||
|
template<class T1, class T2, class T3, class T4> \
|
||||||
|
inline std::ostream& operator<<(std::ostream& out, \
|
||||||
|
const Sequence<T1, T2, T3, T4>& seq) { \
|
||||||
|
google::PrintSequence(out, seq.begin(), seq.end()); \
|
||||||
|
return out; \
|
||||||
|
}
|
||||||
|
|
||||||
|
OUTPUT_FOUR_ARG_CONTAINER(std::map)
|
||||||
|
OUTPUT_FOUR_ARG_CONTAINER(std::multimap)
|
||||||
|
#ifdef GLOG_STL_LOGGING_FOR_UNORDERED
|
||||||
|
OUTPUT_FOUR_ARG_CONTAINER(std::unordered_set)
|
||||||
|
OUTPUT_FOUR_ARG_CONTAINER(std::unordered_multiset)
|
||||||
|
#endif
|
||||||
|
#ifdef GLOG_STL_LOGGING_FOR_TR1_UNORDERED
|
||||||
|
OUTPUT_FOUR_ARG_CONTAINER(std::tr1::unordered_set)
|
||||||
|
OUTPUT_FOUR_ARG_CONTAINER(std::tr1::unordered_multiset)
|
||||||
|
#endif
|
||||||
|
#ifdef GLOG_STL_LOGGING_FOR_EXT_HASH
|
||||||
|
OUTPUT_FOUR_ARG_CONTAINER(__gnu_cxx::hash_set)
|
||||||
|
OUTPUT_FOUR_ARG_CONTAINER(__gnu_cxx::hash_multiset)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#undef OUTPUT_FOUR_ARG_CONTAINER
|
||||||
|
|
||||||
|
#define OUTPUT_FIVE_ARG_CONTAINER(Sequence) \
|
||||||
|
template<class T1, class T2, class T3, class T4, class T5> \
|
||||||
|
inline std::ostream& operator<<(std::ostream& out, \
|
||||||
|
const Sequence<T1, T2, T3, T4, T5>& seq) { \
|
||||||
|
google::PrintSequence(out, seq.begin(), seq.end()); \
|
||||||
|
return out; \
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef GLOG_STL_LOGGING_FOR_UNORDERED
|
||||||
|
OUTPUT_FIVE_ARG_CONTAINER(std::unordered_map)
|
||||||
|
OUTPUT_FIVE_ARG_CONTAINER(std::unordered_multimap)
|
||||||
|
#endif
|
||||||
|
#ifdef GLOG_STL_LOGGING_FOR_TR1_UNORDERED
|
||||||
|
OUTPUT_FIVE_ARG_CONTAINER(std::tr1::unordered_map)
|
||||||
|
OUTPUT_FIVE_ARG_CONTAINER(std::tr1::unordered_multimap)
|
||||||
|
#endif
|
||||||
|
#ifdef GLOG_STL_LOGGING_FOR_EXT_HASH
|
||||||
|
OUTPUT_FIVE_ARG_CONTAINER(__gnu_cxx::hash_map)
|
||||||
|
OUTPUT_FIVE_ARG_CONTAINER(__gnu_cxx::hash_multimap)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#undef OUTPUT_FIVE_ARG_CONTAINER
|
||||||
|
|
||||||
|
template<class First, class Second>
|
||||||
|
inline std::ostream& operator<<(std::ostream& out,
|
||||||
|
const std::pair<First, Second>& p) {
|
||||||
|
out << '(' << p.first << ", " << p.second << ')';
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace google {
|
||||||
|
|
||||||
|
template<class Iter>
|
||||||
|
inline void PrintSequence(std::ostream& out, Iter begin, Iter end) {
|
||||||
|
// Output at most 100 elements -- appropriate if used for logging.
|
||||||
|
for (int i = 0; begin != end && i < 100; ++i, ++begin) {
|
||||||
|
if (i > 0) out << ' ';
|
||||||
|
out << *begin;
|
||||||
|
}
|
||||||
|
if (begin != end) {
|
||||||
|
out << " ...";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Note that this is technically undefined behavior! We are adding things into
|
||||||
|
// the std namespace for a reason though -- we are providing new operations on
|
||||||
|
// types which are themselves defined with this namespace. Without this, these
|
||||||
|
// operator overloads cannot be found via ADL. If these definitions are not
|
||||||
|
// found via ADL, they must be #included before they're used, which requires
|
||||||
|
// this header to be included before apparently independent other headers.
|
||||||
|
//
|
||||||
|
// For example, base/logging.h defines various template functions to implement
|
||||||
|
// CHECK_EQ(x, y) and stream x and y into the log in the event the check fails.
|
||||||
|
// It does so via the function template MakeCheckOpValueString:
|
||||||
|
// template<class T>
|
||||||
|
// void MakeCheckOpValueString(strstream* ss, const T& v) {
|
||||||
|
// (*ss) << v;
|
||||||
|
// }
|
||||||
|
// Because 'glog/logging.h' is included before 'glog/stl_logging.h',
|
||||||
|
// subsequent CHECK_EQ(v1, v2) for vector<...> typed variable v1 and v2 can only
|
||||||
|
// find these operator definitions via ADL.
|
||||||
|
//
|
||||||
|
// Even this solution has problems -- it may pull unintended operators into the
|
||||||
|
// namespace as well, allowing them to also be found via ADL, and creating code
|
||||||
|
// that only works with a particular order of includes. Long term, we need to
|
||||||
|
// move all of the *definitions* into namespace std, bet we need to ensure no
|
||||||
|
// one references them first. This lets us take that step. We cannot define them
|
||||||
|
// in both because that would create ambiguous overloads when both are found.
|
||||||
|
namespace std { using ::operator<<; }
|
||||||
|
|
||||||
|
#endif // UTIL_GTL_STL_LOGGING_INL_H_
|
||||||
7
extern/glog/src/windows/port.h
vendored
7
extern/glog/src/windows/port.h
vendored
@@ -136,6 +136,7 @@ typedef int pid_t;
|
|||||||
#endif // _MSC_VER
|
#endif // _MSC_VER
|
||||||
|
|
||||||
// ----------------------------------- THREADS
|
// ----------------------------------- THREADS
|
||||||
|
#ifndef __MINGW32__
|
||||||
typedef DWORD pthread_t;
|
typedef DWORD pthread_t;
|
||||||
typedef DWORD pthread_key_t;
|
typedef DWORD pthread_key_t;
|
||||||
typedef LONG pthread_once_t;
|
typedef LONG pthread_once_t;
|
||||||
@@ -147,15 +148,11 @@ inline struct tm* localtime_r(const time_t* timep, struct tm* result) {
|
|||||||
localtime_s(result, timep);
|
localtime_s(result, timep);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
inline char* strerror_r(int errnum, char* buf, size_t buflen) {
|
inline char* strerror_r(int errnum, char* buf, size_t buflen) {
|
||||||
#ifdef FREE_WINDOWS
|
|
||||||
strncpy(buf, "Not implemented yet", buflen);
|
|
||||||
return buf;
|
|
||||||
#else
|
|
||||||
strerror_s(buf, buflen, errnum);
|
strerror_s(buf, buflen, errnum);
|
||||||
return buf;
|
return buf;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef __cplusplus
|
#ifndef __cplusplus
|
||||||
|
|||||||
126
extern/gmock/CHANGES
vendored
Normal file
126
extern/gmock/CHANGES
vendored
Normal file
@@ -0,0 +1,126 @@
|
|||||||
|
Changes for 1.7.0:
|
||||||
|
|
||||||
|
* All new improvements in Google Test 1.7.0.
|
||||||
|
* New feature: matchers DoubleNear(), FloatNear(),
|
||||||
|
NanSensitiveDoubleNear(), NanSensitiveFloatNear(),
|
||||||
|
UnorderedElementsAre(), UnorderedElementsAreArray(), WhenSorted(),
|
||||||
|
WhenSortedBy(), IsEmpty(), and SizeIs().
|
||||||
|
* Improvement: Google Mock can now be built as a DLL.
|
||||||
|
* Improvement: when compiled by a C++11 compiler, matchers AllOf()
|
||||||
|
and AnyOf() can accept an arbitrary number of matchers.
|
||||||
|
* Improvement: when compiled by a C++11 compiler, matchers
|
||||||
|
ElementsAreArray() can accept an initializer list.
|
||||||
|
* Improvement: when exceptions are enabled, a mock method with no
|
||||||
|
default action now throws instead crashing the test.
|
||||||
|
* Improvement: added class testing::StringMatchResultListener to aid
|
||||||
|
definition of composite matchers.
|
||||||
|
* Improvement: function return types used in MOCK_METHOD*() macros can
|
||||||
|
now contain unprotected commas.
|
||||||
|
* Improvement (potentially breaking): EXPECT_THAT() and ASSERT_THAT()
|
||||||
|
are now more strict in ensuring that the value type and the matcher
|
||||||
|
type are compatible, catching potential bugs in tests.
|
||||||
|
* Improvement: Pointee() now works on an optional<T>.
|
||||||
|
* Improvement: the ElementsAreArray() matcher can now take a vector or
|
||||||
|
iterator range as input, and makes a copy of its input elements
|
||||||
|
before the conversion to a Matcher.
|
||||||
|
* Improvement: the Google Mock Generator can now generate mocks for
|
||||||
|
some class templates.
|
||||||
|
* Bug fix: mock object destruction triggerred by another mock object's
|
||||||
|
destruction no longer hangs.
|
||||||
|
* Improvement: Google Mock Doctor works better with newer Clang and
|
||||||
|
GCC now.
|
||||||
|
* Compatibility fixes.
|
||||||
|
* Bug/warning fixes.
|
||||||
|
|
||||||
|
Changes for 1.6.0:
|
||||||
|
|
||||||
|
* Compilation is much faster and uses much less memory, especially
|
||||||
|
when the constructor and destructor of a mock class are moved out of
|
||||||
|
the class body.
|
||||||
|
* New matchers: Pointwise(), Each().
|
||||||
|
* New actions: ReturnPointee() and ReturnRefOfCopy().
|
||||||
|
* CMake support.
|
||||||
|
* Project files for Visual Studio 2010.
|
||||||
|
* AllOf() and AnyOf() can handle up-to 10 arguments now.
|
||||||
|
* Google Mock doctor understands Clang error messages now.
|
||||||
|
* SetArgPointee<> now accepts string literals.
|
||||||
|
* gmock_gen.py handles storage specifier macros and template return
|
||||||
|
types now.
|
||||||
|
* Compatibility fixes.
|
||||||
|
* Bug fixes and implementation clean-ups.
|
||||||
|
* Potentially incompatible changes: disables the harmful 'make install'
|
||||||
|
command in autotools.
|
||||||
|
|
||||||
|
Potentially breaking changes:
|
||||||
|
|
||||||
|
* The description string for MATCHER*() changes from Python-style
|
||||||
|
interpolation to an ordinary C++ string expression.
|
||||||
|
* SetArgumentPointee is deprecated in favor of SetArgPointee.
|
||||||
|
* Some non-essential project files for Visual Studio 2005 are removed.
|
||||||
|
|
||||||
|
Changes for 1.5.0:
|
||||||
|
|
||||||
|
* New feature: Google Mock can be safely used in multi-threaded tests
|
||||||
|
on platforms having pthreads.
|
||||||
|
* New feature: function for printing a value of arbitrary type.
|
||||||
|
* New feature: function ExplainMatchResult() for easy definition of
|
||||||
|
composite matchers.
|
||||||
|
* The new matcher API lets user-defined matchers generate custom
|
||||||
|
explanations more directly and efficiently.
|
||||||
|
* Better failure messages all around.
|
||||||
|
* NotNull() and IsNull() now work with smart pointers.
|
||||||
|
* Field() and Property() now work when the matcher argument is a pointer
|
||||||
|
passed by reference.
|
||||||
|
* Regular expression matchers on all platforms.
|
||||||
|
* Added GCC 4.0 support for Google Mock Doctor.
|
||||||
|
* Added gmock_all_test.cc for compiling most Google Mock tests
|
||||||
|
in a single file.
|
||||||
|
* Significantly cleaned up compiler warnings.
|
||||||
|
* Bug fixes, better test coverage, and implementation clean-ups.
|
||||||
|
|
||||||
|
Potentially breaking changes:
|
||||||
|
|
||||||
|
* Custom matchers defined using MatcherInterface or MakePolymorphicMatcher()
|
||||||
|
need to be updated after upgrading to Google Mock 1.5.0; matchers defined
|
||||||
|
using MATCHER or MATCHER_P* aren't affected.
|
||||||
|
* Dropped support for 'make install'.
|
||||||
|
|
||||||
|
Changes for 1.4.0 (we skipped 1.2.* and 1.3.* to match the version of
|
||||||
|
Google Test):
|
||||||
|
|
||||||
|
* Works in more environments: Symbian and minGW, Visual C++ 7.1.
|
||||||
|
* Lighter weight: comes with our own implementation of TR1 tuple (no
|
||||||
|
more dependency on Boost!).
|
||||||
|
* New feature: --gmock_catch_leaked_mocks for detecting leaked mocks.
|
||||||
|
* New feature: ACTION_TEMPLATE for defining templatized actions.
|
||||||
|
* New feature: the .After() clause for specifying expectation order.
|
||||||
|
* New feature: the .With() clause for for specifying inter-argument
|
||||||
|
constraints.
|
||||||
|
* New feature: actions ReturnArg<k>(), ReturnNew<T>(...), and
|
||||||
|
DeleteArg<k>().
|
||||||
|
* New feature: matchers Key(), Pair(), Args<...>(), AllArgs(), IsNull(),
|
||||||
|
and Contains().
|
||||||
|
* New feature: utility class MockFunction<F>, useful for checkpoints, etc.
|
||||||
|
* New feature: functions Value(x, m) and SafeMatcherCast<T>(m).
|
||||||
|
* New feature: copying a mock object is rejected at compile time.
|
||||||
|
* New feature: a script for fusing all Google Mock and Google Test
|
||||||
|
source files for easy deployment.
|
||||||
|
* Improved the Google Mock doctor to diagnose more diseases.
|
||||||
|
* Improved the Google Mock generator script.
|
||||||
|
* Compatibility fixes for Mac OS X and gcc.
|
||||||
|
* Bug fixes and implementation clean-ups.
|
||||||
|
|
||||||
|
Changes for 1.1.0:
|
||||||
|
|
||||||
|
* New feature: ability to use Google Mock with any testing framework.
|
||||||
|
* New feature: macros for easily defining new matchers
|
||||||
|
* New feature: macros for easily defining new actions.
|
||||||
|
* New feature: more container matchers.
|
||||||
|
* New feature: actions for accessing function arguments and throwing
|
||||||
|
exceptions.
|
||||||
|
* Improved the Google Mock doctor script for diagnosing compiler errors.
|
||||||
|
* Bug fixes and implementation clean-ups.
|
||||||
|
|
||||||
|
Changes for 1.0.0:
|
||||||
|
|
||||||
|
* Initial Open Source release of Google Mock
|
||||||
40
extern/gmock/CONTRIBUTORS
vendored
Normal file
40
extern/gmock/CONTRIBUTORS
vendored
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
# This file contains a list of people who've made non-trivial
|
||||||
|
# contribution to the Google C++ Mocking Framework project. People
|
||||||
|
# who commit code to the project are encouraged to add their names
|
||||||
|
# here. Please keep the list sorted by first names.
|
||||||
|
|
||||||
|
Benoit Sigoure <tsuna@google.com>
|
||||||
|
Bogdan Piloca <boo@google.com>
|
||||||
|
Chandler Carruth <chandlerc@google.com>
|
||||||
|
Dave MacLachlan <dmaclach@gmail.com>
|
||||||
|
David Anderson <danderson@google.com>
|
||||||
|
Dean Sturtevant
|
||||||
|
Gene Volovich <gv@cite.com>
|
||||||
|
Hal Burch <gmock@hburch.com>
|
||||||
|
Jeffrey Yasskin <jyasskin@google.com>
|
||||||
|
Jim Keller <jimkeller@google.com>
|
||||||
|
Joe Walnes <joe@truemesh.com>
|
||||||
|
Jon Wray <jwray@google.com>
|
||||||
|
Keir Mierle <mierle@gmail.com>
|
||||||
|
Keith Ray <keith.ray@gmail.com>
|
||||||
|
Kostya Serebryany <kcc@google.com>
|
||||||
|
Lev Makhlis
|
||||||
|
Manuel Klimek <klimek@google.com>
|
||||||
|
Mario Tanev <radix@google.com>
|
||||||
|
Mark Paskin
|
||||||
|
Markus Heule <markus.heule@gmail.com>
|
||||||
|
Matthew Simmons <simmonmt@acm.org>
|
||||||
|
Mike Bland <mbland@google.com>
|
||||||
|
Neal Norwitz <nnorwitz@gmail.com>
|
||||||
|
Nermin Ozkiranartli <nermin@google.com>
|
||||||
|
Owen Carlsen <ocarlsen@google.com>
|
||||||
|
Paneendra Ba <paneendra@google.com>
|
||||||
|
Paul Menage <menage@google.com>
|
||||||
|
Piotr Kaminski <piotrk@google.com>
|
||||||
|
Russ Rufer <russ@pentad.com>
|
||||||
|
Sverre Sundsdal <sundsdal@gmail.com>
|
||||||
|
Takeshi Yoshino <tyoshino@google.com>
|
||||||
|
Vadim Berman <vadimb@google.com>
|
||||||
|
Vlad Losev <vladl@google.com>
|
||||||
|
Wolfgang Klier <wklier@google.com>
|
||||||
|
Zhanyong Wan <wan@google.com>
|
||||||
2
extern/gmock/README.blender
vendored
2
extern/gmock/README.blender
vendored
@@ -1,7 +1,7 @@
|
|||||||
Project: Google C++ Testing Framework
|
Project: Google C++ Testing Framework
|
||||||
URL: https://github.com/google/googletest
|
URL: https://github.com/google/googletest
|
||||||
License: New BSD
|
License: New BSD
|
||||||
Upstream version: 1.7.0 (ec44c6c)
|
Upstream version: 1.8.0 (ec44c6c1675)
|
||||||
Local modifications:
|
Local modifications:
|
||||||
|
|
||||||
None.
|
None.
|
||||||
|
|||||||
2
extern/gtest/README.blender
vendored
2
extern/gtest/README.blender
vendored
@@ -1,7 +1,7 @@
|
|||||||
Project: Google C++ Testing Framework
|
Project: Google C++ Testing Framework
|
||||||
URL: https://github.com/google/googletest
|
URL: https://github.com/google/googletest
|
||||||
License: New BSD
|
License: New BSD
|
||||||
Upstream version: 1.7.0 (ec44c6c)
|
Upstream version: 1.8.0 (ec44c6c1675)
|
||||||
Local modifications:
|
Local modifications:
|
||||||
|
|
||||||
None.
|
None.
|
||||||
|
|||||||
138
extern/gtest/README.md
vendored
Normal file
138
extern/gtest/README.md
vendored
Normal file
@@ -0,0 +1,138 @@
|
|||||||
|
|
||||||
|
# Google Test #
|
||||||
|
|
||||||
|
[](https://travis-ci.org/google/googletest)
|
||||||
|
|
||||||
|
Welcome to **Google Test**, Google's C++ test framework!
|
||||||
|
|
||||||
|
This repository is a merger of the formerly separate GoogleTest and
|
||||||
|
GoogleMock projects. These were so closely related that it makes sense to
|
||||||
|
maintain and release them together.
|
||||||
|
|
||||||
|
Please see the project page above for more information as well as the
|
||||||
|
mailing list for questions, discussions, and development. There is
|
||||||
|
also an IRC channel on OFTC (irc.oftc.net) #gtest available. Please
|
||||||
|
join us!
|
||||||
|
|
||||||
|
**Google Mock** is an extension to Google Test for writing and using C++ mock
|
||||||
|
classes. See the separate [Google Mock documentation](googlemock/README.md).
|
||||||
|
|
||||||
|
More detailed documentation for googletest (including build instructions) are
|
||||||
|
in its interior [googletest/README.md](googletest/README.md) file.
|
||||||
|
|
||||||
|
## Features ##
|
||||||
|
|
||||||
|
* An [XUnit](https://en.wikipedia.org/wiki/XUnit) test framework.
|
||||||
|
* Test discovery.
|
||||||
|
* A rich set of assertions.
|
||||||
|
* User-defined assertions.
|
||||||
|
* Death tests.
|
||||||
|
* Fatal and non-fatal failures.
|
||||||
|
* Value-parameterized tests.
|
||||||
|
* Type-parameterized tests.
|
||||||
|
* Various options for running the tests.
|
||||||
|
* XML test report generation.
|
||||||
|
|
||||||
|
## Platforms ##
|
||||||
|
|
||||||
|
Google test has been used on a variety of platforms:
|
||||||
|
|
||||||
|
* Linux
|
||||||
|
* Mac OS X
|
||||||
|
* Windows
|
||||||
|
* Cygwin
|
||||||
|
* MinGW
|
||||||
|
* Windows Mobile
|
||||||
|
* Symbian
|
||||||
|
|
||||||
|
## Who Is Using Google Test? ##
|
||||||
|
|
||||||
|
In addition to many internal projects at Google, Google Test is also used by
|
||||||
|
the following notable projects:
|
||||||
|
|
||||||
|
* The [Chromium projects](http://www.chromium.org/) (behind the Chrome
|
||||||
|
browser and Chrome OS).
|
||||||
|
* The [LLVM](http://llvm.org/) compiler.
|
||||||
|
* [Protocol Buffers](https://github.com/google/protobuf), Google's data
|
||||||
|
interchange format.
|
||||||
|
* The [OpenCV](http://opencv.org/) computer vision library.
|
||||||
|
|
||||||
|
## Related Open Source Projects ##
|
||||||
|
|
||||||
|
[Google Test UI](https://github.com/ospector/gtest-gbar) is test runner that runs
|
||||||
|
your test binary, allows you to track its progress via a progress bar, and
|
||||||
|
displays a list of test failures. Clicking on one shows failure text. Google
|
||||||
|
Test UI is written in C#.
|
||||||
|
|
||||||
|
[GTest TAP Listener](https://github.com/kinow/gtest-tap-listener) is an event
|
||||||
|
listener for Google Test that implements the
|
||||||
|
[TAP protocol](https://en.wikipedia.org/wiki/Test_Anything_Protocol) for test
|
||||||
|
result output. If your test runner understands TAP, you may find it useful.
|
||||||
|
|
||||||
|
## Requirements ##
|
||||||
|
|
||||||
|
Google Test is designed to have fairly minimal requirements to build
|
||||||
|
and use with your projects, but there are some. Currently, we support
|
||||||
|
Linux, Windows, Mac OS X, and Cygwin. We will also make our best
|
||||||
|
effort to support other platforms (e.g. Solaris, AIX, and z/OS).
|
||||||
|
However, since core members of the Google Test project have no access
|
||||||
|
to these platforms, Google Test may have outstanding issues there. If
|
||||||
|
you notice any problems on your platform, please notify
|
||||||
|
<googletestframework@googlegroups.com>. Patches for fixing them are
|
||||||
|
even more welcome!
|
||||||
|
|
||||||
|
### Linux Requirements ###
|
||||||
|
|
||||||
|
These are the base requirements to build and use Google Test from a source
|
||||||
|
package (as described below):
|
||||||
|
|
||||||
|
* GNU-compatible Make or gmake
|
||||||
|
* POSIX-standard shell
|
||||||
|
* POSIX(-2) Regular Expressions (regex.h)
|
||||||
|
* A C++98-standard-compliant compiler
|
||||||
|
|
||||||
|
### Windows Requirements ###
|
||||||
|
|
||||||
|
* Microsoft Visual C++ v7.1 or newer
|
||||||
|
|
||||||
|
### Cygwin Requirements ###
|
||||||
|
|
||||||
|
* Cygwin v1.5.25-14 or newer
|
||||||
|
|
||||||
|
### Mac OS X Requirements ###
|
||||||
|
|
||||||
|
* Mac OS X v10.4 Tiger or newer
|
||||||
|
* XCode Developer Tools
|
||||||
|
|
||||||
|
### Requirements for Contributors ###
|
||||||
|
|
||||||
|
We welcome patches. If you plan to contribute a patch, you need to
|
||||||
|
build Google Test and its own tests from a git checkout (described
|
||||||
|
below), which has further requirements:
|
||||||
|
|
||||||
|
* [Python](https://www.python.org/) v2.3 or newer (for running some of
|
||||||
|
the tests and re-generating certain source files from templates)
|
||||||
|
* [CMake](https://cmake.org/) v2.6.4 or newer
|
||||||
|
|
||||||
|
## Regenerating Source Files ##
|
||||||
|
|
||||||
|
Some of Google Test's source files are generated from templates (not
|
||||||
|
in the C++ sense) using a script.
|
||||||
|
For example, the
|
||||||
|
file include/gtest/internal/gtest-type-util.h.pump is used to generate
|
||||||
|
gtest-type-util.h in the same directory.
|
||||||
|
|
||||||
|
You don't need to worry about regenerating the source files
|
||||||
|
unless you need to modify them. You would then modify the
|
||||||
|
corresponding `.pump` files and run the '[pump.py](googletest/scripts/pump.py)'
|
||||||
|
generator script. See the [Pump Manual](googletest/docs/PumpManual.md).
|
||||||
|
|
||||||
|
### Contributing Code ###
|
||||||
|
|
||||||
|
We welcome patches. Please read the
|
||||||
|
[Developer's Guide](googletest/docs/DevGuide.md)
|
||||||
|
for how you can contribute. In particular, make sure you have signed
|
||||||
|
the Contributor License Agreement, or we won't be able to accept the
|
||||||
|
patch.
|
||||||
|
|
||||||
|
Happy testing!
|
||||||
8
extern/gtest/include/gtest/gtest-printers.h
vendored
8
extern/gtest/include/gtest/gtest-printers.h
vendored
@@ -103,7 +103,7 @@
|
|||||||
#include "gtest/internal/gtest-port.h"
|
#include "gtest/internal/gtest-port.h"
|
||||||
#include "gtest/internal/gtest-internal.h"
|
#include "gtest/internal/gtest-internal.h"
|
||||||
|
|
||||||
#if defined(GTEST_HAS_STD_TUPLE_) && GTEST_HAS_STD_TUPLE_
|
#if GTEST_HAS_STD_TUPLE_
|
||||||
# include <tuple>
|
# include <tuple>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -581,7 +581,7 @@ inline void PrintTo(const ::std::wstring& s, ::std::ostream* os) {
|
|||||||
}
|
}
|
||||||
#endif // GTEST_HAS_STD_WSTRING
|
#endif // GTEST_HAS_STD_WSTRING
|
||||||
|
|
||||||
#if GTEST_HAS_TR1_TUPLE || (defined(GTEST_HAS_STD_TUPLE_) && GTEST_HAS_STD_TUPLE_)
|
#if GTEST_HAS_TR1_TUPLE || GTEST_HAS_STD_TUPLE_
|
||||||
// Helper function for printing a tuple. T must be instantiated with
|
// Helper function for printing a tuple. T must be instantiated with
|
||||||
// a tuple type.
|
// a tuple type.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@@ -664,7 +664,7 @@ void PrintTo(
|
|||||||
}
|
}
|
||||||
#endif // GTEST_HAS_TR1_TUPLE
|
#endif // GTEST_HAS_TR1_TUPLE
|
||||||
|
|
||||||
#if defined(GTEST_HAS_STD_TUPLE_) && GTEST_HAS_STD_TUPLE_
|
#if GTEST_HAS_STD_TUPLE_
|
||||||
template <typename... Types>
|
template <typename... Types>
|
||||||
void PrintTo(const ::std::tuple<Types...>& t, ::std::ostream* os) {
|
void PrintTo(const ::std::tuple<Types...>& t, ::std::ostream* os) {
|
||||||
PrintTupleTo(t, os);
|
PrintTupleTo(t, os);
|
||||||
@@ -888,7 +888,7 @@ template <typename TupleT>
|
|||||||
const size_t TuplePolicy<TupleT>::tuple_size;
|
const size_t TuplePolicy<TupleT>::tuple_size;
|
||||||
#endif // GTEST_HAS_TR1_TUPLE
|
#endif // GTEST_HAS_TR1_TUPLE
|
||||||
|
|
||||||
#if defined(GTEST_HAS_STD_TUPLE_) && GTEST_HAS_STD_TUPLE_
|
#if GTEST_HAS_STD_TUPLE_
|
||||||
template <typename... Types>
|
template <typename... Types>
|
||||||
struct TuplePolicy< ::std::tuple<Types...> > {
|
struct TuplePolicy< ::std::tuple<Types...> > {
|
||||||
typedef ::std::tuple<Types...> Tuple;
|
typedef ::std::tuple<Types...> Tuple;
|
||||||
|
|||||||
18
extern/gtest/include/gtest/gtest.h
vendored
18
extern/gtest/include/gtest/gtest.h
vendored
@@ -1818,7 +1818,7 @@ class TestWithParam : public Test, public WithParamInterface<T> {
|
|||||||
|
|
||||||
// Define this macro to 1 to omit the definition of FAIL(), which is a
|
// Define this macro to 1 to omit the definition of FAIL(), which is a
|
||||||
// generic name and clashes with some other libraries.
|
// generic name and clashes with some other libraries.
|
||||||
#if !defined(GTEST_DONT_DEFINE_FAIL) || !GTEST_DONT_DEFINE_FAIL
|
#if !GTEST_DONT_DEFINE_FAIL
|
||||||
# define FAIL() GTEST_FAIL()
|
# define FAIL() GTEST_FAIL()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -1827,7 +1827,7 @@ class TestWithParam : public Test, public WithParamInterface<T> {
|
|||||||
|
|
||||||
// Define this macro to 1 to omit the definition of SUCCEED(), which
|
// Define this macro to 1 to omit the definition of SUCCEED(), which
|
||||||
// is a generic name and clashes with some other libraries.
|
// is a generic name and clashes with some other libraries.
|
||||||
#if !defined(GTEST_DONT_DEFINE_SUCCEED) || !GTEST_DONT_DEFINE_SUCCEED
|
#if !GTEST_DONT_DEFINE_SUCCEED
|
||||||
# define SUCCEED() GTEST_SUCCEED()
|
# define SUCCEED() GTEST_SUCCEED()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -1952,27 +1952,27 @@ class TestWithParam : public Test, public WithParamInterface<T> {
|
|||||||
// Define macro GTEST_DONT_DEFINE_ASSERT_XY to 1 to omit the definition of
|
// Define macro GTEST_DONT_DEFINE_ASSERT_XY to 1 to omit the definition of
|
||||||
// ASSERT_XY(), which clashes with some users' own code.
|
// ASSERT_XY(), which clashes with some users' own code.
|
||||||
|
|
||||||
#if !defined(GTEST_DONT_DEFINE_ASSERT_EQ) || !GTEST_DONT_DEFINE_ASSERT_EQ
|
#if !GTEST_DONT_DEFINE_ASSERT_EQ
|
||||||
# define ASSERT_EQ(val1, val2) GTEST_ASSERT_EQ(val1, val2)
|
# define ASSERT_EQ(val1, val2) GTEST_ASSERT_EQ(val1, val2)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(GTEST_DONT_DEFINE_ASSERT_NE) || !GTEST_DONT_DEFINE_ASSERT_NE
|
#if !GTEST_DONT_DEFINE_ASSERT_NE
|
||||||
# define ASSERT_NE(val1, val2) GTEST_ASSERT_NE(val1, val2)
|
# define ASSERT_NE(val1, val2) GTEST_ASSERT_NE(val1, val2)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(GTEST_DONT_DEFINE_ASSERT_LE) || !GTEST_DONT_DEFINE_ASSERT_LE
|
#if !GTEST_DONT_DEFINE_ASSERT_LE
|
||||||
# define ASSERT_LE(val1, val2) GTEST_ASSERT_LE(val1, val2)
|
# define ASSERT_LE(val1, val2) GTEST_ASSERT_LE(val1, val2)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(GTEST_DONT_DEFINE_ASSERT_LT) || !GTEST_DONT_DEFINE_ASSERT_LT
|
#if !GTEST_DONT_DEFINE_ASSERT_LT
|
||||||
# define ASSERT_LT(val1, val2) GTEST_ASSERT_LT(val1, val2)
|
# define ASSERT_LT(val1, val2) GTEST_ASSERT_LT(val1, val2)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(GTEST_DONT_DEFINE_ASSERT_GE) || !GTEST_DONT_DEFINE_ASSERT_GE
|
#if !GTEST_DONT_DEFINE_ASSERT_GE
|
||||||
# define ASSERT_GE(val1, val2) GTEST_ASSERT_GE(val1, val2)
|
# define ASSERT_GE(val1, val2) GTEST_ASSERT_GE(val1, val2)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(GTEST_DONT_DEFINE_ASSERT_GT) || !GTEST_DONT_DEFINE_ASSERT_GT
|
#if !GTEST_DONT_DEFINE_ASSERT_GT
|
||||||
# define ASSERT_GT(val1, val2) GTEST_ASSERT_GT(val1, val2)
|
# define ASSERT_GT(val1, val2) GTEST_ASSERT_GT(val1, val2)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -2183,7 +2183,7 @@ bool StaticAssertTypeEq() {
|
|||||||
|
|
||||||
// Define this macro to 1 to omit the definition of TEST(), which
|
// Define this macro to 1 to omit the definition of TEST(), which
|
||||||
// is a generic name and clashes with some other libraries.
|
// is a generic name and clashes with some other libraries.
|
||||||
#if !defined(GTEST_DONT_DEFINE_TEST) || !GTEST_DONT_DEFINE_TEST
|
#if !GTEST_DONT_DEFINE_TEST
|
||||||
# define TEST(test_case_name, test_name) GTEST_TEST(test_case_name, test_name)
|
# define TEST(test_case_name, test_name) GTEST_TEST(test_case_name, test_name)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -60,10 +60,6 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#if (__cplusplus > 199711L) || (defined(_MSC_VER) && _MSC_VER >= 1800)
|
|
||||||
# include <type_traits>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "gtest/gtest-message.h"
|
#include "gtest/gtest-message.h"
|
||||||
#include "gtest/internal/gtest-string.h"
|
#include "gtest/internal/gtest-string.h"
|
||||||
#include "gtest/internal/gtest-filepath.h"
|
#include "gtest/internal/gtest-filepath.h"
|
||||||
@@ -858,7 +854,6 @@ struct AddReference<T&> { typedef T& type; }; // NOLINT
|
|||||||
template <typename From, typename To>
|
template <typename From, typename To>
|
||||||
class ImplicitlyConvertible {
|
class ImplicitlyConvertible {
|
||||||
private:
|
private:
|
||||||
#if !((__cplusplus > 199711L) || (defined(_MSC_VER) && _MSC_VER >= 1800))
|
|
||||||
// We need the following helper functions only for their types.
|
// We need the following helper functions only for their types.
|
||||||
// They have no implementations.
|
// They have no implementations.
|
||||||
|
|
||||||
@@ -879,7 +874,6 @@ class ImplicitlyConvertible {
|
|||||||
// implicitly converted to type To.
|
// implicitly converted to type To.
|
||||||
static char Helper(To);
|
static char Helper(To);
|
||||||
static char (&Helper(...))[2]; // NOLINT
|
static char (&Helper(...))[2]; // NOLINT
|
||||||
#endif
|
|
||||||
|
|
||||||
// We have to put the 'public' section after the 'private' section,
|
// We have to put the 'public' section after the 'private' section,
|
||||||
// or MSVC refuses to compile the code.
|
// or MSVC refuses to compile the code.
|
||||||
@@ -889,8 +883,6 @@ class ImplicitlyConvertible {
|
|||||||
// instantiation. The simplest workaround is to use its C++0x type traits
|
// instantiation. The simplest workaround is to use its C++0x type traits
|
||||||
// functions (C++Builder 2009 and above only).
|
// functions (C++Builder 2009 and above only).
|
||||||
static const bool value = __is_convertible(From, To);
|
static const bool value = __is_convertible(From, To);
|
||||||
#elif (__cplusplus > 199711L) || (defined(_MSC_VER) && _MSC_VER >= 1800)
|
|
||||||
static const bool value = std::is_convertible<From, To>::value;
|
|
||||||
#else
|
#else
|
||||||
// MSVC warns about implicitly converting from double to int for
|
// MSVC warns about implicitly converting from double to int for
|
||||||
// possible loss of data, so we need to temporarily disable the
|
// possible loss of data, so we need to temporarily disable the
|
||||||
|
|||||||
57
extern/gtest/include/gtest/internal/gtest-port.h
vendored
57
extern/gtest/include/gtest/internal/gtest-port.h
vendored
@@ -306,7 +306,7 @@
|
|||||||
// GTEST_DISABLE_MSC_WARNINGS_PUSH_(4800 4385)
|
// GTEST_DISABLE_MSC_WARNINGS_PUSH_(4800 4385)
|
||||||
// /* code that triggers warnings C4800 and C4385 */
|
// /* code that triggers warnings C4800 and C4385 */
|
||||||
// GTEST_DISABLE_MSC_WARNINGS_POP_()
|
// GTEST_DISABLE_MSC_WARNINGS_POP_()
|
||||||
#if defined(_MSC_VER) && _MSC_VER >= 1500
|
#if _MSC_VER >= 1500
|
||||||
# define GTEST_DISABLE_MSC_WARNINGS_PUSH_(warnings) \
|
# define GTEST_DISABLE_MSC_WARNINGS_PUSH_(warnings) \
|
||||||
__pragma(warning(push)) \
|
__pragma(warning(push)) \
|
||||||
__pragma(warning(disable: warnings))
|
__pragma(warning(disable: warnings))
|
||||||
@@ -323,7 +323,7 @@
|
|||||||
// -std={c,gnu}++{0x,11} is passed. The C++11 standard specifies a
|
// -std={c,gnu}++{0x,11} is passed. The C++11 standard specifies a
|
||||||
// value for __cplusplus, and recent versions of clang, gcc, and
|
// value for __cplusplus, and recent versions of clang, gcc, and
|
||||||
// probably other compilers set that too in C++11 mode.
|
// probably other compilers set that too in C++11 mode.
|
||||||
# if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L
|
# if __GXX_EXPERIMENTAL_CXX0X__ || __cplusplus >= 201103L
|
||||||
// Compiling in at least C++11 mode.
|
// Compiling in at least C++11 mode.
|
||||||
# define GTEST_LANG_CXX11 1
|
# define GTEST_LANG_CXX11 1
|
||||||
# else
|
# else
|
||||||
@@ -352,7 +352,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Only use C++11 library features if the library provides them.
|
// Only use C++11 library features if the library provides them.
|
||||||
#if defined(GTEST_STDLIB_CXX11) && GTEST_STDLIB_CXX11
|
#if GTEST_STDLIB_CXX11
|
||||||
# define GTEST_HAS_STD_BEGIN_AND_END_ 1
|
# define GTEST_HAS_STD_BEGIN_AND_END_ 1
|
||||||
# define GTEST_HAS_STD_FORWARD_LIST_ 1
|
# define GTEST_HAS_STD_FORWARD_LIST_ 1
|
||||||
# define GTEST_HAS_STD_FUNCTION_ 1
|
# define GTEST_HAS_STD_FUNCTION_ 1
|
||||||
@@ -387,37 +387,6 @@
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef GTEST_OS_WINDOWS
|
|
||||||
# define GTEST_OS_WINDOWS 0
|
|
||||||
#endif
|
|
||||||
#ifndef GTEST_OS_WINDOWS_MINGW
|
|
||||||
# define GTEST_OS_WINDOWS_MINGW 0
|
|
||||||
#endif
|
|
||||||
#ifndef GTEST_OS_WINDOWS_PHONE
|
|
||||||
# define GTEST_OS_WINDOWS_PHONE 0
|
|
||||||
#endif
|
|
||||||
#ifndef GTEST_OS_WINDOWS_MOBILE
|
|
||||||
# define GTEST_OS_WINDOWS_MOBILE 0
|
|
||||||
#endif
|
|
||||||
#ifndef GTEST_OS_WINDOWS_RT
|
|
||||||
# define GTEST_OS_WINDOWS_RT 0
|
|
||||||
#endif
|
|
||||||
#ifndef GTEST_OS_LINUX_ANDROID
|
|
||||||
# define GTEST_OS_LINUX_ANDROID 0
|
|
||||||
#endif
|
|
||||||
#ifndef GTEST_OS_QNX
|
|
||||||
# define GTEST_OS_QNX 0
|
|
||||||
#endif
|
|
||||||
#ifndef GTEST_OS_SYMBIAN
|
|
||||||
# define GTEST_OS_SYMBIAN 0
|
|
||||||
#endif
|
|
||||||
#ifndef GTEST_OS_CYGWIN
|
|
||||||
# define GTEST_OS_CYGWIN 0
|
|
||||||
#endif
|
|
||||||
#ifndef GTEST_OS_SOLARIS
|
|
||||||
# define GTEST_OS_SOLARIS 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Brings in definitions for functions used in the testing::internal::posix
|
// Brings in definitions for functions used in the testing::internal::posix
|
||||||
// namespace (read, write, close, chdir, isatty, stat). We do not currently
|
// namespace (read, write, close, chdir, isatty, stat). We do not currently
|
||||||
// use them on Windows Mobile.
|
// use them on Windows Mobile.
|
||||||
@@ -454,7 +423,7 @@ struct _RTL_CRITICAL_SECTION;
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(GTEST_USES_PCRE) && GTEST_USES_PCRE
|
#if GTEST_USES_PCRE
|
||||||
// The appropriate headers have already been included.
|
// The appropriate headers have already been included.
|
||||||
|
|
||||||
#elif GTEST_HAS_POSIX_RE
|
#elif GTEST_HAS_POSIX_RE
|
||||||
@@ -647,7 +616,7 @@ struct _RTL_CRITICAL_SECTION;
|
|||||||
// Determines if hash_map/hash_set are available.
|
// Determines if hash_map/hash_set are available.
|
||||||
// Only used for testing against those containers.
|
// Only used for testing against those containers.
|
||||||
#if !defined(GTEST_HAS_HASH_MAP_)
|
#if !defined(GTEST_HAS_HASH_MAP_)
|
||||||
# if defined(_MSC_VER)
|
# if _MSC_VER
|
||||||
# define GTEST_HAS_HASH_MAP_ 1 // Indicates that hash_map is available.
|
# define GTEST_HAS_HASH_MAP_ 1 // Indicates that hash_map is available.
|
||||||
# define GTEST_HAS_HASH_SET_ 1 // Indicates that hash_set is available.
|
# define GTEST_HAS_HASH_SET_ 1 // Indicates that hash_set is available.
|
||||||
# endif // _MSC_VER
|
# endif // _MSC_VER
|
||||||
@@ -691,8 +660,6 @@ struct _RTL_CRITICAL_SECTION;
|
|||||||
// can build with clang but need to use gcc4.2's libstdc++).
|
// can build with clang but need to use gcc4.2's libstdc++).
|
||||||
# if GTEST_LANG_CXX11 && (!defined(__GLIBCXX__) || __GLIBCXX__ > 20110325)
|
# if GTEST_LANG_CXX11 && (!defined(__GLIBCXX__) || __GLIBCXX__ > 20110325)
|
||||||
# define GTEST_ENV_HAS_STD_TUPLE_ 1
|
# define GTEST_ENV_HAS_STD_TUPLE_ 1
|
||||||
# else
|
|
||||||
# define GTEST_ENV_HAS_STD_TUPLE_ 0
|
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if GTEST_ENV_HAS_TR1_TUPLE_ || GTEST_ENV_HAS_STD_TUPLE_
|
# if GTEST_ENV_HAS_TR1_TUPLE_ || GTEST_ENV_HAS_STD_TUPLE_
|
||||||
@@ -706,7 +673,7 @@ struct _RTL_CRITICAL_SECTION;
|
|||||||
// To avoid conditional compilation everywhere, we make it
|
// To avoid conditional compilation everywhere, we make it
|
||||||
// gtest-port.h's responsibility to #include the header implementing
|
// gtest-port.h's responsibility to #include the header implementing
|
||||||
// tuple.
|
// tuple.
|
||||||
#if defined(GTEST_HAS_STD_TUPLE_) && GTEST_HAS_STD_TUPLE_
|
#if GTEST_HAS_STD_TUPLE_
|
||||||
# include <tuple> // IWYU pragma: export
|
# include <tuple> // IWYU pragma: export
|
||||||
# define GTEST_TUPLE_NAMESPACE_ ::std
|
# define GTEST_TUPLE_NAMESPACE_ ::std
|
||||||
#endif // GTEST_HAS_STD_TUPLE_
|
#endif // GTEST_HAS_STD_TUPLE_
|
||||||
@@ -947,7 +914,7 @@ using ::std::tuple_size;
|
|||||||
# endif
|
# endif
|
||||||
|
|
||||||
#define GTEST_IS_THREADSAFE \
|
#define GTEST_IS_THREADSAFE \
|
||||||
((defined(GTEST_HAS_MUTEX_AND_THREAD_LOCAL_) && GTEST_HAS_MUTEX_AND_THREAD_LOCAL_) \
|
(GTEST_HAS_MUTEX_AND_THREAD_LOCAL_ \
|
||||||
|| (GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT) \
|
|| (GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT) \
|
||||||
|| GTEST_HAS_PTHREAD)
|
|| GTEST_HAS_PTHREAD)
|
||||||
|
|
||||||
@@ -1343,7 +1310,7 @@ inline void FlushInfoLog() { fflush(NULL); }
|
|||||||
GTEST_LOG_(FATAL) << #posix_call << "failed with error " \
|
GTEST_LOG_(FATAL) << #posix_call << "failed with error " \
|
||||||
<< gtest_error
|
<< gtest_error
|
||||||
|
|
||||||
#if defined(GTEST_HAS_STD_MOVE_) && GTEST_HAS_STD_MOVE_
|
#if GTEST_HAS_STD_MOVE_
|
||||||
using std::move;
|
using std::move;
|
||||||
#else // GTEST_HAS_STD_MOVE_
|
#else // GTEST_HAS_STD_MOVE_
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@@ -1427,7 +1394,7 @@ Derived* CheckedDowncastToActualType(Base* base) {
|
|||||||
GTEST_CHECK_(typeid(*base) == typeid(Derived));
|
GTEST_CHECK_(typeid(*base) == typeid(Derived));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(GTEST_HAS_DOWNCAST_) && GTEST_HAS_DOWNCAST_
|
#if GTEST_HAS_DOWNCAST_
|
||||||
return ::down_cast<Derived*>(base);
|
return ::down_cast<Derived*>(base);
|
||||||
#elif GTEST_HAS_RTTI
|
#elif GTEST_HAS_RTTI
|
||||||
return dynamic_cast<Derived*>(base); // NOLINT
|
return dynamic_cast<Derived*>(base); // NOLINT
|
||||||
@@ -1487,7 +1454,7 @@ inline void SleepMilliseconds(int n) {
|
|||||||
}
|
}
|
||||||
# endif // GTEST_HAS_PTHREAD
|
# endif // GTEST_HAS_PTHREAD
|
||||||
|
|
||||||
# if defined(GTEST_HAS_NOTIFICATION_) && GTEST_HAS_NOTIFICATION_
|
# if GTEST_HAS_NOTIFICATION_
|
||||||
// Notification has already been imported into the namespace.
|
// Notification has already been imported into the namespace.
|
||||||
// Nothing to do here.
|
// Nothing to do here.
|
||||||
|
|
||||||
@@ -1670,7 +1637,7 @@ class ThreadWithParam : public ThreadWithParamBase {
|
|||||||
# endif // !GTEST_OS_WINDOWS && GTEST_HAS_PTHREAD ||
|
# endif // !GTEST_OS_WINDOWS && GTEST_HAS_PTHREAD ||
|
||||||
// GTEST_HAS_MUTEX_AND_THREAD_LOCAL_
|
// GTEST_HAS_MUTEX_AND_THREAD_LOCAL_
|
||||||
|
|
||||||
# if defined(GTEST_HAS_MUTEX_AND_THREAD_LOCAL_) && GTEST_HAS_MUTEX_AND_THREAD_LOCAL_
|
# if GTEST_HAS_MUTEX_AND_THREAD_LOCAL_
|
||||||
// Mutex and ThreadLocal have already been imported into the namespace.
|
// Mutex and ThreadLocal have already been imported into the namespace.
|
||||||
// Nothing to do here.
|
// Nothing to do here.
|
||||||
|
|
||||||
@@ -2450,7 +2417,7 @@ inline void Abort() { abort(); }
|
|||||||
// MSVC-based platforms. We map the GTEST_SNPRINTF_ macro to the appropriate
|
// MSVC-based platforms. We map the GTEST_SNPRINTF_ macro to the appropriate
|
||||||
// function in order to achieve that. We use macro definition here because
|
// function in order to achieve that. We use macro definition here because
|
||||||
// snprintf is a variadic function.
|
// snprintf is a variadic function.
|
||||||
#if defined(_MSC_VER) && _MSC_VER >= 1400 && !GTEST_OS_WINDOWS_MOBILE
|
#if _MSC_VER >= 1400 && !GTEST_OS_WINDOWS_MOBILE
|
||||||
// MSVC 2005 and above support variadic macros.
|
// MSVC 2005 and above support variadic macros.
|
||||||
# define GTEST_SNPRINTF_(buffer, size, format, ...) \
|
# define GTEST_SNPRINTF_(buffer, size, format, ...) \
|
||||||
_snprintf_s(buffer, size, size, format, __VA_ARGS__)
|
_snprintf_s(buffer, size, size, format, __VA_ARGS__)
|
||||||
|
|||||||
@@ -302,7 +302,7 @@ class CLIP_OT_bundles_to_mesh(Operator):
|
|||||||
matrix = camera.matrix_world * reconstructed_matrix.inverted()
|
matrix = camera.matrix_world * reconstructed_matrix.inverted()
|
||||||
|
|
||||||
for track in tracking_object.tracks:
|
for track in tracking_object.tracks:
|
||||||
if track.has_bundle and track.select == True:
|
if track.has_bundle and track.select:
|
||||||
new_verts.append(track.bundle)
|
new_verts.append(track.bundle)
|
||||||
|
|
||||||
if new_verts:
|
if new_verts:
|
||||||
|
|||||||
@@ -469,7 +469,8 @@ class RENDER_PT_encoding(RenderButtonsPanel, Panel):
|
|||||||
layout.prop(ffmpeg, "use_lossless_output")
|
layout.prop(ffmpeg, "use_lossless_output")
|
||||||
|
|
||||||
# Output quality
|
# Output quality
|
||||||
if needs_codec and ffmpeg.codec in {'H264', 'MPEG4'}:
|
use_crf = needs_codec and ffmpeg.codec in {'H264', 'MPEG4'}
|
||||||
|
if use_crf:
|
||||||
layout.prop(ffmpeg, "constant_rate_factor")
|
layout.prop(ffmpeg, "constant_rate_factor")
|
||||||
|
|
||||||
# Encoding speed
|
# Encoding speed
|
||||||
@@ -483,7 +484,7 @@ class RENDER_PT_encoding(RenderButtonsPanel, Panel):
|
|||||||
pbox.prop(ffmpeg, "max_b_frames", text="")
|
pbox.prop(ffmpeg, "max_b_frames", text="")
|
||||||
pbox.enabled = ffmpeg.use_max_b_frames
|
pbox.enabled = ffmpeg.use_max_b_frames
|
||||||
|
|
||||||
if ffmpeg.constant_rate_factor == 'NONE':
|
if not use_crf or ffmpeg.constant_rate_factor == 'NONE':
|
||||||
split = layout.split()
|
split = layout.split()
|
||||||
col = split.column()
|
col = split.column()
|
||||||
col.label(text="Rate:")
|
col.label(text="Rate:")
|
||||||
|
|||||||
@@ -235,6 +235,7 @@ void deg_evaluate_on_refresh(EvaluationContext *eval_ctx,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const bool do_time_debug = ((G.debug & G_DEBUG_DEPSGRAPH_TIME) != 0);
|
const bool do_time_debug = ((G.debug & G_DEBUG_DEPSGRAPH_TIME) != 0);
|
||||||
|
const double start_time = do_time_debug ? PIL_check_seconds_timer() : 0;
|
||||||
/* Set time for the current graph evaluation context. */
|
/* Set time for the current graph evaluation context. */
|
||||||
TimeSourceDepsNode *time_src = graph->find_time_source();
|
TimeSourceDepsNode *time_src = graph->find_time_source();
|
||||||
eval_ctx->depsgraph = (::Depsgraph *)graph;
|
eval_ctx->depsgraph = (::Depsgraph *)graph;
|
||||||
@@ -275,6 +276,10 @@ void deg_evaluate_on_refresh(EvaluationContext *eval_ctx,
|
|||||||
if (need_free_scheduler) {
|
if (need_free_scheduler) {
|
||||||
BLI_task_scheduler_free(task_scheduler);
|
BLI_task_scheduler_free(task_scheduler);
|
||||||
}
|
}
|
||||||
|
if (do_time_debug) {
|
||||||
|
printf("Depsgraph updated in %f seconds.\n",
|
||||||
|
PIL_check_seconds_timer() - start_time);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace DEG
|
} // namespace DEG
|
||||||
|
|||||||
@@ -1458,8 +1458,9 @@ static int armature_dissolve_selected_exec(bContext *C, wmOperator *UNUSED(op))
|
|||||||
if (ebone->flag & BONE_DONE) {
|
if (ebone->flag & BONE_DONE) {
|
||||||
copy_v3_v3(ebone->parent->tail, ebone->tail);
|
copy_v3_v3(ebone->parent->tail, ebone->tail);
|
||||||
ebone->parent->rad_tail = ebone->rad_tail;
|
ebone->parent->rad_tail = ebone->rad_tail;
|
||||||
|
SET_FLAG_FROM_TEST(ebone->parent->flag, ebone->flag & BONE_TIPSEL, BONE_TIPSEL);
|
||||||
|
|
||||||
ED_armature_edit_bone_remove(arm, ebone);
|
ED_armature_edit_bone_remove_ex(arm, ebone, false);
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1468,10 +1469,9 @@ static int armature_dissolve_selected_exec(bContext *C, wmOperator *UNUSED(op))
|
|||||||
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
|
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
|
||||||
if (ebone->parent &&
|
if (ebone->parent &&
|
||||||
ebone->parent->temp.ebone &&
|
ebone->parent->temp.ebone &&
|
||||||
(ebone->flag & BONE_CONNECTED) == 0)
|
(ebone->flag & BONE_CONNECTED))
|
||||||
{
|
{
|
||||||
ebone->flag |= BONE_CONNECTED;
|
ebone->rad_head = ebone->parent->rad_tail;
|
||||||
ebone->rad_head = ebone->parent->rad_head;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -134,7 +134,10 @@ void bone_free(bArmature *arm, EditBone *bone)
|
|||||||
BLI_freelinkN(arm->edbo, bone);
|
BLI_freelinkN(arm->edbo, bone);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ED_armature_edit_bone_remove(bArmature *arm, EditBone *exBone)
|
/**
|
||||||
|
* \param clear_connected: When false caller is responsible for keeping the flag in a valid state.
|
||||||
|
*/
|
||||||
|
void ED_armature_edit_bone_remove_ex(bArmature *arm, EditBone *exBone, bool clear_connected)
|
||||||
{
|
{
|
||||||
EditBone *curBone;
|
EditBone *curBone;
|
||||||
|
|
||||||
@@ -142,13 +145,20 @@ void ED_armature_edit_bone_remove(bArmature *arm, EditBone *exBone)
|
|||||||
for (curBone = arm->edbo->first; curBone; curBone = curBone->next) {
|
for (curBone = arm->edbo->first; curBone; curBone = curBone->next) {
|
||||||
if (curBone->parent == exBone) {
|
if (curBone->parent == exBone) {
|
||||||
curBone->parent = exBone->parent;
|
curBone->parent = exBone->parent;
|
||||||
|
if (clear_connected) {
|
||||||
curBone->flag &= ~BONE_CONNECTED;
|
curBone->flag &= ~BONE_CONNECTED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bone_free(arm, exBone);
|
bone_free(arm, exBone);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ED_armature_edit_bone_remove(bArmature *arm, EditBone *exBone)
|
||||||
|
{
|
||||||
|
ED_armature_edit_bone_remove_ex(arm, exBone, true);
|
||||||
|
}
|
||||||
|
|
||||||
bool ED_armature_ebone_is_child_recursive(EditBone *ebone_parent, EditBone *ebone_child)
|
bool ED_armature_ebone_is_child_recursive(EditBone *ebone_parent, EditBone *ebone_child)
|
||||||
{
|
{
|
||||||
for (ebone_child = ebone_child->parent; ebone_child; ebone_child = ebone_child->parent) {
|
for (ebone_child = ebone_child->parent; ebone_child; ebone_child = ebone_child->parent) {
|
||||||
|
|||||||
@@ -156,6 +156,8 @@ void ED_armature_validate_active(struct bArmature *arm);
|
|||||||
|
|
||||||
EditBone *ED_armature_edit_bone_add_primitive(struct Object *obedit_arm, float length, bool view_aligned);
|
EditBone *ED_armature_edit_bone_add_primitive(struct Object *obedit_arm, float length, bool view_aligned);
|
||||||
EditBone *ED_armature_edit_bone_add(struct bArmature *arm, const char *name);
|
EditBone *ED_armature_edit_bone_add(struct bArmature *arm, const char *name);
|
||||||
|
|
||||||
|
void ED_armature_edit_bone_remove_ex(struct bArmature *arm, EditBone *exBone, bool clear_connected);
|
||||||
void ED_armature_edit_bone_remove(struct bArmature *arm, EditBone *exBone);
|
void ED_armature_edit_bone_remove(struct bArmature *arm, EditBone *exBone);
|
||||||
|
|
||||||
bool ED_armature_ebone_is_child_recursive(EditBone *ebone_parent, EditBone *ebone_child);
|
bool ED_armature_ebone_is_child_recursive(EditBone *ebone_parent, EditBone *ebone_child);
|
||||||
|
|||||||
@@ -366,6 +366,8 @@ static void wm_block_confirm_quit_save(bContext *C, void *arg_block, void *UNUSE
|
|||||||
|
|
||||||
WM_operator_properties_create_ptr(&props_ptr, ot);
|
WM_operator_properties_create_ptr(&props_ptr, ot);
|
||||||
RNA_boolean_set(&props_ptr, "exit", true);
|
RNA_boolean_set(&props_ptr, "exit", true);
|
||||||
|
/* No need for second confirmation popup. */
|
||||||
|
RNA_boolean_set(&props_ptr, "check_existing", false);
|
||||||
WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, &props_ptr);
|
WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, &props_ptr);
|
||||||
WM_operator_properties_free(&props_ptr);
|
WM_operator_properties_free(&props_ptr);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user