unoidl2

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

commit 9403daebc3a0b5cdde4635644e10f69b0cd82caf
parent 4f7c118ce98142094681530df837bfff9fcac1f6
Author: Tomas Hlavaty <tom@logand.com>
Date:   Tue, 17 Jan 2012 00:19:32 +0100

moved some, mapc, find, reverse

Diffstat:
Munoidl2.c | 27+++++++++++++++++++++++++++
Munoidl2.h | 4++++
Munoidl2java.c | 27---------------------------
3 files changed, 31 insertions(+), 27 deletions(-)

diff --git a/unoidl2.c b/unoidl2.c @@ -159,3 +159,30 @@ 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; + } + return 0; +} + +Any mapc(void *env, Any (*fn)(void *env, Any e), Any x) { + Any z = NIL; + for(Any y = x; NIL != y; y = cdr(y)) + z = fn(env, car(y)); + return z; +} + +Any find(Any e, Any l, int (*eq)(Any e, Any x)) { + for(; NIL != l; l = cdr(l)) { + Any a = car(l); + if(eq(e, car(a))) return a; + } + return NIL; +} + +Any reverse(Any x, Any a) { + return NIL == x ? a : reverse(cdr(x), cons(car(x), a)); +} diff --git a/unoidl2.h b/unoidl2.h @@ -55,3 +55,7 @@ Any caddddr(Any x); Any cdddddr(Any x); int equal(Any x, Any y); Any print(Any x); +int some(void *env, int (*fn)(void *env, Any e), Any x); +Any mapc(void *env, Any (*fn)(void *env, Any e), Any x); +Any find(Any e, Any l, int (*eq)(Any e, Any x)); +Any reverse(Any x, Any a); diff --git a/unoidl2java.c b/unoidl2java.c @@ -179,21 +179,6 @@ static void pr_slots(Any slots, Any name) { pl(" }"); } -static 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; - } - return 0; -} - -static Any mapc(void *env, Any (*fn)(void *env, Any e), Any x) { - Any z = NIL; - for(Any y = x; NIL != y; y = cdr(y)) - z = fn(env, car(y)); - return z; -} - static Any method; static int k; @@ -526,20 +511,8 @@ static void pr_typedef(Any x) { typedefs = cons(cons(cons(cadr(x), module), cadddr(x)), typedefs); } -static Any find(Any e, Any l, int (*eq)(Any e, Any x)) { - for(; NIL != l; l = cdr(l)) { - Any a = car(l); - if(eq(e, car(a))) return a; - } - return NIL; -} - static Any resolve_typedef(Any x) {return find(x, typedefs, equal);} -static Any reverse(Any x, Any a) { - return NIL == x ? a : reverse(cdr(x), cons(car(x), a)); -} - static void pr_relative(Any x) { if(!use_XInterface && equal(com_sun_star_uno_XInterface, cdr(x))) pr("java.lang.Object");