Documentation
¶
Overview ¶
Package gen turns a wire schema into code: Go (methods on the schema's own types), Swift (NimbusNativeKit hosts) and Kotlin (Android hosts). All three produce byte-identical encodings; conformance_test.go proves it.
Index ¶
- Constants
- func Go(s *schema.Schema) ([]byte, error)
- func Kotlin(s *schema.Schema, kotlinPackage string) []byte
- func KotlinSchema(kotlinPackage string, combined uint64) []byte
- func Namespace(s *schema.Schema) string
- func Swift(s *schema.Schema) []byte
- func SwiftApp(s *schema.Schema) []byte
- func SwiftSchema(combined uint64) []byte
- type Output
Constants ¶
const GoFile = "wire_gen.go"
GoFile is the name of the generated file written into the schema package.
Variables ¶
This section is empty.
Functions ¶
func Go ¶
Go generates methods on the schema's own types: AppendWire / ReadWire on every struct, Append<U> / Read<U> and variant markers for every union, and the Message union with Encode / Decode.
func Kotlin ¶
Kotlin generates the schema's types for Android hosts as one object named after the package (package proto → object Proto) in the given Kotlin package: data classes for structs, sealed interfaces for unions, constant objects for enums. It needs space.nimbusgo.nativekit's WireReader / WireWriter.
Integers keep their size and sign where Kotlin can (Byte, Short, Int, Long); unsigned ones widen: uint8/16 → Int, uint32 → Long, and uint64 is a Long holding the unsigned bit pattern.
func KotlinSchema ¶
KotlinSchema generates the object holding the combined schema hash a host passes to Bridge.start.
func Swift ¶
Swift generates the schema's types for iOS hosts, inside one namespace enum named after the package (package proto → enum Proto). It needs the NimbusNativeKit wire runtime (Wire.swift) in the same module.
func SwiftApp ¶
SwiftApp is Swift for an app's own schema: it imports NimbusNativeKit when the kit is a separate module (a Swift package in an Xcode project) and compiles as one module with it otherwise (the CLI build).
func SwiftSchema ¶
SwiftSchema generates the file that tells the host which combined schema hash to pass to nn_start.
Types ¶
type Output ¶
type Output struct {
Schema *schema.Schema
Go []byte // write to <schema dir>/wire_gen.go
Swift []byte // compile into the iOS app (imports NimbusNativeKit when it is a package)
Kotlin []byte // compile into the Android host, as <Namespace>.kt
}
Output is everything generated for one schema package.