macro librarylib/Ffi.xtlm

Ffi.xtlm -- the binding macro: a facade function written from the signature of a native function (docs/ffi-macro.md). Import: "ffi:" u_se< "Ffi" (xetal-x puts this directory on XETAL_PATH)

"s_hout : text -> text" ᶠᶠⁱb̲ind< "hello/shout"

expands to the facade function l:s_hout, which speaks the ext: channel (docs/bridge.md). Kinds: unit (no argument), text, chars, int, float (an argument of any rank; as a result, a scalar), and as results also floats and ints (any rank, reshaped by the reply's shape).

source

ʰw̲ords : Char -> Box Char

function (private) · line 13

private: the words of a text, and the i-th of them

ʰw̲ords ← { s → (n̲ot s = f̲irst " ") p̲artition s }

ʰw̲ord : Int -> Box a -> a

function (private) · line 14
ʰw̲ord ← { i w → d̲isclose i s̲elect w }

ʰv̲alue : Char -> Char -> Char

function (private) · line 18

private: what an argument a of kind k is sent as, and the query that says its kind (and shape)

ʰv̲alue ← { k a →
  k m̲atch "text" ? a
  k m̲atch "chars" ? "(r_avel " c̲at a c̲at ")"
  k m̲atch "int" ? "(f_ormat r_avel f_loor " c̲at a c̲at ")"
  "(f_ormat r_avel f_loat " c̲at a c̲at ")"
}
Used in: ʰp̲ut

ʰq̲uery : Char -> Char -> Char

function (private) · line 24
ʰq̲uery ← { k a →
  k m̲atch "text" ? "?text\""
  k m̲atch "chars" ? "?chars=\" c_at f_ormat s_hape " c̲at a
  k m̲atch "int" ? "?int=\" c_at f_ormat s_hape " c̲at a
  "?float=\" c_at f_ormat s_hape " c̲at a
}
Used in: ʰp̲ut

ʰp̲ut : Char -> Char -> Char

function (private) · line 32

private: the line putting argument a (kind k) for the native function t

ʰp̲ut ← { ka t →
  k ← 1 ʰw̲ord ʰw̲ords ka
  a ← 2 ʰw̲ord ʰw̲ords ka
  "  p" c̲at a c̲at " := " c̲at (k ʰv̲alue a) c̲at " []N_PUT \"ext:" c̲at t c̲at (k ʰq̲uery a) c̲at "\n"
}
Used in: ʰp̲uts

ʰg̲et : Char -> Char -> Char

function (private) · line 39

private: the lines getting the reply of t as kind k

ʰg̲et ← { k t →
  call ← "[]N_GET \"ext:" c̲at t c̲at "\""
  shape ← "(f_loor n_umbers []N_GET \"ext:" c̲at t c̲at "?shape\") r_eshape v\n"
  k m̲atch "text" ? "  " c̲at call c̲at "\n"
  k m̲atch "float" ? "  f_irst n_umbers " c̲at call c̲at "\n"
  k m̲atch "int" ? "  f_loor f_irst n_umbers " c̲at call c̲at "\n"
  k m̲atch "floats" ? "  v := n_umbers " c̲at call c̲at "\n  " c̲at shape
  k m̲atch "ints" ? "  v := f_loor n_umbers " c̲at call c̲at "\n  " c̲at shape
  "  v := " c̲at call c̲at "\n  " c̲at shape
}
Used in: ᵐb̲ind<

ʰp̲arams : (Any a, Num b) => a -> b -> Char

function (private) · line 51

private: the parameters and the put lines, by how many arguments there are

ʰp̲arams ← { w n →
  n = 0 ? "@"
  n = 1 ? "a"
  "a b"
}
Used in: ᵐb̲ind<

ʰp̲uts : Box Char -> Char -> Char

function (private) · line 56
ʰp̲uts ← { w t →
  n ← (t̲ally w) − 4
  (n = 1) × (3 ʰw̲ord w) m̲atch "unit" ? ""
  n = 1 ? ((3 ʰw̲ord w) c̲at " a") ʰp̲ut t
  (((3 ʰw̲ord w) c̲at " a") ʰp̲ut t) c̲at ((4 ʰw̲ord w) c̲at " b") ʰp̲ut t
}
Used in: ᵐb̲ind<

ᵐb̲ind< : Char -> Char -> Char

macro · line 64
ᵐb̲ind< ← { sig target →
  w ← ʰw̲ords sig
  n ← t̲ally w
  args ← (n − 4) − (3 ʰw̲ord w) m̲atch "unit"
  "l:" c̲at (1 ʰw̲ord w) c̲at " := { " c̲at (w ʰp̲arams args) c̲at " ->\n" c̲at (w ʰp̲uts target) c̲at ((n ʰw̲ord w) ʰg̲et target) c̲at "}"
}