mirror of
https://github.com/keymanapp/keyman.git
synced 2026-08-15 13:19:23 +00:00
chore(developer): use namespaces in kmcmplib (except for in dllexport-functions)
This commit is contained in:
parent
105d6f3fba
commit
081fa7deb9
14 changed files with 154 additions and 160 deletions
|
|
@ -410,22 +410,11 @@ typedef COMPILER_OPTIONS *PCOMPILER_OPTIONS;
|
|||
typedef int (CALLBACK *CompilerMessageProc)(int line, DWORD dwMsgCode, LPSTR szText);
|
||||
|
||||
extern "C" BOOL __declspec(dllexport) CompileKeyboardFile(PSTR pszInfile, PSTR pszOutfile, BOOL FSaveDebug, BOOL ACompilerWarningsAsErrors, BOOL AWarnDeprecatedCode, CompilerMessageProc pMsgProc); // I4865 // I4866
|
||||
extern "C" BOOL __declspec(dllexport) Kmcmp_CompileKeyboardFile(PSTR pszInfile, PSTR pszOutfile, BOOL FSaveDebug, BOOL ACompilerWarningsAsErrors, BOOL AWarnDeprecatedCode, CompilerMessageProc pMsgProc); // I4865 // I4866
|
||||
|
||||
extern "C" void __declspec(dllexport) Keyman_Diagnostic(int mode) ;
|
||||
|
||||
extern "C" BOOL __declspec(dllexport) SetCompilerOptions(PCOMPILER_OPTIONS options);
|
||||
extern "C" BOOL __declspec(dllexport) kmcmp_SetCompilerOptions(PCOMPILER_OPTIONS options);
|
||||
|
||||
extern "C" BOOL __declspec(dllexport) kmcmp_CompileKeyboardFile(PSTR pszInfile, PSTR pszOutfile, BOOL FSaveDebug, BOOL ACompilerWarningsAsErrors, BOOL AWarnDeprecatedCode, CompilerMessageProc pMsgProc); // I4865 // I4866
|
||||
extern "C" BOOL __declspec(dllexport) kmcmp_CompileKeyboardFileToBuffer(PSTR pszInfile, void* pfkBuffer, BOOL ACompilerWarningsAsErrors, BOOL AWarnDeprecatedCode, CompilerMessageProc pMsgProc, int Target); // I4865 // I4866
|
||||
|
||||
|
||||
extern "C" void __declspec(dllexport) kmcmp_Keyman_Diagnostic(int mode) ;
|
||||
namespace kmcmp{
|
||||
|
||||
|
||||
}
|
||||
|
||||
extern "C" BOOL __declspec(dllexport) kmcmp_SetCompilerOptions(PCOMPILER_OPTIONS options);
|
||||
|
||||
#endif // _COMPILER_H
|
||||
|
||||
|
|
|
|||
|
|
@ -298,12 +298,12 @@ bool flag_use_kmcompx = true;
|
|||
|
||||
extern "C" BOOL __declspec(dllexport) SetCompilerOptions(PCOMPILER_OPTIONS options) {
|
||||
|
||||
printf("--> starting SetCompilerOptions in dll\n");
|
||||
printf("---> started in SetCompilerOptions() of kmcmpdll\n");
|
||||
if ( flag_use_kmcompx)
|
||||
{
|
||||
return kmcmp_SetCompilerOptions(options);
|
||||
}
|
||||
printf("--> stay in dll SetCompilerOptions\n");
|
||||
printf("---> stayed in SetCompilerOptions() of kmcmpdll\n");
|
||||
|
||||
if(!options || options->dwSize < sizeof(COMPILER_OPTIONS)) {
|
||||
return FALSE;
|
||||
|
|
@ -320,13 +320,13 @@ extern "C" BOOL __declspec(dllexport) CompileKeyboardFile(PSTR pszInfile, PSTR p
|
|||
DWORD len;
|
||||
char str[260];
|
||||
|
||||
printf("--> starting CompileKeyboardFile in dll\n");
|
||||
printf("---> started in CompileKeyboardFile() of kmcmpdll\n");
|
||||
|
||||
if ( flag_use_kmcompx)
|
||||
{
|
||||
return Kmcmp_CompileKeyboardFile(pszInfile, pszOutfile, ASaveDebug, ACompilerWarningsAsErrors,AWarnDeprecatedCode, pMsgProc);
|
||||
return kmcmp_CompileKeyboardFile(pszInfile, pszOutfile, ASaveDebug, ACompilerWarningsAsErrors,AWarnDeprecatedCode, pMsgProc);
|
||||
}
|
||||
printf("--> stay in dll CompileKeyboardFile of kmcmpdll\n");
|
||||
printf("---> stayed in CompileKeyboardFile() of kmcmpdll\n");
|
||||
|
||||
FSaveDebug = ASaveDebug;
|
||||
FCompilerWarningsAsErrors = ACompilerWarningsAsErrors; // I4865
|
||||
|
|
@ -410,13 +410,13 @@ extern "C" BOOL __declspec(dllexport) CompileKeyboardFileToBuffer(PSTR pszInfile
|
|||
DWORD len;
|
||||
char str[260];
|
||||
|
||||
printf("--> starting CompileKeyboardFileToBuffer in dll.\n");
|
||||
printf("---> started in CompileKeyboardFileToBuffer() of kmcmpdll\n");
|
||||
if ( flag_use_kmcompx)
|
||||
{
|
||||
return kmcmp_CompileKeyboardFileToBuffer( pszInfile, (void*) pfkBuffer, ACompilerWarningsAsErrors, AWarnDeprecatedCode, pMsgProc, Target);
|
||||
}
|
||||
|
||||
printf("--> stay in dll CompileKeyboardFileToBuffer\n");
|
||||
printf("---> stayed in CompileKeyboardFileToBuffer() of kmcmpdll\n");
|
||||
|
||||
|
||||
FSaveDebug = TRUE; // I3681
|
||||
|
|
@ -3775,12 +3775,12 @@ HANDLE UTF16TempFromUTF8(HANDLE hInfile, BOOL hasPreamble)
|
|||
|
||||
extern "C" void __declspec(dllexport) Keyman_Diagnostic(int mode) {
|
||||
|
||||
printf("--> starting Keyman_Diagnostic in dll\n");
|
||||
printf("---> started in Keyman_Diagnostic() of kmcmpdll\n");
|
||||
if ( flag_use_kmcompx)
|
||||
{
|
||||
kmcmp_Keyman_Diagnostic( mode);
|
||||
}
|
||||
printf("--> stay in dll Keyman_Diagnostic\n");
|
||||
printf("---> stayed in Keyman_Diagnostic() of kmcmpdll\n");
|
||||
|
||||
if (mode == 0) {
|
||||
RaiseException(0x0EA0BEEF, EXCEPTION_NONCONTINUABLE, 0, NULL);
|
||||
|
|
|
|||
|
|
@ -14,6 +14,6 @@ typedef KMX_WCHAR* LPKMX_WCHAR ;
|
|||
#endif
|
||||
|
||||
typedef int (CALLBACK *CompilerMessageProc)(int line, KMX_DWORD dwMsgCode, char* szText);
|
||||
extern "C" KMX_BOOL __declspec(dllexport) Kmcmp_CompileKeyboardFile(PKMX_STR pszInfile,
|
||||
extern "C" KMX_BOOL __declspec(dllexport) kmcmp_CompileKeyboardFile(PKMX_STR pszInfile,
|
||||
PKMX_STR pszOutfile, KMX_BOOL ASaveDebug, KMX_BOOL ACompilerWarningsAsErrors,
|
||||
KMX_BOOL AWarnDeprecatedCode, CompilerMessageProc pMsgProc) ; // I4865 // I4866
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
#include <xstring.h>
|
||||
|
||||
namespace kmcmp {
|
||||
extern KMX_BOOL FMnemonicLayout; // TODO: these globals should be consolidated one day
|
||||
extern KMX_BOOL FMnemonicLayout; // TODO: these globals should be consolidated one day
|
||||
}
|
||||
|
||||
KMX_DWORD ExpandCapsRule(PFILE_GROUP gp, PFILE_KEY kpp, PFILE_STORE sp);
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
#define VK_xDF 0xDF
|
||||
|
||||
namespace kmcmp {
|
||||
KMX_BOOL MapUSCharToVK(KMX_UINT ch, KMX_UINT *puKey, KMX_UINT *puShiftFlags);
|
||||
KMX_BOOL MapUSCharToVK(KMX_UINT ch, KMX_UINT *puKey, KMX_UINT *puShiftFlags);
|
||||
}
|
||||
|
||||
KMX_WCHAR VKToChar(KMX_WORD keyCode, KMX_UINT shiftFlags);
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
#include "CheckFilenameConsistency.h"
|
||||
|
||||
namespace kmcmp {
|
||||
extern KMX_CHAR CompileDir[MAX_PATH];
|
||||
extern KMX_CHAR CompileDir[MAX_PATH];
|
||||
}
|
||||
bool IsRelativePath(KMX_CHAR const * p) {
|
||||
// Relative path (returns TRUE):
|
||||
|
|
|
|||
|
|
@ -96,13 +96,13 @@
|
|||
#include "kmx_u16.h"
|
||||
#include <CompMsg.h>
|
||||
using namespace kmcmp;
|
||||
|
||||
namespace kmcmp{
|
||||
|
||||
KMX_BOOL IsValidCallStore(PFILE_STORE fs);
|
||||
void RecordDeadkeyNames(PFILE_KEYBOARD fk);
|
||||
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);
|
||||
KMX_BOOL IsValidCallStore(PFILE_STORE fs);
|
||||
void RecordDeadkeyNames(PFILE_KEYBOARD fk);
|
||||
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 xatoi(PKMX_WCHAR *p);
|
||||
|
|
@ -218,17 +218,17 @@ enum LinePrefixType { lptNone, lptKeymanAndKeymanWeb, lptKeymanWebOnly, lptKeyma
|
|||
/* Compile target */
|
||||
|
||||
namespace kmcmp{
|
||||
HINSTANCE g_hInstance;
|
||||
KMX_BOOL FWarnDeprecatedCode;
|
||||
KMX_BOOL FShouldAddCompilerVersion = TRUE;
|
||||
KMX_BOOL FSaveDebug, FCompilerWarningsAsErrors; // I4865 // I4866
|
||||
int ErrChr;
|
||||
int nErrors = 0;
|
||||
KMX_CHAR ErrExtra[256];
|
||||
KMX_BOOL FMnemonicLayout = FALSE;
|
||||
KMX_BOOL FOldCharPosMatching = FALSE;
|
||||
int CompileTarget;
|
||||
KMX_CHAR CompileDir[MAX_PATH];
|
||||
HINSTANCE g_hInstance;
|
||||
KMX_BOOL FWarnDeprecatedCode;
|
||||
KMX_BOOL FShouldAddCompilerVersion = TRUE;
|
||||
KMX_BOOL FSaveDebug, FCompilerWarningsAsErrors; // I4865 // I4866
|
||||
int ErrChr;
|
||||
int nErrors = 0;
|
||||
KMX_CHAR ErrExtra[256];
|
||||
KMX_BOOL FMnemonicLayout = FALSE;
|
||||
KMX_BOOL FOldCharPosMatching = FALSE;
|
||||
int CompileTarget;
|
||||
KMX_CHAR CompileDir[MAX_PATH];
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -246,11 +246,11 @@ int BeginLine[4];
|
|||
#define CKF_KEYMANWEB 1
|
||||
|
||||
namespace kmcmp {
|
||||
KMX_BOOL WINAPI DllMain(HINSTANCE hinst, KMX_DWORD fdwReason, LPVOID lpvReserved)
|
||||
{
|
||||
if (fdwReason == DLL_PROCESS_ATTACH) kmcmp::g_hInstance = hinst;
|
||||
return TRUE;
|
||||
}
|
||||
KMX_BOOL WINAPI DllMain(HINSTANCE hinst, KMX_DWORD fdwReason, LPVOID lpvReserved)
|
||||
{
|
||||
if (fdwReason == DLL_PROCESS_ATTACH) kmcmp::g_hInstance = hinst;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
PKMX_WCHAR strtowstr(PKMX_STR in)
|
||||
|
|
@ -329,7 +329,7 @@ typedef struct _COMPILER_OPTIONS {
|
|||
typedef COMPILER_OPTIONS *PCOMPILER_OPTIONS;
|
||||
|
||||
extern "C" BOOL __declspec(dllexport) kmcmp_SetCompilerOptions(PCOMPILER_OPTIONS options) {
|
||||
printf("°°-> DEBUG: kmcmp::SetCompilerOptions Compiler.cpp of kmcmplib xxxxxrunning\n");
|
||||
printf("°°-> changed to SetCompilerOptions() of kmcmplib \n");
|
||||
if(!options || options->dwSize < sizeof(COMPILER_OPTIONS)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
|
@ -337,7 +337,7 @@ extern "C" BOOL __declspec(dllexport) kmcmp_SetCompilerOptions(PCOMPILER_OPTIONS
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
extern "C" BOOL __declspec(dllexport) Kmcmp_CompileKeyboardFile(PKMX_STR pszInfile, PKMX_STR pszOutfile, KMX_BOOL ASaveDebug, KMX_BOOL ACompilerWarningsAsErrors, KMX_BOOL AWarnDeprecatedCode, CompilerMessageProc pMsgProc) // I4865 // I4866
|
||||
extern "C" BOOL __declspec(dllexport) kmcmp_CompileKeyboardFile(PKMX_STR pszInfile, PKMX_STR pszOutfile, KMX_BOOL ASaveDebug, KMX_BOOL ACompilerWarningsAsErrors, KMX_BOOL AWarnDeprecatedCode, CompilerMessageProc pMsgProc) // I4865 // I4866
|
||||
{
|
||||
FILE* fp_in = NULL;
|
||||
FILE* fp_out = NULL;
|
||||
|
|
@ -345,7 +345,7 @@ extern "C" BOOL __declspec(dllexport) Kmcmp_CompileKeyboardFile(PKMX_STR pszInfi
|
|||
KMX_DWORD len;
|
||||
KMX_CHAR str[260];
|
||||
|
||||
printf("°°-> DEBUG: Kmcmp::CompileKeyboardFile Compiler.cpp of kmcmplib xxxxxrunning\n");
|
||||
printf("°°-> changed to CompileKeyboardFile() of kmcmplib \n");
|
||||
|
||||
kmcmp::FSaveDebug = ASaveDebug;
|
||||
kmcmp::FCompilerWarningsAsErrors = ACompilerWarningsAsErrors; // I4865
|
||||
|
|
@ -436,7 +436,7 @@ extern "C" BOOL __declspec(dllexport) Kmcmp_CompileKeyboardFile(PKMX_STR pszInfi
|
|||
|
||||
extern "C" BOOL __declspec(dllexport) kmcmp_CompileKeyboardFileToBuffer(PKMX_STR pszInfile, PFILE_KEYBOARD pfkBuffer, KMX_BOOL ACompilerWarningsAsErrors, KMX_BOOL AWarnDeprecatedCode, CompilerMessageProc pMsgProc, int Target) // I4865 // I4866
|
||||
{
|
||||
printf("°°-> DEBUG: kmcmp::CompileKeyboardFileToBuffer Compiler.cpp of kmcmplib xxxxrunning\n");
|
||||
printf("°°-> changed to CompileKeyboardFileToBuffer() of kmcmplib \n");
|
||||
FILE* fp_in = NULL;
|
||||
KMX_BOOL err;
|
||||
KMX_DWORD len;
|
||||
|
|
@ -996,30 +996,30 @@ KMX_DWORD ProcessGroupLine(PFILE_KEYBOARD fk, PKMX_WCHAR p)
|
|||
return CheckForDuplicateGroup(fk, gp);
|
||||
}
|
||||
namespace kmcmp {
|
||||
int cmpkeys(const void *key, const void *elem)
|
||||
{
|
||||
PFILE_KEY akey;
|
||||
PFILE_KEY aelem;
|
||||
int l1, l2;
|
||||
KMX_WCHAR char_key, char_elem;
|
||||
akey = (PFILE_KEY)key;
|
||||
aelem = (PFILE_KEY)elem;
|
||||
char_key = VKToChar(akey->Key, akey->ShiftFlags);
|
||||
char_elem = VKToChar(aelem->Key, aelem->ShiftFlags);
|
||||
if (char_key == char_elem) //akey->Key == aelem->Key)
|
||||
int cmpkeys(const void *key, const void *elem)
|
||||
{
|
||||
l1 = xstrlen(akey->dpContext); l2 = xstrlen(aelem->dpContext);
|
||||
if (l1 == l2)
|
||||
PFILE_KEY akey;
|
||||
PFILE_KEY aelem;
|
||||
int l1, l2;
|
||||
KMX_WCHAR char_key, char_elem;
|
||||
akey = (PFILE_KEY)key;
|
||||
aelem = (PFILE_KEY)elem;
|
||||
char_key = VKToChar(akey->Key, akey->ShiftFlags);
|
||||
char_elem = VKToChar(aelem->Key, aelem->ShiftFlags);
|
||||
if (char_key == char_elem) //akey->Key == aelem->Key)
|
||||
{
|
||||
if (akey->Line < aelem->Line) return -1;
|
||||
if (akey->Line > aelem->Line) return 1;
|
||||
return 0;
|
||||
l1 = xstrlen(akey->dpContext); l2 = xstrlen(aelem->dpContext);
|
||||
if (l1 == l2)
|
||||
{
|
||||
if (akey->Line < aelem->Line) return -1;
|
||||
if (akey->Line > aelem->Line) return 1;
|
||||
return 0;
|
||||
}
|
||||
if (l1 < l2) return 1;
|
||||
if (l1 > l2) return -1;
|
||||
}
|
||||
if (l1 < l2) return 1;
|
||||
if (l1 > l2) return -1;
|
||||
return(char_key - char_elem); // akey->Key - aelem->Key);
|
||||
}
|
||||
return(char_key - char_elem); // akey->Key - aelem->Key);
|
||||
}
|
||||
}
|
||||
KMX_DWORD ProcessGroupFinish(PFILE_KEYBOARD fk)
|
||||
{
|
||||
|
|
@ -3630,24 +3630,24 @@ int atoiW(PKMX_WCHAR p)
|
|||
return i;
|
||||
}
|
||||
namespace kmcmp {
|
||||
int CheckUTF16(int n)
|
||||
{
|
||||
const int res[] = {
|
||||
0xFDD0, 0xFDD1, 0xFDD2, 0xFDD3, 0xFDD4, 0xFDD5, 0xFDD6, 0xFDD7,
|
||||
0xFDD8, 0xFDD9, 0xFDDA, 0xFDDB, 0xFDDC, 0xFDDD, 0xFDDE, 0xFDDF,
|
||||
0xFDE0, 0xFDE1, 0xFDE2, 0xFDE3, 0xFDE4, 0xFDE5, 0xFDE6, 0xFDE7,
|
||||
0xFDE8, 0xFDE9, 0xFDEA, 0xFDEB, 0xFDEC, 0xFDED, 0xFDEE, 0xFDEF,
|
||||
0xFFFF, 0xFFFE, 0 };
|
||||
int CheckUTF16(int n)
|
||||
{
|
||||
const int res[] = {
|
||||
0xFDD0, 0xFDD1, 0xFDD2, 0xFDD3, 0xFDD4, 0xFDD5, 0xFDD6, 0xFDD7,
|
||||
0xFDD8, 0xFDD9, 0xFDDA, 0xFDDB, 0xFDDC, 0xFDDD, 0xFDDE, 0xFDDF,
|
||||
0xFDE0, 0xFDE1, 0xFDE2, 0xFDE3, 0xFDE4, 0xFDE5, 0xFDE6, 0xFDE7,
|
||||
0xFDE8, 0xFDE9, 0xFDEA, 0xFDEB, 0xFDEC, 0xFDED, 0xFDEE, 0xFDEF,
|
||||
0xFFFF, 0xFFFE, 0 };
|
||||
|
||||
if (n == 0) return CERR_ReservedCharacter;
|
||||
for (int i = 0; res[i] > 0; i++)
|
||||
if (n == res[i])
|
||||
{
|
||||
AddWarning(CWARN_ReservedCharacter);
|
||||
break;
|
||||
}
|
||||
return CERR_None;
|
||||
}
|
||||
if (n == 0) return CERR_ReservedCharacter;
|
||||
for (int i = 0; res[i] > 0; i++)
|
||||
if (n == res[i])
|
||||
{
|
||||
AddWarning(CWARN_ReservedCharacter);
|
||||
break;
|
||||
}
|
||||
return CERR_None;
|
||||
}
|
||||
}
|
||||
int kmcmp::UTF32ToUTF16(int n, int *n1, int *n2)
|
||||
{
|
||||
|
|
@ -3844,9 +3844,9 @@ FILE* UTF16TempFromUTF8(FILE* fp_in , KMX_BOOL hasPreamble)
|
|||
return fp_out;
|
||||
}
|
||||
|
||||
extern "C" void __declspec(dllexport) kmcmp_Keyman_Diagnostic(int mode) {
|
||||
extern "C" void __declspec(dllexport) kmcmp_Keyman_Diagnostic(int mode) {
|
||||
|
||||
printf("°°-> DEBUG: kmcmp::Keyman_Diagnostic Compiler.cpp of kmcmplib xxxxxrunning\n");
|
||||
printf("°°-> changed to Keyman_Diagnostic() of kmcmplib \n");
|
||||
if (mode == 0) {
|
||||
RaiseException(0x0EA0BEEF, EXCEPTION_NONCONTINUABLE, 0, NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,31 +29,33 @@
|
|||
using namespace kmcmp;
|
||||
|
||||
namespace kmcmp {
|
||||
extern KMX_CHAR CompileDir[];
|
||||
extern KMX_CHAR CompileDir[];
|
||||
}
|
||||
|
||||
int IsHangulSyllable(const KMX_WCHAR *codename, int *code);
|
||||
namespace kmcmp {
|
||||
KMX_BOOL FileExists(const KMX_CHAR *filename)
|
||||
{
|
||||
intptr_t n;
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
_finddata_t fi;
|
||||
if((n = _findfirst(filename, &fi)) != -1) // I3056 // I3512
|
||||
namespace kmcmp {
|
||||
KMX_BOOL FileExists(const KMX_CHAR *filename)
|
||||
{
|
||||
_findclose(n);
|
||||
return TRUE;
|
||||
intptr_t n;
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
_finddata_t fi;
|
||||
if((n = _findfirst(filename, &fi)) != -1) // I3056 // I3512
|
||||
{
|
||||
_findclose(n);
|
||||
return TRUE;
|
||||
}
|
||||
#else
|
||||
if((n= access(filename,F_OK)) != -1) // I3056 // I3512
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
return FALSE;
|
||||
}
|
||||
#else
|
||||
if((n= access(filename,F_OK)) != -1) // I3056 // I3512
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
NamedCodeConstants::NamedCodeConstants()
|
||||
{
|
||||
nEntries = 0;
|
||||
|
|
@ -117,12 +119,12 @@ void NamedCodeConstants::AddCode_IncludedCodes(int n, const KMX_WCHAR *p)
|
|||
}
|
||||
|
||||
namespace kmcmp {
|
||||
int __cdecl sort_entries(const void *elem1, const void *elem2)
|
||||
{
|
||||
return u16icmp(
|
||||
((NCCENTRY *)elem1)->name,
|
||||
((NCCENTRY *)elem2)->name);
|
||||
}
|
||||
int __cdecl sort_entries(const void *elem1, const void *elem2)
|
||||
{
|
||||
return u16icmp(
|
||||
((NCCENTRY *)elem1)->name,
|
||||
((NCCENTRY *)elem2)->name);
|
||||
}
|
||||
}
|
||||
KMX_BOOL NamedCodeConstants::IntLoadFile(const KMX_CHAR *filename)
|
||||
{
|
||||
|
|
@ -165,12 +167,12 @@ KMX_BOOL NamedCodeConstants::LoadFile(const KMX_CHAR *filename)
|
|||
KMX_CHAR buf[260];
|
||||
// Look in current directory first
|
||||
strncpy_s(buf, _countof(buf), filename, 259); buf[259] = 0; // I3481
|
||||
if(kmcmp::FileExists(buf))
|
||||
if(FileExists(buf))
|
||||
return IntLoadFile(buf);
|
||||
// Then look in keyboard file directory (CompileDir)
|
||||
strncpy_s(buf, _countof(buf), kmcmp::CompileDir, 259); buf[259] = 0; // I3481
|
||||
strncat_s(buf, _countof(buf), filename, 259-strlen(kmcmp::CompileDir)); buf[259] = 0;
|
||||
if(kmcmp::FileExists(buf))
|
||||
strncpy_s(buf, _countof(buf), CompileDir, 259); buf[259] = 0; // I3481
|
||||
strncat_s(buf, _countof(buf), filename, 259-strlen(CompileDir)); buf[259] = 0;
|
||||
if(FileExists(buf))
|
||||
return IntLoadFile(buf);
|
||||
|
||||
//TODO: sort out how to find common includes in non-Windows platforms:
|
||||
|
|
@ -180,7 +182,7 @@ KMX_BOOL NamedCodeConstants::LoadFile(const KMX_CHAR *filename)
|
|||
KMX_CHAR *p = strrchr(buf, '\\'); if(p) p++; else p = buf;
|
||||
*p = 0;
|
||||
strncat_s(buf, _countof(buf), filename, 259-strlen(buf)); buf[259] = 0; // I3481 // I3641
|
||||
if(kmcmp::FileExists(buf))
|
||||
if(FileExists(buf))
|
||||
return IntLoadFile(buf);
|
||||
#endif
|
||||
|
||||
|
|
@ -192,7 +194,7 @@ KMX_BOOL NamedCodeConstants::LoadFile(const KMX_CHAR *filename)
|
|||
void NamedCodeConstants::reindex()
|
||||
{
|
||||
if (entries != NULL) {
|
||||
qsort(entries, nEntries, sizeof(NCCENTRY), kmcmp::sort_entries);
|
||||
qsort(entries, nEntries, sizeof(NCCENTRY), sort_entries);
|
||||
}
|
||||
|
||||
wchar_t c = L'.', d;
|
||||
|
|
|
|||
|
|
@ -13,25 +13,25 @@ struct NCCENTRY
|
|||
};
|
||||
|
||||
namespace kmcmp{
|
||||
class NamedCodeConstants
|
||||
{
|
||||
private:
|
||||
NCCENTRY *entries; // entries from &includecodes
|
||||
NCCENTRY *entries_file; // entries from store(myconst) x
|
||||
int nEntries, nEntries_file;
|
||||
int chrindexes[128]; // A-Z, 0-9, -, _; simple index
|
||||
class NamedCodeConstants
|
||||
{
|
||||
private:
|
||||
NCCENTRY *entries; // entries from &includecodes
|
||||
NCCENTRY *entries_file; // entries from store(myconst) x
|
||||
int nEntries, nEntries_file;
|
||||
int chrindexes[128]; // A-Z, 0-9, -, _; simple index
|
||||
|
||||
int GetCode_IncludedCodes(const KMX_WCHAR *codename);
|
||||
void AddCode_IncludedCodes(int n, const KMX_WCHAR *p);
|
||||
KMX_BOOL IntLoadFile(const KMX_CHAR *filename);
|
||||
public:
|
||||
NamedCodeConstants();
|
||||
~NamedCodeConstants();
|
||||
int GetCode_IncludedCodes(const KMX_WCHAR *codename);
|
||||
void AddCode_IncludedCodes(int n, const KMX_WCHAR *p);
|
||||
KMX_BOOL IntLoadFile(const KMX_CHAR *filename);
|
||||
public:
|
||||
NamedCodeConstants();
|
||||
~NamedCodeConstants();
|
||||
|
||||
void reindex();
|
||||
void AddCode(int n, const KMX_WCHAR *p, KMX_DWORD storeIndex);
|
||||
KMX_BOOL LoadFile(const KMX_CHAR *filename);
|
||||
int GetCode(const KMX_WCHAR *codename, KMX_DWORD *storeIndex);
|
||||
};
|
||||
void reindex();
|
||||
void AddCode(int n, const KMX_WCHAR *p, KMX_DWORD storeIndex);
|
||||
KMX_BOOL LoadFile(const KMX_CHAR *filename);
|
||||
int GetCode(const KMX_WCHAR *codename, KMX_DWORD *storeIndex);
|
||||
};
|
||||
}
|
||||
#endif //NAMEDCODECONSTANTS_H
|
||||
|
|
|
|||
|
|
@ -13,12 +13,12 @@
|
|||
|
||||
#include "UnreachableRules.h"
|
||||
namespace kmcmp {
|
||||
std::wstring MakeHashKeyFromFileKey(PFILE_KEY kp) {
|
||||
std::wstringstream key;
|
||||
key << kp->Key << "," << kp->ShiftFlags << ",";
|
||||
if (kp->dpContext) key << kp->dpContext;
|
||||
return key.str();
|
||||
}
|
||||
std::wstring MakeHashKeyFromFileKey(PFILE_KEY kp) {
|
||||
std::wstringstream key;
|
||||
key << kp->Key << "," << kp->ShiftFlags << ",";
|
||||
if (kp->dpContext) key << kp->dpContext;
|
||||
return key.str();
|
||||
}
|
||||
}
|
||||
KMX_DWORD VerifyUnreachableRules(PFILE_GROUP gp) {
|
||||
PFILE_KEY kp = gp->dpKeyArray;
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
#pragma once
|
||||
|
||||
#include <compfile.h>
|
||||
|
||||
namespace kmcmp {
|
||||
KMX_BOOL AddCompileString(LPSTR buf);
|
||||
KMX_BOOL AddCompileString(LPSTR buf);
|
||||
}
|
||||
|
||||
KMX_BOOL AddCompileMessage(KMX_DWORD msg);
|
||||
|
||||
// TODO: These macros can return FALSE in functions that expect a DWORD CERR_x
|
||||
|
|
@ -12,8 +14,8 @@ KMX_BOOL AddCompileMessage(KMX_DWORD msg);
|
|||
#define AddWarning(warn) { if(AddCompileMessage(warn)) return FALSE; }
|
||||
|
||||
namespace kmcmp {
|
||||
extern BOOL FWarnDeprecatedCode;
|
||||
extern int currentLine;
|
||||
extern BOOL FWarnDeprecatedCode;
|
||||
extern int currentLine;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -4,20 +4,20 @@
|
|||
#include <kmcmpdll.h>
|
||||
|
||||
namespace kmcmp {
|
||||
KMX_BOOL CheckKeyboardFinalVersion(PFILE_KEYBOARD fk) {
|
||||
KMX_CHAR buf[128];
|
||||
KMX_BOOL 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
|
||||
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));
|
||||
kmcmp::AddCompileString(buf);
|
||||
}
|
||||
|
||||
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));
|
||||
kmcmp::AddCompileString(buf);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
KMX_BOOL VerifyKeyboardVersion(PFILE_KEYBOARD fk, KMX_DWORD ver) {
|
||||
if (fk->dwFlags & KF_AUTOMATICVERSION) {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
}
|
||||
|
||||
namespace kmcmp {
|
||||
KMX_BOOL CheckKeyboardFinalVersion(PFILE_KEYBOARD fk);
|
||||
KMX_BOOL CheckKeyboardFinalVersion(PFILE_KEYBOARD fk);
|
||||
}
|
||||
|
||||
KMX_BOOL VerifyKeyboardVersion(PFILE_KEYBOARD fk, KMX_DWORD ver);
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ int main(int argc, char *argv[])
|
|||
char first5[6] = "CERR_";
|
||||
char* pfirst5 = first5;
|
||||
|
||||
if (Kmcmp_CompileKeyboardFile(kmn_file, kmx_file, FALSE, FALSE, TRUE, msgproc)) {
|
||||
if (kmcmp_CompileKeyboardFile(kmn_file, kmx_file, FALSE, FALSE, TRUE, msgproc)) {
|
||||
char* testname = strrchr( (char*) kmn_file, '\\') + 1;
|
||||
if (strncmp(testname, pfirst5, 5) == 0) return 1; //no Error found + CERR_ in Name
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue