Move SSD manual count clamping to typed Kotlin
ober
ed063a6e52374f86ebcc04dc98c44e12221ce06d
--- a/.build.yml +++ b/.build.yml @@ -5,7 +5,7 @@ packages: - make=4.4.1-r4 sources: # Build dependency: full immutable commit, mirrored in dependencies.lock.json. - - "https://git.sr.ht/~lisp/jerboa#26f85c6a2a826a4fb68ff8956362f2f2cf6b57ce" + - "https://git.sr.ht/~lisp/jerboa#5c182bfb123e9d76e0799f63180067818eb085bc" # The second source is the build subject selected by the SourceHut submitter. - https://git.sr.ht/~lisp/jerboa-android tasks: @@ -14,6 +14,6 @@ tasks: test "$(apk info -v chez-scheme)" = chez-scheme-10.3.0-r2 test "$(apk info -v git)" = git-2.54.0-r0 test "$(apk info -v make)" = make-4.4.1-r4 - test "$(git -C ../jerboa rev-parse HEAD)" = 26f85c6a2a826a4fb68ff8956362f2f2cf6b57ce - test "$(git -C ../jerboa rev-parse 'HEAD^{tree}')" = 9d27be793f81e8bd5b3724c9790eee7fb68a42b8 + test "$(git -C ../jerboa rev-parse HEAD)" = 5c182bfb123e9d76e0799f63180067818eb085bc + test "$(git -C ../jerboa rev-parse 'HEAD^{tree}')" = 6d011dae14ea399008582a9c0886bf1873278a0b JERBOA="chez --libdirs .:../jerboa/lib --script" make test --- a/dependencies.lock.json +++ b/dependencies.lock.json @@ -11,8 +11,8 @@ "generator_runtime": { "name": "jerboa", "repository": "https://git.sr.ht/~lisp/jerboa", - "commit": "26f85c6a2a826a4fb68ff8956362f2f2cf6b57ce", - "tree": "9d27be793f81e8bd5b3724c9790eee7fb68a42b8" + "commit": "5c182bfb123e9d76e0799f63180067818eb085bc", + "tree": "6d011dae14ea399008582a9c0886bf1873278a0b" }, "assurance_tools": { "osv_scanner": { --- a/scripts/verify-supply-chain.sh +++ b/scripts/verify-supply-chain.sh @@ -3,8 +3,8 @@ set -eu repo=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd -P) lock="$repo/dependencies.lock.json" -jerboa_commit=26f85c6a2a826a4fb68ff8956362f2f2cf6b57ce # gitsafe:ignore -jerboa_tree=9d27be793f81e8bd5b3724c9790eee7fb68a42b8 # gitsafe:ignore +jerboa_commit=5c182bfb123e9d76e0799f63180067818eb085bc # gitsafe:ignore +jerboa_tree=6d011dae14ea399008582a9c0886bf1873278a0b # gitsafe:ignore gradle_sha=20f1b1176237254a6fc204d8434196fa11a4cfb387567519c61556e8710aed78 jdk_macos_sha=8fa1eff40bb637a33613b2ccb8b12c70dc3661cc22cf8e784943715769a05336 jdk_linux_sha=d8afc263758141a66e0e3aafc321e783f7016696f4eaea067d340a269037d331 --- a/templates/ssd-review.ss +++ b/templates/ssd-review.ss @@ -3586,7 +3586,8 @@ sourceBaseName canonicalSourceName isUsefulGuessLabel isErrorStatus formatActivityDuration groupDisplayLabel appendModeStatus selectedGroupStatus sessionCountsStatus rotatedPageStatus - manualGroupLabel) + manualGroupLabel manualCellCount editedGroupCount) + (type Int32) (def (normalizeFiringArc (value : String)) : String (string-uppercase (string-trim value))) (def (normalizeLabel (value : String)) : String @@ -3701,6 +3702,20 @@ (if (nullable-null? resolvedName) fallback (string-lowercase (nullable-get resolvedName)))))) + (def (manualCellCount (count : Int32)) : Int32 + (if (< count (int32 1)) + (int32 1) + (if (> count (int32 400)) + (int32 400) + count))) + (def (editedGroupCount (count : (Nullable Int32)) + (fallback : Int32)) : Int32 + (if (nullable-null? count) + fallback + (let ((value (nullable-get count))) + (if (< value (int32 0)) + (int32 0) + value)))) (def (appendModeStatus (group : SsdGroup)) : String (string-append "Append mode: drag boxes to add to " @@ -5410,7 +5425,7 @@ " val ids = if (detectedIds.isNotEmpty()) {" " detectedIds.toMutableList()" " } else {" - " createManualCells(session, rect, count.coerceIn(1, 400))" + " createManualCells(session, rect, manualCellCount(count))" " }" " val group = SsdGroup(" " id = ssdSessionNextGroupId(session)," @@ -5443,7 +5458,7 @@ " val ids = if (detectedIds.isNotEmpty()) {" " detectedIds.toMutableList()" " } else {" - " createManualCells(session, rect, count.coerceIn(1, 400))" + " createManualCells(session, rect, manualCellCount(count))" " }" " val added = appendUniqueCellIdsToGroup(group, ids)" " ssdSessionRecomputeGroup(session, group)" @@ -5511,7 +5526,7 @@ " group.label = manualGroupLabel(labelText, resolved?.name, group.label)" " group.boxTypeId = resolved?.id ?: boxTypeText" " group.firingArc = normalizeFiringArc(firingArcText)" - " group.count = countValue?.coerceAtLeast(0) ?: group.count" + " group.count = editedGroupCount(countValue, group.count)" " group.status = \"reviewed\"" " ssdSessionRecomputeGroup(session, group)" " truthStore.appendEvent(\"group_edited\", session)"