Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preference for toggling preprocessor prototype generation #2324

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions app/src/processing/app/preproc/PdePreprocessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,24 +42,21 @@ Processing version Copyright (c) 2004-05 Ben Fry and Casey Reas
* Class that orchestrates preprocessing p5 syntax into straight Java.
*/
public class PdePreprocessor {
// stores number of built user-defined function prototypes
public int prototypeCount = 0;

// stores number of included library headers written
// we always write one header: Arduino.h
public int headerCount = 1;

// the prototypes that are generated by the preprocessor
List<String> prototypes;
ArrayList<String> prototypes;

// these ones have the .* at the end, since a class name might be at the end
// instead of .* which would make trouble other classes using this can lop
// off the . and anything after it to produce a package name consistently.
List<String> programImports;
ArrayList<String> programImports;

// imports just from the code folder, treated differently
// than the others, since the imports are auto-generated.
List<String> codeFolderImports;
ArrayList<String> codeFolderImports;

String indent;

Expand All @@ -78,6 +75,7 @@ public PdePreprocessor() {
char[] indentChars = new char[tabSize];
Arrays.fill(indentChars, ' ');
indent = new String(indentChars);
prototypes = new ArrayList<String>();
}

/**
Expand Down Expand Up @@ -126,10 +124,9 @@ public int writePrefix(String program, String buildPath,
// }
// }

prototypes = prototypes(program);
if (Preferences.getBoolean("preproc.generate.prototypes"))
prototypes = prototypes(program);

// store # of prototypes so that line number reporting can be adjusted
prototypeCount = prototypes.size();

// do this after the program gets re-combobulated
this.program = program;
Expand All @@ -138,7 +135,7 @@ public int writePrefix(String program, String buildPath,
File streamFile = new File(buildPath, name + ".cpp");
stream = new PrintStream(new FileOutputStream(streamFile));

return headerCount + prototypeCount;
return headerCount + prototypes.size();
}


Expand Down
5 changes: 4 additions & 1 deletion build/shared/lib/preferences.txt
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,9 @@ preproc.output_parse_tree = false
# Changed after 1.0.9 to a new name, and also includes the specific entries
preproc.imports.list = java.applet.*,java.awt.Dimension,java.awt.Frame,java.awt.event.MouseEvent,java.awt.event.KeyEvent,java.awt.event.FocusEvent,java.awt.Image,java.io.*,java.net.*,java.text.*,java.util.*,java.util.zip.*,java.util.regex.*

# Toggle preprocess features
preproc.generate.prototypes = true

# set the browser to be used on linux
browser.linux = mozilla

Expand Down Expand Up @@ -262,4 +265,4 @@ serial.debug_rate=9600
# I18 Preferences

# default chosen language (none for none)
editor.languages.current =
editor.languages.current =