static class · System
Exchange
public static class Exchange
- Tipo
- static class
- Espacio de nombres
- System
- Ensamblado
- System.Core
- Acceso
- public, static, abstract
- Archivo fuente
Exchange.ant
Herencia
- Clases base
-
AnyExchange
Métodos
A packet with a copy of bytes.
A packet with a copy of the text's UTF-8 bytes.
How many bytes a packet carries.
The packet's bytes, copied into this domain; the packet is freed.
The packet's bytes as text of this domain; the packet is freed.
Frees a packet nobody takes.
Miembros privados e internos (2)
Miembros heredados (5)
GetTypemétodo de AnyUndescribedmétodo de AnyToStringmétodo de AnyHashmétodo de Anydestroymétodo de Any
Código fuente
Exchange en Antril, descompilado a partir de su Larva HIR.
// System.Exchange — System.Core (decompiled from Larva HIR)
import System.Runtime.InteropServices;
into namespace System
{
public static class Exchange
{
unsafe extern("mem.alloc") Allocate(i64 bytes) : u8*;
unsafe extern("mem.free") Release(u8* block);
public:
/// A packet with a copy of `bytes`.
PackBytes(u8[] bytes) : u8*
{
i64 n = bytes.Length;
unsafe
{
u8* packet = Allocate(8 + n);
loop (i32 i = 0..8)
*(packet + (i64)i) = (u8)(n >> 8 * (i64)i);
if (n > 0)
Memory.Copy(packet + 8, &bytes[0], n);
return packet;
}
}
/// A packet with a copy of the text's UTF-8 bytes.
Pack(str text) : u8* => PackBytes(text.Units());
/// How many bytes a packet carries.
Length(u8* packet) : i32
{
i64 n = 0;
unsafe
{
loop (i32 i = 0..8)
n = n | (i64)*(packet + (i64)i) << 8 * (i64)i;
}
return (i32)n;
}
/// The packet's bytes, copied into this domain; the packet is freed.
Bytes(u8* packet) : u8[]
{
i32 n = Length(packet);
u8[] copy = new u8[n];
unsafe
{
if (n > 0)
Memory.Copy(©[0], packet + 8, n);
Release(packet);
}
return copy;
}
/// The packet's bytes as text of this domain; the packet is freed.
Text(u8* packet) : str => new str(Bytes(packet));
/// Frees a packet nobody takes.
Free(u8* packet)
{
unsafe
{
Release(packet);
}
}
}
}