diff --git a/src/alloy/frontend/ppc/ppc_instr.h b/src/alloy/frontend/ppc/ppc_instr.h index f6052078b..96575a2c4 100644 --- a/src/alloy/frontend/ppc/ppc_instr.h +++ b/src/alloy/frontend/ppc/ppc_instr.h @@ -61,7 +61,7 @@ typedef enum { kXEPPCInstrFormatXDSS = 26, } xe_ppc_instr_format_e; -typedef enum { +typedef enum : uint32_t { kXEPPCInstrMaskVXR = 0xFC0003FF, kXEPPCInstrMaskVXA = 0xFC00003F, kXEPPCInstrMaskVX128 = 0xFC0003D0, diff --git a/src/poly/memory.h b/src/poly/memory.h index 78336867a..a3488eaf4 100644 --- a/src/poly/memory.h +++ b/src/poly/memory.h @@ -10,6 +10,7 @@ #ifndef POLY_MEMORY_H_ #define POLY_MEMORY_H_ +#include #include #include @@ -17,6 +18,15 @@ namespace poly { +inline size_t hash_combine(size_t seed) { return seed; } + +template +size_t hash_combine(size_t seed, const T& v, const Ts&... vs) { + std::hash hasher; + seed ^= hasher(v) + 0x9E3779B9 + (seed << 6) + (seed >> 2); + return hash_combine(seed, vs...); +} + size_t page_size(); template diff --git a/src/xdb/xdb.h b/src/xdb/xdb.h index dbe6052ac..680bd3c1f 100644 --- a/src/xdb/xdb.h +++ b/src/xdb/xdb.h @@ -11,7 +11,6 @@ #define XDB_H_ #include -#include #include #include diff --git a/src/xenia/apu/audio_driver.h b/src/xenia/apu/audio_driver.h index 55d80acb4..d100f6e8f 100644 --- a/src/xenia/apu/audio_driver.h +++ b/src/xenia/apu/audio_driver.h @@ -10,7 +10,7 @@ #ifndef XENIA_APU_AUDIO_DRIVER_H_ #define XENIA_APU_AUDIO_DRIVER_H_ -#include +#include #include #include diff --git a/src/xenia/apu/audio_system.h b/src/xenia/apu/audio_system.h index b0b9a0321..20a24e136 100644 --- a/src/xenia/apu/audio_system.h +++ b/src/xenia/apu/audio_system.h @@ -15,7 +15,7 @@ #include #include -#include +#include #include #include diff --git a/src/xenia/apu/nop/nop_apu-private.h b/src/xenia/apu/nop/nop_apu-private.h index 23da172dd..f41803693 100644 --- a/src/xenia/apu/nop/nop_apu-private.h +++ b/src/xenia/apu/nop/nop_apu-private.h @@ -10,7 +10,7 @@ #ifndef XENIA_APU_NOP_NOP_APU_PRIVATE_H_ #define XENIA_APU_NOP_NOP_APU_PRIVATE_H_ -#include +#include #include diff --git a/src/xenia/apu/nop/nop_apu.h b/src/xenia/apu/nop/nop_apu.h index 2cc6e771b..9159c7b60 100644 --- a/src/xenia/apu/nop/nop_apu.h +++ b/src/xenia/apu/nop/nop_apu.h @@ -12,7 +12,7 @@ #include -#include +#include namespace xe { class Emulator; diff --git a/src/xenia/apu/nop/nop_audio_system.h b/src/xenia/apu/nop/nop_audio_system.h index 55027789c..c42982572 100644 --- a/src/xenia/apu/nop/nop_audio_system.h +++ b/src/xenia/apu/nop/nop_audio_system.h @@ -10,7 +10,7 @@ #ifndef XENIA_APU_NOP_NOP_AUDIO_SYSTEM_H_ #define XENIA_APU_NOP_NOP_AUDIO_SYSTEM_H_ -#include +#include #include #include diff --git a/src/xenia/apu/xaudio2/xaudio2_apu-private.h b/src/xenia/apu/xaudio2/xaudio2_apu-private.h index 7e89a3179..4c890b5e7 100644 --- a/src/xenia/apu/xaudio2/xaudio2_apu-private.h +++ b/src/xenia/apu/xaudio2/xaudio2_apu-private.h @@ -10,7 +10,7 @@ #ifndef XENIA_APU_XAUDIO2_XAUDIO2_APU_PRIVATE_H_ #define XENIA_APU_XAUDIO2_XAUDIO2_APU_PRIVATE_H_ -#include +#include #include diff --git a/src/xenia/apu/xaudio2/xaudio2_apu.h b/src/xenia/apu/xaudio2/xaudio2_apu.h index 565f93d01..5cdd5245c 100644 --- a/src/xenia/apu/xaudio2/xaudio2_apu.h +++ b/src/xenia/apu/xaudio2/xaudio2_apu.h @@ -12,7 +12,7 @@ #include -#include +#include namespace xe { class Emulator; diff --git a/src/xenia/apu/xaudio2/xaudio2_audio_driver.h b/src/xenia/apu/xaudio2/xaudio2_audio_driver.h index b1eac228c..6a500f806 100644 --- a/src/xenia/apu/xaudio2/xaudio2_audio_driver.h +++ b/src/xenia/apu/xaudio2/xaudio2_audio_driver.h @@ -10,19 +10,16 @@ #ifndef XENIA_APU_XAUDIO2_XAUDIO2_AUDIO_DRIVER_H_ #define XENIA_APU_XAUDIO2_XAUDIO2_AUDIO_DRIVER_H_ -#include - -#include -#include - #include +#include +#include +#include namespace xe { namespace apu { namespace xaudio2 { - class XAudio2AudioDriver : public AudioDriver { public: XAudio2AudioDriver(Emulator* emulator, HANDLE wait); @@ -45,10 +42,8 @@ private: VoiceCallback* voice_callback_; }; - } // namespace xaudio2 } // namespace apu } // namespace xe - #endif // XENIA_APU_XAUDIO2_XAUDIO2_AUDIO_DRIVER_H_ diff --git a/src/xenia/apu/xaudio2/xaudio2_audio_system.h b/src/xenia/apu/xaudio2/xaudio2_audio_system.h index 8c6adc6ad..82f01bce3 100644 --- a/src/xenia/apu/xaudio2/xaudio2_audio_system.h +++ b/src/xenia/apu/xaudio2/xaudio2_audio_system.h @@ -10,19 +10,16 @@ #ifndef XENIA_APU_XAUDIO2_XAUDIO2_AUDIO_SYSTEM_H_ #define XENIA_APU_XAUDIO2_XAUDIO2_AUDIO_SYSTEM_H_ -#include - -#include -#include - #include +#include +#include +#include namespace xe { namespace apu { namespace xaudio2 { - class XAudio2AudioSystem : public AudioSystem { public: XAudio2AudioSystem(Emulator* emulator); @@ -35,10 +32,8 @@ protected: virtual void Initialize(); }; - } // namespace xaudio2 } // namespace apu } // namespace xe - #endif // XENIA_APU_XAUDIO2_XAUDIO2_AUDIO_SYSTEM_H_ diff --git a/src/xenia/core.h b/src/xenia/core.h deleted file mode 100644 index 5bf4ebbbe..000000000 --- a/src/xenia/core.h +++ /dev/null @@ -1,31 +0,0 @@ -/** - ****************************************************************************** - * Xenia : Xbox 360 Emulator Research Project * - ****************************************************************************** - * Copyright 2013 Ben Vanik. All rights reserved. * - * Released under the BSD license - see LICENSE in the root for more details. * - ****************************************************************************** - */ - -#ifndef XENIA_CORE_H_ -#define XENIA_CORE_H_ - -#include - -#include -#include -#include -#include - -// TODO(benvanik): remove. -#define XEFAIL() goto XECLEANUP -#define XEEXPECTZERO(expr) \ - if ((expr) != 0) { \ - goto XECLEANUP; \ - } -#define XEEXPECTNOTNULL(expr) \ - if ((expr) == NULL) { \ - goto XECLEANUP; \ - } - -#endif // XENIA_CORE_H_ diff --git a/src/xenia/core/README.md b/src/xenia/core/README.md deleted file mode 100644 index 8fa35ec20..000000000 --- a/src/xenia/core/README.md +++ /dev/null @@ -1,6 +0,0 @@ -TODO(benvanik): remove all of this code. - -* hash can be moved to util/ -* ref can be removed when run_loop is rewritten -* run_loop should be moved to ui/ (perhaps) -* socket can be moved to poly diff --git a/src/xenia/core/hash.cc b/src/xenia/core/hash.cc deleted file mode 100644 index ee6560e84..000000000 --- a/src/xenia/core/hash.cc +++ /dev/null @@ -1,241 +0,0 @@ -/** - ****************************************************************************** - * Xenia : Xbox 360 Emulator Research Project * - ****************************************************************************** - * Copyright 2013 Ben Vanik. All rights reserved. * - * Released under the BSD license - see LICENSE in the root for more details. * - ****************************************************************************** - */ - -// Copyright (c) 2011 Google, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -// -// CityHash, by Geoff Pike and Jyrki Alakuijala -// -// This file provides CityHash64() and related functions. -// -// It's probably possible to create even faster hash functions by -// writing a program that systematically explores some of the space of -// possible hash functions, by using SIMD instructions, or by -// compromising on hash quality. - -#include - -#include -#include - -namespace xe { - -namespace { - -typedef std::pair uint128_t; - -inline uint64_t Uint128Low64(const uint128_t &x) { return x.first; } -inline uint64_t Uint128High64(const uint128_t &x) { return x.second; } - -// Hash 128 input bits down to 64 bits of output. -// This is intended to be a reasonably good hash function. -inline uint64_t Hash128to64(const uint128_t &x) { - // Murmur-inspired hashing. - const uint64_t kMul = 0x9ddfea08eb382d69ULL; - uint64_t a = (Uint128Low64(x) ^ Uint128High64(x)) * kMul; - a ^= (a >> 47); - uint64_t b = (Uint128High64(x) ^ a) * kMul; - b ^= (b >> 47); - b *= kMul; - return b; -} - -inline uint64_t UNALIGNED_LOAD64(const char *p) { - const uint64_t *p64 = (const uint64_t *)p; - return *p64; -} -inline uint32_t UNALIGNED_LOAD32(const char *p) { - const uint32_t *p32 = (const uint32_t *)p; - return *p32; -} - -#if !defined(LIKELY) -#if HAVE_BUILTIN_EXPECT -#define LIKELY(x) (__builtin_expect(!!(x), 1)) -#else -#define LIKELY(x) (x) -#endif -#endif - -static uint64_t Fetch64(const char *p) { return UNALIGNED_LOAD64(p); } - -static uint32_t Fetch32(const char *p) { return UNALIGNED_LOAD32(p); } - -// Some primes between 2^63 and 2^64 for various uses. -static const uint64_t k0 = 0xc3a5c85c97cb3127ULL; -static const uint64_t k1 = 0xb492b66fbe98f273ULL; -static const uint64_t k2 = 0x9ae16a3b2f90404fULL; - -// Bitwise right rotate. Normally this will compile to a single -// instruction, especially if the shift is a manifest constant. -static uint64_t Rotate(uint64_t val, int shift) { - // Avoid shifting by 64: doing so yields an undefined result. - return shift == 0 ? val : ((val >> shift) | (val << (64 - shift))); -} - -static uint64_t ShiftMix(uint64_t val) { return val ^ (val >> 47); } - -static uint64_t HashLen16(uint64_t u, uint64_t v) { - return Hash128to64(uint128_t(u, v)); -} - -static uint64_t HashLen16(uint64_t u, uint64_t v, uint64_t mul) { - // Murmur-inspired hashing. - uint64_t a = (u ^ v) * mul; - a ^= (a >> 47); - uint64_t b = (v ^ a) * mul; - b ^= (b >> 47); - b *= mul; - return b; -} - -static uint64_t HashLen0to16(const char *s, size_t len) { - if (len >= 8) { - uint64_t mul = k2 + len * 2; - uint64_t a = Fetch64(s) + k2; - uint64_t b = Fetch64(s + len - 8); - uint64_t c = Rotate(b, 37) * mul + a; - uint64_t d = (Rotate(a, 25) + b) * mul; - return HashLen16(c, d, mul); - } - if (len >= 4) { - uint64_t mul = k2 + len * 2; - uint64_t a = Fetch32(s); - return HashLen16(len + (a << 3), Fetch32(s + len - 4), mul); - } - if (len > 0) { - uint8_t a = s[0]; - uint8_t b = s[len >> 1]; - uint8_t c = s[len - 1]; - uint32_t y = static_cast(a) + (static_cast(b) << 8); - uint32_t z = (uint32_t)len + (static_cast(c) << 2); - return ShiftMix(y * k2 ^ z * k0) * k2; - } - return k2; -} - -// This probably works well for 16-byte strings as well, but it may be overkill -// in that case. -static uint64_t HashLen17to32(const char *s, size_t len) { - uint64_t mul = k2 + len * 2; - uint64_t a = Fetch64(s) * k1; - uint64_t b = Fetch64(s + 8); - uint64_t c = Fetch64(s + len - 8) * mul; - uint64_t d = Fetch64(s + len - 16) * k2; - return HashLen16(Rotate(a + b, 43) + Rotate(c, 30) + d, - a + Rotate(b + k2, 18) + c, mul); -} - -// Return a 16-byte hash for 48 bytes. Quick and dirty. -// Callers do best to use "random-looking" values for a and b. -static std::pair WeakHashLen32WithSeeds( - uint64_t w, uint64_t x, uint64_t y, uint64_t z, uint64_t a, uint64_t b) { - a += w; - b = Rotate(b + a + z, 21); - uint64_t c = a; - a += x; - a += y; - b += Rotate(a, 44); - return std::make_pair(a + z, b + c); -} - -// Return a 16-byte hash for s[0] ... s[31], a, and b. Quick and dirty. -static std::pair WeakHashLen32WithSeeds(const char *s, - uint64_t a, - uint64_t b) { - return WeakHashLen32WithSeeds(Fetch64(s), Fetch64(s + 8), Fetch64(s + 16), - Fetch64(s + 24), a, b); -} - -// Return an 8-byte hash for 33 to 64 bytes. -static uint64_t HashLen33to64(const char *s, size_t len) { - uint64_t mul = k2 + len * 2; - uint64_t a = Fetch64(s) * k2; - uint64_t b = Fetch64(s + 8); - uint64_t c = Fetch64(s + len - 24); - uint64_t d = Fetch64(s + len - 32); - uint64_t e = Fetch64(s + 16) * k2; - uint64_t f = Fetch64(s + 24) * 9; - uint64_t g = Fetch64(s + len - 8); - uint64_t h = Fetch64(s + len - 16) * mul; - uint64_t u = Rotate(a + g, 43) + (Rotate(b, 30) + c) * 9; - uint64_t v = ((a + g) ^ d) + f + 1; - uint64_t w = poly::byte_swap((u + v) * mul) + h; - uint64_t x = Rotate(e + f, 42) + c; - uint64_t y = (poly::byte_swap((v + w) * mul) + g) * mul; - uint64_t z = e + f + c; - a = poly::byte_swap((x + z) * mul + y) + b; - b = ShiftMix((z + a) * mul + d + h) * mul; - return b + x; -} - -uint64_t CityHash64(const char *s, size_t len) { - if (len <= 32) { - if (len <= 16) { - return HashLen0to16(s, len); - } else { - return HashLen17to32(s, len); - } - } else if (len <= 64) { - return HashLen33to64(s, len); - } - - // For strings over 64 bytes we hash the end first, and then as we - // loop we keep 56 bytes of state: v, w, x, y, and z. - uint64_t x = Fetch64(s + len - 40); - uint64_t y = Fetch64(s + len - 16) + Fetch64(s + len - 56); - uint64_t z = HashLen16(Fetch64(s + len - 48) + len, Fetch64(s + len - 24)); - std::pair v = - WeakHashLen32WithSeeds(s + len - 64, len, z); - std::pair w = - WeakHashLen32WithSeeds(s + len - 32, y + k1, x); - x = x * k1 + Fetch64(s); - - // Decrease len to the nearest multiple of 64, and operate on 64-byte chunks. - len = (len - 1) & ~static_cast(63); - do { - x = Rotate(x + y + v.first + Fetch64(s + 8), 37) * k1; - y = Rotate(y + v.second + Fetch64(s + 48), 42) * k1; - x ^= w.second; - y += v.first + Fetch64(s + 40); - z = Rotate(z + w.first, 33) * k1; - v = WeakHashLen32WithSeeds(s, v.second * k1, x + w.first); - w = WeakHashLen32WithSeeds(s + 32, z + w.second, y + Fetch64(s + 16)); - std::swap(z, x); - s += 64; - len -= 64; - } while (len != 0); - return HashLen16(HashLen16(v.first, w.first) + ShiftMix(y) * k1 + z, - HashLen16(v.second, w.second) + x); -} - -} // anonymous namespace - -uint64_t hash64(const void *data, size_t length, uint64_t seed) { - return HashLen16(CityHash64((const char *)data, length) - k2, seed); -} - -} // namespace xe diff --git a/src/xenia/core/hash.h b/src/xenia/core/hash.h deleted file mode 100644 index 2002724ad..000000000 --- a/src/xenia/core/hash.h +++ /dev/null @@ -1,30 +0,0 @@ -/** - ****************************************************************************** - * Xenia : Xbox 360 Emulator Research Project * - ****************************************************************************** - * Copyright 2013 Ben Vanik. All rights reserved. * - * Released under the BSD license - see LICENSE in the root for more details. * - ****************************************************************************** - */ - -#ifndef XENIA_CORE_HASH_H_ -#define XENIA_CORE_HASH_H_ - -#include - -namespace xe { - -inline size_t hash_combine(size_t seed) { return seed; } - -template -size_t hash_combine(size_t seed, const T& v, const Ts&... vs) { - std::hash hasher; - seed ^= hasher(v) + 0x9E3779B9 + (seed << 6) + (seed >> 2); - return hash_combine(seed, vs...); -} - -uint64_t hash64(const void* data, size_t length, uint64_t seed = 0); - -} // namespace xe - -#endif // XENIA_CORE_HASH_H_ diff --git a/src/xenia/core/ref.cc b/src/xenia/core/ref.cc deleted file mode 100644 index de0347ca5..000000000 --- a/src/xenia/core/ref.cc +++ /dev/null @@ -1,26 +0,0 @@ -/** - ****************************************************************************** - * Xenia : Xbox 360 Emulator Research Project * - ****************************************************************************** - * Copyright 2013 Ben Vanik. All rights reserved. * - * Released under the BSD license - see LICENSE in the root for more details. * - ****************************************************************************** - */ - -#include - -void xe_ref_init(xe_ref_t* ref) { ref->count = 1; } - -void xe_ref_retain(xe_ref_t* ref) { poly::atomic_inc(&ref->count); } - -void xe_ref_release(xe_ref_t* ref, xe_ref_dealloc_t dealloc) { - if (!ref) { - return; - } - if (!poly::atomic_dec(&ref->count)) { - if (dealloc) { - dealloc(ref); - } - free(ref); - } -} diff --git a/src/xenia/core/run_loop.h b/src/xenia/core/run_loop.h deleted file mode 100644 index 7df516726..000000000 --- a/src/xenia/core/run_loop.h +++ /dev/null @@ -1,33 +0,0 @@ -/** - ****************************************************************************** - * Xenia : Xbox 360 Emulator Research Project * - ****************************************************************************** - * Copyright 2013 Ben Vanik. All rights reserved. * - * Released under the BSD license - see LICENSE in the root for more details. * - ****************************************************************************** - */ - -#ifndef XENIA_CORE_RUN_LOOP_H_ -#define XENIA_CORE_RUN_LOOP_H_ - -#include -#include - - -struct xe_run_loop; -typedef struct xe_run_loop* xe_run_loop_ref; - - -xe_run_loop_ref xe_run_loop_create(); -xe_run_loop_ref xe_run_loop_retain(xe_run_loop_ref run_loop); -void xe_run_loop_release(xe_run_loop_ref run_loop); - -int xe_run_loop_pump(xe_run_loop_ref run_loop); -void xe_run_loop_quit(xe_run_loop_ref run_loop); - -typedef void (*xe_run_loop_callback)(void* data); -void xe_run_loop_call(xe_run_loop_ref run_loop, - xe_run_loop_callback callback, void* data); - - -#endif // XENIA_CORE_RUN_LOOP_H_ diff --git a/src/xenia/core/run_loop_win.cc b/src/xenia/core/run_loop_win.cc deleted file mode 100644 index 43fdaaa8d..000000000 --- a/src/xenia/core/run_loop_win.cc +++ /dev/null @@ -1,74 +0,0 @@ -/** - ****************************************************************************** - * Xenia : Xbox 360 Emulator Research Project * - ****************************************************************************** - * Copyright 2013 Ben Vanik. All rights reserved. * - * Released under the BSD license - see LICENSE in the root for more details. * - ****************************************************************************** - */ - -#include - -typedef struct xe_run_loop { xe_ref_t ref; } xe_run_loop_t; - -#define WM_XE_RUN_LOOP_QUIT (WM_APP + 0x100) -#define WM_XE_RUN_LOOP_CALL (WM_APP + 0x101) - -typedef struct xe_run_loop_call { - xe_run_loop_callback callback; - void* data; -} xe_run_loop_call_t; - -xe_run_loop_ref xe_run_loop_create() { - xe_run_loop_ref run_loop = (xe_run_loop_ref)calloc(1, sizeof(xe_run_loop_t)); - xe_ref_init((xe_ref)run_loop); - return run_loop; -} - -void xe_run_loop_dealloc(xe_run_loop_ref run_loop) {} - -xe_run_loop_ref xe_run_loop_retain(xe_run_loop_ref run_loop) { - xe_ref_retain((xe_ref)run_loop); - return run_loop; -} - -void xe_run_loop_release(xe_run_loop_ref run_loop) { - xe_ref_release((xe_ref)run_loop, (xe_ref_dealloc_t)xe_run_loop_dealloc); -} - -int xe_run_loop_pump(xe_run_loop_ref run_loop) { - MSG msg; - if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { - TranslateMessage(&msg); - DispatchMessage(&msg); - switch (msg.message) { - case WM_XE_RUN_LOOP_CALL: - if (msg.wParam == (WPARAM)run_loop) { - xe_run_loop_call_t* call = (xe_run_loop_call_t*)msg.lParam; - call->callback(call->data); - free(call); - } - break; - case WM_XE_RUN_LOOP_QUIT: - if (msg.wParam == (WPARAM)run_loop) { - // Done! - return 1; - } - break; - } - } - return 0; -} - -void xe_run_loop_quit(xe_run_loop_ref run_loop) { - PostMessage(NULL, WM_XE_RUN_LOOP_QUIT, (WPARAM)run_loop, 0); -} - -void xe_run_loop_call(xe_run_loop_ref run_loop, xe_run_loop_callback callback, - void* data) { - xe_run_loop_call_t* call = - (xe_run_loop_call_t*)calloc(1, sizeof(xe_run_loop_call_t)); - call->callback = callback; - call->data = data; - PostMessage(NULL, WM_XE_RUN_LOOP_CALL, (WPARAM)run_loop, (LPARAM)call); -} diff --git a/src/xenia/core/socket.h b/src/xenia/core/socket.h deleted file mode 100644 index f1052f4cd..000000000 --- a/src/xenia/core/socket.h +++ /dev/null @@ -1,57 +0,0 @@ -/** - ****************************************************************************** - * Xenia : Xbox 360 Emulator Research Project * - ****************************************************************************** - * Copyright 2013 Ben Vanik. All rights reserved. * - * Released under the BSD license - see LICENSE in the root for more details. * - ****************************************************************************** - */ - -#ifndef XENIA_CORE_SOCKET_H_ -#define XENIA_CORE_SOCKET_H_ - -#include -#include - - -typedef intptr_t socket_t; -#define XE_INVALID_SOCKET -1 - - -void xe_socket_init(); - -socket_t xe_socket_create_tcp(); -void xe_socket_close(socket_t socket); - -void xe_socket_set_keepalive(socket_t socket, bool value); -void xe_socket_set_reuseaddr(socket_t socket, bool value); -void xe_socket_set_nodelay(socket_t socket, bool value); -void xe_socket_set_nonblock(socket_t socket, bool value); - -int xe_socket_bind(socket_t socket, uint32_t port); -int xe_socket_bind_loopback(socket_t socket); -int xe_socket_listen(socket_t socket); - -typedef struct { - socket_t socket; - char addr[16]; -} xe_socket_connection_t; -int xe_socket_accept(socket_t socket, xe_socket_connection_t* out_client_info); - -int64_t xe_socket_send(socket_t socket, const uint8_t* data, size_t length, - int flags, int* out_error_code); -int64_t xe_socket_recv(socket_t socket, uint8_t* data, size_t length, int flags, - int* out_error_code); - -typedef struct xe_socket_loop xe_socket_loop_t; -xe_socket_loop_t* xe_socket_loop_create(socket_t socket); -void xe_socket_loop_destroy(xe_socket_loop_t* loop); -int xe_socket_loop_poll(xe_socket_loop_t* loop, - bool check_read, bool check_write); -void xe_socket_loop_set_queued_write(xe_socket_loop_t* loop); -bool xe_socket_loop_check_queued_write(xe_socket_loop_t* loop); -bool xe_socket_loop_check_socket_recv(xe_socket_loop_t* loop); -bool xe_socket_loop_check_socket_send(xe_socket_loop_t* loop); - - -#endif // XENIA_CORE_SOCKET_H_ diff --git a/src/xenia/core/socket_posix.cc b/src/xenia/core/socket_posix.cc deleted file mode 100644 index 4672faaa7..000000000 --- a/src/xenia/core/socket_posix.cc +++ /dev/null @@ -1,229 +0,0 @@ -/** - ****************************************************************************** - * Xenia : Xbox 360 Emulator Research Project * - ****************************************************************************** - * Copyright 2013 Ben Vanik. All rights reserved. * - * Released under the BSD license - see LICENSE in the root for more details. * - ****************************************************************************** - */ - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include - -void xe_socket_init() { - // No-op. -} - -socket_t xe_socket_create_tcp() { - socket_t socket_result = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); - if (socket_result < 1) { - return XE_INVALID_SOCKET; - } - return socket_result; -} - -void xe_socket_close(socket_t socket) { - shutdown(socket, SHUT_WR); - close(socket); -} - -void xe_socket_set_keepalive(socket_t socket, bool value) { - int opt_value = value ? 1 : 0; - setsockopt(socket, SOL_SOCKET, SO_KEEPALIVE, &opt_value, sizeof(opt_value)); -} - -void xe_socket_set_reuseaddr(socket_t socket, bool value) { - int opt_value = value ? 1 : 0; - setsockopt(socket, SOL_SOCKET, SO_REUSEADDR, &opt_value, sizeof(opt_value)); -} - -void xe_socket_set_nodelay(socket_t socket, bool value) { - int opt_value = value ? 1 : 0; - setsockopt(socket, IPPROTO_TCP, TCP_NODELAY, &opt_value, sizeof(opt_value)); -} - -void xe_socket_set_nonblock(socket_t socket, bool value) { - int flags; - while ((flags = fcntl(socket, F_GETFL, 0)) == -1 && errno == EINTR) - ; - if (flags == -1) { - return; - } - int r; - while ((r = fcntl(socket, F_SETFL, flags | O_NONBLOCK)) == -1 && - errno == EINTR) - ; - if (r == -1) { - return; - } -} - -int xe_socket_bind(socket_t socket, uint32_t port) { - struct sockaddr_in socket_addr; - socket_addr.sin_family = AF_INET; - socket_addr.sin_addr.s_addr = htonl(INADDR_ANY); - socket_addr.sin_port = htons(port); - int r = bind(socket, (struct sockaddr*)&socket_addr, sizeof(socket_addr)); - if (r < 0) { - return 1; - } - return 0; -} - -int xe_socket_bind_loopback(socket_t socket) { - struct sockaddr_in socket_addr; - socket_addr.sin_family = AF_INET; - socket_addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); - socket_addr.sin_port = htons(0); - int r = bind(socket, (struct sockaddr*)&socket_addr, sizeof(socket_addr)); - if (r == -1) { - return 1; - } - return 0; -} - -int xe_socket_listen(socket_t socket) { - int r = listen(socket, 5); - if (r < 0) { - return 1; - } - return 0; -} - -int xe_socket_accept(socket_t socket, xe_socket_connection_t* out_client_info) { - struct sockaddr_in client_addr; - socklen_t client_count = sizeof(client_addr); - socket_t client_socket_id = - accept(socket, (struct sockaddr*)&client_addr, &client_count); - if (client_socket_id < 0) { - return 1; - } - - out_client_info->socket = client_socket_id; - - int client_ip = client_addr.sin_addr.s_addr; - inet_ntop(AF_INET, &client_ip, out_client_info->addr, - poly::countof(out_client_info->addr)); - - return 0; -} - -int64_t xe_socket_send(socket_t socket, const uint8_t* data, size_t length, - int flags, int* out_error_code) { - ssize_t result = send(socket, data, length, flags); - *out_error_code = errno; - return result; -} - -int64_t xe_socket_recv(socket_t socket, uint8_t* data, size_t length, int flags, - int* out_error_code) { - ssize_t result = recv(socket, data, length, flags); - *out_error_code = errno; - return result; -} - -struct xe_socket_loop { - socket_t socket; - - int notify_rd_id; - int notify_wr_id; - - struct pollfd events[2]; - - bool pending_queued_write; - bool pending_recv; - bool pending_send; -}; - -xe_socket_loop_t* xe_socket_loop_create(socket_t socket) { - xe_socket_loop_t* loop = - (xe_socket_loop_t*)calloc(1, sizeof(xe_socket_loop_t)); - - loop->socket = socket; - - int notify_ids[2]; - socketpair(PF_LOCAL, SOCK_STREAM, 0, notify_ids); - loop->notify_rd_id = notify_ids[0]; - loop->notify_wr_id = notify_ids[1]; - - loop->events[0].fd = socket; - loop->events[0].events = POLLIN; - loop->events[1].fd = loop->notify_rd_id; - loop->events[1].events = POLLIN; - - return loop; -} - -void xe_socket_loop_destroy(xe_socket_loop_t* loop) { - close(loop->notify_rd_id); - close(loop->notify_wr_id); - free(loop); -} - -int xe_socket_loop_poll(xe_socket_loop_t* loop, bool check_read, - bool check_write) { - // Prep events object. - if (check_read) { - loop->events[0].events |= POLLIN; - } - if (check_write) { - loop->events[0].events |= POLLOUT; - } - - // Poll. - int r; - while ((r = poll(loop->events, poly::countof(loop->events), -1)) == -1 && - errno == EINTR) - ; - if (r == -1) { - return 1; - } - - // If we failed, die. - if (loop->events[0].revents & (POLLERR | POLLHUP | POLLNVAL)) { - return 2; - } - - // Check queued write. - loop->pending_queued_write = loop->events[1].revents != 0; - if (loop->pending_queued_write) { - uint8_t dummy; - recv(loop->notify_rd_id, &dummy, 1, 0); - } - loop->events[1].revents = 0; - loop->events[1].events = POLLIN; - - // Check send/recv. - loop->pending_recv = (loop->events[0].revents & POLLIN) != 0; - loop->pending_send = (loop->events[0].revents & POLLOUT) != 0; - loop->events[0].revents = 0; - loop->events[0].events = 0; - - return 0; -} - -void xe_socket_loop_set_queued_write(xe_socket_loop_t* loop) { - uint8_t b = 0xFF; - write(loop->notify_wr_id, &b, 1); -} - -bool xe_socket_loop_check_queued_write(xe_socket_loop_t* loop) { - return loop->pending_queued_write; -} - -bool xe_socket_loop_check_socket_recv(xe_socket_loop_t* loop) { - return loop->pending_recv; -} - -bool xe_socket_loop_check_socket_send(xe_socket_loop_t* loop) { - return loop->pending_send; -} diff --git a/src/xenia/core/socket_win.cc b/src/xenia/core/socket_win.cc deleted file mode 100644 index 7579ff5ad..000000000 --- a/src/xenia/core/socket_win.cc +++ /dev/null @@ -1,293 +0,0 @@ -/** - ****************************************************************************** - * Xenia : Xbox 360 Emulator Research Project * - ****************************************************************************** - * Copyright 2013 Ben Vanik. All rights reserved. * - * Released under the BSD license - see LICENSE in the root for more details. * - ****************************************************************************** - */ - -#include - -#include - -#include -#include -#include -#include - -// TODO(benvanik): win32 calls - -void xe_socket_init() { - WSADATA wsa_data; - int result = WSAStartup(MAKEWORD(2, 2), &wsa_data); - if (result) { - XELOGE("Winsock failed to initialize: %d", result); - return; - } -} - -socket_t xe_socket_create_tcp() { - socket_t socket_result = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); - if (socket_result < 1) { - return XE_INVALID_SOCKET; - } - return socket_result; -} - -void xe_socket_close(socket_t socket) { - struct linger so_linger; - so_linger.l_onoff = TRUE; - so_linger.l_linger = 30; - setsockopt(socket, SOL_SOCKET, SO_LINGER, (const char*)&so_linger, - sizeof so_linger); - shutdown(socket, SD_SEND); - closesocket(socket); -} - -void xe_socket_set_keepalive(socket_t socket, bool value) { - struct tcp_keepalive alive; - alive.onoff = TRUE; - alive.keepalivetime = 7200000; - alive.keepaliveinterval = 6000; - DWORD bytes_returned; - WSAIoctl(socket, SIO_KEEPALIVE_VALS, &alive, sizeof(alive), NULL, 0, - &bytes_returned, NULL, NULL); -} - -void xe_socket_set_reuseaddr(socket_t socket, bool value) { - int opt_value = value ? 1 : 0; - setsockopt(socket, SOL_SOCKET, SO_REUSEADDR, (const char*)&opt_value, - sizeof(opt_value)); -} - -void xe_socket_set_nodelay(socket_t socket, bool value) { - int opt_value = value ? 1 : 0; - setsockopt(socket, IPPROTO_TCP, TCP_NODELAY, (const char*)&opt_value, - sizeof(opt_value)); -} - -void xe_socket_set_nonblock(socket_t socket, bool value) { - u_long mode = value ? 1 : 0; - ioctlsocket(socket, FIONBIO, &mode); -} - -int xe_socket_bind(socket_t socket, uint32_t port) { - struct sockaddr_in socket_addr; - socket_addr.sin_family = AF_INET; - socket_addr.sin_addr.s_addr = htonl(INADDR_ANY); - socket_addr.sin_port = htons(port); - int r = bind(socket, (struct sockaddr*)&socket_addr, sizeof(socket_addr)); - if (r == SOCKET_ERROR) { - return 1; - } - return 0; -} - -int xe_socket_bind_loopback(socket_t socket) { - struct sockaddr_in socket_addr; - socket_addr.sin_family = AF_INET; - socket_addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); - socket_addr.sin_port = htons(0); - int r = bind(socket, (struct sockaddr*)&socket_addr, sizeof(socket_addr)); - if (r == SOCKET_ERROR) { - return 1; - } - return 0; -} - -int xe_socket_listen(socket_t socket) { - int r = listen(socket, 5); - if (r == SOCKET_ERROR) { - return 1; - } - return 0; -} - -int xe_socket_accept(socket_t socket, xe_socket_connection_t* out_client_info) { - struct sockaddr_in client_addr; - int client_count = sizeof(client_addr); - socket_t client_socket_id = - accept(socket, (struct sockaddr*)&client_addr, &client_count); - if (client_socket_id == INVALID_SOCKET) { - return 1; - } - - out_client_info->socket = client_socket_id; - - int client_ip = client_addr.sin_addr.s_addr; - inet_ntop(AF_INET, &client_ip, out_client_info->addr, - poly::countof(out_client_info->addr)); - - return 0; -} - -int64_t xe_socket_send(socket_t socket, const uint8_t* data, size_t length, - int flags, int* out_error_code) { - int result = send(socket, (const char*)data, (int)length, flags); - int error_code = WSAGetLastError(); - if (error_code == WSAEWOULDBLOCK) { - *out_error_code = EWOULDBLOCK; - } else { - *out_error_code = error_code; - } - return result; -} - -int64_t xe_socket_recv(socket_t socket, uint8_t* data, size_t length, int flags, - int* out_error_code) { - int result = recv(socket, (char*)data, (int)length, flags); - int error_code = WSAGetLastError(); - if (error_code == WSAEWOULDBLOCK) { - *out_error_code = EWOULDBLOCK; - } else { - *out_error_code = error_code; - } - return result; -} - -struct xe_socket_loop { - socket_t socket; - - socket_t notify_rd_id; - socket_t notify_wr_id; - - WSAPOLLFD events[2]; - - bool pending_queued_write; - bool pending_recv; - bool pending_send; -}; - -namespace { -int Win32SocketPair(socket_t sockets[2]) { - sockets[0] = sockets[1] = INVALID_SOCKET; - - int r; - - socket_t listener = xe_socket_create_tcp(); - xe_socket_set_reuseaddr(listener, true); - r = xe_socket_bind_loopback(listener); - r = xe_socket_listen(listener); - - sockaddr listener_name; - int listener_name_len = sizeof(listener_name); - r = getsockname(listener, &listener_name, &listener_name_len); - - socket_t client = xe_socket_create_tcp(); - r = connect(client, &listener_name, listener_name_len); - - socket_t server = accept(listener, &listener_name, &listener_name_len); - - sockaddr client_name; - int client_name_len = sizeof(client_name); - r = getsockname(client, &client_name, &client_name_len); - const char* pc = (const char*)&client_name; - const char* pn = (const char*)&listener_name; - for (size_t n = 0; n < sizeof(client_name); n++) { - if (pc[n] != pn[n]) { - closesocket(listener); - return 1; - } - } - - xe_socket_set_nonblock(client, true); - - sockets[0] = client; - sockets[1] = server; - - closesocket(listener); - return 0; -} -} - -xe_socket_loop_t* xe_socket_loop_create(socket_t socket) { - xe_socket_loop_t* loop = - (xe_socket_loop_t*)calloc(1, sizeof(xe_socket_loop_t)); - - loop->socket = socket; - - socket_t notify_ids[2] = {0, 0}; - for (int retry = 0; retry < 5; retry++) { - if (!Win32SocketPair(notify_ids)) { - break; - } - } - if (!notify_ids[0]) { - free(loop); - return NULL; - } - loop->notify_rd_id = notify_ids[0]; - loop->notify_wr_id = notify_ids[1]; - - loop->events[0].fd = socket; - loop->events[0].events = POLLIN; - loop->events[1].fd = loop->notify_rd_id; - loop->events[1].events = POLLIN; - - return loop; -} - -void xe_socket_loop_destroy(xe_socket_loop_t* loop) { - closesocket(loop->notify_rd_id); - closesocket(loop->notify_wr_id); - free(loop); -} - -int xe_socket_loop_poll(xe_socket_loop_t* loop, bool check_read, - bool check_write) { - // Prep events object. - loop->events[0].events = 0; - if (check_read) { - loop->events[0].events |= POLLIN; - } - if (check_write) { - loop->events[0].events |= POLLOUT; - } - - // Poll. - int r = WSAPoll(loop->events, static_cast(poly::countof(loop->events)), - -1); - if (r == -1) { - return 1; - } - - // If we failed, die. - if (loop->events[0].revents & (POLLERR | POLLHUP | POLLNVAL)) { - return 2; - } - - // Check queued write. - loop->pending_queued_write = loop->events[1].revents != 0; - if (loop->pending_queued_write) { - char dummy; - recv(loop->notify_rd_id, &dummy, 1, 0); - } - loop->events[1].revents = 0; - loop->events[1].events = POLLIN; - - // Check send/recv. - loop->pending_recv = (loop->events[0].revents & POLLIN) != 0; - loop->pending_send = (loop->events[0].revents & POLLOUT) != 0; - loop->events[0].revents = 0; - loop->events[0].events = 0; - - return 0; -} - -void xe_socket_loop_set_queued_write(xe_socket_loop_t* loop) { - char b = (char)0xFF; - send(loop->notify_wr_id, &b, 1, 0); -} - -bool xe_socket_loop_check_queued_write(xe_socket_loop_t* loop) { - return loop->pending_queued_write; -} - -bool xe_socket_loop_check_socket_recv(xe_socket_loop_t* loop) { - return loop->pending_recv; -} - -bool xe_socket_loop_check_socket_send(xe_socket_loop_t* loop) { - return loop->pending_send; -} diff --git a/src/xenia/core/sources.gypi b/src/xenia/core/sources.gypi deleted file mode 100644 index 72d490667..000000000 --- a/src/xenia/core/sources.gypi +++ /dev/null @@ -1,33 +0,0 @@ -# Copyright 2013 Ben Vanik. All Rights Reserved. -{ - 'sources': [ - 'hash.cc', - 'hash.h', - 'ref.cc', - 'ref.h', - 'run_loop.h', - 'socket.h', - ], - - 'conditions': [ - ['OS == "mac" or OS == "linux"', { - 'sources': [ - 'socket_posix.cc', - ], - }], - ['OS == "linux"', { - 'sources': [ - ], - }], - ['OS == "mac"', { - 'sources': [ - ], - }], - ['OS == "win"', { - 'sources': [ - 'run_loop_win.cc', - 'socket_win.cc', - ], - }], - ], -} diff --git a/src/xenia/cpu/processor.h b/src/xenia/cpu/processor.h index 59a1b24a8..5bab11ab4 100644 --- a/src/xenia/cpu/processor.h +++ b/src/xenia/cpu/processor.h @@ -13,8 +13,9 @@ #include #include -#include +#include #include +#include namespace xe { namespace cpu { diff --git a/src/xenia/cpu/xenon_runtime.h b/src/xenia/cpu/xenon_runtime.h index 2b53d0561..deb37d8c2 100644 --- a/src/xenia/cpu/xenon_runtime.h +++ b/src/xenia/cpu/xenon_runtime.h @@ -11,10 +11,10 @@ #define XENIA_CPU_XENON_RUNTIME_H_ #include - -#include +#include #include #include +#include namespace xe { namespace cpu { diff --git a/src/xenia/cpu/xenon_thread_state.h b/src/xenia/cpu/xenon_thread_state.h index aedf39df0..7a73bfccf 100644 --- a/src/xenia/cpu/xenon_thread_state.h +++ b/src/xenia/cpu/xenon_thread_state.h @@ -12,7 +12,8 @@ #include #include -#include +#include +#include namespace xdb { namespace protocol { diff --git a/src/xenia/cpu/xex_module.cc b/src/xenia/cpu/xex_module.cc index 43ff90b83..604e130e7 100644 --- a/src/xenia/cpu/xex_module.cc +++ b/src/xenia/cpu/xex_module.cc @@ -27,23 +27,22 @@ void UndefinedImport(PPCContext* ppc_state, void* arg0, void* arg1) { } } - -XexModule::XexModule( - XenonRuntime* runtime) : - runtime_(runtime), - xex_(0), - base_address_(0), low_address_(0), high_address_(0), - Module(runtime) { -} +XexModule::XexModule(XenonRuntime* runtime) + : Module(runtime), + runtime_(runtime), + xex_(nullptr), + base_address_(0), + low_address_(0), + high_address_(0) {} XexModule::~XexModule() { - xe_xex2_release(xex_); + xe_xex2_dealloc(xex_); } int XexModule::Load(const std::string& name, const std::string& path, xe_xex2_ref xex) { int result; - xex_ = xe_xex2_retain(xex); + xex_ = xex; const xe_xex2_header_t* header = xe_xex2_get_header(xex); // Scan and find the low/high addresses. diff --git a/src/xenia/cpu/xex_module.h b/src/xenia/cpu/xex_module.h index 6e973246b..52a6cf9d3 100644 --- a/src/xenia/cpu/xex_module.h +++ b/src/xenia/cpu/xex_module.h @@ -13,16 +13,14 @@ #include #include -#include +#include #include - namespace xe { namespace cpu { class XenonRuntime; - class XexModule : public alloy::runtime::Module { public: XexModule(XenonRuntime* runtime); @@ -52,9 +50,7 @@ private: uint64_t high_address_; }; - } // namespace cpu } // namespace xe - #endif // XENIA_CPU_XEX_MODULE_H_ diff --git a/src/xenia/debug_agent.h b/src/xenia/debug_agent.h index 33a970a3d..57577dced 100644 --- a/src/xenia/debug_agent.h +++ b/src/xenia/debug_agent.h @@ -12,7 +12,7 @@ #include -#include +#include namespace xe { diff --git a/src/xenia/emulator.h b/src/xenia/emulator.h index 8b82e09fa..9a5891800 100644 --- a/src/xenia/emulator.h +++ b/src/xenia/emulator.h @@ -13,9 +13,9 @@ #include #include -#include #include #include +#include #include namespace xe { diff --git a/src/xenia/export_resolver.h b/src/xenia/export_resolver.h index cf93f7ae4..c8ceea761 100644 --- a/src/xenia/export_resolver.h +++ b/src/xenia/export_resolver.h @@ -10,7 +10,7 @@ #ifndef XENIA_EXPORT_RESOLVER_H_ #define XENIA_EXPORT_RESOLVER_H_ -#include +#include #include #include diff --git a/src/xenia/gpu/command_processor.h b/src/xenia/gpu/command_processor.h index ba081aefb..ebe06be91 100644 --- a/src/xenia/gpu/command_processor.h +++ b/src/xenia/gpu/command_processor.h @@ -10,19 +10,17 @@ #ifndef XENIA_GPU_COMMAND_PROCESSOR_H_ #define XENIA_GPU_COMMAND_PROCESSOR_H_ -#include +#include #include #include #include - namespace xe { namespace gpu { class GraphicsDriver; class GraphicsSystem; - class CommandProcessor { public: CommandProcessor(GraphicsSystem* graphics_system, Memory* memory); @@ -77,9 +75,7 @@ private: DrawCommand draw_command_; }; - } // namespace gpu } // namespace xe - #endif // XENIA_GPU_COMMAND_PROCESSOR_H_ diff --git a/src/xenia/gpu/d3d11/d3d11_geometry_shader.h b/src/xenia/gpu/d3d11/d3d11_geometry_shader.h index 7e519f236..66bfd055b 100644 --- a/src/xenia/gpu/d3d11/d3d11_geometry_shader.h +++ b/src/xenia/gpu/d3d11/d3d11_geometry_shader.h @@ -10,19 +10,16 @@ #ifndef XENIA_GPU_D3D11_D3D11_GEOMETRY_SHADER_H_ #define XENIA_GPU_D3D11_D3D11_GEOMETRY_SHADER_H_ -#include - #include +#include #include - namespace xe { namespace gpu { namespace d3d11 { class D3D11VertexShaderResource; - class D3D11GeometryShader { public: virtual ~D3D11GeometryShader(); @@ -77,10 +74,8 @@ protected: alloy::StringBuffer* output) override; }; - } // namespace d3d11 } // namespace gpu } // namespace xe - #endif // XENIA_GPU_D3D11_D3D11_SHADER_H_ diff --git a/src/xenia/gpu/d3d11/d3d11_gpu-private.h b/src/xenia/gpu/d3d11/d3d11_gpu-private.h index 924e4b144..defea7f45 100644 --- a/src/xenia/gpu/d3d11/d3d11_gpu-private.h +++ b/src/xenia/gpu/d3d11/d3d11_gpu-private.h @@ -10,10 +10,9 @@ #ifndef XENIA_GPU_D3D11_D3D11_GPU_PRIVATE_H_ #define XENIA_GPU_D3D11_D3D11_GPU_PRIVATE_H_ -#include - #include +#include #include namespace xe { diff --git a/src/xenia/gpu/d3d11/d3d11_gpu.h b/src/xenia/gpu/d3d11/d3d11_gpu.h index 3ab0265e1..2357e95d9 100644 --- a/src/xenia/gpu/d3d11/d3d11_gpu.h +++ b/src/xenia/gpu/d3d11/d3d11_gpu.h @@ -12,7 +12,7 @@ #include -#include +#include namespace xe { class Emulator; diff --git a/src/xenia/gpu/d3d11/d3d11_graphics_driver.h b/src/xenia/gpu/d3d11/d3d11_graphics_driver.h index 568d08478..6fe34801a 100644 --- a/src/xenia/gpu/d3d11/d3d11_graphics_driver.h +++ b/src/xenia/gpu/d3d11/d3d11_graphics_driver.h @@ -10,19 +10,17 @@ #ifndef XENIA_GPU_D3D11_D3D11_GRAPHICS_DRIVER_H_ #define XENIA_GPU_D3D11_D3D11_GRAPHICS_DRIVER_H_ -#include +#include #include #include #include #include - namespace xe { namespace gpu { namespace d3d11 { - class D3D11GraphicsDriver : public GraphicsDriver { public: D3D11GraphicsDriver( @@ -89,10 +87,8 @@ private: } state_; }; - } // namespace d3d11 } // namespace gpu } // namespace xe - #endif // XENIA_GPU_D3D11_D3D11_GRAPHICS_DRIVER_H_ diff --git a/src/xenia/gpu/d3d11/d3d11_graphics_system.h b/src/xenia/gpu/d3d11/d3d11_graphics_system.h index 02d83328d..60f065bc3 100644 --- a/src/xenia/gpu/d3d11/d3d11_graphics_system.h +++ b/src/xenia/gpu/d3d11/d3d11_graphics_system.h @@ -10,11 +10,9 @@ #ifndef XENIA_GPU_D3D11_D3D11_GRAPHICS_SYSTEM_H_ #define XENIA_GPU_D3D11_D3D11_GRAPHICS_SYSTEM_H_ -#include - -#include +#include #include - +#include namespace xe { namespace gpu { diff --git a/src/xenia/gpu/d3d11/d3d11_profiler_display.h b/src/xenia/gpu/d3d11/d3d11_profiler_display.h index 24489f8b7..5162f9dd1 100644 --- a/src/xenia/gpu/d3d11/d3d11_profiler_display.h +++ b/src/xenia/gpu/d3d11/d3d11_profiler_display.h @@ -10,17 +10,15 @@ #ifndef XENIA_GPU_D3D11_D3D11_PROFILER_DISPLAY_H_ #define XENIA_GPU_D3D11_D3D11_PROFILER_DISPLAY_H_ -#include +#include #include - namespace xe { namespace gpu { namespace d3d11 { class D3D11Window; - class D3D11ProfilerDisplay : public ProfilerDisplay { public: D3D11ProfilerDisplay(D3D11Window* window); @@ -75,11 +73,8 @@ private: } font_description_; }; - - } // namespace d3d11 } // namespace gpu } // namespace xe - #endif // XENIA_GPU_D3D11_D3D11_PROFILER_DISPLAY_H_ diff --git a/src/xenia/gpu/d3d11/d3d11_resource_cache.h b/src/xenia/gpu/d3d11/d3d11_resource_cache.h index 064d6ca46..0ae6092bf 100644 --- a/src/xenia/gpu/d3d11/d3d11_resource_cache.h +++ b/src/xenia/gpu/d3d11/d3d11_resource_cache.h @@ -10,23 +10,20 @@ #ifndef XENIA_GPU_D3D11_D3D11_RESOURCE_CACHE_H_ #define XENIA_GPU_D3D11_D3D11_RESOURCE_CACHE_H_ -#include - +#include #include #include - namespace xe { namespace gpu { namespace d3d11 { - class D3D11ResourceCache : public ResourceCache { public: D3D11ResourceCache(Memory* memory, ID3D11Device* device, ID3D11DeviceContext* context); virtual ~D3D11ResourceCache(); - + ID3D11Device* device() const { return device_; } ID3D11DeviceContext* context() const { return context_; } @@ -54,10 +51,8 @@ private: ID3D11DeviceContext* context_; }; - } // namespace d3d11 } // namespace gpu } // namespace xe - #endif // XENIA_GPU_D3D11_D3D11_RESOURCE_CACHE_H_ diff --git a/src/xenia/gpu/d3d11/d3d11_window.h b/src/xenia/gpu/d3d11/d3d11_window.h index 8c6d92052..afc6cd51b 100644 --- a/src/xenia/gpu/d3d11/d3d11_window.h +++ b/src/xenia/gpu/d3d11/d3d11_window.h @@ -10,17 +10,14 @@ #ifndef XENIA_GPU_D3D11_D3D11_WINDOW_H_ #define XENIA_GPU_D3D11_D3D11_WINDOW_H_ -#include - +#include #include #include - namespace xe { namespace gpu { namespace d3d11 { - class D3D11Window : public xe::ui::win32::Win32Window { public: D3D11Window( @@ -48,10 +45,8 @@ private: ID3D11RenderTargetView* render_target_view_; }; - } // namespace d3d11 } // namespace gpu } // namespace xe - #endif // XENIA_GPU_D3D11_D3D11_WINDOW_H_ diff --git a/src/xenia/gpu/draw_command.h b/src/xenia/gpu/draw_command.h index ac5b07fe6..081641ff5 100644 --- a/src/xenia/gpu/draw_command.h +++ b/src/xenia/gpu/draw_command.h @@ -10,18 +10,16 @@ #ifndef XENIA_GPU_DRAW_COMMAND_H_ #define XENIA_GPU_DRAW_COMMAND_H_ -#include +#include #include #include #include #include #include - namespace xe { namespace gpu { - // TODO(benvanik): move more of the enums in here? struct DrawCommand { xenos::XE_GPU_PRIMITIVE_TYPE prim_type; @@ -70,9 +68,7 @@ struct DrawCommand { size_t pixel_shader_sampler_count; }; - } // namespace gpu } // namespace xe - #endif // XENIA_GPU_DRAW_COMMAND_H_ diff --git a/src/xenia/gpu/graphics_driver.h b/src/xenia/gpu/graphics_driver.h index 1f9f3f848..dd48a04ce 100644 --- a/src/xenia/gpu/graphics_driver.h +++ b/src/xenia/gpu/graphics_driver.h @@ -10,17 +10,15 @@ #ifndef XENIA_GPU_GRAPHICS_DRIVER_H_ #define XENIA_GPU_GRAPHICS_DRIVER_H_ -#include +#include #include #include #include #include - namespace xe { namespace gpu { - class GraphicsDriver { public: virtual ~GraphicsDriver(); @@ -32,7 +30,7 @@ public: virtual int Initialize() = 0; int LoadShader(xenos::XE_GPU_SHADER_TYPE type, - uint32_t address, uint32_t length, + uint32_t address, uint32_t length, uint32_t start); int PrepareDraw(DrawCommand& command); @@ -63,9 +61,7 @@ protected: PixelShaderResource* pixel_shader_; }; - } // namespace gpu } // namespace xe - #endif // XENIA_GPU_GRAPHICS_DRIVER_H_ diff --git a/src/xenia/gpu/graphics_system.h b/src/xenia/gpu/graphics_system.h index 4f5e8f4c3..e983cdc72 100644 --- a/src/xenia/gpu/graphics_system.h +++ b/src/xenia/gpu/graphics_system.h @@ -13,7 +13,7 @@ #include #include -#include +#include #include #include diff --git a/src/xenia/gpu/nop/nop_gpu-private.h b/src/xenia/gpu/nop/nop_gpu-private.h index 2aaa2d459..8631c82fc 100644 --- a/src/xenia/gpu/nop/nop_gpu-private.h +++ b/src/xenia/gpu/nop/nop_gpu-private.h @@ -10,11 +10,9 @@ #ifndef XENIA_GPU_NOP_NOP_GPU_PRIVATE_H_ #define XENIA_GPU_NOP_NOP_GPU_PRIVATE_H_ -#include - +#include #include - namespace xe { namespace gpu { namespace nop { @@ -27,5 +25,4 @@ namespace nop { } // namespace gpu } // namespace xe - #endif // XENIA_GPU_NOP_NOP_PRIVATE_H_ diff --git a/src/xenia/gpu/nop/nop_gpu.h b/src/xenia/gpu/nop/nop_gpu.h index 54de9d619..fadea2079 100644 --- a/src/xenia/gpu/nop/nop_gpu.h +++ b/src/xenia/gpu/nop/nop_gpu.h @@ -12,7 +12,7 @@ #include -#include +#include namespace xe { class Emulator; diff --git a/src/xenia/gpu/nop/nop_graphics_driver.h b/src/xenia/gpu/nop/nop_graphics_driver.h index 9463a0cd5..457105159 100644 --- a/src/xenia/gpu/nop/nop_graphics_driver.h +++ b/src/xenia/gpu/nop/nop_graphics_driver.h @@ -10,18 +10,15 @@ #ifndef XENIA_GPU_NOP_NOP_GRAPHICS_DRIVER_H_ #define XENIA_GPU_NOP_NOP_GRAPHICS_DRIVER_H_ -#include - +#include #include #include #include - namespace xe { namespace gpu { namespace nop { - class NopGraphicsDriver : public GraphicsDriver { public: NopGraphicsDriver(Memory* memory); @@ -39,10 +36,8 @@ protected: ResourceCache* resource_cache_; }; - } // namespace nop } // namespace gpu } // namespace xe - #endif // XENIA_GPU_NOP_NOP_GRAPHICS_DRIVER_H_ diff --git a/src/xenia/gpu/nop/nop_graphics_system.h b/src/xenia/gpu/nop/nop_graphics_system.h index cf5f43b8a..0252826b7 100644 --- a/src/xenia/gpu/nop/nop_graphics_system.h +++ b/src/xenia/gpu/nop/nop_graphics_system.h @@ -10,17 +10,14 @@ #ifndef XENIA_GPU_NOP_NOP_GRAPHICS_SYSTEM_H_ #define XENIA_GPU_NOP_NOP_GRAPHICS_SYSTEM_H_ -#include - +#include #include #include - namespace xe { namespace gpu { namespace nop { - class NopGraphicsSystem : public GraphicsSystem { public: NopGraphicsSystem(Emulator* emulator); @@ -39,10 +36,8 @@ private: HANDLE vsync_timer_; }; - } // namespace nop } // namespace gpu } // namespace xe - #endif // XENIA_GPU_NOP_NOP_GRAPHICS_SYSTEM_H_ diff --git a/src/xenia/gpu/register_file.h b/src/xenia/gpu/register_file.h index 3ab23b4fa..929536f73 100644 --- a/src/xenia/gpu/register_file.h +++ b/src/xenia/gpu/register_file.h @@ -10,13 +10,11 @@ #ifndef XENIA_GPU_REGISTER_FILE_H_ #define XENIA_GPU_REGISTER_FILE_H_ -#include - +#include namespace xe { namespace gpu { - enum Register { #define XE_GPU_REGISTER(index, type, name) \ XE_GPU_REG_##name = index, @@ -24,7 +22,6 @@ enum Register { #undef XE_GPU_REGISTER }; - class RegisterFile { public: RegisterFile(); @@ -43,9 +40,7 @@ public: } }; - } // namespace gpu } // namespace xe - #endif // XENIA_GPU_REGISTER_FILE_H_ diff --git a/src/xenia/gpu/resource.h b/src/xenia/gpu/resource.h index 98bcb9245..21a6fba84 100644 --- a/src/xenia/gpu/resource.h +++ b/src/xenia/gpu/resource.h @@ -10,14 +10,12 @@ #ifndef XENIA_GPU_RESOURCE_H_ #define XENIA_GPU_RESOURCE_H_ -#include +#include #include - namespace xe { namespace gpu { - struct MemoryRange { uint8_t* host_base; uint32_t guest_base; @@ -96,9 +94,7 @@ protected: StaticResource(); }; - } // namespace gpu } // namespace xe - #endif // XENIA_GPU_RESOURCE_H_ diff --git a/src/xenia/gpu/resource_cache.h b/src/xenia/gpu/resource_cache.h index 968fdc40b..870a6c495 100644 --- a/src/xenia/gpu/resource_cache.h +++ b/src/xenia/gpu/resource_cache.h @@ -13,7 +13,7 @@ #include #include -#include +#include #include #include #include @@ -21,11 +21,9 @@ #include #include - namespace xe { namespace gpu { - class ResourceCache { public: virtual ~ResourceCache(); @@ -36,7 +34,7 @@ public: PixelShaderResource* FetchPixelShader( const MemoryRange& memory_range, const PixelShaderResource::Info& info); - + TextureResource* FetchTexture( const MemoryRange& memory_range, const TextureResource::Info& info); @@ -92,7 +90,7 @@ protected: resources_.push_back(resource); return resource; } - + virtual VertexShaderResource* CreateVertexShader( const MemoryRange& memory_range, const VertexShaderResource::Info& info) = 0; @@ -120,9 +118,7 @@ private: std::multimap paged_resources_; }; - } // namespace gpu } // namespace xe - #endif // XENIA_GPU_RESOURCE_CACHE_H_ diff --git a/src/xenia/gpu/xenos/packets.h b/src/xenia/gpu/xenos/packets.h index 459ab7e6e..492b836bb 100644 --- a/src/xenia/gpu/xenos/packets.h +++ b/src/xenia/gpu/xenos/packets.h @@ -10,14 +10,12 @@ #ifndef XENIA_GPU_XENOS_PACKETS_H_ #define XENIA_GPU_XENOS_PACKETS_H_ -#include - +#include namespace xe { namespace gpu { namespace xenos { - // Opcodes (IT_OPCODE) for Type-3 commands in the ringbuffer. // https://github.com/freedreno/amd-gpu/blob/master/include/api/gsl_pm4types.h // Not sure if all of these are used. @@ -82,10 +80,8 @@ enum Type3Opcode { PM4_SET_BIN_SELECT_HI = 0x63, }; - } // namespace xenos } // namespace gpu } // namespace xe - #endif // XENIA_GPU_XENOS_PACKETS_H_ diff --git a/src/xenia/gpu/xenos/ucode.h b/src/xenia/gpu/xenos/ucode.h index 1e656d1ca..963e78d35 100644 --- a/src/xenia/gpu/xenos/ucode.h +++ b/src/xenia/gpu/xenos/ucode.h @@ -10,7 +10,7 @@ #ifndef XENIA_GPU_XENOS_UCODE_H_ #define XENIA_GPU_XENOS_UCODE_H_ -#include +#include namespace xe { namespace gpu { diff --git a/src/xenia/gpu/xenos/ucode_disassembler.h b/src/xenia/gpu/xenos/ucode_disassembler.h index 70516960c..d6fdf47e2 100644 --- a/src/xenia/gpu/xenos/ucode_disassembler.h +++ b/src/xenia/gpu/xenos/ucode_disassembler.h @@ -10,8 +10,7 @@ #ifndef XENIA_GPU_XENOS_UCODE_DISASSEMBLER_H_ #define XENIA_GPU_XENOS_UCODE_DISASSEMBLER_H_ -#include - +#include #include #include diff --git a/src/xenia/gpu/xenos/xenos.h b/src/xenia/gpu/xenos/xenos.h index 35cb70ae3..63beb54ec 100644 --- a/src/xenia/gpu/xenos/xenos.h +++ b/src/xenia/gpu/xenos/xenos.h @@ -10,7 +10,7 @@ #ifndef XENIA_GPU_XENOS_XENOS_H_ #define XENIA_GPU_XENOS_XENOS_H_ -#include +#include #include namespace xe { diff --git a/src/xenia/hid/input_driver.h b/src/xenia/hid/input_driver.h index db8cb3725..4c8ecfd06 100644 --- a/src/xenia/hid/input_driver.h +++ b/src/xenia/hid/input_driver.h @@ -10,7 +10,7 @@ #ifndef XENIA_HID_INPUT_DRIVER_H_ #define XENIA_HID_INPUT_DRIVER_H_ -#include +#include #include namespace xe { diff --git a/src/xenia/hid/input_system.h b/src/xenia/hid/input_system.h index 98ff0e23a..3f71866a6 100644 --- a/src/xenia/hid/input_system.h +++ b/src/xenia/hid/input_system.h @@ -13,7 +13,7 @@ #include #include -#include +#include #include #include diff --git a/src/xenia/hid/nop/nop_hid-private.h b/src/xenia/hid/nop/nop_hid-private.h index 29bd21ebb..a4460606c 100644 --- a/src/xenia/hid/nop/nop_hid-private.h +++ b/src/xenia/hid/nop/nop_hid-private.h @@ -10,7 +10,7 @@ #ifndef XENIA_HID_NOP_NOP_HID_PRIVATE_H_ #define XENIA_HID_NOP_NOP_HID_PRIVATE_H_ -#include +#include #include namespace xe { diff --git a/src/xenia/hid/nop/nop_hid.h b/src/xenia/hid/nop/nop_hid.h index 79c29aecd..d401ce54a 100644 --- a/src/xenia/hid/nop/nop_hid.h +++ b/src/xenia/hid/nop/nop_hid.h @@ -12,7 +12,7 @@ #include -#include +#include namespace xe { namespace hid { diff --git a/src/xenia/hid/nop/nop_input_driver.h b/src/xenia/hid/nop/nop_input_driver.h index 6faca0c0a..7be53bf16 100644 --- a/src/xenia/hid/nop/nop_input_driver.h +++ b/src/xenia/hid/nop/nop_input_driver.h @@ -10,7 +10,7 @@ #ifndef XENIA_HID_NOP_NOP_INPUT_DRIVER_H_ #define XENIA_HID_NOP_NOP_INPUT_DRIVER_H_ -#include +#include #include #include diff --git a/src/xenia/hid/winkey/winkey_hid-private.h b/src/xenia/hid/winkey/winkey_hid-private.h index 8272462b5..da925e722 100644 --- a/src/xenia/hid/winkey/winkey_hid-private.h +++ b/src/xenia/hid/winkey/winkey_hid-private.h @@ -10,7 +10,7 @@ #ifndef XENIA_HID_WINKEY_WINKEY_HID_PRIVATE_H_ #define XENIA_HID_WINKEY_WINKEY_HID_PRIVATE_H_ -#include +#include #include namespace xe { diff --git a/src/xenia/hid/winkey/winkey_hid.h b/src/xenia/hid/winkey/winkey_hid.h index b249d8b30..cfdec12e1 100644 --- a/src/xenia/hid/winkey/winkey_hid.h +++ b/src/xenia/hid/winkey/winkey_hid.h @@ -12,7 +12,7 @@ #include -#include +#include namespace xe { namespace hid { diff --git a/src/xenia/hid/winkey/winkey_input_driver.h b/src/xenia/hid/winkey/winkey_input_driver.h index 9a547cb8f..16bc51461 100644 --- a/src/xenia/hid/winkey/winkey_input_driver.h +++ b/src/xenia/hid/winkey/winkey_input_driver.h @@ -10,7 +10,7 @@ #ifndef XENIA_HID_WINKEY_WINKEY_DRIVER_H_ #define XENIA_HID_WINKEY_WINKEY_DRIVER_H_ -#include +#include #include #include diff --git a/src/xenia/hid/xinput/xinput_hid-private.h b/src/xenia/hid/xinput/xinput_hid-private.h index cc83fd0b3..c9dc937ae 100644 --- a/src/xenia/hid/xinput/xinput_hid-private.h +++ b/src/xenia/hid/xinput/xinput_hid-private.h @@ -10,7 +10,7 @@ #ifndef XENIA_HID_XINPUT_XINPUT_HID_PRIVATE_H_ #define XENIA_HID_XINPUT_XINPUT_HID_PRIVATE_H_ -#include +#include #include namespace xe { diff --git a/src/xenia/hid/xinput/xinput_hid.h b/src/xenia/hid/xinput/xinput_hid.h index d6c8d78c9..7fbca77cf 100644 --- a/src/xenia/hid/xinput/xinput_hid.h +++ b/src/xenia/hid/xinput/xinput_hid.h @@ -12,7 +12,7 @@ #include -#include +#include namespace xe { namespace hid { diff --git a/src/xenia/hid/xinput/xinput_input_driver.h b/src/xenia/hid/xinput/xinput_input_driver.h index c020f59a7..c780b7df4 100644 --- a/src/xenia/hid/xinput/xinput_input_driver.h +++ b/src/xenia/hid/xinput/xinput_input_driver.h @@ -10,7 +10,7 @@ #ifndef XENIA_HID_XINPUT_XINPUT_DRIVER_H_ #define XENIA_HID_XINPUT_XINPUT_DRIVER_H_ -#include +#include #include #include diff --git a/src/xenia/kernel/app.h b/src/xenia/kernel/app.h index cc6a1b45e..4b4782a69 100644 --- a/src/xenia/kernel/app.h +++ b/src/xenia/kernel/app.h @@ -14,7 +14,7 @@ #include #include -#include +#include #include namespace xe { diff --git a/src/xenia/kernel/apps/apps.h b/src/xenia/kernel/apps/apps.h index 723dc74ae..9c0d2477c 100644 --- a/src/xenia/kernel/apps/apps.h +++ b/src/xenia/kernel/apps/apps.h @@ -11,8 +11,6 @@ #define XENIA_KERNEL_XBOXKRNL_APPS_APPS_H_ #include -#include - #include #include diff --git a/src/xenia/kernel/apps/xmp_app.h b/src/xenia/kernel/apps/xmp_app.h index a57cb4bc7..b851ea5c2 100644 --- a/src/xenia/kernel/apps/xmp_app.h +++ b/src/xenia/kernel/apps/xmp_app.h @@ -11,8 +11,6 @@ #define XENIA_KERNEL_XBOXKRNL_APPS_XMP_APP_H_ #include -#include - #include #include diff --git a/src/xenia/kernel/async_request.h b/src/xenia/kernel/async_request.h index 93876445d..1da5fa18a 100644 --- a/src/xenia/kernel/async_request.h +++ b/src/xenia/kernel/async_request.h @@ -13,7 +13,6 @@ #include #include -#include #include namespace xe { diff --git a/src/xenia/kernel/dispatcher.h b/src/xenia/kernel/dispatcher.h index 2cde407b9..e06a4e823 100644 --- a/src/xenia/kernel/dispatcher.h +++ b/src/xenia/kernel/dispatcher.h @@ -13,8 +13,6 @@ #include #include -#include - #include namespace xe { diff --git a/src/xenia/kernel/fs/device.h b/src/xenia/kernel/fs/device.h index eff460bf5..0758aa2f1 100644 --- a/src/xenia/kernel/fs/device.h +++ b/src/xenia/kernel/fs/device.h @@ -13,7 +13,7 @@ #include #include -#include +#include #include namespace xe { diff --git a/src/xenia/kernel/fs/devices/disc_image_device.h b/src/xenia/kernel/fs/devices/disc_image_device.h index 97b6feb41..352a089db 100644 --- a/src/xenia/kernel/fs/devices/disc_image_device.h +++ b/src/xenia/kernel/fs/devices/disc_image_device.h @@ -15,7 +15,6 @@ #include #include -#include #include namespace xe { diff --git a/src/xenia/kernel/fs/devices/disc_image_entry.h b/src/xenia/kernel/fs/devices/disc_image_entry.h index 4ba6c79cc..019abc46a 100644 --- a/src/xenia/kernel/fs/devices/disc_image_entry.h +++ b/src/xenia/kernel/fs/devices/disc_image_entry.h @@ -14,7 +14,6 @@ #include #include -#include #include namespace xe { diff --git a/src/xenia/kernel/fs/devices/disc_image_file.h b/src/xenia/kernel/fs/devices/disc_image_file.h index 5e22187eb..95e5bb83d 100644 --- a/src/xenia/kernel/fs/devices/disc_image_file.h +++ b/src/xenia/kernel/fs/devices/disc_image_file.h @@ -11,7 +11,6 @@ #define XENIA_KERNEL_FS_DEVICES_DISC_IMAGE_FILE_H_ #include -#include #include namespace xe { diff --git a/src/xenia/kernel/fs/devices/host_path_device.h b/src/xenia/kernel/fs/devices/host_path_device.h index bc662ada6..0af6d8b62 100644 --- a/src/xenia/kernel/fs/devices/host_path_device.h +++ b/src/xenia/kernel/fs/devices/host_path_device.h @@ -13,7 +13,6 @@ #include #include -#include #include namespace xe { diff --git a/src/xenia/kernel/fs/devices/host_path_entry.h b/src/xenia/kernel/fs/devices/host_path_entry.h index b72b0460a..ca156b93a 100644 --- a/src/xenia/kernel/fs/devices/host_path_entry.h +++ b/src/xenia/kernel/fs/devices/host_path_entry.h @@ -11,7 +11,6 @@ #define XENIA_KERNEL_FS_DEVICES_HOST_PATH_ENTRY_H_ #include -#include #include namespace xe { diff --git a/src/xenia/kernel/fs/devices/host_path_file.h b/src/xenia/kernel/fs/devices/host_path_file.h index 9acbc909d..cbd59c083 100644 --- a/src/xenia/kernel/fs/devices/host_path_file.h +++ b/src/xenia/kernel/fs/devices/host_path_file.h @@ -13,7 +13,6 @@ #include #include -#include #include namespace xe { diff --git a/src/xenia/kernel/fs/devices/stfs_container_device.h b/src/xenia/kernel/fs/devices/stfs_container_device.h index 0022e6545..34568bedd 100644 --- a/src/xenia/kernel/fs/devices/stfs_container_device.h +++ b/src/xenia/kernel/fs/devices/stfs_container_device.h @@ -15,7 +15,6 @@ #include #include -#include #include namespace xe { diff --git a/src/xenia/kernel/fs/devices/stfs_container_entry.h b/src/xenia/kernel/fs/devices/stfs_container_entry.h index 65e416c0e..8cd6d0729 100644 --- a/src/xenia/kernel/fs/devices/stfs_container_entry.h +++ b/src/xenia/kernel/fs/devices/stfs_container_entry.h @@ -14,7 +14,6 @@ #include #include -#include #include namespace xe { diff --git a/src/xenia/kernel/fs/devices/stfs_container_file.h b/src/xenia/kernel/fs/devices/stfs_container_file.h index 90e2e3157..d468130ca 100644 --- a/src/xenia/kernel/fs/devices/stfs_container_file.h +++ b/src/xenia/kernel/fs/devices/stfs_container_file.h @@ -11,8 +11,6 @@ #define XENIA_KERNEL_FS_DEVICES_STFS_CONTAINER_FILE_H_ #include -#include - #include namespace xe { diff --git a/src/xenia/kernel/fs/entry.h b/src/xenia/kernel/fs/entry.h index e9082d6b4..3959d083c 100644 --- a/src/xenia/kernel/fs/entry.h +++ b/src/xenia/kernel/fs/entry.h @@ -13,7 +13,7 @@ #include #include -#include +#include #include namespace xe { diff --git a/src/xenia/kernel/fs/filesystem.h b/src/xenia/kernel/fs/filesystem.h index 708f89343..54239cacb 100644 --- a/src/xenia/kernel/fs/filesystem.h +++ b/src/xenia/kernel/fs/filesystem.h @@ -16,8 +16,6 @@ #include #include -#include - #include namespace xe { diff --git a/src/xenia/kernel/fs/gdfx.h b/src/xenia/kernel/fs/gdfx.h index 682cb9f14..b829efcdf 100644 --- a/src/xenia/kernel/fs/gdfx.h +++ b/src/xenia/kernel/fs/gdfx.h @@ -13,7 +13,7 @@ #include #include -#include +#include #include #include diff --git a/src/xenia/kernel/fs/stfs.h b/src/xenia/kernel/fs/stfs.h index a5291480e..7d29cf204 100644 --- a/src/xenia/kernel/fs/stfs.h +++ b/src/xenia/kernel/fs/stfs.h @@ -14,7 +14,7 @@ #include #include -#include +#include #include #include diff --git a/src/xenia/kernel/kernel_state.h b/src/xenia/kernel/kernel_state.h index c590b0da6..ae690e21f 100644 --- a/src/xenia/kernel/kernel_state.h +++ b/src/xenia/kernel/kernel_state.h @@ -14,14 +14,13 @@ #include #include -#include - #include -#include #include +#include #include #include -#include +#include +#include namespace xe { class Emulator; diff --git a/src/xenia/kernel/native_list.h b/src/xenia/kernel/native_list.h index 5c29e7bb9..d07774a2c 100644 --- a/src/xenia/kernel/native_list.h +++ b/src/xenia/kernel/native_list.h @@ -11,8 +11,7 @@ #define XENIA_KERNEL_XBOXKRNL_NATIVE_LIST_H_ #include -#include - +#include #include namespace xe { diff --git a/src/xenia/kernel/object_table.h b/src/xenia/kernel/object_table.h index 1da7e8184..f49aa1194 100644 --- a/src/xenia/kernel/object_table.h +++ b/src/xenia/kernel/object_table.h @@ -13,8 +13,6 @@ #include #include -#include - #include namespace xe { diff --git a/src/xenia/kernel/objects/xuser_module.cc b/src/xenia/kernel/objects/xuser_module.cc index 03ccd998b..2f9449448 100644 --- a/src/xenia/kernel/objects/xuser_module.cc +++ b/src/xenia/kernel/objects/xuser_module.cc @@ -20,11 +20,11 @@ namespace kernel { using namespace xe::cpu; XUserModule::XUserModule(KernelState* kernel_state, const char* path) - : XModule(kernel_state, path), xex_(NULL) {} + : XModule(kernel_state, path), xex_(nullptr) {} -XUserModule::~XUserModule() { xe_xex2_release(xex_); } +XUserModule::~XUserModule() { xe_xex2_dealloc(xex_); } -xe_xex2_ref XUserModule::xex() { return xe_xex2_retain(xex_); } +xe_xex2_ref XUserModule::xex() { return xex_; } const xe_xex2_header_t* XUserModule::xex_header() { return xe_xex2_get_header(xex_); @@ -50,33 +50,52 @@ X_STATUS XUserModule::LoadFromFile(const char* path) { if (fs_entry->can_map()) { // Map. auto mmap = fs_entry->CreateMemoryMapping(fs::Mode::READ, 0, 0); - XEEXPECTNOTNULL(mmap); + if (!mmap) { + if (file) { + file->Release(); + } + return result; + } // Load the module. result = LoadFromMemory(mmap->address(), mmap->length()); } else { XFileInfo file_info; result = fs_entry->QueryInfo(&file_info); - XEEXPECTZERO(result); + if (result) { + if (file) { + file->Release(); + } + return result; + } std::vector buffer(file_info.file_length); // Open file for reading. result = kernel_state()->file_system()->Open( std::move(fs_entry), kernel_state(), fs::Mode::READ, false, &file); - XEEXPECTZERO(result); + if (result) { + if (file) { + file->Release(); + } + return result; + } // Read entire file into memory. // Ugh. size_t bytes_read = 0; result = file->Read(buffer.data(), buffer.size(), 0, &bytes_read); - XEEXPECTZERO(result); + if (result) { + if (file) { + file->Release(); + } + return result; + } // Load the module. result = LoadFromMemory(buffer.data(), bytes_read); } -XECLEANUP: if (file) { file->Release(); } diff --git a/src/xenia/kernel/user_profile.h b/src/xenia/kernel/user_profile.h index 95f40388d..d654396ae 100644 --- a/src/xenia/kernel/user_profile.h +++ b/src/xenia/kernel/user_profile.h @@ -16,8 +16,6 @@ #include #include -#include - #include namespace xe { diff --git a/src/xenia/kernel/util/shim_utils.h b/src/xenia/kernel/util/shim_utils.h index 8adeb86de..0ef263435 100644 --- a/src/xenia/kernel/util/shim_utils.h +++ b/src/xenia/kernel/util/shim_utils.h @@ -10,10 +10,8 @@ #ifndef XENIA_KERNEL_UTIL_SHIM_UTILS_H_ #define XENIA_KERNEL_UTIL_SHIM_UTILS_H_ -#include -#include - #include +#include #include diff --git a/src/xenia/kernel/util/xex2.cc b/src/xenia/kernel/util/xex2.cc index 8e2e67db5..44a6a79bd 100644 --- a/src/xenia/kernel/util/xex2.cc +++ b/src/xenia/kernel/util/xex2.cc @@ -23,11 +23,19 @@ // using namespace alloy; +// TODO(benvanik): remove. +#define XEEXPECTZERO(expr) \ + if ((expr) != 0) { \ + goto XECLEANUP; \ + } +#define XEEXPECTNOTNULL(expr) \ + if ((expr) == NULL) { \ + goto XECLEANUP; \ + } + DEFINE_bool(xex_dev_key, false, "Use the devkit key."); typedef struct xe_xex2 { - xe_ref_t ref; - xe::Memory *memory; xe_xex2_header_t header; @@ -52,7 +60,6 @@ int xe_xex2_find_import_infos(xe_xex2_ref xex, xe_xex2_ref xe_xex2_load(xe::Memory *memory, const void *addr, const size_t length, xe_xex2_options_t options) { xe_xex2_ref xex = (xe_xex2_ref)calloc(1, sizeof(xe_xex2)); - xe_ref_init((xe_ref)xex); xex->memory = memory; xex->sections = new std::vector(); @@ -74,11 +81,15 @@ xe_xex2_ref xe_xex2_load(xe::Memory *memory, const void *addr, return xex; XECLEANUP: - xe_xex2_release(xex); - return NULL; + xe_xex2_dealloc(xex); + return nullptr; } void xe_xex2_dealloc(xe_xex2_ref xex) { + if (!xex) { + return; + } + for (std::vector::iterator it = xex->sections->begin(); it != xex->sections->end(); ++it) { delete *it; @@ -98,15 +109,6 @@ void xe_xex2_dealloc(xe_xex2_ref xex) { xex->memory = NULL; } -xe_xex2_ref xe_xex2_retain(xe_xex2_ref xex) { - xe_ref_retain((xe_ref)xex); - return xex; -} - -void xe_xex2_release(xe_xex2_ref xex) { - xe_ref_release((xe_ref)xex, (xe_ref_dealloc_t)xe_xex2_dealloc); -} - const xe_xex2_header_t *xe_xex2_get_header(xe_xex2_ref xex) { return &xex->header; } @@ -720,7 +722,7 @@ int xe_xex2_read_image_compressed(const xe_xex2_header_t *header, XELOGE("Unable to allocate XEX memory at %.8X-%.8X.", header->exe_address, uncompressed_size); result_code = 2; - XEFAIL(); + goto XECLEANUP; } uint8_t *buffer = memory->Translate(header->exe_address); diff --git a/src/xenia/kernel/util/xex2.h b/src/xenia/kernel/util/xex2.h index c6a63fd04..bb806648d 100644 --- a/src/xenia/kernel/util/xex2.h +++ b/src/xenia/kernel/util/xex2.h @@ -10,8 +10,9 @@ #ifndef XENIA_KERNEL_UTIL_XEX2_H_ #define XENIA_KERNEL_UTIL_XEX2_H_ -#include +#include #include +#include typedef struct { int reserved; } xe_xex2_options_t; @@ -45,8 +46,7 @@ class PESection { xe_xex2_ref xe_xex2_load(xe::Memory* memory, const void* addr, const size_t length, xe_xex2_options_t options); -xe_xex2_ref xe_xex2_retain(xe_xex2_ref xex); -void xe_xex2_release(xe_xex2_ref xex); +void xe_xex2_dealloc(xe_xex2_ref xex); const xe_xex2_header_t* xe_xex2_get_header(xe_xex2_ref xex); const PESection* xe_xex2_get_pe_section(xe_xex2_ref xex, const char* name); diff --git a/src/xenia/kernel/xam_content.cc b/src/xenia/kernel/xam_content.cc index 5876181ef..3b1c97a4d 100644 --- a/src/xenia/kernel/xam_content.cc +++ b/src/xenia/kernel/xam_content.cc @@ -8,11 +8,10 @@ */ #include -#include -#include #include -#include #include +#include +#include namespace xe { namespace kernel { diff --git a/src/xenia/kernel/xam_info.cc b/src/xenia/kernel/xam_info.cc index 39eeb44a9..b6a140c01 100644 --- a/src/xenia/kernel/xam_info.cc +++ b/src/xenia/kernel/xam_info.cc @@ -8,13 +8,12 @@ */ #include -#include -#include #include -#include #include #include #include +#include +#include namespace xe { namespace kernel { diff --git a/src/xenia/kernel/xam_input.cc b/src/xenia/kernel/xam_input.cc index da8656c93..eafc7dda1 100644 --- a/src/xenia/kernel/xam_input.cc +++ b/src/xenia/kernel/xam_input.cc @@ -8,13 +8,12 @@ */ #include -#include -#include #include #include #include -#include #include +#include +#include namespace xe { namespace kernel { diff --git a/src/xenia/kernel/xam_module.h b/src/xenia/kernel/xam_module.h index 0adab60de..353f03ae5 100644 --- a/src/xenia/kernel/xam_module.h +++ b/src/xenia/kernel/xam_module.h @@ -11,10 +11,9 @@ #define XENIA_KERNEL_XAM_H_ #include -#include #include -#include #include +#include namespace xe { namespace kernel { diff --git a/src/xenia/kernel/xam_msg.cc b/src/xenia/kernel/xam_msg.cc index 29d537956..9647c323a 100644 --- a/src/xenia/kernel/xam_msg.cc +++ b/src/xenia/kernel/xam_msg.cc @@ -8,12 +8,11 @@ */ #include -#include -#include #include -#include #include #include +#include +#include namespace xe { namespace kernel { diff --git a/src/xenia/kernel/xam_net.cc b/src/xenia/kernel/xam_net.cc index f141fe8b8..3ac6ef62c 100644 --- a/src/xenia/kernel/xam_net.cc +++ b/src/xenia/kernel/xam_net.cc @@ -10,11 +10,10 @@ #include #include -#include -#include #include -#include #include +#include +#include namespace xe { namespace kernel { diff --git a/src/xenia/kernel/xam_notify.cc b/src/xenia/kernel/xam_notify.cc index dfd753ef8..5a93bfb32 100644 --- a/src/xenia/kernel/xam_notify.cc +++ b/src/xenia/kernel/xam_notify.cc @@ -8,12 +8,11 @@ */ #include -#include -#include #include -#include #include #include +#include +#include namespace xe { namespace kernel { diff --git a/src/xenia/kernel/xam_ordinals.h b/src/xenia/kernel/xam_ordinals.h index 4b85e613c..e7a71561d 100644 --- a/src/xenia/kernel/xam_ordinals.h +++ b/src/xenia/kernel/xam_ordinals.h @@ -11,7 +11,6 @@ #define XENIA_KERNEL_XAM_ORDINALS_H_ #include -#include #include // Build an ordinal enum to make it easy to lookup ordinals. diff --git a/src/xenia/kernel/xam_private.h b/src/xenia/kernel/xam_private.h index a79b2082b..bca7b2ac8 100644 --- a/src/xenia/kernel/xam_private.h +++ b/src/xenia/kernel/xam_private.h @@ -11,7 +11,6 @@ #define XENIA_KERNEL_XAM_PRIVATE_H_ #include -#include #include namespace xe { diff --git a/src/xenia/kernel/xam_ui.cc b/src/xenia/kernel/xam_ui.cc index 4b7302b95..553c43161 100644 --- a/src/xenia/kernel/xam_ui.cc +++ b/src/xenia/kernel/xam_ui.cc @@ -8,11 +8,10 @@ */ #include -#include -#include #include -#include #include +#include +#include namespace xe { namespace kernel { diff --git a/src/xenia/kernel/xam_user.cc b/src/xenia/kernel/xam_user.cc index 9447ba5c3..f77cdcd5b 100644 --- a/src/xenia/kernel/xam_user.cc +++ b/src/xenia/kernel/xam_user.cc @@ -8,13 +8,12 @@ */ #include -#include -#include #include -#include #include #include #include +#include +#include namespace xe { namespace kernel { diff --git a/src/xenia/kernel/xam_video.cc b/src/xenia/kernel/xam_video.cc index d9fff40eb..4b06939d5 100644 --- a/src/xenia/kernel/xam_video.cc +++ b/src/xenia/kernel/xam_video.cc @@ -8,11 +8,10 @@ */ #include -#include -#include #include -#include #include +#include +#include namespace xe { namespace kernel { diff --git a/src/xenia/kernel/xam_voice.cc b/src/xenia/kernel/xam_voice.cc index decc55417..4bdcc106e 100644 --- a/src/xenia/kernel/xam_voice.cc +++ b/src/xenia/kernel/xam_voice.cc @@ -8,12 +8,11 @@ */ #include -#include -#include #include #include -#include #include +#include +#include namespace xe { namespace kernel { diff --git a/src/xenia/kernel/xboxkrnl_audio.cc b/src/xenia/kernel/xboxkrnl_audio.cc index c045a0b88..dfd723e10 100644 --- a/src/xenia/kernel/xboxkrnl_audio.cc +++ b/src/xenia/kernel/xboxkrnl_audio.cc @@ -7,14 +7,13 @@ ****************************************************************************** */ -#include -#include -#include -#include #include +#include +#include #include -#include #include +#include +#include namespace xe { namespace kernel { diff --git a/src/xenia/kernel/xboxkrnl_debug.cc b/src/xenia/kernel/xboxkrnl_debug.cc index 232ed4595..95aa084d6 100644 --- a/src/xenia/kernel/xboxkrnl_debug.cc +++ b/src/xenia/kernel/xboxkrnl_debug.cc @@ -8,12 +8,11 @@ */ #include -#include -#include #include -#include #include #include +#include +#include namespace xe { namespace kernel { diff --git a/src/xenia/kernel/xboxkrnl_hal.cc b/src/xenia/kernel/xboxkrnl_hal.cc index 424744268..4ba62f831 100644 --- a/src/xenia/kernel/xboxkrnl_hal.cc +++ b/src/xenia/kernel/xboxkrnl_hal.cc @@ -8,11 +8,10 @@ */ #include -#include -#include #include -#include #include +#include +#include namespace xe { namespace kernel { diff --git a/src/xenia/kernel/xboxkrnl_io.cc b/src/xenia/kernel/xboxkrnl_io.cc index a74a77549..4ccc18f6f 100644 --- a/src/xenia/kernel/xboxkrnl_io.cc +++ b/src/xenia/kernel/xboxkrnl_io.cc @@ -7,15 +7,14 @@ ****************************************************************************** */ +#include #include -#include -#include #include #include -#include #include #include #include +#include #include namespace xe { @@ -384,7 +383,8 @@ SHIM_CALL NtQueryInformationFile_shim(PPCContext* ppc_state, assert_true(length == 8); info = 8; // TODO(benvanik): use pointer to fs:: entry? - SHIM_SET_MEM_64(file_info_ptr, hash_combine(0, file->absolute_path())); + SHIM_SET_MEM_64(file_info_ptr, + poly::hash_combine(0, file->absolute_path())); break; case XFilePositionInformation: // struct FILE_POSITION_INFORMATION { diff --git a/src/xenia/kernel/xboxkrnl_memory.cc b/src/xenia/kernel/xboxkrnl_memory.cc index 7cb6266dc..8e40b8278 100644 --- a/src/xenia/kernel/xboxkrnl_memory.cc +++ b/src/xenia/kernel/xboxkrnl_memory.cc @@ -9,11 +9,10 @@ #include #include -#include -#include #include -#include #include +#include +#include namespace xe { namespace kernel { diff --git a/src/xenia/kernel/xboxkrnl_misc.cc b/src/xenia/kernel/xboxkrnl_misc.cc index 28cf77f87..cd2f5ca76 100644 --- a/src/xenia/kernel/xboxkrnl_misc.cc +++ b/src/xenia/kernel/xboxkrnl_misc.cc @@ -8,12 +8,11 @@ */ #include -#include -#include #include -#include #include #include +#include +#include namespace xe { namespace kernel { diff --git a/src/xenia/kernel/xboxkrnl_module.h b/src/xenia/kernel/xboxkrnl_module.h index c5923bf57..d1e97d260 100644 --- a/src/xenia/kernel/xboxkrnl_module.h +++ b/src/xenia/kernel/xboxkrnl_module.h @@ -11,10 +11,9 @@ #define XENIA_KERNEL_XBOXKRNL_MODULE_H_ #include -#include #include -#include #include +#include // All of the exported functions: #include diff --git a/src/xenia/kernel/xboxkrnl_modules.cc b/src/xenia/kernel/xboxkrnl_modules.cc index 03dd0f358..33f66aa26 100644 --- a/src/xenia/kernel/xboxkrnl_modules.cc +++ b/src/xenia/kernel/xboxkrnl_modules.cc @@ -8,13 +8,12 @@ */ #include -#include -#include #include -#include #include #include #include +#include +#include namespace xe { namespace kernel { @@ -145,7 +144,6 @@ SHIM_CALL XexCheckExecutablePrivilege_shim(PPCContext* ppc_state, const xe_xex2_header_t* header = xe_xex2_get_header(xex); uint32_t result = (header->system_flags & mask) > 0; - xe_xex2_release(xex); module->Release(); SHIM_SET_RETURN_32(result); diff --git a/src/xenia/kernel/xboxkrnl_ob.cc b/src/xenia/kernel/xboxkrnl_ob.cc index 697a36fe2..a5589e359 100644 --- a/src/xenia/kernel/xboxkrnl_ob.cc +++ b/src/xenia/kernel/xboxkrnl_ob.cc @@ -8,13 +8,12 @@ */ #include -#include -#include #include -#include -#include #include #include +#include +#include +#include namespace xe { namespace kernel { diff --git a/src/xenia/kernel/xboxkrnl_ordinals.h b/src/xenia/kernel/xboxkrnl_ordinals.h index 27b0f5033..95c0d5087 100644 --- a/src/xenia/kernel/xboxkrnl_ordinals.h +++ b/src/xenia/kernel/xboxkrnl_ordinals.h @@ -11,7 +11,6 @@ #define XENIA_KERNEL_XBOXKRNL_ORDINALS_H_ #include -#include #include // Build an ordinal enum to make it easy to lookup ordinals. diff --git a/src/xenia/kernel/xboxkrnl_private.h b/src/xenia/kernel/xboxkrnl_private.h index 4a67d2736..3bb1bc76a 100644 --- a/src/xenia/kernel/xboxkrnl_private.h +++ b/src/xenia/kernel/xboxkrnl_private.h @@ -11,7 +11,6 @@ #define XENIA_KERNEL_XBOXKRNL_PRIVATE_H_ #include -#include #include namespace xe { diff --git a/src/xenia/kernel/xboxkrnl_rtl.h b/src/xenia/kernel/xboxkrnl_rtl.h index fa959bc3a..abec61852 100644 --- a/src/xenia/kernel/xboxkrnl_rtl.h +++ b/src/xenia/kernel/xboxkrnl_rtl.h @@ -11,7 +11,6 @@ #define XENIA_KERNEL_XBOXKRNL_RTL_H_ #include -#include #include namespace xe { diff --git a/src/xenia/kernel/xboxkrnl_strings.cc b/src/xenia/kernel/xboxkrnl_strings.cc index 1498deb43..0c774fbd4 100644 --- a/src/xenia/kernel/xboxkrnl_strings.cc +++ b/src/xenia/kernel/xboxkrnl_strings.cc @@ -8,14 +8,13 @@ */ #include -#include -#include #include -#include #include #include #include #include +#include +#include namespace xe { namespace kernel { diff --git a/src/xenia/kernel/xboxkrnl_threading.cc b/src/xenia/kernel/xboxkrnl_threading.cc index 4a9be33ec..e63ca2ef0 100644 --- a/src/xenia/kernel/xboxkrnl_threading.cc +++ b/src/xenia/kernel/xboxkrnl_threading.cc @@ -8,19 +8,18 @@ */ #include -#include -#include #include #include #include #include -#include #include #include #include #include #include #include +#include +#include namespace xe { namespace kernel { diff --git a/src/xenia/kernel/xboxkrnl_usbcam.cc b/src/xenia/kernel/xboxkrnl_usbcam.cc index f61fad285..a3625b437 100644 --- a/src/xenia/kernel/xboxkrnl_usbcam.cc +++ b/src/xenia/kernel/xboxkrnl_usbcam.cc @@ -8,11 +8,10 @@ */ #include -#include -#include #include -#include #include +#include +#include namespace xe { namespace kernel { diff --git a/src/xenia/kernel/xboxkrnl_video.cc b/src/xenia/kernel/xboxkrnl_video.cc index 26a818d58..3d00a9b30 100644 --- a/src/xenia/kernel/xboxkrnl_video.cc +++ b/src/xenia/kernel/xboxkrnl_video.cc @@ -8,16 +8,15 @@ */ #include -#include -#include -#include #include +#include #include #include #include +#include #include #include -#include +#include namespace xe { namespace kernel { diff --git a/src/xenia/memory.h b/src/xenia/memory.h index 3745ca856..bcdc254d7 100644 --- a/src/xenia/memory.h +++ b/src/xenia/memory.h @@ -14,7 +14,7 @@ #include -#include +#include #include typedef struct xe_ppc_state xe_ppc_state_t; diff --git a/src/xenia/sources.gypi b/src/xenia/sources.gypi index 13ef28ad4..9891468fb 100644 --- a/src/xenia/sources.gypi +++ b/src/xenia/sources.gypi @@ -2,7 +2,6 @@ { 'sources': [ 'common.h', - 'core.h', 'debug_agent.cc', 'debug_agent.h', 'emulator.cc', @@ -20,7 +19,6 @@ 'includes': [ 'apu/sources.gypi', - 'core/sources.gypi', 'cpu/sources.gypi', 'gpu/sources.gypi', 'hid/sources.gypi', diff --git a/src/xenia/ui/menu_item.cc b/src/xenia/ui/menu_item.cc index 756e01d84..89b050810 100644 --- a/src/xenia/ui/menu_item.cc +++ b/src/xenia/ui/menu_item.cc @@ -9,14 +9,16 @@ #include +namespace xe { +namespace ui { -using namespace xe; -using namespace xe::ui; +MenuItem::MenuItem(Window* window) : window_(window), parent_item_(nullptr) {} +MenuItem::~MenuItem() {} -MenuItem::MenuItem(Window* window, MenuItem* parent_item) : - window_(window), parent_item_(parent_item) { +void MenuItem::AddChild(std::unique_ptr child_item) { + children_.emplace_back(std::move(child_item)); } -MenuItem::~MenuItem() { -} +} // namespace ui +} // namespace xe diff --git a/src/xenia/ui/menu_item.h b/src/xenia/ui/menu_item.h index 48af63420..06264c7b1 100644 --- a/src/xenia/ui/menu_item.h +++ b/src/xenia/ui/menu_item.h @@ -10,32 +10,33 @@ #ifndef XENIA_UI_MENU_ITEM_H_ #define XENIA_UI_MENU_ITEM_H_ -#include +#include +#include +#include namespace xe { namespace ui { class Window; - class MenuItem { -public: - MenuItem(Window* window, MenuItem* parent_item = NULL); + public: + MenuItem(Window* window); virtual ~MenuItem(); Window* window() const { return window_; } MenuItem* parent_item() const { return parent_item_; } -private: - Window* window_; - MenuItem* parent_item_; - // children -}; + virtual void AddChild(std::unique_ptr child_item); + private: + Window* window_; + MenuItem* parent_item_; + std::vector> children_; +}; } // namespace ui } // namespace xe - #endif // XENIA_UI_MENU_ITEM_H_ diff --git a/src/xenia/ui/ui_event.h b/src/xenia/ui/ui_event.h index 95c313d19..3f4fd8dd1 100644 --- a/src/xenia/ui/ui_event.h +++ b/src/xenia/ui/ui_event.h @@ -10,7 +10,7 @@ #ifndef XENIA_UI_UI_EVENT_H_ #define XENIA_UI_UI_EVENT_H_ -#include +#include namespace xe { namespace ui { diff --git a/src/xenia/ui/win32/sources.gypi b/src/xenia/ui/win32/sources.gypi index 45f5a2845..ae78b203b 100644 --- a/src/xenia/ui/win32/sources.gypi +++ b/src/xenia/ui/win32/sources.gypi @@ -1,6 +1,8 @@ # Copyright 2014 Ben Vanik. All Rights Reserved. { 'sources': [ + 'win32_loop.cc', + 'win32_loop.h', 'win32_menu_item.cc', 'win32_menu_item.h', 'win32_window.cc', diff --git a/src/xenia/ui/win32/win32_loop.cc b/src/xenia/ui/win32/win32_loop.cc new file mode 100644 index 000000000..907165efb --- /dev/null +++ b/src/xenia/ui/win32/win32_loop.cc @@ -0,0 +1,44 @@ +/** + ****************************************************************************** + * Xenia : Xbox 360 Emulator Research Project * + ****************************************************************************** + * Copyright 2014 Ben Vanik. All rights reserved. * + * Released under the BSD license - see LICENSE in the root for more details. * + ****************************************************************************** + */ + +#include + +namespace xe { +namespace ui { +namespace win32 { + +const DWORD kWmWin32LoopQuit = WM_APP + 0x100; + +Win32Loop::Win32Loop() {} + +Win32Loop::~Win32Loop() {} + +bool Win32Loop::Run() { + MSG msg; + while (GetMessage(&msg, nullptr, 0, 0)) { + TranslateMessage(&msg); + DispatchMessage(&msg); + switch (msg.message) { + case kWmWin32LoopQuit: + if (msg.wParam == reinterpret_cast(this)) { + return true; + } + break; + } + } + return true; +} + +void Win32Loop::Quit() { + PostMessage(nullptr, kWmWin32LoopQuit, reinterpret_cast(this), 0); +} + +} // namespace win32 +} // namespace ui +} // namespace xe diff --git a/src/xenia/core/ref.h b/src/xenia/ui/win32/win32_loop.h similarity index 52% rename from src/xenia/core/ref.h rename to src/xenia/ui/win32/win32_loop.h index 2406102d0..6888c4782 100644 --- a/src/xenia/core/ref.h +++ b/src/xenia/ui/win32/win32_loop.h @@ -2,28 +2,35 @@ ****************************************************************************** * Xenia : Xbox 360 Emulator Research Project * ****************************************************************************** - * Copyright 2013 Ben Vanik. All rights reserved. * + * Copyright 2014 Ben Vanik. All rights reserved. * * Released under the BSD license - see LICENSE in the root for more details. * ****************************************************************************** */ -#ifndef XENIA_CORE_REF_H_ -#define XENIA_CORE_REF_H_ +#ifndef XENIA_UI_WIN32_WIN32_LOOP_H_ +#define XENIA_UI_WIN32_WIN32_LOOP_H_ #include +#include -typedef struct { - volatile int32_t count; -} xe_ref_t; -typedef xe_ref_t* xe_ref; +namespace xe { +namespace ui { +namespace win32 { -typedef void (*xe_ref_dealloc_t)(xe_ref); +class Win32Loop { + public: + Win32Loop(); + ~Win32Loop(); + bool Run(); + void Quit(); -void xe_ref_init(xe_ref ref); -void xe_ref_retain(xe_ref ref); -void xe_ref_release(xe_ref ref, xe_ref_dealloc_t dealloc); + private: +}; +} // namespace win32 +} // namespace ui +} // namespace xe -#endif // XENIA_CORE_REF_H_ +#endif // XENIA_UI_WIN32_WIN32_LOOP_H_ diff --git a/src/xenia/ui/win32/win32_menu_item.cc b/src/xenia/ui/win32/win32_menu_item.cc index 5d66c3237..9ce673acc 100644 --- a/src/xenia/ui/win32/win32_menu_item.cc +++ b/src/xenia/ui/win32/win32_menu_item.cc @@ -9,15 +9,14 @@ #include +namespace xe { +namespace ui { +namespace win32 { -using namespace xe; -using namespace xe::ui; -using namespace xe::ui::win32; +Win32MenuItem::Win32MenuItem(Window* window) : MenuItem(window) {} +Win32MenuItem::~Win32MenuItem() {} -Win32MenuItem::Win32MenuItem(Window* window, MenuItem* parent_item) : - MenuItem(window, parent_item) { -} - -Win32MenuItem::~Win32MenuItem() { -} +} // namespace win32 +} // namespace ui +} // namespace xe diff --git a/src/xenia/ui/win32/win32_menu_item.h b/src/xenia/ui/win32/win32_menu_item.h index 7f43109bb..adb5d261c 100644 --- a/src/xenia/ui/win32/win32_menu_item.h +++ b/src/xenia/ui/win32/win32_menu_item.h @@ -10,28 +10,23 @@ #ifndef XENIA_UI_WIN32_WIN32_MENU_ITEM_H_ #define XENIA_UI_WIN32_WIN32_MENU_ITEM_H_ -#include - +#include #include - namespace xe { namespace ui { namespace win32 { - class Win32MenuItem : public MenuItem { -public: - Win32MenuItem(Window* window, MenuItem* parent_item = NULL); - virtual ~Win32MenuItem(); + public: + Win32MenuItem(Window* window); + ~Win32MenuItem() override; -private: + private: }; - } // namespace win32 } // namespace ui } // namespace xe - #endif // XENIA_UI_WIN32_WIN32_MENU_ITEM_H_ diff --git a/src/xenia/ui/win32/win32_window.cc b/src/xenia/ui/win32/win32_window.cc index ec5806fdb..9e084b679 100644 --- a/src/xenia/ui/win32/win32_window.cc +++ b/src/xenia/ui/win32/win32_window.cc @@ -13,16 +13,12 @@ #include #include +namespace xe { +namespace ui { +namespace win32 { -using namespace xe; -using namespace xe::ui; -using namespace xe::ui::win32; - - -namespace { - -static LRESULT CALLBACK Win32WindowWndProc( - HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { +static LRESULT CALLBACK +Win32WindowWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { Win32Window* window = 0; if (message == WM_NCCREATE) { LPCREATESTRUCT create_struct = (LPCREATESTRUCT)lParam; @@ -38,18 +34,12 @@ static LRESULT CALLBACK Win32WindowWndProc( } } -} // namespace - - -Win32Window::Win32Window(xe_run_loop_ref run_loop) : - handle_(0), closing_(false), - Window(run_loop) { -} +Win32Window::Win32Window() : handle_(0), closing_(false) {} Win32Window::~Win32Window() { if (handle_) { CloseWindow(handle_); - handle_ = NULL; + handle_ = nullptr; } } @@ -63,44 +53,34 @@ int Win32Window::Initialize(const std::wstring& title, uint32_t width, HINSTANCE hInstance = GetModuleHandle(NULL); WNDCLASSEX wcex; - wcex.cbSize = sizeof(WNDCLASSEX); - wcex.style = 0; - wcex.lpfnWndProc = Win32WindowWndProc; - wcex.cbClsExtra = 0; - wcex.cbWndExtra = 0; - wcex.hInstance = hInstance; - wcex.hIcon = NULL; // LoadIcon(hInstance, (LPCTSTR)IDI_TUTORIAL1); - wcex.hIconSm = NULL; // LoadIcon(hInstance, (LPCTSTR)IDI_TUTORIAL1); - wcex.hCursor = LoadCursor(NULL, IDC_ARROW); - wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); - wcex.lpszMenuName = NULL; - wcex.lpszClassName = L"XeniaWindowClass"; + wcex.cbSize = sizeof(WNDCLASSEX); + wcex.style = CS_OWNDC; + wcex.lpfnWndProc = Win32WindowWndProc; + wcex.cbClsExtra = 0; + wcex.cbWndExtra = 0; + wcex.hInstance = hInstance; + wcex.hIcon = NULL; // LoadIcon(hInstance, (LPCTSTR)IDI_TUTORIAL1); + wcex.hIconSm = NULL; // LoadIcon(hInstance, (LPCTSTR)IDI_TUTORIAL1); + wcex.hCursor = LoadCursor(NULL, IDC_ARROW); + wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); + wcex.lpszMenuName = NULL; + wcex.lpszClassName = L"XeniaWindowClass"; if (!RegisterClassEx(&wcex)) { XELOGE("RegisterClassEx failed"); return 1; } // Setup initial size. - DWORD window_style = WS_OVERLAPPEDWINDOW; + DWORD window_style = WS_OVERLAPPEDWINDOW; DWORD window_ex_style = WS_EX_APPWINDOW; - RECT rc = { - 0, 0, - static_cast(width), static_cast(height) - }; + RECT rc = {0, 0, static_cast(width), static_cast(height)}; AdjustWindowRect(&rc, WS_OVERLAPPEDWINDOW, FALSE); // Create window. - handle_ = CreateWindowEx( - window_ex_style, - L"XeniaWindowClass", - L"Xenia", - window_style, - CW_USEDEFAULT, CW_USEDEFAULT, - rc.right - rc.left, rc.bottom - rc.top, - NULL, - NULL, - hInstance, - this); + handle_ = CreateWindowEx(window_ex_style, L"XeniaWindowClass", L"Xenia", + window_style, CW_USEDEFAULT, CW_USEDEFAULT, + rc.right - rc.left, rc.bottom - rc.top, NULL, NULL, + hInstance, this); if (!handle_) { XELOGE("CreateWindow failed"); return 1; @@ -109,18 +89,17 @@ int Win32Window::Initialize(const std::wstring& title, uint32_t width, // Disable flicks. ATOM atom = GlobalAddAtom(L"MicrosoftTabletPenServiceProperty"); const DWORD_PTR dwHwndTabletProperty = - TABLET_DISABLE_PRESSANDHOLD | // disables press and hold (right-click) gesture - TABLET_DISABLE_PENTAPFEEDBACK | // disables UI feedback on pen up (waves) - TABLET_DISABLE_PENBARRELFEEDBACK | // disables UI feedback on pen button down (circle) - TABLET_DISABLE_FLICKS | // disables pen flicks (back, forward, drag down, drag up) - TABLET_DISABLE_TOUCHSWITCH | - TABLET_DISABLE_SMOOTHSCROLLING | - TABLET_DISABLE_TOUCHUIFORCEON | - TABLET_ENABLE_MULTITOUCHDATA; - SetProp( - handle_, - L"MicrosoftTabletPenServiceProperty", - reinterpret_cast(dwHwndTabletProperty)); + TABLET_DISABLE_PRESSANDHOLD | // disables press and hold (right-click) + // gesture + TABLET_DISABLE_PENTAPFEEDBACK | // disables UI feedback on pen up (waves) + TABLET_DISABLE_PENBARRELFEEDBACK | // disables UI feedback on pen button + // down (circle) + TABLET_DISABLE_FLICKS | // disables pen flicks (back, forward, drag down, + // drag up) + TABLET_DISABLE_TOUCHSWITCH | TABLET_DISABLE_SMOOTHSCROLLING | + TABLET_DISABLE_TOUCHUIFORCEON | TABLET_ENABLE_MULTITOUCHDATA; + SetProp(handle_, L"MicrosoftTabletPenServiceProperty", + reinterpret_cast(dwHwndTabletProperty)); GlobalDeleteAtom(atom); // Enable DWM elevation. @@ -138,27 +117,27 @@ void Win32Window::EnableMMCSS() { return; } - typedef HRESULT (__stdcall *PDwmEnableMMCSS)(BOOL); + typedef HRESULT(__stdcall * PDwmEnableMMCSS)(BOOL); PDwmEnableMMCSS pDwmEnableMMCSS = - (PDwmEnableMMCSS)GetProcAddress( - hLibrary, "DwmEnableMMCSS"); + (PDwmEnableMMCSS)GetProcAddress(hLibrary, "DwmEnableMMCSS"); if (pDwmEnableMMCSS) { pDwmEnableMMCSS(TRUE); } - typedef HRESULT (__stdcall *PDwmSetPresentParameters)(HWND, DWM_PRESENT_PARAMETERS*); + typedef HRESULT(__stdcall * PDwmSetPresentParameters)( + HWND, DWM_PRESENT_PARAMETERS*); PDwmSetPresentParameters pDwmSetPresentParameters = - (PDwmSetPresentParameters)GetProcAddress( - hLibrary, "DwmSetPresentParameters"); + (PDwmSetPresentParameters)GetProcAddress(hLibrary, + "DwmSetPresentParameters"); if (pDwmSetPresentParameters) { DWM_PRESENT_PARAMETERS pp; memset(&pp, 0, sizeof(DWM_PRESENT_PARAMETERS)); - pp.cbSize = sizeof(DWM_PRESENT_PARAMETERS); - pp.fQueue = FALSE; - pp.cBuffer = 2; - pp.fUseSourceRate = FALSE; - pp.cRefreshesPerFrame = 1; - pp.eSampling = DWM_SOURCE_FRAME_SAMPLING_POINT; + pp.cbSize = sizeof(DWM_PRESENT_PARAMETERS); + pp.fQueue = FALSE; + pp.cBuffer = 2; + pp.fUseSourceRate = FALSE; + pp.cRefreshesPerFrame = 1; + pp.eSampling = DWM_SOURCE_FRAME_SAMPLING_POINT; pDwmSetPresentParameters(handle_, &pp); } @@ -187,10 +166,7 @@ bool Win32Window::set_cursor_visible(bool value) { } bool Win32Window::SetSize(uint32_t width, uint32_t height) { - RECT rc = { - 0, 0, - static_cast(width), static_cast(height) - }; + RECT rc = {0, 0, static_cast(width), static_cast(height)}; AdjustWindowRect(&rc, WS_OVERLAPPEDWINDOW, FALSE); // TODO(benvanik): center? MoveWindow(handle_, 0, 0, rc.right - rc.left, rc.bottom - rc.top, TRUE); @@ -209,7 +185,7 @@ bool Win32Window::HandleMouse(UINT message, WPARAM wParam, LPARAM lParam) { int32_t x = GET_X_LPARAM(lParam); int32_t y = GET_Y_LPARAM(lParam); if (message == WM_MOUSEWHEEL) { - POINT pt = { x, y }; + POINT pt = {x, y}; ScreenToClient(handle_, &pt); x = pt.x; y = pt.y; @@ -219,64 +195,64 @@ bool Win32Window::HandleMouse(UINT message, WPARAM wParam, LPARAM lParam) { int32_t dx = 0; int32_t dy = 0; switch (message) { - case WM_LBUTTONDOWN: - case WM_LBUTTONUP: - button = MouseEvent::MOUSE_BUTTON_LEFT; - break; - case WM_RBUTTONDOWN: - case WM_RBUTTONUP: - button = MouseEvent::MOUSE_BUTTON_RIGHT; - break; - case WM_MBUTTONDOWN: - case WM_MBUTTONUP: - button = MouseEvent::MOUSE_BUTTON_MIDDLE; - break; - case WM_XBUTTONDOWN: - case WM_XBUTTONUP: - switch (GET_XBUTTON_WPARAM(wParam)) { - case XBUTTON1: - button = MouseEvent::MOUSE_BUTTON_X1; + case WM_LBUTTONDOWN: + case WM_LBUTTONUP: + button = MouseEvent::MOUSE_BUTTON_LEFT; break; - case XBUTTON2: - button = MouseEvent::MOUSE_BUTTON_X2; + case WM_RBUTTONDOWN: + case WM_RBUTTONUP: + button = MouseEvent::MOUSE_BUTTON_RIGHT; + break; + case WM_MBUTTONDOWN: + case WM_MBUTTONUP: + button = MouseEvent::MOUSE_BUTTON_MIDDLE; + break; + case WM_XBUTTONDOWN: + case WM_XBUTTONUP: + switch (GET_XBUTTON_WPARAM(wParam)) { + case XBUTTON1: + button = MouseEvent::MOUSE_BUTTON_X1; + break; + case XBUTTON2: + button = MouseEvent::MOUSE_BUTTON_X2; + break; + default: + return false; + } + break; + case WM_MOUSEMOVE: + button = MouseEvent::MOUSE_BUTTON_NONE; + break; + case WM_MOUSEWHEEL: + button = MouseEvent::MOUSE_BUTTON_NONE; + dx = 0; // ? + dy = GET_WHEEL_DELTA_WPARAM(wParam); break; default: - return false; - } - break; - case WM_MOUSEMOVE: - button = MouseEvent::MOUSE_BUTTON_NONE; - break; - case WM_MOUSEWHEEL: - button = MouseEvent::MOUSE_BUTTON_NONE; - dx = 0; // ? - dy = GET_WHEEL_DELTA_WPARAM(wParam); - break; - default: - // Double click/etc? - return true; + // Double click/etc? + return true; } auto e = MouseEvent(this, button, x, y, dx, dy); switch (message) { - case WM_LBUTTONDOWN: - case WM_RBUTTONDOWN: - case WM_MBUTTONDOWN: - case WM_XBUTTONDOWN: - mouse_down(e); - break; - case WM_LBUTTONUP: - case WM_RBUTTONUP: - case WM_MBUTTONUP: - case WM_XBUTTONUP: - mouse_up(e); - break; - case WM_MOUSEMOVE: - mouse_move(e); - break; - case WM_MOUSEWHEEL: - mouse_wheel(e); - break; + case WM_LBUTTONDOWN: + case WM_RBUTTONDOWN: + case WM_MBUTTONDOWN: + case WM_XBUTTONDOWN: + mouse_down(e); + break; + case WM_LBUTTONUP: + case WM_RBUTTONUP: + case WM_MBUTTONUP: + case WM_XBUTTONUP: + mouse_up(e); + break; + case WM_MOUSEMOVE: + mouse_move(e); + break; + case WM_MOUSEWHEEL: + mouse_wheel(e); + break; } return true; } @@ -284,19 +260,19 @@ bool Win32Window::HandleMouse(UINT message, WPARAM wParam, LPARAM lParam) { bool Win32Window::HandleKeyboard(UINT message, WPARAM wParam, LPARAM lParam) { auto e = KeyEvent(this, (int)wParam); switch (message) { - case WM_KEYDOWN: - key_down(e); - return true; - case WM_KEYUP: - key_up(e); - return true; - default: - return false; + case WM_KEYDOWN: + key_down(e); + return true; + case WM_KEYUP: + key_up(e); + return true; + default: + return false; } } -LRESULT Win32Window::WndProc(HWND hWnd, UINT message, - WPARAM wParam, LPARAM lParam) { +LRESULT Win32Window::WndProc(HWND hWnd, UINT message, WPARAM wParam, + LPARAM lParam) { if (message >= WM_MOUSEFIRST && message <= WM_MOUSELAST) { if (HandleMouse(message, wParam, lParam)) { return 0; @@ -312,62 +288,65 @@ LRESULT Win32Window::WndProc(HWND hWnd, UINT message, } switch (message) { - case WM_NCCREATE: - handle_ = hWnd; - return DefWindowProc(hWnd, message, wParam, lParam); - case WM_ACTIVATEAPP: - if (wParam) { - // Made active. - OnShow(); - } else { - // Made inactive. - OnHide(); - } - return DefWindowProc(hWnd, message, wParam, lParam); - case WM_CLOSE: - closing_ = true; - Close(); - return DefWindowProc(hWnd, message, wParam, lParam); - case WM_DESTROY: - return 0; + case WM_NCCREATE: + handle_ = hWnd; + return DefWindowProc(hWnd, message, wParam, lParam); + case WM_ACTIVATEAPP: + if (wParam) { + // Made active. + OnShow(); + } else { + // Made inactive. + OnHide(); + } + return DefWindowProc(hWnd, message, wParam, lParam); + case WM_CLOSE: + closing_ = true; + Close(); + return DefWindowProc(hWnd, message, wParam, lParam); + case WM_DESTROY: + return 0; - case WM_PAINT: - { + case WM_PAINT: { PAINTSTRUCT ps; HDC hdc = BeginPaint(hWnd, &ps); EndPaint(hWnd, &ps); } - return 0; - case WM_ERASEBKGND: - return 0; // ignore - case WM_DISPLAYCHANGE: - return DefWindowProc(hWnd, message, wParam, lParam); + return 0; + case WM_ERASEBKGND: + return 0; // ignore + case WM_DISPLAYCHANGE: + return DefWindowProc(hWnd, message, wParam, lParam); - case WM_MOVE: - return DefWindowProc(hWnd, message, wParam, lParam); - case WM_SIZING: - BeginResizing(); - return DefWindowProc(hWnd, message, wParam, lParam); - case WM_SIZE: - { + case WM_MOVE: + return DefWindowProc(hWnd, message, wParam, lParam); + case WM_SIZING: + BeginResizing(); + return DefWindowProc(hWnd, message, wParam, lParam); + case WM_SIZE: { RECT frame; GetClientRect(handle_, &frame); OnResize(frame.right - frame.left, frame.bottom - frame.top); EndResizing(); } - return DefWindowProc(hWnd, message, wParam, lParam); + return DefWindowProc(hWnd, message, wParam, lParam); - case WM_TABLET_QUERYSYSTEMGESTURESTATUS: - return - TABLET_DISABLE_PRESSANDHOLD | // disables press and hold (right-click) gesture - TABLET_DISABLE_PENTAPFEEDBACK | // disables UI feedback on pen up (waves) - TABLET_DISABLE_PENBARRELFEEDBACK | // disables UI feedback on pen button down (circle) - TABLET_DISABLE_FLICKS | // disables pen flicks (back, forward, drag down, drag up) - TABLET_DISABLE_TOUCHSWITCH | - TABLET_DISABLE_SMOOTHSCROLLING | - TABLET_DISABLE_TOUCHUIFORCEON | - TABLET_ENABLE_MULTITOUCHDATA; - default: - return DefWindowProc(hWnd, message, wParam, lParam); + case WM_TABLET_QUERYSYSTEMGESTURESTATUS: + return TABLET_DISABLE_PRESSANDHOLD | // disables press and hold + // (right-click) gesture + TABLET_DISABLE_PENTAPFEEDBACK | // disables UI feedback on pen up + // (waves) + TABLET_DISABLE_PENBARRELFEEDBACK | // disables UI feedback on pen + // button down (circle) + TABLET_DISABLE_FLICKS | // disables pen flicks (back, forward, + // drag down, drag up) + TABLET_DISABLE_TOUCHSWITCH | TABLET_DISABLE_SMOOTHSCROLLING | + TABLET_DISABLE_TOUCHUIFORCEON | TABLET_ENABLE_MULTITOUCHDATA; + default: + return DefWindowProc(hWnd, message, wParam, lParam); } } + +} // namespace win32 +} // namespace ui +} // namespace xe diff --git a/src/xenia/ui/win32/win32_window.h b/src/xenia/ui/win32/win32_window.h index 600907574..2dc05d3a2 100644 --- a/src/xenia/ui/win32/win32_window.h +++ b/src/xenia/ui/win32/win32_window.h @@ -12,8 +12,7 @@ #include -#include - +#include #include namespace xe { @@ -22,7 +21,7 @@ namespace win32 { class Win32Window : public Window { public: - Win32Window(xe_run_loop_ref run_loop); + Win32Window(); ~Win32Window() override; int Initialize(const std::wstring& title, uint32_t width, diff --git a/src/xenia/ui/window.cc b/src/xenia/ui/window.cc index 91a43dde0..568388f44 100644 --- a/src/xenia/ui/window.cc +++ b/src/xenia/ui/window.cc @@ -9,19 +9,17 @@ #include -using namespace xe; -using namespace xe::ui; +namespace xe { +namespace ui { -Window::Window(xe_run_loop_ref run_loop) +Window::Window() : title_(L"Window"), is_visible_(true), is_cursor_visible_(true), width_(0), - height_(0) { - run_loop_ = xe_run_loop_retain(run_loop); -} + height_(0) {} -Window::~Window() { xe_run_loop_release(run_loop_); } +Window::~Window() {} int Window::Initialize(const std::wstring& title, uint32_t width, uint32_t height) { @@ -111,3 +109,6 @@ void Window::Close() { } void Window::OnClose() {} + +} // namespace ui +} // namespace xe diff --git a/src/xenia/ui/window.h b/src/xenia/ui/window.h index 551458ba1..1deafd712 100644 --- a/src/xenia/ui/window.h +++ b/src/xenia/ui/window.h @@ -12,9 +12,8 @@ #include -#include - #include +#include #include namespace xe { @@ -22,14 +21,12 @@ namespace ui { class Window { public: - Window(xe_run_loop_ref run_loop); + Window(); virtual ~Window(); virtual int Initialize(const std::wstring& title, uint32_t width, uint32_t height); - xe_run_loop_ref run_loop() const { return run_loop_; } - const std::wstring& title() const { return title_; } virtual bool set_title(const std::wstring& title); bool is_visible() const { return is_visible_; } @@ -69,7 +66,6 @@ class Window { virtual void OnClose(); private: - xe_run_loop_ref run_loop_; std::wstring title_; bool is_visible_; bool is_cursor_visible_; diff --git a/src/xenia/xbox.h b/src/xenia/xbox.h index 933756ef9..170f3e4d8 100644 --- a/src/xenia/xbox.h +++ b/src/xenia/xbox.h @@ -12,7 +12,6 @@ #include #include -#include namespace xe {