change up how extra statements from size() are handled (fixes #3531)

This commit is contained in:
Ben Fry
2015-08-05 08:33:34 -04:00
parent 5315c6c869
commit 98a5650fc3
5 changed files with 94 additions and 36 deletions
+19 -12
View File
@@ -8,6 +8,7 @@ X fix problem with JAR loading inside createInputRaw()
o https://github.com/processing/processing/pull/3514
_ are we clear on sketchPath() for OS X?
_ working dir (user.dir?) returns home dir, not app dir in Oracle Java
_ could add -Dapp.root=$APP_ROOT and get via System.getProperty("app.root")
jakub
X Remove size() from setup() when copying to settings()
@@ -23,6 +24,22 @@ X https://github.com/processing/processing/issues/3473
X https://github.com/processing/processing/pull/3521
X size() errors
X https://github.com/processing/processing/issues/3483
X improve hint(ENABLE_DEPTH_SORT) to use proper painter's algo
X https://github.com/processing/processing/issues/90
X also for begin/endRaw:
X https://github.com/processing/processing/issues/2235
X polygon z-order depth sorting with alpha in opengl
X complete the implementation of hint() with proper implementation
X gl alpha on images when flipped around backwards
X will sorting based on depth help this? also ask simon for ideas
X need to merge sorting/drawing of lines and triangles
X lines will occlude tris and vice versa
X will need to split each based on the other
X sort issues will affect both
X https://github.com/processing/processing/pull/3507
X https://github.com/processing/processing/pull/3477
X https://github.com/processing/processing/pull/3410
X https://github.com/processing/processing/pull/3372
opengl
X ArrayIndexOutOfBoundsException error when enabling depth sorting in P3D
@@ -42,6 +59,7 @@ X Depth sorting wrong when drawing inside setup(), P3D
X can no longer be reproduced
X https://github.com/processing/processing/issues/2483
docs
_ note that full screen and present are now different
_ on Export to Application, this has an impact
@@ -82,6 +100,7 @@ _ or is Canvas specific to the PGraphics, and we get another Context2D?
_ http://docs.oracle.com/javafx/2/api/javafx/scene/canvas/Canvas.html
_ loadPixels() (also 2x)
_ text and fonts?
_ maybe helpful: https://wiki.openjdk.java.net/display/OpenJFX/Font+Setup
_ updatePixels()
_ save() and saveFrame()
_ get() and set()
@@ -623,18 +642,6 @@ _ Disabling Aero scheme sometimes prevents the problem
_ Updating graphics drivers may prevent the problem
_ ellipse scaling method isn't great
_ http://code.google.com/p/processing/issues/detail?id=87
_ improve hint(ENABLE_DEPTH_SORT) to use proper painter's algo
_ https://github.com/processing/processing/issues/90
_ for begin/endRaw: https://github.com/processing/processing/issues/2235
_ http://code.google.com/p/processing/issues/detail?id=51
_ polygon z-order depth sorting with alpha in opengl
_ complete the implementation of hint() with proper implementation
_ gl alpha on images when flipped around backwards
_ will sorting based on depth help this? also ask simon for ideas
_ need to merge sorting/drawing of lines and triangles
_ lines will occlude tris and vice versa
_ will need to split each based on the other
_ sort issues will affect both
_ Stroking a rect() leaves off the upper right pixel
_ http://code.google.com/p/processing/issues/detail?id=67
_ Signature issue on contributed libraries affects unrelated opengl sketches
+15 -6
View File
@@ -257,13 +257,22 @@ public class JavaBuild {
return null;
}
//System.out.format("size() is '%s'%n", info[0]);
// Remove the size() statement (will be added back by writeFooter())
// Remove the entries being moved to settings(). They will be re-inserted
// by writeFooter() when it emits the settings() method.
if (sizeInfo != null) {
String sizeStatement = sizeInfo.getStatement();
if (sizeStatement != null) {
int index = bigCode.indexOf(sizeStatement);
bigCode.delete(index, index + sizeStatement.length());
// String sizeStatement = sizeInfo.getStatement();
for (String stmt : sizeInfo.getStatements()) {
// if (sizeStatement != null) {
//System.out.format("size stmt is '%s'%n", sizeStatement);
int index = bigCode.indexOf(stmt);
if (index != -1) {
bigCode.delete(index, index + stmt.length());
} else {
// TODO remove once we hit final; but prevent an exception like in
// https://github.com/processing/processing/issues/3531
System.err.format("Error removing '%s' from the code.", stmt);
}
}
}
@@ -357,7 +357,8 @@ public class PdePreprocessor {
if (sizeContents != null) {
StringList args = breakCommas(sizeContents[1]);
SurfaceInfo info = new SurfaceInfo();
info.statement = sizeContents[0];
// info.statement = sizeContents[0];
info.addStatement(sizeContents[0]);
info.width = args.get(0).trim();
info.height = args.get(1).trim();
info.renderer = (args.size() >= 3) ? args.get(2).trim() : null;
@@ -384,9 +385,7 @@ public class PdePreprocessor {
throw new SketchException("Please fix the size() line to continue.", false);
}
if (extraStatements.size() != 0) {
info.statement += extraStatements.join(" ");
}
info.addStatements(extraStatements);
info.checkEmpty();
return info;
//return new String[] { contents[0], width, height, renderer, path };
@@ -395,7 +394,8 @@ public class PdePreprocessor {
//contents = PApplet.match(searchArea, FULL_SCREEN_CONTENTS_REGEX);
if (fullContents != null) {
SurfaceInfo info = new SurfaceInfo();
info.statement = fullContents[0];
// info.statement = fullContents[0];
info.addStatement(fullContents[0]);
StringList args = breakCommas(fullContents[1]);
if (args.size() > 0) { // might have no args
String args0 = args.get(0).trim();
@@ -416,9 +416,10 @@ public class PdePreprocessor {
}
info.width = "displayWidth";
info.height = "displayHeight";
if (extraStatements.size() != 0) {
info.statement += extraStatements.join(" ");
}
// if (extraStatements.size() != 0) {
// info.statement += extraStatements.join(" ");
// }
info.addStatements(extraStatements);
info.checkEmpty();
return info;
}
@@ -427,7 +428,8 @@ public class PdePreprocessor {
// need to pull out the noSmooth() and smooth(N) methods.
if (extraStatements.size() != 0) {
SurfaceInfo info = new SurfaceInfo();
info.statement = extraStatements.join(" ");
// info.statement = extraStatements.join(" ");
info.addStatements(extraStatements);
return info;
}
@@ -1094,10 +1096,10 @@ public class PdePreprocessor {
}
if ((mode == Mode.STATIC) || (mode == Mode.ACTIVE)) {
// doesn't remove the oriiginal size() method, but calling size()
// doesn't remove the original size() method, but calling size()
// again in setup() is harmless.
if (!hasMethod("settings") && sizeInfo.statement != null) {
out.println(indent + "public void settings() { " + sizeInfo.statement + " }");
if (!hasMethod("settings") && sizeInfo.hasSettings()) {
out.println(indent + "public void settings() { " + sizeInfo.getSettings() + " }");
// out.println(indent + "public void settings() {");
// out.println(indent + indent + sizeStatement);
// out.println(indent + "}");
@@ -25,10 +25,12 @@ package processing.mode.java.preproc;
import processing.app.Base;
import processing.core.PApplet;
import processing.data.StringList;
public class SurfaceInfo {
String statement;
// String statement;
StringList statements;
String width;
String height;
String renderer;
@@ -101,7 +103,42 @@ public class SurfaceInfo {
}
public String getStatement() {
return statement;
// public String getStatements() {
// return statements.join(" ");
// }
public StringList getStatements() {
return statements;
}
/**
* Add an item that will be moved from size() into the settings() method.
* This needs to be the exact version of the statement so that it can be
* matched against and removed from the size() method in the code.
*/
public void addStatement(String stmt) {
if (statements == null) {
statements = new StringList();
}
statements.append(stmt);
}
public void addStatements(StringList list) {
statements.append(list);
}
/** @return true if there's code to be inserted for a settings() method. */
public boolean hasSettings() {
return statements != null;
}
/** @return the contents of the settings() method to be inserted */
public String getSettings() {
return statements.join(" ");
}
}
+6 -3
View File
@@ -4,7 +4,8 @@ X https://github.com/processing/processing/issues/3474
X Add message that says it's safe to ignore the tools.jar warning
X add new lower console/errors icons
X dist needs to do a git pull on processing-docs
_ don't show display warning when display 1 doesn't exist
X StringIndexOutOfBoundsException while preprocessing
X https://github.com/processing/processing/issues/3531
fixed earlier
X font fixes for Georgia in the examples
@@ -28,6 +29,7 @@ X https://github.com/processing/processing/pull/3522
beta
_ don't show display warning when display 1 doesn't exist
_ try to get images working in welcome screen
_ https://github.com/processing/processing/blob/master/build/shared/lib/welcome/sketchbook.html#L60
_ https://github.com/processing/processing/issues/3494
@@ -39,11 +41,11 @@ _ Contribution Manager design is really rough
_ https://github.com/processing/processing/issues/3464
_ Ready to add contributed example packages?
_ https://github.com/processing/processing/issues/2953
_ fix the red for the console/error stuff
_ also the sidebar, the squiggly line beneath code, and the status bar
gui
_ fix the red for the console/error stuff
_ also the sidebar, the squiggly line beneath code, and the status bar
_ show hover text with 'debug'
_ inquire about updated document icon
_ don't show breakpoints when debugger is off
@@ -133,6 +135,7 @@ _ add last revision used / max revision used settings?
crashing
_ fix appbundler problems due to rollback
_ appbundler is no longer being developed by Oracle, switch to "packager"
_ this re-introduces two bugs (serial export and scrolling)
_ and any other changes later than 16 November 2015:
_ https://github.com/processing/processing/commits/master/build/macosx/appbundler.jar