Skip to content

Commit

Permalink
revert int changes
Browse files Browse the repository at this point in the history
  • Loading branch information
nickgerrets committed Apr 5, 2024
1 parent 8305452 commit 843bf67
Show file tree
Hide file tree
Showing 4 changed files with 319 additions and 314 deletions.
60 changes: 30 additions & 30 deletions third_party/fmt/include/fmt/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ struct monostate {};
// An enable_if helper to be used in template parameters which results in much
// shorter symbols: https://godbolt.org/z/sWw4vP. Extra parentheses are needed
// to workaround a bug in MSVC 2019 (see #1140 and #1186).
#define FMT_ENABLE_IF(...) enable_if_t<(__VA_ARGS__), int32_t> = 0
#define FMT_ENABLE_IF(...) enable_if_t<(__VA_ARGS__), int> = 0

namespace internal {

Expand Down Expand Up @@ -316,9 +316,9 @@ template <typename Char> class basic_string_view {
}

// Lexicographically compare this string reference to other.
int32_t compare(basic_string_view other) const {
int compare(basic_string_view other) const {
size_t str_size = size_ < other.size_ ? size_ : other.size_;
int32_t result = std::char_traits<Char>::compare(data_, other.data_, str_size);
int result = std::char_traits<Char>::compare(data_, other.data_, str_size);
if (result == 0)
result = size_ == other.size_ ? 0 : (size_ < other.size_ ? -1 : 1);
return result;
Expand Down Expand Up @@ -456,7 +456,7 @@ template <typename Char, typename ErrorHandler = internal::error_handler>
class basic_format_parse_context : private ErrorHandler {
private:
basic_string_view<Char> format_str_;
int32_t next_arg_id_;
int next_arg_id_;

public:
using char_type = Char;
Expand Down Expand Up @@ -488,7 +488,7 @@ class basic_format_parse_context : private ErrorHandler {
Reports an error if using the manual argument indexing; otherwise returns
the next argument index and switches to the automatic indexing.
*/
FMT_CONSTEXPR int32_t next_arg_id() {
FMT_CONSTEXPR int next_arg_id() {
if (next_arg_id_ >= 0) return next_arg_id_++;
on_error("cannot switch from manual to automatic argument indexing");
return 0;
Expand All @@ -498,7 +498,7 @@ class basic_format_parse_context : private ErrorHandler {
Reports an error if using the automatic argument indexing; otherwise
switches to the manual indexing.
*/
FMT_CONSTEXPR void check_arg_id(int32_t) {
FMT_CONSTEXPR void check_arg_id(int) {
if (next_arg_id_ > 0)
on_error("cannot switch from automatic to manual argument indexing");
else
Expand Down Expand Up @@ -536,7 +536,7 @@ struct formatter {
template <typename T, typename Char, typename Enable = void>
struct FMT_DEPRECATED convert_to_int
: bool_constant<!std::is_arithmetic<T>::value &&
std::is_convertible<T, int32_t>::value> {};
std::is_convertible<T, int>::value> {};

// Specifies if T has an enabled formatter specialization. A type can be
// formattable even if it doesn't have a formatter e.g. via a conversion.
Expand Down Expand Up @@ -801,11 +801,11 @@ template <typename Context> class value {
template <typename Context, typename T>
FMT_CONSTEXPR basic_format_arg<Context> make_arg(const T& value);

// To minimize the number of types we need to deal with, int64_t is translated
// either to int32_t or to int64_t depending on its size.
enum { long_short = sizeof(int64_t) == sizeof(int32_t) };
using long_type = conditional_t<long_short, int32_t, int64_t>;
using ulong_type = conditional_t<long_short, uint32_t, uint64_t>;
// To minimize the number of types we need to deal with, long is translated
// either to int or to long long depending on its size.
enum { long_short = sizeof(long) == sizeof(int) };
using long_type = conditional_t<long_short, int, long long>;
using ulong_type = conditional_t<long_short, unsigned, unsigned long long>;

// Maps formatting arguments to core types.
template <typename Context> struct arg_mapper {
Expand Down Expand Up @@ -873,7 +873,7 @@ template <typename Context> struct arg_mapper {
FMT_CONSTEXPR const void* map(void* val) { return val; }
FMT_CONSTEXPR const void* map(const void* val) { return val; }
FMT_CONSTEXPR const void* map(std::nullptr_t val) { return val; }
template <typename T> FMT_CONSTEXPR int32_t map(const T*) {
template <typename T> FMT_CONSTEXPR int map(const T*) {
// Formatting of arbitrary pointers is disallowed. If you want to output
// a pointer cast it to "void *" or "const void *". In particular, this
// forbids formatting of "[const] volatile char *" which is printed as bool
Expand Down Expand Up @@ -920,7 +920,7 @@ using mapped_type_constant =
enum { packed_arg_bits = 5 };
// Maximum number of arguments with packed types.
enum { max_packed_args = 63 / packed_arg_bits };
enum : uint64_t { is_unpacked_bit = 1ULL << 63 };
enum : unsigned long long { is_unpacked_bit = 1ULL << 63 };

template <typename Context> class arg_map;
} // namespace internal
Expand Down Expand Up @@ -1037,7 +1037,7 @@ template <typename Context> class arg_map {
};

entry* map_;
uint32_t size_;
unsigned size_;

void push_back(value<Context> val) {
const auto& named = *val.named_arg;
Expand Down Expand Up @@ -1075,10 +1075,10 @@ class locale_ref {
template <typename Locale> Locale get() const;
};

template <typename> constexpr uint64_t encode_types() { return 0; }
template <typename> constexpr unsigned long long encode_types() { return 0; }

template <typename Context, typename Arg, typename... Args>
constexpr uint64_t encode_types() {
constexpr unsigned long long encode_types() {
return mapped_type_constant<Arg, Context>::value |
(encode_types<Context, Args...>() << packed_arg_bits);
}
Expand Down Expand Up @@ -1132,7 +1132,7 @@ template <typename OutputIt, typename Char> class basic_format_context {
internal::locale_ref loc = internal::locale_ref())
: out_(out), args_(ctx_args), loc_(loc) {}

format_arg arg(int32_t id) const { return args_.get(id); }
format_arg arg(int id) const { return args_.get(id); }

// Checks if manual indexing is used and returns the argument with the
// specified name.
Expand Down Expand Up @@ -1178,7 +1178,7 @@ template <typename Context, typename... Args> class format_arg_store {
friend class basic_format_args<Context>;

public:
static constexpr uint64_t types =
static constexpr unsigned long long types =
is_packed ? internal::encode_types<Context, Args...>()
: internal::is_unpacked_bit | num_args;

Expand All @@ -1203,13 +1203,13 @@ inline format_arg_store<Context, Args...> make_format_args(
/** Formatting arguments. */
template <typename Context> class basic_format_args {
public:
using size_type = int32_t;
using size_type = int;
using format_arg = basic_format_arg<Context>;

private:
// To reduce compiled code size per formatting function call, types of first
// max_packed_args arguments are passed in the types_ field.
uint64_t types_;
unsigned long long types_;
union {
// If the number of arguments is less than max_packed_args, the argument
// values are stored in values_, otherwise they are stored in args_.
Expand All @@ -1222,9 +1222,9 @@ template <typename Context> class basic_format_args {

bool is_packed() const { return (types_ & internal::is_unpacked_bit) == 0; }

internal::type type(int32_t index) const {
int32_t shift = index * internal::packed_arg_bits;
uint32_t mask = (1 << internal::packed_arg_bits) - 1;
internal::type type(int index) const {
int shift = index * internal::packed_arg_bits;
unsigned int mask = (1 << internal::packed_arg_bits) - 1;
return static_cast<internal::type>((types_ >> shift) & mask);
}

Expand All @@ -1233,7 +1233,7 @@ template <typename Context> class basic_format_args {
void set_data(const internal::value<Context>* values) { values_ = values; }
void set_data(const format_arg* args) { args_ = args; }

format_arg do_get(int32_t index) const {
format_arg do_get(int index) const {
format_arg arg;
if (!is_packed()) {
auto num_args = max_size();
Expand Down Expand Up @@ -1267,22 +1267,22 @@ template <typename Context> class basic_format_args {
Constructs a `basic_format_args` object from a dynamic set of arguments.
\endrst
*/
basic_format_args(const format_arg* args, int32_t count)
basic_format_args(const format_arg* args, int count)
: types_(internal::is_unpacked_bit | internal::to_unsigned(count)) {
set_data(args);
}

/** Returns the argument at specified index. */
format_arg get(int32_t index) const {
format_arg get(int index) const {
format_arg arg = do_get(index);
if (arg.type_ == internal::named_arg_type)
arg = arg.value_.named_arg->template deserialize<Context>();
return arg;
}

int32_t max_size() const {
uint64_t max_packed = internal::max_packed_args;
return static_cast<int32_t>(is_packed() ? max_packed
int max_size() const {
unsigned long long max_packed = internal::max_packed_args;
return static_cast<int>(is_packed() ? max_packed
: types_ & ~internal::is_unpacked_bit);
}
};
Expand Down
Loading

0 comments on commit 843bf67

Please sign in to comment.