about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlexey Yerin <yyp@disroot.org>2023-08-07 00:23:08 +0300
committerAlexey Yerin <yyp@disroot.org>2023-08-07 00:23:08 +0300
commitc664e4023682322875b475bac595a171a47f1c8e (patch)
treef64ab2b36eeaa11d1f1c7af98c3a66897d1584ea
parenta222d0d6dbd976d756a6e7d5f30f6841bc23278f (diff)
Update for memio/bufio
-rw-r--r--cmd/hare-gi/ctype.ha14
-rw-r--r--cmd/hare-gi/emit.ha2
-rw-r--r--cmd/hare-gi/ident.ha28
3 files changed, 22 insertions, 22 deletions
diff --git a/cmd/hare-gi/ctype.ha b/cmd/hare-gi/ctype.ha
index f45dc9b..185be7d 100644
--- a/cmd/hare-gi/ctype.ha
+++ b/cmd/hare-gi/ctype.ha
@@ -1,9 +1,9 @@
 // The world's worst C parser
 
 use ascii;
-use strings;
-use strio;
 use fmt;
+use memio;
+use strings;
 
 type ctype = ((cmodule, str) | str | cbuiltin | cpointer);
 type cpointer = *ctype;
@@ -227,24 +227,24 @@ fn next_token(iter: *strings::iterator) (str | rune | void) = {
 };
 
 fn _next_token(iter: *strings::iterator) (str | rune | void) = {
-	let buffer = strio::dynamic();
+	let buffer = memio::dynamic();
 	let first = true;
 	for (true) match (strings::next(iter)) {
 	case let r: rune =>
 		if (ascii::isspace(r)) {
 			if (len(buffer.buf) > 0) {
-				return strio::string(&buffer);
+				return memio::string(&buffer)!;
 			};
 			continue;
 		};
 		if (is_ident(r, first)) {
-			strio::appendrune(&buffer, r)!;
+			memio::appendrune(&buffer, r)!;
 			first = false;
 		} else switch (r) {
 		case '*' =>
 			if (len(buffer.buf) > 0) {
 				strings::prev(iter);
-				return strio::string(&buffer);
+				return memio::string(&buffer)!;
 			} else {
 				return r;
 			};
@@ -255,7 +255,7 @@ fn _next_token(iter: *strings::iterator) (str | rune | void) = {
 		break;
 	};
 	if (len(buffer.buf) > 0) {
-		return strio::string(&buffer);
+		return memio::string(&buffer)!;
 	};
 };
 
diff --git a/cmd/hare-gi/emit.ha b/cmd/hare-gi/emit.ha
index 4014b76..9f3486e 100644
--- a/cmd/hare-gi/emit.ha
+++ b/cmd/hare-gi/emit.ha
@@ -28,7 +28,7 @@ fn emit(ctx: *context) (void | io::error) = {
 		if (ns.output_file == -1) continue;
 
 		static let wbuf: [os::BUFSIZ]u8 = [0...];
-		const stream = bufio::buffered(ns.output_file, [], wbuf);
+		const stream = bufio::init(ns.output_file, [], wbuf);
 		ctx.current.output = &stream;
 
 		delete(ctx.current.exports[..]);
diff --git a/cmd/hare-gi/ident.ha b/cmd/hare-gi/ident.ha
index 962a6b3..7dae645 100644
--- a/cmd/hare-gi/ident.ha
+++ b/cmd/hare-gi/ident.ha
@@ -1,8 +1,8 @@
 use ascii;
 use fmt;
 use io;
+use memio;
 use strings;
-use strio;
 
 const keywords: [_]str = [
 	"abort", "align", "alloc", "append", "as", "assert", "bool", "break",
@@ -39,31 +39,31 @@ fn fix_identifier(s: str) str = {
 // '-' with '_'.
 fn normalize_signal(in: str) str = {
 	static let buf: [128]u8 = [0...];
-	let buf = strio::fixed(buf);
+	let buf = memio::fixed(buf);
 
 	let iter = strings::iter(in);
 	for (true) match (strings::next(&iter)) {
 	case let r: rune =>
-		strio::appendrune(&buf, if (r == '-') '_' else r)!;
+		memio::appendrune(&buf, if (r == '-') '_' else r)!;
 	case =>
 		break;
 	};
-	return strio::string(&buf);
+	return memio::string(&buf)!;
 };
 
 // Converts lower_case into UPPER_CASE
 fn to_uppercase(in: str) str = {
 	static let buf: [128]u8 = [0...];
-	let buf = strio::fixed(buf);
+	let buf = memio::fixed(buf);
 
 	let iter = strings::iter(in);
 	for (true) match (strings::next(&iter)) {
 	case let r: rune =>
-		strio::appendrune(&buf, ascii::toupper(r))!;
+		memio::appendrune(&buf, ascii::toupper(r))!;
 	case =>
 		break;
 	};
-	return strio::string(&buf);
+	return memio::string(&buf)!;
 };
 
 // Converts PascalCase into snake_case
@@ -71,7 +71,7 @@ fn swap_case(in: str) str = {
 	let parts: []str = [];
 	defer strings::freeall(parts);
 
-	let buf = strio::dynamic();
+	let buf = memio::dynamic();
 	defer io::close(&buf)!;
 
 	let iter = strings::iter(in);
@@ -79,20 +79,20 @@ fn swap_case(in: str) str = {
 	for (true) match (strings::next(&iter)) {
 	case let r: rune =>
 		if (ascii::isupper(r) && !ascii::isupper(prev)) {
-			if (len(strio::string(&buf)) > 0) {
+			if (len(memio::string(&buf)!) > 0) {
 				append(parts,
-					strings::dup(strio::string(&buf)));
-				strio::reset(&buf);
+					strings::dup(memio::string(&buf)!));
+				memio::reset(&buf);
 			};
 		};
-		strio::appendrune(&buf, ascii::tolower(r))!;
+		memio::appendrune(&buf, ascii::tolower(r))!;
 		prev = r;
 	case void =>
 		break;
 	};
 
-	if (len(strio::string(&buf)) > 0) {
-		append(parts, strings::dup(strio::string(&buf)));
+	if (len(memio::string(&buf)!) > 0) {
+		append(parts, strings::dup(memio::string(&buf)!));
 	};
 
 	return strings::join("_", parts...);