1 26 27 package org.objectweb.corba.command.lib; 28 29 import org.objectweb.util.cmdline.lib.DefaultCommandLine; 31 import org.objectweb.util.cmdline.lib.DefaultOptionArgument; 32 import org.objectweb.openccm.ast.api.FileScope; 33 import org.objectweb.openccm.command.lib.CompilerGeneratorBase; 34 35 42 43 public class CIFtoJavaImpl 44 extends CompilerGeneratorBase 45 implements org.objectweb.corba.command.api.CIFtoJavaImpl 46 { 47 53 54 private org.objectweb.util.cmdline.api.OptionArgument odir_; 56 62 63 public 64 CIFtoJavaImpl() 65 { 66 super(new DefaultCommandLine("cif_jimpl", 68 "file", 69 new String [] { 70 "Compile an OMG CIDL file and generate its associated Java implementation templates." 71 }, 72 true) 73 ); 74 75 odir_ = new DefaultOptionArgument( 78 new String [] { "-d" }, 79 "outputdir", 80 new String [] { 81 "Generate Java implementations templates into directory <outputdir>,", 82 "default is generated/" 83 }, 84 "generated" ); 85 getCommandLine().addOption(odir_); 86 } 87 88 94 100 106 113 public int 114 run(java.lang.String [] args) 115 { 116 String filename = args[0]; 117 118 if(!initAST()) 120 return -1; 121 122 FileScope fileScope = compile(filename); 124 if(fileScope == null) 125 return -1; 126 127 if (!generate_cif_jimpl(fileScope, 129 filename, getOutputDirectory())) return -1; 132 133 return 0; 135 } 136 137 143 149 155 161 167 172 public String 173 getOutputDirectory() 174 { 175 return odir_.getArgument(); 176 } 177 178 190 public boolean 191 generate_cif_jimpl(org.objectweb.openccm.ast.api.FileScope filescope, 192 String inputfile, 193 String base_dir) 194 { 195 org.objectweb.corba.generator.cif.api.CIF_JavaImplGenerator gen = 197 new org.objectweb.corba.generator.cif.lib.CIF_JavaImplGenerator(getAST()); 198 try 199 { 200 gen.cif_to_java_impl(base_dir, filescope); 201 } 202 catch(org.objectweb.openccm.generator.common.lib.GenerationException ex) 203 { 204 report_exception(ex); 205 return false; 206 } 207 return true; 208 } 209 210 216 221 public static void 222 main(String [] args) 223 { 224 CIFtoJavaImpl cif2jimpl = new CIFtoJavaImpl(); 225 cif2jimpl.runMain(args); 226 } 227 } 228 | Popular Tags |