unoidl2

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

commit 4f7c118ce98142094681530df837bfff9fcac1f6
parent f51a31155e79d173a7adc4c58ec68a8ae8a8f1db
Author: Tomas Hlavaty <tom@logand.com>
Date:   Tue, 17 Jan 2012 00:15:31 +0100

null() removed

Diffstat:
Munoidl2.c | 15+++++++--------
Munoidl2.h | 4+++-
Munoidl2ast.c | 2+-
Munoidl2java.c | 71+++++++++++++++++++++++++++++++++++------------------------------------
4 files changed, 46 insertions(+), 46 deletions(-)

diff --git a/unoidl2.c b/unoidl2.c @@ -65,7 +65,6 @@ Any mkinum(int n) { return x; } -int null(Any x) {return NIL == x;} int consp(Any x) {return CONS == x->tag;} Any car(Any x) {return x->u.c.car;} Any cdr(Any x) {return x->u.c.cdr;} @@ -98,10 +97,10 @@ Any list6(Any a, Any b, Any c, Any d, Any e, Any f) { } Any nconc2(Any a, Any b) { - if(null(a)) + if(NIL == a) return b; Any x, d; - for(x = a, d = cdr(x); !null(d); x = d, d = cdr(x)); + for(x = a, d = cdr(x); NIL != d; x = d, d = cdr(x)); x->u.c.cdr = b; return a; } @@ -116,12 +115,12 @@ Any caddddr(Any x) {return car(cdr(cdr(cdr(cdr(x)))));} Any cdddddr(Any x) {return cdr(cdr(cdr(cdr(cdr(x)))));} int equal(Any x, Any y) { - if(null(x)) return null(y); + if(NIL == x) return NIL == y; switch(x->tag) { case CONS: - for(; !null(x) && !null(y); x = cdr(x), y = cdr(y)) + for(; NIL != x && NIL != y; x = cdr(x), y = cdr(y)) if(!equal(car(x), car(y))) return 0; - return null(x) && null(y); + return NIL == x && NIL == y; case TOKEN: return TOKEN == y->tag && kind(x) == kind(y) && 0 == strcmp(token(x), token(y)); case INUM: @@ -131,14 +130,14 @@ int equal(Any x, Any y) { } Any print(Any x) { - if(null(x)) + if(NIL == x) printf("NIL"); else switch(x->tag) { case CONS: printf("("); print(car(x)); - for(Any d = cdr(x); !null(d); d = cdr(d)) { + for(Any d = cdr(x); NIL != d; d = cdr(d)) { printf(" "); if(consp(d)) print(car(d)); diff --git a/unoidl2.h b/unoidl2.h @@ -21,10 +21,12 @@ typedef struct any *Any; enum yytokentype; typedef enum yytokentype Kind; +extern const Any NIL; +extern const Any T; + Any cons(Any car, Any cdr); Any mk(Kind kind, char *token); Any mkinum(int n); -int null(Any x); int consp(Any x); Any car(Any x); Any cdr(Any x); diff --git a/unoidl2ast.c b/unoidl2ast.c @@ -26,7 +26,7 @@ extern int yyparse(); extern Any ast; static void pr_all(Any x) { - for(; !null(x); x = cdr(x)) { + for(; NIL != x; x = cdr(x)) { print(car(x)); printf("\n\n"); } diff --git a/unoidl2java.c b/unoidl2java.c @@ -24,7 +24,6 @@ extern int yyparse(); extern const Any ast; -extern const Any NIL; static Any module; static Any typedefs; @@ -47,14 +46,14 @@ static inline void pi(int x) {printf("%d", x);} static void pp(Any x); static void pp_list(Any x, char *sep) { - for(int i = 0; !null(x); x = cdr(x), i++) { + for(int i = 0; NIL != x; x = cdr(x), i++) { if(sep && 0 < i) pr(sep); pp(car(x)); } } static void pr_module(Any x, char *sep, int dot) { - if(!null(x)) { + if(NIL != x) { pr_module(cdr(x), sep, 1); pp(car(x)); if(dot) pr(sep); @@ -63,8 +62,8 @@ static void pr_module(Any x, char *sep, int dot) { static Any last(Any x) { if(consp(x)) { - for(; !null(x); x = cdr(x)) - if(null(cdr(x))) return car(x); + for(; NIL != x; x = cdr(x)) + if(NIL == cdr(x)) return car(x); return NIL; } else return x; } @@ -73,7 +72,7 @@ static void pr_package(Any class) { pr("///--- "); pr_module(module, "/", 0); pr(" "); pp(last(class)); pl(".java"); // TODO only toplevel pl("// Generated by unoidl2java, do not edit!"); pr("package "); pr_module(module, ".", 0); pl(";"); - for(Any x = cdr(module); !null(x); x = cdr(x)) { + for(Any x = cdr(module); NIL != x; x = cdr(x)) { pr("import "); pr_module(x, ".", 0); pl(".*;"); } } @@ -81,7 +80,7 @@ static void pr_package(Any class) { static void pr_enum(Any x) { Any name = cadr(x); Any published = caddr(x); - if(!null(published)) { + if(NIL != published) { Any values = cdddr(x); Any v0 = car(values); Any v0k = consp(v0) ? car(v0) : v0; @@ -95,7 +94,7 @@ static void pr_enum(Any x) { pl(" }"); int n = 0; int explicit = 0; - for(Any y = values; !null(y); y = cdr(y)) { + for(Any y = values; NIL != y; y = cdr(y)) { Any value = car(y); int explicit1 = consp(value); explicit |= explicit1; @@ -111,7 +110,7 @@ static void pr_enum(Any x) { pl(" switch(value) {"); pr(" default: return null;"); n = 0; - for(Any y = values; !null(y); y = cdr(y)) { + for(Any y = values; NIL != y; y = cdr(y)) { Any value = car(y); char *k = token(consp(value) ? car(value) : value); Any v = consp(value) ? cadr(value) : mkinum(n++); @@ -124,7 +123,7 @@ static void pr_enum(Any x) { } static void pr_args(Any x) { - for(int i = 0; !null(x); x = cdr(x), i++) { + for(int i = 0; NIL != x; x = cdr(x), i++) { Any a = car(x); if(0 < i) pr(", "); pp(cadr(a)); pr(" "); pp(car(a)); @@ -132,7 +131,7 @@ static void pr_args(Any x) { } static void pr_args2(Any x) { // for in, out, inout - for(int i = 0; !null(x); x = cdr(x), i++) { + for(int i = 0; NIL != x; x = cdr(x), i++) { Any a = car(x); if(0 < i) pr(", "); pp(caddr(a)); pr(" "); pp(cadr(a)); @@ -145,7 +144,7 @@ static void pr_args2(Any x) { // for in, out, inout static void pr_default_slots(Any slots) { // TODO init enum to default - for(Any y = slots; !null(y); y = cdr(y)) { + for(Any y = slots; NIL != y; y = cdr(y)) { Any slot = car(y); Any n = car(slot); Any t = cadr(slot); @@ -160,7 +159,7 @@ static void pr_default_slots(Any slots) { } static void pr_slots(Any slots, Any name) { - for(Any y = slots; !null(y); y = cdr(y)) { + for(Any y = slots; NIL != y; y = cdr(y)) { Any slot = car(y); Any n = car(slot); Any t = cadr(slot); @@ -170,7 +169,7 @@ static void pr_slots(Any slots, Any name) { pr_default_slots(slots); pl(" }"); pr(" public "); pp(name); pr("("); pr_args(slots); pl(") {"); - for(Any y = slots; !null(y); y = cdr(y)) { + for(Any y = slots; NIL != y; y = cdr(y)) { Any slot = car(y); Any n = car(slot); Any t = cadr(slot); @@ -181,7 +180,7 @@ static void pr_slots(Any slots, Any name) { } static int some(void *env, int (*fn)(void *env, Any e), Any x) { - for(Any y = x; !null(y); y = cdr(y)) { + for(Any y = x; NIL != y; y = cdr(y)) { int z = fn(env, car(y)); if(z) return z; } @@ -190,7 +189,7 @@ static int some(void *env, int (*fn)(void *env, Any e), Any x) { static Any mapc(void *env, Any (*fn)(void *env, Any e), Any x) { Any z = NIL; - for(Any y = x; !null(y); y = cdr(y)) + for(Any y = x; NIL != y; y = cdr(y)) z = fn(env, car(y)); return z; } @@ -260,7 +259,7 @@ static Any pr_TypeInfo1(void *env, Any x) { method = cadr(x); t = cadddr(x); f |= type_flags(t); - if(!null(caddr(x))) f |= _ONEWAY; + if(NIL != caddr(x)) f |= _ONEWAY; pr_TypeInfo2("Method", method, t, f, env, -1); int i = -1; mapc(&i, pr_TypeInfo1, caddddr(x)); @@ -316,7 +315,7 @@ static void pr_TypeInfo(Any body) { } static void pr_extends(Any x) { - if(!null(x)) { + if(NIL != x) { pr(" extends "); use_XInterface = 1; pp(x); @@ -327,7 +326,7 @@ static void pr_extends(Any x) { static void pr_struct(Any x) { Any name = cadr(x); Any published = caddr(x); - if(!null(published)) { + if(NIL != published) { Any super = cadddr(x); Any slots = cddddr(x); pr_package(name); @@ -343,7 +342,7 @@ static void pr_struct(Any x) { static void pr_exception(Any x) { Any name = cadr(x); Any published = caddr(x); - if(!null(published)) { + if(NIL != published) { Any super = cadddr(x); Any body = cddddr(x); pr_package(name); @@ -371,7 +370,7 @@ static void pr_exception(Any x) { pl(" new com.sun.star.lib.uno.typeinfo.MemberTypeInfo(\"Context\", 0, 128)"); pl(" };"); } else { - for(Any y = body; !null(y); y = cdr(y)) { + for(Any y = body; NIL != y; y = cdr(y)) { Any slot = car(y); pr(" public "); pp(cadr(slot)); pr(" "); pp(car(slot)); pl(";"); } @@ -406,22 +405,22 @@ static Any pr_definterface_nonattribute(void *env, Any x) { static void pr_definterface(Any x) { Any name = cadr(x); Any published = caddr(x); - if(!null(published)) { + if(NIL != published) { Any super = cadddr(x); Any body = cddddr(x); pr_package(name); pr("public interface "); pp(name); pr_extends(super); use_XInterface = 1; - int i = null(super) ? 0 : 1; - for(Any y = body; !null(y); y = cdr(y)) { + int i = NIL == super ? 0 : 1; + for(Any y = body; NIL != y; y = cdr(y)) { Any slot = car(y); if(INTERFACE == kind(car(slot))) { pr(0 < i++ ? ", " : " extends "); pp(cadr(slot)); } } - if(null(super) && i <= 0 + if(NIL == super && i <= 0 && !(equal(name, XInterface) && equal(module, uno_star_sun_com))) pr(" extends com.sun.star.uno.XInterface"); use_XInterface = 0; @@ -442,7 +441,7 @@ static void pr_method(Any x) { Any args = caddddr(x); Any body = cdddddr(x); pr(" public abstract "); pp(type); pr(" "); pp(name); pr("("); pr_args2(args); pr(")"); - if(!null(body)) { + if(NIL != body) { pr(" throws "); pp_list(body, ", "); } pl(";"); @@ -497,7 +496,7 @@ static void pr_singleton(Any x) { static void pr_constants(Any x) { Any name = cadr(x); Any published = caddr(x); - if(!null(published)) { + if(NIL != published) { Any body = cdddr(x); pr_package(name); pr("public interface "); pp(name); pl(" { // constants"); @@ -528,7 +527,7 @@ static void pr_typedef(Any x) { } static Any find(Any e, Any l, int (*eq)(Any e, Any x)) { - for(; !null(l); l = cdr(l)) { + for(; NIL != l; l = cdr(l)) { Any a = car(l); if(eq(e, car(a))) return a; } @@ -538,22 +537,22 @@ static Any find(Any e, Any l, int (*eq)(Any e, Any x)) { static Any resolve_typedef(Any x) {return find(x, typedefs, equal);} static Any reverse(Any x, Any a) { - return null(x) ? a : reverse(cdr(x), cons(car(x), 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"); else { - if(null(cddr(x))) { // local typedef + if(NIL == cddr(x)) { // local typedef Any y = resolve_typedef(cons(cadr(x), module)); - if(!null(y)) { + if(NIL != y) { pp(cdr(y)); return; } } Any y = resolve_typedef(reverse(cdr(x), NIL)); - if(!null(y)) { // non-local typedef + if(NIL != y) { // non-local typedef Any a = car(y); // (ServiceContextList iop corba star sun com) Any d = cdr(y); // (sequence (relative ServiceContext)) rel_package = cons(cdr(a), rel_package); @@ -562,7 +561,7 @@ static void pr_relative(Any x) { return; } Any p = car(rel_package); - if(null(cddr(x))) // x => (relative ServiceContext) p => (iop corba star sun com) + if(NIL == cddr(x)) // x => (relative ServiceContext) p => (iop corba star sun com) pp_list(reverse(cons(cadr(x), p), NIL), "."); else pp_list(cdr(x), "."); @@ -574,7 +573,7 @@ static void pr_absolute(Any x) { pr("java.lang.Object"); else { Any y = resolve_typedef(reverse(cdr(x), NIL)); - if(!null(y)) { // non-local typedef + if(NIL != y) { // non-local typedef Any a = car(y); // (ServiceContextList iop corba star sun com) Any d = cdr(y); // (sequence (relative ServiceContext)) rel_package = cons(cdr(a), rel_package); @@ -602,7 +601,7 @@ static void pr_property(Any x) { static void pr_deftemplate(Any x) { Any name = cadr(x); Any published = caddr(x); - if(!null(published)) { + if(NIL != published) { Any args = cadddr(x); Any slots = cddddr(x); pr_package(name); @@ -699,7 +698,7 @@ static void pp(Any x) { case MOD: pp(cadr(x)); pp(car(x)); pp(caddr(x)); break; case PLUS: case MINUS: - if(null(cddr(x))) { // unary + if(NIL == cddr(x)) { // unary pp(car(x)); pp(cadr(x)); } else { // binary pp(cadr(x)); pp(car(x)); pp(caddr(x));