Skip to content

Commit 9503224

Browse files
ChetSimpsonejaquay
authored andcommitted
change name and catalog_id in cartridge (and derived types) to return string by value instead of by reference
1 parent 859f219 commit 9503224

File tree

8 files changed

+25
-29
lines changed

8 files changed

+25
-29
lines changed

libcommon/include/vcc/core/cartridge.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ namespace vcc { namespace core
3939

4040
virtual ~cartridge() = default;
4141

42-
virtual const name_type& name() const = 0;
43-
virtual const catalog_id_type& catalog_id() const = 0;
42+
virtual name_type name() const = 0;
43+
virtual catalog_id_type catalog_id() const = 0;
4444

4545
virtual void start() = 0;
4646
virtual void reset() = 0;

libcommon/include/vcc/core/cartridges/basic_cartridge.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ namespace vcc { namespace core { namespace cartridges
3434

3535
using cartridge::cartridge;
3636

37-
const name_type& name() const override;
38-
const catalog_id_type& catalog_id() const override;
37+
name_type name() const override;
38+
catalog_id_type catalog_id() const override;
3939

4040
void start() override;
4141
void reset() override;

libcommon/include/vcc/core/cartridges/legacy_cartridge.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ namespace vcc { namespace core { namespace cartridges
4343
AssertInteruptModuleCallback assertCallback,
4444
AssertCartridgeLineModuleCallback assertCartCallback);
4545

46-
LIBCOMMON_EXPORT const name_type& name() const override;
47-
LIBCOMMON_EXPORT const catalog_id_type& catalog_id() const override;
46+
LIBCOMMON_EXPORT name_type name() const override;
47+
LIBCOMMON_EXPORT catalog_id_type catalog_id() const override;
4848

4949
LIBCOMMON_EXPORT void reset() override;
5050
LIBCOMMON_EXPORT void heartbeat() override;

libcommon/include/vcc/core/cartridges/rom_cartridge.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ namespace vcc { namespace core { namespace cartridges
4444
buffer_type buffer,
4545
bool enable_bank_switching);
4646

47-
LIBCOMMON_EXPORT const name_type& name() const override;
48-
LIBCOMMON_EXPORT const catalog_id_type& catalog_id() const override;
47+
LIBCOMMON_EXPORT name_type name() const override;
48+
LIBCOMMON_EXPORT catalog_id_type catalog_id() const override;
4949

5050
LIBCOMMON_EXPORT void reset() override;
5151
LIBCOMMON_EXPORT void write_port(unsigned char port_id, unsigned char value) override;

libcommon/include/vcc/core/utils/critical_section.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,28 +23,28 @@ namespace vcc { namespace core { namespace utils
2323
critical_section(const critical_section&) = delete;
2424
critical_section& operator=(const critical_section&) = delete;
2525

26-
void lock()
26+
void lock() const
2727
{
2828
EnterCriticalSection(&section_);
2929
}
3030

31-
void unlock()
31+
void unlock() const
3232
{
3333
LeaveCriticalSection(&section_);
3434
}
3535

3636

3737
private:
3838

39-
CRITICAL_SECTION section_;
39+
mutable CRITICAL_SECTION section_;
4040
};
4141

4242

4343
class section_locker
4444
{
4545
public:
4646

47-
explicit section_locker(critical_section& section)
47+
explicit section_locker(const critical_section& section)
4848
: section_(section)
4949
{
5050
section_.lock();
@@ -61,7 +61,7 @@ namespace vcc { namespace core { namespace utils
6161

6262
private:
6363

64-
critical_section& section_;
64+
const critical_section& section_;
6565
};
6666

6767
} } }

libcommon/src/core/cartridges/basic_cartridge.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,14 @@
2121
namespace vcc { namespace core { namespace cartridges
2222
{
2323

24-
const basic_cartridge::name_type& basic_cartridge::name() const
24+
basic_cartridge::name_type basic_cartridge::name() const
2525
{
26-
static const name_type local_name;
27-
28-
return local_name;
26+
return {};
2927
}
3028

31-
const basic_cartridge::catalog_id_type& basic_cartridge::catalog_id() const
29+
basic_cartridge::catalog_id_type basic_cartridge::catalog_id() const
3230
{
33-
static const catalog_id_type local_id;
34-
35-
return local_id;
31+
return {};
3632
}
3733

3834

@@ -61,9 +57,9 @@ namespace vcc { namespace core { namespace cartridges
6157
return {};
6258
}
6359

64-
void basic_cartridge::status(char* status_text)
60+
void basic_cartridge::status(char* status_buffer)
6561
{
66-
*status_text = 0;
62+
*status_buffer = 0;
6763
}
6864

6965
unsigned short basic_cartridge::sample_audio()

libcommon/src/core/cartridges/legacy_cartridge.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,12 @@ namespace vcc { namespace core { namespace cartridges
156156
// ModuleConfig ==> PakProcessMenuItem
157157
}
158158

159-
const legacy_cartridge::name_type& legacy_cartridge::name() const
159+
legacy_cartridge::name_type legacy_cartridge::name() const
160160
{
161161
return name_;
162162
}
163163

164-
const legacy_cartridge::catalog_id_type& legacy_cartridge::catalog_id() const
164+
legacy_cartridge::catalog_id_type legacy_cartridge::catalog_id() const
165165
{
166166
return catalog_id_;
167167
}
@@ -176,9 +176,9 @@ namespace vcc { namespace core { namespace cartridges
176176
heartbeat_();
177177
}
178178

179-
void legacy_cartridge::status(char* status_text)
179+
void legacy_cartridge::status(char* status_buffer)
180180
{
181-
status_(status_text);
181+
status_(status_buffer);
182182
}
183183

184184
void legacy_cartridge::write_port(unsigned char port_id, unsigned char value)

libcommon/src/core/cartridges/rom_cartridge.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ namespace vcc { namespace core { namespace cartridges
3737
{}
3838

3939

40-
const rom_cartridge::name_type& rom_cartridge::name() const
40+
rom_cartridge::name_type rom_cartridge::name() const
4141
{
4242
return name_;
4343
}
4444

45-
const rom_cartridge::catalog_id_type& rom_cartridge::catalog_id() const
45+
rom_cartridge::catalog_id_type rom_cartridge::catalog_id() const
4646
{
4747
return catalog_id_;
4848
}

0 commit comments

Comments
 (0)