unoidl2

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

commit 29063f7c2bc264f6a274965ef3a83df0635dba30
parent 0a5921ee97aa2f421b6d69b98ca837c73c001fe0
Author: Tomas Hlavaty <tom@logand.com>
Date:   Sun, 15 Jan 2012 13:59:36 +0100

handle attributes

Diffstat:
Munoidl2java.c | 44+++++++++++++++++++++++++++++---------------
1 file changed, 29 insertions(+), 15 deletions(-)

diff --git a/unoidl2java.c b/unoidl2java.c @@ -46,13 +46,13 @@ static inline void pi(int x) {printf("%d", x);} static void pp(Any x); -static void pp_list(Any x, char *sep) { +static void pp_list(void (*fn) (Any e), 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); - pp(car(x)); + fn(car(x)); } } @@ -381,6 +381,16 @@ static void pr_exception(Any x) { } } +static void pr_definterface_attribute(Any x) { + if(ATTRIBUTE == kind(car(x))) + pp(x); +} + +static void pr_definterface_nonattribute(Any x) { + if(ATTRIBUTE != kind(car(x))) + pp(x); +} + static void pr_definterface(Any x) { Any name = cadr(x); Any published = caddr(x); @@ -405,7 +415,8 @@ static void pr_definterface(Any x) { use_XInterface = 0; pl(" {"); if(!(equal(name, XInterface) && equal(module, uno_star_sun_com))) { - pp_list(body, ""); + pp_list(pr_definterface_attribute, body, ""); + pp_list(pr_definterface_nonattribute, body, ""); pr_TypeInfo(body); } pl("}"); @@ -420,13 +431,16 @@ 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(body, ", "); + pr(" throws "); pp_list(pp, body, ", "); } pl(";"); } -static void pr_attribute(Any x) { - pr(" "); pp(cadr(x)); pr(" "); pp(caddr(x)); pl(";"); // TODO options +static void pr_attribute(Any x) { // (attribute (string) KeyName (readonly)) + Any t = cadr(x); + Any n = caddr(x); + pr(" public abstract "); pp(t); pr(" get"); pp(n); pl("();"); + pr(" public abstract void set"); pp(n); pr("("); pp(t); pl(" x);"); } static void pr_arg(Any x) { @@ -472,7 +486,7 @@ static void pr_constants(Any x) { Any body = cdddr(x); pr_package(name); pr("public interface "); pp(name); pl(" { // constants"); - pp_list(body, ""); + pp_list(pp, body, ""); pl("}"); } } @@ -532,9 +546,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(reverse(cons(cadr(x), p), NIL), "."); + pp_list(pp, reverse(cons(cadr(x), p), NIL), "."); else - pp_list(cdr(x), "."); + pp_list(pp, cdr(x), "."); } } @@ -551,7 +565,7 @@ static void pr_absolute(Any x) { rel_package = cdr(rel_package); return; } - pp_list(cdr(x), "."); + pp_list(pp, cdr(x), "."); } } @@ -572,7 +586,7 @@ static void pr_deftemplate(Any x) { Any slots = cddddr(x); pr_package(name); pr("public class "); pp(name); - pr("<"); pp_list(args, ", "); pr(">"); pl(" { // deftemplate"); + pr("<"); pp_list(pp, args, ", "); pr(">"); pl(" { // deftemplate"); pr_slots(slots, name); pr_TypeInfo(slots); pl("}"); @@ -607,7 +621,7 @@ static void pr_primitive(Any x) { static void pr_template(Any x) { template = 1; - pp(cadr(x)); pr("<"); pp_list(caddr(x), ", "); pr(">"); + pp(cadr(x)); pr("<"); pp_list(pp, caddr(x), ", "); pr(">"); template = 0; } @@ -618,7 +632,7 @@ static void pp(Any x) { switch(kind(a)) { case MODULE: module = cons(cadr(x), module); - pp_list(cddr(x), ""); + pp_list(pp, cddr(x), ""); module = cdr(module); break; case ENUM: pr_enum(x); break; @@ -634,7 +648,7 @@ static void pp(Any x) { case CONSTANTS: pr_constants(x); break; case CONST: pr_const(x); break; case SEQUENCE: pp(cadr(x)); pr(seq0 ? "[0]" : "[]"); break; - //case ATTRIBUTE: pr_attribute(x); break; + case ATTRIBUTE: pr_attribute(x); break; case EXCEPTION: pr_exception(x); break; //case SERVICE: pr_service(x); break; case PROPERTY: pr_property(x); break; @@ -691,7 +705,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(ast, NULL); + pp_list(pp, ast, NULL); //print(typedefs); return 0; }