fed-sx-m1: 8b-bridge cleanup — remove dead helpers + duplicate test
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 34s

Step 8b-bridge was actually completed in 0f85bd96 (Step 8b-start) using
er-request-dict-to-proplist / er-proplist-to-dict plus er-spawn-fun to
host the handler inside a real Erlang process. My previous commit
(31ff1e6a) shipped a parallel set of helpers (er-http-req-of-sx,
er-http-resp-to-sx and friends) plus a duplicate test under
next/tests/http_listen_bridge.sh — the BIF body never referenced them,
so they sat in runtime.sx as dead code while http_marshal.sh already
covered the live marshalers.

This commit:
  - deletes the 8 dead helpers from lib/erlang/runtime.sx
  - deletes the duplicate next/tests/http_listen_bridge.sh
  - rewrites next/README.md substrate gap #3 to name the helpers and
    tests that are actually live

No behaviour change. Erlang conformance still 761/761; http_listen_bif
5/5, http_route 11/11, http_publish_fold 10/10, http_marshal 10/10.
This commit is contained in:
2026-06-05 23:10:45 +00:00
parent 7267b83b08
commit 78eae9ef12
3 changed files with 12 additions and 331 deletions

View File

@@ -1578,147 +1578,6 @@
;; entry is keyed by "Module/Name/Arity"; multi-arity BIFs register
;; once per arity. Called eagerly at the end of runtime.sx so the
;; registry is ready before any erlang-eval-ast call.
(define
er-binary->string
(fn (b) (list->string (map integer->char (get b :bytes)))))
;; Register everything at load time.
(define
string->er-binary
(fn (s) (er-mk-binary (map char->integer (string->list s)))))
(define
er-mk-proplist
(fn
(pairs)
(let
((out (er-mk-nil)))
(for-each
(fn
(i)
(let
((idx (- (- (len pairs) 1) i)))
(let
((pair (nth pairs idx)))
(set!
out
(er-mk-cons
(er-mk-tuple
(list
(er-mk-atom (nth pair 0))
(nth pair 1)))
out)))))
(range 0 (len pairs)))
out)))
(define
er-proplist-get
(fn
(plist key default)
(cond
(er-nil? plist)
default
(er-cons? plist)
(let
((head (get plist :head)) (tail (get plist :tail)))
(let
((match? (cond (not (er-tuple? head)) false :else (let ((es (get head :elements))) (cond (< (len es) 2) false (not (er-atom? (nth es 0))) false :else (= (get (nth es 0) :name) key))))))
(cond
match?
(nth (get head :elements) 1)
:else (er-proplist-get tail key default))))
:else default)))
(define
er-http-headers-of-sx
(fn
(hdrs)
(cond
(not (= (type-of hdrs) "dict"))
(er-mk-nil)
:else (let
((ks (keys hdrs)) (out (er-mk-nil)))
(for-each
(fn
(i)
(let
((idx (- (- (len ks) 1) i)))
(let
((k (nth ks idx)))
(let
((v (get hdrs k)))
(set!
out
(er-mk-cons
(er-mk-tuple
(list
(string->er-binary k)
(string->er-binary
(if (= (type-of v) "string") v ""))))
out))))))
(range 0 (len ks)))
out))))
(define
er-http-headers-to-sx
(fn
(hdrs)
(let
((pairs (er-cons-to-sx-list hdrs)) (out {}))
(for-each
(fn
(i)
(let
((p (nth pairs i)))
(cond
(not (= (type-of p) "list"))
nil
(< (len p) 2)
nil
:else (dict-set! out (nth p 0) (nth p 1)))))
(range 0 (len pairs)))
out)))
(define
er-http-req-of-sx
(fn
(req-dict)
(let
((s (fn (v) (if (= (type-of v) "string") v ""))))
(let
((method (s (get req-dict "method")))
(path (s (get req-dict "path")))
(query (s (get req-dict "query")))
(body (s (get req-dict "body")))
(hdrs-d (get req-dict "headers")))
(er-mk-proplist
(list
(list "method" (string->er-binary method))
(list "path" (string->er-binary path))
(list "query" (string->er-binary query))
(list "headers" (er-http-headers-of-sx hdrs-d))
(list "body" (string->er-binary body))))))))
(define
er-http-resp-to-sx
(fn
(resp)
(let
((status-v (er-proplist-get resp "status" 200))
(headers-v (er-proplist-get resp "headers" (er-mk-nil)))
(body-v (er-proplist-get resp "body" (string->er-binary ""))))
(let
((status (cond (= (type-of status-v) "number") status-v :else 200))
(body
(cond
(er-binary? body-v)
(er-binary->string body-v)
(= (type-of body-v) "string")
body-v
:else ""))
(hdrs (er-http-headers-to-sx headers-v)))
{:body body :headers hdrs :status status}))))
(define
er-bif-http-listen
(fn
@@ -1731,14 +1590,10 @@
(not (er-fun? handler))
(raise (er-mk-error-marker (er-mk-atom "badarg")))
:else (let
((sx-handler
(fn (req-dict)
(er-http-resp-to-sx
(er-apply-fun
handler
(list (er-http-req-of-sx req-dict)))))))
((sx-handler (fn (req-dict) (er-http-resp-to-sx (er-apply-fun handler (list (er-http-req-of-sx req-dict)))))))
(http-listen port sx-handler))))))
;; Register everything at load time.
(define
er-register-builtin-bifs!
(fn