fix: apply clang-format to all source files
Fixes formatting violations that were causing CI failures. Applied clang-format-14 to ensure consistent code formatting across the codebase. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -21,10 +21,11 @@ namespace yaze {
|
||||
|
||||
class Transaction {
|
||||
public:
|
||||
explicit Transaction(Rom &rom) : rom_(rom) {}
|
||||
explicit Transaction(Rom& rom) : rom_(rom) {}
|
||||
|
||||
Transaction &WriteByte(int address, uint8_t value) {
|
||||
if (!status_.ok()) return *this;
|
||||
Transaction& WriteByte(int address, uint8_t value) {
|
||||
if (!status_.ok())
|
||||
return *this;
|
||||
auto original = rom_.ReadByte(address);
|
||||
if (!original.ok()) {
|
||||
status_ = original.status();
|
||||
@@ -32,13 +33,15 @@ class Transaction {
|
||||
}
|
||||
status_ = rom_.WriteByte(address, value);
|
||||
if (status_.ok()) {
|
||||
operations_.push_back({address, static_cast<uint8_t>(*original), OperationType::kWriteByte});
|
||||
operations_.push_back({address, static_cast<uint8_t>(*original),
|
||||
OperationType::kWriteByte});
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
Transaction &WriteWord(int address, uint16_t value) {
|
||||
if (!status_.ok()) return *this;
|
||||
Transaction& WriteWord(int address, uint16_t value) {
|
||||
if (!status_.ok())
|
||||
return *this;
|
||||
auto original = rom_.ReadWord(address);
|
||||
if (!original.ok()) {
|
||||
status_ = original.status();
|
||||
@@ -46,13 +49,15 @@ class Transaction {
|
||||
}
|
||||
status_ = rom_.WriteWord(address, value);
|
||||
if (status_.ok()) {
|
||||
operations_.push_back({address, static_cast<uint16_t>(*original), OperationType::kWriteWord});
|
||||
operations_.push_back({address, static_cast<uint16_t>(*original),
|
||||
OperationType::kWriteWord});
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
Transaction &WriteLong(int address, uint32_t value) {
|
||||
if (!status_.ok()) return *this;
|
||||
Transaction& WriteLong(int address, uint32_t value) {
|
||||
if (!status_.ok())
|
||||
return *this;
|
||||
auto original = rom_.ReadLong(address);
|
||||
if (!original.ok()) {
|
||||
status_ = original.status();
|
||||
@@ -60,14 +65,17 @@ class Transaction {
|
||||
}
|
||||
status_ = rom_.WriteLong(address, value);
|
||||
if (status_.ok()) {
|
||||
operations_.push_back({address, static_cast<uint32_t>(*original), OperationType::kWriteLong});
|
||||
operations_.push_back({address, static_cast<uint32_t>(*original),
|
||||
OperationType::kWriteLong});
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
Transaction &WriteVector(int address, const std::vector<uint8_t> &data) {
|
||||
if (!status_.ok()) return *this;
|
||||
auto original = rom_.ReadByteVector(address, static_cast<uint32_t>(data.size()));
|
||||
Transaction& WriteVector(int address, const std::vector<uint8_t>& data) {
|
||||
if (!status_.ok())
|
||||
return *this;
|
||||
auto original =
|
||||
rom_.ReadByteVector(address, static_cast<uint32_t>(data.size()));
|
||||
if (!original.ok()) {
|
||||
status_ = original.status();
|
||||
return *this;
|
||||
@@ -79,8 +87,9 @@ class Transaction {
|
||||
return *this;
|
||||
}
|
||||
|
||||
Transaction &WriteColor(int address, const gfx::SnesColor &color) {
|
||||
if (!status_.ok()) return *this;
|
||||
Transaction& WriteColor(int address, const gfx::SnesColor& color) {
|
||||
if (!status_.ok())
|
||||
return *this;
|
||||
// Store original raw 16-bit value for rollback via WriteWord.
|
||||
auto original_word = rom_.ReadWord(address);
|
||||
if (!original_word.ok()) {
|
||||
@@ -89,7 +98,8 @@ class Transaction {
|
||||
}
|
||||
status_ = rom_.WriteColor(address, color);
|
||||
if (status_.ok()) {
|
||||
operations_.push_back({address, static_cast<uint16_t>(*original_word), OperationType::kWriteColor});
|
||||
operations_.push_back({address, static_cast<uint16_t>(*original_word),
|
||||
OperationType::kWriteColor});
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
@@ -103,22 +113,27 @@ class Transaction {
|
||||
|
||||
void Rollback() {
|
||||
for (auto it = operations_.rbegin(); it != operations_.rend(); ++it) {
|
||||
const auto &op = *it;
|
||||
const auto& op = *it;
|
||||
switch (op.type) {
|
||||
case OperationType::kWriteByte:
|
||||
(void)rom_.WriteByte(op.address, std::get<uint8_t>(op.original_value));
|
||||
(void)rom_.WriteByte(op.address,
|
||||
std::get<uint8_t>(op.original_value));
|
||||
break;
|
||||
case OperationType::kWriteWord:
|
||||
(void)rom_.WriteWord(op.address, std::get<uint16_t>(op.original_value));
|
||||
(void)rom_.WriteWord(op.address,
|
||||
std::get<uint16_t>(op.original_value));
|
||||
break;
|
||||
case OperationType::kWriteLong:
|
||||
(void)rom_.WriteLong(op.address, std::get<uint32_t>(op.original_value));
|
||||
(void)rom_.WriteLong(op.address,
|
||||
std::get<uint32_t>(op.original_value));
|
||||
break;
|
||||
case OperationType::kWriteVector:
|
||||
(void)rom_.WriteVector(op.address, std::get<std::vector<uint8_t>>(op.original_value));
|
||||
(void)rom_.WriteVector(
|
||||
op.address, std::get<std::vector<uint8_t>>(op.original_value));
|
||||
break;
|
||||
case OperationType::kWriteColor:
|
||||
(void)rom_.WriteWord(op.address, std::get<uint16_t>(op.original_value));
|
||||
(void)rom_.WriteWord(op.address,
|
||||
std::get<uint16_t>(op.original_value));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -126,15 +141,22 @@ class Transaction {
|
||||
}
|
||||
|
||||
private:
|
||||
enum class OperationType { kWriteByte, kWriteWord, kWriteLong, kWriteVector, kWriteColor };
|
||||
enum class OperationType {
|
||||
kWriteByte,
|
||||
kWriteWord,
|
||||
kWriteLong,
|
||||
kWriteVector,
|
||||
kWriteColor
|
||||
};
|
||||
|
||||
struct Operation {
|
||||
int address;
|
||||
std::variant<uint8_t, uint16_t, uint32_t, std::vector<uint8_t>> original_value;
|
||||
std::variant<uint8_t, uint16_t, uint32_t, std::vector<uint8_t>>
|
||||
original_value;
|
||||
OperationType type;
|
||||
};
|
||||
|
||||
Rom &rom_;
|
||||
Rom& rom_;
|
||||
absl::Status status_;
|
||||
std::vector<Operation> operations_;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user