1 26 27 package org.objectweb.openccm.command.lib; 28 29 import org.objectweb.util.cmdline.lib.DefaultCommandLine; 31 import java.util.ArrayList ; 32 33 41 42 public class IR3toIDL3 43 extends GeneratorBase 44 implements org.objectweb.openccm.command.api.IR3toIDL3 45 { 46 52 53 private OptionMultipleArguments import_; 54 55 61 62 public 63 IR3toIDL3() 64 { 65 super(new DefaultCommandLine("ir3_idl3", 67 "declaration", 68 "Generate OMG IDL 3.0 for a declaration from the OpenCCM Interface Repository", 69 true), 70 "generated.idl3"); 71 72 74 import_ = new OptionMultipleArguments( 76 "-i", 77 new String [] { "-i" }, 78 "ir_object", 79 new String [] { "Add import ir_object statement" }, 80 "", 81 true); 82 getCommandLine().addOption(import_); 83 } 84 85 91 97 103 110 public int 111 run(java.lang.String [] args) 112 { 113 if(!initAST()) 115 return -1; 116 117 if (!generate_idl3(args[0], 119 getOutputFileName(), 120 import_.getOptionArguments())) 121 return -1; 122 123 return 0; 125 } 126 127 133 139 145 151 160 public boolean 161 generate_idl3(String decl_name, 162 String outputfile, 163 String [] imports) 164 { 165 getComponentRepository().as_IDL3_repository(); 167 168 org.objectweb.openccm.ast.api.Scope scope = null; 170 try 171 { 172 scope = (org.objectweb.openccm.ast.api.Scope)getAST().lookup(decl_name); 173 } 174 catch(ClassCastException e) 175 { 176 getConsole().error(decl_name + "is not a scope!"); 177 return false; 178 } 179 180 if(scope == null) 181 { 182 getConsole().error("Declaration " + decl_name + " not found!"); 183 return false; 184 } 185 186 getConsole().message("Generating OMG IDL 3.0 for " + decl_name + "..."); 187 188 org.objectweb.openccm.generator.idl.api.IDL3Generator gen = 190 new org.objectweb.openccm.generator.idl.lib.IDL3Generator(getAST()); 191 gen.initialize( outputfile, 192 new ArrayList (java.util.Arrays.asList(imports)), 193 "IR3toIDL3" ); 194 195 try 197 { 198 gen.generate(scope); 199 } 200 catch(org.objectweb.openccm.generator.common.lib.GenerationException ex) 201 { 202 report_exception(ex); 203 return false; 204 } 205 206 getConsole().message("OMG IDL 3.0 generated in " + outputfile + "."); 207 return true; 208 } 209 210 216 221 public static void 222 main(String [] args) 223 { 224 IR3toIDL3 ir3_idl3 = new IR3toIDL3(); 225 ir3_idl3.runMain(args); 226 } 227 } 228 | Popular Tags |