1

changed a lot of small clang-tidy warnings

This commit is contained in:
churl
2022-05-23 17:06:11 +02:00
parent b78faebdc5
commit 7927220247
30 changed files with 158 additions and 190 deletions

View File

@ -13,9 +13,8 @@
#define __Chain_include__
class Chain {
private:
Chain(const Chain &copy); // Verhindere Kopieren
Chain(const Chain& copy) = delete; // Verhindere Kopieren
public:
Chain* next;

View File

@ -28,20 +28,20 @@
// NOTE: I added this
class fillw {
public:
fillw() : w(0) {};
fillw(unsigned char w) : w(w) {};
fillw() : w(0) {}
fillw(unsigned char w) : w(w) {}
unsigned char w;
};
class fillc {
public:
fillc() : c(' ') {};
fillc(char c) : c(c) {};
fillc() : c(' ') {}
fillc(char c) : c(c) {}
char c;
};
class OutStream : public StringBuffer {
private:
OutStream(const OutStream& copy); // Verhindere Kopieren
OutStream(const OutStream& copy) = delete; // Verhindere Kopieren
// NOTE: I added this
unsigned char fill_used; // indicates how many characters are already used by the text internally
@ -55,13 +55,7 @@ public:
unsigned char fill_width;
char fill_char; // fill character for fixed width
OutStream() : StringBuffer() {
base = 10; // initial Dezimalsystem
fill_width = 0; // no fixed width
fill_char = ' '; // fill with spaces
fill_used = 0;
}
OutStream() : fill_used(0), base(10), fill_width(0), fill_char(' ') {}
// Methode zur Ausgabe des Pufferinhalts der Basisklasse StringBuffer.
void flush() override;
@ -165,7 +159,7 @@ public:
// Bestimmung der groessten Potenz der gewaehlten Zahlenbasis, die
// noch kleiner als die darzustellende Zahl ist.
for (div = 1; ival / div >= (unsigned long)os.base; div *= os.base) {};
for (div = 1; ival / div >= (unsigned long)os.base; div *= os.base) {}
// ziffernweise Ausgabe der Zahl
for (; div > 0; div /= (unsigned long)os.base) {

View File

@ -3,7 +3,7 @@
// NOTE: I added this file
void ScrollbackBuffer::put(CGA::cga_line_t* line) {
CGA::cga_line_t* destination = (CGA::cga_line_t*)this->buffer + this->pos;
CGA::cga_line_t* destination = (CGA::cga_line_t*)this->buffer.get() + this->pos;
mmem::memcpy<CGA::cga_line_t>(destination, line);
this->pos = (this->pos + 1) % this->rows;
@ -21,13 +21,13 @@ void ScrollbackBuffer::get(CGA::cga_line_t* destination, unsigned char page) con
unsigned int wrapline;
for (unsigned int line = 0; line < (this->rows / this->pages); ++line) {
wrapline = (this->pos + rpage * (this->rows / this->pages) + line) % this->rows;
mmem::memcpy<CGA::cga_line_t>(destination + line, (CGA::cga_line_t*)this->buffer + wrapline);
mmem::memcpy<CGA::cga_line_t>(destination + line, (CGA::cga_line_t*)this->buffer.get() + wrapline);
}
}
void ScrollbackBuffer::clear() {
for (unsigned char page = 0; page < this->pages; ++page) {
mmem::zero<CGA::cga_page_t>(this->buffer + page);
mmem::zero<CGA::cga_page_t>(this->buffer.get() + page);
}
this->pos = 0;
}

View File

@ -3,14 +3,15 @@
#include "devices/CGA.h"
#include "lib/MyStdLib.h"
#include <memory>
#include <stddef.h>
// NOTE: I added this file
class ScrollbackBuffer {
private:
CGA::cga_page_t* buffer; // Circular buffer to store lines that left the screen
unsigned int pos; // Buffer write position
std::unique_ptr<CGA::cga_page_t[]> buffer; // Circular buffer to store lines that left the screen
unsigned int pos; // Buffer write position
ScrollbackBuffer(const ScrollbackBuffer&) = delete;
@ -20,12 +21,8 @@ public:
ScrollbackBuffer(unsigned char rows, unsigned char pages)
: pos(0), pages(pages), rows(rows * pages) {
this->buffer = new CGA::cga_page_t[pages]; // Allocate with new because it's quite large (and I want to use the allocator)
this->clear(); // Null out the buffer so no crap gets displayed
}
~ScrollbackBuffer() {
delete[] this->buffer;
this->buffer = std::make_unique<CGA::cga_page_t[]>(pages); // Allocate with new because it's quite large (and I want to use the allocator)
this->clear(); // Null out the buffer so no crap gets displayed
}
void put(CGA::cga_line_t* line);

View File

@ -31,6 +31,7 @@
void StringBuffer::put(char c) {
buffer[pos] = c;
pos++;
if (pos == sizeof(buffer))
if (pos == sizeof(buffer)) {
flush();
}
}