gizlang/objc
Objective-C's runtime as a macOS process has it, through gizlang/native, so nothing links at build time. Its users (gizlang/window's macOS window, gizhw/metal) call what Objc gives: system gives the runtime's own, a test gives a fake that records the calls. A message is integer words: the target, the selector, then each integer or pointer argument; a floating-point or struct value goes through key-value coding and NSValue instead (Objc.box, Objc.unbox), so no call depends on how an ABI passes a double or a struct.
import * as Objc from "gizlang/objc";Types
Objc
type Objc = { send: (words: Vec<u64>) => u64 effects {io, fail, read, write}; selector: (name: string) => u64 effects {io, fail, read, write}; find: (name: string) => u64 effects {io, fail, read, write}; push: () => u64 effects {io, fail, read, write}; pop: (pool: u64) => void effects {io, fail, read, write}; text: (address: u64) => string effects {io, fail, read, write}; sendAddress: u64; freeAddress: u64; }Objective-C's runtime. send is objc_msgSend (words: target, selector, integer arguments); selector is
sel_registerName, find objc_getClass, push and pop an autorelease pool; text is the C string at an address.
sendAddress and freeAddress are objc_msgSend and free, the functions a Gizlang value can own memory with.
send:(arg0: Vec<u64>) => u64 effects { fail, read, write, io }selector:(arg0: string) => u64 effects { fail, read, write, io }find:(arg0: string) => u64 effects { fail, read, write, io }push:() => u64 effects { fail, read, write, io }pop:(arg0: u64) => void effects { fail, read, write, io }text:(arg0: u64) => string effects { fail, read, write, io }sendAddress:u64freeAddress:u64
Functions
system
function system(nat: Native): Option<Objc>Objective-C's runtime as this process has it, or none (not macOS).
Effects: fail, io, alloc.
Methods
Objc.call
function Objc.call(self: Objc, target: u64, selector: string, arguments: Vec<u64> = []): u64The message SELECTOR (a name) to TARGET with integer ARGUMENTS.
Effects: fail, read, write, io, alloc.
Objc.string
function Objc.string(self: Objc, nat: Native, text: string): u64A new NSString of TEXT, autoreleased.
Effects: fail, read, write, io, alloc.
Objc.box
function Objc.box(self: Objc, nat: Native, value: bytes, type: string): u64An NSValue of the bytes VALUE whose Objective-C type is TYPE ({CGSize=dd}), autoreleased: how a struct or a
double reaches a setter by key-value coding.
Effects: fail, read, write, io, alloc.
Objc.unbox
function Objc.unbox(self: Objc, nat: Native, target: u64, key: string, size: i64): bytesThe SIZE bytes of the property KEY of TARGET, read by key-value coding: a struct or a number, boxed by the getter and copied out of its NSValue.
Effects: fail, read, write, io, alloc.