Clean up int types

Change-Id: Ib6819b9d7f00208f47533d7ab3d2e02ca3730981
main
Ken Wakasa 2012-12-03 19:43:15 +09:00
parent f9898d05f7
commit 1d516fb1b0
4 changed files with 29 additions and 32 deletions

View File

@ -21,23 +21,23 @@ namespace latinime {
// TODO: Have proximity character informations in each language's binary dictionary.
const char *AdditionalProximityChars::LOCALE_EN_US = "en";
const int32_t AdditionalProximityChars::EN_US_ADDITIONAL_A[EN_US_ADDITIONAL_A_SIZE] = {
const int AdditionalProximityChars::EN_US_ADDITIONAL_A[EN_US_ADDITIONAL_A_SIZE] = {
'e', 'i', 'o', 'u'
};
const int32_t AdditionalProximityChars::EN_US_ADDITIONAL_E[EN_US_ADDITIONAL_E_SIZE] = {
const int AdditionalProximityChars::EN_US_ADDITIONAL_E[EN_US_ADDITIONAL_E_SIZE] = {
'a', 'i', 'o', 'u'
};
const int32_t AdditionalProximityChars::EN_US_ADDITIONAL_I[EN_US_ADDITIONAL_I_SIZE] = {
const int AdditionalProximityChars::EN_US_ADDITIONAL_I[EN_US_ADDITIONAL_I_SIZE] = {
'a', 'e', 'o', 'u'
};
const int32_t AdditionalProximityChars::EN_US_ADDITIONAL_O[EN_US_ADDITIONAL_O_SIZE] = {
const int AdditionalProximityChars::EN_US_ADDITIONAL_O[EN_US_ADDITIONAL_O_SIZE] = {
'a', 'e', 'i', 'u'
};
const int32_t AdditionalProximityChars::EN_US_ADDITIONAL_U[EN_US_ADDITIONAL_U_SIZE] = {
const int AdditionalProximityChars::EN_US_ADDITIONAL_U[EN_US_ADDITIONAL_U_SIZE] = {
'a', 'e', 'i', 'o'
};
} // namespace latinime

View File

@ -18,7 +18,6 @@
#define LATINIME_ADDITIONAL_PROXIMITY_CHARS_H
#include <cstring>
#include <stdint.h>
#include "defines.h"
@ -29,15 +28,15 @@ class AdditionalProximityChars {
DISALLOW_IMPLICIT_CONSTRUCTORS(AdditionalProximityChars);
static const char *LOCALE_EN_US;
static const int EN_US_ADDITIONAL_A_SIZE = 4;
static const int32_t EN_US_ADDITIONAL_A[];
static const int EN_US_ADDITIONAL_A[];
static const int EN_US_ADDITIONAL_E_SIZE = 4;
static const int32_t EN_US_ADDITIONAL_E[];
static const int EN_US_ADDITIONAL_E[];
static const int EN_US_ADDITIONAL_I_SIZE = 4;
static const int32_t EN_US_ADDITIONAL_I[];
static const int EN_US_ADDITIONAL_I[];
static const int EN_US_ADDITIONAL_O_SIZE = 4;
static const int32_t EN_US_ADDITIONAL_O[];
static const int EN_US_ADDITIONAL_O[];
static const int EN_US_ADDITIONAL_U_SIZE = 4;
static const int32_t EN_US_ADDITIONAL_U[];
static const int EN_US_ADDITIONAL_U[];
AK_FORCE_INLINE static bool isEnLocale(const char *localeStr) {
const size_t LOCALE_EN_US_SIZE = strlen(LOCALE_EN_US);
@ -46,7 +45,7 @@ class AdditionalProximityChars {
}
public:
static int getAdditionalCharsSize(const char *localeStr, const int32_t c) {
static int getAdditionalCharsSize(const char *localeStr, const int c) {
if (!isEnLocale(localeStr)) {
return 0;
}
@ -66,7 +65,7 @@ class AdditionalProximityChars {
}
}
static const int32_t *getAdditionalChars(const char *localeStr, const int32_t c) {
static const int *getAdditionalChars(const char *localeStr, const int c) {
if (!isEnLocale(localeStr)) {
return 0;
}

View File

@ -66,7 +66,7 @@ ProximityInfo::ProximityInfo(JNIEnv *env, const jstring localeJStr, const int ma
HAS_TOUCH_POSITION_CORRECTION_DATA(keyCount > 0 && keyXCoordinates && keyYCoordinates
&& keyWidths && keyHeights && keyCharCodes && sweetSpotCenterXs
&& sweetSpotCenterYs && sweetSpotRadii),
mProximityCharsArray(new int32_t[GRID_WIDTH * GRID_HEIGHT * MAX_PROXIMITY_CHARS_SIZE
mProximityCharsArray(new int[GRID_WIDTH * GRID_HEIGHT * MAX_PROXIMITY_CHARS_SIZE
/* proximityGridLength */]),
mCodeToKeyMap() {
const int proximityGridLength = GRID_WIDTH * GRID_HEIGHT * MAX_PROXIMITY_CHARS_SIZE;
@ -115,7 +115,7 @@ bool ProximityInfo::hasSpaceProximity(const int x, const int y) const {
if (DEBUG_PROXIMITY_INFO) {
AKLOGI("hasSpaceProximity: index %d, %d, %d", startIndex, x, y);
}
int32_t *proximityCharsArray = mProximityCharsArray;
int *proximityCharsArray = mProximityCharsArray;
for (int i = 0; i < MAX_PROXIMITY_CHARS_SIZE; ++i) {
if (DEBUG_PROXIMITY_INFO) {
AKLOGI("Index: %d", mProximityCharsArray[startIndex + i]);
@ -163,14 +163,14 @@ int ProximityInfo::squaredDistanceToEdge(const int keyId, const int x, const int
}
void ProximityInfo::calculateNearbyKeyCodes(
const int x, const int y, const int32_t primaryKey, int *inputCodes) const {
int32_t *proximityCharsArray = mProximityCharsArray;
const int x, const int y, const int primaryKey, int *inputCodes) const {
int *proximityCharsArray = mProximityCharsArray;
int insertPos = 0;
inputCodes[insertPos++] = primaryKey;
const int startIndex = getStartIndexFromCoordinates(x, y);
if (startIndex >= 0) {
for (int i = 0; i < MAX_PROXIMITY_CHARS_SIZE; ++i) {
const int32_t c = proximityCharsArray[startIndex + i];
const int c = proximityCharsArray[startIndex + i];
if (c < KEYCODE_SPACE || c == primaryKey) {
continue;
}
@ -198,13 +198,13 @@ void ProximityInfo::calculateNearbyKeyCodes(
return;
}
const int32_t *additionalProximityChars =
const int *additionalProximityChars =
AdditionalProximityChars::getAdditionalChars(mLocaleStr, primaryKey);
for (int j = 0; j < additionalProximitySize; ++j) {
const int32_t ac = additionalProximityChars[j];
const int ac = additionalProximityChars[j];
int k = 0;
for (; k < insertPos; ++k) {
if (static_cast<int>(ac) == inputCodes[k]) {
if (ac == inputCodes[k]) {
break;
}
}
@ -235,7 +235,7 @@ int ProximityInfo::getKeyIndexOf(const int c) const {
if (c == NOT_A_CODE_POINT) {
return NOT_AN_INDEX;
}
const int lowerCode = static_cast<int>(toLowerCase(c));
const int lowerCode = toLowerCase(c);
hash_map_compat<int, int>::const_iterator mapPos = mCodeToKeyMap.find(lowerCode);
if (mapPos != mCodeToKeyMap.end()) {
return mapPos->second;
@ -254,7 +254,7 @@ void ProximityInfo::initializeG() {
// TODO: Optimize
for (int i = 0; i < KEY_COUNT; ++i) {
const int code = mKeyCodePoints[i];
const int lowerCode = static_cast<int>(toLowerCase(code));
const int lowerCode = toLowerCase(code);
mCenterXsG[i] = mKeyXCoordinates[i] + mKeyWidths[i] / 2;
mCenterYsG[i] = mKeyYCoordinates[i] + mKeyHeights[i] / 2;
mCodeToKeyMap[lowerCode] = i;

View File

@ -17,8 +17,6 @@
#ifndef LATINIME_PROXIMITY_INFO_H
#define LATINIME_PROXIMITY_INFO_H
#include <stdint.h>
#include "defines.h"
#include "hash_map_compat.h"
#include "jni.h"
@ -59,7 +57,7 @@ class ProximityInfo {
return mSweetSpotCenterYs[keyIndex];
}
void calculateNearbyKeyCodes(
const int x, const int y, const int32_t primaryKey, int *inputCodes) const;
const int x, const int y, const int primaryKey, int *inputCodes) const;
bool hasTouchPositionCorrectionData() const {
return HAS_TOUCH_POSITION_CORRECTION_DATA;
@ -141,12 +139,12 @@ class ProximityInfo {
const int KEYBOARD_HEIGHT;
const bool HAS_TOUCH_POSITION_CORRECTION_DATA;
char mLocaleStr[MAX_LOCALE_STRING_LENGTH];
int32_t *mProximityCharsArray;
int32_t mKeyXCoordinates[MAX_KEY_COUNT_IN_A_KEYBOARD];
int32_t mKeyYCoordinates[MAX_KEY_COUNT_IN_A_KEYBOARD];
int32_t mKeyWidths[MAX_KEY_COUNT_IN_A_KEYBOARD];
int32_t mKeyHeights[MAX_KEY_COUNT_IN_A_KEYBOARD];
int32_t mKeyCodePoints[MAX_KEY_COUNT_IN_A_KEYBOARD];
int *mProximityCharsArray;
int mKeyXCoordinates[MAX_KEY_COUNT_IN_A_KEYBOARD];
int mKeyYCoordinates[MAX_KEY_COUNT_IN_A_KEYBOARD];
int mKeyWidths[MAX_KEY_COUNT_IN_A_KEYBOARD];
int mKeyHeights[MAX_KEY_COUNT_IN_A_KEYBOARD];
int mKeyCodePoints[MAX_KEY_COUNT_IN_A_KEYBOARD];
float mSweetSpotCenterXs[MAX_KEY_COUNT_IN_A_KEYBOARD];
float mSweetSpotCenterYs[MAX_KEY_COUNT_IN_A_KEYBOARD];
float mSweetSpotRadii[MAX_KEY_COUNT_IN_A_KEYBOARD];