unoidl2

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

commit 2c65cf0923048e3d3f6a068b91f64cdc8364aee4
parent 12e715ab9bd62d8a88637972d94f65c87e0df9b6
Author: Tomas Hlavaty <tom@logand.com>
Date:   Tue, 17 Jan 2012 01:19:42 +0100

some() simplified

Diffstat:
Munoidl2.c | 8++++----
Munoidl2.h | 2+-
Munoidl2java.c | 18+++++++++---------
3 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/unoidl2.c b/unoidl2.c @@ -162,10 +162,10 @@ Any print(Any x) { return x; } -int some(void *env, int (*fn)(void *env, Any e), Any x) { - for(Any y = x; NIL != y; y = cdr(y)) { - int z = fn(env, car(y)); - if(z) return z; +Any some(Fn1 test, Any lst) { + for(; NIL != lst; lst = cdr(lst)) { + Any x = test(car(lst)); + if(NIL != x) return x; } return 0; } diff --git a/unoidl2.h b/unoidl2.h @@ -59,7 +59,7 @@ Any cdddddr(Any x); int equal_(Any x, Any y); Any equal(Any x, Any y); Any print(Any x); -int some(void *env, int (*fn)(void *env, Any e), Any x); +Any some(Fn1 test, Any lst); Any mapc(void *env, Any (*fn)(void *env, Any e), Any x); Any find(Any elt, Any lst, Fn2 cmp, Fn1 key); Any reverse(Any x, Any a); diff --git a/unoidl2java.c b/unoidl2java.c @@ -243,7 +243,9 @@ static int type_flags(Any x) { return 0; } -static int readonlyp(void *env, Any x) {return READONLY == kind(x);} +static Any kindeq(Kind k, Any a) {return k == kind(a) ? T : NIL;} + +static Any readonlyp(Any a) {return kindeq(READONLY, a);} static Any pr_TypeInfo1(void *env, Any x) { int f = 0; @@ -252,7 +254,7 @@ static Any pr_TypeInfo1(void *env, Any x) { case ATTRIBUTE: // (attribute (string) KeyName (readonly)) t = cadr(x); f |= type_flags(t); - if(some(NULL, readonlyp, cadddr(x))) f |= _READONLY; + if(NIL != some(readonlyp, cadddr(x))) f |= _READONLY; pr_TypeInfo2("Attribute", caddr(x), t, f, env, -1); break; case ID: // (NewValue (any)) @@ -293,7 +295,7 @@ static Any pr_TypeInfo1(void *env, Any x) { static Any pr_TypeInfo1_attribute(void *env, Any x) { if(ATTRIBUTE == kind(car(x))) { pr_TypeInfo1(env, x); - if(!some(NULL, readonlyp, cadddr(x))) + if(NIL == some(readonlyp, cadddr(x))) ++*((int *) env); } return NIL; @@ -305,10 +307,10 @@ static Any pr_TypeInfo1_nonattribute(void *env, Any x) { return NIL; } -static int pr_TypeInfo_p(void *env, Any x) {return INTERFACE != kind(car(x));} +static Any pr_TypeInfo_p(Any a) {return kindeq(INTERFACE, a);} static void pr_TypeInfo(Any body) { - if(some(NULL, pr_TypeInfo_p, body)) { + if(NIL != some(pr_TypeInfo_p, body)) { pr(" public static final com.sun.star.lib.uno.typeinfo.TypeInfo UNOTYPEINFO[] = {"); int i = -1; k = -1; @@ -458,7 +460,7 @@ static void pr_attribute(Any x) { // (attribute (string) KeyName (readonly)) Any n = caddr(x); Any o = cadddr(x); pr(" public abstract "); pp(t); pr(" get"); pp(n); pl("();"); - if(!some(NULL, readonlyp, o)) { + if(NIL == some(readonlyp, o)) { pr(" public abstract void set"); pp(n); pr("("); pp(t); pl(" x);"); } } @@ -579,15 +581,13 @@ static void pr_absolute(Any x) { } } -static int propertyp(void *env, Any e) {return READONLY == kind(car(e));} - static void pr_property(Any x) { Any n = cadr(x); Any t = caddr(x); Any o = cadddr(x); pr(" protected "); pp(t); pr(" "); pp(n); pl(";"); pr(" public "); pp(t); pr(" get"); pp(n); pl("();"); - if(!some(NULL, readonlyp, o)) { + if(NIL == some(readonlyp, o)) { pr(" public void set"); pp(n); pr("("); pp(t); pr(" "); pp(n); pl(");"); } }