unoidl2

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

commit dc94e1c26b44e26872479c74e49faf3e4759270f
parent 434b75310d964c62982cf7b9e00491e3b84adbaa
Author: Tomas Hlavaty <tom@logand.com>
Date:   Sat, 17 Dec 2011 18:00:02 +0100

separate checked and unchecked exceptions

Diffstat:
Munoidl2java.c | 24++++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/unoidl2java.c b/unoidl2java.c @@ -31,6 +31,7 @@ static Any typedefs; static Any rel_package; static Any uno_star_sun_com; static Any Exception; +static Any RuntimeException; static int template = 0; @@ -180,18 +181,21 @@ static void pr_exception(Any x) { Any body = cddddr(x); pr_package(name); pr("public class "); pp(name); - if(!null(super)) { + int e = equal(name, Exception) && equal(module, uno_star_sun_com); + if(e) + pr(" extends java.lang.Exception"); + int r = equal(name, RuntimeException) && equal(module, uno_star_sun_com); + if(r) + pr(" extends java.lang.RuntimeException"); + if(!e && !r && !null(super)) { pr(" extends "); pp(super); } - int root = equal(name, Exception) && equal(module, uno_star_sun_com); - if(root) - pr(" extends java.lang.RuntimeException"); // TODO really RuntimeException? pl(" { // exception"); for(Any y = body; !null(y); y = cdr(y)) { Any slot = car(y); pr(" "); pp(cadr(slot)); pr(" _"); pp(car(slot)); pl(";"); } - if(root) { + if(e) { pl(" public Exception() {"); pl(" }"); pl(" public Exception(java.lang.String _Message) {"); @@ -203,6 +207,13 @@ static void pr_exception(Any x) { pr(" this._"); pp(car(slot)); pr(" = _"); pp(car(slot)); pl(";"); } pl(" }"); + } else if(r) { + pl(" java.lang.String _Message;"); + pl(" public RuntimeException() {"); + pl(" }"); + pl(" public RuntimeException(java.lang.String _Message) {"); + pl(" this._Message = _Message;"); + pl(" }"); } else { pr(" public "); pp(name); pl("() {"); pl(" super();"); @@ -232,7 +243,7 @@ static void pr_method(Any x) { Any published = caddr(x); Any type = cadddr(x); Any args = caddddr(x); - Any body = cdddddr(x); // TODO throws + Any body = cdddddr(x); pr(" "); pp(type); pr(" "); pp(name); pr("("); pr_args2(args); pr(")"); if(!null(body)) { pr(" throws "); pp_list(body, ", "); @@ -472,6 +483,7 @@ int main() { rel_package = NIL; uno_star_sun_com = list4(mk(ID, "uno"), mk(ID, "star"), mk(ID, "sun"), mk(ID, "com")); Exception = mk(ID, "Exception"); + RuntimeException = mk(ID, "RuntimeException"); pp_list(ast, NULL); //print(typedefs); return 0;