diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-07-03 21:17:35 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-07-03 21:20:13 +0200 |
commit | 27f699ef0c8c2dce0f1dff19eef25f02e3da397e (patch) | |
tree | 52f95be1d05ba2a621d3bb8ac9129341f8d9973b /Applications | |
parent | c4c4bbc5ba5119e9ccc8ded948b26e7c4851a909 (diff) | |
download | serenity-27f699ef0c8c2dce0f1dff19eef25f02e3da397e.zip |
AK: Rename the common integer typedefs to make it obvious what they are.
These types can be picked up by including <AK/Types.h>:
* u8, u16, u32, u64 (unsigned)
* i8, i16, i32, i64 (signed)
Diffstat (limited to 'Applications')
-rw-r--r-- | Applications/FontEditor/FontEditor.cpp | 4 | ||||
-rw-r--r-- | Applications/FontEditor/GlyphEditorWidget.cpp | 2 | ||||
-rw-r--r-- | Applications/FontEditor/GlyphEditorWidget.h | 8 | ||||
-rw-r--r-- | Applications/FontEditor/GlyphMapWidget.cpp | 8 | ||||
-rw-r--r-- | Applications/FontEditor/GlyphMapWidget.h | 12 | ||||
-rw-r--r-- | Applications/ProcessManager/MemoryStatsWidget.cpp | 18 | ||||
-rw-r--r-- | Applications/ProcessManager/ProcessModel.cpp | 14 | ||||
-rw-r--r-- | Applications/Terminal/Terminal.cpp | 44 | ||||
-rw-r--r-- | Applications/Terminal/Terminal.h | 60 |
9 files changed, 85 insertions, 85 deletions
diff --git a/Applications/FontEditor/FontEditor.cpp b/Applications/FontEditor/FontEditor.cpp index 28dc2e6366..90d9563907 100644 --- a/Applications/FontEditor/FontEditor.cpp +++ b/Applications/FontEditor/FontEditor.cpp @@ -91,12 +91,12 @@ FontEditorWidget::FontEditorWidget(const String& path, RefPtr<Font>&& edited_fon demo_label_2->update(); }; - m_glyph_editor_widget->on_glyph_altered = [this, update_demo](byte glyph) { + m_glyph_editor_widget->on_glyph_altered = [this, update_demo](u8 glyph) { m_glyph_map_widget->update_glyph(glyph); update_demo(); }; - m_glyph_map_widget->on_glyph_selected = [this, info_label, width_spinbox](byte glyph) { + m_glyph_map_widget->on_glyph_selected = [this, info_label, width_spinbox](u8 glyph) { m_glyph_editor_widget->set_glyph(glyph); width_spinbox->set_value(m_edited_font->glyph_width(m_glyph_map_widget->selected_glyph())); info_label->set_text(String::format("0x%b (%c)", glyph, glyph)); diff --git a/Applications/FontEditor/GlyphEditorWidget.cpp b/Applications/FontEditor/GlyphEditorWidget.cpp index c8e491dff1..24ff5bc7f7 100644 --- a/Applications/FontEditor/GlyphEditorWidget.cpp +++ b/Applications/FontEditor/GlyphEditorWidget.cpp @@ -15,7 +15,7 @@ GlyphEditorWidget::~GlyphEditorWidget() { } -void GlyphEditorWidget::set_glyph(byte glyph) +void GlyphEditorWidget::set_glyph(u8 glyph) { if (m_glyph == glyph) return; diff --git a/Applications/FontEditor/GlyphEditorWidget.h b/Applications/FontEditor/GlyphEditorWidget.h index 9fd05a322e..31b83ed3e5 100644 --- a/Applications/FontEditor/GlyphEditorWidget.h +++ b/Applications/FontEditor/GlyphEditorWidget.h @@ -6,8 +6,8 @@ public: GlyphEditorWidget(Font&, GWidget* parent); virtual ~GlyphEditorWidget() override; - byte glyph() const { return m_glyph; } - void set_glyph(byte); + u8 glyph() const { return m_glyph; } + void set_glyph(u8); int preferred_width() const; int preferred_height() const; @@ -15,7 +15,7 @@ public: Font& font() { return *m_font; } const Font& font() const { return *m_font; } - Function<void(byte)> on_glyph_altered; + Function<void(u8)> on_glyph_altered; private: virtual void paint_event(GPaintEvent&) override; @@ -25,6 +25,6 @@ private: void draw_at_mouse(const GMouseEvent&); RefPtr<Font> m_font; - byte m_glyph { 0 }; + u8 m_glyph { 0 }; int m_scale { 10 }; }; diff --git a/Applications/FontEditor/GlyphMapWidget.cpp b/Applications/FontEditor/GlyphMapWidget.cpp index 4d94b2eeaf..1d86a83184 100644 --- a/Applications/FontEditor/GlyphMapWidget.cpp +++ b/Applications/FontEditor/GlyphMapWidget.cpp @@ -25,7 +25,7 @@ int GlyphMapWidget::preferred_height() const return rows() * (font().glyph_height() + m_vertical_spacing) + 2 + frame_thickness() * 2; } -void GlyphMapWidget::set_selected_glyph(byte glyph) +void GlyphMapWidget::set_selected_glyph(u8 glyph) { if (m_selected_glyph == glyph) return; @@ -35,7 +35,7 @@ void GlyphMapWidget::set_selected_glyph(byte glyph) update(); } -Rect GlyphMapWidget::get_outer_rect(byte glyph) const +Rect GlyphMapWidget::get_outer_rect(u8 glyph) const { int row = glyph / columns(); int column = glyph % columns(); @@ -48,7 +48,7 @@ Rect GlyphMapWidget::get_outer_rect(byte glyph) const .translated(frame_thickness(), frame_thickness()); } -void GlyphMapWidget::update_glyph(byte glyph) +void GlyphMapWidget::update_glyph(u8 glyph) { update(get_outer_rect(glyph)); } @@ -63,7 +63,7 @@ void GlyphMapWidget::paint_event(GPaintEvent& event) painter.set_font(font()); painter.fill_rect(frame_inner_rect(), Color::White); - byte glyph = 0; + u8 glyph = 0; for (int row = 0; row < rows(); ++row) { for (int column = 0; column < columns(); ++column, ++glyph) { diff --git a/Applications/FontEditor/GlyphMapWidget.h b/Applications/FontEditor/GlyphMapWidget.h index 521c0f7c2f..944aca6542 100644 --- a/Applications/FontEditor/GlyphMapWidget.h +++ b/Applications/FontEditor/GlyphMapWidget.h @@ -8,8 +8,8 @@ public: GlyphMapWidget(Font&, GWidget* parent); virtual ~GlyphMapWidget() override; - byte selected_glyph() const { return m_selected_glyph; } - void set_selected_glyph(byte); + u8 selected_glyph() const { return m_selected_glyph; } + void set_selected_glyph(u8); int rows() const { return m_rows; } int columns() const { return 256 / m_rows; } @@ -20,19 +20,19 @@ public: Font& font() { return *m_font; } const Font& font() const { return *m_font; } - void update_glyph(byte); + void update_glyph(u8); - Function<void(byte)> on_glyph_selected; + Function<void(u8)> on_glyph_selected; private: virtual void paint_event(GPaintEvent&) override; virtual void mousedown_event(GMouseEvent&) override; - Rect get_outer_rect(byte glyph) const; + Rect get_outer_rect(u8 glyph) const; RefPtr<Font> m_font; int m_rows { 8 }; int m_horizontal_spacing { 2 }; int m_vertical_spacing { 2 }; - byte m_selected_glyph { 0 }; + u8 m_selected_glyph { 0 }; }; diff --git a/Applications/ProcessManager/MemoryStatsWidget.cpp b/Applications/ProcessManager/MemoryStatsWidget.cpp index d114d937d4..433b0b7c9b 100644 --- a/Applications/ProcessManager/MemoryStatsWidget.cpp +++ b/Applications/ProcessManager/MemoryStatsWidget.cpp @@ -64,16 +64,16 @@ void MemoryStatsWidget::refresh() auto file_contents = m_proc_memstat.read_all(); auto json = JsonValue::from_string(file_contents).as_object(); - unsigned kmalloc_eternal_allocated = json.get("kmalloc_eternal_allocated").to_dword(); + unsigned kmalloc_eternal_allocated = json.get("kmalloc_eternal_allocated").to_u32(); (void)kmalloc_eternal_allocated; - unsigned kmalloc_allocated = json.get("kmalloc_allocated").to_dword(); - unsigned kmalloc_available = json.get("kmalloc_available").to_dword(); - unsigned user_physical_allocated = json.get("user_physical_allocated").to_dword(); - unsigned user_physical_available = json.get("user_physical_available").to_dword(); - unsigned super_physical_alloc = json.get("super_physical_allocated").to_dword(); - unsigned super_physical_free = json.get("super_physical_available").to_dword(); - unsigned kmalloc_call_count = json.get("kmalloc_call_count").to_dword(); - unsigned kfree_call_count = json.get("kfree_call_count").to_dword(); + unsigned kmalloc_allocated = json.get("kmalloc_allocated").to_u32(); + unsigned kmalloc_available = json.get("kmalloc_available").to_u32(); + unsigned user_physical_allocated = json.get("user_physical_allocated").to_u32(); + unsigned user_physical_available = json.get("user_physical_available").to_u32(); + unsigned super_physical_alloc = json.get("super_physical_allocated").to_u32(); + unsigned super_physical_free = json.get("super_physical_available").to_u32(); + unsigned kmalloc_call_count = json.get("kmalloc_call_count").to_u32(); + unsigned kfree_call_count = json.get("kfree_call_count").to_u32(); size_t kmalloc_sum_available = kmalloc_allocated + kmalloc_available; size_t user_pages_available = user_physical_allocated + user_physical_available; diff --git a/Applications/ProcessManager/ProcessModel.cpp b/Applications/ProcessManager/ProcessModel.cpp index 9c0986d6e3..ac1c872305 100644 --- a/Applications/ProcessManager/ProcessModel.cpp +++ b/Applications/ProcessManager/ProcessModel.cpp @@ -198,12 +198,12 @@ void ProcessModel::update() auto json = JsonValue::from_string({ file_contents.data(), file_contents.size() }); json.as_array().for_each([&](auto& value) { const JsonObject& process_object = value.as_object(); - pid_t pid = process_object.get("pid").to_dword(); - unsigned nsched = process_object.get("times_scheduled").to_dword(); + pid_t pid = process_object.get("pid").to_u32(); + unsigned nsched = process_object.get("times_scheduled").to_u32(); ProcessState state; state.pid = pid; state.nsched = nsched; - unsigned uid = process_object.get("uid").to_dword(); + unsigned uid = process_object.get("uid").to_u32(); { auto it = m_usernames.find((uid_t)uid); if (it != m_usernames.end()) @@ -212,11 +212,11 @@ void ProcessModel::update() state.user = String::number(uid); } state.priority = process_object.get("priority").to_string(); - state.syscalls = process_object.get("syscall_count").to_dword(); + state.syscalls = process_object.get("syscall_count").to_u32(); state.state = process_object.get("state").to_string(); state.name = process_object.get("name").to_string(); - state.virtual_size = process_object.get("amount_virtual").to_dword(); - state.physical_size = process_object.get("amount_resident").to_dword(); + state.virtual_size = process_object.get("amount_virtual").to_u32(); + state.physical_size = process_object.get("amount_resident").to_u32(); sum_nsched += nsched; { auto it = m_processes.find(pid); @@ -240,7 +240,7 @@ void ProcessModel::update() continue; } auto& process = *it.value; - dword nsched_diff = process.current_state.nsched - process.previous_state.nsched; + u32 nsched_diff = process.current_state.nsched - process.previous_state.nsched; process.current_state.cpu_percent = ((float)nsched_diff * 100) / (float)(sum_nsched - last_sum_nsched); if (it.key != 0) { total_cpu_percent += process.current_state.cpu_percent; diff --git a/Applications/Terminal/Terminal.cpp b/Applications/Terminal/Terminal.cpp index 85579225b0..9140f81ede 100644 --- a/Applications/Terminal/Terminal.cpp +++ b/Applications/Terminal/Terminal.cpp @@ -17,8 +17,8 @@ #include <unistd.h> //#define TERMINAL_DEBUG -byte Terminal::Attribute::default_foreground_color = 7; -byte Terminal::Attribute::default_background_color = 0; +u8 Terminal::Attribute::default_foreground_color = 7; +u8 Terminal::Attribute::default_background_color = 0; Terminal::Terminal(int ptm_fd, RefPtr<CConfigFile> config) : m_ptm_fd(ptm_fd) @@ -45,7 +45,7 @@ Terminal::Terminal(int ptm_fd, RefPtr<CConfigFile> config) set_font(Font::load_from_file(font_entry)); m_notifier.on_ready_to_read = [this] { - byte buffer[BUFSIZ]; + u8 buffer[BUFSIZ]; ssize_t nread = read(m_ptm_fd, buffer, sizeof(buffer)); if (nread < 0) { dbgprintf("Terminal read error: %s\n", strerror(errno)); @@ -69,7 +69,7 @@ Terminal::Terminal(int ptm_fd, RefPtr<CConfigFile> config) m_config->read_num_entry("Window", "Height", 25)); } -Terminal::Line::Line(word length) +Terminal::Line::Line(u16 length) { set_length(length); } @@ -80,11 +80,11 @@ Terminal::Line::~Line() delete[] attributes; } -void Terminal::Line::set_length(word new_length) +void Terminal::Line::set_length(u16 new_length) { if (m_length == new_length) return; - auto* new_characters = new byte[new_length]; + auto* new_characters = new u8[new_length]; auto* new_attributes = new Attribute[new_length]; memset(new_characters, ' ', new_length); delete[] characters; @@ -98,7 +98,7 @@ void Terminal::Line::clear(Attribute attribute) { if (dirty) { memset(characters, ' ', m_length); - for (word i = 0; i < m_length; ++i) + for (u16 i = 0; i < m_length; ++i) attributes[i] = attribute; return; } @@ -125,17 +125,17 @@ void Terminal::clear() set_cursor(0, 0); } -inline bool is_valid_parameter_character(byte ch) +inline bool is_valid_parameter_character(u8 ch) { return ch >= 0x30 && ch <= 0x3f; } -inline bool is_valid_intermediate_character(byte ch) +inline bool is_valid_intermediate_character(u8 ch) { return ch >= 0x20 && ch <= 0x2f; } -inline bool is_valid_final_character(byte ch) +inline bool is_valid_final_character(u8 ch) { return ch >= 0x40 && ch <= 0x7e; } @@ -481,7 +481,7 @@ void Terminal::escape$S(const ParamVector& params) if (params.size() >= 1) count = params[0]; - for (word i = 0; i < count; i++) + for (u16 i = 0; i < count; i++) scroll_up(); } @@ -491,7 +491,7 @@ void Terminal::escape$T(const ParamVector& params) if (params.size() >= 1) count = params[0]; - for (word i = 0; i < count; i++) + for (u16 i = 0; i < count; i++) scroll_down(); } @@ -577,7 +577,7 @@ void Terminal::execute_xterm_command() m_xterm_param2.clear_with_capacity(); } -void Terminal::execute_escape_sequence(byte final) +void Terminal::execute_escape_sequence(u8 final) { bool question_param = false; m_final = final; @@ -701,7 +701,7 @@ void Terminal::execute_escape_sequence(byte final) void Terminal::newline() { - word new_row = m_cursor_row; + u16 new_row = m_cursor_row; if (m_cursor_row == m_scroll_region_bottom) { scroll_up(); } else { @@ -744,7 +744,7 @@ void Terminal::set_cursor(unsigned a_row, unsigned a_column) invalidate_cursor(); } -void Terminal::put_character_at(unsigned row, unsigned column, byte ch) +void Terminal::put_character_at(unsigned row, unsigned column, u8 ch) { ASSERT(row < rows()); ASSERT(column < columns()); @@ -757,7 +757,7 @@ void Terminal::put_character_at(unsigned row, unsigned column, byte ch) m_last_char = ch; } -void Terminal::on_char(byte ch) +void Terminal::on_char(u8 ch) { #ifdef TERMINAL_DEBUG dbgprintf("Terminal::on_char: %b (%c), fg=%u, bg=%u\n", ch, ch, m_current_attribute.foreground_color, m_current_attribute.background_color); @@ -913,7 +913,7 @@ void Terminal::unimplemented_xterm_escape() inject_string(message); } -void Terminal::set_size(word columns, word rows) +void Terminal::set_size(u16 columns, u16 rows) { if (columns == m_columns && rows == m_rows) return; @@ -965,14 +965,14 @@ void Terminal::set_size(word columns, word rows) ASSERT(rc == 0); } -Rect Terminal::glyph_rect(word row, word column) +Rect Terminal::glyph_rect(u16 row, u16 column) { int y = row * m_line_height; int x = column * font().glyph_width('x'); return { x + frame_thickness() + m_inset, y + frame_thickness() + m_inset, font().glyph_width('x'), font().glyph_height() }; } -Rect Terminal::row_rect(word row) +Rect Terminal::row_rect(u16 row) { int y = row * m_line_height; Rect rect = { frame_thickness() + m_inset, y + frame_thickness() + m_inset, font().glyph_width('x') * m_columns, font().glyph_height() }; @@ -1083,14 +1083,14 @@ void Terminal::paint_event(GPaintEvent& event) painter.fill_rect(frame_inner_rect(), Color(Color::Black).with_alpha(m_opacity)); invalidate_cursor(); - for (word row = 0; row < m_rows; ++row) { + for (u16 row = 0; row < m_rows; ++row) { auto& line = this->line(row); bool has_only_one_background_color = line.has_only_one_background_color(); if (m_visual_beep_timer.is_active()) painter.fill_rect(row_rect(row), Color::Red); else if (has_only_one_background_color) painter.fill_rect(row_rect(row), lookup_color(line.attributes[0].background_color).with_alpha(m_opacity)); - for (word column = 0; column < m_columns; ++column) { + for (u16 column = 0; column < m_columns; ++column) { char ch = line.characters[column]; bool should_reverse_fill_for_cursor_or_selection = (m_cursor_blink_state && m_in_active_window && row == m_cursor_row && column == m_cursor_column) || selection_contains({ row, column }); @@ -1167,7 +1167,7 @@ void Terminal::update_cursor() flush_dirty_lines(); } -void Terminal::set_opacity(byte new_opacity) +void Terminal::set_opacity(u8 new_opacity) { if (m_opacity == new_opacity) return; diff --git a/Applications/Terminal/Terminal.h b/Applications/Terminal/Terminal.h index c0243419ee..b60f924bbe 100644 --- a/Applications/Terminal/Terminal.h +++ b/Applications/Terminal/Terminal.h @@ -61,14 +61,14 @@ public: virtual ~Terminal() override; void create_window(); - void on_char(byte); + void on_char(u8); void flush_dirty_lines(); void force_repaint(); void apply_size_increments_to_window(GWindow&); - void set_opacity(byte); + void set_opacity(u8); float opacity() { return m_opacity; }; bool should_beep() { return m_should_beep; } void set_should_beep(bool sb) { m_should_beep = sb; }; @@ -98,7 +98,7 @@ private: void scroll_down(); void newline(); void set_cursor(unsigned row, unsigned column); - void put_character_at(unsigned row, unsigned column, byte ch); + void put_character_at(unsigned row, unsigned column, u8 ch); void invalidate_cursor(); void set_window_title(const String&); @@ -131,18 +131,18 @@ private: void clear(); - void set_size(word columns, word rows); - word columns() const { return m_columns; } - word rows() const { return m_rows; } - Rect glyph_rect(word row, word column); - Rect row_rect(word row); + void set_size(u16 columns, u16 rows); + u16 columns() const { return m_columns; } + u16 rows() const { return m_rows; } + Rect glyph_rect(u16 row, u16 column); + Rect row_rect(u16 row); void update_cursor(); struct Attribute { Attribute() { reset(); } - static byte default_foreground_color; - static byte default_background_color; + static u8 default_foreground_color; + static u8 default_background_color; void reset() { @@ -150,8 +150,8 @@ private: background_color = default_background_color; flags = Flags::NoAttributes; } - byte foreground_color; - byte background_color; + u8 foreground_color; + u8 background_color; enum Flags { NoAttributes = 0x00, @@ -180,15 +180,15 @@ private: }; struct Line { - explicit Line(word columns); + explicit Line(u16 columns); ~Line(); void clear(Attribute); bool has_only_one_background_color() const; - void set_length(word); - byte* characters { nullptr }; + void set_length(u16); + u8* characters { nullptr }; Attribute* attributes { nullptr }; bool dirty { false }; - word m_length { 0 }; + u16 m_length { 0 }; }; Line& line(size_t index) { @@ -209,20 +209,20 @@ private: int m_scroll_region_top { 0 }; int m_scroll_region_bottom { 0 }; - word m_columns { 0 }; - word m_rows { 0 }; + u16 m_columns { 0 }; + u16 m_rows { 0 }; - byte m_cursor_row { 0 }; - byte m_cursor_column { 0 }; - byte m_saved_cursor_row { 0 }; - byte m_saved_cursor_column { 0 }; + u8 m_cursor_row { 0 }; + u8 m_cursor_column { 0 }; + u8 m_saved_cursor_row { 0 }; + u8 m_saved_cursor_column { 0 }; bool m_stomp { false }; bool m_should_beep { false }; Attribute m_current_attribute; - void execute_escape_sequence(byte final); + void execute_escape_sequence(u8 final); void execute_xterm_command(); enum EscapeState { @@ -237,12 +237,12 @@ private: ExpectXtermFinal, }; EscapeState m_escape_state { Normal }; - Vector<byte> m_parameters; - Vector<byte> m_intermediates; - Vector<byte> m_xterm_param1; - Vector<byte> m_xterm_param2; + Vector<u8> m_parameters; + Vector<u8> m_intermediates; + Vector<u8> m_xterm_param1; + Vector<u8> m_xterm_param2; Vector<bool> m_horizontal_tabs; - byte m_final { 0 }; + u8 m_final { 0 }; bool m_belling { false }; int m_pixel_width { 0 }; @@ -261,7 +261,7 @@ private: CNotifier m_notifier; - byte m_opacity { 255 }; + u8 m_opacity { 255 }; bool m_needs_background_fill { true }; bool m_cursor_blink_state { true }; @@ -271,5 +271,5 @@ private: CTimer m_visual_beep_timer; RefPtr<CConfigFile> m_config; - byte m_last_char { 0 }; + u8 m_last_char { 0 }; }; |