From 887fb4b980d0ebeef1553e5c3337c23cac68aa66 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Sat, 30 Jul 2016 09:54:30 -0400 Subject: [PATCH] use scoped enum instead of #define --- src/core/PieceTable.cc | 2 +- src/core/PieceTable.h | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/core/PieceTable.cc b/src/core/PieceTable.cc index 95a1f66..8ea66bd 100644 --- a/src/core/PieceTable.cc +++ b/src/core/PieceTable.cc @@ -22,7 +22,7 @@ void PieceTable::append_initial_line_piece(uint8_t * start, uint32_t length, uin piece->length = length; piece->n_chars = n_chars; if (eol) - piece->n_chars |= PIECE_DESCRIPTOR_N_CHARS_EOL_FLAG_MASK; + piece->n_chars |= Piece::N_CHARS_EOL_FLAG; end_piece->prev->next = piece; end_piece->prev = piece; m_num_lines++; diff --git a/src/core/PieceTable.h b/src/core/PieceTable.h index efb0add..4912e04 100644 --- a/src/core/PieceTable.h +++ b/src/core/PieceTable.h @@ -5,8 +5,6 @@ #include "PagedBuffer.h" #include -#define PIECE_DESCRIPTOR_N_CHARS_EOL_FLAG_MASK 0x80000000u - class PieceTable { public: @@ -18,6 +16,11 @@ public: struct Piece { + enum + { + N_CHARS_EOL_FLAG = 0x80000000u, + }; + /** The previous piece in the chain. */ Piece * prev; @@ -37,13 +40,13 @@ public: uint32_t n_chars; /** Get the number of characters pointed to by this piece. */ - uint32_t get_n_chars() { return n_chars & (~PIECE_DESCRIPTOR_N_CHARS_EOL_FLAG_MASK); } + uint32_t get_n_chars() { return n_chars & (~N_CHARS_EOL_FLAG); } /** Get whether this piece is the end of a line. */ - bool eol() { return (n_chars & PIECE_DESCRIPTOR_N_CHARS_EOL_FLAG_MASK) != 0u; } + bool eol() { return (n_chars & N_CHARS_EOL_FLAG) != 0u; } /** Toggle whether this piece is the end of a line. */ - void toggle_eol() { n_chars ^= PIECE_DESCRIPTOR_N_CHARS_EOL_FLAG_MASK; } + void toggle_eol() { n_chars ^= N_CHARS_EOL_FLAG; } }; struct Position