[ion/simulator] Get rid of useless Ion:: prefixes

This commit is contained in:
Romain Goyet
2020-09-17 21:41:49 -04:00
committed by Léa Saviot
parent 699cf22023
commit 6c389c9a1d
7 changed files with 37 additions and 57 deletions

View File

@@ -1,28 +1,32 @@
#include <ion.h>
uint32_t crc32Helper(const uint8_t * data, size_t length, bool wordAccess) {
namespace Ion {
static uint32_t crc32Helper(const uint8_t * data, size_t length, bool wordAccess) {
size_t uint32ByteLength = sizeof(uint32_t)/sizeof(uint8_t);
uint32_t crc = 0xFFFFFFFF;
size_t byteLength = (wordAccess ? length * uint32ByteLength : length);
size_t wordLength = byteLength / uint32ByteLength;
for (int i = 0; i < (int)wordLength; i++) {
for (int i = 0; i < wordLength; i++) {
// FIXME: Assumes little-endian byte order!
for (int j = uint32ByteLength-1; j >= 0; j--) {
// scan byte by byte to avoid alignment issue when building for emscripten platform
crc = Ion::crc32EatByte(crc, data[i*uint32ByteLength+j]);
crc = crc32EatByte(crc, data[i*uint32ByteLength+j]);
}
}
for (int i = (int) wordLength * uint32ByteLength; i < byteLength; i++) {
crc = Ion::crc32EatByte(crc, data[i]);
for (int i = wordLength * uint32ByteLength; i < byteLength; i++) {
crc = crc32EatByte(crc, data[i]);
}
return crc;
}
uint32_t Ion::crc32Word(const uint32_t * data, size_t length) {
return crc32Helper((const uint8_t *) data, length, true);
uint32_t crc32Word(const uint32_t * data, size_t length) {
return crc32Helper(reinterpret_cast<const uint8_t *>(data), length, true);
}
uint32_t Ion::crc32Byte(const uint8_t * data, size_t length) {
uint32_t crc32Byte(const uint8_t * data, size_t length) {
return crc32Helper(data, length, false);
}
}

View File

@@ -19,8 +19,8 @@ static inline Event eventFromSDLKeyboardEvent(SDL_KeyboardEvent event) {
/* If an event is detected, we want to remove the Shift modifier to mimic the
* device behaviour. If no event was detected, we restore the previous
* ShiftAlphaStatus. */
Ion::Events::ShiftAlphaStatus previousShiftAlphaStatus = Ion::Events::shiftAlphaStatus();
Ion::Events::removeShift();
ShiftAlphaStatus previousShiftAlphaStatus = shiftAlphaStatus();
removeShift();
if (event.keysym.mod & (KMOD_CTRL|KMOD_GUI)) {
switch (event.keysym.sym) {
@@ -87,7 +87,7 @@ static inline Event eventFromSDLKeyboardEvent(SDL_KeyboardEvent event) {
return Termination;
}
// No event was detected, restore the previous ShiftAlphaStatus.
Ion::Events::setShiftAlphaStatus(previousShiftAlphaStatus);
setShiftAlphaStatus(previousShiftAlphaStatus);
return None;
}
@@ -116,7 +116,7 @@ static Event eventFromSDLTextInputEvent(SDL_TextInputEvent event) {
* then we press "&", transformed by eventFromSDLTextInputEvent into the
* text "1". If we do not remove the Shift here, it would still be
* pressed afterwards. */
Ion::Events::removeShift();
Events::removeShift();
Event res = sEventForASCIICharAbove32[character-32];
if (res != None) {
return res;
@@ -133,7 +133,7 @@ Event getPlatformEvent() {
Event result = None;
while (SDL_PollEvent(&event)) { // That "while" is important: it'll do a fast-pass over all useless SDL events
if (event.type == SDL_WINDOWEVENT) {
Ion::Simulator::Window::relayout();
Simulator::Window::relayout();
break;
}
if (event.type == SDL_QUIT) {

View File

@@ -19,7 +19,7 @@ static bool sFrameBufferActive = false;
namespace Ion {
namespace Display {
static KDFrameBuffer sFrameBuffer = KDFrameBuffer(sPixels, KDSize(Ion::Display::Width, Ion::Display::Height));
static KDFrameBuffer sFrameBuffer = KDFrameBuffer(sPixels, KDSize(Width, Height));
void pushRect(KDRect r, const KDColor * pixels) {
if (sFrameBufferActive) {

View File

@@ -27,15 +27,15 @@ private:
};
void init() {
Ion::Events::logTo(logJournal());
Events::logTo(logJournal());
}
Ion::Events::Journal * replayJournal() {
Events::Journal * replayJournal() {
static Journal journal;
return &journal;
}
Ion::Events::Journal * logJournal() {
Events::Journal * logJournal() {
static Journal journal;
return &journal;
}

View File

@@ -5,32 +5,34 @@
#include <ion/keyboard.h>
#include <SDL.h>
static Ion::Keyboard::State sKeyboardState;
using namespace Ion::Keyboard;
static State sKeyboardState;
class KeySDLKeyPair {
public:
constexpr KeySDLKeyPair(Ion::Keyboard::Key key, SDL_Scancode SDLKey) :
constexpr KeySDLKeyPair(Key key, SDL_Scancode SDLKey) :
m_key(key),
m_SDLKey(SDLKey)
{}
Ion::Keyboard::Key key() const { return m_key; }
Key key() const { return m_key; }
SDL_Scancode SDLKey() const { return m_SDLKey; }
private:
Ion::Keyboard::Key m_key;
Key m_key;
SDL_Scancode m_SDLKey;
};
constexpr static KeySDLKeyPair sKeyPairs[] = {
KeySDLKeyPair(Ion::Keyboard::Key::Down, SDL_SCANCODE_DOWN),
KeySDLKeyPair(Ion::Keyboard::Key::Up, SDL_SCANCODE_UP),
KeySDLKeyPair(Ion::Keyboard::Key::Left, SDL_SCANCODE_LEFT),
KeySDLKeyPair(Ion::Keyboard::Key::Right, SDL_SCANCODE_RIGHT),
KeySDLKeyPair(Ion::Keyboard::Key::Shift, SDL_SCANCODE_LSHIFT),
KeySDLKeyPair(Ion::Keyboard::Key::Shift, SDL_SCANCODE_RSHIFT),
KeySDLKeyPair(Ion::Keyboard::Key::EXE, SDL_SCANCODE_RETURN),
KeySDLKeyPair(Ion::Keyboard::Key::Back, SDL_SCANCODE_ESCAPE),
KeySDLKeyPair(Ion::Keyboard::Key::Toolbox, SDL_SCANCODE_TAB),
KeySDLKeyPair(Ion::Keyboard::Key::Backspace, SDL_SCANCODE_BACKSPACE)
KeySDLKeyPair(Key::Down, SDL_SCANCODE_DOWN),
KeySDLKeyPair(Key::Up, SDL_SCANCODE_UP),
KeySDLKeyPair(Key::Left, SDL_SCANCODE_LEFT),
KeySDLKeyPair(Key::Right, SDL_SCANCODE_RIGHT),
KeySDLKeyPair(Key::Shift, SDL_SCANCODE_LSHIFT),
KeySDLKeyPair(Key::Shift, SDL_SCANCODE_RSHIFT),
KeySDLKeyPair(Key::EXE, SDL_SCANCODE_RETURN),
KeySDLKeyPair(Key::Back, SDL_SCANCODE_ESCAPE),
KeySDLKeyPair(Key::Toolbox, SDL_SCANCODE_TAB),
KeySDLKeyPair(Key::Backspace, SDL_SCANCODE_BACKSPACE)
};
constexpr int sNumberOfKeyPairs = sizeof(sKeyPairs)/sizeof(KeySDLKeyPair);

View File

@@ -1,13 +0,0 @@
#include "../shared/platform.h"
namespace Ion {
namespace Simulator {
namespace Platform {
SDL_Keymod actionModifier() {
return static_cast<SDL_Keymod>(KMOD_CTRL);
}
}
}
}

View File

@@ -1,13 +0,0 @@
#include "../shared/platform.h"
namespace Ion {
namespace Simulator {
namespace Platform {
SDL_Keymod actionModifier() {
return KMOD_GUI;
}
}
}
}