.{math: .{Vec2}, buffer, memory} := @use("../../stn/src/lib.hb"); .{Surface} := @use("../../render/src/lib.hb") $BUFFER := "sunset\0" client := @use("./client.hb") server := @use("./server.hb") message := @use("./message.hb") receive_message := fn($Expr: type, buffer_id: uint): ?Expr { recv := @as(?Expr, null) buffer.recv(?Expr, buffer_id, &recv) return recv } send_message := fn($Expr: type, msg: Expr, buffer_id: uint): void { buffer.write(?Expr, buffer_id, &@as(?Expr, msg)) } await_buffer := fn(name: ^u8): uint { id := 0 loop if id != 0 return id else id = buffer.search(BUFFER) } await_message := fn($Expr: type, buffer_id: uint): Expr { response := @as(?Expr, null) loop { buffer.recv(?Expr, buffer_id, &response) if response != null { i := 0 return @as(Expr, response) } } } // ! we need a better message format but this will do for now. // enums would be nice MessageHeader := packed struct { kind: uint, data: uint, } WindowProps := struct { position: Vec2(uint), dimensions: Vec2(uint), // ! replace with owned string type later title: ^u8, } WindowData := struct { props: WindowProps, buffer_id: uint, } Window := struct { data: WindowData, surface: Surface, }