Skip to content

Commit

Permalink
Change 'virtual' to 'override' where appropriate
Browse files Browse the repository at this point in the history
This makes it clearer which functions override.
  • Loading branch information
ssilverman committed Nov 29, 2024
1 parent 058d280 commit 1236bbb
Show file tree
Hide file tree
Showing 26 changed files with 189 additions and 189 deletions.
2 changes: 1 addition & 1 deletion teensy/CrashReport.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class CrashReportClass: public Printable {
public:
virtual size_t printTo(Print& p) const;
size_t printTo(Print& p) const override;
void clear();
operator bool();
};
Expand Down
12 changes: 6 additions & 6 deletions teensy/HardwareSerial.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ class HardwareSerial : public Stream
void _begin(uint16_t baud_count, uint8_t pin);
void end(void);
void transmitterEnable(uint8_t pin);
virtual int available(void);
virtual int peek(void);
virtual int read(void);
virtual void flush(void);
int availableForWrite(void);
int available(void) override;
int peek(void) override;
int read(void) override;
void flush(void) override;
int availableForWrite(void) override;
void clear(void);
#if ARDUINO >= 100
virtual size_t write(uint8_t);
size_t write(uint8_t) override;
#else
virtual void write(uint8_t);
#endif
Expand Down
2 changes: 1 addition & 1 deletion teensy/IPAddress.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class IPAddress : public Printable {
IPAddress& operator=(const uint8_t *address);
IPAddress& operator=(uint32_t address);

virtual size_t printTo(Print& p) const;
size_t printTo(Print& p) const override;

friend class EthernetClass;
friend class UDP;
Expand Down
2 changes: 1 addition & 1 deletion teensy3/CrashReport.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class CrashReportClass: public Printable {
public:
virtual size_t printTo(Print& p) const;
size_t printTo(Print& p) const override;
void clear();
operator bool();
void breadcrumb(unsigned int num, unsigned int value) { }
Expand Down
2 changes: 1 addition & 1 deletion teensy3/FS.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class File final : public Stream {
}

// override print version
virtual size_t write(const uint8_t *buf, size_t size) {
size_t write(const uint8_t *buf, size_t size) override {
return (f) ? f->write((void*)buf, size) : 0;
}

Expand Down
84 changes: 42 additions & 42 deletions teensy3/HardwareSerial.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,21 +292,21 @@ class HardwareSerial : public Stream
virtual void setTX(uint8_t pin, bool opendrain=false) { serial_set_tx(pin, opendrain); }
virtual bool attachRts(uint8_t pin) { return serial_set_rts(pin); }
virtual bool attachCts(uint8_t pin) { return serial_set_cts(pin); }
virtual int available(void) { return serial_available(); }
virtual int peek(void) { return serial_peek(); }
virtual int read(void) { return serial_getchar(); }
virtual void flush(void) { serial_flush(); }
int available(void) override { return serial_available(); }
int peek(void) override { return serial_peek(); }
int read(void) override { return serial_getchar(); }
void flush(void) override { serial_flush(); }
virtual void clear(void) { serial_clear(); }
virtual int availableForWrite(void) { return serial_write_buffer_free(); }
int availableForWrite(void) override { return serial_write_buffer_free(); }
virtual void addMemoryForRead(void *buffer, size_t length) {serial_add_memory_for_read(buffer, length);}
virtual void addMemoryForWrite(void *buffer, size_t length){serial_add_memory_for_write(buffer, length);}
using Print::write;
virtual size_t write(uint8_t c) { serial_putchar(c); return 1; }
size_t write(uint8_t c) override { serial_putchar(c); return 1; }
virtual size_t write(unsigned long n) { return write((uint8_t)n); }
virtual size_t write(long n) { return write((uint8_t)n); }
virtual size_t write(unsigned int n) { return write((uint8_t)n); }
virtual size_t write(int n) { return write((uint8_t)n); }
virtual size_t write(const uint8_t *buffer, size_t size)
size_t write(const uint8_t *buffer, size_t size) override
{ serial_write(buffer, size); return size; }
virtual size_t write(const char *str) { size_t len = strlen(str);
serial_write((const uint8_t *)str, len);
Expand Down Expand Up @@ -346,21 +346,21 @@ class HardwareSerial2 : public HardwareSerial
virtual void setTX(uint8_t pin, bool opendrain=false) { serial2_set_tx(pin, opendrain); }
virtual bool attachRts(uint8_t pin) { return serial2_set_rts(pin); }
virtual bool attachCts(uint8_t pin) { return serial2_set_cts(pin); }
virtual int available(void) { return serial2_available(); }
virtual int peek(void) { return serial2_peek(); }
virtual int read(void) { return serial2_getchar(); }
virtual void flush(void) { serial2_flush(); }
int available(void) override { return serial2_available(); }
int peek(void) override { return serial2_peek(); }
int read(void) override { return serial2_getchar(); }
void flush(void) override { serial2_flush(); }
virtual void clear(void) { serial2_clear(); }
virtual int availableForWrite(void) { return serial2_write_buffer_free(); }
int availableForWrite(void) override { return serial2_write_buffer_free(); }
virtual void addMemoryForRead(void *buffer, size_t length) {serial2_add_memory_for_read(buffer, length);}
virtual void addMemoryForWrite(void *buffer, size_t length){serial2_add_memory_for_write(buffer, length);}
using Print::write;
virtual size_t write(uint8_t c) { serial2_putchar(c); return 1; }
size_t write(uint8_t c) override { serial2_putchar(c); return 1; }
virtual size_t write(unsigned long n) { return write((uint8_t)n); }
virtual size_t write(long n) { return write((uint8_t)n); }
virtual size_t write(unsigned int n) { return write((uint8_t)n); }
virtual size_t write(int n) { return write((uint8_t)n); }
virtual size_t write(const uint8_t *buffer, size_t size)
size_t write(const uint8_t *buffer, size_t size) override
{ serial2_write(buffer, size); return size; }
virtual size_t write(const char *str) { size_t len = strlen(str);
serial2_write((const uint8_t *)str, len);
Expand All @@ -385,21 +385,21 @@ class HardwareSerial3 : public HardwareSerial
virtual void setTX(uint8_t pin, bool opendrain=false) { serial3_set_tx(pin, opendrain); }
virtual bool attachRts(uint8_t pin) { return serial3_set_rts(pin); }
virtual bool attachCts(uint8_t pin) { return serial3_set_cts(pin); }
virtual int available(void) { return serial3_available(); }
virtual int peek(void) { return serial3_peek(); }
virtual int read(void) { return serial3_getchar(); }
virtual void flush(void) { serial3_flush(); }
int available(void) override { return serial3_available(); }
int peek(void) override { return serial3_peek(); }
int read(void) override { return serial3_getchar(); }
void flush(void) override { serial3_flush(); }
virtual void clear(void) { serial3_clear(); }
virtual int availableForWrite(void) { return serial3_write_buffer_free(); }
int availableForWrite(void) override { return serial3_write_buffer_free(); }
virtual void addMemoryForRead(void *buffer, size_t length) {serial3_add_memory_for_read(buffer, length);}
virtual void addMemoryForWrite(void *buffer, size_t length){serial3_add_memory_for_write(buffer, length);}
using Print::write;
virtual size_t write(uint8_t c) { serial3_putchar(c); return 1; }
size_t write(uint8_t c) override { serial3_putchar(c); return 1; }
virtual size_t write(unsigned long n) { return write((uint8_t)n); }
virtual size_t write(long n) { return write((uint8_t)n); }
virtual size_t write(unsigned int n) { return write((uint8_t)n); }
virtual size_t write(int n) { return write((uint8_t)n); }
virtual size_t write(const uint8_t *buffer, size_t size)
size_t write(const uint8_t *buffer, size_t size) override
{ serial3_write(buffer, size); return size; }
virtual size_t write(const char *str) { size_t len = strlen(str);
serial3_write((const uint8_t *)str, len);
Expand All @@ -424,21 +424,21 @@ class HardwareSerial4 : public HardwareSerial
virtual void setTX(uint8_t pin, bool opendrain=false) { serial4_set_tx(pin, opendrain); }
virtual bool attachRts(uint8_t pin) { return serial4_set_rts(pin); }
virtual bool attachCts(uint8_t pin) { return serial4_set_cts(pin); }
virtual int available(void) { return serial4_available(); }
virtual int peek(void) { return serial4_peek(); }
virtual int read(void) { return serial4_getchar(); }
virtual void flush(void) { serial4_flush(); }
int available(void) override { return serial4_available(); }
int peek(void) override { return serial4_peek(); }
int read(void) override { return serial4_getchar(); }
void flush(void) override { serial4_flush(); }
virtual void clear(void) { serial4_clear(); }
virtual int availableForWrite(void) { return serial4_write_buffer_free(); }
int availableForWrite(void) override { return serial4_write_buffer_free(); }
virtual void addMemoryForRead(void *buffer, size_t length) {serial4_add_memory_for_read(buffer, length);}
virtual void addMemoryForWrite(void *buffer, size_t length){serial4_add_memory_for_write(buffer, length);}
using Print::write;
virtual size_t write(uint8_t c) { serial4_putchar(c); return 1; }
size_t write(uint8_t c) override { serial4_putchar(c); return 1; }
virtual size_t write(unsigned long n) { return write((uint8_t)n); }
virtual size_t write(long n) { return write((uint8_t)n); }
virtual size_t write(unsigned int n) { return write((uint8_t)n); }
virtual size_t write(int n) { return write((uint8_t)n); }
virtual size_t write(const uint8_t *buffer, size_t size)
size_t write(const uint8_t *buffer, size_t size) override
{ serial4_write(buffer, size); return size; }
virtual size_t write(const char *str) { size_t len = strlen(str);
serial4_write((const uint8_t *)str, len);
Expand All @@ -463,21 +463,21 @@ class HardwareSerial5 : public HardwareSerial
virtual void setTX(uint8_t pin, bool opendrain=false) { serial5_set_tx(pin, opendrain); }
virtual bool attachRts(uint8_t pin) { return serial5_set_rts(pin); }
virtual bool attachCts(uint8_t pin) { return serial5_set_cts(pin); }
virtual int available(void) { return serial5_available(); }
virtual int peek(void) { return serial5_peek(); }
virtual int read(void) { return serial5_getchar(); }
virtual void flush(void) { serial5_flush(); }
int available(void) override { return serial5_available(); }
int peek(void) override { return serial5_peek(); }
int read(void) override { return serial5_getchar(); }
void flush(void) override { serial5_flush(); }
virtual void clear(void) { serial5_clear(); }
virtual int availableForWrite(void) { return serial5_write_buffer_free(); }
int availableForWrite(void) override { return serial5_write_buffer_free(); }
virtual void addMemoryForRead(void *buffer, size_t length) {serial5_add_memory_for_read(buffer, length);}
virtual void addMemoryForWrite(void *buffer, size_t length){serial5_add_memory_for_write(buffer, length);}
using Print::write;
virtual size_t write(uint8_t c) { serial5_putchar(c); return 1; }
size_t write(uint8_t c) override { serial5_putchar(c); return 1; }
virtual size_t write(unsigned long n) { return write((uint8_t)n); }
virtual size_t write(long n) { return write((uint8_t)n); }
virtual size_t write(unsigned int n) { return write((uint8_t)n); }
virtual size_t write(int n) { return write((uint8_t)n); }
virtual size_t write(const uint8_t *buffer, size_t size)
size_t write(const uint8_t *buffer, size_t size) override
{ serial5_write(buffer, size); return size; }
virtual size_t write(const char *str) { size_t len = strlen(str);
serial5_write((const uint8_t *)str, len);
Expand Down Expand Up @@ -509,21 +509,21 @@ class HardwareSerial6 : public HardwareSerial
virtual void setTX(uint8_t pin, bool opendrain=false) { serial6_set_tx(pin, opendrain); }
virtual bool attachRts(uint8_t pin) { return serial6_set_rts(pin); }
virtual bool attachCts(uint8_t pin) { return serial6_set_cts(pin); }
virtual int available(void) { return serial6_available(); }
virtual int peek(void) { return serial6_peek(); }
virtual int read(void) { return serial6_getchar(); }
virtual void flush(void) { serial6_flush(); }
int available(void) override { return serial6_available(); }
int peek(void) override { return serial6_peek(); }
int read(void) override { return serial6_getchar(); }
void flush(void) override { serial6_flush(); }
virtual void clear(void) { serial6_clear(); }
virtual int availableForWrite(void) { return serial6_write_buffer_free(); }
int availableForWrite(void) override { return serial6_write_buffer_free(); }
virtual void addMemoryForRead(void *buffer, size_t length) {serial6_add_memory_for_read(buffer, length);}
virtual void addMemoryForWrite(void *buffer, size_t length){serial6_add_memory_for_write(buffer, length);}
using Print::write;
virtual size_t write(uint8_t c) { serial6_putchar(c); return 1; }
size_t write(uint8_t c) override { serial6_putchar(c); return 1; }
virtual size_t write(unsigned long n) { return write((uint8_t)n); }
virtual size_t write(long n) { return write((uint8_t)n); }
virtual size_t write(unsigned int n) { return write((uint8_t)n); }
virtual size_t write(int n) { return write((uint8_t)n); }
virtual size_t write(const uint8_t *buffer, size_t size)
size_t write(const uint8_t *buffer, size_t size) override
{ serial6_write(buffer, size); return size; }
virtual size_t write(const char *str) { size_t len = strlen(str);
serial6_write((const uint8_t *)str, len);
Expand Down
2 changes: 1 addition & 1 deletion teensy3/IPAddress.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class IPAddress : public Printable {
return *this;
}

virtual size_t printTo(Print& p) const;
size_t printTo(Print& p) const override;

friend class EthernetClass;
friend class UDP;
Expand Down
2 changes: 1 addition & 1 deletion teensy3/usb_keyboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class usb_keyboard_class : public Print
public:
void begin(void) { }
void end(void) { }
virtual size_t write(uint8_t c) { usb_keyboard_write(c); return 1; }
size_t write(uint8_t c) override { usb_keyboard_write(c); return 1; }
size_t write(unsigned long n) { return write((uint8_t)n); }
size_t write(long n) { return write((uint8_t)n); }
size_t write(unsigned int n) { return write((uint8_t)n); }
Expand Down
28 changes: 14 additions & 14 deletions teensy3/usb_seremu.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,17 @@ class usb_seremu_class : public Stream
}
}
void end() { /* TODO: flush output and shut down USB port */ };
virtual int available() { return usb_seremu_available(); }
virtual int read() { return usb_seremu_getchar(); }
virtual int peek() { return usb_seremu_peekchar(); }
virtual void flush() { usb_seremu_flush_output(); }
virtual size_t write(uint8_t c) { return usb_seremu_putchar(c); }
virtual size_t write(const uint8_t *buffer, size_t size) { return usb_seremu_write(buffer, size); }
int available() override { return usb_seremu_available(); }
int read() override { return usb_seremu_getchar(); }
int peek() override { return usb_seremu_peekchar(); }
void flush() override { usb_seremu_flush_output(); }
size_t write(uint8_t c) override { return usb_seremu_putchar(c); }
size_t write(const uint8_t *buffer, size_t size) override { return usb_seremu_write(buffer, size); }
size_t write(unsigned long n) { return write((uint8_t)n); }
size_t write(long n) { return write((uint8_t)n); }
size_t write(unsigned int n) { return write((uint8_t)n); }
size_t write(int n) { return write((uint8_t)n); }
virtual int availableForWrite() { return usb_seremu_write_buffer_free(); }
int availableForWrite() override { return usb_seremu_write_buffer_free(); }
using Print::write;
void send_now(void) { usb_seremu_flush_output(); };
uint32_t baud(void) { return 9600; }
Expand Down Expand Up @@ -120,17 +120,17 @@ class usb_seremu_class : public Stream
constexpr usb_seremu_class() {}
void begin(long) { };
void end() { };
virtual int available() { return 0; }
virtual int read() { return -1; }
virtual int peek() { return -1; }
virtual void flush() { }
virtual size_t write(uint8_t c) { return 1; }
virtual size_t write(const uint8_t *buffer, size_t size) { return size; }
int available() override { return 0; }
int read() override { return -1; }
int peek() override { return -1; }
void flush() override { }
size_t write(uint8_t c) override { return 1; }
size_t write(const uint8_t *buffer, size_t size) override { return size; }
size_t write(unsigned long n) { return 1; }
size_t write(long n) { return 1; }
size_t write(unsigned int n) { return 1; }
size_t write(int n) { return 1; }
virtual int availableForWrite() { return 0; }
int availableForWrite() override { return 0; }
using Print::write;
void send_now(void) { }
uint32_t baud(void) { return 0; }
Expand Down
28 changes: 14 additions & 14 deletions teensy3/usb_serial.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,18 @@ class usb_serial_class : public Stream
}
}
void end() { /* TODO: flush output and shut down USB port */ };
virtual int available() { return usb_serial_available(); }
virtual int read() { return usb_serial_getchar(); }
virtual int peek() { return usb_serial_peekchar(); }
virtual void flush() { usb_serial_flush_output(); } // TODO: actually wait for data to leave USB...
int available() override { return usb_serial_available(); }
int read() override { return usb_serial_getchar(); }
int peek() override { return usb_serial_peekchar(); }
void flush() override { usb_serial_flush_output(); } // TODO: actually wait for data to leave USB...
virtual void clear(void) { usb_serial_flush_input(); }
virtual size_t write(uint8_t c) { return usb_serial_putchar(c); }
virtual size_t write(const uint8_t *buffer, size_t size) { return usb_serial_write(buffer, size); }
size_t write(uint8_t c) override { return usb_serial_putchar(c); }
size_t write(const uint8_t *buffer, size_t size) override { return usb_serial_write(buffer, size); }
size_t write(unsigned long n) { return write((uint8_t)n); }
size_t write(long n) { return write((uint8_t)n); }
size_t write(unsigned int n) { return write((uint8_t)n); }
size_t write(int n) { return write((uint8_t)n); }
virtual int availableForWrite() { return usb_serial_write_buffer_free(); }
int availableForWrite() override { return usb_serial_write_buffer_free(); }
using Print::write;
void send_now(void) { usb_serial_flush_output(); }
uint32_t baud(void) { return usb_cdc_line_coding[0]; }
Expand Down Expand Up @@ -144,18 +144,18 @@ class usb_serial_class : public Stream
constexpr usb_serial_class() {}
void begin(long) { };
void end() { };
virtual int available() { return 0; }
virtual int read() { return -1; }
virtual int peek() { return -1; }
virtual void flush() { }
int available() override { return 0; }
int read() override { return -1; }
int peek() override { return -1; }
void flush() override { }
virtual void clear() { }
virtual size_t write(uint8_t c) { return 1; }
virtual size_t write(const uint8_t *buffer, size_t size) { return size; }
size_t write(uint8_t c) override { return 1; }
size_t write(const uint8_t *buffer, size_t size) override { return size; }
size_t write(unsigned long n) { return 1; }
size_t write(long n) { return 1; }
size_t write(unsigned int n) { return 1; }
size_t write(int n) { return 1; }
virtual int availableForWrite() { return 0; }
int availableForWrite() override { return 0; }
using Print::write;
void send_now(void) { }
uint32_t baud(void) { return 0; }
Expand Down
Loading

0 comments on commit 1236bbb

Please sign in to comment.