shithub: neindaw

Download patch

ref: 7ef0433142bcef6a0a55c9b5fff976a0e2a5cd1a
parent: ae475783094a17ec828a9de3c1076d85860cf19d
author: Sigrid Haflínudóttir <ftrvxmtrx@gmail.com>
date: Fri Jan 17 17:10:14 EST 2020

uiglue: allow ui controls without prior declarations

--- a/dsp/mkfile
+++ b/dsp/mkfile
@@ -16,7 +16,7 @@
 
 </sys/src/cmd/mkmany
 
-$TARG.c: $TARG.dsp
+%.c: %.dsp
 	echo Need to run gen.sh, $prereq changed
 
 $BIN/%:	$O.%
--- a/dsp/uiglue.c
+++ b/dsp/uiglue.c
@@ -66,7 +66,7 @@
 	float v;
 
 	if (type != Xuictl)
-		sysfatal("unknown ui file");
+		sysfatal("unknown ui file %d", type);
 
 	/* FIXME optional argument should specify at which frame to apply the change */
 
@@ -175,8 +175,12 @@
 {
 	UI *ui;
 
-	if (zone != decl.zone)
-		sysfatal("zone mismatch during definition");
+	if (zone != decl.zone) { /* no "declare" called before */
+		decl.zone = zone;
+		free(decl.meta);
+		decl.meta = nil;
+		decl.nummeta = 0;
+	}
 	ui = newui(f, label, type);
 	uiglue.f = f;
 
@@ -257,7 +261,7 @@
 	USED(f);
 
 	if (decl.zone != nil && decl.zone != zone)
-		sysfatal("zone mismatch during declaration");
+		sysfatal("%s=\"%s\": zone mismatch during declaration (%p != %p)", key, value, decl.zone, zone);
 	decl.zone = zone;
 	decl.meta = realloc(decl.meta, sizeof(Meta)*(decl.nummeta+1));
 	decl.meta[decl.nummeta].k = key;