chore(developer): split CKF_KEYMANWEB for typescript compiler

This commit is contained in:
Marc Durdin 2023-05-09 15:24:35 +07:00
parent eac6651c03
commit 80e5d650de
4 changed files with 15 additions and 12 deletions

View file

@ -141,6 +141,7 @@ type
const
CKF_KEYMAN = 0;
CKF_KEYMANWEB = 1;
// CKF_KEYMANWEB_MODERN = 2; // used only by Typescript-based compiler
const
CERR_FATAL = $00008000;

View file

@ -148,7 +148,8 @@ export class KmnCompiler {
private runCompiler(infile: string, outfile: string, options: CompilerOptions): boolean {
const CKF_KEYMAN = 0;
const CKF_KEYMANWEB = 1;
// const CKF_KEYMANWEB = 1; // not used -- legacy compiler only
const CKF_KEYMANWEB_MODERN = 2;
try {
if (!this.wasm.setCompilerOptions(options.shouldAddCompilerVersion ? 1 : 0)) {
@ -161,7 +162,7 @@ export class KmnCompiler {
options.compilerWarningsAsErrors ? 1 : 0,
options.warnDeprecatedCode ? 1 : 0,
this.callbackName,
options.target == 'js' ? CKF_KEYMANWEB : CKF_KEYMAN);
options.target == 'js' ? CKF_KEYMANWEB_MODERN : CKF_KEYMAN);
} catch(e) {
this.callbacks.reportMessage(CompilerMessages.Fatal_UnexpectedException({e:e}));
return false;

View file

@ -33,13 +33,14 @@ EXTERN bool kmcmp_CompileKeyboardFile(
bool AWarnDeprecatedCode,
kmcmp_CompilerMessageProc pMsgproc,
void* AmsgprocContext,
int target // CKF_KEYMAN || CKF_KEYMANWEB
int target // CKF_KEYMAN || CKF_KEYMANWEB || CKF_KEYMANWEB_MODERN
);
/* Compile target */
#define CKF_KEYMAN 0
#define CKF_KEYMANWEB 1
#define CKF_KEYMANWEB 1 // For legacy kmcomp compiler, to be deprecated and removed
#define CKF_KEYMANWEB_MODERN 2 // For Typescript kmc-kmw compiler
EXTERN bool kmcmp_CompileKeyboardFileToBuffer(
char* pszInfile,

View file

@ -1042,10 +1042,10 @@ KMX_DWORD ProcessSystemStore(PFILE_KEYBOARD fk, KMX_DWORD SystemID, PFILE_STORE
pp2[4] = 0;
}
if(CompileTarget == CKF_KEYMAN) {
// When we compile to kmx, we want to save this info into
// the .kmx, but for KMW, we need the original source file
// for the KMW compiler process
if(CompileTarget != CKF_KEYMANWEB_MODERN) {
// When we compile to kmx, we want to save this info into the .kmx, and
// for the legacy kmw compiler, but for kmc-kmw, we need the original
// source file for the kmc-kmw compiler process
delete[] sp->dpString;
sp->dpString = q;
}
@ -1054,7 +1054,7 @@ KMX_DWORD ProcessSystemStore(PFILE_KEYBOARD fk, KMX_DWORD SystemID, PFILE_STORE
return msg;
}
if(CompileTarget == CKF_KEYMANWEB) {
if(CompileTarget == CKF_KEYMANWEB_MODERN) {
delete[] q;
}
}
@ -1234,7 +1234,7 @@ KMX_DWORD CheckStatementOffsets(PFILE_KEYBOARD fk, PFILE_GROUP gp, PKMX_WCHAR co
// Due to a limitation in earlier versions of KeymanWeb, the minimum version
// for context() referring to notany() is 14.0. See #917 for details.
if (kmcmp::CompileTarget == CKF_KEYMANWEB) {
if (kmcmp::CompileTarget != CKF_KEYMAN) {
for (q = context, i = 1; *q && i < contextOffset; q = incxstr(q), i++);
if (*q == UC_SENTINEL && *(q + 1) == CODE_NOTANY) {
VERIFY_KEYBOARD_VERSION(fk, VERSION_140, CERR_140FeatureOnlyContextAndNotAnyWeb);
@ -1687,7 +1687,7 @@ int LineTokenType(PKMX_WCHAR *str)
/* Test KeymanWeb, Keyman and KeymanOnly prefixes */
if (kmcmp::CompileTarget == CKF_KEYMAN && lpt == lptKeymanWebOnly) return T_BLANK;
if (kmcmp::CompileTarget == CKF_KEYMANWEB && lpt == lptKeymanOnly) return T_BLANK;
if (kmcmp::CompileTarget != CKF_KEYMAN && lpt == lptKeymanOnly) return T_BLANK;
while (iswspace(*p)) p++;
@ -2168,7 +2168,7 @@ KMX_DWORD GetXStringImpl(PKMX_WCHAR tstr, PFILE_KEYBOARD fk, PKMX_WCHAR str, KMX
// in the web target platform, even if there are platform() rules excluding this possibility. In that (rare) situation, the keyboard developer should simply specify
// the &version to be 9.0 or whatever to avoid this behaviour.
if (sFlag & (LCTRLFLAG | LALTFLAG | RCTRLFLAG | RALTFLAG | CAPITALFLAG | NOTCAPITALFLAG | NUMLOCKFLAG | NOTNUMLOCKFLAG | SCROLLFLAG | NOTSCROLLFLAG) &&
kmcmp::CompileTarget == CKF_KEYMANWEB &&
kmcmp::CompileTarget != CKF_KEYMAN &&
fk->dwFlags & KF_AUTOMATICVERSION) {
VERIFY_KEYBOARD_VERSION(fk, VERSION_100, 0);
}