commit f991965abc97f8ec33e4ebe7a6c324dcffdbe805
parent 29063f7c2bc264f6a274965ef3a83df0635dba30
Author: Tomas Hlavaty <tom@logand.com>
Date:   Sun, 15 Jan 2012 14:07:53 +0100
simplify and clean up after previous "attribute" change
Diffstat:
1 file changed, 17 insertions(+), 18 deletions(-)
diff --git a/unoidl2java.c b/unoidl2java.c
@@ -46,13 +46,10 @@ static inline void pi(int x)   {printf("%d", x);}
 
 static void pp(Any x);
 
-static void pp_list(void (*fn) (Any e), Any x, char *sep) {
+static void pp_list(Any x, char *sep) {
   for(int i = 0; !null(x); x = cdr(x), i++) {
-    /* if(!sep) { */
-    /*   pr("###"); print(car(x)); pl(""); */
-    /* } */
     if(sep && 0 < i) pr(sep);
-    fn(car(x));
+    pp(car(x));
   }
 }
 
@@ -381,14 +378,16 @@ static void pr_exception(Any x) {
   }
 }
 
-static void pr_definterface_attribute(Any x) {
+static Any pr_definterface_attribute(void *env, Any x) {
   if(ATTRIBUTE == kind(car(x)))
     pp(x);
+  return NIL;
 }
 
-static void pr_definterface_nonattribute(Any x) {
+static Any pr_definterface_nonattribute(void *env, Any x) {
   if(ATTRIBUTE != kind(car(x)))
     pp(x);
+  return NIL;
 }
 
 static void pr_definterface(Any x) {
@@ -415,8 +414,8 @@ static void pr_definterface(Any x) {
     use_XInterface = 0;
     pl(" {");
     if(!(equal(name, XInterface) && equal(module, uno_star_sun_com))) {
-      pp_list(pr_definterface_attribute, body, "");
-      pp_list(pr_definterface_nonattribute, body, "");
+      mapc(NULL, pr_definterface_attribute, body);
+      mapc(NULL, pr_definterface_nonattribute, body);
       pr_TypeInfo(body);
     }
     pl("}");
@@ -431,7 +430,7 @@ static void pr_method(Any x) {
   Any body = cdddddr(x);
   pr("   public abstract "); pp(type); pr(" "); pp(name); pr("("); pr_args2(args); pr(")");
   if(!null(body)) {
-    pr(" throws "); pp_list(pp, body, ", ");
+    pr(" throws "); pp_list(body, ", ");
   }
   pl(";");
 }
@@ -486,7 +485,7 @@ static void pr_constants(Any x) {
     Any body = cdddr(x);
     pr_package(name);
     pr("public interface "); pp(name); pl(" { // constants");
-    pp_list(pp, body, "");
+    pp_list(body, "");
     pl("}");
   }
 }
@@ -546,9 +545,9 @@ static void pr_relative(Any x) {
     }
     Any p = car(rel_package);
     if(null(cddr(x))) // x => (relative ServiceContext) p => (iop corba star sun com)
-      pp_list(pp, reverse(cons(cadr(x), p), NIL), ".");
+      pp_list(reverse(cons(cadr(x), p), NIL), ".");
     else
-      pp_list(pp, cdr(x), ".");
+      pp_list(cdr(x), ".");
   }
 }
 
@@ -565,7 +564,7 @@ static void pr_absolute(Any x) {
       rel_package = cdr(rel_package);
       return;
     }
-    pp_list(pp, cdr(x), ".");
+    pp_list(cdr(x), ".");
   }
 }
 
@@ -586,7 +585,7 @@ static void pr_deftemplate(Any x) {
     Any slots = cddddr(x);
     pr_package(name);
     pr("public class "); pp(name);
-    pr("<"); pp_list(pp, args, ", "); pr(">"); pl(" { // deftemplate");
+    pr("<"); pp_list(args, ", "); pr(">"); pl(" { // deftemplate");
     pr_slots(slots, name);
     pr_TypeInfo(slots);
     pl("}");
@@ -621,7 +620,7 @@ static void pr_primitive(Any x) {
 
 static void pr_template(Any x) {
   template = 1;
-  pp(cadr(x)); pr("<"); pp_list(pp, caddr(x), ", "); pr(">");
+  pp(cadr(x)); pr("<"); pp_list(caddr(x), ", "); pr(">");
   template = 0;
 }
 
@@ -632,7 +631,7 @@ static void pp(Any x) {
       switch(kind(a)) {
       case MODULE:
         module = cons(cadr(x), module);
-        pp_list(pp, cddr(x), "");
+        pp_list(cddr(x), "");
         module = cdr(module);
         break;
       case ENUM: pr_enum(x); break;
@@ -705,7 +704,7 @@ int main() {
   XInterface = mk(ID, "XInterface");
   com_sun_star_uno_XInterface = reverse(uno_star_sun_com, list1(XInterface));
   Context = mk(ID, "Context");
-  pp_list(pp, ast, NULL);
+  pp_list(ast, NULL);
   //print(typedefs);
   return 0;
 }