diff --git a/app/build.xml b/app/build.xml index eb1c313bf20..e0f67e05879 100644 --- a/app/build.xml +++ b/app/build.xml @@ -43,7 +43,7 @@ excludes="**/tools/format/**" encoding="UTF-8" includeAntRuntime="false" - classpath="../core/core.jar; ${env.JAVA_HOME}/lib/tools.jar; lib/ant.jar; lib/ant-launcher.jar; lib/apple.jar; lib/ecj.jar; lib/jna.jar; lib/oro.jar; lib/RXTXcomm.jar" /> + classpath="../core/core.jar; ${env.JAVA_HOME}/lib/tools.jar; lib/ant.jar; lib/ant-launcher.jar; lib/apple.jar; lib/ecj.jar; lib/jna.jar; lib/RXTXcomm.jar" /> diff --git a/app/lib/oro.jar b/app/lib/oro.jar deleted file mode 100644 index 667e86cb7a8..00000000000 Binary files a/app/lib/oro.jar and /dev/null differ diff --git a/app/src/processing/app/preproc/PdePreprocessor.java b/app/src/processing/app/preproc/PdePreprocessor.java index 10b940536e6..2deaa15aa92 100644 --- a/app/src/processing/app/preproc/PdePreprocessor.java +++ b/app/src/processing/app/preproc/PdePreprocessor.java @@ -35,7 +35,7 @@ Processing version Copyright (c) 2004-05 Ben Fry and Casey Reas import java.io.*; import java.util.*; -import com.oroinc.text.regex.*; +import java.util.regex.*; /** @@ -49,16 +49,17 @@ public class PdePreprocessor { // we always write one header: WProgram.h public int headerCount = 1; - List prototypes; + // the prototypes that are generated by the preprocessor + List 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. - ArrayList programImports; + List programImports; // imports just from the code folder, treated differently // than the others, since the imports are auto-generated. - ArrayList codeFolderImports; + List codeFolderImports; String indent; @@ -79,6 +80,14 @@ public PdePreprocessor() { indent = new String(indentChars); } + /** + * Writes out the head of the c++ code generated for a sketch. + * Called from processing.app.Sketch. + * @param program the concatenated code from all tabs containing pde-files + * @param buildPath the path into which the processed pde-code is to be written + * @param name the name of the sketch + * @param codeFolderPackages unused param (leftover from processing) + */ public int writePrefix(String program, String buildPath, String sketchName, String codeFolderPackages[]) throws FileNotFoundException { this.buildPath = buildPath; @@ -93,7 +102,7 @@ public int writePrefix(String program, String buildPath, // an OutOfMemoryError or NullPointerException will happen. // again, not gonna bother tracking this down, but here's a hack. // http://dev.processing.org/bugs/show_bug.cgi?id=16 - String scrubbed = Sketch.scrubComments(program); + Sketch.scrubComments(program); // If there are errors, an exception is thrown and this fxn exits. if (Preferences.getBoolean("preproc.substitute_unicode")) { @@ -117,14 +126,7 @@ public int writePrefix(String program, String buildPath, // } // } - prototypes = new ArrayList(); - - try { - prototypes = prototypes(program); - } catch (MalformedPatternException e) { - System.out.println("Internal error while pre-processing; " + - "not generating function prototypes.\n\n" + e); - } + prototypes = prototypes(program); // store # of prototypes so that line number reporting can be adjusted prototypeCount = prototypes.size(); @@ -193,7 +195,7 @@ public String write() throws java.lang.Exception { } // Write the pde program to the cpp file - protected void writeProgram(PrintStream out, String program, List prototypes) { + protected void writeProgram(PrintStream out, String program, List prototypes) { int prototypeInsertionPoint = firstStatement(program); out.print(program.substring(0, prototypeInsertionPoint)); @@ -216,7 +218,7 @@ protected void writeProgram(PrintStream out, String program, List prototypes) { protected void writeFooter(PrintStream out) throws java.lang.Exception {} - public ArrayList getExtraImports() { + public List getExtraImports() { return programImports; } @@ -229,31 +231,23 @@ public ArrayList getExtraImports() { * or a pre-processor directive. */ public int firstStatement(String in) { - PatternMatcherInput input = new PatternMatcherInput(in); - PatternCompiler compiler = new Perl5Compiler(); - PatternMatcher matcher = new Perl5Matcher(); - Pattern pattern = null; + // whitespace + String p = "\\s+"; - try { - pattern = compiler.compile( - // XXX: doesn't properly handle special single-quoted characters - // whitespace - "\\s+" + "|" + - // multi-line comment - "(/\\*[^*]*(?:\\*(?!/)[^*]*)*\\*/)" + "|" + - // single-line comment - "(//.*?$)" + "|" + - // pre-processor directive - "(#(?:\\\\\\n|.)*)", - Perl5Compiler.MULTILINE_MASK); - } catch (MalformedPatternException e) { - throw new RuntimeException("Internal error in firstStatement()", e); - } + // multi-line and single-line comment + //p += "|" + "(//\\s*?$)|(/\\*\\s*?\\*/)"; + p += "|(/\\*[^*]*(?:\\*(?!/)[^*]*)*\\*/)|(//.*?$)"; + + // pre-processor directive + p += "|(#(?:\\\\\\n|.)*)"; + Pattern pattern = Pattern.compile(p, Pattern.MULTILINE); + Matcher matcher = pattern.matcher(in); int i = 0; - while (matcher.matchesPrefix(input, pattern)) { - i = matcher.getMatch().endOffset(0); - input.setCurrentOffset(i); + while (matcher.find()) { + if (matcher.start()!=i) + break; + i = matcher.end(); } return i; @@ -265,31 +259,24 @@ public int firstStatement(String in) { * @param in the String to strip * @return the stripped String */ - public String strip(String in) throws MalformedPatternException { - PatternCompiler compiler = new Perl5Compiler(); - PatternMatcher matcher = new Perl5Matcher(); - Pattern pattern = compiler.compile( - // XXX: doesn't properly handle special single-quoted characters - // single-quoted character - "('.')" + "|" + - // double-quoted string - "(\"(?:[^\"\\\\]|\\\\.)*\")" + "|" + - // multi-line comment - "(/\\*[^*]*(?:\\*(?!/)[^*]*)*\\*/)" + "|" + - // single-line comment - "(//.*?$)" + "|" + - // pre-processor directive - "(^\\s*#.*?$)", - Perl5Compiler.MULTILINE_MASK); - - while (matcher.contains(in, pattern)) { - MatchResult result = matcher.getMatch(); - // XXX: should preserve newlines in the result so that line numbers of - // the stripped string correspond to those in the original source. - in = in.substring(0, result.beginOffset(0)) + " " + in.substring(result.endOffset(0)); - } + public String strip(String in) { + // XXX: doesn't properly handle special single-quoted characters + // single-quoted character + String p = "('.')"; + + // double-quoted string + p += "|(\"(?:[^\"\\\\]|\\\\.)*\")"; - return in; + // single and multi-line comment + //p += "|" + "(//\\s*?$)|(/\\*\\s*?\\*/)"; + p += "|(//.*?$)|(/\\*[^*]*(?:\\*(?!/)[^*]*)*\\*/)"; + + // pre-processor directive + p += "|" + "(^\\s*#.*?$)"; + + Pattern pattern = Pattern.compile(p, Pattern.MULTILINE); + Matcher matcher = pattern.matcher(in); + return matcher.replaceAll(" "); } /** @@ -324,21 +311,17 @@ private String collapseBraces(String in) { return buffer.toString(); } - public List prototypes(String in) throws MalformedPatternException { + public ArrayList prototypes(String in) { in = collapseBraces(strip(in)); - PatternMatcherInput input = new PatternMatcherInput(in); - PatternCompiler compiler = new Perl5Compiler(); - PatternMatcher matcher = new Perl5Matcher(); // XXX: doesn't handle ... varargs // XXX: doesn't handle function pointers - Pattern pattern = compiler.compile( - "[\\w\\[\\]\\*]+\\s+[\\[\\]\\*\\w\\s]+\\([,\\[\\]\\*\\w\\s]*\\)(?=\\s*\\{)"); - List matches = new ArrayList(); + Pattern pattern = Pattern.compile("[\\w\\[\\]\\*]+\\s+[&\\[\\]\\*\\w\\s]+\\([&,\\[\\]\\*\\w\\s]*\\)(?=\\s*\\{)"); - while (matcher.contains(input, pattern)) { - matches.add(matcher.getMatch().group(0) + ";"); - } + ArrayList matches = new ArrayList(); + Matcher matcher = pattern.matcher(in); + while (matcher.find()) + matches.add(matcher.group(0) + ";"); return matches; } diff --git a/build/build.xml b/build/build.xml index 98d15985350..479cc7e1bf2 100644 --- a/build/build.xml +++ b/build/build.xml @@ -19,7 +19,6 @@ - diff --git a/build/macosx/template.app/Contents/Info.plist b/build/macosx/template.app/Contents/Info.plist index c48c547b511..19e0ff47e2e 100755 --- a/build/macosx/template.app/Contents/Info.plist +++ b/build/macosx/template.app/Contents/Info.plist @@ -72,7 +72,7 @@ - $JAVAROOT/pde.jar:$JAVAROOT/core.jar:$JAVAROOT/antlr.jar:$JAVAROOT/ecj.jar:$JAVAROOT/registry.jar:$JAVAROOT/quaqua.jar:$JAVAROOT/oro.jar:$JAVAROOT/RXTXcomm.jar + $JAVAROOT/pde.jar:$JAVAROOT/core.jar:$JAVAROOT/antlr.jar:$JAVAROOT/ecj.jar:$JAVAROOT/registry.jar:$JAVAROOT/quaqua.jar:$JAVAROOT/RXTXcomm.jar JVMArchs diff --git a/build/windows/launcher/config.xml b/build/windows/launcher/config.xml index 877e390a1e7..ba29d3a0673 100755 --- a/build/windows/launcher/config.xml +++ b/build/windows/launcher/config.xml @@ -19,7 +19,6 @@ lib/core.jar lib/jna.jar lib/ecj.jar - lib/oro.jar lib/RXTXcomm.jar diff --git a/todo.txt b/todo.txt index cc6ec46fbfa..014d099d08d 100644 --- a/todo.txt +++ b/todo.txt @@ -105,7 +105,6 @@ Sketch.java PreProcessor.java - split write() into writeHeader() and write() as in Processing? - add getExtraImports() function instead of having Sketch grab them directly. - - don't use oro.jar Base.java - add keywords from libraries to the syntax coloring pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy