Move SSD JSON rect helpers to typed Kotlin

ober

e3d1f40b148aa91d8a254544d814eb49a576ecf9

diff --git a/.build.yml b/.build.yml
index 98a0080..088ca19 100644
--- 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#060bf67c52967edad54111e041996bdbe88e82c9"
+  - "https://git.sr.ht/~lisp/jerboa#063dc728b171b6039887edb42acecd201f5dd3f0"
   # 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)" = 060bf67c52967edad54111e041996bdbe88e82c9
-      test "$(git -C ../jerboa rev-parse 'HEAD^{tree}')" = 4a5faf71c0a5a678e5574d42ca1519899b71f26e
+      test "$(git -C ../jerboa rev-parse HEAD)" = 063dc728b171b6039887edb42acecd201f5dd3f0
+      test "$(git -C ../jerboa rev-parse 'HEAD^{tree}')" = 08e730fabd0754a09c6b50b072823385540bc627
       JERBOA="chez --libdirs .:../jerboa/lib --script" make test
diff --git a/dependencies.lock.json b/dependencies.lock.json
index 4c62d1b..bdc7390 100644
--- a/dependencies.lock.json
+++ b/dependencies.lock.json
@@ -11,8 +11,8 @@
   "generator_runtime": {
     "name": "jerboa",
     "repository": "https://git.sr.ht/~lisp/jerboa",
-    "commit": "060bf67c52967edad54111e041996bdbe88e82c9",
-    "tree": "4a5faf71c0a5a678e5574d42ca1519899b71f26e"
+    "commit": "063dc728b171b6039887edb42acecd201f5dd3f0",
+    "tree": "08e730fabd0754a09c6b50b072823385540bc627"
   },
   "assurance_tools": {
     "osv_scanner": {
diff --git a/scripts/verify-supply-chain.sh b/scripts/verify-supply-chain.sh
index bc7f578..36bc170 100755
--- 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=060bf67c52967edad54111e041996bdbe88e82c9 # gitsafe:ignore
-jerboa_tree=4a5faf71c0a5a678e5574d42ca1519899b71f26e # gitsafe:ignore
+jerboa_commit=063dc728b171b6039887edb42acecd201f5dd3f0 # gitsafe:ignore
+jerboa_tree=08e730fabd0754a09c6b50b072823385540bc627 # gitsafe:ignore
 gradle_sha=20f1b1176237254a6fc204d8434196fa11a4cfb387567519c61556e8710aed78
 jdk_macos_sha=8fa1eff40bb637a33613b2ccb8b12c70dc3661cc22cf8e784943715769a05336
 jdk_linux_sha=d8afc263758141a66e0e3aafc321e783f7016696f4eaea067d340a269037d331
diff --git a/templates/ssd-review.ss b/templates/ssd-review.ss
index 5735f9d..fa30bb1 100644
--- a/templates/ssd-review.ss
+++ b/templates/ssd-review.ss
@@ -748,6 +748,35 @@
                    (> (TruthIndexEntry-truthTime candidate)
                       (TruthIndexEntry-truthTime current)))))))
 
+    (typed-kotlin-file "com/sfb/ssdreview/JsonGeometry.kt"
+      (kotlin-imports (org json JSONArray))
+      (typed-library (com sfb ssdreview)
+        (export floatArrayToJson jsonRect)
+        (type JSONArray)
+        (type FloatArray)
+        (type Int32)
+        (type Float32)
+        (def (floatArrayToJson (rect : FloatArray)) : JSONArray
+          (let ((json (json-array-empty)))
+            (begin
+              (for/fold ((ignored (int32 0)))
+                        ((i (in-range (int32 0) (float-array-length rect))))
+                (begin
+                  (json-array-put-float32! json (float-array-ref rect i))
+                  ignored))
+              json)))
+        (def (jsonRect (json : (Nullable JSONArray))) : (Nullable FloatArray)
+          (if (nullable-null? json)
+              (nullable-none FloatArray)
+              (if (< (json-array-length (nullable-get json)) (int32 4))
+                  (nullable-none FloatArray)
+                  (nullable-some
+                    (float-array
+                      (json-array-opt-float32 (nullable-get json) (int32 0) (float32 0.0))
+                      (json-array-opt-float32 (nullable-get json) (int32 1) (float32 0.0))
+                      (json-array-opt-float32 (nullable-get json) (int32 2) (float32 0.0))
+                      (json-array-opt-float32 (nullable-get json) (int32 3) (float32 0.0)))))))))
+
     (typed-kotlin-file "com/sfb/ssdreview/Guess.kt"
       (typed-library (com sfb ssdreview)
         (export make-Guess Guess? Guess-label Guess-boxType Guess-reason)
@@ -3611,20 +3640,6 @@
        "    return payload"
        "}"
        ""
-	       "fun floatArrayToJson(rect: FloatArray): JSONArray = JSONArray().apply {"
-	       "    rect.forEach { put(it.toDouble()) }"
-	       "}"
-	       ""
-	       "fun jsonRect(json: JSONArray?): FloatArray? {"
-	       "    if (json == null || json.length() < 4) return null"
-	       "    return floatArrayOf("
-	       "        json.optDouble(0, 0.0).toFloat(),"
-	       "        json.optDouble(1, 0.0).toFloat(),"
-	       "        json.optDouble(2, 0.0).toFloat(),"
-	       "        json.optDouble(3, 0.0).toFloat()"
-	       "    )"
-	       "}"
-	       ""
 	       ))
     (kotlin-file-lines "com/sfb/ssdreview/SsdDetector.kt"
       (