diff --git a/developer/src/kmcmplib/include/kmcompx.h b/developer/src/kmcmplib/include/kmcompx.h index 5dfd2108c9..e7257661d8 100644 --- a/developer/src/kmcmplib/include/kmcompx.h +++ b/developer/src/kmcmplib/include/kmcompx.h @@ -5,3 +5,17 @@ typedef wchar_t KMX_WCHART; typedef KMX_DWORD * PKMX_DWORD; typedef char * PKMX_STR; typedef KMX_WCHAR* PKMX_WCHAR ; + +// TODO: these defines are copied out of unicode.h, because unicode.h still +// has windows-specific types. These should be remerged at a future date + +#define Uni_IsSurrogate1(ch) ((ch) >= 0xD800 && (ch) <= 0xDBFF) +#define Uni_IsSurrogate2(ch) ((ch) >= 0xDC00 && (ch) <= 0xDFFF) +#define Uni_IsSMP(ch) ((ch) >= 0x10000) + +#define Uni_SurrogateToUTF32(ch, cl) (((ch) - 0xD800) * 0x400 + ((cl) - 0xDC00) + 0x10000) + +#define Uni_UTF32ToSurrogate1(ch) (((ch) - 0x10000) / 0x400 + 0xD800) +#define Uni_UTF32ToSurrogate2(ch) (((ch) - 0x10000) % 0x400 + 0xDC00) + +#define Uni_UTF16ToUTF32(p) (Uni_IsSurrogate1(*(p)) && Uni_IsSurrogate2(*((p)+1)) ? Uni_SurrogateToUTF32(*(p), *((p)+1)) : *(p)) diff --git a/developer/src/kmcmplib/src/CharToKeyConversion.cpp b/developer/src/kmcmplib/src/CharToKeyConversion.cpp index dd96a67079..0c2b652d09 100644 --- a/developer/src/kmcmplib/src/CharToKeyConversion.cpp +++ b/developer/src/kmcmplib/src/CharToKeyConversion.cpp @@ -2,6 +2,26 @@ #include "pch.h" #include "CharToKeyConversion.h" +/* Following VKeys come from Windows */ + +#define VK_COLON 0xBA +#define VK_EQUAL 0xBB +#define VK_COMMA 0xBC +#define VK_HYPHEN 0xBD +#define VK_PERIOD 0xBE +#define VK_SLASH 0xBF +#define VK_ACCENT 0xC0 +#define VK_LBRKT 0xDB +#define VK_BKSLASH 0xDC +#define VK_RBRKT 0xDD +#define VK_QUOTE 0xDE +#define VK_xDF 0xDF + +#define VK_NUMPAD0 0x60 +#define VK_NUMPAD9 0x69 +#define VK_SPACE 0x20 + + /* Following code lifted from syskbd.cpp and tweaked for compiler use. Todo: consolidate */ KMX_WCHAR kmcmp::VKToChar(KMX_WORD keyCode, KMX_UINT shiftFlags) diff --git a/developer/src/kmcmplib/src/CharToKeyConversion.h b/developer/src/kmcmplib/src/CharToKeyConversion.h index fafe4fad1c..dd71ccbc0b 100644 --- a/developer/src/kmcmplib/src/CharToKeyConversion.h +++ b/developer/src/kmcmplib/src/CharToKeyConversion.h @@ -1,18 +1,5 @@ #pragma once -#define VK_COLON 0xBA -#define VK_EQUAL 0xBB -#define VK_COMMA 0xBC -#define VK_HYPHEN 0xBD -#define VK_PERIOD 0xBE -#define VK_SLASH 0xBF -#define VK_ACCENT 0xC0 -#define VK_LBRKT 0xDB -#define VK_BKSLASH 0xDC -#define VK_RBRKT 0xDD -#define VK_QUOTE 0xDE -#define VK_xDF 0xDF - namespace kmcmp { KMX_BOOL MapUSCharToVK(KMX_UINT ch, KMX_UINT *puKey, KMX_UINT *puShiftFlags); KMX_WCHAR VKToChar(KMX_WORD keyCode, KMX_UINT shiftFlags); diff --git a/developer/src/kmcmplib/src/CheckFilenameConsistency.cpp b/developer/src/kmcmplib/src/CheckFilenameConsistency.cpp index 144d3b250d..c895465e3d 100644 --- a/developer/src/kmcmplib/src/CheckFilenameConsistency.cpp +++ b/developer/src/kmcmplib/src/CheckFilenameConsistency.cpp @@ -13,7 +13,7 @@ namespace fs = std::experimental::filesystem; using std::experimental::filesystem::directory_iterator; namespace kmcmp { - extern KMX_CHAR CompileDir[MAX_PATH]; + extern KMX_CHAR CompileDir[260]; // TODO: this should not be a fixed buffer } bool IsRelativePath(KMX_CHAR const * p) { // Relative path (returns TRUE): @@ -122,7 +122,7 @@ KMX_DWORD CheckFilenameConsistencyForCalls(PFILE_KEYBOARD fk) { // But let's check what we have anyway PFILE_STORE sp; - DWORD i, msg; + KMX_DWORD i, msg; for (i = 0, sp = fk->dpStoreArray; i < fk->cxStoreArray; i++, sp++) { if (!sp->fIsCall) continue; diff --git a/developer/src/kmcmplib/src/Compiler.cpp b/developer/src/kmcmplib/src/Compiler.cpp index b936d83298..ad32a790aa 100644 --- a/developer/src/kmcmplib/src/Compiler.cpp +++ b/developer/src/kmcmplib/src/Compiler.cpp @@ -78,13 +78,15 @@ #include "virtualcharkeys.h" +// TODO: These three should be under common/cpp/include -- not windows specific +#include "../../../../common/windows/cpp/include/keymanversion.h" #include "../../../../common/windows/cpp/include/crc32.h" #include "../../../../common/windows/cpp/include/ConvertUTF.h" + #include "debugstore.h" #include "namedcodeconstants.h" -#include "../../../../common/windows/cpp/include/unicode.h" -#include "../../../../common/windows/cpp/include/keymanversion.h" -#include "../../../../developer/src/kmcmplib/src/xstring.h" + +#include "xstring.h" #include "edition.h" @@ -98,14 +100,20 @@ #include "CheckForDuplicates.h" #include "kmx_u16.h" #include + +/* These macros are adapted from winnt.h and legacy use only */ +#define MAKELANGID(p, s) ((((uint16_t)(s)) << 10) | (uint16_t)(p)) +#define PRIMARYLANGID(lgid) ((uint16_t)(lgid) & 0x3ff) +#define SUBLANGID(lgid) ((uint16_t)(lgid) >> 10) + + using namespace kmcmp; char ErrExtraLIB[256]; KMX_WCHAR ErrExtraW[256]; - BOOL AWarnDeprecatedCode_GLOBAL_LIB; + KMX_BOOL AWarnDeprecatedCode_GLOBAL_LIB; namespace kmcmp{ - HINSTANCE g_hInstance; KMX_BOOL FShouldAddCompilerVersion = TRUE; KMX_BOOL FSaveDebug, FCompilerWarningsAsErrors; // I4865 // I4866 int ErrChr; @@ -113,18 +121,12 @@ namespace kmcmp{ KMX_BOOL FMnemonicLayout = FALSE; KMX_BOOL FOldCharPosMatching = FALSE; int CompileTarget; - KMX_CHAR CompileDir[MAX_PATH]; + KMX_CHAR CompileDir[260]; // TODO: this should not be a fixed buffer int BeginLine[4]; - KMX_BOOL WINAPI DllMain(HINSTANCE hinst, KMX_DWORD fdwReason, LPVOID lpvReserved) - { - if (fdwReason == DLL_PROCESS_ATTACH) kmcmp::g_hInstance = hinst; - return TRUE; - } - KMX_BOOL IsValidCallStore(PFILE_STORE fs); void RecordDeadkeyNames(PFILE_KEYBOARD fk); - DWORD AddCompilerVersionStore(PFILE_KEYBOARD fk); + KMX_DWORD AddCompilerVersionStore(PFILE_KEYBOARD fk); KMX_BOOL CheckStoreUsage(PFILE_KEYBOARD fk, int storeIndex, KMX_BOOL fIsStore, KMX_BOOL fIsOption, KMX_BOOL fIsCall); int UTF32ToUTF16(int n, int *n1, int *n2); int CheckUTF16(int n); @@ -277,9 +279,8 @@ PKMX_STR wstrtostr(PKMX_WCHAR in) return result; } -KMX_BOOL kmcmp::AddCompileWarning(LPSTR buf) +KMX_BOOL kmcmp::AddCompileWarning(PKMX_CHAR buf) { - SetLastError(0); (*msgproc)(kmcmp::currentLine + 1, CWARN_Info, buf, msgprocContext); return FALSE; } @@ -289,8 +290,6 @@ KMX_BOOL AddCompileError(KMX_DWORD msg) KMX_CHAR szText[SZMAX_ERRORTEXT + 1 + 280]; KMX_CHAR* szTextp = NULL; - SetLastError(0); - if (msg & CERR_FATAL) { szTextp = GetCompilerErrorString(msg); @@ -355,8 +354,8 @@ extern "C" uint32_t kmcmp_CompileKeyboardFile(char* pszInfile, if (p = strrchr_slash(pszInfile)) { - strncpy_s(kmcmp::CompileDir, _countof(kmcmp::CompileDir), pszInfile, (INT_PTR)(p - pszInfile + 1)); // I3481 - kmcmp::CompileDir[(INT_PTR)(p - pszInfile + 1)] = 0; + strncpy_s(kmcmp::CompileDir, _countof(kmcmp::CompileDir), pszInfile, (int)(p - pszInfile + 1)); // I3481 + kmcmp::CompileDir[(int)(p - pszInfile + 1)] = 0; } else kmcmp::CompileDir[0] = 0; @@ -448,8 +447,8 @@ extern "C" uint32_t kmcmp_CompileKeyboardFileToBuffer(char* pszInfile, void* pfk if (p = strrchr_slash(pszInfile)) { - strncpy_s(kmcmp::CompileDir, _countof(kmcmp::CompileDir), pszInfile, (INT_PTR)(p - pszInfile + 1)); // I3481 - kmcmp::CompileDir[(INT_PTR)(p - pszInfile + 1)] = 0; + strncpy_s(kmcmp::CompileDir, _countof(kmcmp::CompileDir), pszInfile, (int)(p - pszInfile + 1)); // I3481 + kmcmp::CompileDir[(int)(p - pszInfile + 1)] = 0; } else kmcmp::CompileDir[0] = 0; @@ -492,22 +491,6 @@ extern "C" uint32_t kmcmp_CompileKeyboardFileToBuffer(char* pszInfile, void* pfk return err; } -void GetVersionInfo(KMX_DWORD *VersionMajor, KMX_DWORD *VersionMinor) -{ - - //TODO: sort out how to find common includes in non-Windows platforms: - #ifdef _WINDOWS_ - HRSRC hres = FindResource(0, MAKEINTRESOURCE(1), RT_VERSION); - if (hres) - { - HGLOBAL hmem = LoadResource(0, hres); - PKMX_STR buf = (PKMX_STR)LockResource(hmem); - *VersionMajor = *((PKMX_DWORD)&buf[0x30]); - *VersionMinor = *((PKMX_DWORD)&buf[0x34]); - } - #endif -} - KMX_BOOL CompileKeyboardHandle(FILE* fp_in, PFILE_KEYBOARD fk) { PKMX_WCHAR str, p; @@ -556,10 +539,7 @@ KMX_BOOL CompileKeyboardHandle(FILE* fp_in, PFILE_KEYBOARD fk) /* Add a store for the Keyman 6.0 copyright information string */ if(kmcmp::FShouldAddCompilerVersion) { - KMX_DWORD vmajor, vminor; - GetVersionInfo(&vmajor, &vminor); - u16sprintf(str,LINESIZE, L"Created with Keyman Developer version %d.%d.%d.%d", HIWORD(vmajor), LOWORD(vmajor), HIWORD(vminor), LOWORD(vminor)); - + u16sprintf(str,LINESIZE, L"Created with Keyman Developer version %d.%d.%d.%d", KEYMAN_VersionMajor, KEYMAN_VersionMinor, KEYMAN_VersionPatch, 0); AddStore(fk, TSS_KEYMANCOPYRIGHT, str); } @@ -667,7 +647,7 @@ KMX_DWORD ProcessBeginLine(PFILE_KEYBOARD fk, PKMX_WCHAR p) kmcmp::BeginLine[BeginMode] = kmcmp::currentLine; - if ((msg = GetRHS(fk, p, tstr, 80, (int)(INT_PTR)(p - pp), FALSE)) != CERR_None) return msg; + if ((msg = GetRHS(fk, p, tstr, 80, (int)(p - pp), FALSE)) != CERR_None) return msg; if (tstr[0] != UC_SENTINEL || tstr[1] != CODE_USE) { return CERR_InvalidBegin; @@ -863,7 +843,7 @@ KMX_DWORD ParseLine(PFILE_KEYBOARD fk, PKMX_WCHAR str) if (fk->currentGroup == 0xFFFFFFFF) return CERR_CodeInvalidInThisSection; { PKMX_WCHAR buf = new KMX_WCHAR[GLOBAL_BUFSIZE]; - if ((msg = GetRHS(fk, p, buf, GLOBAL_BUFSIZE - 1, (int)(INT_PTR)(p - pp), IsUnicode)) != CERR_None) + if ((msg = GetRHS(fk, p, buf, GLOBAL_BUFSIZE - 1, (int)(p - pp), IsUnicode)) != CERR_None) { delete buf; return msg; @@ -897,7 +877,7 @@ KMX_DWORD ParseLine(PFILE_KEYBOARD fk, PKMX_WCHAR str) if (fk->currentGroup == 0xFFFFFFFF) return CERR_CodeInvalidInThisSection; { PKMX_WCHAR buf = new KMX_WCHAR[GLOBAL_BUFSIZE]; - if ((msg = GetRHS(fk, p, buf, GLOBAL_BUFSIZE, (int)(INT_PTR)(p - pp), IsUnicode)) != CERR_None) + if ((msg = GetRHS(fk, p, buf, GLOBAL_BUFSIZE, (int)(p - pp), IsUnicode)) != CERR_None) { delete[] buf; return msg; @@ -1074,7 +1054,7 @@ KMX_DWORD ProcessStoreLine(PFILE_KEYBOARD fk, PKMX_WCHAR p) { PKMX_WCHAR temp = new KMX_WCHAR[GLOBAL_BUFSIZE]; - if ((msg = GetXString(fk, p, u"c\n", temp, GLOBAL_BUFSIZE - 1, (int)(INT_PTR)(p - pp), &p, FALSE, TRUE)) != CERR_None) + if ((msg = GetXString(fk, p, u"c\n", temp, GLOBAL_BUFSIZE - 1, (int)(p - pp), &p, FALSE, TRUE)) != CERR_None) { delete[] temp; return msg; @@ -1498,9 +1478,9 @@ KMX_BOOL IsValidKeyboardVersion(KMX_WCHAR *dpString) { // I4140 } -DWORD kmcmp::AddCompilerVersionStore(PFILE_KEYBOARD fk) +KMX_DWORD kmcmp::AddCompilerVersionStore(PFILE_KEYBOARD fk) { - DWORD msg; + KMX_DWORD msg; if(!kmcmp::FShouldAddCompilerVersion) { return CERR_None; @@ -1701,19 +1681,19 @@ KMX_DWORD ProcessKeyLine(PFILE_KEYBOARD fk, PKMX_WCHAR str, KMX_BOOL IsUnicode) pp = str; if (gp->fUsingKeys) { - if ((msg = GetXString(fk, str, u"+", pklIn, GLOBAL_BUFSIZE - 1, (int)(INT_PTR)(str - pp), &p, TRUE, IsUnicode)) != CERR_None) return msg; + if ((msg = GetXString(fk, str, u"+", pklIn, GLOBAL_BUFSIZE - 1, (int)(str - pp), &p, TRUE, IsUnicode)) != CERR_None) return msg; str = p + 1; - if ((msg = GetXString(fk, str, u">", pklKey, GLOBAL_BUFSIZE - 1, (int)(INT_PTR)(str - pp), &p, TRUE, IsUnicode)) != CERR_None) return msg; + if ((msg = GetXString(fk, str, u">", pklKey, GLOBAL_BUFSIZE - 1, (int)(str - pp), &p, TRUE, IsUnicode)) != CERR_None) return msg; if (pklKey[0] == 0) return CERR_ZeroLengthString; if (xstrlen(pklKey) > 1) AddWarning(CWARN_KeyBadLength); } else { - if ((msg = GetXString(fk, str, u">", pklIn, GLOBAL_BUFSIZE - 1, (int)(INT_PTR)(str - pp), &p, TRUE, IsUnicode)) != CERR_None) return msg; + if ((msg = GetXString(fk, str, u">", pklIn, GLOBAL_BUFSIZE - 1, (int)(str - pp), &p, TRUE, IsUnicode)) != CERR_None) return msg; if (pklIn[0] == 0) return CERR_ZeroLengthString; } str = p + 1; - if ((msg = GetXString(fk, str, u"c\n", pklOut, GLOBAL_BUFSIZE - 1, (int)(INT_PTR)(str - pp), &p, TRUE, IsUnicode)) != CERR_None) return msg; + if ((msg = GetXString(fk, str, u"c\n", pklOut, GLOBAL_BUFSIZE - 1, (int)(str - pp), &p, TRUE, IsUnicode)) != CERR_None) return msg; if (pklOut[0] == 0) return CERR_ZeroLengthString; @@ -1824,7 +1804,7 @@ KMX_DWORD ExpandKp_ReplaceIndex(PFILE_KEYBOARD fk, PFILE_KEY k, KMX_DWORD keyInd for (i = 0, pStore = s->dpString; i < nAnyIndex; i++, pStore = incxstr(pStore)); PKMX_WCHAR qStore = incxstr(pStore); - int w = (int)(INT_PTR)(qStore - pStore); + int w = (int)(qStore - pStore); if (w > 4) { *pIndex = UC_SENTINEL; @@ -1869,7 +1849,7 @@ KMX_DWORD ExpandKp(PFILE_KEYBOARD fk, PFILE_KEY kpp, KMX_DWORD storeIndex) if (!k) return CERR_CannotAllocateMemory; memcpy(k, gp->dpKeyArray, gp->cxKeyArray * sizeof(FILE_KEY)); - kpp = &k[(INT_PTR)(kpp - gp->dpKeyArray)]; + kpp = &k[(int)(kpp - gp->dpKeyArray)]; delete gp->dpKeyArray; gp->dpKeyArray = k; @@ -2066,7 +2046,7 @@ KMX_DWORD GetXString(PFILE_KEYBOARD fk, PKMX_WCHAR str, KMX_WCHAR const * token, while (iswspace(*p) && !u16chr(token, *p)) p++; if (!*p) break; - ErrChr = (int)(INT_PTR)(p - str) + offset + 1; + ErrChr = (int)(p - str) + offset + 1; /* char *tokenTypes[] = { @@ -2143,20 +2123,20 @@ KMX_DWORD GetXString(PFILE_KEYBOARD fk, PKMX_WCHAR str, KMX_WCHAR const * token, case 1: q = (PKMX_WCHAR) u16chr(p + 1, '\"'); if (!q) return CERR_UnterminatedString; - if ((INT_PTR)(q - p) - 1 + mx > max) return CERR_UnterminatedString; + if ((int)(q - p) - 1 + mx > max) return CERR_UnterminatedString; if (sFlag) return CERR_StringInVirtualKeySection; - u16ncat(tstr, p + 1, (INT_PTR)(q - p) - 1); // I3481 - mx += (int)(INT_PTR)(q - p) - 1; + u16ncat(tstr, p + 1, (int)(q - p) - 1); // I3481 + mx += (int)(q - p) - 1; tstr[mx] = 0; p = q + 1; continue; case 2: q = (PKMX_WCHAR) u16chr(p + 1, '\''); if (!q) return CERR_UnterminatedString; - if ((INT_PTR)(q - p) - 1 + mx > max) return CERR_UnterminatedString; + if ((int)(q - p) - 1 + mx > max) return CERR_UnterminatedString; if (sFlag) return CERR_StringInVirtualKeySection; - u16ncat(tstr, p + 1, (INT_PTR)(q - p) - 1); // I3481 - mx += (int)(INT_PTR)(q - p) - 1; + u16ncat(tstr, p + 1, (int)(q - p) - 1); // I3481 + mx += (int)(q - p) - 1; tstr[mx] = 0; p = q + 1; continue; @@ -3152,7 +3132,7 @@ KMX_DWORD ProcessHotKey(PKMX_WCHAR p, KMX_DWORD *hk) } else return CERR_NoTokensFound; - j = (int)(INT_PTR)(r - q); + j = (int)(r - q); for (i = 0; i <= VK__MAX; i++) // I3438 if (j == (int) u16len(VKeyNames[i]) && u16nicmp(q, VKeyNames[i], j) == 0) break; @@ -3409,12 +3389,20 @@ KMX_DWORD ReadLine(FILE* fp_in , PKMX_WCHAR wstr, KMX_BOOL PreProcess) if (cur == fsize) - // S: Is replacing "\r\n" with "\n" here sufficient or do we need changes at other places as well when we skip "\r"? + // \r\n is still added here even though Linux doesn`t use \r. + // This is to ensure to still have a working windows-only-version u16ncat(str, u"\r\n", _countof(str)); // I3481 // Always a "\r\n" to the EOF, avoids funny bugs - // u16ncat(str, u"\n", _countof(str)); // I3481 if (len == 0) return CERR_EndOfFile; + // neccessary to add this block for using on non-windows platforms (removes all \r for platforms that use \n instead of \r\n) + for (p = str, n = 0; n < len; n++, p++) { + if (*p == L'\r') + *p = L' '; + } + + // \r is still left in this block even though Linux doesn`t use \r. + // This is to ensure to still have a working windows-only-version for (p = str, n = 0; n < len; n++, p++) { if (currentQuotes != 0) @@ -3433,7 +3421,7 @@ KMX_DWORD ReadLine(FILE* fp_in , PKMX_WCHAR wstr, KMX_BOOL PreProcess) *p = L' '; continue; } - if((*p == L'\\') || (*p == L'/')) { + if((*p == L'\\')) { LineCarry = TRUE; *p = L' '; continue; @@ -3489,7 +3477,7 @@ KMX_DWORD ReadLine(FILE* fp_in , PKMX_WCHAR wstr, KMX_BOOL PreProcess) if (*p == L'\n') kmcmp::currentLine++; - fseek(fp_in, -(int)(len * 2 - (INT_PTR)(p - str) * 2 - 2), SEEK_CUR); + fseek(fp_in, -(int)(len * 2 - (int)(p - str) * 2 - 2), SEEK_CUR); p--; while (p >= str && iswspace(*p)) p--; @@ -3759,7 +3747,7 @@ FILE* UTF16TempFromUTF8(FILE* fp_in , KMX_BOOL hasPreamble) PKMX_BYTE buf, p; PKMX_WCHAR outbuf, poutbuf; KMX_DWORD len; - DWORD len2; + KMX_DWORD len2; KMX_WCHAR prolog = 0xFEFF; fwrite(&prolog,2, 1, fp_out); @@ -3783,7 +3771,7 @@ FILE* UTF16TempFromUTF8(FILE* fp_in , KMX_BOOL hasPreamble) // We have a preamble, so we attempt to read as UTF-8 and allow conversion errors to be filtered. This is not great for a // compiler but matches existing behaviour -- in future versions we may not do lenient conversion. ConversionResult cr = ConvertUTF8toUTF16(&p, &buf[len2], (UTF16 **)&poutbuf, (const UTF16 *)&outbuf[len], lenientConversion); - fwrite(outbuf, (KMX_DWORD)(INT_PTR)(poutbuf - outbuf) * 2 , 1, fp_out); + fwrite(outbuf, (KMX_DWORD)(poutbuf - outbuf) * 2 , 1, fp_out); } else { // No preamble, so we attempt to read as strict UTF-8 and fall back to ANSI if that fails @@ -3805,7 +3793,7 @@ FILE* UTF16TempFromUTF8(FILE* fp_in , KMX_BOOL hasPreamble) } else { - fwrite(outbuf, (KMX_DWORD)(INT_PTR)(poutbuf - outbuf) * 2 , 1, fp_out); + fwrite(outbuf, (KMX_DWORD)(poutbuf - outbuf) * 2 , 1, fp_out); } } } diff --git a/developer/src/kmcmplib/src/DeprecationChecks.cpp b/developer/src/kmcmplib/src/DeprecationChecks.cpp index 992c3da130..7153a6f723 100644 --- a/developer/src/kmcmplib/src/DeprecationChecks.cpp +++ b/developer/src/kmcmplib/src/DeprecationChecks.cpp @@ -27,7 +27,7 @@ KMX_BOOL kmcmp::CheckForDeprecatedFeatures(PFILE_KEYBOARD fk) { #define TSS_WINDOWSLANGUAGES 29 */ int oldCurrentLine = kmcmp::currentLine; - DWORD i; + KMX_DWORD i; PFILE_STORE sp; if (!AWarnDeprecatedCode_GLOBAL_LIB) { diff --git a/developer/src/kmcmplib/src/kmcmplib.h b/developer/src/kmcmplib/src/kmcmplib.h index 64d47e642d..896ed8e10a 100644 --- a/developer/src/kmcmplib/src/kmcmplib.h +++ b/developer/src/kmcmplib/src/kmcmplib.h @@ -3,11 +3,11 @@ #include "compfile.h" namespace kmcmp { - KMX_BOOL AddCompileWarning(LPSTR buf); + KMX_BOOL AddCompileWarning(char* buf); extern int currentLine; } -extern BOOL AWarnDeprecatedCode_GLOBAL_LIB; +extern KMX_BOOL AWarnDeprecatedCode_GLOBAL_LIB; extern char ErrExtraLIB[256]; extern KMX_WCHAR ErrExtraW[256]; KMX_BOOL AddCompileError(KMX_DWORD msg); diff --git a/developer/src/kmcmplib/src/meson.build b/developer/src/kmcmplib/src/meson.build index 8d732384d1..7d05e9a511 100644 --- a/developer/src/kmcmplib/src/meson.build +++ b/developer/src/kmcmplib/src/meson.build @@ -85,10 +85,8 @@ lib = library('kmcmplib', '../../../../common/windows/cpp/src/ConvertUTF.c', '../../../../common/windows/cpp/src/crc32.cpp', - '../../../../common/windows/cpp/src/registry.cpp', - '../../../../common/windows/cpp/src/unicode.cpp', '../../../../common/windows/cpp/src/vkeys.cpp', - '../../../../common/windows/cpp/src/xstring.cpp', + 'xstring.cpp', '../../ext/json-schema-validator/json-schema-draft4.json.cpp', '../../ext/json-schema-validator/json-uri.cpp', diff --git a/developer/src/kmcmplib/src/pch.h b/developer/src/kmcmplib/src/pch.h index 82a82b3746..f878ad11be 100644 --- a/developer/src/kmcmplib/src/pch.h +++ b/developer/src/kmcmplib/src/pch.h @@ -1,14 +1,5 @@ #pragma once -#ifndef _WIN32_WINNT -#define _WIN32_WINNT 0x0600 -#endif - -#ifndef STRICT -#define STRICT -#endif - -#include #include #define USE_CHAR16_T @@ -16,8 +7,6 @@ #include "kmx_u16.h" #include -#include "../../../../common/windows/cpp/include/registry.h" -#include "../../../../common/windows/cpp/include/unicode.h" #include "../../../../common/windows/cpp/include/crc32.h" #include diff --git a/developer/src/kmcmplib/src/versioning.cpp b/developer/src/kmcmplib/src/versioning.cpp index 9b66bcd439..df85aafd5a 100644 --- a/developer/src/kmcmplib/src/versioning.cpp +++ b/developer/src/kmcmplib/src/versioning.cpp @@ -4,22 +4,26 @@ #include "kmcmplib.h" #include "versioning.h" -//namespace kmcmp { - KMX_BOOL kmcmp::CheckKeyboardFinalVersion(PFILE_KEYBOARD fk) { - KMX_CHAR buf[128]; +KMX_BOOL kmcmp::CheckKeyboardFinalVersion(PFILE_KEYBOARD fk) { + KMX_CHAR buf[128]; - if (fk->dwFlags & KF_AUTOMATICVERSION) { - if (fk->version <= 0) { - fk->version = VERSION_60; // minimum version that we can be safe with - } - - sprintf(buf, "The compiler has assigned a minimum engine version of %d.%d based on features used in this keyboard", (int)((fk->version & 0xFF00) >> 8), (int)(fk->version & 0xFF)); - AddCompileWarning(buf); + if (fk->dwFlags & KF_AUTOMATICVERSION) { + if (fk->version <= 0) { + fk->version = VERSION_60; // minimum version that we can be safe with } - return TRUE; + sprintf(buf, "The compiler has assigned a minimum engine version of %d.%d based on features used in this keyboard", (int)((fk->version & 0xFF00) >> 8), (int)(fk->version & 0xFF)); + AddCompileWarning(buf); } -//} + + return TRUE; +} + +// Note: max is not a standard c api function or macro +#ifndef max +#define max(a,b) (((a) > (b)) ? (a) : (b)) +#endif + KMX_BOOL VerifyKeyboardVersion(PFILE_KEYBOARD fk, KMX_DWORD ver) { if (fk->dwFlags & KF_AUTOMATICVERSION) { fk->version = max(fk->version, ver); diff --git a/developer/src/kmcmplib/src/virtualcharkeys.cpp b/developer/src/kmcmplib/src/virtualcharkeys.cpp index 3b50ab957e..eaef45aac4 100644 --- a/developer/src/kmcmplib/src/virtualcharkeys.cpp +++ b/developer/src/kmcmplib/src/virtualcharkeys.cpp @@ -1,7 +1,7 @@ #include "pch.h" #include "virtualcharkeys.h" -BOOL VKeyMayBeVCKey[256] = { +KMX_BOOL VKeyMayBeVCKey[256] = { FALSE, // L"K_?00", // &H0 FALSE, // L"K_LBUTTON", // &H1 FALSE, // L"K_RBUTTON", // &H2 @@ -271,4 +271,4 @@ BOOL VKeyMayBeVCKey[256] = { FALSE, // L"K_?FE", // &HFE FALSE, // L"K_?FF" // &HFF }; - + diff --git a/developer/src/kmcmplib/src/virtualcharkeys.h b/developer/src/kmcmplib/src/virtualcharkeys.h index e463b75cb5..539c5c5d40 100644 --- a/developer/src/kmcmplib/src/virtualcharkeys.h +++ b/developer/src/kmcmplib/src/virtualcharkeys.h @@ -1,7 +1,7 @@ #ifndef _VIRTUALCHARKEYS_H #define _VIRTUALCHARKEYS_H -extern BOOL VKeyMayBeVCKey[256]; +extern KMX_BOOL VKeyMayBeVCKey[256]; #endif diff --git a/developer/src/kmcmplib/src/xstring.h b/developer/src/kmcmplib/src/xstring.h index 3bf7eb68fa..ae08cfe64a 100644 --- a/developer/src/kmcmplib/src/xstring.h +++ b/developer/src/kmcmplib/src/xstring.h @@ -1,3 +1,4 @@ +// TODO: merge with xstring.h from common #pragma once #ifndef XSTRING_H #define SXTRING_H