Restore horrible reinterpret_casts in OSXUchrKeyResource

This commit is contained in:
Andrew Nelless 2016-09-13 11:26:34 +01:00
parent 602fd3f649
commit 26c11ec3c9
1 changed files with 12 additions and 12 deletions

View File

@ -56,19 +56,19 @@ OSXUchrKeyResource::OSXUchrKeyResource(const void* resource,
} }
// get tables for keyboard type // get tables for keyboard type
const UInt8* base = static_cast<const UInt8*>(m_resource); const UInt8* const base = reinterpret_cast<const UInt8*>(m_resource);
m_m = static_cast<const UCKeyModifiersToTableNum*>(base + m_m = reinterpret_cast<const UCKeyModifiersToTableNum*>(base +
th->keyModifiersToTableNumOffset); th->keyModifiersToTableNumOffset);
m_cti = static_cast<const UCKeyToCharTableIndex*>(base + m_cti = reinterpret_cast<const UCKeyToCharTableIndex*>(base +
th->keyToCharTableIndexOffset); th->keyToCharTableIndexOffset);
m_sdi = static_cast<const UCKeySequenceDataIndex*>(base + m_sdi = reinterpret_cast<const UCKeySequenceDataIndex*>(base +
th->keySequenceDataIndexOffset); th->keySequenceDataIndexOffset);
if (th->keyStateRecordsIndexOffset != 0) { if (th->keyStateRecordsIndexOffset != 0) {
m_sri = static_cast<const UCKeyStateRecordsIndex*>(base + m_sri = reinterpret_cast<const UCKeyStateRecordsIndex*>(base +
th->keyStateRecordsIndexOffset); th->keyStateRecordsIndexOffset);
} }
if (th->keyStateTerminatorsOffset != 0) { if (th->keyStateTerminatorsOffset != 0) {
m_st = static_cast<const UCKeyStateTerminators*>(base + m_st = reinterpret_cast<const UCKeyStateTerminators*>(base +
th->keyStateTerminatorsOffset); th->keyStateTerminatorsOffset);
} }
@ -81,7 +81,7 @@ OSXUchrKeyResource::OSXUchrKeyResource(const void* resource,
KeyID id = getKey(table, button); KeyID id = getKey(table, button);
if (id == 0x20) { if (id == 0x20) {
UCKeyOutput c = UCKeyOutput c =
static_cast<const UCKeyOutput*>(base + reinterpret_cast<const UCKeyOutput*>(base +
m_cti->keyToCharTableOffsets[table])[button]; m_cti->keyToCharTableOffsets[table])[button];
if ((c & kUCKeyOutputTestForIndexMask) == if ((c & kUCKeyOutputTestForIndexMask) ==
kUCKeyOutputStateIndexMask) { kUCKeyOutputStateIndexMask) {
@ -134,8 +134,8 @@ OSXUchrKeyResource::getKey(UInt32 table, UInt32 button) const
assert(table < getNumTables()); assert(table < getNumTables());
assert(button < getNumButtons()); assert(button < getNumButtons());
const UInt8* base = static_cast<const UInt8*>(m_resource); const UInt8* const base = reinterpret_cast<const UInt8*>(m_resource);
const UCKeyOutput* cPtr = static_cast<const UCKeyOutput*>(base + const UCKeyOutput* cPtr = reinterpret_cast<const UCKeyOutput*>(base +
m_cti->keyToCharTableOffsets[table]); m_cti->keyToCharTableOffsets[table]);
const UCKeyOutput c = cPtr[button]; const UCKeyOutput c = cPtr[button];
@ -211,12 +211,12 @@ bool
OSXUchrKeyResource::getKeyRecord( OSXUchrKeyResource::getKeyRecord(
KeySequence& keys, UInt16 index, UInt16& state) const KeySequence& keys, UInt16 index, UInt16& state) const
{ {
const UInt8* base = static_cast<const UInt8*>(m_resource); const UInt8* const base = reinterpret_cast<const UInt8*>(m_resource);
const UCKeyStateRecord* sr = const UCKeyStateRecord* sr =
static_cast<const UCKeyStateRecord*>(base + reinterpret_cast<const UCKeyStateRecord*>(base +
m_sri->keyStateRecordOffsets[index]); m_sri->keyStateRecordOffsets[index]);
const UCKeyStateEntryTerminal* kset = const UCKeyStateEntryTerminal* kset =
static_cast<const UCKeyStateEntryTerminal*>(sr->stateEntryData); reinterpret_cast<const UCKeyStateEntryTerminal*>(sr->stateEntryData);
UInt16 nextState = 0; UInt16 nextState = 0;
bool found = false; bool found = false;