Skip to content

Commit

Permalink
Merge pull request #6408 from keymanapp/fix/developer/kmcomp-x64-stru…
Browse files Browse the repository at this point in the history
…ct-sizes

fix(developer): structure sizes for kmcomp x64
  • Loading branch information
mcdurdin committed Mar 23, 2022
2 parents 04e1909 + 68a792c commit d714ccc
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 12 deletions.
10 changes: 5 additions & 5 deletions windows/src/developer/kmcmpdll/kcframe/kcframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ int WINAPI msgproc(int line, DWORD dwMsgCode, LPSTR szText)
int main(int argc, char *argv[])
{
if (argc == 2 && strcmp(argv[1], "--sizeof") == 0) {
printf("FILE_KEYBOARD_SIZE = %d\n", sizeof(FILE_KEYBOARD));
printf("FILE_GROUP_SIZE = %d\n", sizeof(FILE_GROUP));
printf("FILE_STORE_SIZE = %d\n", sizeof(FILE_STORE));
printf("FILE_KEY_SIZE = %d\n", sizeof(FILE_KEY));
printf("FILE_DEADKEY_SIZE = %d\n", sizeof(FILE_DEADKEY));
printf("FILE_KEYBOARD_SIZE = %zu\n", sizeof(FILE_KEYBOARD));
printf("FILE_GROUP_SIZE = %zu\n", sizeof(FILE_GROUP));
printf("FILE_STORE_SIZE = %zu\n", sizeof(FILE_STORE));
printf("FILE_KEY_SIZE = %zu\n", sizeof(FILE_KEY));
printf("FILE_DEADKEY_SIZE = %zu\n", sizeof(FILE_DEADKEY));
return 0;
}
if(argc < 3)
Expand Down
30 changes: 23 additions & 7 deletions windows/src/global/delphi/general/compile.pas
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,19 @@ FILE_KEYBOARD = record

const
// kcframe --sizeof returns these values
{$IFDEF WIN64}
FILE_KEYBOARD_SIZE = 2984;
FILE_GROUP_SIZE = 200;
FILE_STORE_SIZE = 200;
FILE_KEY_SIZE = 32;
FILE_DEADKEY_SIZE = 160;
{$ELSE}
FILE_KEYBOARD_SIZE = 2952;
FILE_GROUP_SIZE = 184;
FILE_STORE_SIZE = 192;
FILE_KEY_SIZE = 20;
FILE_DEADKEY_SIZE = 160;

{$ENDIF}

function CompileKeyboardFile(kmnFile, kmxFile: PChar; FSaveDebug, CompilerWarningsAsErrors, WarnDeprecatedCode: BOOL; CallBack: TCompilerCallback): Integer; cdecl; // I4865 // I4866
function CompileKeyboardFileToBuffer(kmnFile: PChar; buf: PFILE_KEYBOARD; CompilerWarningsAsErrors, WarnDeprecatedCode: BOOL; CallBack: TCompilerCallback; Target: Integer): Integer; cdecl; // I4865 // I4866
Expand Down Expand Up @@ -295,12 +302,21 @@ initialization
// We want to early load the compiler because we need it loaded for
// sentry symbolication: https://github.com/getsentry/sentry-native/issues/213
LoadCompiler;
Assert(sizeof(FILE_KEYBOARD) = FILE_KEYBOARD_SIZE);
Assert(sizeof(FILE_GROUP) = FILE_GROUP_SIZE);
Assert(sizeof(FILE_STORE) = FILE_STORE_SIZE);
Assert(sizeof(FILE_KEY) = FILE_KEY_SIZE);
Assert(sizeof(FILE_DEADKEY) = FILE_DEADKEY_SIZE);

try
Assert(sizeof(FILE_KEYBOARD) = FILE_KEYBOARD_SIZE, 'Assertion failure: sizeof(FILE_KEYBOARD) = FILE_KEYBOARD_SIZE');
Assert(sizeof(FILE_GROUP) = FILE_GROUP_SIZE, 'Assertion failure: sizeof(FILE_GROUP) = FILE_GROUP_SIZE');
Assert(sizeof(FILE_STORE) = FILE_STORE_SIZE, 'Assertion failure: sizeof(FILE_STORE) = FILE_STORE_SIZE');
Assert(sizeof(FILE_KEY) = FILE_KEY_SIZE, 'Assertion failure: sizeof(FILE_KEY) = FILE_KEY_SIZE');
Assert(sizeof(FILE_DEADKEY) = FILE_DEADKEY_SIZE, 'Assertion failure: sizeof(FILE_DEADKEY) = FILE_DEADKEY_SIZE');
except
on E:Exception do
begin
// We emit to the console manually because this exception is otherwise
// completely silent, which is a pain for testing.
writeln(E.Message);
raise;
end;
end;
finalization
if HKMCmpDll > 0 then
FreeLibrary(HKMCmpDll);
Expand Down

0 comments on commit d714ccc

Please sign in to comment.