| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -131,9 +131,6 @@ | |||
| 131 | 131 | * itself. The ANTLR manual goes into a fair amount of detail about the | |
| 132 | 132 | * what each type of file is for. | |
| 133 | 133 | * <P/> | |
| 134 | - * | ||
| 135 | - * Hacked to death in 2010 by | ||
| 136 | - * @author Jonathan Feinberg <jdf@pobox.com> | ||
| 137 | 134 | */ | |
| 138 | 135 | public class PdePreprocessor { | |
| 139 | 136 | protected static final String UNICODE_ESCAPES = "0123456789abcdefABCDEF"; | |
@@ -150,87 +147,10 @@ public static enum Mode { | |||
| 150 | 147 | ||
| 151 | 148 | private TokenStreamCopyingHiddenTokenFilter filter; | |
| 152 | 149 | ||
| 153 | - // private boolean foundMain; | ||
| 154 | 150 | private String advClassName = ""; | |
| 155 | 151 | protected Mode mode; | |
| 156 | 152 | Set<String> foundMethods; | |
| 157 | 153 | ||
| 158 | - // protected String sizeStatement; | ||
| 159 | - // protected String sketchWidth; | ||
| 160 | - // protected String sketchHeight; | ||
| 161 | - // protected String sketchRenderer; | ||
| 162 | - // protected String sketchOutputPath; | ||
| 163 | - | ||
| 164 | - /* | ||
| 165 | - static class SizeInfo { | ||
| 166 | - String statement; | ||
| 167 | - String width; | ||
| 168 | - String height; | ||
| 169 | - String renderer; | ||
| 170 | - String path; | ||
| 171 | - String display; | ||
| 172 | - | ||
| 173 | - // SizeInfo(String statement, String width, String height, | ||
| 174 | - // String renderer, String outputPath, String display) { | ||
| 175 | - // this.statement = statement; | ||
| 176 | - // } | ||
| 177 | - | ||
| 178 | - boolean hasOldSyntax() { | ||
| 179 | - if (width.equals("screenWidth") || | ||
| 180 | - width.equals("screenHeight") || | ||
| 181 | - height.equals("screenHeight") || | ||
| 182 | - height.equals("screenWidth")) { | ||
| 183 | - final String message = | ||
| 184 | - "The screenWidth and screenHeight variables are named\n" + | ||
| 185 | - "displayWidth and displayHeight in Processing 3.\n" + | ||
| 186 | - "Or you can use the fullScreen() method instead of size()."; | ||
| 187 | - Base.showWarning("Time for a quick update", message, null); | ||
| 188 | - return true; | ||
| 189 | - } | ||
| 190 | - if (width.equals("screen.width") || | ||
| 191 | - width.equals("screen.height") || | ||
| 192 | - height.equals("screen.height") || | ||
| 193 | - height.equals("screen.width")) { | ||
| 194 | - final String message = | ||
| 195 | - "The screen.width and screen.height variables are named\n" + | ||
| 196 | - "displayWidth and displayHeight in Processing 3.\n" + | ||
| 197 | - "Or you can use the fullScreen() method instead of size()."; | ||
| 198 | - Base.showWarning("Time for a quick update", message, null); | ||
| 199 | - return true; | ||
| 200 | - } | ||
| 201 | - return false; | ||
| 202 | - } | ||
| 203 | - | ||
| 204 | - boolean hasBadSize() { | ||
| 205 | - if (!width.equals("displayWidth") && | ||
| 206 | - !width.equals("displayHeight") && | ||
| 207 | - PApplet.parseInt(width, -1) == -1) { | ||
| 208 | - return true; | ||
| 209 | - } | ||
| 210 | - if (!height.equals("displayWidth") && | ||
| 211 | - !height.equals("displayHeight") && | ||
| 212 | - PApplet.parseInt(height, -1) == -1) { | ||
| 213 | - return true; | ||
| 214 | - } | ||
| 215 | - return false; | ||
| 216 | - } | ||
| 217 | - | ||
| 218 | - | ||
| 219 | - void checkEmpty() { | ||
| 220 | - if (renderer != null) { | ||
| 221 | - if (renderer.length() == 0) { // if empty, set null | ||
| 222 | - renderer = null; | ||
| 223 | - } | ||
| 224 | - } | ||
| 225 | - if (path != null) { | ||
| 226 | - if (path.length() == 0) { | ||
| 227 | - path = null; | ||
| 228 | - } | ||
| 229 | - } | ||
| 230 | - } | ||
| 231 | - } | ||
| 232 | - */ | ||
| 233 | - | ||
| 234 | 154 | SizeInfo sizeInfo; | |
| 235 | 155 | ||
| 236 | 156 | ||
@@ -254,18 +174,17 @@ void checkEmpty() { | |||
| 254 | 174 | "(?:^|\\s|;)void\\ssetup\\s*\\("; | |
| 255 | 175 | ||
| 256 | 176 | ||
| 177 | + // Can't only match any 'public class', needs to be a PApplet | ||
| 178 | + // http://code.google.com/p/processing/issues/detail?id=551 | ||
| 257 | 179 | static private final Pattern PUBLIC_CLASS = | |
| 258 | 180 | Pattern.compile("(^|;)\\s*public\\s+class\\s+\\S+\\s+extends\\s+PApplet", Pattern.MULTILINE); | |
| 259 | - // Can't only match any 'public class', needs to be a PApplet | ||
| 260 | - // http://code.google.com/p/processing/issues/detail?id=551 | ||
| 261 | - //Pattern.compile("(^|;)\\s*public\\s+class", Pattern.MULTILINE); | ||
| 262 | 181 | ||
| 263 | 182 | ||
| 264 | 183 | private static final Pattern FUNCTION_DECL = | |
| 265 | 184 | Pattern.compile("(^|;)\\s*((public|private|protected|final|static)\\s+)*" + | |
| 266 | - "(void|int|float|double|String|char|byte)" + | ||
| 267 | - "(\\s*\\[\\s*\\])?\\s+[a-zA-Z0-9]+\\s*\\(", | ||
| 268 | - Pattern.MULTILINE); | ||
| 185 | + "(void|int|float|double|String|char|byte)" + | ||
| 186 | + "(\\s*\\[\\s*\\])?\\s+[a-zA-Z0-9]+\\s*\\(", | ||
| 187 | + Pattern.MULTILINE); | ||
| 269 | 188 | ||
| 270 | 189 | ||
| 271 | 190 | public PdePreprocessor(final String sketchName) { | |
@@ -281,16 +200,8 @@ public PdePreprocessor(final String sketchName, final int tabSize) { | |||
| 281 | 200 | } | |
| 282 | 201 | ||
| 283 | 202 | ||
| 284 | - public SizeInfo initSketchSize(String code, boolean sizeWarning) throws SketchException { | ||
| 285 | - // String[] info = parseSketchSize(code, sizeWarning); | ||
| 286 | - // if (info != null) { | ||
| 287 | - // sizeStatement = info[0]; | ||
| 288 | - // sketchWidth = info[1]; | ||
| 289 | - // sketchHeight = info[2]; | ||
| 290 | - // sketchRenderer = info[3]; | ||
| 291 | - // sketchOutputPath = info[4]; | ||
| 292 | - // } | ||
| 293 | - // return info; | ||
| 203 | + public SizeInfo initSketchSize(String code, | ||
| 204 | + boolean sizeWarning) throws SketchException { | ||
| 294 | 205 | sizeInfo = parseSketchSize(code, sizeWarning); | |
| 295 | 206 | return sizeInfo; | |
| 296 | 207 | } | |
@@ -430,6 +341,20 @@ make sure that it uses numbers (or displayWidth/Height), copy into settings | |||
| 430 | 341 | return info; | |
| 431 | 342 | //return new String[] { contents[0], width, height, renderer, path }; | |
| 432 | 343 | } | |
| 344 | + // if no size() found, check for fullScreen() | ||
| 345 | + contents = PApplet.match(searchArea, FULL_SCREEN_CONTENTS_REGEX); | ||
| 346 | + if (contents != null) { | ||
| 347 | + SizeInfo info = new SizeInfo(); | ||
| 348 | + info.statement = contents[0]; | ||
| 349 | + StringList args = breakCommas(contents[1]); | ||
| 350 | + info.renderer = args.get(0).trim(); | ||
| 351 | + info.display = args.size() > 1 ? args.get(1).trim() : null; | ||
| 352 | + info.width = "displayWidth"; | ||
| 353 | + info.height = "displayHeight"; | ||
| 354 | + info.checkEmpty(); | ||
| 355 | + return info; | ||
| 356 | + } | ||
| 357 | + | ||
| 433 | 358 | // not an error, just no size() specified | |
| 434 | 359 | //return new String[] { null, null, null, null, null }; | |
| 435 | 360 | return new SizeInfo(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -89,6 +89,11 @@ void checkEmpty() { | |||
| 89 | 89 | path = null; | |
| 90 | 90 | } | |
| 91 | 91 | } | |
| 92 | + if (display != null) { | ||
| 93 | + if (display.length() == 0) { | ||
| 94 | + display = null; | ||
| 95 | + } | ||
| 96 | + } | ||
| 92 | 97 | } | |
| 93 | 98 | ||
| 94 | 99 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments