@@ -208,9 +208,11 @@ public PdePreprocessor(final String sketchName, final int tabSize) {
208208 }
209209
210210
211+ /** Parse the sketch size and set the internal sizeInfo variable */
211212 public SurfaceInfo initSketchSize (String code ,
212- boolean sizeWarning ) throws SketchException {
213- return parseSketchSize (code , sizeWarning );
213+ boolean sizeWarning ) throws SketchException {
214+ sizeInfo = parseSketchSize (code , sizeWarning );
215+ return sizeInfo ;
214216 }
215217
216218
@@ -422,9 +424,6 @@ static public SurfaceInfo parseSketchSize(String code,
422424 }
423425 info .width = "displayWidth" ;
424426 info .height = "displayHeight" ;
425- // if (extraStatements.size() != 0) {
426- // info.statement += extraStatements.join(" ");
427- // }
428427 info .addStatements (extraStatements );
429428 info .checkEmpty ();
430429 return info ;
@@ -434,71 +433,21 @@ static public SurfaceInfo parseSketchSize(String code,
434433 // need to pull out the noSmooth() and smooth(N) methods.
435434 if (extraStatements .size () != 0 ) {
436435 SurfaceInfo info = new SurfaceInfo ();
437- // info.statement = extraStatements.join(" ");
438436 info .addStatements (extraStatements );
439437 return info ;
440438 }
441439
442440 // not an error, just no size() specified
443- //return new String[] { null, null, null, null, null };
444441 return new SurfaceInfo ();
445442 }
446443
447- /*
448- static String readSingleQuote(char[] c, int i) {
449- StringBuilder sb = new StringBuilder();
450- try {
451- sb.append(c[i++]); // add the quote
452- if (c[i] == '\\') {
453- sb.append(c[i++]); // add the escape
454- if (c[i] == 'u') {
455- // grabs uNNN and the fourth N will be added below
456- for (int j = 0; j < 4; j++) {
457- sb.append(c[i++]);
458- }
459- }
460- }
461- sb.append(c[i++]); // get the char, escapee, or last unicode digit
462- sb.append(c[i++]); // get the closing quote
463-
464- } catch (ArrayIndexOutOfBoundsException ignored) {
465- // this means they have bigger problems with their code
466- }
467- return sb.toString();
468- }
469-
470-
471- static String readDoubleQuote(char[] c, int i) {
472- StringBuilder sb = new StringBuilder();
473- try {
474- sb.append(c[i++]); // add the quote
475- while (i < c.length) {
476- if (c[i] == '\\') {
477- sb.append(c[i++]); // add the escape
478- sb.append(c[i++]); // add whatever was escaped
479- } else if (c[i] == '\"') {
480- sb.append(c[i++]);
481- break;
482- } else {
483- sb.append(c[i++]);
484- }
485- }
486- } catch (ArrayIndexOutOfBoundsException ignored) {
487- // this means they have bigger problems with their code
488- }
489- return sb.toString();
490- }
491- */
492-
493444
494445 /**
495446 * Parses the code and determines the mode of the sketch.
496- *
497447 * @param code code without comments
498448 * @return determined mode
499449 */
500450 static public Mode parseMode (CharSequence code ) {
501-
502451 // See if we can find any function in the global scope
503452 if (findInCurrentScope (FUNCTION_DECL , code ) != null ) {
504453 return Mode .ACTIVE ;
@@ -1230,8 +1179,7 @@ protected void writeFooter(PrintWriter out, String className) {
12301179 if ((mode == Mode .STATIC ) || (mode == Mode .ACTIVE )) {
12311180 // doesn't remove the original size() method,
12321181 // but calling size() again in setup() is harmless.
1233- if (!hasMethod ("settings" ) &&
1234- sizeInfo != null && sizeInfo .hasSettings ()) {
1182+ if (!hasMethod ("settings" ) && sizeInfo .hasSettings ()) {
12351183 out .println (indent + "public void settings() { " + sizeInfo .getSettings () + " }" );
12361184 }
12371185
0 commit comments