Commit graph

396 commits

Author SHA1 Message Date
Dr Mark C. Sinclair
a09dcffb03 chore(developer): Merge branch 'master' into fix/developer/12262-ensure-call-detects-invalid-store-in-kmcmplib-compiler
# Keyman Conventional Commit suggestions:
#
# - Link to a Sentry issue with git trailer:
#     Fixes: _MODULE_-_ID_
# - Give credit to co-authors:
#     Co-authored-by: _Name_ <_email_>
# - Use imperative, present tense ('attach' not 'attaches', 'attached' etc)
# - Don't include a period at the end of the title
# - Always include a blank line before trailers
# - More: https://github.com/keymanapp/keyman/wiki/Pull-Request-and-Commit-workflow-notes
2024-08-22 17:13:00 +01:00
Dr Mark C. Sinclair
862f0d9191 fix(developer): add test cases for spaces before and after valid store in call in GetXStringImpl_type_c test 2024-08-22 15:21:01 +01:00
Dr Mark C. Sinclair
b608e1ca84 fix(developer): add ERROR_InvalidCall and first valid test case to GetXStringImpl_type_c test 2024-08-22 15:15:32 +01:00
Dr Mark C. Sinclair
75508f46b4 fix(developer): add ERROR_StoreDoesNotExist test cases to GetXStringImpl_type_c test 2024-08-22 11:43:03 +01:00
Dr Mark C. Sinclair
7e2f797dd8 fix(developer): move check on store name search to just after search 2024-08-22 11:41:02 +01:00
Dr Mark C. Sinclair
b721ff6d5d fix(developer): add call test cases from #11990 to GetXStringImpl_type_c test 2024-08-22 11:19:37 +01:00
Marc Durdin
a0ebe130de chore(developer): enable build for emscripten 3.1.60+
Emscripten 3.1.60 made a breaking change to `BindingType::toWireType`
(why is this done in a patch version?) so this change ensures that we
can continue to build on 3.1.58 and 3.1.64 (which is needed for #12234),
as a bridging strategy. We will need to merge this into 17.0-stable as
well so that we can upgrade the build agents to 3.1.64.

Relates-to: emscripten-core/emscripten#21692
Relates-to: #12234
2024-08-21 14:24:10 +02:00
Eberhard Beilharz
ab3722ecfa
fix(core): look for emcc instead of emcc.py on Linux and Mac
`emcc.py` is not marked as executable in emcripten's git repo so the
build failed when trying to locate emscripten. However, it turns out
that `emcc` is marked as executable, so we use that instead.

On Windows however, we still need to use `emcc.py` because otherwise
Meson won't detect it as valid compiler.
2024-08-20 15:52:52 +02:00
Marc Durdin
dde4e2b2c3 refactor: move kmx_u16 to common and rename to km_u16 2024-08-14 10:07:08 +02:00
Marc Durdin
4a57258afc refactor(developer): remove unnecessary includes from kmx_u16 2024-08-14 09:50:11 +02:00
Sabine
30493f94bb chore(common): replace DEBUGSTORE_, DEBUGSTORE_...C with DEBUGSTORE_..._L , DEBUGSTORE_..._U 2024-08-13 15:59:43 +02:00
Sabine
07c8d13f53 chore(common):use googletests for kmx_u16 2024-08-13 15:24:19 +02:00
Sabine
a3a7bd38ff chore(common): use strtof() in u16tof() 2024-08-13 15:10:24 +02:00
Sabine
cbe712d2cd chore(common): replace u16fmt and convert_pchar16T_To_wstr with wstring_from_u16string 2024-08-13 15:10:24 +02:00
Sabine
6554bd615e chore(common): replace codecvt in module u16 2024-08-13 15:10:24 +02:00
Marc Durdin
86fd36a713
Merge pull request #12117 from keymanapp/chore/developer/build-ci-linux-mac
chore(developer): start building Developer on linux,mac
2024-08-09 18:57:38 +10:00
Marc Durdin
2a12b63c6d chore(developer): add more casts for signed/unsigned in compiler 2024-08-08 05:39:27 +07:00
Marc Durdin
d088c250ff chore(developer): add more casts for signed/unsigned in compiler 2024-08-08 05:32:01 +07:00
Marc Durdin
f765311750 chore(developer): add casts for signed/unsigned in compiler
Address build failure on macOS; reduction in file size from 64-bit to
32-bit; never expecting 2GB+ keyboard files.
2024-08-08 05:21:10 +07:00
Marc Durdin
e9d054ab2c
Merge branch 'master' into refactor/common/9665-move-kvk-file-to-developer 2024-08-07 15:13:41 +10:00
Marc Durdin
0bd6990fc8
Merge pull request #12063 from keymanapp/refactor/developer/12047-remove-VERIFY_KEYBOARD_VERSION
refactor(developer): replace `VERIFY_KEYBOARD_VERSION()` calls with `VerifyKeyboardVersion()` 🌋
2024-08-03 21:02:54 +10:00
Marc Durdin
6d81177570
Merge pull request #12061 from keymanapp/chore/developer/support-message-filename-kmcmplib
chore(developer): support filename field in kmcmplib compiler messages 🌋
2024-08-03 20:56:58 +10:00
Marc Durdin
427d1970da
Merge pull request #12060 from keymanapp/refactor/developer/kmcmplib-rename-error-message-functions
refactor(developer): rename compiler error reporting functions in kmcmplib 🌋
2024-08-03 20:56:44 +10:00
Marc Durdin
29155a4edf chore(developer): fixup test namespaces 2024-08-03 15:58:35 +07:00
Marc Durdin
a9b066d956
Merge branch 'master' into refactor/developer/kmcmplib-construct-messages-in-kmc-kmn 2024-08-03 12:13:53 +10:00
Marc Durdin
15829a8e9d
Merge pull request #12048 from keymanapp/refactor/developer/kmcmplib-yak-shave-more-bools
refactor(developer): move error reporting inside `GetCompileTargetsFromTargetsStore` and `ProcessGroupFinish` 🌋
2024-08-03 12:13:08 +10:00
Marc Durdin
bdb8f65b1b
Merge branch 'master' into refactor/developer/kmcmplib-yak-shave-bools-instead-of-errors-returned 2024-08-03 12:12:21 +10:00
Marc Durdin
e476aaa7dd
Merge branch 'master' into refactor/developer/kmcmplib-compiler-error-code-alignment 2024-08-03 12:10:52 +10:00
Marc Durdin
bc4abad7bd
Merge pull request #12031 from keymanapp/refactor/developer/kmcmplib-compiler-interfaces
refactor(developer): improve the callbacks for kmcmplib 🌋
2024-08-03 12:08:15 +10:00
Marc Durdin
98560dd644
Merge pull request #12030 from keymanapp/refactor/developer/kmcmplib-compiler-errors
refactor(developer): move functions and variables into CompilerErrors.cpp 🌋
2024-08-03 12:07:49 +10:00
Marc Durdin
53551f5662
Merge branch 'refactor/common/9665-move-kps-file-type-to-developer' into refactor/common/9665-move-kvk-file-to-developer 2024-08-01 10:35:33 +10:00
Marc Durdin
d8986be12f refactor(common): merge master into branch 2024-08-01 07:07:07 +07:00
Dr Mark C. Sinclair
a53ea2ced4 chore(developer): add additional comment to LineTokenType test case for 'c' with no following space 2024-07-30 11:49:23 +01:00
Dr Mark C. Sinclair
298853bccb chore(developer): correct copy-paste error in finl test case of u16tok_str_compare_to_strtok 2024-07-30 11:30:59 +01:00
Marc Durdin
dc459a0926 refactor(developer): replace VERIFY_KEYBOARD_VERSION() calls with VerifyKeyboardVersion()
Remove the `VERIFY_KEYBOARD_VERSION()` and
`VERIFY_KEYBOARD_VERSION_ret()` macros, and instead use
`VerifyKeyboardVersion()`. The DRYing out of this function call pattern
moved the return statement into a macro, which is an inappropriate way
to reduce repetition, because (a) it is hard for devs to spot function
exits, and (b) automated code analysis tools stumble on it.

Also means that we uncover more clearly the return mismatches between
`KMX_DWORD` and `KMX_BOOL` through the compiler source.

Fixes: #12047
2024-07-30 13:13:10 +07:00
Marc Durdin
897697d208 chore(developer): support filename field in kmcmplib compiler messages
Relates-to: #10866
2024-07-30 13:09:55 +07:00
Marc Durdin
7682a31e32 refactor(developer): replace AddWarning() and AddWarningBool() macro usage with call to ReportCompilerMessage()
The `AddWarning()` and `AddWarningBool()` macros just called
`ReportCompilerMessage()`. A side-effect of removing `AddWarningBool()`
is that the functions that called it always returned `TRUE` (and the
return value was never checked anyway), and so these functions have been
made `void`.
2024-07-30 11:02:37 +07:00
Marc Durdin
619b03a20d refactor(developer): rename AddCompileError() to ReportCompilerMessage() 2024-07-30 10:05:06 +07:00
Marc Durdin
8cd97e5f5d refactor(developer): move kmcmplib message construction to kmc-kmn
* Remove compiler message definitions from kmcmplib
* Add parameterization to compiler message structures
* Translate parameters for existing parameterized messages (except for
  `ERROR_InvalidToken`, which requires a bigger refactor of
  `GetXStringImpl()` and many friends)
* Add columnNumber to message structures (not yet used in kmc-kmn)
* Add filename to message structures (not yet used in kmcmplib)
* Rename `INFO_Info` to `INFO_MinimumCoreEngineVersion` and
  `INFO_MinimumEngineVersion` to `INFO_MinimumWebEngineVersion`

Relates-to: #10866
2024-07-30 10:01:19 +07:00
Marc Durdin
59addc5d2b refactor(developer): move error reporting inside GetCompileTargetsFromTargetsStore
This supports upcoming changes for parameterized errors in
`GetCompileTargetsFromTargetsStore`.
2024-07-29 10:52:23 +07:00
Marc Durdin
c359fd6ccc refactor(developer): move error reporting inside ProcessGroupFinish
This supports upcoming changes for parameterized errors in
`VerifyUnreachableRules` (now a `void` return because it always returned
success anyway).
2024-07-29 10:41:32 +07:00
Marc Durdin
bcec446144 refactor(developer): return KMX_BOOL instead of KMX_DWORD for AddStore() and friends
This is definitely a yak shave, but should have payoff in terms of
cleaner and more descriptive error messages in the long run.

In the existing design, many (but not all) functions return a KMX_DWORD
error value, and that is passed on up the call stack to be reported as
an error elsewhere. This separation of error reporting from error site
makes it difficult to add parameters (and masks the actual error site in
analysis).

This commit starts to move the error reporting to the actual site of the
error, in `AddStore()`, `ProcessSystemStore()`, `ParseLine()`,
`AddCompilerVersionStore()`, `BuildVKDictionary()`, and
`ProcessBeginLine()`.

During analysis, identified a memory leak (missing `delete[] temp`) in
`process_if()`. Fixed on line 2716.

Many of the `process_*()` functions call `AddStore()`, which is now
responsible for reporting its own errors; these functions have not yet
been updated and so if `AddStore()` fails, the compiler will generate
two error messages -- one from `AddStore()` and a second one in the
value returned from the calling `process_*()` function.

The `VERIFY_KEYBOARD_VERSION` macro hides a `return` statement which
returned an error code on failure. This has been split into
`VERIFY_KEYBOARD_VERSION_ret` which causes the caller to returns the
error code, and the existing `VERIFY_KEYBOARD_VERSION` macro now causes
the caller to return `FALSE` on failure. This should be refactored to
move the `return` condition into the caller (removing the `return`
side-effect) in the future.
2024-07-29 06:21:21 +07:00
Marc Durdin
05fd680a9e refactor(developer): Move error reporting inside CheckForDuplicateStore
This is the same change as for `CheckForDuplicateGroup`.

`CheckForDuplicateStore` is one of a few places where parameterized
errors are returned. Moving the error reporting inside the function
makes it cleaner to refactor those parameterized errors later. (This
requires a similar change in `ProcessStoreLine`, also formatted and
rebraced per style guide.)
2024-07-29 04:27:06 +07:00
Marc Durdin
7371c87867 refactor(developer): Move error reporting inside CheckForDuplicateGroup
`CheckForDuplicateGroup` is one of a few places where parameterized
errors are returned. Moving the error reporting inside the function
makes it cleaner to refactor those parameterized errors later. (This
requires a similar, simple change in `ProcessGroupLine`.)
2024-07-29 04:18:28 +07:00
Marc Durdin
92c5d41501 refactor(developer): make AddCompileError void type
`AddCompileError` would return FALSE only for 'user interruption' (not
used since Developer 17) or for fatal errors. After analysis, it turns
out that this error value was not used anywhere and removing it
simplifies the error management logic, making code paths much easier to
follow.

The return value was used in v17.0 and earlier in the macro for
`AddCompileWarning`, effectively only relevant for 'user interruption'
(`CERR_Break`); this was an ugly code pattern as it meant that any
`AddCompileWarning` could exit a function with failure -- though as
noted above `CERR_Break` was never emitted in v17.0.
2024-07-29 04:13:15 +07:00
Marc Durdin
6a48f5e550 refactor(developer): align kmcmplib error codes with kmc
Renames kmcmplib error codes to match those in kmc-kmn, and updates the
bitmasks accordingly. Adds a KmnCompilerMessages namespace so a trivial
enum can be declared without risk of clashes with other ERROR_ or
similar messages.
2024-07-28 11:45:03 +07:00
Marc Durdin
c8b055101f refactor(developer): rename CWARN_Info to CINFO_Info 2024-07-28 08:42:57 +07:00
Marc Durdin
091b4042a2 refactor(developer): rename CERR_None and CERR_EndOfFile to STATUS_
These two codes are not true error or message codes, but are used as
return values extensively throughout kmcmplib. The codes are never
passed to message callbacks. As such, I have renamed them to reflect
usage, but opted not to change their values as there would be some risk
in doing so (e.g. use of `!v` vs `v == CERR_None`).
2024-07-27 09:24:13 +07:00
Marc Durdin
a0e786035f refactor(developer): rename error severity masks to match typescript 2024-07-27 09:17:20 +07:00
Marc Durdin
503d9c6ea9 chore(developer): use FATAL_ prefix for fatal errors in kmcmplib 2024-07-27 09:11:03 +07:00