01 / std/binary_linux.zi

binary_linux

Little-endian binary fields for native Linux programs. No file format or application record layout is imposed by this module.

Import with #import "binary_linux" and pass --module-path std.

ReadU64LE :: (bytes: []u8, at: s32) -> u64
WriteU64LE :: (bytes: []u8, at: s32, value: u64) -> bool
ReadF64LE :: (bytes: []u8, at: s32) -> float64
WriteF64LE :: (bytes: []u8, at: s32, value: float64) -> bool

Source ↗

02 / std/bundle_host.zi

bundle_host

Native C ABI for embedding a portable Ziran bundle. The runtime owns the bundle and instance; callers own binding contexts and borrowed result data.

Import with #import "bundle_host" and pass --module-path std.

HostValueKind :: enum { HostVoid = 0; HostInteger = 1; HostUnsigned = 2; HostReal = 3; HostString = 4; HostRecord = 5; HostSlice = 6; HostPointer = 7; HostArray = 8; }
HostValue :: struct { kind: s32; type_name: *u8; integer: s64; bits: u64; real: float64; data: *u8; length: u64; fields: *HostField; field_count: u64; elements: *HostValue; pointer: *void; }
HostField :: struct { name: *u8; value: HostValue; }
HostCall :: #type (context: *void, module: *u8, function: *u8, arguments: *HostValue, count: s32, result: *HostValue) -> s32
HostBinding :: struct { module: *u8; function: *u8; call: HostCall; context: *void; }
OpenBundle :: (path: *u8) -> *void
CloseBundle :: (bundle: *void)
InstantiateBundle :: (bundle: *void, bindings: *HostBinding, count: u64) -> *void
RunBundleInstance :: (instance: *void, result: *s64, has_result: *s32) -> s32
CloseBundleInstance :: (instance: *void)

Source ↗

03 / std/byte_text_linux.zi

byte_text_linux

Borrow UTF-8 bytes as a Ziran string at native foreign-function boundaries. The caller must keep the byte storage alive while the string is in use.

Import with #import "byte_text_linux" and pass --module-path std.

TextDescriptor :: struct { data: *u8; length: usize; }
ByteDescriptor :: struct { data: *u8; length: s64; }
TextFromBytes :: (buffer: []u8) -> string
BytesFromPointer :: (data: *u8, count: u64) -> []u8

Borrow native storage at a foreign-function boundary. The caller must keep it allocated and writable throughout the slice's use.

TextFromCString :: (value: *u8) -> string

The returned string borrows the C buffer and retains its lifetime.

Source ↗

04 / std/c_string.zi

c_string

Copies a borrowed Ziran string into caller-owned, NUL-terminated storage. Reject embedded NUL bytes and insufficient capacity before exposing the buffer to a native C API.

Import with #import "c_string" and pass --module-path std.

CopyCString :: (value: string, output: []u8) -> bool

Source ↗

05 / std/constant_time.zi

constant_time

Constant-time equality for caller-owned byte spans. The length check is intentionally explicit; callers protecting secret tags should use fixed-size buffers so unequal lengths do not become an oracle.

Import with #import "constant_time" and pass --module-path std.

ConstantTimeEqual :: (left: []u8, right: []u8) -> bool
ConstantTimeTextEqual :: (left: string, right: string) -> bool

Text carries arbitrary bytes without a mutable borrowed view. Compare every byte of equal-length tags just as for caller-owned byte spans.

Source ↗

06 / std/date_parse.zi

date_parse

UTC calendar parsing for feeds and dated data sources.

Import with #import "date_parse" and pass --module-path std.

DateDigit :: (value: u8) -> s32
DateNumber :: (value: string, start: s32, count: s32) -> s32
DaysFromCivil :: (year: s32, month: s32, day: s32) -> s64
DateValid :: (year: s32, month: s32, day: s32) -> bool
UtcDate :: struct { year: s32; month: s32; day: s32; hour: s32; minute: s32; second: s32; }
CivilFromUnix :: (timestamp: s64) -> UtcDate
DateWriteDigits :: (output: []u8, at: s32, value: s32, digits: s32) -> s32
WriteCompactUtc :: (timestamp: s64, output: []u8) -> s32
WriteIsoDay :: (timestamp: s64, output: []u8) -> s32
UtcSeconds :: (year: s32, month: s32, day: s32, hour: s32, minute: s32, second: s32) -> s64
ParseCompactUtc :: (value: string) -> s64
DateMonth :: (value: string, at: s32) -> s32
ParseRfc822Utc :: (value: string) -> s64

Source ↗

07 / std/date_time.zi

date_time

Import with #import "date_time" and pass --module-path std.

LocalDateTime :: struct { year: s32; month: s32; day: s32; day_of_year: s32; hour: s32; minute: s32; second: s32; valid: bool; }

The host supplies local civil time, including timezone and daylight-saving decisions. day_of_year is zero-based, matching the platform tm convention.

LocalNow :: () -> LocalDateTime

Needs a host capability.

UnixNow :: () -> s64

Needs a host capability.

Source ↗

08 / std/date_time_linux.zi

date_time_linux

Unix clock for native Linux programs.

Import with #import "date_time_linux" and pass --module-path std.

UnixNow :: () -> s64

Source ↗

09 / std/file_linux.zi

file_linux

Import with #import "file_linux" and pass --module-path std.

FileHandle :: struct { fd: s32; valid: bool; }
OpenRead :: (path: string) -> FileHandle
OpenUpdate :: (path: string) -> FileHandle
OpenReplace :: (path: string) -> FileHandle
OpenExclusivePrivate :: (path: string) -> FileHandle
RemoveFile :: (path: string) -> bool
PathExists :: (path: string) -> bool
DirectoryExists :: (path: string) -> bool
RenamePath :: (source: string, destination: string) -> bool
RenameNoReplace :: (source: string, destination: string) -> bool
LinkFile :: (source: string, destination: string) -> bool
CreateDirectory :: (path: string) -> bool
CreatePrivateDirectory :: (path: string) -> bool
FileSize :: (file: FileHandle) -> s64
ReadAt :: (file: FileHandle, output: []u8, offset: s64) -> s64
WriteAt :: (file: FileHandle, input: []u8, offset: s64) -> s64
WriteTextAt :: (file: FileHandle, input: string, offset: s64) -> s64

Copy immutable text through a bounded buffer before writing it. The string may borrow read-only storage, so it must not be exposed as a mutable slice.

CloseFile :: (file: FileHandle) -> bool
SyncFile :: (file: FileHandle) -> bool

Source ↗

10 / std/hmac_sha256_go.zi

hmac_sha256_go

Import with #import "hmac_sha256_go" and pass --module-path std.

DigestResult :: struct { value: string; error: string; }
HMACSHA256 :: (key: []u8, message: string) -> DigestResult

HMAC over arbitrary text bytes. SHA-256 itself comes from Go's crypto package; this module owns only RFC 2104's key normalization and pads.

Source ↗

11 / std/http_get_linux.zi

http_get_linux

Import with #import "http_get_linux" and pass --module-path std.

GetHttps :: (url: string, output: []u8) -> CaptureResult

Native HTTPS GET. curl owns TLS and redirects; the caller owns storage.

Source ↗

12 / std/json_scan.zi

json_scan

Import with #import "json_scan" and pass --module-path std.

JsonSpan :: struct { start: s32; end: s32; after: s32; valid: bool; }

A small allocation-free JSON scanner. Positions are UTF-8 byte offsets. String spans retain escapes; member lookup matches unescaped ASCII names.

JsonNumber :: struct { value: float64; after: s32; valid: bool; }
Space :: (text: string, at: s32) -> s32
Digit :: (ch: u8) -> bool
Hex :: (ch: u8) -> bool
ReadString :: (text: string, at: s32) -> JsonSpan
SpanEqualsASCII :: (text: string, span: JsonSpan, expected: string) -> bool
SpanContainsFoldASCII :: (text: string, span: JsonSpan, needle: string) -> bool
ReadNumber :: (text: string, at: s32) -> JsonNumber
MatchLiteral :: (text: string, at: s32, literal: string) -> bool
ValueEnd :: (text: string, at: s32, depth: s32) -> s32
FieldAt :: (text: string, object_at: s32, name: string) -> s32
ElementAt :: (text: string, array_at: s32, index: s32) -> s32
ArrayCount :: (text: string, array_at: s32) -> s32

Source ↗

13 / std/mapped_file_linux.zi

mapped_file_linux

Import with #import "mapped_file_linux" and pass --module-path std.

MappedFile :: struct { data: *u8; length: u64; valid: bool; }
MapPrivate :: (path: string) -> MappedFile
MappedBytes :: (file: MappedFile) -> []u8
UnmapFile :: (file: MappedFile) -> bool

Source ↗

14 / std/math.zi

math

Portable float32 helpers for native and bundled Ziran programs.

Import with #import "math" and pass --module-path std.

Finite32 :: (value: float32) -> bool
FloorInteger :: (value: float32) -> s32
CeilInteger :: (value: float32) -> s32
SineDegrees :: (degrees: float32) -> float32

Reduce to [-pi/2, pi/2] before the Taylor polynomial.

CosineDegrees :: (degrees: float32) -> float32

Source ↗

15 / std/net_http.zi

net_http

Import with #import "net_http" and pass --module-path std.

HttpHeader :: struct { name: string; value: string; }

Network transport is an explicit host capability. The host adds a Bearer Authorization header when token is nonempty. It must not log that token. The request and response records have the same meaning in native targets and portable bundles.

HttpRequest :: struct { method: string; url: string; token: string; accept: string; content_type: string; body: string; headers: []HttpHeader; }
HttpResponse :: struct { status: s32; body: string; error: string; }
Send :: (request: HttpRequest) -> HttpResponse

Needs a host capability.

Source ↗

16 / std/net_http_curl_linux.zi

net_http_curl_linux

Import with #import "net_http_curl_linux" and pass --module-path std.

CurlInitRoutine :: #type ()
CurlUrl :: 10002
CurlMethod :: 10036
CurlWriteData :: 10001
CurlWriteFunction :: 20011
CurlHeaders :: 10023
CurlPostFields :: 10015
CurlPostSize :: 30120
CurlTimeoutMs :: 155
CurlConnectTimeoutMs :: 156
CurlNoSignal :: 99
CurlResponseCode :: 2097154
curl_once: s32
curl_init_result: s32
InitCurl :: ()
CurlReady :: () -> bool
StartsWith :: (value: string, prefix: string) -> bool
MethodToken :: (value: string) -> bool
HeaderName :: (value: string) -> bool
CurlResult :: struct { status: s32; length: s64; code: s32; truncated: bool; }
CurlOutput :: struct { data: *u8; capacity: s64; length: s64; truncated: bool; }
CurlWriteCallback64 :: #type (data: *u8, size: u64, count: u64, user: *void) -> u64
CurlWriteCallback32 :: #type (data: *u8, size: u32, count: u32, user: *void) -> u32
AppendCurlOutput :: (data: *u8, size: u64, count: u64, context: *CurlOutput) -> u64
CurlWrite64 :: (data: *u8, size: u64, count: u64, user: *void) -> u64
CurlWrite32 :: (data: *u8, size: u32, count: u32, user: *void) -> u32
SetCurlLong :: (handle: *void, option: s32, value: s32) -> bool
ReadCurlStatus :: (handle: *void) -> s32
HeaderText :: (prefix: string, value: string, output: []u8) -> bool
AddCurlHeader :: (headers: **void, prefix: string, value: string, buffer: []u8) -> bool
AddNamedHeader :: (headers: **void, name: string, value: string, buffer: []u8) -> bool
SendCurl :: (request: HttpRequest, output: []u8) -> CurlResult

The caller owns output. It remains NUL terminated, including on failure. HTTP errors retain their status and body for protocol-level decisions.

Source ↗

17 / std/net_http_linux.zi

net_http_linux

Import with #import "net_http_linux" and pass --module-path std.

PostJson :: (url: string, body: string, output: []u8) -> CaptureResult

Native HTTPS JSON transport. curl owns TLS and HTTP framing; Ziran owns the request arguments and caller-provided response buffer.

Source ↗

18 / std/net_ws_curl_linux.zi

net_ws_curl_linux

Blocking, bounded WebSocket text receive for native libcurl hosts. The protocol consumer owns URL construction and JSON validation.

Import with #import "net_ws_curl_linux" and pass --module-path std.

CurlWsFrame :: struct { age: s32; flags: s32; offset: s64; bytes_left: s64; length: u64; }
PollDescriptor :: struct { fd: s32; events: s16; returned: s16; }
CurlConnectOnly :: 141
CurlActiveSocket :: 5242924
CurlAgain :: 81
CurlWsText :: 1
CurlWsContinue :: 4
CurlWsClose :: 8
PollRead :: 1

Output is NUL terminated on success. status is 401 on an unauthorized

ReceiveWebSocketCurl :: (context: *void, url: string, token: string, output: []u8, status: *s32) -> bool

Source ↗

19 / std/number_text.zi

number_text

Import with #import "number_text" and pass --module-path std.

FormatInteger :: (value: s64, output: []u8) -> string

A whole number in base ten. The buffer needs 21 bytes for any s64.

FormatDecimal :: (value: float64, places: s32, output: []u8) -> string

A number rounded to `places` digits after the point (at most 9), with trailing zeros dropped: 0.5, 12, -3.25. The buffer needs 32 bytes.

Source ↗

20 / std/option.zi

option

Import with #import "option" and pass --module-path std.

Option :: struct($T: Type) { has_value: bool; value: T; }

Source ↗

21 / std/pair.zi

pair

Import with #import "pair" and pass --module-path std.

Pair :: struct($A: Type, $B: Type) { first: A; second: B; }

Source ↗

22 / std/process.zi

process

Import with #import "process" and pass --module-path std.

ProcessRequest :: struct { executable: string; cwd: string; stdin: string; credential_name: string; credential_value: string; isolate_desktop: bool; timeout_ms: s64; }

A line-oriented child-process capability. The host receives explicit arguments, stdin, and one optional secret environment binding. Hosts must honor isolate_desktop before starting any child. Handles are host-owned; callers consume lines and then wait exactly once.

ProcessStart :: struct { handle: s32; error: string; }
ProcessLine :: struct { text: string; eof: bool; error: string; }
ProcessExit :: struct { code: s32; stderr: string; error: string; }
Start :: (request: ProcessRequest, args: []string) -> ProcessStart

Needs a host capability.

NextLine :: (handle: s32) -> ProcessLine

Needs a host capability.

Wait :: (handle: s32) -> ProcessExit

Needs a host capability.

Source ↗

23 / std/process_capture_linux.zi

process_capture_linux

Import with #import "process_capture_linux" and pass --module-path std.

CapturePointer :: struct { value: *u8; }
CaptureArgument :: struct { bytes: [4096]u8; }
CaptureResult :: struct { code: s32; length: s32; error: bool; truncated: bool; }
CaptureOutput :: (arguments: []string, output: []u8) -> CaptureResult

Source ↗

24 / std/queue.zi

queue

Allocation-free bounded FIFO queue over caller-owned byte storage. Queue state is passed and returned by value; every operation receives the backing bytes explicitly so their lifetime remains visible to the caller.

Import with #import "queue" and pass --module-path std.

BoundedQueue :: struct { capacity: s64; head: s64; count: s64; }
QueueByte :: struct { queue: BoundedQueue; valid: bool; value: u8; }
QueueBytes :: struct { queue: BoundedQueue; count: s64; }
QueueStart :: (storage: []u8) -> BoundedQueue
QueueCapacity :: (queue: BoundedQueue) -> s64
QueueCount :: (queue: BoundedQueue) -> s64
QueuePush :: (queue: BoundedQueue, storage: []u8, value: u8) -> BoundedQueue
QueuePushBytes :: (queue: BoundedQueue, storage: []u8, input: []u8) -> BoundedQueue
QueuePop :: (queue: BoundedQueue, storage: []u8) -> QueueByte
QueuePopBytes :: (queue: BoundedQueue, storage: []u8, output: []u8) -> QueueBytes
QueueClear :: (queue: BoundedQueue) -> BoundedQueue

Source ↗

25 / std/random_linux.zi

random_linux

Secure operating-system randomness for native Linux programs. The caller owns the destination bytes and no fallback generator is permitted.

Import with #import "random_linux" and pass --module-path std.

FillSecure :: (output: []u8) -> bool

Source ↗

26 / std/result.zi

result

Import with #import "result" and pass --module-path std.

Result :: struct($T: Type, $E: Type) { is_ok: bool; value: T; error: E; }

Source ↗

27 / std/rss_scan.zi

rss_scan

Import with #import "rss_scan" and pass --module-path std.

FeedSpan :: struct { start: s32; end: s32; after: s32; valid: bool; }
FeedMatch :: (document: string, at: s32, needle: string) -> bool
FeedFind :: (document: string, from: s32, needle: string) -> s32
FeedNextItem :: (document: string, from: s32) -> FeedSpan
FeedTag :: (document: string, item: FeedSpan, tag: string) -> FeedSpan
FeedEntity :: (document: string, at: s32, end: s32, output: *u8) -> s32
FeedCopyText :: (document: string, span: FeedSpan, output: []u8) -> s32

Copies a text or CDATA field into caller-owned storage. Tags in summaries become spaces, and a malformed/truncated field is rejected.

Source ↗

28 / std/socket_linux.zi

socket_linux

Bounded, cancellation-aware TCP client sockets for native Linux programs. The caller supplies a literal IPv4 address; this module performs no DNS, HTTP, TLS, or plaintext-protocol fallback.

Import with #import "socket_linux" and pass --module-path std.

LinuxSocket :: struct { fd: s32; valid: bool; error: s32; }
LinuxSocketEvent :: struct { ready: s32; error: s32; }
LinuxSocketAddress :: struct { family: u16; port: u16; address: u32; zero: [8]u8; }
LinuxPollFd :: struct { fd: s32; events: s16; revents: s16; }
LinuxErrno :: () -> s32
SocketWaitForEvents :: (socket: LinuxSocket, events: s32, timeout_ms: s32) -> LinuxSocketEvent
SocketConnectError :: (socket: LinuxSocket) -> s32
OpenTCPv4 :: (address: [4]u8, port: u16, timeout_ms: s32) -> LinuxSocket
SocketCancel :: (socket: LinuxSocket) -> bool
SocketSendAll :: (socket: LinuxSocket, input: []u8, timeout_ms: s32) -> s64
SocketReceive :: (socket: LinuxSocket, output: []u8, timeout_ms: s32) -> s64
SocketClose :: (socket: *LinuxSocket) -> bool

Source ↗

29 / std/sort.zi

sort

Sorting and searching for slices of any type ordered by the < operator. Sorting is an in-place heapsort: O(n log n) comparisons, no allocation, no recursion, and not stable.

Import with #import "sort" and pass --module-path std.

Sort :: (values: []$T)

Sorts values in ascending order.

IsSorted :: (values: []$T) -> bool

Reports whether values are in ascending order.

LowerBound :: (values: []$T, target: T) -> s64

Returns the first index whose value is not less than target, or values.count when every value is less. values must be sorted.

BinarySearch :: (values: []$T, target: T) -> s64

Returns an index holding target, or -1 when values has none. values must be sorted.

Source ↗

30 / std/string_range.zi

string_range

A byte range of an immutable borrowed string. Bounds are checked by Ziran. Callers working with UTF-8 text should choose codepoint boundaries.

Import with #import "string_range" and pass --module-path std.

Substring :: (source: string, start: s32, length: s32) -> string

Source ↗

31 / std/text.zi

text

ASCII-only case folding keeps the result identical across native targets and the portable runner. UTF-8 bytes outside ASCII compare unchanged.

Import with #import "text" and pass --module-path std.

LowerASCII :: (value: u8) -> u8
StartsWithFoldASCII :: (value: string, prefix: string) -> bool
ContainsFoldASCII :: (value: string, needle: string) -> bool

Source ↗

32 / std/text_buffer.zi

text_buffer

Bounded NUL-terminated byte buffer to borrowed text. The caller keeps the buffer alive until the returned view is no longer used.

Import with #import "text_buffer" and pass --module-path std.

TextUntilNul :: (buffer: []u8) -> string

Source ↗

33 / std/timer_linux.zi

timer_linux

Monotonic timing and interruptible sleeps for native glibc Linux programs. Wall-clock time is intentionally unavailable from this module.

Import with #import "timer_linux" and pass --module-path std.

ClockValue :: struct { seconds: s64; nanoseconds: s64; }
MonotonicMilliseconds :: () -> s64
MakeClockValue :: (milliseconds: s64) -> ClockValue
SleepMilliseconds :: (milliseconds: s64) -> bool

Source ↗

34 / std/update.zi

update

Import with #import "update" and pass --module-path std.

Artifact :: struct { url: [512]u8; sha256: [65]u8; size: s64; available: bool; }

Release metadata and version decisions are portable. Downloading and installing an artifact remain explicit host operations.

Appcast :: struct { version: [32]u8; notes_url: [512]u8; artifact: Artifact; valid: bool; }
CompareVersions :: (left: string, right: string) -> s32
ParseAppcast :: (json: string, channel: string) -> Appcast

Select one channel from the release manifest. A missing channel still yields a valid appcast: package-managed installs show the release page.

Source ↗

35 / std/utf8.zi

utf8

Advance one Unicode scalar in an immutable UTF-8 string. An invalid byte advances by one so callers always make progress and never split a valid multibyte sequence.

Import with #import "utf8" and pass --module-path std.

Continuation :: (byte: u8) -> bool
Decoded :: struct { value: u32; after: s32; valid: bool; }
Decode :: (text: string, at: s32) -> Decoded

Decode one scalar. A malformed sequence consumes its lead byte and yields U+FFFD so callers can continue scanning without splitting valid text.

Next :: (value: string, at: s32) -> s32
Count :: (value: string) -> s32

Source ↗

36 / std/vec.zi

vec

Owned growable storage. Operations on Vec values are compiler primitives; the data pointer is private to those operations.

Import with #import "vec" and pass --module-path std.

Vec :: struct($T: Type) { data: *T; count: s64; capacity: s64; }

Source ↗

37 / std/web.zi

web

Browser access for Ziran code compiled to WebAssembly. Any Web API is reachable through objects held in the page's handle table: read and write properties, call methods, construct objects, pass Ziran functions as callbacks, and wait on promises. The page side is web/ziran_web.js. A handle is an s32; 0 means null or undefined, 1 is the global object, and 2 is Emscripten's Module. Names are interned once with WebName and reused, which keeps each call cheap. Handles the bridge returns are temporary: they all die when the current scope ends. A callback is its own scope; a long-running loop should wrap each pass in WebScope and WebEnd. WebKeep turns a temporary handle into one that lasts until WebRelease, for objects a program holds on to.

Import with #import "web" and pass --module-path std.

WebValue :: struct { tag: s32; aux: s32; number: float64; }

A value crossing the boundary: a tag, a length or handle, and a number.

WebUndefinedTag :: 0
WebNullTag :: 1
WebBoolTag :: 2
WebNumberTag :: 3
WebTextTag :: 4
WebObjectTag :: 5
WebStringTag :: 6
WebGlobal :: 1
WebModule :: 2
WebBytesUint8 :: 0

The kinds of typed array WebBytes builds.

WebBytesUint8Clamped :: 1
WebBytesInt16 :: 2
WebBytesInt32 :: 3
WebBytesFloat32 :: 4
WebTypeUndefined :: 0

What WebTypeOf reports.

WebTypeNull :: 1
WebTypeBool :: 2
WebTypeNumber :: 3
WebTypeString :: 4
WebTypeObject :: 5
WebTypeFunction :: 6

Receives a JS function's first three arguments as handles that are valid

WebCallback :: #type (context: s32, first: s32, second: s32, third: s32)
web_failed: bool
WebName :: (text: string) -> s32

Interns a name for property and method access. Do this once per name.

WebUndefined :: () -> WebValue
WebNull :: () -> WebValue
WebBool :: (value: bool) -> WebValue
WebNumber :: (value: float64) -> WebValue
WebText :: (text: string) -> WebValue

The text is read while the call it is passed to runs, so it must stay alive until then.

WebObject :: (handle: s32) -> WebValue
WebAsNumber :: (value: WebValue) -> float64
WebAsBool :: (value: WebValue) -> bool
WebAsObject :: (value: WebValue) -> s32

The handle of an object or string result, or 0.

WebIsUndefined :: (value: WebValue) -> bool
WebFailed :: () -> bool

Whether the last property access, call, or construction threw. The exception is WebLastError.

WebLastError :: () -> s32
WebGet :: (object: s32, name: s32) -> WebValue
WebGetNumber :: (object: s32, name: s32) -> float64
WebGetObject :: (object: s32, name: s32) -> s32
WebSet :: (object: s32, name: s32, value: WebValue)
WebAt :: (object: s32, index: s32) -> WebValue
WebSetAt :: (object: s32, index: s32, value: WebValue)
WebCall :: (object: s32, name: s32, args: *WebValue, count: s32) -> WebValue
WebCall0 :: (object: s32, name: s32) -> WebValue
WebCall1 :: (object: s32, name: s32, a: WebValue) -> WebValue
WebCall2 :: (object: s32, name: s32, a: WebValue, b: WebValue) -> WebValue
WebCall3 :: (object: s32, name: s32, a: WebValue, b: WebValue, c: WebValue) -> WebValue
WebCall4 :: (object: s32, name: s32, a: WebValue, b: WebValue, c: WebValue, d: WebValue) -> WebValue
WebCall5 :: (object: s32, name: s32, a: WebValue, b: WebValue, c: WebValue, d: WebValue, e: WebValue) -> WebValue
WebCall6 :: (object: s32, name: s32, a: WebValue, b: WebValue, c: WebValue, d: WebValue, e: WebValue, f: WebValue) -> WebValue
WebCall8 :: (object: s32, name: s32, a: WebValue, b: WebValue, c: WebValue, d: WebValue, e: WebValue, f: WebValue, g: WebValue, h: WebValue) -> WebValue
WebNew :: (constructor: s32, args: *WebValue, count: s32) -> s32

Constructs `new constructor(args...)`; returns the new object's handle.

WebNew0 :: (constructor: s32) -> s32
WebNew1 :: (constructor: s32, a: WebValue) -> s32
WebNew2 :: (constructor: s32, a: WebValue, b: WebValue) -> s32
WebNew3 :: (constructor: s32, a: WebValue, b: WebValue, c: WebValue) -> s32
WebValueOf :: (handle: s32) -> WebValue

The value a handle holds, such as the number a callback argument carries.

WebNewObject :: () -> s32
WebNewArray :: () -> s32
WebRelease :: (handle: s32)

Frees a handle made by WebKeep or WebFunction. Temporary handles need no release.

WebScope :: () -> s32

Starts a scope; WebEnd(mark) frees every temporary handle made since.

WebEnd :: (mark: s32)
WebKeep :: (handle: s32) -> s32

A handle to the same object that lasts until WebRelease, unlike the temporary one it came from.

WebLiveHandles :: () -> s32

How many handles are live, for checking a program does not leak them.

WebTypeOf :: (handle: s32) -> s32
WebInstanceOf :: (handle: s32, constructor: s32) -> bool
WebFunction :: (callback: WebCallback, context: s32) -> s32

A JS function that runs `callback` with `context` and up to three argument handles, kept until released.

WebStringLength :: (handle: s32) -> s32

The length in bytes of a string handle's text.

WebCopyString :: (handle: s32, buffer: []u8) -> s32

Copies a string handle's text into `buffer`, NUL-terminated, and returns its length in bytes.

WebBytes :: (kind: s32, data: *void, count: s32) -> s32

A typed array holding a copy of `count` elements from `data`.

WebCopyOut :: (handle: s32, data: *void, capacity: s32) -> s32

Copies a typed array's bytes into `data`, at most `capacity`; returns the number copied.

WebCopyIn :: (handle: s32, data: *void, length: s32) -> s32

Copies `length` bytes from `data` over the start of a typed array.

WebAwait :: (promise: s32, result: *WebValue) -> bool

Suspends until the promise settles. Returns whether it resolved, with its value in `result`.

WebSleep :: (milliseconds: s32)
WebNextFrame :: (minimum_delay: float64)

Suspends until the browser draws its next frame, and at least `minimum_delay` milliseconds have passed.

Source ↗

38 / std/zip.zi

zip

Classic ZIP directory reader for byte buffers. The caller owns the archive bytes and decides which named entries are allowed in its application. ZIP64, encrypted entries, split archives, and ambiguous names are rejected.

Import with #import "zip" and pass --module-path std.

ZipEntry :: struct { data_start: u64; compressed_size: u64; size: u64; crc32: u32; method: u32; found: bool; }
ZipDirectory :: struct { start: u64; end: u64; cursor: u64; count: u64; index: u64; valid: bool; }
ZipNamedEntry :: struct { directory: ZipDirectory; entry: ZipEntry; name_start: u64; name_size: u64; valid: bool; }
ZipWriteItem :: struct { name_start: u64; name_size: u64; data_start: u64; data_size: u64; }
ZipU16 :: (bytes: []u8, at: u64) -> u32
ZipU32 :: (bytes: []u8, at: u64) -> u32
ZipNameEqual :: (bytes: []u8, at: u64, size: u64, wanted: string) -> bool
OpenZipDirectory :: (bytes: []u8) -> ZipDirectory
ZipNamesMatch :: (bytes: []u8, first: u64, second: u64, size: u64) -> bool
NextZipEntry :: (bytes: []u8, directory: ZipDirectory) -> ZipNamedEntry

On malformed input, both the returned record and the cursor become invalid.

FindZipEntry :: (bytes: []u8, wanted: string) -> ZipEntry

A missing or invalid entry has found=false. Duplicate names are invalid.

ZipCRC32Update :: (crc_start: u32, bytes: []u8) -> u32
ZipCRC32 :: (bytes: []u8) -> u32
CopyStoredZipEntry :: (bytes: []u8, entry: ZipEntry, output: []u8) -> bool
ZipPut16 :: (output: []u8, at: u64, value: u32)
ZipPut32 :: (output: []u8, at: u64, value: u32)
StoredZipSize :: (input: []u8, items: []ZipWriteItem) -> u64

Returns the exact output size or zero when classic ZIP limits are exceeded.

ZipCopyBytes :: (output: []u8, at: u64, input: []u8, input_at: u64, size: u64)
ZipCRC32Range :: (bytes: []u8, at: u64, size: u64) -> u32
WriteStoredZip :: (output: []u8, input: []u8, items: []ZipWriteItem) -> u64

Writes uncompressed ZIP entries into caller-owned memory. An app can choose compression separately; this keeps the archive format portable and usable even where no native compression library is installed.

Source ↗

39 / std/zip_file_linux.zi

zip_file_linux

Import with #import "zip_file_linux" and pass --module-path std.

ZipFileRecord :: struct { local_offset: u64; size: u64; name_size: u32; crc32: u32; valid: bool; }
ZipFilePut16 :: (bytes: []u8, at: s32, value: u32)
ZipFilePut32 :: (bytes: []u8, at: s32, value: u32)
ZipFileWriteAll :: (file: FileHandle, bytes: []u8, at: u64) -> bool
ZipFileWriteName :: (file: FileHandle, name: string, at: u64) -> bool
WriteStoredZipFileEntry :: (file: FileHandle, at: u64, name: string, data: []u8) -> ZipFileRecord
StoredZipFileNext :: (record: ZipFileRecord) -> u64
WriteStoredZipFileDirectoryEntry :: (file: FileHandle, at: u64, name: string, record: ZipFileRecord) -> u64
FinishStoredZipFile :: (file: FileHandle, directory_start: u64, directory_end: u64, count: u32) -> bool

Source ↗

40 / std/zip_linux.zi

zip_linux

Import with #import "zip_linux" and pass --module-path std.

ZStream :: struct { next_in: *u8; avail_in: u32; total_in: usize; next_out: *u8; avail_out: u32; total_out: usize; msg: *u8; state: *void; zalloc: *void; zfree: *void; opaque: *void; data_type: s32; adler: usize; reserved: usize; }
ExtractZipEntry :: (archive: []u8, entry: ZipEntry, output: []u8) -> bool
ZipExtractWriteAll :: (file: FileHandle, bytes: []u8, offset: u64) -> bool
ExtractZipEntryToFile :: (archive: []u8, entry: ZipEntry, file: FileHandle) -> bool

Source ↗