chore(developer): support filename field in kmcmplib compiler messages

Relates-to: #10866
This commit is contained in:
Marc Durdin 2024-07-30 13:09:55 +07:00
parent 7682a31e32
commit 897697d208
5 changed files with 12 additions and 10 deletions

View file

@ -233,9 +233,7 @@ enum LinePrefixType { lptNone, lptKeymanAndKeymanWeb, lptKeymanWebOnly, lptKeyma
/* Compile target */
kmcmp_LoadFileProc loadfileproc = NULL;
void* msgprocContext = NULL;
kmcmp_LoadFileProc kmcmp::loadfileproc = NULL;
int kmcmp::currentLine = 0;

View file

@ -8,6 +8,8 @@ namespace kmcmp {
int ErrChr;
int nErrors = 0;
kmcmp_CompilerMessageProc msgproc = nullptr;
void* msgprocContext = NULL;
std::string messageFilename;
}
void ReportCompilerMessage(KMX_DWORD msg, const std::vector<std::string>& parameters) {
@ -22,8 +24,8 @@ void ReportCompilerMessage(KMX_DWORD msg, const std::vector<std::string>& parame
message.lineNumber = kmcmp::currentLine + 1;
message.columnNumber = kmcmp::ErrChr;
message.parameters = parameters;
//TODO: message.filename =
(*kmcmp::msgproc)(message, msgprocContext);
message.filename = kmcmp::messageFilename;
(*kmcmp::msgproc)(message, kmcmp::msgprocContext);
kmcmp::ErrChr = 0;
}

View file

@ -5,7 +5,8 @@
namespace kmcmp {
extern kmcmp_CompilerMessageProc msgproc;
extern void* msgprocContext;
extern std::string messageFilename;
}
extern void* msgprocContext;
void ReportCompilerMessage(KMX_DWORD msg, const std::vector<std::string>& parameters = {});

View file

@ -29,14 +29,15 @@ EXTERN bool kmcmp_CompileKeyboard(
return FALSE;
}
kmcmp::messageFilename = pszInfile;
kmcmp::msgproc = messageProc;
loadfileproc = loadFileProc;
msgprocContext = (void*)procContext;
kmcmp::loadfileproc = loadFileProc;
kmcmp::msgprocContext = (void*)procContext;
kmcmp::currentLine = 0;
kmcmp::nErrors = 0;
int sz;
std::vector<uint8_t> bufvec = loadFileProc(pszInfile, "");
std::vector<uint8_t> bufvec = kmcmp::loadfileproc(pszInfile, "");
sz = bufvec.size();
if(!sz) {
ReportCompilerMessage(KmnCompilerMessages::ERROR_InfileNotExist);

View file

@ -17,12 +17,12 @@ namespace kmcmp {
extern int BeginLine[4];
extern int currentLine;
extern NamedCodeConstants *CodeConstants;
extern kmcmp_LoadFileProc loadfileproc;
void RecordDeadkeyNames(PFILE_KEYBOARD fk);
KMX_BOOL AddCompilerVersionStore(PFILE_KEYBOARD fk);
}
extern kmcmp_LoadFileProc loadfileproc;
extern KMX_BOOL AWarnDeprecatedCode_GLOBAL_LIB;