Apply clang-format across the whole tree

Run clang-format (the repo's .clang-format: LLVM base, 120 cols, tabs,
Allman functions) over every source file so the tree is formatter-clean.
Whitespace only -- no behavior change; full x64 + x86 suites pass.

Also set SortIncludes: false in .clang-format. Windows include order is
load-bearing (windows.h must precede tlhelp32.h / mmreg.h / xinput.h /
dinput.h; winsock2.h must precede windows.h), and the default
alphabetical sort reorders tlhelp32.h ahead of windows.h -- a build
break. Leaving order alone keeps the manual, correct grouping.
This commit is contained in:
2026-07-12 11:52:53 +02:00
parent c684a15fb9
commit 30eccf749d
155 changed files with 3333 additions and 6171 deletions

View File

@@ -9,26 +9,20 @@
#include "coop/protocol.hpp"
namespace coop
{
namespace coop {
class SharedMemory
{
public:
class SharedMemory {
public:
SharedMemory() = default;
SharedMemory(const SharedMemory&) = delete;
SharedMemory& operator=(const SharedMemory&) = delete;
SharedMemory(SharedMemory&& other) noexcept
{
*this = std::move(other);
}
SharedMemory(SharedMemory&& other) noexcept { *this = std::move(other); }
SharedMemory& operator=(SharedMemory&& other) noexcept
{
if (this != &other)
{
if (this != &other) {
reset();
mapping_ = std::exchange(other.mapping_, nullptr);
view_ = std::exchange(other.view_, nullptr);
@@ -37,19 +31,15 @@ public:
return *this;
}
~SharedMemory()
{
reset();
}
~SharedMemory() { reset(); }
// Host side: create (or open if it already exists) the named section.
bool create(const std::wstring& name, std::size_t size)
{
reset();
mapping_ = CreateFileMappingW(INVALID_HANDLE_VALUE, nullptr, PAGE_READWRITE, 0,
static_cast<DWORD>(size), name.c_str());
if (mapping_ == nullptr)
{
mapping_ = CreateFileMappingW(INVALID_HANDLE_VALUE, nullptr, PAGE_READWRITE, 0, static_cast<DWORD>(size),
name.c_str());
if (mapping_ == nullptr) {
return false;
}
return map(size);
@@ -60,8 +50,7 @@ public:
{
reset();
mapping_ = OpenFileMappingW(FILE_MAP_ALL_ACCESS, FALSE, name.c_str());
if (mapping_ == nullptr)
{
if (mapping_ == nullptr) {
return false;
}
return map(size);
@@ -69,23 +58,18 @@ public:
void reset()
{
if (view_ != nullptr)
{
if (view_ != nullptr) {
UnmapViewOfFile(view_);
view_ = nullptr;
}
if (mapping_ != nullptr)
{
if (mapping_ != nullptr) {
CloseHandle(mapping_);
mapping_ = nullptr;
}
size_ = 0;
}
[[nodiscard]] bool valid() const
{
return view_ != nullptr;
}
[[nodiscard]] bool valid() const { return view_ != nullptr; }
template <typename T>
[[nodiscard]] T* as() const
@@ -93,22 +77,15 @@ public:
return static_cast<T*>(view_);
}
[[nodiscard]] void* data() const
{
return view_;
}
[[nodiscard]] void* data() const { return view_; }
[[nodiscard]] std::size_t size() const
{
return size_;
}
[[nodiscard]] std::size_t size() const { return size_; }
private:
private:
bool map(std::size_t size)
{
view_ = MapViewOfFile(mapping_, FILE_MAP_ALL_ACCESS, 0, 0, size);
if (view_ == nullptr)
{
if (view_ == nullptr) {
CloseHandle(mapping_);
mapping_ = nullptr;
return false;