blob: 2c8539bb23778896fe2f24372eaf4ca47aab029a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#include "kern/print.hpp"
#include <string_view>
namespace teachos
{
namespace
{
constinit auto noop = [](std::string_view) {};
constinit auto current_print_handler = static_cast<print_handler *>(noop);
constinit auto current_println_handler = static_cast<println_handler *>(noop);
constinit auto current_print_error_handler = static_cast<print_handler *>(noop);
constinit auto current_println_error_handler = static_cast<println_handler *>(noop);
} // namespace
auto print(std::string_view text) -> void { current_print_handler(text); }
auto println(std::string_view text) -> void { current_println_handler(text); }
auto print_error(std::string_view text) -> void { current_print_error_handler(text); }
auto println_error(std::string_view text) -> void { current_println_error_handler(text); }
auto set_print_handler(print_handler handler) -> print_handler *
{
auto old = current_print_handler;
current_print_handler = handler;
return old;
}
auto set_println_handler(println_handler handler) -> print_handler *
{
auto old = current_println_handler;
current_println_handler = handler;
return old;
}
auto set_print_error_handler(print_handler handler) -> print_handler *
{
auto old = current_print_error_handler;
current_print_error_handler = handler;
return old;
}
auto set_println_error_handler(println_handler handler) -> print_handler *
{
auto old = current_println_error_handler;
current_println_error_handler = handler;
return old;
}
} // namespace teachos
|