mirror of
https://github.com/ahwootech/BRUTAL.git
synced 2026-11-25 12:38:24 +01:00
samples: add Hello/Demo samples for most BRUTAL packages (#19)
Add samples/, a collection of single-file .NET 10 apps run with `dotnet run <file>.cs`. Hello/ has one minimal sample per package that has a public API, many of them headless; Demo/ has fuller programs that combine packages into a more interesting application. samples/README.md indexes every sample and covers the layout, error handling and per-OS requirements.
This commit is contained in:
parent
4ac91e105e
commit
7a3b72d843
1 changed files with 4599 additions and 1 deletions
29
samples/Hello/HelloCore.cs
Normal file
29
samples/Hello/HelloCore.cs
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* HelloCore
|
||||
*
|
||||
* Shows a few Brutal.Core basics: platform detection, ByteSize/ElementCount arithmetic and Ptr<T>.
|
||||
*/
|
||||
|
||||
#:property AllowUnsafeBlocks=true
|
||||
#:package Ahwoo.Brutal.Core@2026.10.1
|
||||
|
||||
// RIAN: This package mainly contains the absolute bare minimum types and methods we use often across our packages.
|
||||
|
||||
using Brutal;
|
||||
using Brutal.Pointers;
|
||||
|
||||
Console.WriteLine($"Running on {Platform.CurrentFamily}");
|
||||
|
||||
var stride = ByteSize.Of<float>();
|
||||
var total = stride * new ElementCount(1024);
|
||||
Console.WriteLine($"1024 floats = {total}");
|
||||
|
||||
var alternative = ByteSize.Of<float>(1024);
|
||||
Console.WriteLine($"1024 floats = {alternative}");
|
||||
|
||||
unsafe
|
||||
{
|
||||
var raw = stackalloc int[4] { 10, 20, 30, 40 };
|
||||
Ptr<int> p = raw;
|
||||
Console.WriteLine($"p.Value = {p.Value}, p[2] = {p[2]}, p.Offset(1).Value = {p.Offset(1).Value}");
|
||||
}
|
||||
Loading…
Reference in a new issue