Move to RAII-style status_line objects for console status

This commit is contained in:
Justin C. Miller
2020-02-23 17:55:53 -08:00
parent 6f5a2a3d3f
commit 93f0b70eba
5 changed files with 173 additions and 115 deletions

View File

@@ -11,11 +11,6 @@ class console
public:
console(uefi::boot_services *bs, uefi::protos::simple_text_output *out);
void status_begin(const wchar_t *message);
void status_warn(const wchar_t *message, const wchar_t *error=nullptr);
void status_fail(const wchar_t *message, const wchar_t *error=nullptr);
void status_end();
size_t print_hex(uint32_t n) const;
size_t print_dec(uint32_t n) const;
size_t print_long_hex(uint64_t n) const;
@@ -26,19 +21,45 @@ public:
static size_t print(const wchar_t *fmt, ...);
private:
friend class status_line;
void pick_mode(uefi::boot_services *bs);
size_t vprintf(const wchar_t *fmt, va_list args) const;
size_t m_rows, m_cols;
int m_status_level;
int m_status_line;
uefi::protos::simple_text_output *m_out;
static console *s_console;
};
class status_line
{
public:
status_line(const wchar_t *message);
~status_line();
inline static void warn(const wchar_t *message, const wchar_t *error=nullptr) {
if (s_current) s_current->do_warn(message, error);
}
inline static void fail(const wchar_t *message, const wchar_t *error=nullptr) {
if (s_current) s_current->do_fail(message, error);
}
private:
void print_status_tag();
void do_warn(const wchar_t *message, const wchar_t *error);
void do_fail(const wchar_t *message, const wchar_t *error);
void finish();
size_t m_line;
int m_level;
int m_depth;
status_line *m_next;
static status_line *s_current;
};
uefi::status
con_get_framebuffer(
uefi::boot_services *bs,