Skip to content

Commit 7b7f447

Browse files
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.
1 parent beac88e commit 7b7f447

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

app/src/processing/app/Sketch.java

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1312,11 +1312,11 @@ public void prepare() throws IOException {
13121312
* @param buildPath Location to copy all the .java files
13131313
* @return null if compilation failed, main class name if not
13141314
*/
1315-
public String preprocess(String buildPath) throws RunnerException {
1316-
return preprocess(buildPath, new PdePreprocessor());
1315+
public void preprocess(String buildPath) throws RunnerException {
1316+
preprocess(buildPath, new PdePreprocessor());
13171317
}
13181318

1319-
public String preprocess(String buildPath, PdePreprocessor preprocessor) throws RunnerException {
1319+
public void preprocess(String buildPath, PdePreprocessor preprocessor) throws RunnerException {
13201320
// make sure the user didn't hide the sketch folder
13211321
ensureExistence();
13221322

@@ -1372,18 +1372,12 @@ public String preprocess(String buildPath, PdePreprocessor preprocessor) throws
13721372
// 2. run preproc on that code using the sugg class name
13731373
// to create a single .java file and write to buildpath
13741374

1375-
String primaryClassName = null;
1376-
13771375
try {
13781376
// Output file
13791377
File streamFile = new File(buildPath, name + ".cpp");
13801378
FileOutputStream outputStream = new FileOutputStream(streamFile);
13811379
preprocessor.write(outputStream);
13821380
outputStream.close();
1383-
1384-
// store this for the compiler and the runtime
1385-
primaryClassName = name + ".cpp";
1386-
13871381
} catch (FileNotFoundException fnfe) {
13881382
fnfe.printStackTrace();
13891383
String msg = _("Build folder disappeared or could not be written");
@@ -1432,7 +1426,6 @@ public String preprocess(String buildPath, PdePreprocessor preprocessor) throws
14321426
sc.addPreprocOffset(headerOffset);
14331427
}
14341428
}
1435-
return primaryClassName;
14361429
}
14371430

14381431

@@ -1538,7 +1531,8 @@ public String build(boolean verbose) throws RunnerException {
15381531
public String build(String buildPath, boolean verbose) throws RunnerException {
15391532
// run the preprocessor
15401533
editor.status.progressUpdate(20);
1541-
String primaryClassName = preprocess(buildPath);
1534+
String primaryClassName = name + ".cpp";
1535+
preprocess(buildPath);
15421536

15431537
// compile the program. errors will happen as a RunnerException
15441538
// that will bubble up to whomever called build().

0 commit comments

Comments
 (0)