unoidl2

Unnamed repository; edit this file to name it for gitweb.
git clone https://logand.com/git/unoidl2.git/
Log | Files | Refs

commit 2e8f7573e893753795bfaec41ebd67bc80d2de58
parent dc94e1c26b44e26872479c74e49faf3e4759270f
Author: Tomas Hlavaty <tom@logand.com>
Date:   Sat, 17 Dec 2011 20:04:13 +0100

2java stricter enum, once explicit, always explicit

Diffstat:
Munoidl2java.c | 12++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/unoidl2java.c b/unoidl2java.c @@ -88,13 +88,17 @@ static void pr_enum(Any x) { pr(" public static "); pp(name); pl(" getDefault() {"); pr(" return "); pp(v0k); pl(";"); pl(" }"); - int n = 0; // TODO inc the last explicit value + int n = 0; + int explicit = 0; for(Any y = values; !null(y); y = cdr(y)) { Any value = car(y); - char *k = token(consp(value) ? car(value) : value); - Any v = consp(value) ? cadr(value) : mkinum(n++); + int explicit1 = consp(value); + explicit |= explicit1; + char *k = token(explicit1 ? car(value) : value); + Any v = explicit1 ? cadr(value) : mkinum(n++); pr(" public static final int "); pr(k); pr("_value = "); - pp(v); pl(";"); + if(!explicit || explicit1) pp(v); // syntax error if not + pl(";"); pr(" public static final "); pp(name); pr(" "); pr(k); pr(" = new "); pp(name); pr("("); pp(v); pl(");"); }