about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlexey Yerin <yyp@disroot.org>2023-06-03 11:39:46 +0300
committerAlexey Yerin <yyp@disroot.org>2023-06-03 11:39:46 +0300
commit5bbe71aa7e1e90851f586696304473d00d1c599d (patch)
treefea39c974e80a85a7181af44ebd3ec9ec102ced3
parent616abb352df95663d9aefa9fc3432f52a6dc0d1d (diff)
Fill uninitialized fields
-rw-r--r--cmd/hare-gi/context.ha6
-rw-r--r--cmd/hare-gi/main.ha6
-rw-r--r--gir/parse.ha26
3 files changed, 20 insertions, 18 deletions
diff --git a/cmd/hare-gi/context.ha b/cmd/hare-gi/context.ha
index d4f47fa..f1ff3d1 100644
--- a/cmd/hare-gi/context.ha
+++ b/cmd/hare-gi/context.ha
@@ -50,6 +50,12 @@ type context = struct {
 	glib: *namespace,
 	gobject: *namespace,
 };
+fn context_init() context = context {
+	current = null: *namespace,
+	glib = null: *namespace,
+	gobject = null: *namespace,
+	...
+};
 fn context_finish(ctx: *context) void = {
 	for (let i = 0z; i < len(ctx.namespaces); i += 1) {
 		namespace_finish(&ctx.namespaces[i]);
diff --git a/cmd/hare-gi/main.ha b/cmd/hare-gi/main.ha
index 6aa1213..e0afc98 100644
--- a/cmd/hare-gi/main.ha
+++ b/cmd/hare-gi/main.ha
@@ -17,11 +17,7 @@ export fn main() void = {
 	const cmd = getopt::parse(os::args, help...);
 	defer getopt::finish(&cmd);
 
-	let ctx = context {
-		glib = null: *namespace,
-		gobject = null: *namespace,
-		...
-	};
+	let ctx = context_init();
 	defer context_finish(&ctx);
 
 	let check = false;
diff --git a/gir/parse.ha b/gir/parse.ha
index f844cd9..3c0204f 100644
--- a/gir/parse.ha
+++ b/gir/parse.ha
@@ -215,7 +215,7 @@ fn parse_record_entry(parser: *xml::parser, entries: *void) (void | error) = {
 
 fn parse_constructor(parser: *xml::parser, constructors: *void) (void | error) = {
 	const constructors = constructors: *[]constructor;
-	let new = constructor { ... };
+	let new = constructor { return_value = void, ... };
 	parse_element(parser, "constructor",
 		parse_callable(&new),
 		("parameters", &parse_parameters, &new.params),
@@ -225,7 +225,7 @@ fn parse_constructor(parser: *xml::parser, constructors: *void) (void | error) =
 };
 fn parse_method(parser: *xml::parser, methods: *void) (void | error) = {
 	const methods = methods: *[]method;
-	let new = method { ... };
+	let new = method { return_value = void, ... };
 	parse_element(parser, "method",
 		parse_callable(&new),
 		("glib:set-property", &new.glib_set_property),
@@ -238,7 +238,7 @@ fn parse_method(parser: *xml::parser, methods: *void) (void | error) = {
 };
 fn parse_virtual_method(parser: *xml::parser, vmethods: *void) (void | error) = {
 	const vmethods = vmethods: *[]virtual_method;
-	let new = virtual_method { ... };
+	let new = virtual_method { return_value = void, ... };
 	parse_element(parser, "virtual-method",
 		parse_callable(&new),
 		("invoker", &new.invoker),
@@ -250,9 +250,9 @@ fn parse_virtual_method(parser: *xml::parser, vmethods: *void) (void | error) =
 };
 fn parse_field(parser: *xml::parser, entries: *void) (void | error) = {
 	const entries = entries: *[]entry;
-	let new = field { ... };
+	let new = field { type_ = simple_type { ... }, ... };
 	let type_: any_type = simple_type { ... };
-	let cb = callback { ... };
+	let cb = callback { return_value = void, ... };
 	parse_element(parser, "field",
 		parse_info(&new),
 		("name", &new.name),
@@ -273,7 +273,7 @@ fn parse_field(parser: *xml::parser, entries: *void) (void | error) = {
 };
 fn parse_property(parser: *xml::parser, properties: *void) (void | error) = {
 	const properties = properties: *[]property;
-	let new = property { ... };
+	let new = property { type_ = simple_type { ... }, ... };
 	parse_element(parser, "property",
 		parse_info(&new),
 		("name", &new.name),
@@ -310,7 +310,7 @@ fn parse_enumeration(parser: *xml::parser, enums: *void) (void | error) = {
 
 fn parse_function(parser: *xml::parser, functions: *void) (void | error) = {
 	const functions = functions: *[]function;
-	let new = function { ... };
+	let new = function { return_value = void, ... };
 	parse_element(parser, "function",
 		parse_callable(&new),
 		("parameters", &parse_parameters, &new.params),
@@ -367,7 +367,7 @@ fn parse_bitfield(parser: *xml::parser, bitfields: *void) (void | error) = {
 
 fn parse_callback(parser: *xml::parser, callbacks: *void) (void | error) = {
 	const callbacks = callbacks: *[]callback;
-	let new = callback { ... };
+	let new = callback { return_value = void, ... };
 	parse_one_callback(parser, &new)?;
 	append(callbacks, new);
 };
@@ -386,7 +386,7 @@ fn parse_one_callback(parser: *xml::parser, cb: *void) (void | error) = {
 
 fn parse_constant(parser: *xml::parser, constants: *void) (void | error) = {
 	const constants = constants: *[]constant;
-	let new = constant { ... };
+	let new = constant { type_ = void, ... };
 	let type_: any_type = simple_type { ... };
 	parse_element(parser, "constant",
 		parse_info(&new),
@@ -406,7 +406,7 @@ fn parse_constant(parser: *xml::parser, constants: *void) (void | error) = {
 
 fn parse_signal(parser: *xml::parser, signals: *void) (void | error) = {
 	const signals = signals: *[]signal;
-	let new = signal { ... };
+	let new = signal { return_value = void, ... };
 	parse_element(parser, "glib:signal",
 		parse_info(&new),
 		("name", &new.name),
@@ -488,7 +488,7 @@ fn parse_instance_parameter(parser: *xml::parser, param: *void) (void | error) =
 };
 fn parse_parameter(parser: *xml::parser, parameters: *void) (void | error) = {
 	const parameters = parameters: *[]callable_param;
-	let new = callable_param { ... };
+	let new = callable_param { parameter = simple_type { ... }, ... };
 	let type_: any_type = simple_type { ... };
 	let has_varargs = false;
 	parse_element(parser, "parameter",
@@ -521,7 +521,7 @@ fn parse_varargs(parser: *xml::parser, has_varargs: *void) (void | error) = {
 };
 fn parse_return_value(parser: *xml::parser, return_value: *void) (void | error) = {
 	const return_value = return_value: *(callable_return | void);
-	let new = callable_return { ... };
+	let new = callable_return { type_ = simple_type { ... }, ... };
 	parse_element(parser, "return-value",
 		parse_info(&new),
 		("introspectable", &new.introspectable),
@@ -603,7 +603,7 @@ fn parse_simple_type_union(parser: *xml::parser, out: *void) (void | error) = {
 };
 fn parse_array_type_union(parser: *xml::parser, out: *void) (void | error) = {
 	const out = out: *any_type;
-	let array = array_type { ... };
+	let array = array_type { inner = null: *any_type, ... };
 	parse_array_type(parser, &array)?;
 	*out = array;
 };