Updated stream API.

This commit is contained in:
Christoffer Lerno
2023-09-02 19:48:51 +02:00
committed by Christoffer Lerno
parent a6cff5c2a5
commit 9a6d83f526
44 changed files with 837 additions and 952 deletions

View File

@@ -38,7 +38,7 @@ fn void! brainf(String program)
io::putchar(memory[mem]);
io::stdout().flush();
case ',':
memory[mem] = io::stdin().getc()!!;
memory[mem] = io::stdin().read_byte()!!;
case '[':
usz indent = 1;
if (memory[mem]) continue;

View File

@@ -19,7 +19,7 @@ struct StringData @private
char[*] chars;
}
fn void Summary.print(Summary *s, File out)
fn void Summary.print(Summary *s, File* out)
{
String title = s.title ? s.title.as_str() : "missing";
out.printf("Summary({ .title = %s, .ok = %s})", title, s.ok);

View File

@@ -6,6 +6,6 @@ fn void! main()
defer f.close()!!;
while (!f.eof())
{
@pool() { io::printn(f.tgetline()); };
@pool() { io::printn(f.treadline()!); };
}
}

View File

@@ -10,15 +10,15 @@ fault TokenResult
// While we could have written this with libc
// the C way, let's showcase some features added to C3.
fn void main(String[] args)
fn void! main(String[] args)
{
// Grab a string from stdin
DString s = io::stdin().getline();
String s = io::stdin().readline()!;
// Delete it at scope end [defer]
defer s.free();
// Grab the string as a slice.
String numbers = s.as_str();
// Copy the slice, which doesn't change the underlying data.
String numbers = s;
// Track our current value
int val = 0;

View File

@@ -7,7 +7,7 @@ fn void! main()
String command = env::WIN32 ? "dir" : "ls";
SubProcess x = process::create({ command }, { .search_user_path = true })!!;
x.join()!;
Stream stream = x.stdout().as_stream();
Stream* stream = &&x.stdout();
while (try char b = stream.read_byte())
{
io::printf("%c", b);