Targets · Swift · Native modules

Native modules

The hand-written, per-platform code behind NATIVE functions.

Contents

How a Program becomes Swift, in parts. Start with the introduction, then follow each part into the rendered output and the runtime it links against.

Hand-written Swift behind NATIVE

A function's hand-written swift NATIVE body is dropped in where the function is called, wrapped so its inputs arrive as plain Swift values.

public static func Add(_ a: Any, _ b: Any) -> ReactiveValue<Double> {
  return Reactive.Calculate {
    let a = Reactive.Value(__reactive_a) as! Double
    let b = Reactive.Value(__reactive_b) as! Double
    return a + b               // the swift NATIVE body
  }
}

As on JavaScript, the drivers are native code too — the SwiftUI interface driver, animation and network live in their modules' native Swift — and the runtime (Reactive, Context) is itself a native module the rest builds on.