Skip to content

Commit b153979

Browse files
committed
windows: use seperate exported name for each library, recordings
1 parent 011e99c commit b153979

File tree

9 files changed

+66
-54
lines changed

9 files changed

+66
-54
lines changed

src/libs/recordings/meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ liboopetris_recordings = library(
1717
include_directories: recordings_lib.get('inc_dirs'),
1818
dependencies: recordings_lib.get('deps'),
1919
cpp_args: recordings_lib.get('compile_args'),
20-
cpp_shared_args: ['-DOOPETRIS_LIBRARY_EXPORT'],
20+
cpp_shared_args: ['-DOOPETRIS_LIBRARY_RECORDINGS_EXPORT'],
2121
override_options: {
2222
'warning_level': '3',
2323
'werror': true,

src/libs/recordings/utility/additional_information.hpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include "./helper.hpp"
66
#include <core/helper/expected.hpp>
77
#include <core/helper/types.hpp>
8-
#include <core/helper/windows.hpp>
8+
#include "./windows.hpp"
99

1010
#include <fmt/format.h>
1111
#include <fmt/ranges.h>
@@ -65,7 +65,7 @@ namespace recorder {
6565
return m_value;
6666
}
6767

68-
OOPETRIS_EXPORTED [[nodiscard]] std::string to_string(u32 recursion_depth = 0) const;
68+
OOPETRIS_RECORDINGS_EXPORTED [[nodiscard]] std::string to_string(u32 recursion_depth = 0) const;
6969

7070
template<typename T>
7171
[[nodiscard]] bool operator==(const T& other) const { // NOLINT(misc-no-recursion)
@@ -115,13 +115,13 @@ namespace recorder {
115115
);
116116
}
117117

118-
OOPETRIS_EXPORTED static helper::expected<std::pair<std::string, InformationValue>, std::string> read_from_istream(
118+
OOPETRIS_RECORDINGS_EXPORTED static helper::expected<std::pair<std::string, InformationValue>, std::string> read_from_istream(
119119
std::istream& istream
120120
);
121121

122-
OOPETRIS_EXPORTED[[nodiscard]] helper::expected<std::vector<char>, std::string> to_bytes(u32 recursion_depth = 0) const;
122+
OOPETRIS_RECORDINGS_EXPORTED[[nodiscard]] helper::expected<std::vector<char>, std::string> to_bytes(u32 recursion_depth = 0) const;
123123

124-
OOPETRIS_EXPORTED [[nodiscard]] static std::vector<char> string_to_bytes(const std::string& value);
124+
OOPETRIS_RECORDINGS_EXPORTED [[nodiscard]] static std::vector<char> string_to_bytes(const std::string& value);
125125

126126
private:
127127
static helper::expected<std::string, std::string> read_string_from_istream(std::istream& istream);
@@ -142,21 +142,21 @@ namespace recorder {
142142
explicit AdditionalInformation(UnderlyingContainer&& values);
143143

144144
public:
145-
OOPETRIS_EXPORTED explicit AdditionalInformation();
145+
OOPETRIS_RECORDINGS_EXPORTED explicit AdditionalInformation();
146146

147-
OOPETRIS_EXPORTED static helper::expected<AdditionalInformation, std::string> from_istream(std::istream& istream);
147+
OOPETRIS_RECORDINGS_EXPORTED static helper::expected<AdditionalInformation, std::string> from_istream(std::istream& istream);
148148

149-
OOPETRIS_EXPORTED void add_value(const std::string& key, const InformationValue& value, bool overwrite = false);
149+
OOPETRIS_RECORDINGS_EXPORTED void add_value(const std::string& key, const InformationValue& value, bool overwrite = false);
150150

151151
template<typename T>
152152
void add(const std::string& key, const T& raw_value, bool overwrite = false) {
153153
const auto value = InformationValue{ raw_value };
154154
add_value(key, value, overwrite);
155155
}
156156

157-
OOPETRIS_EXPORTED [[nodiscard]] std::optional<InformationValue> get(const std::string& key) const;
157+
OOPETRIS_RECORDINGS_EXPORTED [[nodiscard]] std::optional<InformationValue> get(const std::string& key) const;
158158

159-
OOPETRIS_EXPORTED [[nodiscard]] bool has(const std::string& key) const;
159+
OOPETRIS_RECORDINGS_EXPORTED [[nodiscard]] bool has(const std::string& key) const;
160160

161161
template<typename T>
162162
[[nodiscard]] std::optional<T> get_if(const std::string& key) const {
@@ -174,9 +174,9 @@ namespace recorder {
174174
return value.as<T>();
175175
}
176176

177-
OOPETRIS_EXPORTED [[nodiscard]] helper::expected<std::vector<char>, std::string> to_bytes() const;
177+
OOPETRIS_RECORDINGS_EXPORTED [[nodiscard]] helper::expected<std::vector<char>, std::string> to_bytes() const;
178178

179-
OOPETRIS_EXPORTED [[nodiscard]] helper::expected<Sha256Stream::Checksum, std::string> get_checksum() const;
179+
OOPETRIS_RECORDINGS_EXPORTED [[nodiscard]] helper::expected<Sha256Stream::Checksum, std::string> get_checksum() const;
180180

181181
// iterator trait
182182
using iterator = UnderlyingContainer::iterator; //NOLINT(readability-identifier-naming)
@@ -188,13 +188,13 @@ namespace recorder {
188188
using iterator_category = std::bidirectional_iterator_tag; //NOLINT(readability-identifier-naming)
189189

190190

191-
OOPETRIS_EXPORTED [[nodiscard]] iterator begin();
191+
OOPETRIS_RECORDINGS_EXPORTED [[nodiscard]] iterator begin();
192192

193-
OOPETRIS_EXPORTED [[nodiscard]] const_iterator begin() const;
193+
OOPETRIS_RECORDINGS_EXPORTED [[nodiscard]] const_iterator begin() const;
194194

195-
OOPETRIS_EXPORTED [[nodiscard]] iterator end();
195+
OOPETRIS_RECORDINGS_EXPORTED [[nodiscard]] iterator end();
196196

197-
OOPETRIS_EXPORTED [[nodiscard]] const_iterator end() const;
197+
OOPETRIS_RECORDINGS_EXPORTED [[nodiscard]] const_iterator end() const;
198198
};
199199

200200
STATIC_ASSERT_WITH_MESSAGE(

src/libs/recordings/utility/checksum_helper.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
#include <core/hash-library/sha256.h>
66
#include <core/helper/utils.hpp>
7-
#include <core/helper/windows.hpp>
7+
#include "./windows.hpp"
88

99
#include <array>
1010
#include <string>
@@ -28,7 +28,7 @@ struct Sha256Stream {
2828
return *this;
2929
}
3030

31-
OOPETRIS_EXPORTED Sha256Stream& operator<<(const std::string& value);
31+
OOPETRIS_RECORDINGS_EXPORTED Sha256Stream& operator<<(const std::string& value);
3232

3333
template<typename T>
3434
Sha256Stream& operator<<(const std::vector<T>& values) {
@@ -48,5 +48,5 @@ struct Sha256Stream {
4848
return *this;
4949
}
5050

51-
OOPETRIS_EXPORTED [[nodiscard]] Checksum get_hash();
51+
OOPETRIS_RECORDINGS_EXPORTED [[nodiscard]] Checksum get_hash();
5252
};

src/libs/recordings/utility/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ _header_files = files(
1717
'recording_writer.hpp',
1818
'tetrion_core_information.hpp',
1919
'tetrion_snapshot.hpp',
20+
'windows.hpp',
2021
)
2122

2223
recordings_header_files += _header_files

src/libs/recordings/utility/recording.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include <core/helper/input_event.hpp>
44
#include <core/helper/random.hpp>
55
#include <core/helper/types.hpp>
6-
#include <core/helper/windows.hpp>
6+
#include "./windows.hpp"
77

88
#include "./additional_information.hpp"
99
#include "./checksum_helper.hpp"
@@ -37,7 +37,7 @@ namespace recorder {
3737
Random::Seed seed;
3838
u32 starting_level;
3939

40-
OOPETRIS_EXPORTED TetrionHeader(Random::Seed seed, u32 starting_level);
40+
OOPETRIS_RECORDINGS_EXPORTED TetrionHeader(Random::Seed seed, u32 starting_level);
4141
};
4242

4343
struct Recording {
@@ -58,11 +58,11 @@ namespace recorder {
5858
Recording& operator=(Recording&&) = delete;
5959
virtual ~Recording() = default;
6060

61-
OOPETRIS_EXPORTED [[nodiscard]] const std::vector<TetrionHeader>& tetrion_headers() const;
61+
OOPETRIS_RECORDINGS_EXPORTED [[nodiscard]] const std::vector<TetrionHeader>& tetrion_headers() const;
6262

63-
OOPETRIS_EXPORTED [[nodiscard]] const AdditionalInformation& information() const;
63+
OOPETRIS_RECORDINGS_EXPORTED [[nodiscard]] const AdditionalInformation& information() const;
6464

65-
OOPETRIS_EXPORTED [[nodiscard]] static Sha256Stream::Checksum get_header_checksum(
65+
OOPETRIS_RECORDINGS_EXPORTED [[nodiscard]] static Sha256Stream::Checksum get_header_checksum(
6666
u8 version_number,
6767
const std::vector<TetrionHeader>& tetrion_headers,
6868
const AdditionalInformation& information

src/libs/recordings/utility/recording_reader.hpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#pragma once
22

3-
#include <core/helper/windows.hpp>
3+
#include "./windows.hpp"
44

55
#include "./helper.hpp"
66

@@ -26,21 +26,21 @@ namespace recorder {
2626
);
2727

2828
public:
29-
OOPETRIS_EXPORTED RecordingReader(RecordingReader&& old) noexcept;
29+
OOPETRIS_RECORDINGS_EXPORTED RecordingReader(RecordingReader&& old) noexcept;
3030

31-
OOPETRIS_EXPORTED static helper::expected<RecordingReader, std::string> from_path(
31+
OOPETRIS_RECORDINGS_EXPORTED static helper::expected<RecordingReader, std::string> from_path(
3232
const std::filesystem::path& path
3333
);
3434

35-
OOPETRIS_EXPORTED [[nodiscard]] const Record& at(usize index) const;
35+
OOPETRIS_RECORDINGS_EXPORTED [[nodiscard]] const Record& at(usize index) const;
3636

37-
OOPETRIS_EXPORTED [[nodiscard]] usize num_records() const;
37+
OOPETRIS_RECORDINGS_EXPORTED [[nodiscard]] usize num_records() const;
3838

39-
OOPETRIS_EXPORTED [[nodiscard]] const UnderlyingContainer& records() const;
39+
OOPETRIS_RECORDINGS_EXPORTED [[nodiscard]] const UnderlyingContainer& records() const;
4040

41-
OOPETRIS_EXPORTED [[nodiscard]] const std::vector<TetrionSnapshot>& snapshots() const;
41+
OOPETRIS_RECORDINGS_EXPORTED [[nodiscard]] const std::vector<TetrionSnapshot>& snapshots() const;
4242

43-
OOPETRIS_EXPORTED [[nodiscard]] static helper::
43+
OOPETRIS_RECORDINGS_EXPORTED [[nodiscard]] static helper::
4444
expected<std::pair<recorder::AdditionalInformation, std::vector<recorder::TetrionHeader>>, std::string>
4545
is_header_valid(const std::filesystem::path& path);
4646

@@ -53,13 +53,13 @@ namespace recorder {
5353
using reference = UnderlyingContainer::reference; //NOLINT(readability-identifier-naming)
5454
using iterator_category = std::bidirectional_iterator_tag; //NOLINT(readability-identifier-naming)
5555

56-
OOPETRIS_EXPORTED [[nodiscard]] iterator begin();
56+
OOPETRIS_RECORDINGS_EXPORTED [[nodiscard]] iterator begin();
5757

58-
OOPETRIS_EXPORTED [[nodiscard]] const_iterator begin() const;
58+
OOPETRIS_RECORDINGS_EXPORTED [[nodiscard]] const_iterator begin() const;
5959

60-
OOPETRIS_EXPORTED [[nodiscard]] iterator end();
60+
OOPETRIS_RECORDINGS_EXPORTED [[nodiscard]] iterator end();
6161

62-
OOPETRIS_EXPORTED [[nodiscard]] const_iterator end() const;
62+
OOPETRIS_RECORDINGS_EXPORTED [[nodiscard]] const_iterator end() const;
6363

6464
private:
6565
[[nodiscard]] static helper::expected<

src/libs/recordings/utility/recording_writer.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include "./tetrion_core_information.hpp"
77

88
#include <core/helper/expected.hpp>
9-
#include <core/helper/windows.hpp>
9+
#include "./windows.hpp"
1010

1111
#include <filesystem>
1212

@@ -23,22 +23,22 @@ namespace recorder {
2323
);
2424

2525
public:
26-
OOPETRIS_EXPORTED RecordingWriter(RecordingWriter&& old) noexcept;
26+
OOPETRIS_RECORDINGS_EXPORTED RecordingWriter(RecordingWriter&& old) noexcept;
2727

28-
OOPETRIS_EXPORTED static helper::expected<RecordingWriter, std::string> get_writer(
28+
OOPETRIS_RECORDINGS_EXPORTED static helper::expected<RecordingWriter, std::string> get_writer(
2929
const std::filesystem::path& path,
3030
std::vector<TetrionHeader>&& tetrion_headers,
3131
AdditionalInformation&& information,
3232
bool overwrite = false
3333
);
3434

35-
OOPETRIS_EXPORTED [[nodiscard]] helper::expected<void, std::string> add_record(
35+
OOPETRIS_RECORDINGS_EXPORTED [[nodiscard]] helper::expected<void, std::string> add_record(
3636
u8 tetrion_index, // NOLINT(bugprone-easily-swappable-parameters)
3737
u64 simulation_step_index,
3838
InputEvent event
3939
);
4040

41-
OOPETRIS_EXPORTED [[nodiscard]] helper::expected<void, std::string>
41+
OOPETRIS_RECORDINGS_EXPORTED [[nodiscard]] helper::expected<void, std::string>
4242
add_snapshot(u64 simulation_step_index, std::unique_ptr<TetrionCoreInformation> information);
4343

4444
private:

src/libs/recordings/utility/tetrion_snapshot.hpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include <core/game/mino_stack.hpp>
44
#include <core/helper/expected.hpp>
55
#include <core/helper/utils.hpp>
6-
#include <core/helper/windows.hpp>
6+
#include "./windows.hpp"
77

88
#include "./tetrion_core_information.hpp"
99

@@ -30,7 +30,7 @@ struct TetrionSnapshot final {
3030
using MinoCount = u64;
3131
using Coordinate = u8;
3232

33-
OOPETRIS_EXPORTED TetrionSnapshot(
33+
OOPETRIS_RECORDINGS_EXPORTED TetrionSnapshot(
3434
u8 tetrion_index,
3535
Level level,
3636
Score score,
@@ -39,24 +39,24 @@ struct TetrionSnapshot final {
3939
MinoStack mino_stack
4040
);
4141

42-
OOPETRIS_EXPORTED static helper::expected<TetrionSnapshot, std::string> from_istream(std::istream& istream);
42+
OOPETRIS_RECORDINGS_EXPORTED static helper::expected<TetrionSnapshot, std::string> from_istream(std::istream& istream);
4343

44-
OOPETRIS_EXPORTED
44+
OOPETRIS_RECORDINGS_EXPORTED
4545
TetrionSnapshot(std::unique_ptr<TetrionCoreInformation> information, SimulationStep simulation_step_index);
4646

47-
OOPETRIS_EXPORTED [[nodiscard]] u8 tetrion_index() const;
47+
OOPETRIS_RECORDINGS_EXPORTED [[nodiscard]] u8 tetrion_index() const;
4848

49-
OOPETRIS_EXPORTED [[nodiscard]] Level level() const;
49+
OOPETRIS_RECORDINGS_EXPORTED [[nodiscard]] Level level() const;
5050

51-
OOPETRIS_EXPORTED [[nodiscard]] Score score() const;
51+
OOPETRIS_RECORDINGS_EXPORTED [[nodiscard]] Score score() const;
5252

53-
OOPETRIS_EXPORTED [[nodiscard]] LineCount lines_cleared() const;
53+
OOPETRIS_RECORDINGS_EXPORTED [[nodiscard]] LineCount lines_cleared() const;
5454

55-
OOPETRIS_EXPORTED [[nodiscard]] u64 simulation_step_index() const;
55+
OOPETRIS_RECORDINGS_EXPORTED [[nodiscard]] u64 simulation_step_index() const;
5656

57-
OOPETRIS_EXPORTED [[nodiscard]] const MinoStack& mino_stack() const;
57+
OOPETRIS_RECORDINGS_EXPORTED [[nodiscard]] const MinoStack& mino_stack() const;
5858

59-
OOPETRIS_EXPORTED [[nodiscard]] std::vector<char> to_bytes() const;
59+
OOPETRIS_RECORDINGS_EXPORTED [[nodiscard]] std::vector<char> to_bytes() const;
6060

61-
OOPETRIS_EXPORTED [[nodiscard]] helper::expected<void, std::string> compare_to(const TetrionSnapshot& other) const;
61+
OOPETRIS_RECORDINGS_EXPORTED [[nodiscard]] helper::expected<void, std::string> compare_to(const TetrionSnapshot& other) const;
6262
};
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#pragma once
2+
3+
#if defined(_MSC_VER)
4+
#if defined(OOPETRIS_LIBRARY_RECORDINGS_EXPORT)
5+
#define OOPETRIS_RECORDINGS_EXPORTED __declspec(dllexport)
6+
#else
7+
#define OOPETRIS_RECORDINGS_EXPORTED __declspec(dllimport)
8+
#endif
9+
#else
10+
#define OOPETRIS_RECORDINGS_EXPORTED
11+
#endif

0 commit comments

Comments
 (0)