From 0f60ecda03f4955ce083080a6b4235ffa632449b Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Thu, 18 Apr 2024 12:09:52 +0100 Subject: [PATCH 01/48] chore(developer): add check run sets related packages correctly test --- .../test/test-keyboard-info-compiler.ts | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/developer/src/kmc-keyboard-info/test/test-keyboard-info-compiler.ts b/developer/src/kmc-keyboard-info/test/test-keyboard-info-compiler.ts index 3547eb63ab..e9d0c4972b 100644 --- a/developer/src/kmc-keyboard-info/test/test-keyboard-info-compiler.ts +++ b/developer/src/kmc-keyboard-info/test/test-keyboard-info-compiler.ts @@ -390,6 +390,38 @@ describe('keyboard-info-compiler', function () { assert.deepEqual(keyboard_info.platformSupport, testCase.expected); })); + it('check run sets related packages correctly', async function() { + const kpjFilename = KHMER_ANGKOR_KPJ; + const sources = KHMER_ANGKOR_SOURCES; + const compiler = new KeyboardInfoCompiler(); + assert.isTrue(await compiler.init(callbacks, {sources})); + const kmpCompiler = new KmpCompiler(); + await kmpCompiler.init(callbacks, {}); + const kmpJsonData = kmpCompiler.transformKpsToKmpObject(sources.kpsFilename); + kmpJsonData.relatedPackages = [ + { id: "dep1", relationship: "deprecates" }, + { id: "dep2", relationship: "deprecates" }, + { id: "rel1", relationship: "related" }, + ]; + const origKmpCompilerTransformKpsToKmpObject = KmpCompiler.prototype.transformKpsToKmpObject; + let result: KeyboardInfoCompilerResult; + try { + KmpCompiler.prototype.transformKpsToKmpObject = (_kpsFilename: string): KmpJsonFile.KmpJsonFile => kmpJsonData; + result = await compiler.run(kpjFilename, null); + } catch(e) { + assert.fail(e); + } finally { + KmpCompiler.prototype.transformKpsToKmpObject = origKmpCompilerTransformKpsToKmpObject; + } + assert.isNotNull(result); + const keyboard_info = JSON.parse(new TextDecoder().decode(result.artifacts.keyboard_info.data)); + assert.deepEqual(keyboard_info.related['dep1'], {deprecates: true}); + assert.deepEqual(keyboard_info.related['dep2'], {deprecates: true}); + assert.deepEqual(keyboard_info.related['rel1'], {deprecates: false}); + }); + + // [ { id: "khmer10", relationship: "deprecates"} ] + it('should write artifacts to disk', async function() { const kpjFilename = KHMER_ANGKOR_KPJ; const actualFilename = makePathToFixture('khmer_angkor', 'build', 'actual.keyboard_info'); From ebe891140927fd75fdc917da2af2143c918c3dcd Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Thu, 18 Apr 2024 12:11:10 +0100 Subject: [PATCH 02/48] chore(developer): delete temporary comment --- .../src/kmc-keyboard-info/test/test-keyboard-info-compiler.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/developer/src/kmc-keyboard-info/test/test-keyboard-info-compiler.ts b/developer/src/kmc-keyboard-info/test/test-keyboard-info-compiler.ts index e9d0c4972b..f8881864ec 100644 --- a/developer/src/kmc-keyboard-info/test/test-keyboard-info-compiler.ts +++ b/developer/src/kmc-keyboard-info/test/test-keyboard-info-compiler.ts @@ -420,8 +420,6 @@ describe('keyboard-info-compiler', function () { assert.deepEqual(keyboard_info.related['rel1'], {deprecates: false}); }); - // [ { id: "khmer10", relationship: "deprecates"} ] - it('should write artifacts to disk', async function() { const kpjFilename = KHMER_ANGKOR_KPJ; const actualFilename = makePathToFixture('khmer_angkor', 'build', 'actual.keyboard_info'); From a001bbd1050dacf25150e5a4d1255c9e244aac98 Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Thu, 18 Apr 2024 12:23:06 +0100 Subject: [PATCH 03/48] chore(developer): add code coverage for schema validation failure --- developer/src/kmc-keyboard-info/src/keyboard-info-compiler.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/developer/src/kmc-keyboard-info/src/keyboard-info-compiler.ts b/developer/src/kmc-keyboard-info/src/keyboard-info-compiler.ts index c2a1376340..5337ba2fd4 100644 --- a/developer/src/kmc-keyboard-info/src/keyboard-info-compiler.ts +++ b/developer/src/kmc-keyboard-info/src/keyboard-info-compiler.ts @@ -372,6 +372,7 @@ export class KeyboardInfoCompiler implements KeymanCompiler { const jsonOutput = JSON.stringify(keyboard_info, null, 2); + /* c8 ignore next 8 */ if(!SchemaValidators.default.keyboard_info(keyboard_info)) { // This is an internal fatal error; we should not be capable of producing // invalid output, so it is best to throw and die From 0f0b51f80e22058721447ad8653a8d55c332f84b Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Tue, 23 Apr 2024 11:30:45 +0100 Subject: [PATCH 04/48] chore(developer): clarify element tag name in platforms test --- .../test/test-keyboard-info-compiler.ts | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/developer/src/kmc-keyboard-info/test/test-keyboard-info-compiler.ts b/developer/src/kmc-keyboard-info/test/test-keyboard-info-compiler.ts index f8881864ec..4f0fd5c65a 100644 --- a/developer/src/kmc-keyboard-info/test/test-keyboard-info-compiler.ts +++ b/developer/src/kmc-keyboard-info/test/test-keyboard-info-compiler.ts @@ -341,15 +341,15 @@ describe('keyboard-info-compiler', function () { })); const platformsTestCases = [ - { hasJsFile: true, targets: 'any', expected: { windows: "full",macos: "full",linux: "full",desktopWeb: "full",ios: "full",android: "full",mobileWeb: "full" } }, - { hasJsFile: false, targets: '', expected: { desktopWeb: "full",mobileWeb: "full" } }, - { hasJsFile: true, targets: '', expected: { desktopWeb: "full",ios: "full",android: "full",mobileWeb: "full" } }, - { hasJsFile: true, targets: 'androidphone', expected: { android: "full",mobileWeb: "full" } }, - { hasJsFile: true, targets: 'iphone', expected: { ios: "full",mobileWeb: "full" } }, - { hasJsFile: true, targets: 'linux', expected: { linux: "full",desktopWeb: "full" } }, - { hasJsFile: true, targets: 'macosx', expected: { macos: "full",desktopWeb: "full" } }, - { hasJsFile: true, targets: 'windows', expected: { windows: "full",desktopWeb: "full" } }, - { hasJsFile: true, targets: 'androidphone iphone', expected: { android: "full",ios: "full",mobileWeb: "full" } }, + { hasJsFileInKps: true, targets: 'any', expected: { windows: "full",macos: "full",linux: "full",desktopWeb: "full",ios: "full",android: "full",mobileWeb: "full" } }, + { hasJsFileInKps: false, targets: '', expected: { desktopWeb: "full",mobileWeb: "full" } }, + { hasJsFileInKps: true, targets: '', expected: { desktopWeb: "full",ios: "full",android: "full",mobileWeb: "full" } }, + { hasJsFileInKps: true, targets: 'androidphone', expected: { android: "full",mobileWeb: "full" } }, + { hasJsFileInKps: true, targets: 'iphone', expected: { ios: "full",mobileWeb: "full" } }, + { hasJsFileInKps: true, targets: 'linux', expected: { linux: "full",desktopWeb: "full" } }, + { hasJsFileInKps: true, targets: 'macosx', expected: { macos: "full",desktopWeb: "full" } }, + { hasJsFileInKps: true, targets: 'windows', expected: { windows: "full",desktopWeb: "full" } }, + { hasJsFileInKps: true, targets: 'androidphone iphone', expected: { android: "full",ios: "full",mobileWeb: "full" } }, ]; platformsTestCases.forEach((testCase, idx) => it(`check run sets platforms correctly (test case #${idx})`, async function() { @@ -362,7 +362,7 @@ describe('keyboard-info-compiler', function () { assert.isTrue(await kmpCompiler.init(callbacks, {})); const kmpJsonData = kmpCompiler.transformKpsToKmpObject(kpsFilename); assert.isNotNull(kmpJsonData); - if (!testCase.hasJsFile) { + if (!testCase.hasJsFileInKps) { // remove .js file kmpJsonData.files = kmpJsonData.files.filter(file => !KeymanFileTypes.filenameIs(file.name, KeymanFileTypes.Binary.WebKeyboard)); } From e2ba026313d4cbfc272fc6d3c45b98fe863d01b2 Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Thu, 25 Apr 2024 11:09:37 +0100 Subject: [PATCH 05/48] chore(developer): rmove unnecessary async from preinit test --- .../src/kmc-keyboard-info/test/test-keyboard-info-compiler.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/developer/src/kmc-keyboard-info/test/test-keyboard-info-compiler.ts b/developer/src/kmc-keyboard-info/test/test-keyboard-info-compiler.ts index 4f0fd5c65a..47e16dc5f8 100644 --- a/developer/src/kmc-keyboard-info/test/test-keyboard-info-compiler.ts +++ b/developer/src/kmc-keyboard-info/test/test-keyboard-info-compiler.ts @@ -109,7 +109,7 @@ describe('keyboard-info-compiler', function () { assert.deepEqual(actual, expected); }); - it('check preinit creates langtagsByTag correctly', async function() { + it('check preinit creates langtagsByTag correctly', function() { const compiler = new KeyboardInfoCompiler(); // indirectly call preinit() assert.isNotNull(compiler); const en_langtag = langtags.find(({ tag }) => tag === 'en'); From 983f0b237a102fd27d06c5701f95472c3118c046 Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Thu, 25 Apr 2024 11:20:48 +0100 Subject: [PATCH 06/48] chore(developer): replace some local variables with constants --- .../test/test-keyboard-info-compiler.ts | 25 +++++++------------ 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/developer/src/kmc-keyboard-info/test/test-keyboard-info-compiler.ts b/developer/src/kmc-keyboard-info/test/test-keyboard-info-compiler.ts index 47e16dc5f8..4dcd90464b 100644 --- a/developer/src/kmc-keyboard-info/test/test-keyboard-info-compiler.ts +++ b/developer/src/kmc-keyboard-info/test/test-keyboard-info-compiler.ts @@ -283,7 +283,6 @@ describe('keyboard-info-compiler', function () { ]; packageIncludesTestCases.forEach((testCase, idx) => it(`check run sets packageIncludes correctly (test case #${idx})`, async function() { - const kpjFilename = KHMER_ANGKOR_KPJ; const sources = KHMER_ANGKOR_SOURCES; const compiler = new KeyboardInfoCompiler(); assert.isTrue(await compiler.init(callbacks, {sources})); @@ -301,7 +300,7 @@ describe('keyboard-info-compiler', function () { let result: KeyboardInfoCompilerResult; try { KmpCompiler.prototype.transformKpsToKmpObject = (_kpsFilename: string): KmpJsonFile.KmpJsonFile => kmpJsonData; - result = await compiler.run(kpjFilename, null); + result = await compiler.run(KHMER_ANGKOR_KPJ, null); } catch(e) { assert.fail(e); } finally { @@ -321,7 +320,6 @@ describe('keyboard-info-compiler', function () { ]; minKeymanVersionTestCases.forEach((testCase, idx) => it(`check run sets minKeymanVersion correctly (test case #${idx})`, async function() { - const kpjFilename = KHMER_ANGKOR_KPJ; const sources = KHMER_ANGKOR_SOURCES; const compiler = new KeyboardInfoCompiler(); assert.isTrue(await compiler.init(callbacks, {sources})); @@ -332,7 +330,7 @@ describe('keyboard-info-compiler', function () { jsFile = jsFile.replace('this.KMINVER="10.0";', insert); compiler['loadJsFile'] = (_filename: string) => jsFile; compiler['kmxFileVersionToString'] = (_version: number) => testCase.kmx; - const result = await compiler.run(kpjFilename, null); + const result = await compiler.run(KHMER_ANGKOR_KPJ, null); compiler['loadJsFile'] = origCompilerLoadJsFile; compiler['kmxFileVersionToString'] = origKmxFileVersionToString; assert.isNotNull(result); @@ -353,7 +351,6 @@ describe('keyboard-info-compiler', function () { ]; platformsTestCases.forEach((testCase, idx) => it(`check run sets platforms correctly (test case #${idx})`, async function() { - const kpjFilename = KHMER_ANGKOR_KPJ; const sources = KHMER_ANGKOR_SOURCES; const compiler = new KeyboardInfoCompiler(); assert.isTrue(await compiler.init(callbacks, {sources})); @@ -378,7 +375,7 @@ describe('keyboard-info-compiler', function () { try { KmpCompiler.prototype.transformKpsToKmpObject = (_kpsFilename: string): KmpJsonFile.KmpJsonFile => kmpJsonData; compiler['loadKmxFiles'] = (_kpsFilename: string, _kmpJsonData: KmpJsonFile.KmpJsonFile) => kmxFiles; - result = await compiler.run(kpjFilename, null); + result = await compiler.run(KHMER_ANGKOR_KPJ, null); } catch(e) { assert.fail(e); } finally { @@ -391,7 +388,6 @@ describe('keyboard-info-compiler', function () { })); it('check run sets related packages correctly', async function() { - const kpjFilename = KHMER_ANGKOR_KPJ; const sources = KHMER_ANGKOR_SOURCES; const compiler = new KeyboardInfoCompiler(); assert.isTrue(await compiler.init(callbacks, {sources})); @@ -407,7 +403,7 @@ describe('keyboard-info-compiler', function () { let result: KeyboardInfoCompilerResult; try { KmpCompiler.prototype.transformKpsToKmpObject = (_kpsFilename: string): KmpJsonFile.KmpJsonFile => kmpJsonData; - result = await compiler.run(kpjFilename, null); + result = await compiler.run(KHMER_ANGKOR_KPJ, null); } catch(e) { assert.fail(e); } finally { @@ -421,14 +417,13 @@ describe('keyboard-info-compiler', function () { }); it('should write artifacts to disk', async function() { - const kpjFilename = KHMER_ANGKOR_KPJ; const actualFilename = makePathToFixture('khmer_angkor', 'build', 'actual.keyboard_info'); const expectedFilename = makePathToFixture('khmer_angkor', 'build', 'khmer_angkor.keyboard_info'); const sources = KHMER_ANGKOR_SOURCES; const compiler = new KeyboardInfoCompiler(); assert.isTrue(await compiler.init(callbacks, {sources})); - const result = await compiler.run(kpjFilename, null); + const result = await compiler.run(KHMER_ANGKOR_KPJ, null); assert.isNotNull(result); if(fs.existsSync(actualFilename)) { @@ -489,32 +484,30 @@ describe('keyboard-info-compiler', function () { }); it('check loadKmxFiles returns empty array if .kmx file is missing from .kmp', async function() { - const kpsFilename = KHMER_ANGKOR_KPS; const compiler = new KeyboardInfoCompiler(); const kmpCompiler = new KmpCompiler(); assert.isTrue(await kmpCompiler.init(callbacks, {})); - const kmpJsonData = kmpCompiler.transformKpsToKmpObject(kpsFilename); + const kmpJsonData = kmpCompiler.transformKpsToKmpObject(KHMER_ANGKOR_KPS); assert.isNotNull(kmpJsonData); // remove .kmx file kmpJsonData.files = kmpJsonData.files.filter(file => !KeymanFileTypes.filenameIs(file.name, KeymanFileTypes.Binary.Keyboard)); const kmxFiles: { filename: string, data: KMX.KEYBOARD - }[] = compiler['loadKmxFiles'](kpsFilename, kmpJsonData); + }[] = compiler['loadKmxFiles'](KHMER_ANGKOR_KPS, kmpJsonData); assert.deepEqual(kmxFiles, []); }); it('check loadKmxFiles throws error if .kmx file is missing from disk', async function() { - const kpsFilename = KHMER_ANGKOR_KPS; const compiler = new KeyboardInfoCompiler(); const kmpCompiler = new KmpCompiler(); assert.isTrue(await kmpCompiler.init(callbacks, {})); - const kmpJsonData = kmpCompiler.transformKpsToKmpObject(kpsFilename); + const kmpJsonData = kmpCompiler.transformKpsToKmpObject(KHMER_ANGKOR_KPS); assert.isNotNull(kmpJsonData); // rename .kmx file in files list so it cannot be loaded from disk const kmpIndex = kmpJsonData.files.findIndex(file => KeymanFileTypes.filenameIs(file.name, KeymanFileTypes.Binary.Keyboard)); kmpJsonData.files[kmpIndex].name = '../build/throw_error.kmx'; - assert.throws(() => compiler['loadKmxFiles'](kpsFilename, kmpJsonData)); + assert.throws(() => compiler['loadKmxFiles'](KHMER_ANGKOR_KPS, kmpJsonData)); }); it('check loadKmxFiles can handle two .kmx files', async function() { From 90e999965745869642caeb85294c66ab3ca93956 Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Thu, 25 Apr 2024 11:20:48 +0100 Subject: [PATCH 07/48] chore(developer): replace some local variables with constants --- .../test/test-keyboard-info-compiler.ts | 57 +++++++------------ 1 file changed, 20 insertions(+), 37 deletions(-) diff --git a/developer/src/kmc-keyboard-info/test/test-keyboard-info-compiler.ts b/developer/src/kmc-keyboard-info/test/test-keyboard-info-compiler.ts index 47e16dc5f8..c25a1eab1f 100644 --- a/developer/src/kmc-keyboard-info/test/test-keyboard-info-compiler.ts +++ b/developer/src/kmc-keyboard-info/test/test-keyboard-info-compiler.ts @@ -146,7 +146,6 @@ describe('keyboard-info-compiler', function () { }); it('check run returns null if KmpCompiler.transformKpsToKmpObject fails', async function() { - const kpjFilename = KHMER_ANGKOR_KPJ; const sources = KHMER_ANGKOR_SOURCES; const compiler = new KeyboardInfoCompiler(); assert.isTrue(await compiler.init(callbacks, {sources})); @@ -154,7 +153,7 @@ describe('keyboard-info-compiler', function () { let result: KeyboardInfoCompilerResult; try { KmpCompiler.prototype.transformKpsToKmpObject = (_kpsFilename: string): KmpJsonFile.KmpJsonFile => null; - result = await compiler.run(kpjFilename, null); + result = await compiler.run(KHMER_ANGKOR_KPJ, null); } catch(e) { assert.fail(e); } finally { @@ -164,40 +163,36 @@ describe('keyboard-info-compiler', function () { }); it('check run returns null if loadJsFile fails', async function() { - const kpjFilename = KHMER_ANGKOR_KPJ; const sources = KHMER_ANGKOR_SOURCES const compiler = new KeyboardInfoCompiler(); assert.isTrue(await compiler.init(callbacks, {sources})); compiler['loadJsFile'] = (_filename: string): string => null; - const result = await compiler.run(kpjFilename, null); + const result = await compiler.run(KHMER_ANGKOR_KPJ, null); assert.isNull(result); }); it('check run returns null if license is not MIT', async function() { - const kpjFilename = KHMER_ANGKOR_KPJ; const sources = KHMER_ANGKOR_SOURCES; const compiler = new KeyboardInfoCompiler(); assert.isTrue(await compiler.init(callbacks, {sources})); compiler['isLicenseMIT'] = (_filename: string): boolean => false; - const result = await compiler.run(kpjFilename, null); + const result = await compiler.run(KHMER_ANGKOR_KPJ, null); assert.isNull(result); }); it('check run leaves keyboard_info.isRTL undefined if not set in jsFile', async function() { - const kpjFilename = KHMER_ANGKOR_KPJ; const sources = KHMER_ANGKOR_SOURCES; const compiler = new KeyboardInfoCompiler(); assert.isTrue(await compiler.init(callbacks, {sources})); const jsFile = compiler['loadJsFile'](sources.jsFilename); assert.isNull(jsFile.match(/this\.KRTL=1/)); - const result = await compiler.run(kpjFilename, null); + const result = await compiler.run(KHMER_ANGKOR_KPJ, null); assert.isNotNull(result); const keyboard_info = JSON.parse(new TextDecoder().decode(result.artifacts.keyboard_info.data)); assert.isUndefined(keyboard_info.isRTL); }); it('check run sets keyboard_info.isRTL if set in jsFile', async function() { - const kpjFilename = KHMER_ANGKOR_KPJ; const sources = KHMER_ANGKOR_SOURCES; const compiler = new KeyboardInfoCompiler(); assert.isTrue(await compiler.init(callbacks, {sources})); @@ -205,7 +200,7 @@ describe('keyboard-info-compiler', function () { jsFile = jsFile.replace('this\.KN="Khmer Angkor";', '$&\n this\.KRTL=1;'); // insert this.KRTL=1 const origCompilerLoadJsFile = compiler['loadJsFile']; compiler['loadJsFile'] = (_filename: string) => jsFile; - const result = await compiler.run(kpjFilename, null); + const result = await compiler.run(KHMER_ANGKOR_KPJ, null); compiler['loadJsFile'] = origCompilerLoadJsFile; assert.isNotNull(result); const keyboard_info = JSON.parse(new TextDecoder().decode(result.artifacts.keyboard_info.data)); @@ -213,7 +208,6 @@ describe('keyboard-info-compiler', function () { }); it('check run sets author.url correctly if mailto provided', async function() { - const kpjFilename = KHMER_ANGKOR_KPJ; const sources = KHMER_ANGKOR_SOURCES; const compiler = new KeyboardInfoCompiler(); assert.isTrue(await compiler.init(callbacks, {sources})); @@ -221,14 +215,13 @@ describe('keyboard-info-compiler', function () { await kmpCompiler.init(callbacks, {}); const kmpJsonData = kmpCompiler.transformKpsToKmpObject(sources.kpsFilename); assert.isNotNull(kmpJsonData.info.author.url.match(/^mailto\:/)); - const result = await compiler.run(kpjFilename, null); + const result = await compiler.run(KHMER_ANGKOR_KPJ, null); assert.isNotNull(result); const keyboard_info = JSON.parse(new TextDecoder().decode(result.artifacts.keyboard_info.data)); assert.deepEqual(keyboard_info.authorEmail, 'makara_sok@sil.org'); }); it('check run sets author.url correctly if just email provided', async function() { - const kpjFilename = KHMER_ANGKOR_KPJ; const sources = KHMER_ANGKOR_SOURCES; const compiler = new KeyboardInfoCompiler(); assert.isTrue(await compiler.init(callbacks, {sources})); @@ -240,7 +233,7 @@ describe('keyboard-info-compiler', function () { let result: KeyboardInfoCompilerResult; try { KmpCompiler.prototype.transformKpsToKmpObject = (_kpsFilename: string): KmpJsonFile.KmpJsonFile => kmpJsonData; - result = await compiler.run(kpjFilename, null); + result = await compiler.run(KHMER_ANGKOR_KPJ, null); } catch(e) { assert.fail(e); } finally { @@ -252,12 +245,11 @@ describe('keyboard-info-compiler', function () { }); it('check run returns null if fillLanguages fails', async function() { - const kpjFilename = KHMER_ANGKOR_KPJ; const sources = KHMER_ANGKOR_SOURCES; const compiler = new KeyboardInfoCompiler(); assert.isTrue(await compiler.init(callbacks, {sources})); compiler['fillLanguages'] = async (_kpsFilename: string, _keyboard_info: KeyboardInfoFile, _kmpJsonData: KmpJsonFile.KmpJsonFile): Promise => false; - const result = await compiler.run(kpjFilename, null); + const result = await compiler.run(KHMER_ANGKOR_KPJ, null); assert.isNull(result); }); @@ -283,7 +275,6 @@ describe('keyboard-info-compiler', function () { ]; packageIncludesTestCases.forEach((testCase, idx) => it(`check run sets packageIncludes correctly (test case #${idx})`, async function() { - const kpjFilename = KHMER_ANGKOR_KPJ; const sources = KHMER_ANGKOR_SOURCES; const compiler = new KeyboardInfoCompiler(); assert.isTrue(await compiler.init(callbacks, {sources})); @@ -291,17 +282,16 @@ describe('keyboard-info-compiler', function () { compiler['fontSourceToKeyboardInfoFont'] = async (_kpsFilename: string, _kmpJsonData: KmpJsonFile.KmpJsonFile, _source: string[]) => { return (_source[0] == KHMER_ANGKOR_DISPLAY_FONT) ? KHMER_ANGKOR_DISPLAY_FONT_INFO : KHMER_ANGKOR_OSK_FONT_INFO; } - const kpsFilename = KHMER_ANGKOR_KPS; const kmpCompiler = new KmpCompiler(); assert.isTrue(await kmpCompiler.init(callbacks, {})); - const kmpJsonData = kmpCompiler.transformKpsToKmpObject(kpsFilename); + const kmpJsonData = kmpCompiler.transformKpsToKmpObject(KHMER_ANGKOR_KPS); assert.isNotNull(kmpJsonData); const origKmpCompilerTransformKpsToKmpObject = KmpCompiler.prototype.transformKpsToKmpObject; kmpJsonData.files = testCase.files; let result: KeyboardInfoCompilerResult; try { KmpCompiler.prototype.transformKpsToKmpObject = (_kpsFilename: string): KmpJsonFile.KmpJsonFile => kmpJsonData; - result = await compiler.run(kpjFilename, null); + result = await compiler.run(KHMER_ANGKOR_KPJ, null); } catch(e) { assert.fail(e); } finally { @@ -321,7 +311,6 @@ describe('keyboard-info-compiler', function () { ]; minKeymanVersionTestCases.forEach((testCase, idx) => it(`check run sets minKeymanVersion correctly (test case #${idx})`, async function() { - const kpjFilename = KHMER_ANGKOR_KPJ; const sources = KHMER_ANGKOR_SOURCES; const compiler = new KeyboardInfoCompiler(); assert.isTrue(await compiler.init(callbacks, {sources})); @@ -332,7 +321,7 @@ describe('keyboard-info-compiler', function () { jsFile = jsFile.replace('this.KMINVER="10.0";', insert); compiler['loadJsFile'] = (_filename: string) => jsFile; compiler['kmxFileVersionToString'] = (_version: number) => testCase.kmx; - const result = await compiler.run(kpjFilename, null); + const result = await compiler.run(KHMER_ANGKOR_KPJ, null); compiler['loadJsFile'] = origCompilerLoadJsFile; compiler['kmxFileVersionToString'] = origKmxFileVersionToString; assert.isNotNull(result); @@ -353,14 +342,12 @@ describe('keyboard-info-compiler', function () { ]; platformsTestCases.forEach((testCase, idx) => it(`check run sets platforms correctly (test case #${idx})`, async function() { - const kpjFilename = KHMER_ANGKOR_KPJ; const sources = KHMER_ANGKOR_SOURCES; const compiler = new KeyboardInfoCompiler(); assert.isTrue(await compiler.init(callbacks, {sources})); - const kpsFilename = KHMER_ANGKOR_KPS; const kmpCompiler = new KmpCompiler(); assert.isTrue(await kmpCompiler.init(callbacks, {})); - const kmpJsonData = kmpCompiler.transformKpsToKmpObject(kpsFilename); + const kmpJsonData = kmpCompiler.transformKpsToKmpObject(KHMER_ANGKOR_KPS); assert.isNotNull(kmpJsonData); if (!testCase.hasJsFileInKps) { // remove .js file @@ -369,7 +356,7 @@ describe('keyboard-info-compiler', function () { const kmxFiles: { filename: string, data: KMX.KEYBOARD - }[] = compiler['loadKmxFiles'](kpsFilename, kmpJsonData); + }[] = compiler['loadKmxFiles'](KHMER_ANGKOR_KPS, kmpJsonData); // set targets kmxFiles[0].data.targets = testCase.targets; const origLoadKmxFiles = compiler['loadKmxFiles']; @@ -378,7 +365,7 @@ describe('keyboard-info-compiler', function () { try { KmpCompiler.prototype.transformKpsToKmpObject = (_kpsFilename: string): KmpJsonFile.KmpJsonFile => kmpJsonData; compiler['loadKmxFiles'] = (_kpsFilename: string, _kmpJsonData: KmpJsonFile.KmpJsonFile) => kmxFiles; - result = await compiler.run(kpjFilename, null); + result = await compiler.run(KHMER_ANGKOR_KPJ, null); } catch(e) { assert.fail(e); } finally { @@ -391,7 +378,6 @@ describe('keyboard-info-compiler', function () { })); it('check run sets related packages correctly', async function() { - const kpjFilename = KHMER_ANGKOR_KPJ; const sources = KHMER_ANGKOR_SOURCES; const compiler = new KeyboardInfoCompiler(); assert.isTrue(await compiler.init(callbacks, {sources})); @@ -407,7 +393,7 @@ describe('keyboard-info-compiler', function () { let result: KeyboardInfoCompilerResult; try { KmpCompiler.prototype.transformKpsToKmpObject = (_kpsFilename: string): KmpJsonFile.KmpJsonFile => kmpJsonData; - result = await compiler.run(kpjFilename, null); + result = await compiler.run(KHMER_ANGKOR_KPJ, null); } catch(e) { assert.fail(e); } finally { @@ -421,14 +407,13 @@ describe('keyboard-info-compiler', function () { }); it('should write artifacts to disk', async function() { - const kpjFilename = KHMER_ANGKOR_KPJ; const actualFilename = makePathToFixture('khmer_angkor', 'build', 'actual.keyboard_info'); const expectedFilename = makePathToFixture('khmer_angkor', 'build', 'khmer_angkor.keyboard_info'); const sources = KHMER_ANGKOR_SOURCES; const compiler = new KeyboardInfoCompiler(); assert.isTrue(await compiler.init(callbacks, {sources})); - const result = await compiler.run(kpjFilename, null); + const result = await compiler.run(KHMER_ANGKOR_KPJ, null); assert.isNotNull(result); if(fs.existsSync(actualFilename)) { @@ -489,32 +474,30 @@ describe('keyboard-info-compiler', function () { }); it('check loadKmxFiles returns empty array if .kmx file is missing from .kmp', async function() { - const kpsFilename = KHMER_ANGKOR_KPS; const compiler = new KeyboardInfoCompiler(); const kmpCompiler = new KmpCompiler(); assert.isTrue(await kmpCompiler.init(callbacks, {})); - const kmpJsonData = kmpCompiler.transformKpsToKmpObject(kpsFilename); + const kmpJsonData = kmpCompiler.transformKpsToKmpObject(KHMER_ANGKOR_KPS); assert.isNotNull(kmpJsonData); // remove .kmx file kmpJsonData.files = kmpJsonData.files.filter(file => !KeymanFileTypes.filenameIs(file.name, KeymanFileTypes.Binary.Keyboard)); const kmxFiles: { filename: string, data: KMX.KEYBOARD - }[] = compiler['loadKmxFiles'](kpsFilename, kmpJsonData); + }[] = compiler['loadKmxFiles'](KHMER_ANGKOR_KPS, kmpJsonData); assert.deepEqual(kmxFiles, []); }); it('check loadKmxFiles throws error if .kmx file is missing from disk', async function() { - const kpsFilename = KHMER_ANGKOR_KPS; const compiler = new KeyboardInfoCompiler(); const kmpCompiler = new KmpCompiler(); assert.isTrue(await kmpCompiler.init(callbacks, {})); - const kmpJsonData = kmpCompiler.transformKpsToKmpObject(kpsFilename); + const kmpJsonData = kmpCompiler.transformKpsToKmpObject(KHMER_ANGKOR_KPS); assert.isNotNull(kmpJsonData); // rename .kmx file in files list so it cannot be loaded from disk const kmpIndex = kmpJsonData.files.findIndex(file => KeymanFileTypes.filenameIs(file.name, KeymanFileTypes.Binary.Keyboard)); kmpJsonData.files[kmpIndex].name = '../build/throw_error.kmx'; - assert.throws(() => compiler['loadKmxFiles'](kpsFilename, kmpJsonData)); + assert.throws(() => compiler['loadKmxFiles'](KHMER_ANGKOR_KPS, kmpJsonData)); }); it('check loadKmxFiles can handle two .kmx files', async function() { From 179fac39f2b0cd91a9f190e400e9821b9cd60c02 Mon Sep 17 00:00:00 2001 From: Keyman Build Agent Date: Thu, 2 May 2024 14:05:02 -0400 Subject: [PATCH 08/48] auto: increment beta version to 17.0.319 --- HISTORY.md | 5 +++++ VERSION.md | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/HISTORY.md b/HISTORY.md index efff32b1a4..ce2e51e9a0 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,5 +1,10 @@ # Keyman Version History +## 17.0.318 beta 2024-05-02 + +* fix(web): longpress shortcut activation should only consider northward part (#11306) +* chore(ios,mac): support build on Apple Silicon using Xcode 15.3 (#11302) + ## 17.0.317 beta 2024-05-01 * (#11322) diff --git a/VERSION.md b/VERSION.md index 7f479d3db1..d64b9fd77a 100644 --- a/VERSION.md +++ b/VERSION.md @@ -1 +1 @@ -17.0.318 \ No newline at end of file +17.0.319 \ No newline at end of file From 6706ae0957a615dad68da395e1062b4579cf19e4 Mon Sep 17 00:00:00 2001 From: "Steven R. Loomis" Date: Thu, 2 May 2024 17:39:15 -0500 Subject: [PATCH 09/48] chore(core): km_core_cp -> km_core_cu - km_core_cp represents a 16 bit code unit, not a code point. Fixes: #11033 --- common/include/km_types.h | 8 +- core/include/keyman/keyman_core_api.h | 36 ++++---- core/include/keyman/keyman_core_api_debug.h | 6 +- core/src/context.hpp | 8 +- core/src/context_helpers.cpp | 10 +-- core/src/km_core_context_api.cpp | 4 +- core/src/km_core_options_api.cpp | 4 +- core/src/km_core_state_api.cpp | 22 ++--- .../km_core_state_context_set_if_needed.cpp | 16 ++-- core/src/kmx/kmx_debugger.cpp | 2 +- core/src/kmx/kmx_environment.cpp | 2 +- core/src/kmx/kmx_environment.h | 4 +- core/src/kmx/kmx_processevent.cpp | 4 +- core/src/kmx/kmx_xstring.cpp | 28 +++---- core/src/kmx/kmx_xstring.h | 18 ++-- core/src/option.cpp | 4 +- .../tests/kmx_test_source/kmx_test_source.cpp | 10 +-- core/tests/unit/kmnkbd/action_set_api.cpp | 2 +- core/tests/unit/kmnkbd/context_api.cpp | 14 ++-- core/tests/unit/kmnkbd/options_api.cpp | 4 +- core/tests/unit/kmnkbd/state_context_api.cpp | 84 +++++++++---------- .../unit/kmnkbd/test_actions_get_api.cpp | 8 +- .../unit/kmnkbd/test_actions_normalize.cpp | 22 ++--- core/tests/unit/kmx/kmx.cpp | 6 +- core/tests/unit/kmx/kmx_imx.cpp | 4 +- core/tests/unit/ldml/ldml.cpp | 2 +- core/tests/unit/ldml/ldml_test_source.cpp | 12 +-- .../unit/ldml/test_context_normalization.cpp | 24 +++--- developer/src/kmcmplib/src/Compiler.cpp | 2 +- .../debug/Keyman.System.Debug.DebugCore.pas | 16 ++-- .../tike/main/Keyman.System.KeymanCore.pas | 16 ++-- .../main/Keyman.System.KeymanCoreDebug.pas | 6 +- linux/debian/libkeymancore1.symbols | 2 +- linux/ibus-keyman/src/engine.c | 14 ++-- linux/ibus-keyman/src/keymanutil.c | 2 +- .../CoreWrapper/CoreWrapper.m | 10 +-- .../src/engine/keyman32/CoreEnvironment.cpp | 4 +- windows/src/engine/keyman32/appcontext.cpp | 2 +- windows/src/engine/keyman32/calldll.cpp | 4 +- .../src/engine/keyman32/keyboardoptions.cpp | 8 +- windows/src/engine/keyman32/kmprocess.cpp | 6 +- .../keyboardoptionstests.cpp | 6 +- 42 files changed, 233 insertions(+), 233 deletions(-) diff --git a/common/include/km_types.h b/common/include/km_types.h index 0ae6252752..f0bb906c8a 100644 --- a/common/include/km_types.h +++ b/common/include/km_types.h @@ -28,14 +28,14 @@ typedef uint8_t KMX_BYTE; typedef uint16_t KMX_WORD; #if defined(__cplusplus) -typedef char16_t km_core_cp; +typedef char16_t km_core_cu; typedef char32_t km_core_usv; #else -typedef uint16_t km_core_cp; // code point +typedef uint16_t km_core_cu; // code point typedef uint32_t km_core_usv; // Unicode Scalar Value #endif -typedef km_core_cp KMX_WCHAR; // wc, 16-bit UNICODE character +typedef km_core_cu KMX_WCHAR; // wc, 16-bit UNICODE character typedef KMX_WCHAR* PKMX_WCHAR; typedef char KMX_CHAR; @@ -60,7 +60,7 @@ typedef KMX_DWORD* PKMX_DWORD; #ifdef USE_CHAR16_T #define lpuch(x) u ## x -typedef km_core_cp KMX_UCHAR; +typedef km_core_cu KMX_UCHAR; #else #define lpuch(x) L ## x typedef wchar_t KMX_UCHAR; diff --git a/core/include/keyman/keyman_core_api.h b/core/include/keyman/keyman_core_api.h index 724b30299f..328965e876 100644 --- a/core/include/keyman/keyman_core_api.h +++ b/core/include/keyman/keyman_core_api.h @@ -205,7 +205,7 @@ interface. Fundamental types for representing data passed across the API. -### km_core_cp type +### km_core_cu type `uint16_t/char16_t` @@ -683,7 +683,7 @@ KMN_API km_core_context_status km_core_state_context_set_if_needed( km_core_state *state, - km_core_cp const *application_context + km_core_cu const *application_context ); /* @@ -800,8 +800,8 @@ Platform layer. ## Specification ```c */ struct km_core_option_item { - km_core_cp const * key; - km_core_cp const * value; + km_core_cu const * key; + km_core_cu const * value; uint8_t scope; }; @@ -860,8 +860,8 @@ KMN_API km_core_status km_core_state_option_lookup(km_core_state const *state, uint8_t scope, - km_core_cp const *key, - km_core_cp const **value); + km_core_cu const *key, + km_core_cu const **value); /* ``` @@ -1005,8 +1005,8 @@ Provides read-only information about a keyboard. ```c */ typedef struct { - km_core_cp const * version_string; - km_core_cp const * id; + km_core_cu const * version_string; + km_core_cu const * id; km_core_path_name folder_path; km_core_option_item const * default_options; } km_core_keyboard_attrs; @@ -1070,8 +1070,8 @@ Describes a single Input Method eXtension library and entry point. ```c */ typedef struct { - km_core_cp const * library_name; - km_core_cp const * function_name; + km_core_cu const * library_name; + km_core_cu const * function_name; uint32_t imx_id; } km_core_keyboard_imx; @@ -1332,7 +1332,7 @@ void km_core_state_imx_register_callback(km_core_state *state, km_core_keyboard_ : pointer to a function that implements the IMX callback `callback_object` -: An opaque pointer that can be used to pass context information to the callback function, +: An opaque pointer that can be used to pass context information to the callback function, usually it is a user-defined data structure. ------------------------------------------------------------------------------- @@ -1523,7 +1523,7 @@ Returns a debug formatted string of the context from the state. ```c */ KMN_API -km_core_cp * +km_core_cu * km_core_state_context_debug(km_core_state *state, km_core_debug_context_type context_type); /* @@ -1538,16 +1538,16 @@ km_core_state_context_debug(km_core_state *state, km_core_debug_context_type con ## Returns -A pointer to a [km_core_cp] UTF-16 string. Must be disposed of by a call -to [km_core_cp_dispose]. +A pointer to a [km_core_cu] UTF-16 string. Must be disposed of by a call +to [km_core_cu_dispose]. ------------------------------------------------------------------------------- -# km_core_cp_dispose() +# km_core_cu_dispose() ## Description -Free the allocated memory belonging to a [km_core_cp] array previously +Free the allocated memory belonging to a [km_core_cu] array previously returned by [km_core_state_context_debug]. May be `nullptr`. ## Specification @@ -1555,14 +1555,14 @@ returned by [km_core_state_context_debug]. May be `nullptr`. ```c */ KMN_API void -km_core_cp_dispose(km_core_cp *cp); +km_core_cu_dispose(km_core_cu *cp); /* ``` ## Parameters `cp` -: A pointer to the start of the [km_core_cp] array to be disposed of. +: A pointer to the start of the [km_core_cu] array to be disposed of. ------------------------------------------------------------------------------- diff --git a/core/include/keyman/keyman_core_api_debug.h b/core/include/keyman/keyman_core_api_debug.h index 8f80481d2c..493de708a4 100644 --- a/core/include/keyman/keyman_core_api_debug.h +++ b/core/include/keyman/keyman_core_api_debug.h @@ -24,7 +24,7 @@ extern "C" #endif /** - * The maximum size of context in km_core_cp units for a single debug + * The maximum size of context in km_core_cu units for a single debug * event. This is taken from MAXCONTEXT in keyman32 (Windows) and is purely * a convenience value. We can increase it if there is a demonstrated need. */ @@ -65,7 +65,7 @@ typedef struct { */ typedef struct { void *store; // LPSTORE - km_core_cp value[DEBUG_MAX_CONTEXT]; // value to be saved into the store + km_core_cu value[DEBUG_MAX_CONTEXT]; // value to be saved into the store } km_core_state_debug_kmx_option_info; /** @@ -80,7 +80,7 @@ typedef struct { */ typedef struct { - km_core_cp context[DEBUG_MAX_CONTEXT]; // The context matched by the rule (? may not need this?) // TODO: rename to context_matched + km_core_cu context[DEBUG_MAX_CONTEXT]; // The context matched by the rule (? may not need this?) // TODO: rename to context_matched void *group; // LPGROUP void *rule; // LPKEY uint16_t store_offsets[DEBUG_STORE_OFFSETS_SIZE]; // pairs--store, char position, terminated by 0xFFFF // TODO use a better structure here diff --git a/core/src/context.hpp b/core/src/context.hpp index bcab65f85d..91cc9688cd 100644 --- a/core/src/context.hpp +++ b/core/src/context.hpp @@ -45,8 +45,8 @@ void context::push_marker(uint32_t marker) { // Context helper functions -km_core_cp* get_context_as_string(km_core_context *context); -km_core_status set_context_from_string(km_core_context *context, km_core_cp const *new_context); +km_core_cu* get_context_as_string(km_core_context *context); +km_core_status set_context_from_string(km_core_context *context, km_core_cu const *new_context); } // namespace core } // namespace km @@ -84,7 +84,7 @@ struct km_core_context : public km::core::context * `km_core_context_items_dispose`. */ km_core_status -context_items_from_utf16(km_core_cp const *text, +context_items_from_utf16(km_core_cu const *text, km_core_context_item **out_ptr); /** @@ -113,7 +113,7 @@ context_items_from_utf16(km_core_cp const *text, */ km_core_status context_items_to_utf16(km_core_context_item const *item, - km_core_cp *buf, + km_core_cu *buf, size_t *buf_size); /** diff --git a/core/src/context_helpers.cpp b/core/src/context_helpers.cpp index 6c687f3200..ff59c6a233 100644 --- a/core/src/context_helpers.cpp +++ b/core/src/context_helpers.cpp @@ -13,9 +13,9 @@ using namespace km::core; /** - * Retrieves the context as a km_core_cp string, dropping markers + * Retrieves the context as a km_core_cu string, dropping markers */ -km_core_cp* km::core::get_context_as_string(km_core_context *context) { +km_core_cu* km::core::get_context_as_string(km_core_context *context) { assert(context != nullptr); if(context == nullptr) { return nullptr; @@ -33,7 +33,7 @@ km_core_cp* km::core::get_context_as_string(km_core_context *context) { return nullptr; } - km_core_cp *app_context_string = new km_core_cp[buf_size]; + km_core_cu *app_context_string = new km_core_cu[buf_size]; km_core_status status = context_items_to_utf16(context_items, app_context_string, &buf_size); km_core_context_items_dispose(context_items); @@ -46,9 +46,9 @@ km_core_cp* km::core::get_context_as_string(km_core_context *context) { } /** - * Updates the context from the new_context km_core_cp string + * Updates the context from the new_context km_core_cu string */ -km_core_status km::core::set_context_from_string(km_core_context *context, km_core_cp const *new_context) { +km_core_status km::core::set_context_from_string(km_core_context *context, km_core_cu const *new_context) { assert(context != nullptr); assert(new_context != nullptr); if(context == nullptr || new_context == nullptr) { diff --git a/core/src/km_core_context_api.cpp b/core/src/km_core_context_api.cpp index 980aa6f298..dd27ab7e5c 100644 --- a/core/src/km_core_context_api.cpp +++ b/core/src/km_core_context_api.cpp @@ -108,7 +108,7 @@ namespace { } km_core_status -context_items_from_utf16(km_core_cp const *text, +context_items_from_utf16(km_core_cu const *text, km_core_context_item **out_ptr) { return _context_items_from(reinterpret_cast(text), out_ptr); @@ -125,7 +125,7 @@ km_core_status context_items_to_utf8(km_core_context_item const *ci, km_core_status context_items_to_utf16(km_core_context_item const *ci, - km_core_cp *buf, size_t * sz_ptr) + km_core_cu *buf, size_t * sz_ptr) { return _context_items_to(ci, reinterpret_cast(buf), diff --git a/core/src/km_core_options_api.cpp b/core/src/km_core_options_api.cpp index 4ea5c74062..4811ee9161 100644 --- a/core/src/km_core_options_api.cpp +++ b/core/src/km_core_options_api.cpp @@ -36,8 +36,8 @@ km_core_options_list_size(km_core_option_item const *opts) km_core_status km_core_state_option_lookup(km_core_state const *state, - uint8_t scope, km_core_cp const *key, - km_core_cp const **value_out) + uint8_t scope, km_core_cu const *key, + km_core_cu const **value_out) { assert(state); assert(key); assert(value_out); if (!state || !key || !value_out) return KM_CORE_STATUS_INVALID_ARGUMENT; diff --git a/core/src/km_core_state_api.cpp b/core/src/km_core_state_api.cpp index 0f3fd7f112..16af9511d8 100644 --- a/core/src/km_core_state_api.cpp +++ b/core/src/km_core_state_api.cpp @@ -285,22 +285,22 @@ km_core_status km_core_state_context_clear( return KM_CORE_STATUS_OK; } -void km_core_cp_dispose( - km_core_cp *cp +void km_core_cu_dispose( + km_core_cu *cp ) { if(cp != nullptr) { delete [] cp; } } -km_core_cp * _new_error_string(std::u16string const str) { - km_core_cp* result = new km_core_cp[str.size()+1]; +km_core_cu * _new_error_string(std::u16string const str) { + km_core_cu* result = new km_core_cu[str.size()+1]; str.copy(result, str.size()); result[str.size()] = 0; return result; } -km_core_cp * km_core_state_context_debug( +km_core_cu * km_core_state_context_debug( km_core_state *state, km_core_debug_context_type context_type ) { @@ -359,7 +359,7 @@ km_core_cp * km_core_state_context_debug( std::u16string s = std::wstring_convert, char16_t>{}.from_bytes(buffer.str()); - km_core_cp* result = new km_core_cp[s.size() + 1]; + km_core_cu* result = new km_core_cu[s.size() + 1]; s.copy(result, s.size()); result[s.size()] = 0; @@ -385,11 +385,11 @@ state_should_invalidate_context(km_core_state *state, // if emit_keystroke is present, check if a context reset is needed if (state_has_action_type(state, KM_CORE_IT_EMIT_KEYSTROKE)) { if ( - // when a backspace keystroke is emitted, it is because we are at the start of - // context, and we want to give the application the chance to process it, e.g. - // by moving to previous field. Note that context manipulation does not result - // in an emit_keystroke backspace action, as this is handled through the - // `code_points_to_delete` field. So we always invalidate context when a + // when a backspace keystroke is emitted, it is because we are at the start of + // context, and we want to give the application the chance to process it, e.g. + // by moving to previous field. Note that context manipulation does not result + // in an emit_keystroke backspace action, as this is handled through the + // `code_points_to_delete` field. So we always invalidate context when a // processor emits a backspace. vk == KM_CORE_VKEY_BKSP || // certain modifiers invalidate context diff --git a/core/src/km_core_state_context_set_if_needed.cpp b/core/src/km_core_state_context_set_if_needed.cpp index 7107815249..70dd5fddb7 100644 --- a/core/src/km_core_state_context_set_if_needed.cpp +++ b/core/src/km_core_state_context_set_if_needed.cpp @@ -39,12 +39,12 @@ typedef struct { // Forward declarations -bool replace_context(context_change_result context_change, km_core_context *context, km_core_cp const *new_context); +bool replace_context(context_change_result context_change, km_core_context *context, km_core_cu const *new_context); bool should_normalize(km_core_state *state); -context_change_result get_context_change(km_core_cp const *new_context, km_core_context *context); +context_change_result get_context_change(km_core_cu const *new_context, km_core_context *context); context_change_result get_context_items_change(km_core_context_item *new_context_items, km_core_context_item *context_items); -bool do_normalize_nfd(km_core_cp const * src, std::u16string &dst); +bool do_normalize_nfd(km_core_cu const * src, std::u16string &dst); km_core_context_status do_fail(km_core_context *app_context, km_core_context *cached_context, const char* error); // --------------------------------------------------------------------------- @@ -52,7 +52,7 @@ km_core_context_status do_fail(km_core_context *app_context, km_core_context *ca km_core_context_status km_core_state_context_set_if_needed( km_core_state *state, - km_core_cp const *new_app_context + km_core_cu const *new_app_context ) { assert(state != nullptr); assert(new_app_context != nullptr); @@ -91,7 +91,7 @@ km_core_state_context_set_if_needed( // Finally, we normalize and replace the cached context std::u16string normalized_buffer; - km_core_cp const *new_cached_context = nullptr; + km_core_cu const *new_cached_context = nullptr; if (should_normalize(state)) { if (!do_normalize_nfd(new_app_context, normalized_buffer)) { @@ -128,7 +128,7 @@ bool replace_context( context_change_result context_change, km_core_context *context, - km_core_cp const *new_context + km_core_cu const *new_context ) { if (context_change.type == CONTEXT_DIFFERENT) { if (set_context_from_string(context, new_context) != KM_CORE_STATUS_OK) { @@ -189,7 +189,7 @@ context_previous_char( */ context_change_result get_context_change( - km_core_cp const *new_context_string, + km_core_cu const *new_context_string, km_core_context *context ) { context_change_result change_type({CONTEXT_DIFFERENT, 0}); @@ -286,7 +286,7 @@ get_context_items_change( /** * Normalize the input string using ICU */ -bool do_normalize_nfd(km_core_cp const * src, std::u16string &dst) { +bool do_normalize_nfd(km_core_cu const * src, std::u16string &dst) { UErrorCode icu_status = U_ZERO_ERROR; const icu::Normalizer2 *nfd = icu::Normalizer2::getNFDInstance(icu_status); assert(U_SUCCESS(icu_status)); diff --git a/core/src/kmx/kmx_debugger.cpp b/core/src/kmx/kmx_debugger.cpp index 374175a650..f380e28942 100644 --- a/core/src/kmx/kmx_debugger.cpp +++ b/core/src/kmx/kmx_debugger.cpp @@ -61,7 +61,7 @@ void KMX_DebugItems::fill_store_offsets(km_core_state_debug_kmx_info *info, PKMX int i, n; - km_core_cp *p; + km_core_cu *p; // TODO turn this into a struct rather than interwoven values for(i = n = 0, p = static_cast(info->rule)->dpContext; p && *p; p = incxstr(p), i++) { diff --git a/core/src/kmx/kmx_environment.cpp b/core/src/kmx/kmx_environment.cpp index 1260f0f4be..bd4d57d0e7 100644 --- a/core/src/kmx/kmx_environment.cpp +++ b/core/src/kmx/kmx_environment.cpp @@ -11,7 +11,7 @@ using namespace km::core; using namespace kmx; namespace { - km_core_cp const + km_core_cu const *DEFAULT_PLATFORM = u"windows hardware desktop native", *DEFAULT_BASELAYOUT = u"kbdus.dll", *DEFAULT_BASELAYOUTALT = u"en-US", diff --git a/core/src/kmx/kmx_environment.h b/core/src/kmx/kmx_environment.h index 6202333b73..0cb90bed28 100644 --- a/core/src/kmx/kmx_environment.h +++ b/core/src/kmx/kmx_environment.h @@ -15,8 +15,8 @@ private: std::u16string _platform; void InitOption( std::vector