Skip to content

Commit 9c9e408

Browse files
author
Mark Sproul
committed
Merge branch 'master' of http://github.com/arduino/Arduino
2 parents 9901d40 + b248953 commit 9c9e408

File tree

8 files changed

+89
-77
lines changed

8 files changed

+89
-77
lines changed

app/build.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
excludes="**/tools/format/**"
4444
encoding="UTF-8"
4545
includeAntRuntime="false"
46-
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" />
46+
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" />
4747
</target>
4848

4949
<target name="build" depends="compile" description="Build PDE">

app/lib/oro.jar

-26.1 KB
Binary file not shown.

app/src/processing/app/preproc/PdePreprocessor.java

Lines changed: 54 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Processing version Copyright (c) 2004-05 Ben Fry and Casey Reas
3535
import java.io.*;
3636
import java.util.*;
3737

38-
import com.oroinc.text.regex.*;
38+
import java.util.regex.*;
3939

4040

4141
/**
@@ -49,16 +49,17 @@ public class PdePreprocessor {
4949
// we always write one header: WProgram.h
5050
public int headerCount = 1;
5151

52-
List prototypes;
52+
// the prototypes that are generated by the preprocessor
53+
List<String> prototypes;
5354

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

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

6364
String indent;
6465

@@ -79,6 +80,14 @@ public PdePreprocessor() {
7980
indent = new String(indentChars);
8081
}
8182

83+
/**
84+
* Writes out the head of the c++ code generated for a sketch.
85+
* Called from processing.app.Sketch.
86+
* @param program the concatenated code from all tabs containing pde-files
87+
* @param buildPath the path into which the processed pde-code is to be written
88+
* @param name the name of the sketch
89+
* @param codeFolderPackages unused param (leftover from processing)
90+
*/
8291
public int writePrefix(String program, String buildPath,
8392
String sketchName, String codeFolderPackages[]) throws FileNotFoundException {
8493
this.buildPath = buildPath;
@@ -93,7 +102,7 @@ public int writePrefix(String program, String buildPath,
93102
// an OutOfMemoryError or NullPointerException will happen.
94103
// again, not gonna bother tracking this down, but here's a hack.
95104
// http://dev.processing.org/bugs/show_bug.cgi?id=16
96-
String scrubbed = Sketch.scrubComments(program);
105+
Sketch.scrubComments(program);
97106
// If there are errors, an exception is thrown and this fxn exits.
98107

99108
if (Preferences.getBoolean("preproc.substitute_unicode")) {
@@ -117,14 +126,7 @@ public int writePrefix(String program, String buildPath,
117126
// }
118127
// }
119128

120-
prototypes = new ArrayList();
121-
122-
try {
123-
prototypes = prototypes(program);
124-
} catch (MalformedPatternException e) {
125-
System.out.println("Internal error while pre-processing; " +
126-
"not generating function prototypes.\n\n" + e);
127-
}
129+
prototypes = prototypes(program);
128130

129131
// store # of prototypes so that line number reporting can be adjusted
130132
prototypeCount = prototypes.size();
@@ -193,7 +195,7 @@ public String write() throws java.lang.Exception {
193195
}
194196

195197
// Write the pde program to the cpp file
196-
protected void writeProgram(PrintStream out, String program, List prototypes) {
198+
protected void writeProgram(PrintStream out, String program, List<String> prototypes) {
197199
int prototypeInsertionPoint = firstStatement(program);
198200

199201
out.print(program.substring(0, prototypeInsertionPoint));
@@ -216,7 +218,7 @@ protected void writeProgram(PrintStream out, String program, List prototypes) {
216218
protected void writeFooter(PrintStream out) throws java.lang.Exception {}
217219

218220

219-
public ArrayList<String> getExtraImports() {
221+
public List<String> getExtraImports() {
220222
return programImports;
221223
}
222224

@@ -229,31 +231,23 @@ public ArrayList<String> getExtraImports() {
229231
* or a pre-processor directive.
230232
*/
231233
public int firstStatement(String in) {
232-
PatternMatcherInput input = new PatternMatcherInput(in);
233-
PatternCompiler compiler = new Perl5Compiler();
234-
PatternMatcher matcher = new Perl5Matcher();
235-
Pattern pattern = null;
234+
// whitespace
235+
String p = "\\s+";
236236

237-
try {
238-
pattern = compiler.compile(
239-
// XXX: doesn't properly handle special single-quoted characters
240-
// whitespace
241-
"\\s+" + "|" +
242-
// multi-line comment
243-
"(/\\*[^*]*(?:\\*(?!/)[^*]*)*\\*/)" + "|" +
244-
// single-line comment
245-
"(//.*?$)" + "|" +
246-
// pre-processor directive
247-
"(#(?:\\\\\\n|.)*)",
248-
Perl5Compiler.MULTILINE_MASK);
249-
} catch (MalformedPatternException e) {
250-
throw new RuntimeException("Internal error in firstStatement()", e);
251-
}
237+
// multi-line and single-line comment
238+
//p += "|" + "(//\\s*?$)|(/\\*\\s*?\\*/)";
239+
p += "|(/\\*[^*]*(?:\\*(?!/)[^*]*)*\\*/)|(//.*?$)";
240+
241+
// pre-processor directive
242+
p += "|(#(?:\\\\\\n|.)*)";
243+
Pattern pattern = Pattern.compile(p, Pattern.MULTILINE);
252244

245+
Matcher matcher = pattern.matcher(in);
253246
int i = 0;
254-
while (matcher.matchesPrefix(input, pattern)) {
255-
i = matcher.getMatch().endOffset(0);
256-
input.setCurrentOffset(i);
247+
while (matcher.find()) {
248+
if (matcher.start()!=i)
249+
break;
250+
i = matcher.end();
257251
}
258252

259253
return i;
@@ -265,31 +259,24 @@ public int firstStatement(String in) {
265259
* @param in the String to strip
266260
* @return the stripped String
267261
*/
268-
public String strip(String in) throws MalformedPatternException {
269-
PatternCompiler compiler = new Perl5Compiler();
270-
PatternMatcher matcher = new Perl5Matcher();
271-
Pattern pattern = compiler.compile(
272-
// XXX: doesn't properly handle special single-quoted characters
273-
// single-quoted character
274-
"('.')" + "|" +
275-
// double-quoted string
276-
"(\"(?:[^\"\\\\]|\\\\.)*\")" + "|" +
277-
// multi-line comment
278-
"(/\\*[^*]*(?:\\*(?!/)[^*]*)*\\*/)" + "|" +
279-
// single-line comment
280-
"(//.*?$)" + "|" +
281-
// pre-processor directive
282-
"(^\\s*#.*?$)",
283-
Perl5Compiler.MULTILINE_MASK);
284-
285-
while (matcher.contains(in, pattern)) {
286-
MatchResult result = matcher.getMatch();
287-
// XXX: should preserve newlines in the result so that line numbers of
288-
// the stripped string correspond to those in the original source.
289-
in = in.substring(0, result.beginOffset(0)) + " " + in.substring(result.endOffset(0));
290-
}
262+
public String strip(String in) {
263+
// XXX: doesn't properly handle special single-quoted characters
264+
// single-quoted character
265+
String p = "('.')";
266+
267+
// double-quoted string
268+
p += "|(\"(?:[^\"\\\\]|\\\\.)*\")";
291269

292-
return in;
270+
// single and multi-line comment
271+
//p += "|" + "(//\\s*?$)|(/\\*\\s*?\\*/)";
272+
p += "|(//.*?$)|(/\\*[^*]*(?:\\*(?!/)[^*]*)*\\*/)";
273+
274+
// pre-processor directive
275+
p += "|" + "(^\\s*#.*?$)";
276+
277+
Pattern pattern = Pattern.compile(p, Pattern.MULTILINE);
278+
Matcher matcher = pattern.matcher(in);
279+
return matcher.replaceAll(" ");
293280
}
294281

295282
/**
@@ -324,21 +311,17 @@ private String collapseBraces(String in) {
324311
return buffer.toString();
325312
}
326313

327-
public List prototypes(String in) throws MalformedPatternException {
314+
public ArrayList<String> prototypes(String in) {
328315
in = collapseBraces(strip(in));
329316

330-
PatternMatcherInput input = new PatternMatcherInput(in);
331-
PatternCompiler compiler = new Perl5Compiler();
332-
PatternMatcher matcher = new Perl5Matcher();
333317
// XXX: doesn't handle ... varargs
334318
// XXX: doesn't handle function pointers
335-
Pattern pattern = compiler.compile(
336-
"[\\w\\[\\]\\*]+\\s+[\\[\\]\\*\\w\\s]+\\([,\\[\\]\\*\\w\\s]*\\)(?=\\s*\\{)");
337-
List matches = new ArrayList();
319+
Pattern pattern = Pattern.compile("[\\w\\[\\]\\*]+\\s+[&\\[\\]\\*\\w\\s]+\\([&,\\[\\]\\*\\w\\s]*\\)(?=\\s*\\{)");
338320

339-
while (matcher.contains(input, pattern)) {
340-
matches.add(matcher.getMatch().group(0) + ";");
341-
}
321+
ArrayList<String> matches = new ArrayList<String>();
322+
Matcher matcher = pattern.matcher(in);
323+
while (matcher.find())
324+
matches.add(matcher.group(0) + ";");
342325

343326
return matches;
344327
}

build/build.xml

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
<include name="app/pde.jar" />
2020
<include name="app/lib/ecj.jar" />
2121
<include name="app/lib/jna.jar" />
22-
<include name="app/lib/oro.jar" />
2322
<include name="app/lib/RXTXcomm.jar" />
2423
<include name="app/lib/ant.jar" />
2524
<include name="app/lib/ant-launcher.jar" />
@@ -472,7 +471,39 @@
472471
</echo>
473472
</target>
474473

474+
475+
<!-- - - - - - - - -->
476+
<!-- Source -->
477+
<!-- - - - - - - - -->
478+
479+
<target name="source-dist" depends="revision-check"
480+
description="Build .tar.gz of source code">
481+
<input message="Enter version number:"
482+
addproperty="version"
483+
defaultvalue="${revision}" />
484+
485+
<tar compression="gzip" destfile="arduino-${version}-src.tar.gz">
486+
<tarfileset dir="../"
487+
prefix="arduino-${version}"
488+
excludes="**/*.tgz,
489+
**/macosx/,
490+
**/windows/,
491+
**/work/,
492+
**/.git/,
493+
**/*.class"
494+
/>
495+
</tar>
496+
497+
<echo>
498+
=======================================================
499+
Arduino source distribution was built. Grab the archive from
500+
501+
arduino-${version}-src.tar.gz
502+
=======================================================
503+
</echo>
504+
</target>
475505

506+
476507
<!-- - - - - - - - -->
477508
<!-- Run It! -->
478509
<!-- - - - - - - - -->

build/macosx/template.app/Contents/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
<!-- In 0149, removed /System/Library/Java from the CLASSPATH because
7373
it can cause problems if users have installed weird files there.
7474
http://dev.processing.org/bugs/show_bug.cgi?id=1045 -->
75-
<string>$JAVAROOT/pde.jar:$JAVAROOT/core.jar:$JAVAROOT/antlr.jar:$JAVAROOT/ecj.jar:$JAVAROOT/registry.jar:$JAVAROOT/quaqua.jar:$JAVAROOT/oro.jar:$JAVAROOT/RXTXcomm.jar</string>
75+
<string>$JAVAROOT/pde.jar:$JAVAROOT/core.jar:$JAVAROOT/antlr.jar:$JAVAROOT/ecj.jar:$JAVAROOT/registry.jar:$JAVAROOT/quaqua.jar:$JAVAROOT/RXTXcomm.jar</string>
7676

7777
<key>JVMArchs</key>
7878
<array>

build/windows/launcher/config.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
<cp>lib/core.jar</cp>
2020
<cp>lib/jna.jar</cp>
2121
<cp>lib/ecj.jar</cp>
22-
<cp>lib/oro.jar</cp>
2322
<cp>lib/RXTXcomm.jar</cp>
2423
</classPath>
2524
<jre>

libraries/SPI/SPI.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,6 @@ void SPIClass::setDataMode(uint8_t mode)
5656
void SPIClass::setClockDivider(uint8_t rate)
5757
{
5858
SPCR = (SPCR & ~SPI_CLOCK_MASK) | (rate & SPI_CLOCK_MASK);
59-
SPSR = (SPSR & ~SPI_2XCLOCK_MASK) | (rate & SPI_2XCLOCK_MASK);
59+
SPSR = (SPSR & ~SPI_2XCLOCK_MASK) | ((rate >> 2) & SPI_2XCLOCK_MASK);
6060
}
6161

todo.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ Sketch.java
105105
PreProcessor.java
106106
- split write() into writeHeader() and write() as in Processing?
107107
- add getExtraImports() function instead of having Sketch grab them directly.
108-
- don't use oro.jar
109108

110109
Base.java
111110
- add keywords from libraries to the syntax coloring

0 commit comments

Comments
 (0)