#pragma once // Support for the generated platform skeleton (platform_stub.py, docs/PORT-PLAN.md 2A). A function whose // body still starts with MT_PLATFORM_STUB() has no platform implementation yet; it does nothing and // returns a default value. With MT_PLATFORM_STUB_TRACE set in the environment, the first call of each // one is reported on stderr. #include #include void mt_platform_stub_called(const char* function, bool* reported); #define MT_PLATFORM_STUB() \ do \ { \ static bool mt_platform_stub_reported = false; \ mt_platform_stub_called(__func__, &mt_platform_stub_reported); \ } while (0) template T mt_platform_stub_return() { if constexpr (std::is_reference_v) { using U = std::remove_cv_t>; if constexpr (std::is_default_constructible_v && !std::is_abstract_v) { static U value{}; return static_cast(value); } else { // Never constructed: a caller that uses the referent of an unimplemented platform function // is a bug the stub cannot hide. alignas(U) static unsigned char storage[sizeof(U)]; return static_cast(*reinterpret_cast(storage)); } } else if constexpr (std::is_same_v) { // Callers strcmp/strlen/format the names these return (CPythonPlayer::GetName in RecvGuild); a // null string would crash where the real function never returns one. return ""; } else if constexpr (std::is_default_constructible_v) { return T{}; } else { std::abort(); } }