about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2025-02-17 14:31:43 +0100
committerAlexey Yerin <yyp@disroot.org>2025-02-17 17:03:26 +0300
commita53329a66b255684a92374c417f5612988293e1b (patch)
tree54c7f00db09478b4818f4155b2d1e97a6d49f333
parente5d712e6185dd807728de5e8887042e2b8ea8fd0 (diff)
all: updates for nomem upstream
-rw-r--r--cmd/hare-gi/context.ha8
-rw-r--r--cmd/hare-gi/emit.ha26
-rw-r--r--cmd/hare-gi/ident.ha6
-rw-r--r--cmd/hare-gi/main.ha2
-rw-r--r--cmd/hare-gi/populate.ha4
-rw-r--r--format/fastxml/parser.ha4
-rw-r--r--format/fastxml/types.ha2
-rw-r--r--gir/parse.ha64
8 files changed, 58 insertions, 58 deletions
diff --git a/cmd/hare-gi/context.ha b/cmd/hare-gi/context.ha
index a1b4edf..672129f 100644
--- a/cmd/hare-gi/context.ha
+++ b/cmd/hare-gi/context.ha
@@ -81,8 +81,8 @@ fn add_repository(ctx: *context, repo: gir::repository) void = {
 			...
 		};
 		*(&new: *gir::namespace) = repo.namespaces[i];
-		append(new.includes, repo.includes...);
-		append(ctx.namespaces, new);
+		append(new.includes, repo.includes...)!;
+		append(ctx.namespaces, new)!;
 	};
 };
 
@@ -111,7 +111,7 @@ fn add_import(ns: *namespace, module: ident) void = {
 			return;
 		};
 	};
-	append(ns.imports, strings::dupall(module));
+	append(ns.imports, strings::dupall(module)!)!;
 };
 
 fn lookup_type(ctx: *context, name: str) ((*namespace, str, object_type) | void) = {
@@ -137,7 +137,7 @@ fn lookup_type_in_namespace(ns: *namespace, name: str) ((str, object_type) | voi
 };
 
 fn push(ctx: *context, name: str) void = {
-	append(ctx.stack, name);
+	append(ctx.stack, name)!;
 };
 fn pop(ctx: *context) void = {
 	assert(len(ctx.stack) > 0);
diff --git a/cmd/hare-gi/emit.ha b/cmd/hare-gi/emit.ha
index 3e3f0c4..bec5b4a 100644
--- a/cmd/hare-gi/emit.ha
+++ b/cmd/hare-gi/emit.ha
@@ -81,7 +81,7 @@ fn emit_alias(ctx: *context, alias: *gir::alias) (void | io::error) = {
 	if (is_exported(ctx, alias.c_type)) {
 		return;
 	};
-	append(ctx.current.exports, alias.c_type);
+	append(ctx.current.exports, alias.c_type)!;
 
 	emit_doc(ctx, alias)?;
 	fmt::fprintf(ctx.current.output, "export type {} = ",
@@ -94,7 +94,7 @@ fn emit_class(ctx: *context, class: *gir::class) (void | io::error) = {
 	if (is_exported(ctx, class.c_type)) {
 		return;
 	};
-	append(ctx.current.exports, class.c_type);
+	append(ctx.current.exports, class.c_type)!;
 
 	emit_doc(ctx, class)?;
 	fmt::fprintf(ctx.current.output, "export type {} = ",
@@ -139,7 +139,7 @@ fn emit_interface(ctx: *context, iface: *gir::interface) (void | io::error) = {
 	if (is_exported(ctx, iface.c_type)) {
 		return;
 	};
-	append(ctx.current.exports, iface.c_type);
+	append(ctx.current.exports, iface.c_type)!;
 
 	emit_doc(ctx, iface)?;
 	fmt::fprintf(ctx.current.output, "export type {} = ",
@@ -184,7 +184,7 @@ fn emit_union(ctx: *context, union_: *gir::union_) (void | io::error) = {
 	if (is_exported(ctx, union_.c_type)) {
 		return;
 	};
-	append(ctx.current.exports, union_.c_type);
+	append(ctx.current.exports, union_.c_type)!;
 
 	emit_doc(ctx, union_)?;
 	fmt::fprintf(ctx.current.output, "export type {} = ",
@@ -216,7 +216,7 @@ fn emit_record(ctx: *context, record: *gir::record) (void | io::error) = {
 	if (is_exported(ctx, record.c_type)) {
 		return;
 	};
-	append(ctx.current.exports, record.c_type);
+	append(ctx.current.exports, record.c_type)!;
 
 	emit_doc(ctx, record)?;
 	fmt::fprintf(ctx.current.output, "export type {} = ",
@@ -251,7 +251,7 @@ fn emit_enumeration(
 	if (is_exported(ctx, enumeration.c_type)) {
 		return;
 	};
-	append(ctx.current.exports, enumeration.c_type);
+	append(ctx.current.exports, enumeration.c_type)!;
 
 	emit_doc(ctx, enumeration)?;
 	fmt::fprintfln(ctx.current.output, "export type {} = enum uint {{",
@@ -272,7 +272,7 @@ fn emit_bitfield(ctx: *context, bitfield: *gir::bitfield) (void | io::error) = {
 	if (is_exported(ctx, bitfield.c_type)) {
 		return;
 	};
-	append(ctx.current.exports, bitfield.c_type);
+	append(ctx.current.exports, bitfield.c_type)!;
 
 	emit_doc(ctx, bitfield)?;
 	fmt::fprintfln(ctx.current.output, "export type {} = enum uint {{",
@@ -299,7 +299,7 @@ fn emit_callback(ctx: *context, callback: *gir::callback) (void | io::error) = {
 	if (is_exported(ctx, callback.c_type)) {
 		return;
 	};
-	append(ctx.current.exports, callback.c_type);
+	append(ctx.current.exports, callback.c_type)!;
 
 	emit_doc(ctx, callback)?;
 	fmt::fprintf(ctx.current.output, "export type {} = *fn(",
@@ -329,7 +329,7 @@ fn emit_constructor(
 	if (is_exported(ctx, constructor.c_identifier)) {
 		return;
 	};
-	append(ctx.current.exports, constructor.c_identifier);
+	append(ctx.current.exports, constructor.c_identifier)!;
 
 	emit_doc(ctx, constructor)?;
 	fmt::fprintf(ctx.current.output, `export @symbol("{}") fn `,
@@ -353,7 +353,7 @@ fn emit_method(ctx: *context, method: *gir::method) (void | io::error) = {
 	if (is_exported(ctx, method.c_identifier)) {
 		return;
 	};
-	append(ctx.current.exports, method.c_identifier);
+	append(ctx.current.exports, method.c_identifier)!;
 
 	emit_doc(ctx, method)?;
 	fmt::fprintf(ctx.current.output, `export @symbol("{}") fn `,
@@ -378,7 +378,7 @@ fn emit_function(ctx: *context, function: *gir::function) (void | io::error) = {
 	if (is_exported(ctx, function.c_identifier)) {
 		return;
 	};
-	append(ctx.current.exports, function.c_identifier);
+	append(ctx.current.exports, function.c_identifier)!;
 
 	emit_doc(ctx, function)?;
 	fmt::fprintf(ctx.current.output, `export @symbol("{}") fn `,
@@ -419,7 +419,7 @@ fn emit_signal(ctx: *context, signal: *gir::signal) (void | io::error) = {
 	const function = strings::concat(
 		"connect_",
 		normalize_signal(signal.name),
-	);
+	)!;
 	defer free(function);
 
 	fmt::fprintf(ctx.current.output, "export fn ")?;
@@ -500,7 +500,7 @@ fn emit_function_name(ctx: *context, name: str) (void | io::error) = {
 		return;
 	};
 
-	const path = strings::concat(ctx.stack...);
+	const path = strings::concat(ctx.stack...)!;
 	defer free(path);
 	const lower = swap_case(path);
 	defer free(lower);
diff --git a/cmd/hare-gi/ident.ha b/cmd/hare-gi/ident.ha
index 65571f4..1305192 100644
--- a/cmd/hare-gi/ident.ha
+++ b/cmd/hare-gi/ident.ha
@@ -74,7 +74,7 @@ fn swap_case(in: str) str = {
 		if (ascii::isupper(r) && !ascii::isupper(prev)) {
 			if (len(memio::string(&buf)!) > 0) {
 				append(parts,
-					strings::dup(memio::string(&buf)!));
+					strings::dup(memio::string(&buf)!)!)!;
 				memio::reset(&buf);
 			};
 		};
@@ -83,10 +83,10 @@ fn swap_case(in: str) str = {
 	};
 
 	if (len(memio::string(&buf)!) > 0) {
-		append(parts, strings::dup(memio::string(&buf)!));
+		append(parts, strings::dup(memio::string(&buf)!)!)!;
 	};
 
-	return strings::join("_", parts...);
+	return strings::join("_", parts...)!;
 };
 
 @test fn swap_case() void = {
diff --git a/cmd/hare-gi/main.ha b/cmd/hare-gi/main.ha
index e0afc98..ec4cfe9 100644
--- a/cmd/hare-gi/main.ha
+++ b/cmd/hare-gi/main.ha
@@ -74,7 +74,7 @@ export fn main() void = {
 			case null =>
 				fmt::fatalf("No such namespace '{}'", ns);
 			};
-			ns.module = strings::split(module, "::");
+			ns.module = strings::split(module, "::")!;
 			if (len(output) > 0) {
 				match (os::create(output, fs::mode::USER_RW)) {
 				case let f: io::file =>
diff --git a/cmd/hare-gi/populate.ha b/cmd/hare-gi/populate.ha
index b84d86d..542af78 100644
--- a/cmd/hare-gi/populate.ha
+++ b/cmd/hare-gi/populate.ha
@@ -66,6 +66,6 @@ fn populate_type(ctx: *context, c: str, name: str, objtype: object_type) void =
 	if (len(c) == 0) {
 		return;
 	};
-	const hare = strings::dup(fix_identifier(name));
-	append(ctx.current.types, (c, hare, objtype));
+	const hare = strings::dup(fix_identifier(name))!;
+	append(ctx.current.types, (c, hare, objtype))!;
 };
diff --git a/format/fastxml/parser.ha b/format/fastxml/parser.ha
index 5dc1b52..e1573f2 100644
--- a/format/fastxml/parser.ha
+++ b/format/fastxml/parser.ha
@@ -39,7 +39,7 @@ export fn parse(in: io::file) (*parser | error) = {
 		textbuf = memio::dynamic(),
 		line = 1,
 		...
-	});
+	})?;
 	match (prolog(par)) {
 	case void => void;
 	case let err: error =>
@@ -308,7 +308,7 @@ fn scan_element(par: *parser) (token | error) = {
 		poptag(par, name)?;
 		return name: elementend;
 	} else {
-		append(par.tags, strings::dup(name));
+		append(par.tags, strings::dup(name)?)?;
 		return name: elementstart;
 	};
 };
diff --git a/format/fastxml/types.ha b/format/fastxml/types.ha
index 8dcf785..f998a97 100644
--- a/format/fastxml/types.ha
+++ b/format/fastxml/types.ha
@@ -49,7 +49,7 @@ export type token = (elementstart | elementend | attribute | text);
 export type syntaxerr = !size;
 
 // Any error which can occur during XML parsing.
-export type error = !(syntaxerr | utf8::invalid | io::error | errors::error);
+export type error = !(syntaxerr | utf8::invalid | io::error | errors::error | nomem);
 
 // Converts an [[error]] to a user-friendly string representation.
 export fn strerror(err: error) const str = {
diff --git a/gir/parse.ha b/gir/parse.ha
index a68a7f6..9b7d911 100644
--- a/gir/parse.ha
+++ b/gir/parse.ha
@@ -55,7 +55,7 @@ fn parse_include(parser: *xml::parser, includes: *opaque) (void | error) = {
 		("name", &new.name),
 		("version", &new.version),
 	)?;
-	append(includes, new);
+	append(includes, new)!;
 };
 
 fn parse_namespace(parser: *xml::parser, namespaces: *opaque) (void | error) = {
@@ -85,7 +85,7 @@ fn parse_namespace(parser: *xml::parser, namespaces: *opaque) (void | error) = {
 		("docsection", null, null),
 		("function-macro", null, null),
 	)?;
-	append(namespaces, new);
+	append(namespaces, new)!;
 };
 
 fn parse_alias(parser: *xml::parser, aliases: *opaque) (void | error) = {
@@ -97,7 +97,7 @@ fn parse_alias(parser: *xml::parser, aliases: *opaque) (void | error) = {
 		("c:type", &new.c_type),
 		("type", &parse_simple_type, &new.inner),
 	)?;
-	append(aliases, new);
+	append(aliases, new)!;
 };
 
 fn parse_class(parser: *xml::parser, classes: *opaque) (void | error) = {
@@ -133,7 +133,7 @@ fn parse_class(parser: *xml::parser, classes: *opaque) (void | error) = {
 		("record", &parse_record_entry, &new.entries),
 		("callback", &parse_callback, &new.callbacks),
 	)?;
-	append(classes, new);
+	append(classes, new)!;
 };
 fn parse_implements(parser: *xml::parser, implements: *opaque) (void | error) = {
 	const implements = implements: *[]str;
@@ -141,7 +141,7 @@ fn parse_implements(parser: *xml::parser, implements: *opaque) (void | error) =
 	parse_element(parser, "implements",
 		("name", &name),
 	)?;
-	append(implements, name);
+	append(implements, name)!;
 };
 fn parse_interface(parser: *xml::parser, interfaces: *opaque) (void | error) = {
 	const interfaces = interfaces: *[]interface;
@@ -167,7 +167,7 @@ fn parse_interface(parser: *xml::parser, interfaces: *opaque) (void | error) = {
 		("callback", &parse_callback, &new.callbacks),
 		("constant", &parse_constant, &new.constants),
 	)?;
-	append(interfaces, new);
+	append(interfaces, new)!;
 };
 fn parse_prerequisite(parser: *xml::parser, prerequisites: *opaque) (void | error) = {
 	const prerequisites = prerequisites: *[]str;
@@ -175,7 +175,7 @@ fn parse_prerequisite(parser: *xml::parser, prerequisites: *opaque) (void | erro
 	parse_element(parser, "prerequisite",
 		("name", &name),
 	)?;
-	append(prerequisites, name);
+	append(prerequisites, name)!;
 };
 
 fn parse_record(parser: *xml::parser, records: *opaque) (void | error) = {
@@ -202,7 +202,7 @@ fn parse_record(parser: *xml::parser, records: *opaque) (void | error) = {
 		("method", &parse_method, &new.methods),
 		("constructor", &parse_constructor, &new.constructors),
 	)?;
-	append(records, new);
+	append(records, new)!;
 };
 
 fn parse_record_entry(parser: *xml::parser, entries: *opaque) (void | error) = {
@@ -210,7 +210,7 @@ fn parse_record_entry(parser: *xml::parser, entries: *opaque) (void | error) = {
 	let records: []record = [];
 	defer free(records);
 	parse_record(parser, &records)?;
-	append(entries, records[0]);
+	append(entries, records[0])!;
 };
 
 fn parse_constructor(parser: *xml::parser, constructors: *opaque) (void | error) = {
@@ -221,7 +221,7 @@ fn parse_constructor(parser: *xml::parser, constructors: *opaque) (void | error)
 		("parameters", &parse_parameters, &new.params),
 		("return-value", &parse_return_value, &new.return_value),
 	)?;
-	append(constructors, new);
+	append(constructors, new)!;
 };
 fn parse_method(parser: *xml::parser, methods: *opaque) (void | error) = {
 	const methods = methods: *[]method;
@@ -234,7 +234,7 @@ fn parse_method(parser: *xml::parser, methods: *opaque) (void | error) = {
 			&(&new.instance, &new.params)),
 		("return-value", &parse_return_value, &new.return_value),
 	)?;
-	append(methods, new);
+	append(methods, new)!;
 };
 fn parse_virtual_method(parser: *xml::parser, vmethods: *opaque) (void | error) = {
 	const vmethods = vmethods: *[]virtual_method;
@@ -246,7 +246,7 @@ fn parse_virtual_method(parser: *xml::parser, vmethods: *opaque) (void | error)
 			&(&new.instance, &new.params)),
 		("return-value", &parse_return_value, &new.return_value),
 	)?;
-	append(vmethods, new);
+	append(vmethods, new)!;
 };
 fn parse_field(parser: *xml::parser, entries: *opaque) (void | error) = {
 	const entries = entries: *[]entry;
@@ -269,7 +269,7 @@ fn parse_field(parser: *xml::parser, entries: *opaque) (void | error) = {
 	} else {
 		new.type_ = type_;
 	};
-	append(entries, new);
+	append(entries, new)!;
 };
 fn parse_property(parser: *xml::parser, properties: *opaque) (void | error) = {
 	const properties = properties: *[]property;
@@ -288,7 +288,7 @@ fn parse_property(parser: *xml::parser, properties: *opaque) (void | error) = {
 
 		parse_any_type(&new.type_),
 	)?;
-	append(properties, new);
+	append(properties, new)!;
 };
 
 fn parse_enumeration(parser: *xml::parser, enums: *opaque) (void | error) = {
@@ -305,7 +305,7 @@ fn parse_enumeration(parser: *xml::parser, enums: *opaque) (void | error) = {
 		("member", &parse_member, &new.members),
 		("function", &parse_function, &new.functions),
 	)?;
-	append(enums, new);
+	append(enums, new)!;
 };
 
 fn parse_function(parser: *xml::parser, functions: *opaque) (void | error) = {
@@ -316,7 +316,7 @@ fn parse_function(parser: *xml::parser, functions: *opaque) (void | error) = {
 		("parameters", &parse_parameters, &new.params),
 		("return-value", &parse_return_value, &new.return_value),
 	)?;
-	append(functions, new);
+	append(functions, new)!;
 };
 
 fn parse_union(parser: *xml::parser, unions: *opaque) (void | error) = {
@@ -338,7 +338,7 @@ fn parse_union(parser: *xml::parser, unions: *opaque) (void | error) = {
 		("function", &parse_function, &new.functions),
 		("record", &parse_record_entry, &new.entries),
 	)?;
-	append(unions, new);
+	append(unions, new)!;
 };
 
 fn parse_union_entry(parser: *xml::parser, entries: *opaque) (void | error) = {
@@ -346,7 +346,7 @@ fn parse_union_entry(parser: *xml::parser, entries: *opaque) (void | error) = {
 	let unions: []union_ = [];
 	defer free(unions);
 	parse_union(parser, &unions)?;
-	append(entries, unions[0]);
+	append(entries, unions[0])!;
 };
 
 fn parse_bitfield(parser: *xml::parser, bitfields: *opaque) (void | error) = {
@@ -362,14 +362,14 @@ fn parse_bitfield(parser: *xml::parser, bitfields: *opaque) (void | error) = {
 		("member", &parse_member, &new.members),
 		("function", &parse_function, &new.functions),
 	)?;
-	append(bitfields, new);
+	append(bitfields, new)!;
 };
 
 fn parse_callback(parser: *xml::parser, callbacks: *opaque) (void | error) = {
 	const callbacks = callbacks: *[]callback;
 	let new = callback { return_value = void, ... };
 	parse_one_callback(parser, &new)?;
-	append(callbacks, new);
+	append(callbacks, new)!;
 };
 fn parse_one_callback(parser: *xml::parser, cb: *opaque) (void | error) = {
 	const cb = cb: *callback;
@@ -401,7 +401,7 @@ fn parse_constant(parser: *xml::parser, constants: *opaque) (void | error) = {
 	} else {
 		new.type_ = void;
 	};
-	append(constants, new);
+	append(constants, new)!;
 };
 
 fn parse_signal(parser: *xml::parser, signals: *opaque) (void | error) = {
@@ -420,7 +420,7 @@ fn parse_signal(parser: *xml::parser, signals: *opaque) (void | error) = {
 		("parameters", &parse_parameters, &new.params),
 		("return-value", &parse_return_value, &new.return_value),
 	)?;
-	append(signals, new);
+	append(signals, new)!;
 };
 
 // enum + bitfield
@@ -435,7 +435,7 @@ fn parse_member(parser: *xml::parser, members: *opaque) (void | error) = {
 		("glib:nick", &new.glib_nick),
 		("glib:name", &new.glib_name),
 	)?;
-	append(members, new);
+	append(members, new)!;
 };
 
 // callable
@@ -516,7 +516,7 @@ fn parse_parameter(parser: *xml::parser, parameters: *opaque) (void | error) = {
 	} else {
 		new.parameter = type_;
 	};
-	append(parameters, new);
+	append(parameters, new)!;
 };
 fn parse_varargs(parser: *xml::parser, has_varargs: *opaque) (void | error) = {
 	*(has_varargs: *bool) = true;
@@ -591,7 +591,7 @@ fn parse_array_type(parser: *xml::parser, out: *opaque) (void | error) = {
 		("c:type", &out.c_type),
 		parse_any_type(&inner),
 	)?;
-	out.inner = alloc(inner);
+	out.inner = alloc(inner)!;
 };
 
 fn parse_any_type(out: *any_type) [2]scan = [
@@ -640,18 +640,18 @@ fn parse_element(
 		case let s: []scan =>
 			for (let j = 0z; j < len(s); j += 1) match (s[j]) {
 			case let s: scan_element =>
-				append(elements, s);
+				append(elements, s)!;
 			case let s: scan_attribute =>
-				append(attrs, s);
+				append(attrs, s)!;
 			case let s: scan_text =>
 				assert(text_out is null, "only one scan_text is allowed");
 				text_out = s;
 			case => abort("too deep");
 			};
 		case let s: scan_element =>
-			append(elements, s);
+			append(elements, s)!;
 		case let s: scan_attribute =>
-			append(attrs, s);
+			append(attrs, s)!;
 		case let s: scan_text =>
 			assert(text_out is null, "only one scan_text is allowed");
 			text_out = s;
@@ -690,7 +690,7 @@ fn parse_element(
 				case let s: nullable *str =>
 					match(s) {
 					case let s: *str =>
-						*s = strings::dup(attr.1);
+						*s = strings::dup(attr.1)!;
 					case null => yield;
 					};
 				case let b: *bool =>
@@ -715,7 +715,7 @@ fn parse_element(
 		if (len(strings::trim(text)) > 0) {
 			match (text_out) {
 			case let s: *str =>
-				*s = strings::dup(text);
+				*s = strings::dup(text)!;
 			case null =>
 				yield;
 			};
@@ -729,7 +729,7 @@ fn parse_element(
 };
 
 fn ignore(parser: *xml::parser, name: str) (void | error) = {
-	const name = strings::dup(name);
+	const name = strings::dup(name)!;
 	defer free(name);
 
 	for (true) match (xml::scan(parser)?) {