mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 00:57:36 +00:00
AK: Rename new_out to out and new_warn to warn.
This commit is contained in:
parent
74438e6fdc
commit
3b3edbc4d2
10 changed files with 38 additions and 41 deletions
13
AK/Format.h
13
AK/Format.h
|
@ -309,27 +309,24 @@ void vformat(const LogStream& stream, StringView fmtstr, TypeErasedFormatParams)
|
||||||
#ifndef KERNEL
|
#ifndef KERNEL
|
||||||
void vout(FILE*, StringView fmtstr, TypeErasedFormatParams, bool newline = false);
|
void vout(FILE*, StringView fmtstr, TypeErasedFormatParams, bool newline = false);
|
||||||
|
|
||||||
// FIXME: Rename 'new_out' to 'out' when the name becomes avaliable.
|
|
||||||
template<typename... Parameters>
|
template<typename... Parameters>
|
||||||
void new_out(FILE* file, StringView fmtstr, const Parameters&... parameters) { vout(file, fmtstr, VariadicFormatParams { parameters... }); }
|
void out(FILE* file, StringView fmtstr, const Parameters&... parameters) { vout(file, fmtstr, VariadicFormatParams { parameters... }); }
|
||||||
template<typename... Parameters>
|
template<typename... Parameters>
|
||||||
void outln(FILE* file, StringView fmtstr, const Parameters&... parameters) { vout(file, fmtstr, VariadicFormatParams { parameters... }, true); }
|
void outln(FILE* file, StringView fmtstr, const Parameters&... parameters) { vout(file, fmtstr, VariadicFormatParams { parameters... }, true); }
|
||||||
template<typename... Parameters>
|
template<typename... Parameters>
|
||||||
void outln(FILE* file, const char* fmtstr, const Parameters&... parameters) { vout(file, fmtstr, VariadicFormatParams { parameters... }, true); }
|
void outln(FILE* file, const char* fmtstr, const Parameters&... parameters) { vout(file, fmtstr, VariadicFormatParams { parameters... }, true); }
|
||||||
inline void outln(FILE* file) { fputc('\n', file); }
|
inline void outln(FILE* file) { fputc('\n', file); }
|
||||||
|
|
||||||
// FIXME: Rename 'new_out' to 'out' when the name becomes avaliable.
|
|
||||||
template<typename... Parameters>
|
template<typename... Parameters>
|
||||||
void new_out(StringView fmtstr, const Parameters&... parameters) { new_out(stdout, fmtstr, parameters...); }
|
void out(StringView fmtstr, const Parameters&... parameters) { out(stdout, fmtstr, parameters...); }
|
||||||
template<typename... Parameters>
|
template<typename... Parameters>
|
||||||
void outln(StringView fmtstr, const Parameters&... parameters) { outln(stdout, fmtstr, parameters...); }
|
void outln(StringView fmtstr, const Parameters&... parameters) { outln(stdout, fmtstr, parameters...); }
|
||||||
template<typename... Parameters>
|
template<typename... Parameters>
|
||||||
void outln(const char* fmtstr, const Parameters&... parameters) { outln(stdout, fmtstr, parameters...); }
|
void outln(const char* fmtstr, const Parameters&... parameters) { outln(stdout, fmtstr, parameters...); }
|
||||||
inline void outln() { outln(stdout); }
|
inline void outln() { outln(stdout); }
|
||||||
|
|
||||||
// FIXME: Rename 'new_warn' to 'warn' when the name becomes avaliable.
|
|
||||||
template<typename... Parameters>
|
template<typename... Parameters>
|
||||||
void new_warn(StringView fmtstr, const Parameters&... parameters) { new_out(stderr, fmtstr, parameters...); }
|
void warn(StringView fmtstr, const Parameters&... parameters) { out(stderr, fmtstr, parameters...); }
|
||||||
template<typename... Parameters>
|
template<typename... Parameters>
|
||||||
void warnln(StringView fmtstr, const Parameters&... parameters) { outln(stderr, fmtstr, parameters...); }
|
void warnln(StringView fmtstr, const Parameters&... parameters) { outln(stderr, fmtstr, parameters...); }
|
||||||
template<typename... Parameters>
|
template<typename... Parameters>
|
||||||
|
@ -385,10 +382,10 @@ struct Formatter<FormatIfSupported<T>> : __FormatIfSupported<T, HasFormatter<T>:
|
||||||
} // namespace AK
|
} // namespace AK
|
||||||
|
|
||||||
#ifndef KERNEL
|
#ifndef KERNEL
|
||||||
using AK::new_out;
|
using AK::out;
|
||||||
using AK::outln;
|
using AK::outln;
|
||||||
|
|
||||||
using AK::new_warn;
|
using AK::warn;
|
||||||
using AK::warnln;
|
using AK::warnln;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -222,7 +222,7 @@ TEST_CASE(file_descriptor)
|
||||||
FILE* file = fdopen(fd, "w+");
|
FILE* file = fdopen(fd, "w+");
|
||||||
|
|
||||||
outln(file, "{}", "Hello, World!");
|
outln(file, "{}", "Hello, World!");
|
||||||
new_out(file, "foo");
|
out(file, "foo");
|
||||||
outln(file, "bar");
|
outln(file, "bar");
|
||||||
|
|
||||||
rewind(file);
|
rewind(file);
|
||||||
|
|
|
@ -150,14 +150,14 @@ static bool handle_breakpoint_command(const String& command)
|
||||||
|
|
||||||
static void print_help()
|
static void print_help()
|
||||||
{
|
{
|
||||||
new_out("Options:\n"
|
out("Options:\n"
|
||||||
"cont - Continue execution\n"
|
"cont - Continue execution\n"
|
||||||
"si - step to the next instruction\n"
|
"si - step to the next instruction\n"
|
||||||
"sl - step to the next source line\n"
|
"sl - step to the next source line\n"
|
||||||
"line - show the position of the current instruction in the source code\n"
|
"line - show the position of the current instruction in the source code\n"
|
||||||
"regs - Print registers\n"
|
"regs - Print registers\n"
|
||||||
"dis [number of instructions] - Print disassembly\n"
|
"dis [number of instructions] - Print disassembly\n"
|
||||||
"bp <address/symbol/file:line> - Insert a breakpoint\n");
|
"bp <address/symbol/file:line> - Insert a breakpoint\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
|
|
|
@ -49,7 +49,7 @@ int main(int argc, char** argv, char** envp)
|
||||||
auto byte_ptr = (uint8_t*)auxvp->a_un.a_ptr;
|
auto byte_ptr = (uint8_t*)auxvp->a_un.a_ptr;
|
||||||
outln(" My Random bytes are: ");
|
outln(" My Random bytes are: ");
|
||||||
for (size_t i = 0; i < 16; ++i)
|
for (size_t i = 0; i < 16; ++i)
|
||||||
new_out("{:#02x} ", byte_ptr[i]);
|
out("{:#02x} ", byte_ptr[i]);
|
||||||
outln();
|
outln();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -373,7 +373,7 @@ void Project::rebuild_tree()
|
||||||
#if 0
|
#if 0
|
||||||
Function<void(ProjectTreeNode&, int indent)> dump_tree = [&](ProjectTreeNode& node, int indent) {
|
Function<void(ProjectTreeNode&, int indent)> dump_tree = [&](ProjectTreeNode& node, int indent) {
|
||||||
for (int i = 0; i < indent; ++i)
|
for (int i = 0; i < indent; ++i)
|
||||||
new_out(" ");
|
out(" ");
|
||||||
if (node.name.is_null())
|
if (node.name.is_null())
|
||||||
outln("(null)");
|
outln("(null)");
|
||||||
else
|
else
|
||||||
|
|
|
@ -181,28 +181,28 @@ bool ArgsParser::parse(int argc, char** argv, bool exit_on_failure)
|
||||||
|
|
||||||
void ArgsParser::print_usage(FILE* file, const char* argv0)
|
void ArgsParser::print_usage(FILE* file, const char* argv0)
|
||||||
{
|
{
|
||||||
new_out(file, "Usage:\n\t\033[1m{}\033[0m", argv0);
|
out(file, "Usage:\n\t\033[1m{}\033[0m", argv0);
|
||||||
|
|
||||||
for (auto& opt : m_options) {
|
for (auto& opt : m_options) {
|
||||||
if (opt.long_name && !strcmp(opt.long_name, "help"))
|
if (opt.long_name && !strcmp(opt.long_name, "help"))
|
||||||
continue;
|
continue;
|
||||||
if (opt.requires_argument)
|
if (opt.requires_argument)
|
||||||
new_out(file, " [{} {}]", opt.name_for_display(), opt.value_name);
|
out(file, " [{} {}]", opt.name_for_display(), opt.value_name);
|
||||||
else
|
else
|
||||||
new_out(file, " [{}]", opt.name_for_display());
|
out(file, " [{}]", opt.name_for_display());
|
||||||
}
|
}
|
||||||
for (auto& arg : m_positional_args) {
|
for (auto& arg : m_positional_args) {
|
||||||
bool required = arg.min_values > 0;
|
bool required = arg.min_values > 0;
|
||||||
bool repeated = arg.max_values > 1;
|
bool repeated = arg.max_values > 1;
|
||||||
|
|
||||||
if (required && repeated)
|
if (required && repeated)
|
||||||
new_out(file, " <{}...>", arg.name);
|
out(file, " <{}...>", arg.name);
|
||||||
else if (required && !repeated)
|
else if (required && !repeated)
|
||||||
new_out(file, " <{}>", arg.name);
|
out(file, " <{}>", arg.name);
|
||||||
else if (!required && repeated)
|
else if (!required && repeated)
|
||||||
new_out(file, " [{}...]", arg.name);
|
out(file, " [{}...]", arg.name);
|
||||||
else if (!required && !repeated)
|
else if (!required && !repeated)
|
||||||
new_out(file, " [{}]", arg.name);
|
out(file, " [{}]", arg.name);
|
||||||
}
|
}
|
||||||
outln(file);
|
outln(file);
|
||||||
|
|
||||||
|
@ -212,25 +212,25 @@ void ArgsParser::print_usage(FILE* file, const char* argv0)
|
||||||
auto print_argument = [&]() {
|
auto print_argument = [&]() {
|
||||||
if (opt.value_name) {
|
if (opt.value_name) {
|
||||||
if (opt.requires_argument)
|
if (opt.requires_argument)
|
||||||
new_out(file, " {}", opt.value_name);
|
out(file, " {}", opt.value_name);
|
||||||
else
|
else
|
||||||
new_out(file, " [{}]", opt.value_name);
|
out(file, " [{}]", opt.value_name);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
new_out(file, "\t");
|
out(file, "\t");
|
||||||
if (opt.short_name) {
|
if (opt.short_name) {
|
||||||
new_out(file, "\033[1m-{}\033[0m", opt.short_name);
|
out(file, "\033[1m-{}\033[0m", opt.short_name);
|
||||||
print_argument();
|
print_argument();
|
||||||
}
|
}
|
||||||
if (opt.short_name && opt.long_name)
|
if (opt.short_name && opt.long_name)
|
||||||
new_out(file, ", ");
|
out(file, ", ");
|
||||||
if (opt.long_name) {
|
if (opt.long_name) {
|
||||||
new_out(file, "\033[1m--{}\033[0m", opt.long_name);
|
out(file, "\033[1m--{}\033[0m", opt.long_name);
|
||||||
print_argument();
|
print_argument();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opt.help_string)
|
if (opt.help_string)
|
||||||
new_out(file, "\t{}", opt.help_string);
|
out(file, "\t{}", opt.help_string);
|
||||||
outln(file);
|
outln(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,9 +238,9 @@ void ArgsParser::print_usage(FILE* file, const char* argv0)
|
||||||
outln(file, "\nArguments:");
|
outln(file, "\nArguments:");
|
||||||
|
|
||||||
for (auto& arg : m_positional_args) {
|
for (auto& arg : m_positional_args) {
|
||||||
new_out(file, "\t\033[1m{}\033[0m", arg.name);
|
out(file, "\t\033[1m{}\033[0m", arg.name);
|
||||||
if (arg.help_string)
|
if (arg.help_string)
|
||||||
new_out(file, "\t{}", arg.help_string);
|
out(file, "\t{}", arg.help_string);
|
||||||
outln(file);
|
outln(file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,9 +47,9 @@ Print the value of EXPRESSION to standard output.)");
|
||||||
template<typename... Args>
|
template<typename... Args>
|
||||||
[[noreturn]] void fail(Args&&... args)
|
[[noreturn]] void fail(Args&&... args)
|
||||||
{
|
{
|
||||||
new_warn("ERROR: \e[31m");
|
warn("ERROR: \e[31m");
|
||||||
warnln(args...);
|
warnln(args...);
|
||||||
new_warn("\e[0m");
|
warn("\e[0m");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ static void handle_sigint(int)
|
||||||
static void print_function_call(String function_name, size_t depth)
|
static void print_function_call(String function_name, size_t depth)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < depth; ++i) {
|
for (size_t i = 0; i < depth; ++i) {
|
||||||
new_out(" ");
|
out(" ");
|
||||||
}
|
}
|
||||||
outln("=> {}", function_name);
|
outln("=> {}", function_name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ int main(int argc, char** argv)
|
||||||
for (size_t i = 0; i < NSIG; ++i) {
|
for (size_t i = 0; i < NSIG; ++i) {
|
||||||
if (i && !(i % 5))
|
if (i && !(i % 5))
|
||||||
outln("");
|
outln("");
|
||||||
new_out("{:2}) {:10}", i, getsignalname(i));
|
out("{:2}) {:10}", i, getsignalname(i));
|
||||||
}
|
}
|
||||||
outln("");
|
outln("");
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -51,11 +51,11 @@ static void print_directory_tree(const String& root_path, int depth, const Strin
|
||||||
} else {
|
} else {
|
||||||
root_indent_string = "";
|
root_indent_string = "";
|
||||||
}
|
}
|
||||||
new_out("{}|-- ", root_indent_string);
|
out("{}|-- ", root_indent_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
String root_dir_name = AK::LexicalPath(root_path).basename();
|
String root_dir_name = AK::LexicalPath(root_path).basename();
|
||||||
new_out("\033[34;1m{}\033[0m\n", root_dir_name);
|
out("\033[34;1m{}\033[0m\n", root_dir_name);
|
||||||
|
|
||||||
if (depth >= max_depth) {
|
if (depth >= max_depth) {
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue