From 795e23c05d81ca40f46f38bac0872272de6f9851 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 16 Jan 2019 21:12:03 -0800 Subject: GLK: Constifying attribute, width calc methods --- engines/glk/window_text_buffer.cpp | 3 +-- engines/glk/window_text_buffer.h | 2 +- engines/glk/windows.cpp | 4 ++-- engines/glk/windows.h | 10 +++++----- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/engines/glk/window_text_buffer.cpp b/engines/glk/window_text_buffer.cpp index ce4dd7c22e..0faafc803c 100644 --- a/engines/glk/window_text_buffer.cpp +++ b/engines/glk/window_text_buffer.cpp @@ -1587,8 +1587,7 @@ void TextBufferWindow::scrollResize() { _scrollBack += SCROLLBACK; } -int TextBufferWindow::calcWidth(uint32 *chars, Attributes *attrs, int startchar, - int numChars, int spw) { +int TextBufferWindow::calcWidth(const uint32 *chars, const Attributes *attrs, int startchar, int numChars, int spw) { Screen &screen = *g_vm->_screen; int w = 0; int a, b; diff --git a/engines/glk/window_text_buffer.h b/engines/glk/window_text_buffer.h index 47d87a45ab..0ac74d2e2a 100644 --- a/engines/glk/window_text_buffer.h +++ b/engines/glk/window_text_buffer.h @@ -91,7 +91,7 @@ private: void scrollOneLine(bool forced); void scrollResize(); - int calcWidth(uint32 *chars, Attributes *attrs, int startchar, int numchars, int spw); + int calcWidth(const uint32 *chars, const Attributes *attrs, int startchar, int numchars, int spw); public: int _width, _height; int _spaced; diff --git a/engines/glk/windows.cpp b/engines/glk/windows.cpp index c8ab44768d..624defa9f5 100644 --- a/engines/glk/windows.cpp +++ b/engines/glk/windows.cpp @@ -730,7 +730,7 @@ void Attributes::clear() { style = 0; } -byte *Attributes::attrBg(WindowStyle *styles) { +const byte *Attributes::attrBg(const WindowStyle *styles) { int revset = reverse || (styles[style].reverse && !Windows::_overrideReverse); int zfset = fgset ? fgset : Windows::_overrideFgSet; @@ -771,7 +771,7 @@ byte *Attributes::attrBg(WindowStyle *styles) { } } -byte *Attributes::attrFg(WindowStyle *styles) { +const byte *Attributes::attrFg(const WindowStyle *styles) { int revset = reverse || (styles[style].reverse && !Windows::_overrideReverse); int zfset = fgset ? fgset : Windows::_overrideFgSet; diff --git a/engines/glk/windows.h b/engines/glk/windows.h index c905556f9e..c917d2f04b 100644 --- a/engines/glk/windows.h +++ b/engines/glk/windows.h @@ -328,7 +328,7 @@ struct Attributes { /** * Equality comparison */ - bool operator==(const Attributes &src) { + bool operator==(const Attributes &src) const { return fgset == src.fgset && bgset == src.bgset && reverse == src.reverse && style == src.style && fgcolor == src.fgcolor && bgcolor == src.bgcolor && hyper == src.hyper; @@ -336,7 +336,7 @@ struct Attributes { /** * Inequality comparison */ - bool operator!=(const Attributes &src) { + bool operator!=(const Attributes &src) const { return fgset != src.fgset || bgset != src.bgset || reverse != src.reverse || style != src.style || fgcolor != src.fgcolor || bgcolor != src.bgcolor || hyper != src.hyper; @@ -345,17 +345,17 @@ struct Attributes { /** * Return the background color for the current font style */ - byte *attrBg(WindowStyle *styles); + const byte *attrBg(const WindowStyle *styles); /** * Return the foreground color for the current font style */ - byte *attrFg(WindowStyle *styles); + const byte *attrFg(const WindowStyle *styles); /** * Get the font for the current font style */ - FACES attrFont(WindowStyle *styles) const { + FACES attrFont(const WindowStyle *styles) const { return styles[style].font; } }; -- cgit v1.2.3