use scoped enum instead of #define
This commit is contained in:
parent
7064afc1f1
commit
887fb4b980
@ -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++;
|
||||
|
@ -5,8 +5,6 @@
|
||||
#include "PagedBuffer.h"
|
||||
#include <utility>
|
||||
|
||||
#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
|
||||
|
Loading…
x
Reference in New Issue
Block a user