unoidl2

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

commit 74eed4ccefd6fed230f6ea6804bed172f3a75e2d
parent 2ea341380b1bec4991dcc427fa90081dc02c658b
Author: Tomas Hlavaty <tom@logand.com>
Date:   Sun, 22 Jan 2012 19:08:05 +0100

2java fixes: better pr_struct and pr_slots

Diffstat:
Munoidl2java.c | 53++++++++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 46 insertions(+), 7 deletions(-)

diff --git a/unoidl2java.c b/unoidl2java.c @@ -146,13 +146,23 @@ static void pr_args2(Any x) { // for in, out, inout } static Any matching_enum_p(Any e, Any x) { - //pr("@@@"); print(e); print(x); // (relative com sun star uno XInterface)(com sun star uno TypeClass) - // TODO relative (not full) match - return equal(cdr(e), x); + int z = equal_(cdr(e), x); + if(!z) + z = equal_(reverse(module, cdr(e)), x); + return z ? e : NIL; +} + +static Any matching_struct_p(Any e, Any x) { + // (relative com sun star uno XInterface)(com sun star uno TypeClass) + int z = equal_(cdr(e), x); + if(!z) + z = equal_(reverse(module, cdr(e)), x); + return z ? e : NIL; } static Any find_enum(Any x) {return find(x, enums, matching_enum_p, car);} +static Any find_struct(Any x) {return find(x, structs, matching_struct_p, car);} static void pr_default_slots(Any slots) { // TODO init enum to default @@ -172,6 +182,8 @@ static void pr_default_slots(Any slots) { Any d = cadr(e); pr(" this."); pp(n); pl(" = "); pp(t); pr("."); pp(consp(d) ? car(d) : d); pr(";"); + } else if(NIL != (e = find_struct(t))) { + pr(" this."); pp(n); pr(" = new "); pp(t); pl("();"); } } //default: pr("@@@"); print(t); pp(t); @@ -179,7 +191,26 @@ static void pr_default_slots(Any slots) { } } -static void pr_slots(Any slots, Any name) { +static int pr_slots_rec1(Any super) { + if(NIL == super) return 0; + Any s = find_struct(super); + if(pr_slots_rec1(cadr(s))) pr(", "); + pr_args(cddr(s)); + return 1; +} + +static int pr_slots_rec2(Any super) { + if(NIL == super) return 0; + Any s = find_struct(super); + int z = pr_slots_rec2(cadr(s)); + for(Any y = cddr(s); NIL != y; y = cdr(y)) { + if(0 < z++) pr(", "); + pp(car(car(y))); + } + return 1; +} + +static void pr_slots(Any slots, Any name, Any super) { for(Any y = slots; NIL != y; y = cdr(y)) { Any slot = car(y); Any n = car(slot); @@ -189,7 +220,15 @@ static void pr_slots(Any slots, Any name) { pr(" public "); pp(name); pl("() {"); pr_default_slots(slots); pl(" }"); - pr(" public "); pp(name); pr("("); pr_args(slots); pl(") {"); + pr(" public "); pp(name); pr("("); + if(pr_slots_rec1(super) && NIL != slots) pr(", "); + pr_args(slots); + pl(") {"); + if(NIL != super) { + pr(" super("); + pr_slots_rec2(super); + pl(");"); + } for(Any y = slots; NIL != y; y = cdr(y)) { Any slot = car(y); Any n = car(slot); @@ -340,7 +379,7 @@ static void pr_struct(Any x) { pr("public class "); pp(name); pr_extends(super); pl(" { // struct"); - pr_slots(slots, name); + pr_slots(slots, name, super); pr_TypeInfo(slots); pl("}"); } @@ -601,7 +640,7 @@ static void pr_deftemplate(Any x) { pr_package(name); pr("public class "); pp(name); pr("<"); pp_list(args, ", "); pr(">"); pl(" { // deftemplate"); - pr_slots(slots, name); + pr_slots(slots, name, NIL); pr_TypeInfo(slots); pl("}"); }