unoidl2

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

commit 649573fccec8779e2fc33c3ada5eef4714880dfd
parent 646be72f6f2596a7532260c22117dba126cd28cc
Author: Tomas Hlavaty <tom@logand.com>
Date:   Thu,  8 Dec 2011 08:53:43 +0100

unoidl2java: improved

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

diff --git a/unoidl2java.c b/unoidl2java.c @@ -88,7 +88,6 @@ static void pr_args2(Any x) { // for in, out, inout } static void pr_struct(Any x) { - print(x); Any name = cadr(x); Any published = caddr(x); Any super = cadddr(x); @@ -99,7 +98,9 @@ static void pr_struct(Any x) { pl(" {"); for(Any y = slots; !null(y); y = cdr(y)) { Any slot = car(y); - pr(" public "); pp(cadr(slot)); pr(" "); pp(car(slot)); pl(";"); + Any n = car(slot); + Any t = cadr(slot); + pr(" public "); pp(t); pr(" "); pp(n); pl(";"); } pr(" public "); pp(name); pl("() {"); // TODO init enum to default @@ -107,10 +108,24 @@ static void pr_struct(Any x) { pr(" public "); pp(name); pr("("); pr_args(slots); pl(") {"); for(Any y = slots; !null(y); y = cdr(y)) { Any slot = car(y); + Any n = car(slot); + Any t = cadr(slot); // TODO if Object => super(slot); - pr(" this."); pp(car(slot)); pr(" = "); pp(car(slot)); pl(";"); + pr(" this."); pp(n); pr(" = "); pp(n); pl(";"); } pl(" }"); + for(Any y = slots; !null(y); y = cdr(y)) { + Any slot = car(y); + Any n = car(slot); + Any t = cadr(slot); + pr(" public "); pp(t); pr(" get"); pp(n); pl("() {"); + pr(" return this."); pp(n); pl(";"); + pl(" }"); + pr(" public void set"); pp(n); pr("("); pp(t); pr(" "); pp(n); pl(") {"); + pr(" this."); pp(n); pr(" = "); pp(n); pl(";"); + pl(" }"); + } + pl("}"); } static void pr_exception(Any x) { @@ -137,7 +152,7 @@ static void pr_exception(Any x) { pl("}"); } -static void pr_interface(Any x) { +static void pr_interface(Any x) { // TODO nesting Any name = cadr(x); Any published = caddr(x); Any super = cadddr(x); @@ -172,9 +187,19 @@ static void pr_arg(Any x) { } static void pr_service(Any x) { + Any name = cadr(x); + Any published = caddr(x); + Any super = cadddr(x); + Any body = caddddr(x); + pr_package(); + pr("public class "); pp(name); + if(!null(super)) {pr(" extends "); pp(super);} + pl(" {"); + pp_list(body, ""); + pl(" }"); } -static void pr_singleton(Any x) { +static void pr_singleton(Any x) { // TODO (singleton theMacroExpander T (relative MacroExpander) T) } static void pr_constants(Any x) { @@ -192,7 +217,25 @@ static void pr_const(Any x) { pp(caddr(x)); pr(" = "); pp(cadddr(x)); pl(";"); } -static void pr_typedef(Any x) { +static void pr_typedef(Any x) { // TODO (typedef (unsigned long) T ObjectSystemID) + // TODO remember and replace ObjectSystemID with (unsigned long) when printing type +} + +static void pr_property(Any x) { + Any name = cadr(x); + Any type = caddr(x); + Any options = cadddr(x); + //pr_package(); + //pr("public class "); pp(name); pl(" {"); + pr(" protected "); pp(type); pr(" "); pp(name); pl(";"); + //pr(" public "); pp(name); pl("();"); + //pr(" public "); pp(name); pr("("); pp(type); pr(" "); pp(name); pl(");"); + pr(" public "); pp(type); pr(" get"); pp(name); pl("();"); + pr(" public void set"); pp(name); pr("("); pp(type); pr(" "); pp(name); pl(");"); + pl("}"); +} + +static void pr_deftemplate(Any x) { // TODO (deftemplate Pair T (T U) (T First) U Second) } static void pp(Any x) { @@ -219,6 +262,8 @@ static void pp(Any x) { case SEQUENCE: pp(cadr(x)); pr("[]"); break; case ATTRIBUTE: pr_attribute(x); break; case EXCEPTION: pr_exception(x); break; + case SERVICE: pr_service(x); break; + case PROPERTY: pr_property(x); break; case VOID: case BOOLEAN: case BYTE: