Skip to content

Commit

Permalink
feat(developer): support store(&version) '17.0'
Browse files Browse the repository at this point in the history
Fixes #9541.

Also adds version 16.0 support to the kmcmplib compiler constants, and
unit tests for both versions. Does not add any support for automatic
version feature detection, because that forces an inverted dependency on
the touch layout compilation phase (done in kmc-kmw), which would be a
significant refactor. This may be something we need to support in the
future.
  • Loading branch information
mcdurdin committed Oct 2, 2023
1 parent 966e5db commit 7adc9b5
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 5 deletions.
3 changes: 2 additions & 1 deletion common/include/kmx_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,10 @@ namespace kmx {
#define VERSION_150 0x00000F00

#define VERSION_160 0x00001000
#define VERSION_170 0x00001100

#define VERSION_MIN VERSION_50
#define VERSION_MAX VERSION_160
#define VERSION_MAX VERSION_170

//
// Backspace types
Expand Down
3 changes: 2 additions & 1 deletion common/web/types/src/kmx/kmx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,10 @@ export class KMXFile {
public static readonly VERSION_150 = 0x00000F00;

public static readonly VERSION_160 = 0x00001000;
public static readonly VERSION_170 = 0x00001100;

public static readonly VERSION_MIN = this.VERSION_50;
public static readonly VERSION_MAX = this.VERSION_160;
public static readonly VERSION_MAX = this.VERSION_170;

//
// Backspace types
Expand Down
3 changes: 2 additions & 1 deletion common/windows/cpp/include/legacy_kmx_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@
#define VERSION_140 0x00000E00
#define VERSION_150 0x00000F00
#define VERSION_160 0x00001000
#define VERSION_170 0x00001100
#define VERSION_MIN VERSION_50
#define VERSION_MAX VERSION_160
#define VERSION_MAX VERSION_170

/*
Special flag for WM_CHAR/WM_KEY???/WM_SYSKEY???: says that key has been
Expand Down
3 changes: 2 additions & 1 deletion common/windows/delphi/keyboards/kmxfileconsts.pas
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,10 @@ interface
VERSION_140 = $00000E00;
VERSION_150 = $00000F00;
VERSION_160 = $00001000;
VERSION_170 = $00001100;

VERSION_MIN = VERSION_50;
VERSION_MAX = VERSION_160;
VERSION_MAX = VERSION_170;

VERSION_MASK_MINOR = $00FF;
VERSION_MASK_MAJOR = $FF00;
Expand Down
8 changes: 8 additions & 0 deletions developer/src/kmc-kmn/test/fixtures/features/version_160.kmn
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
c Description: Verifies that kmcmplib can compile a v16.0 keyboard

store(&NAME) 'version_160'
store(&VERSION) '16.0'

begin unicode > use(main)

group(main) using keys
8 changes: 8 additions & 0 deletions developer/src/kmc-kmn/test/fixtures/features/version_170.kmn
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
c Description: Verifies that kmcmplib can compile a v17.0 keyboard

store(&NAME) 'version_170'
store(&VERSION) '17.0'

begin unicode > use(main)

group(main) using keys
44 changes: 44 additions & 0 deletions developer/src/kmc-kmn/test/test-features.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import 'mocha';
import { assert } from 'chai';
import { KmnCompiler } from '../src/main.js';
import { TestCompilerCallbacks } from '@keymanapp/developer-test-helpers';
import { makePathToFixture } from './helpers/index.js';
import { KMX, KmxFileReader } from '@keymanapp/common-types';

describe('Keyboard compiler features', async function() {
let compiler: KmnCompiler = null;
let callbacks: TestCompilerCallbacks = null;

this.beforeAll(async function() {
compiler = new KmnCompiler();
callbacks = new TestCompilerCallbacks();
assert(await compiler.init(callbacks));
assert(compiler.verifyInitialized());
});

beforeEach(function() {
callbacks.clear();
});

// Test each Keyman file version target

const versions = [
// TODO(lowpri): we should add a test for each version + also test automatic feature detection
['16.0', '160', KMX.KMXFile.VERSION_160],
['17.0', '170', KMX.KMXFile.VERSION_170],
];

for(const v of versions) {
it(`should build a version ${v[0]} keyboard`, function() {
const fixtureName = makePathToFixture('features', `version_${v[1]}.kmn`);

const result = compiler.runCompiler(fixtureName, `version_${v[1]}.kmx`, {saveDebug: true});
if(result === null) callbacks.printMessages();
assert.isNotNull(result);

const reader = new KmxFileReader();
const keyboard = reader.read(result.kmx.data);
assert.equal(keyboard.fileVersion, v[2]);
});
}
});
2 changes: 2 additions & 0 deletions developer/src/kmcmplib/src/Compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1029,6 +1029,8 @@ KMX_DWORD ProcessSystemStore(PFILE_KEYBOARD fk, KMX_DWORD SystemID, PFILE_STORE
else if (u16ncmp(p, u"10.0", 4) == 0) fk->version = VERSION_100;
else if (u16ncmp(p, u"14.0", 4) == 0) fk->version = VERSION_140; // Adds support for #917 -- context() with notany() for KeymanWeb
else if (u16ncmp(p, u"15.0", 4) == 0) fk->version = VERSION_150; // Adds support for U_xxxx_yyyy #2858
else if (u16ncmp(p, u"16.0", 4) == 0) fk->version = VERSION_160; // KMXPlus
else if (u16ncmp(p, u"17.0", 4) == 0) fk->version = VERSION_170; // Flicks and gestures

else return CERR_InvalidVersion;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ struct COMP_KEYBOARD {
#define VERSION_140 0x00000E00
#define VERSION_150 0x00000F00
#define VERSION_160 0x00001000
#define VERSION_170 0x00001100
#define VERSION_MIN VERSION_50
#define VERSION_MAX VERSION_160
#define VERSION_MAX VERSION_170

struct COMP_GROUP {
DWORD dpName; // string (only debug)
Expand Down

0 comments on commit 7adc9b5

Please sign in to comment.