mirror of
https://github.com/processing/processing4.git
synced 2026-02-13 02:20:45 +01:00
clean up some size() issues, making notes wrapping up the release
This commit is contained in:
@@ -121,8 +121,8 @@ public class JavaBuild {
|
||||
* @return null if compilation failed, main class name if not
|
||||
* @throws RunnerException
|
||||
*/
|
||||
public String build() throws SketchException {
|
||||
return build(sketch.makeTempFolder(), sketch.makeTempFolder());
|
||||
public String build(boolean sizeWarning) throws SketchException {
|
||||
return build(sketch.makeTempFolder(), sketch.makeTempFolder(), sizeWarning);
|
||||
}
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ public class JavaBuild {
|
||||
*
|
||||
* @return null if compilation failed, main class name if not
|
||||
*/
|
||||
public String build(File srcFolder, File binFolder) throws SketchException {
|
||||
public String build(File srcFolder, File binFolder, boolean sizeWarning) throws SketchException {
|
||||
this.srcFolder = srcFolder;
|
||||
this.binFolder = binFolder;
|
||||
|
||||
@@ -143,7 +143,7 @@ public class JavaBuild {
|
||||
// Base.openFolder(binFolder);
|
||||
|
||||
// run the preprocessor
|
||||
String classNameFound = preprocess(srcFolder);
|
||||
String classNameFound = preprocess(srcFolder, sizeWarning);
|
||||
|
||||
// compile the program. errors will happen as a RunnerException
|
||||
// that will bubble up to whomever called build().
|
||||
@@ -183,8 +183,8 @@ public class JavaBuild {
|
||||
// }
|
||||
|
||||
|
||||
public String preprocess(File srcFolder) throws SketchException {
|
||||
return preprocess(srcFolder, null, new PdePreprocessor(sketch.getName()));
|
||||
public String preprocess(File srcFolder, boolean sizeWarning) throws SketchException {
|
||||
return preprocess(srcFolder, null, new PdePreprocessor(sketch.getName()), sizeWarning);
|
||||
}
|
||||
|
||||
|
||||
@@ -197,7 +197,8 @@ public class JavaBuild {
|
||||
*/
|
||||
public String preprocess(File srcFolder,
|
||||
String packageName,
|
||||
PdePreprocessor preprocessor) throws SketchException {
|
||||
PdePreprocessor preprocessor,
|
||||
boolean sizeWarning) throws SketchException {
|
||||
// make sure the user isn't playing "hide the sketch folder"
|
||||
sketch.ensureExistence();
|
||||
|
||||
@@ -246,7 +247,7 @@ public class JavaBuild {
|
||||
// if this fella is OpenGL, and if so, to add the import. It's messy and
|
||||
// gross and someday we'll just always include OpenGL.
|
||||
String[] sizeInfo =
|
||||
preprocessor.initSketchSize(sketch.getMainProgram());
|
||||
preprocessor.initSketchSize(sketch.getMainProgram(), sizeWarning);
|
||||
//PdePreprocessor.parseSketchSize(sketch.getMainProgram(), false);
|
||||
if (sizeInfo != null) {
|
||||
String sketchRenderer = sizeInfo[3];
|
||||
@@ -710,7 +711,7 @@ public class JavaBuild {
|
||||
|
||||
srcFolder = sketch.makeTempFolder();
|
||||
binFolder = sketch.makeTempFolder();
|
||||
String foundName = build(srcFolder, binFolder);
|
||||
String foundName = build(srcFolder, binFolder, true);
|
||||
|
||||
// (already reported) error during export, exit this function
|
||||
if (foundName == null) return false;
|
||||
@@ -1042,7 +1043,7 @@ public class JavaBuild {
|
||||
// not redoing the compilation for each platform. In particular, though,
|
||||
// importedLibraries won't be set until the preprocessing has finished,
|
||||
// so we have to do that before the stuff below.
|
||||
String foundName = build();
|
||||
String foundName = build(true);
|
||||
|
||||
// (already reported) error during export, exit this function
|
||||
if (foundName == null) return false;
|
||||
|
||||
@@ -174,7 +174,7 @@ public class JavaMode extends Mode {
|
||||
|
||||
public Runner handleRun(Sketch sketch, RunnerListener listener) throws SketchException {
|
||||
JavaBuild build = new JavaBuild(sketch);
|
||||
String appletClassName = build.build();
|
||||
String appletClassName = build.build(false);
|
||||
if (appletClassName != null) {
|
||||
final Runner runtime = new Runner(build, listener);
|
||||
new Thread(new Runnable() {
|
||||
@@ -190,7 +190,7 @@ public class JavaMode extends Mode {
|
||||
|
||||
public Runner handlePresent(Sketch sketch, RunnerListener listener) throws SketchException {
|
||||
JavaBuild build = new JavaBuild(sketch);
|
||||
String appletClassName = build.build();
|
||||
String appletClassName = build.build(false);
|
||||
if (appletClassName != null) {
|
||||
final Runner runtime = new Runner(build, listener);
|
||||
new Thread(new Runnable() {
|
||||
|
||||
@@ -183,8 +183,8 @@ public class PdePreprocessor {
|
||||
}
|
||||
|
||||
|
||||
public String[] initSketchSize(String code) throws SketchException {
|
||||
String[] info = parseSketchSize(code, true);
|
||||
public String[] initSketchSize(String code, boolean sizeWarning) throws SketchException {
|
||||
String[] info = parseSketchSize(code, sizeWarning);
|
||||
if (info != null) {
|
||||
sizeStatement = info[0];
|
||||
sketchWidth = info[1];
|
||||
@@ -249,8 +249,11 @@ public class PdePreprocessor {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Remove additional space 'round the renderer
|
||||
matches[3] = matches[3].trim();
|
||||
|
||||
// if the renderer entry is empty, set it to null
|
||||
if (matches[3].trim().length() == 0) {
|
||||
if (matches[3].length() == 0) {
|
||||
matches[3] = null;
|
||||
}
|
||||
return matches;
|
||||
@@ -832,13 +835,25 @@ public class PdePreprocessor {
|
||||
|
||||
if ((mode == Mode.STATIC) || (mode == Mode.ACTIVE)) {
|
||||
if (sketchWidth != null && !hasMethod("sketchWidth")) {
|
||||
out.println(indent + "public int sketchWidth() { return " + sketchWidth + "; }");
|
||||
// Only include if it's a number (a variable will be a problem)
|
||||
if (PApplet.parseInt(sketchWidth, -1) != -1 || sketchWidth.equals("displayWidth")) {
|
||||
out.println(indent + "public int sketchWidth() { return " + sketchWidth + "; }");
|
||||
}
|
||||
}
|
||||
if (sketchHeight != null && !hasMethod("sketchHeight")) {
|
||||
out.println(indent + "public int sketchHeight() { return " + sketchHeight + "; }");
|
||||
// Only include if it's a number
|
||||
if (PApplet.parseInt(sketchHeight, -1) != -1 || sketchHeight.equals("displayHeight")) {
|
||||
out.println(indent + "public int sketchHeight() { return " + sketchHeight + "; }");
|
||||
}
|
||||
}
|
||||
if (sketchRenderer != null && !hasMethod("sketchRenderer")) {
|
||||
out.println(indent + "public String sketchRenderer() { return " + sketchRenderer + "; }");
|
||||
// Only include if it's a known renderer (otherwise it might be a variable)
|
||||
if (sketchRenderer.equals("P2D") ||
|
||||
sketchRenderer.equals("P3D") ||
|
||||
sketchRenderer.equals("OPENGL") ||
|
||||
sketchRenderer.equals("JAVA2D")) {
|
||||
out.println(indent + "public String sketchRenderer() { return " + sketchRenderer + "; }");
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasMethod("main")) {
|
||||
|
||||
Reference in New Issue
Block a user