//-*-java-*- OutputVisitor { (@ PrintWriter out = null; String univ_header; File checksums; @) before Weaver (@ checksums = new File(Weaver.outputdir, "checksums"); FileCheck.readChecksums(checksums); @) after Weaver (@ FileCheck.writeChecksums(checksums); @) before {FixVisibility,FixModifiers} (@ StringWriter sw = new StringWriter(); host.universal_trv0(new PrintVisitor(new PrintWriter(sw))); out.print(sw.toString()); @) before ClassName (@ out.print(host.get_ident()+" "); @) before JavaCode (@ out.print(host.get_text().toString()); @) around AddClass {{ File output = new File(Weaver.outputdir, host.get_name().get_ident()+".java"); FileCheck fcheck = new FileCheck(); out = fcheck.openOutputFile(output); if(host.get_pack() != null) out.println("package "+host.get_pack()+";"); if(host.imports != null) { Enumeration imp_enum = host.imports.elements(); while(imp_enum.hasMoreElements()) out.println(imp_enum.nextElement().toString()); } subtraversal.apply(); out.print("}\n"); fcheck.closeOutputFile(); }} before AddClassName (@ out.print("class "+host+" "); @) around ClassParentFeature {{ if(host.get_parentclass() != null) { out.print("extends "); host.get_parentclass().toAllOut(this); out.print(' '); } if(host.get_interfaces() != null) { out.print("implements "); host.get_interfaces().toAllOut(this); out.print(' '); } out.print("{\n"); }} around ComListOfDotList (@ // trap traversal StringWriter sw = new StringWriter(); host.universal_trv0(new PrintVisitor(new PrintWriter(sw))); out.print(sw.toString()); @) before {ParsableClassPart,ParsableInterfacePart} (@ out.print(" "); @) after {ClassPart,InterfacePart} (@ out.print("\n"); @) after FixDataType (@ out.print(' '); @) before SquareBrackets (@ out.print("[]"); @) before {MemberName,MethodName} (@ out.print(host.get_ident().toString()); @) around DottedName (@ out.print(host.toString()); @) // trap traversal around {FieldNamesAndOptInits,FieldNamesAndInits} (@ Enumeration field_enum = host.elements(); boolean first = true; while(field_enum.hasMoreElements()) { if(first) first = false; else out.print(", "); if((Object)host instanceof FieldNamesAndOptInits) { FieldNameOptInit field = (FieldNameOptInit)field_enum.nextElement(); field.toAllOut(this); } else { FieldNameInit field = (FieldNameInit)field_enum.nextElement(); field.toAllOut(this); } } @) before InitFieldTrailer (@ out.print(" = "); @) after {ClassField,InterfaceField} (@ out.print(';'); @) around ClassMethod (@ if(host.get_vis() != null) host.get_vis().toAllOut(this); if(host.get_mods() != null) host.get_mods().toAllOut(this); host.get_type().toAllOut(this); host.get_name().toAllOut(this); out.print('('); if(host.get_args() != null) host.get_args().toAllOut(this); out.print(") "); if(host.get_throwz() != null) host.get_throwz().toAllOut(this); host.get_body().toAllOut(this); @) around Arguments (@ StringWriter sw = new StringWriter(); host.universal_trv0(new PrintVisitor(new PrintWriter(sw))); out.print(sw.toString()); @) around MethodThrows (@ out.print("throws "); subtraversal.apply(); out.print(' '); @) around FixMethodBody (@ out.print("{"); subtraversal.apply(); out.print("}"); @) before NoMethodBody (@ out.print(';'); @) around AddInterface (@ File output = new File(Weaver.outputdir, host.get_name().get_ident()+".java"); FileCheck fcheck = new FileCheck(); out = fcheck.openOutputFile(output); if(host.get_pack() != null) out.println("package "+host.get_pack()+";"); if(host.imports != null) { Enumeration imp_enum = host.imports.elements(); while(imp_enum.hasMoreElements()) out.println(imp_enum.nextElement().toString()); } subtraversal.apply(); out.print("}\n"); fcheck.closeOutputFile(); @) before InterfaceName {{ out.print("interface "+host+" "); }} around InterfaceParentFeature {{ if(host.get_parents() != null) { out.print("extends "); subtraversal.apply(); out.print(' '); } out.print("{\n"); }} around InterfaceMethod {{ if(host.get_vis() != null) host.get_vis().toAllOut(this); if(host.get_mods() != null) host.get_mods().toAllOut(this); host.get_type().toAllOut(this); host.get_name().toAllOut(this); out.print('('); if(host.get_args() != null) host.get_args().toAllOut(this); out.print(") "); if(host.get_throwz() != null) host.get_throwz().toAllOut(this); out.print(";\n"); }} } DottedName { public String toString() (@ StringBuffer ret = new StringBuffer(); Enumeration name_enum = this.get_name().elements(); if(name_enum.hasMoreElements()) { ret.append((Ident)name_enum.nextElement()); while(name_enum.hasMoreElements()) ret.append("."+(Ident)name_enum.nextElement()); } return ret.toString(); @) } {ClassName,AddClassName,InterfaceName} { public String toString() (@ return get_ident().toString(); @) }