forked from fmtlib/fmt
Update to new naming conventions
This commit is contained in:
@ -642,7 +642,7 @@ typed_value<C, name_arg_type>
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Maximum number of arguments with packed types.
|
// Maximum number of arguments with packed types.
|
||||||
enum { MAX_PACKED_ARGS = 15 };
|
enum { max_packed_args = 15 };
|
||||||
|
|
||||||
template <typename Context>
|
template <typename Context>
|
||||||
class arg_map;
|
class arg_map;
|
||||||
@ -912,8 +912,7 @@ typedef buffer_context<wchar_t>::type wcontext;
|
|||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
template <typename Context, typename T>
|
template <typename Context, typename T>
|
||||||
class get_type {
|
struct get_type {
|
||||||
public:
|
|
||||||
typedef decltype(make_value<Context>(
|
typedef decltype(make_value<Context>(
|
||||||
declval<typename std::decay<T>::type&>())) value_type;
|
declval<typename std::decay<T>::type&>())) value_type;
|
||||||
static const type value = value_type::type_tag;
|
static const type value = value_type::type_tag;
|
||||||
@ -954,7 +953,7 @@ class arg_store {
|
|||||||
static const size_t NUM_ARGS = sizeof...(Args);
|
static const size_t NUM_ARGS = sizeof...(Args);
|
||||||
|
|
||||||
// Packed is a macro on MinGW so use IS_PACKED instead.
|
// Packed is a macro on MinGW so use IS_PACKED instead.
|
||||||
static const bool IS_PACKED = NUM_ARGS < internal::MAX_PACKED_ARGS;
|
static const bool IS_PACKED = NUM_ARGS < internal::max_packed_args;
|
||||||
|
|
||||||
typedef typename std::conditional<
|
typedef typename std::conditional<
|
||||||
IS_PACKED, internal::value<Context>, basic_arg<Context>>::type value_type;
|
IS_PACKED, internal::value<Context>, basic_arg<Context>>::type value_type;
|
||||||
@ -1004,10 +1003,10 @@ class basic_format_args {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
// To reduce compiled code size per formatting function call, types of first
|
// To reduce compiled code size per formatting function call, types of first
|
||||||
// MAX_PACKED_ARGS arguments are passed in the types_ field.
|
// max_packed_args arguments are passed in the types_ field.
|
||||||
uint64_t types_;
|
uint64_t types_;
|
||||||
union {
|
union {
|
||||||
// If the number of arguments is less than MAX_PACKED_ARGS, the argument
|
// If the number of arguments is less than max_packed_args, the argument
|
||||||
// values are stored in values_, otherwise they are stored in args_.
|
// values are stored in values_, otherwise they are stored in args_.
|
||||||
// This is done to reduce compiled code size as storing larger objects
|
// This is done to reduce compiled code size as storing larger objects
|
||||||
// may require more code (at least on x86-64) even if the same amount of
|
// may require more code (at least on x86-64) even if the same amount of
|
||||||
@ -1035,7 +1034,7 @@ class basic_format_args {
|
|||||||
return index < num_args ? args_[index] : format_arg();
|
return index < num_args ? args_[index] : format_arg();
|
||||||
}
|
}
|
||||||
format_arg arg;
|
format_arg arg;
|
||||||
if (index > internal::MAX_PACKED_ARGS)
|
if (index > internal::max_packed_args)
|
||||||
return arg;
|
return arg;
|
||||||
arg.type_ = type(index);
|
arg.type_ = type(index);
|
||||||
if (arg.type_ == internal::none_type)
|
if (arg.type_ == internal::none_type)
|
||||||
@ -1064,7 +1063,7 @@ class basic_format_args {
|
|||||||
unsigned max_size() const {
|
unsigned max_size() const {
|
||||||
int64_t signed_types = static_cast<int64_t>(types_);
|
int64_t signed_types = static_cast<int64_t>(types_);
|
||||||
return signed_types < 0 ?
|
return signed_types < 0 ?
|
||||||
-signed_types : static_cast<int64_t>(internal::MAX_PACKED_ARGS);
|
-signed_types : static_cast<int64_t>(internal::max_packed_args);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1127,7 +1126,7 @@ inline internal::named_arg<T, wchar_t> arg(wstring_view name, const T &arg) {
|
|||||||
template <typename S, typename T, typename Char>
|
template <typename S, typename T, typename Char>
|
||||||
void arg(S, internal::named_arg<T, Char>) FMT_DELETED;
|
void arg(S, internal::named_arg<T, Char>) FMT_DELETED;
|
||||||
|
|
||||||
enum color { BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE };
|
enum color { black, red, green, yellow, blue, magenta, cyan, white };
|
||||||
|
|
||||||
FMT_API void vprint_colored(color c, string_view format, format_args args);
|
FMT_API void vprint_colored(color c, string_view format, format_args args);
|
||||||
|
|
||||||
|
@ -1326,7 +1326,7 @@ void arg_map<Context>::init(const basic_format_args<Context> &args) {
|
|||||||
if (map_)
|
if (map_)
|
||||||
return;
|
return;
|
||||||
map_ = new entry[args.max_size()];
|
map_ = new entry[args.max_size()];
|
||||||
bool use_values = args.type(MAX_PACKED_ARGS - 1) == internal::none_type;
|
bool use_values = args.type(max_packed_args - 1) == internal::none_type;
|
||||||
if (use_values) {
|
if (use_values) {
|
||||||
for (unsigned i = 0;/*nothing*/; ++i) {
|
for (unsigned i = 0;/*nothing*/; ++i) {
|
||||||
internal::type arg_type = args.type(i);
|
internal::type arg_type = args.type(i);
|
||||||
@ -1342,11 +1342,11 @@ void arg_map<Context>::init(const basic_format_args<Context> &args) {
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (unsigned i = 0; i != MAX_PACKED_ARGS; ++i) {
|
for (unsigned i = 0; i != max_packed_args; ++i) {
|
||||||
if (args.type(i) == internal::name_arg_type)
|
if (args.type(i) == internal::name_arg_type)
|
||||||
push_back(args.args_[i].value_);
|
push_back(args.args_[i].value_);
|
||||||
}
|
}
|
||||||
for (unsigned i = MAX_PACKED_ARGS; ; ++i) {
|
for (unsigned i = max_packed_args; ; ++i) {
|
||||||
switch (args.args_[i].type_) {
|
switch (args.args_[i].type_) {
|
||||||
case internal::none_type:
|
case internal::none_type:
|
||||||
return;
|
return;
|
||||||
|
@ -442,9 +442,9 @@ TEST(FormatterTest, ManyArgs) {
|
|||||||
format_error, "argument index out of range");
|
format_error, "argument index out of range");
|
||||||
EXPECT_THROW_MSG(TestFormat<21>::format("{21}"),
|
EXPECT_THROW_MSG(TestFormat<21>::format("{21}"),
|
||||||
format_error, "argument index out of range");
|
format_error, "argument index out of range");
|
||||||
enum { MAX_PACKED_ARGS = fmt::internal::MAX_PACKED_ARGS };
|
enum { max_packed_args = fmt::internal::max_packed_args };
|
||||||
std::string format_str = fmt::format("{{{}}}", MAX_PACKED_ARGS + 1);
|
std::string format_str = fmt::format("{{{}}}", max_packed_args + 1);
|
||||||
EXPECT_THROW_MSG(TestFormat<MAX_PACKED_ARGS>::format(format_str),
|
EXPECT_THROW_MSG(TestFormat<max_packed_args>::format(format_str),
|
||||||
format_error, "argument index out of range");
|
format_error, "argument index out of range");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1405,7 +1405,7 @@ TEST(FormatTest, Print) {
|
|||||||
|
|
||||||
#if FMT_USE_FILE_DESCRIPTORS
|
#if FMT_USE_FILE_DESCRIPTORS
|
||||||
TEST(FormatTest, PrintColored) {
|
TEST(FormatTest, PrintColored) {
|
||||||
EXPECT_WRITE(stdout, fmt::print_colored(fmt::RED, "Hello, {}!\n", "world"),
|
EXPECT_WRITE(stdout, fmt::print_colored(fmt::red, "Hello, {}!\n", "world"),
|
||||||
"\x1b[31mHello, world!\n\x1b[0m");
|
"\x1b[31mHello, world!\n\x1b[0m");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user