Skip to content

Commit b5a1e13

Browse files
committed
chore(developer): add store.line metadata and cleanup
1 parent 7dbf97f commit b5a1e13

File tree

6 files changed

+14
-20
lines changed

6 files changed

+14
-20
lines changed

developer/src/kmc-kmn/src/compiler/compiler.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export const STORETYPE__MASK = 0x1F;
3131
export interface CompilerResultExtraStore {
3232
storeType: number; // STORETYPE__MASK
3333
name: string; // when debug=false, the .kmx will not have store names
34+
line: number; // source line number where store is defined
3435
};
3536

3637
export interface CompilerResultExtraGroup {
@@ -203,7 +204,7 @@ export class KmnCompiler implements UnicodeSetParser {
203204
displayMap: null
204205
};
205206
for(let store of wasm_result.extra.stores) {
206-
result.extra.stores.push({storeType: store.storeType, name: store.name});
207+
result.extra.stores.push({storeType: store.storeType, name: store.name, line: store.line});
207208
}
208209
for(let group of wasm_result.extra.groups) {
209210
result.extra.groups.push({isReadOnly: group.isReadOnly, name: group.name});

developer/src/kmc-kmn/src/kmw-compiler/kmw-compiler.ts

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -51,26 +51,16 @@ export function WriteCompiledKeyboard(
5151

5252
setupGlobals(callbacks, opts, FDebug?' ':'', FDebug?'\r\n':'', kmxResult, keyboard, kmnfile);
5353

54-
// let fgp: GROUP;
55-
56-
// let fsp: STORE;
57-
// let fkp: KEY;
58-
59-
// let j: number;
60-
// let n: number;
61-
6254
let vMnemonic: number = 0;
63-
let /*s: string,*/ sRTL: string = "", sHelp: string = "''", sHelpFile: string = "",
55+
let sRTL: string = "", sHelp: string = "''", sHelpFile: string = "",
6456
sEmbedJSFilename: string = "", sEmbedCSSFilename: string = "";
6557
let sVisualKeyboardFilename: string = "", sFullName: string = "";
6658
let sBegin_NewContext: string = "", sBegin_PostKeystroke: string = "";
6759
let sLayoutFilename: string = "", sVKDictionary: string = "";
6860
let linecomment: string; // I3438
69-
// let HasRules: boolean;
7061
let sModifierBitmask: string;
7162
let FOptionStores: string;
7263
let FKeyboardVersion = "1.0";
73-
// let rec: TSentinelRecord;
7464

7565
let result = "";
7666
// Locate the name of the keyboard
@@ -228,33 +218,32 @@ export function WriteCompiledKeyboard(
228218
const isDebugStore = (index: number) => isStoreType(index, STORETYPE_DEBUG);
229219
const isReservedStore = (index: number) => isStoreType(index, STORETYPE_RESERVED);
230220
const isOptionStore = (index: number) => isStoreType(index, STORETYPE_OPTION);
221+
const getStoreLine = (index: number) => kmxResult.extra.stores[index].line;
231222

232223
// Write the stores out
233224
FOptionStores = '';
234225
for(let i = 0; i < keyboard.stores.length; i++) {
235226
let fsp = keyboard.stores[i];
236227
// I3438 - Save all system stores to the keyboard, for now // I3684
237228

238-
if (!isDebugStore(i)) { // and not (fsp.dwSystemID in [TSS_BITMAP, TSS_NAME, TSS_VERSION, TSS_CUSTOMKEYMANEDITION, TSS_CUSTOMKEYMANEDITIONNAME, TSS_KEYMANCOPYRIGHT]) then
229+
if (!isDebugStore(i)) {
239230
if (fsp.dwSystemID == KMX.KMXFile.TSS_COMPARISON) {
240-
result += `${FTabStop}this.s${JavaScript_Name(i, fsp.dpName)}=${JavaScript_Store(keyboard, 0/*fsp.line*/, fsp.dpString)};${nl}`;
231+
result += `${FTabStop}this.s${JavaScript_Name(i, fsp.dpName)}=${JavaScript_Store(keyboard, getStoreLine(i), fsp.dpString)};${nl}`;
241232
}
242233
else if (fsp.dwSystemID == KMX.KMXFile.TSS_COMPILEDVERSION) {
243-
result += `${FTabStop}this.KVER=${JavaScript_Store(keyboard, 0/*fsp.line*/, fsp.dpString)};${nl}`;
234+
result += `${FTabStop}this.KVER=${JavaScript_Store(keyboard, getStoreLine(i), fsp.dpString)};${nl}`;
244235
}
245-
//else if fsp.dwSystemID = TSS_VKDICTIONARY then // I3438, required for vkdictionary
246-
// Result := Result + Format('%sthis.s%s=%s;%s', [FTabStop, JavaScript_Name(i, fsp.szName), JavaScript_Store(fsp.line, fsp.dpString), nl])
247236
else if (isOptionStore(i) && !isReservedStore(i)) {
248237
result += `${FTabStop}this.s${JavaScript_Name(i,fsp.dpName)}=KeymanWeb.KLOAD(this.KI,"${JavaScript_Name(i,fsp.dpName,true)}",`+
249-
`${JavaScript_Store(keyboard, 0/*fsp.line*/, fsp.dpString)});${nl}`;
238+
`${JavaScript_Store(keyboard, getStoreLine(i), fsp.dpString)});${nl}`;
250239

251240
if (FOptionStores != '') {
252241
FOptionStores += ',';
253242
}
254243
FOptionStores += `'s${JavaScript_Name(i, fsp.dpName)}'`;
255244
}
256-
else if (fsp.dwSystemID == KMX.KMXFile.TSS_NONE /* aka not fsp.fIsReserved */) {
257-
result += `${FTabStop}this.s${JavaScript_Name(i, fsp.dpName)}=${JavaScript_Store(keyboard, 0/*fsp.line*/, fsp.dpString)};${nl}`; // I3681
245+
else if (fsp.dwSystemID == KMX.KMXFile.TSS_NONE /* aka !isReservedStore(i) */) {
246+
result += `${FTabStop}this.s${JavaScript_Name(i, fsp.dpName)}=${JavaScript_Store(keyboard, getStoreLine(i), fsp.dpString)};${nl}`; // I3681
258247
}
259248
}
260249
}

developer/src/kmc-kmn/src/kmw-compiler/messages.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export class KmwCompilerMessages extends KmnCompilerMessages {
6161
`The touch layout font should be the same for all platforms.`);
6262
static Warn_TouchLayoutMissingRequiredKeys = (o:{layerId:string, platformName:string, missingKeys:string}) => m(this.WARN_TouchLayoutMissingRequiredKeys,
6363
`Layer "${o.layerId}" on platform "${o.platformName}" is missing the required key(s) '${o.missingKeys}.`);
64+
6465
// Following messages are kmw-compiler only, so use KmwCompiler error namespace
6566

6667
static Error_NotAnyRequiresVersion14 = () => m(this.ERROR_NotAnyRequiresVersion14,

developer/src/kmcmplib/include/kmcmplibapi.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ struct KMCMP_COMPILER_OPTIONS {
4545
struct KMCMP_COMPILER_RESULT_EXTRA_STORE {
4646
int storeType; // STORETYPE__MASK
4747
std::string name; // when debug=false, the .kmx will not have store names
48+
int line; // source line number where store is defined
4849
};
4950

5051
struct KMCMP_COMPILER_RESULT_EXTRA_GROUP {

developer/src/kmcmplib/src/CompileKeyboardBuffer.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ namespace kmcmp {
183183
(store->fIsDebug ? STORETYPE_DEBUG : 0) |
184184
(store->fIsCall ? STORETYPE_CALL : 0);
185185
extraStore.name = string_from_u16string(store->szName);
186+
extraStore.line = store->line;
186187
fk->extra->stores.push_back(extraStore);
187188
}
188189

developer/src/kmcmplib/src/CompilerInterfacesWasm.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ EMSCRIPTEN_BINDINGS(compiler_interface) {
148148
emscripten::value_object<KMCMP_COMPILER_RESULT_EXTRA_STORE>("CompilerResultExtraStore")
149149
.field("storeType", &KMCMP_COMPILER_RESULT_EXTRA_STORE::storeType)
150150
.field("name", &KMCMP_COMPILER_RESULT_EXTRA_STORE::name)
151+
.field("line", &KMCMP_COMPILER_RESULT_EXTRA_STORE::line)
151152
;
152153

153154
emscripten::value_object<KMCMP_COMPILER_RESULT_EXTRA_GROUP>("CompilerResultExtraGroup")

0 commit comments

Comments
 (0)