commit b7fb9b4490271cb55e52f80d3cf0610e7caa96f8
parent e4c9a6d4ba24c3d965dc3f0ebd4ce310fe673837
Author: Tomas Hlavaty <tom@logand.com>
Date: Tue, 24 Jan 2012 00:34:45 +0100
2java pr_default_slots understands typedefs
Diffstat:
M | unoidl2java.c | | | 62 | ++++++++++++++++++++++++++++++++++++++++---------------------- |
1 file changed, 40 insertions(+), 22 deletions(-)
diff --git a/unoidl2java.c b/unoidl2java.c
@@ -164,29 +164,49 @@ static Any matching_struct_p(Any e, Any x) {
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) {
- for(Any y = slots; NIL != y; y = cdr(y)) {
- Any slot = car(y);
- Any n = car(slot);
- Any t = cadr(slot);
- Any e;
- switch(kind(consp(t) ? car(t) : t)) {
- case STRING: pr(" this."); pp(n); pl(" = \"\";"); break;
- case ANY: pr(" this."); pp(n); pl(" = com.sun.star.uno.Any.VOID;"); break;
- case TYPE: pr(" this."); pp(n); pl(" = com.sun.star.uno.Type.VOID;"); break;
- case SEQUENCE: pr(" this."); pp(n); pr(" = new "); seq0 = 1; pp(t); seq0 = 0; pl(";"); break;
- case RELATIVE:
- case ABSOLUTE:
- if(NIL != (e = find_enum(t))) {
- 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("();");
+static Any resolve_typedef(Any x) {return find(x, typedefs, equal, car);}
+
+static Any pr_default_slot(void *env, Any slot) {
+ Any n = car(slot);
+ Any t = cadr(slot);
+ Any e;
+ switch(kind(consp(t) ? car(t) : t)) {
+ case STRING: pr(" this."); pp(n); pl(" = \"\";"); break;
+ case ANY: pr(" this."); pp(n); pl(" = com.sun.star.uno.Any.VOID;"); break;
+ case TYPE: pr(" this."); pp(n); pl(" = com.sun.star.uno.Type.VOID;"); break;
+ case SEQUENCE:
+ pr(" this."); pp(n); pr(" = new ");
+ seq0 = 1;
+ pp(t);
+ seq0 = 0;
+ pl(";");
+ break;
+ case RELATIVE:
+ case ABSOLUTE:
+ if(NIL != (e = find_enum(t))) {
+ 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("();");
+ } else if(NIL == cddr(t)) {
+ Any y = resolve_typedef(cons(cadr(t), module));
+ if(NIL != y) pr_default_slot(NULL, list2(n, cdr(y))); // local typedef
+ } else {
+ Any y = resolve_typedef(reverse(cdr(t), NIL));
+ if(NIL != y) { // non-local typedef
+ rel_package = cons(cdr(car(y)), rel_package);
+ pr_default_slot(NULL, list2(n, cdr(y)));
+ rel_package = cdr(rel_package);
}
- //default: pr("@@@"); print(t); pp(t);
}
+ //default: pr("@@@"); print(t); pp(t);
}
+ return slot;
+}
+
+static void pr_default_slots(Any slots) {
+ mapc(NULL, pr_default_slot, slots);
}
static int pr_slots_rec1(Any super) {
@@ -621,8 +641,6 @@ static void pr_typedef(Any x) {
typedefs = cons(cons(cons(cadr(x), module), cadddr(x)), typedefs);
}
-static Any resolve_typedef(Any x) {return find(x, typedefs, equal, car);}
-
static void pr_relative(Any x) {
if(!use_XInterface && equal_(com_sun_star_uno_XInterface, cdr(x)))
pr("java.lang.Object");