131131 * itself. The ANTLR manual goes into a fair amount of detail about the
132132 * what each type of file is for.
133133 * <P/>
134- *
135- * Hacked to death in 2010 by
136- * @author Jonathan Feinberg <jdf@pobox.com>
137134 */
138135public class PdePreprocessor {
139136 protected static final String UNICODE_ESCAPES = "0123456789abcdefABCDEF" ;
@@ -150,87 +147,10 @@ public static enum Mode {
150147
151148 private TokenStreamCopyingHiddenTokenFilter filter ;
152149
153- // private boolean foundMain;
154150 private String advClassName = "" ;
155151 protected Mode mode ;
156152 Set <String > foundMethods ;
157153
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-
234154 SizeInfo sizeInfo ;
235155
236156
@@ -254,18 +174,17 @@ void checkEmpty() {
254174 "(?:^|\\ s|;)void\\ ssetup\\ s*\\ (" ;
255175
256176
177+ // Can't only match any 'public class', needs to be a PApplet
178+ // http://code.google.com/p/processing/issues/detail?id=551
257179 static private final Pattern PUBLIC_CLASS =
258180 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);
262181
263182
264183 private static final Pattern FUNCTION_DECL =
265184 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 );
269188
270189
271190 public PdePreprocessor (final String sketchName ) {
@@ -281,16 +200,8 @@ public PdePreprocessor(final String sketchName, final int tabSize) {
281200 }
282201
283202
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 {
294205 sizeInfo = parseSketchSize (code , sizeWarning );
295206 return sizeInfo ;
296207 }
@@ -430,6 +341,20 @@ make sure that it uses numbers (or displayWidth/Height), copy into settings
430341 return info ;
431342 //return new String[] { contents[0], width, height, renderer, path };
432343 }
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+
433358 // not an error, just no size() specified
434359 //return new String[] { null, null, null, null, null };
435360 return new SizeInfo ();
0 commit comments