| 126 | |
| 127 | |
| 128 | private void process(StringBuilder out, File input) throws IOException { |
| 129 | BufferedReader in = createReader(input); |
| 130 | int comments = 0; |
| 131 | String line = null; |
| 132 | StringBuilder commentBuffer = new StringBuilder(); |
| 133 | |
| 134 | while ((line = in.readLine()) != null) { |
| 135 | String decl = ""; |
| 136 | |
| 137 | // Keep track of comments |
| 138 | //if (line.matches(Pattern.quote("/*"))) { |
| 139 | if (line.indexOf("/*") != -1) { |
| 140 | comments++; |
| 141 | } |
| 142 | |
| 143 | //if (line.matches(Pattern.quote("*/"))) { |
| 144 | if (line.indexOf("*/") != -1) { |
| 145 | commentBuffer.append(line); |
| 146 | commentBuffer.append('\n'); |
| 147 | //System.out.println("comment is: " + commentBuffer.toString()); |
| 148 | comments--; |
| 149 | // otherwise gotSomething will be false, and nuke the comment |
| 150 | continue; |
| 151 | } |
| 152 | |
| 153 | // Ignore everything inside comments |
| 154 | if (comments > 0) { |
| 155 | commentBuffer.append(line); |
| 156 | commentBuffer.append('\n'); |
| 157 | continue; |
| 158 | } |
| 159 | |
| 160 | boolean gotSomething = false; |
| 161 | boolean gotStatic = false; |
| 162 | |
| 163 | Matcher result; |
| 164 | |
| 165 | if ((result = Pattern.compile("^\\s*public ([\\w\\[\\]]+) [a-zA-z_]+\\(.*$").matcher(line)).matches()) { |
| 166 | gotSomething = true; |
| 167 | |
| 168 | } else if ((result = Pattern.compile("^\\s*abstract public ([\\w\\[\\]]+) [a-zA-z_]+\\(.*$").matcher(line)).matches()) { |
| 169 | gotSomething = true; |
| 170 | |
| 171 | } else if ((result = Pattern.compile("^\\s*public final ([\\w\\[\\]]+) [a-zA-z_]+\\(.*$").matcher(line)).matches()) { |
| 172 | gotSomething = true; |
| 173 | |
| 174 | } else if ((result = Pattern.compile("^\\s*static public ([\\w\\[\\]]+) [a-zA-z_]+\\(.*$").matcher(line)).matches()) { |
| 175 | gotSomething = true; |
| 176 | gotStatic = true; |
| 177 | } |
| 178 | |
| 179 | // if function is marked "// ignore" then, uh, ignore it. |
| 180 | if (gotSomething && line.indexOf("// ignore") >= 0) { |
| 181 | gotSomething = false; |
| 182 | } |
| 183 | |
| 184 | String returns = ""; |
| 185 | if (gotSomething) { |