From ff10337321018ad48172f8954827043ae56608d6 Mon Sep 17 00:00:00 2001 From: JeffBobbo Date: Wed, 24 Sep 2014 19:18:33 +0100 Subject: [PATCH] Added preproc.generate.prototypes preference setting to disable the generation of function prototypes (also done some cleanup) - Issues: 2304, 992 and 386 (workaround) --- .../processing/app/preproc/PdePreprocessor.java | 17 +++++++---------- build/shared/lib/preferences.txt | 5 ++++- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/src/processing/app/preproc/PdePreprocessor.java b/app/src/processing/app/preproc/PdePreprocessor.java index 5cb0e57e817..d29ca36de22 100644 --- a/app/src/processing/app/preproc/PdePreprocessor.java +++ b/app/src/processing/app/preproc/PdePreprocessor.java @@ -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 prototypes; + ArrayList 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 programImports; + ArrayList programImports; // imports just from the code folder, treated differently // than the others, since the imports are auto-generated. - List codeFolderImports; + ArrayList codeFolderImports; String indent; @@ -78,6 +75,7 @@ public PdePreprocessor() { char[] indentChars = new char[tabSize]; Arrays.fill(indentChars, ' '); indent = new String(indentChars); + prototypes = new ArrayList(); } /** @@ -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; @@ -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(); } diff --git a/build/shared/lib/preferences.txt b/build/shared/lib/preferences.txt index f9bac321b33..ac5b9410e71 100755 --- a/build/shared/lib/preferences.txt +++ b/build/shared/lib/preferences.txt @@ -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 @@ -262,4 +265,4 @@ serial.debug_rate=9600 # I18 Preferences # default chosen language (none for none) -editor.languages.current = \ No newline at end of file +editor.languages.current =