Skip to content

Commit 6aba145

Browse files
ChetSimpsonejaquay
authored andcommitted
add [[nodiscard]] attribute to functions that return a value
add [[maybe_unused]] attribute to unused parameters add missing copyright headers
1 parent c696a16 commit 6aba145

28 files changed

+249
-166
lines changed

libcommon/include/vcc/cartridges/capi_adapter_cartridge.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,21 @@ namespace vcc::cartridges
4040
path_type configuration_path,
4141
const cartridge_capi_context& capi_context);
4242

43-
LIBCOMMON_EXPORT name_type name() const override;
44-
LIBCOMMON_EXPORT catalog_id_type catalog_id() const override;
45-
LIBCOMMON_EXPORT description_type description() const override;
43+
LIBCOMMON_EXPORT [[nodiscard]] name_type name() const override;
44+
LIBCOMMON_EXPORT [[nodiscard]] catalog_id_type catalog_id() const override;
45+
LIBCOMMON_EXPORT [[nodiscard]] description_type description() const override;
4646

4747
LIBCOMMON_EXPORT void start() override;
4848
LIBCOMMON_EXPORT void stop() override;
4949
LIBCOMMON_EXPORT void reset() override;
5050

51-
LIBCOMMON_EXPORT unsigned char read_memory_byte(unsigned short memory_address) override;
51+
LIBCOMMON_EXPORT [[nodiscard]] unsigned char read_memory_byte(unsigned short memory_address) override;
5252

5353
LIBCOMMON_EXPORT void write_port(unsigned char port_id, unsigned char value) override;
54-
LIBCOMMON_EXPORT unsigned char read_port(unsigned char port_id) override;
54+
LIBCOMMON_EXPORT [[nodiscard]] unsigned char read_port(unsigned char port_id) override;
5555

5656
LIBCOMMON_EXPORT void process_horizontal_sync() override;
57-
LIBCOMMON_EXPORT unsigned short sample_audio() override;
57+
LIBCOMMON_EXPORT [[nodiscard]] unsigned short sample_audio() override;
5858

5959
LIBCOMMON_EXPORT void status(char* text_buffer, size_t buffer_size) override;
6060
LIBCOMMON_EXPORT void menu_item_clicked(unsigned char menu_item_id) override;

libcommon/include/vcc/cartridges/empty_cartridge.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ namespace vcc::cartridges
2626
{
2727
public:
2828

29-
name_type name() const override;
30-
catalog_id_type catalog_id() const override;
31-
description_type description() const override;
29+
[[nodiscard]] name_type name() const override;
30+
[[nodiscard]] catalog_id_type catalog_id() const override;
31+
[[nodiscard]] description_type description() const override;
3232
};
3333

3434
}

libcommon/include/vcc/cartridges/rom_cartridge.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,22 +46,18 @@ namespace vcc::cartridges
4646
buffer_type buffer,
4747
bool enable_bank_switching);
4848

49-
LIBCOMMON_EXPORT name_type name() const override;
50-
LIBCOMMON_EXPORT catalog_id_type catalog_id() const override;
51-
LIBCOMMON_EXPORT description_type description() const override;
49+
LIBCOMMON_EXPORT [[nodiscard]] name_type name() const override;
50+
LIBCOMMON_EXPORT [[nodiscard]] catalog_id_type catalog_id() const override;
51+
LIBCOMMON_EXPORT [[nodiscard]] description_type description() const override;
5252

5353
LIBCOMMON_EXPORT void start() override;
5454
LIBCOMMON_EXPORT void reset() override;
5555

56-
LIBCOMMON_EXPORT unsigned char read_memory_byte(unsigned short memory_address) override;
56+
LIBCOMMON_EXPORT [[nodiscard]] unsigned char read_memory_byte(unsigned short memory_address) override;
5757

5858
LIBCOMMON_EXPORT void write_port(unsigned char port_id, unsigned char value) override;
5959

6060

61-
protected:
62-
63-
64-
6561
private:
6662

6763
const std::unique_ptr<context_type> context_;

libcommon/include/vcc/common/DialogOps.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class LIBCOMMON_EXPORT FileDialog
5050

5151
FileDialog();
5252

53-
bool show(BOOL Save = FALSE, HWND Owner = nullptr);
53+
[[nodiscard]] bool show(BOOL Save = FALSE, HWND Owner = nullptr);
5454
void setpath(const char * Path);
5555
void setDefExt(const char * DefExt);
5656
void setInitialDir(const char * InitialDir);
@@ -60,7 +60,7 @@ class LIBCOMMON_EXPORT FileDialog
6060
void getdir(char * Dir, int maxsize = MAX_PATH) const;
6161
void getpath(char * Path, int maxsize = MAX_PATH) const;
6262
void getupath(char * Path, int maxsize = MAX_PATH) const;
63-
const char *path() const;
63+
[[nodiscard]] const char *path() const;
6464

6565

6666
private:

libcommon/include/vcc/common/FileOps.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222

2323
LIBCOMMON_EXPORT void PathStripPath(char*);
2424
LIBCOMMON_EXPORT void ValidatePath(char* Path);
25-
LIBCOMMON_EXPORT int CheckPath(char*);
26-
LIBCOMMON_EXPORT BOOL PathRemoveFileSpec(char*);
27-
LIBCOMMON_EXPORT BOOL PathRemoveExtension(char*);
28-
LIBCOMMON_EXPORT char* PathFindExtension(char*);
29-
LIBCOMMON_EXPORT DWORD WritePrivateProfileInt(LPCTSTR, LPCTSTR, int, LPCTSTR);
30-
LIBCOMMON_EXPORT BOOL FilePrintf(HANDLE, const char*, ...);
25+
LIBCOMMON_EXPORT [[nodiscard]] int CheckPath(char*);
26+
LIBCOMMON_EXPORT [[nodiscard]] BOOL PathRemoveFileSpec(char*);
27+
LIBCOMMON_EXPORT [[nodiscard]] BOOL PathRemoveExtension(char*);
28+
LIBCOMMON_EXPORT [[nodiscard]] char* PathFindExtension(char*);
29+
LIBCOMMON_EXPORT [[nodiscard]] DWORD WritePrivateProfileInt(LPCTSTR, LPCTSTR, int, LPCTSTR);
30+
LIBCOMMON_EXPORT [[nodiscard]] BOOL FilePrintf(HANDLE, const char*, ...);
3131

libcommon/include/vcc/core/cartridge.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,22 @@ namespace vcc::core
4040

4141
virtual ~cartridge() = default;
4242

43-
virtual name_type name() const = 0;
44-
virtual catalog_id_type catalog_id() const = 0;
45-
virtual description_type description() const = 0;
43+
virtual [[nodiscard]] name_type name() const = 0;
44+
virtual [[nodiscard]] catalog_id_type catalog_id() const = 0;
45+
virtual [[nodiscard]] description_type description() const = 0;
4646

4747
virtual void start();
4848
virtual void stop();
4949
virtual void reset();
5050

51-
virtual unsigned char read_memory_byte(unsigned short memory_address);
51+
virtual [[nodiscard]] unsigned char read_memory_byte(unsigned short memory_address);
5252

5353
virtual void write_port(unsigned char port_id, unsigned char value);
54-
virtual unsigned char read_port(unsigned char port_id);
54+
virtual [[nodiscard]] unsigned char read_port(unsigned char port_id);
5555

5656
virtual void process_horizontal_sync();
5757

58-
virtual unsigned short sample_audio();
58+
virtual [[nodiscard]] unsigned short sample_audio();
5959

6060
virtual void status(char* text_buffer, size_t buffer_size);
6161
virtual void menu_item_clicked(unsigned char menu_item_id);

libcommon/include/vcc/core/cartridge_context.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ namespace vcc::core
3636

3737
virtual ~cartridge_context() = default;
3838

39-
virtual path_type configuration_path() const = 0;
39+
virtual [[nodiscard]] path_type configuration_path() const = 0;
4040

4141
virtual void reset() = 0;
4242

4343
virtual void assert_cartridge_line(bool line_state) = 0;
4444
virtual void assert_interrupt(Interrupt interrupt, InterruptSource interrupt_source) = 0;
4545

4646
virtual void write_memory_byte(unsigned char value, unsigned short address) = 0;
47-
virtual unsigned char read_memory_byte(unsigned short address) = 0;
47+
virtual [[nodiscard]] unsigned char read_memory_byte(unsigned short address) = 0;
4848

4949
virtual void add_menu_item(const char* menu_name, int menu_id, MenuItemType menu_type) = 0;
5050
};

libcommon/include/vcc/core/detail/exports.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
////////////////////////////////////////////////////////////////////////////////
1818
#pragma once
1919

20+
2021
#ifdef LIBCOMMON_EXPORTS
2122
#define LIBCOMMON_EXPORT __declspec(dllexport)
2223
#else

libcommon/include/vcc/devices/becker/beckerport.h

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
1-
//---------------------------------------------------------------------------------
2-
// Copyright 2015 by Joseph Forgione
3-
// This file is part of VCC (Virtual Color Computer).
4-
//
5-
// VCC (Virtual Color Computer) is free software: you can redistribute it and/or
6-
// modify it under the terms of the GNU General Public License as published by
7-
// the Free Software Foundation, either version 3 of the License, or any later
8-
// version.
9-
//
10-
// VCC (Virtual Color Computer) is distributed in the hope that it will be useful,
11-
// but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12-
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13-
// more details. You should have received a copy of the GNU General Public License
14-
// along with VCC (Virtual Color Computer). If not, see
15-
// <http://www.gnu.org/licenses/>.
16-
//
17-
//---------------------------------------------------------------------------------
18-
1+
////////////////////////////////////////////////////////////////////////////////
2+
// Copyright 2015 by Joseph Forgione
3+
// This file is part of VCC (Virtual Color Computer).
4+
//
5+
// VCC (Virtual Color Computer) is free software: you can redistribute itand/or
6+
// modify it under the terms of the GNU General Public License as published by
7+
// the Free Software Foundation, either version 3 of the License, or (at your
8+
// option) any later version.
9+
//
10+
// VCC (Virtual Color Computer) is distributed in the hope that it will be
11+
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
13+
// Public License for more details.
14+
//
15+
// You should have received a copy of the GNU General Public License along with
16+
// VCC (Virtual Color Computer). If not, see <http://www.gnu.org/licenses/>.
17+
////////////////////////////////////////////////////////////////////////////////
1918
#pragma once
20-
2119
#include <vcc/core/detail/exports.h>
2220

21+
2322
namespace vcc::devices::beckerport
2423
{
2524
constexpr int BUFFER_SIZE = 512;

libcommon/include/vcc/devices/rom/banked_rom_image.h

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
////////////////////////////////////////////////////////////////////////////////
2+
// Copyright 2015 by Joseph Forgione
3+
// This file is part of VCC (Virtual Color Computer).
4+
//
5+
// VCC (Virtual Color Computer) is free software: you can redistribute itand/or
6+
// modify it under the terms of the GNU General Public License as published by
7+
// the Free Software Foundation, either version 3 of the License, or (at your
8+
// option) any later version.
9+
//
10+
// VCC (Virtual Color Computer) is distributed in the hope that it will be
11+
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
13+
// Public License for more details.
14+
//
15+
// You should have received a copy of the GNU General Public License along with
16+
// VCC (Virtual Color Computer). If not, see <http://www.gnu.org/licenses/>.
17+
////////////////////////////////////////////////////////////////////////////////
118
#pragma once
219
#include <vcc/devices/rom/rom_image.h>
320

@@ -12,20 +29,21 @@ namespace vcc::devices::rom
1229
using rom_image_type = ::vcc::devices::rom::rom_image;
1330
using value_type = rom_image_type::value_type;
1431
using size_type = rom_image_type::size_type;
32+
using path_type = std::string;
1533

1634
static const unsigned BankSize = 16384; // 8k banks
1735

18-
bool empty() const
36+
[[nodiscard]] bool empty() const
1937
{
2038
return rom_image_.empty();
2139
}
2240

23-
std::string filename() const
41+
[[nodiscard]] path_type filename() const
2442
{
2543
return rom_image_.filename();
2644
}
2745

28-
LIBCOMMON_EXPORT bool load(std::string filename);
46+
LIBCOMMON_EXPORT [[nodiscard]] bool load(path_type filename);
2947

3048
void clear()
3149
{
@@ -39,7 +57,7 @@ namespace vcc::devices::rom
3957
select_bank(0);
4058
}
4159

42-
unsigned char selected_bank() const
60+
[[nodiscard]] unsigned char selected_bank() const
4361
{
4462
return bank_register_;
4563
}
@@ -53,7 +71,7 @@ namespace vcc::devices::rom
5371
}
5472
}
5573

56-
value_type read_memory_byte(size_type memory_address) const
74+
[[nodiscard]] value_type read_memory_byte(size_type memory_address) const
5775
{
5876
return rom_image_.read_memory_byte(bank_offset_ + memory_address);
5977
}

0 commit comments

Comments
 (0)