From 7b7f447a4adca2ea9edcd11a1036e57c9a59450f Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Tue, 29 Oct 2013 14:57:31 +0100 Subject: [PATCH] Move the definition of primaryClassName in Sketch Instead of defining in the preprocess method and returning, just define it in the build method. This makes sure the name is available before preprocessing, which is important for the upcoming commits. This commit should not change behaviour, only prepare for the next commits. --- app/src/processing/app/Sketch.java | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/app/src/processing/app/Sketch.java b/app/src/processing/app/Sketch.java index 3376ee18a..95feb0cb5 100644 --- a/app/src/processing/app/Sketch.java +++ b/app/src/processing/app/Sketch.java @@ -1312,11 +1312,11 @@ public class Sketch { * @param buildPath Location to copy all the .java files * @return null if compilation failed, main class name if not */ - public String preprocess(String buildPath) throws RunnerException { - return preprocess(buildPath, new PdePreprocessor()); + public void preprocess(String buildPath) throws RunnerException { + preprocess(buildPath, new PdePreprocessor()); } - public String preprocess(String buildPath, PdePreprocessor preprocessor) throws RunnerException { + public void preprocess(String buildPath, PdePreprocessor preprocessor) throws RunnerException { // make sure the user didn't hide the sketch folder ensureExistence(); @@ -1372,18 +1372,12 @@ public class Sketch { // 2. run preproc on that code using the sugg class name // to create a single .java file and write to buildpath - String primaryClassName = null; - try { // Output file File streamFile = new File(buildPath, name + ".cpp"); FileOutputStream outputStream = new FileOutputStream(streamFile); preprocessor.write(outputStream); outputStream.close(); - - // store this for the compiler and the runtime - primaryClassName = name + ".cpp"; - } catch (FileNotFoundException fnfe) { fnfe.printStackTrace(); String msg = _("Build folder disappeared or could not be written"); @@ -1432,7 +1426,6 @@ public class Sketch { sc.addPreprocOffset(headerOffset); } } - return primaryClassName; } @@ -1538,7 +1531,8 @@ public class Sketch { public String build(String buildPath, boolean verbose) throws RunnerException { // run the preprocessor editor.status.progressUpdate(20); - String primaryClassName = preprocess(buildPath); + String primaryClassName = name + ".cpp"; + preprocess(buildPath); // compile the program. errors will happen as a RunnerException // that will bubble up to whomever called build().