Cairn.Fuzz.Trusted.Export
lean/Cairn/Fuzz/Trusted/Export.lean
Lean's side of the trusted-base fuzzer
C exports for cairn-fuzz-trusted (host/Tests/CairnFuzzTrusted), the Swift executable that
links this library next to the Swift host, so both sides of each trusted boundary run in one
process (docs/fuzz.md, "Trusted base"). No import Lean: this links into a Swift binary.
cairn_tf_gen_frame seed: a random frame (Gen.frame), encoded.cairn_tf_decode_frame bytesandcairn_tf_decode_events bytes: Lean's proved decoders' verdict on any bytes. The reply is"R"(rejected), or"A="/"A~"(accepted;=when re-encoding the value gives the same bytes back) followed by the canonical dump (Cairn.Dump), which the Swift side compares with its own dump.cairn_tf_field_init/step/frame: an app that is one text field, on the real runtime and boundary (Runtime.stepBytes,Frame.boundary,TextMetrics.host), so the host'sNSTextInputClientand its shadow of the field can be checked againstField.apply. The same ABI ascairn_app_*(docs/runtime.md), under other names so it can't clash.cairn_tf_wrap: where Lean breaks a string into lines at a width withTextMetrics.host, and where layout puts each line, so the Swift side can shape each line as the renderer will and compare with Core Text's own line breaking.
Imports Cairn.Fuzz.Trusted.Gen, Cairn.Frame.Dump, Cairn.Abi, Cairn.Runtime.Abi, Cairn.Text.Host, Cairn.Text.Field, Cairn.Layout.Core
Definitions 13
verdict {α : Type} (decoded : Option α) (reencode : α → ByteArray)
(dump : α → String) (b : ByteArray) : ByteArray"A=", "A~" or "R", then the dump.
genFrame (seed : UInt64) : ByteArray
decodeFrameVerdict (b : ByteArray) : ByteArray
decodeEventsVerdict (b : ByteArray) : ByteArray
fieldRef : ControlRef
fieldView (f : Text.Field) (ui : UI) : Node
One text field across the window, with a little padding so the field's text is inset and long text scrolls.
fieldUpdate (f : Text.Field) : Action → Text.Field × List Effect
fieldApp : App Text.Field
fieldCfg : Runtime.Config
fieldInit (w h scalePercent : UInt32) : Runtime.State Text.Field
fieldStep (s : Runtime.State Text.Field) (events : ByteArray) : Runtime.State Text.Field
fieldFrame (s : Runtime.State Text.Field) : ByteArray
wrap (family size weight : UInt32) (style : UInt8) (tracking width : UInt32) (s : String) : ByteArray
A string wrapped at width (a para filling a window that wide), as int32s: the line count,
then for each line its scalar range a, b, Lean's width for it (o b - o a) and the x, y, w
of the line's laid-out rect.