Merge with trank @ 137446
[official-gcc.git] / libjava / classpath / tools / gnu / classpath / tools / javah / GcjhMain.java
blob15bcec2630bfd39bda2a3c4a8a0f2eda6b90cee8
1 /* GcjhMain.java - gcjh main program
2 Copyright (C) 2007 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 02110-1301 USA.
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
24 combination.
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
39 package gnu.classpath.tools.javah;
41 import gnu.classpath.tools.common.ClasspathToolParser;
43 import gnu.classpath.tools.getopt.Option;
44 import gnu.classpath.tools.getopt.OptionException;
45 import gnu.classpath.tools.getopt.OptionGroup;
47 import java.io.IOException;
48 import java.util.ArrayList;
50 public class GcjhMain extends Main
52 ArrayList commands = new ArrayList();
54 public GcjhMain()
56 cni = true;
59 protected String getName()
61 return "gcjh";
64 protected ClasspathToolParser getParser()
66 ClasspathToolParser result = super.getParser();
68 result.setHeader("usage: gcjh [OPTION]... CLASS...");
70 OptionGroup text = new OptionGroup("CNI text options");
71 text.add(new Option("add", "Insert TEXT into class body", "TEXT")
73 public void parsed(String arg) throws OptionException
75 commands.add(new Text(Text.ADD, arg));
77 });
78 text.add(new Option("append", "Append TEXT after class declaration",
79 "TEXT")
81 public void parsed(String arg) throws OptionException
83 commands.add(new Text(Text.APPEND, arg));
85 });
86 text.add(new Option("friend", "Insert TEXT as a 'friend' declaration",
87 "TEXT")
89 public void parsed(String arg) throws OptionException
91 commands.add(new Text(Text.FRIEND, arg));
93 });
94 text.add(new Option("prepend", "Insert TEXT before start of class", "TEXT")
96 public void parsed(String arg) throws OptionException
98 commands.add(new Text(Text.PREPEND, arg));
101 result.add(text);
103 OptionGroup compat = new OptionGroup("Compatibility options (unused)");
104 // gcjh itself had compatibility options -old and -trace. I
105 // didn't add them here since they should really be unused by now.
106 compat.add(new Option("td", "Unused compatibility option", "DIRECTORY")
108 public void parsed(String arg) throws OptionException
112 // I don't believe anyone ever used these options.
113 compat.add(new Option("M", "Unused compatibility option")
115 public void parsed(String arg) throws OptionException
119 compat.add(new Option("MM", "Unused compatibility option")
121 public void parsed(String arg) throws OptionException
125 compat.add(new Option("MD", "Unused compatibility option")
127 public void parsed(String arg) throws OptionException
131 compat.add(new Option("MMD", "Unused compatibility option")
133 public void parsed(String arg) throws OptionException
138 result.add(compat);
140 return result;
143 protected void postParse(String[] names)
145 for (int i = 0; i < names.length; ++i)
146 textMap.put(names[i].replace('.', '/'), commands);
149 public static void main(String[] args) throws IOException
151 new GcjhMain().run(args);