Skip to content
FutureBlitz

    Install

    Import std.ffi.buffer

    std.ffi.buffer

    Buffer<T>: native memory of C's values at an address that doesn't move, which C code reads and fills through its Pointer and safe code reads and sets with [], each index checked against its Count, so std.io and C libraries share memory with safe code without copying it.

    std/ffi/buffer.fb

    Types

    Buffer class

    Public Class Buffer<T: CData> Implements Iterable<T>

    Count T's of native memory at an address that doesn't move: its own, all 0 at first, given back once nothing has the Buffer; part of another Buffer's, which a view from Slice keeps alive; or memory C owns, which a view from View promises is there while it is.

    std/ffi/buffer.fb, line 16

    • @PanicsAtCaller Public New(count: Int64) constructor #

      count T's, all 0. Panics when count is negative, or there isn't that much memory.

    • @PanicsAtCaller Public Static Method From(items: T[]): Buffer<T> static method #

      A new Buffer of the items, in order. Panics when there isn't that much memory.

    • @PanicsAtCaller Public Unsafe Static Method View(pointer: Ptr<T>, count: Int64): Buffer<T> static method #

      A view of count T's of memory C owns, from pointer, which C keeps there while the view is, since nothing else does, and doesn't give back. Panics when count is negative, or isn't 0 and pointer is Null, or the T's take more bytes than an Int64 counts, as New does.

    • Public Property Count: Int64 property #

      How many T's it has.

    • @PanicsAtCaller Operator [](index: Int64): T operator #

      The T at index, from 0 to Count minus 1.

    • @PanicsAtCaller Operator []=(index: Int64, value: T) operator #

      Gives the T at index, from 0 to Count minus 1, a new value, in the memory.

    • Public Unsafe Method Pointer(): Ptr<T> method #

      Where its T's start, for C code, which can read and write Count of them there while the Buffer, or a view that keeps it alive, is.

    • @PanicsAtCaller Public Method Slice(start: Int64, finish: Int64): Buffer<T> method #

      The T's from start up to finish, without the one at finish, as a view of its memory, which keeps this Buffer alive and sees what changes in it.

    • @PanicsAtCaller Public Method CopyTo(destination: Buffer<T>) method #

      Copies its T's to the start of destination, which has room for them. The two can share memory, as two views of one Buffer do.

    • @PanicsAtCaller Public Method ToArray(): T[] method #

      Its T's, in a new array. Panics when there are more than an array holds.

    • Public Method Iterate(): BufferIterator<T> method #

      Its T's, in order.

    BufferIterator struct

    Public Struct BufferIterator<T: CData> Implements Iterator<T>

    The values of a Buffer, in order, which For ... In goes over.

    std/ffi/buffer.fb, line 184

    Report an issue with this page or with FutureBlitz on GitHub.