Skip to content

Commit aba27c4

Browse files
committed
Merged upstream arduino branch
2 parents e8ea12c + 9a13d21 commit aba27c4

File tree

364 files changed

+153091
-105
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

364 files changed

+153091
-105
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ hardware/arduino/bootloaders/caterina_LUFA/Caterina.elf
1414
hardware/arduino/bootloaders/caterina_LUFA/Caterina.eep
1515
hardware/arduino/bootloaders/caterina_LUFA/.dep/
1616
.gitignore
17-
build/windows/work/
17+
build/windows/work/
18+
build/linux/work/

app/src/processing/app/Editor.java

+60-27
Original file line numberDiff line numberDiff line change
@@ -1095,9 +1095,10 @@ public void actionPerformed(ActionEvent e) {
10951095
item = newJMenuItemShift(_("Find in Reference"), 'F');
10961096
item.addActionListener(new ActionListener() {
10971097
public void actionPerformed(ActionEvent e) {
1098-
if (textarea.isSelectionActive()) {
1099-
handleFindReference();
1100-
}
1098+
// if (textarea.isSelectionActive()) {
1099+
// handleFindReference();
1100+
// }
1101+
handleFindReference();
11011102
}
11021103
});
11031104
menu.add(item);
@@ -1830,25 +1831,58 @@ protected void handleIndentOutdent(boolean indent) {
18301831
stopCompoundEdit();
18311832
}
18321833

1833-
1834-
protected void handleFindReference() {
1835-
String text = textarea.getSelectedText().trim();
1836-
1837-
if (text.length() == 0) {
1838-
statusNotice(_("First select a word to find in the reference."));
1839-
1840-
} else {
1841-
String referenceFile = PdeKeywords.getReference(text);
1842-
//System.out.println("reference file is " + referenceFile);
1843-
if (referenceFile == null) {
1844-
statusNotice(
1845-
I18n.format(_("No reference available for \"{0}\""), text)
1846-
);
1847-
} else {
1848-
Base.showReference(I18n.format(_("{0}.html"), referenceFile));
1849-
}
1850-
}
1851-
}
1834+
protected String getCurrentKeyword() {
1835+
String text = "";
1836+
if (textarea.getSelectedText() != null)
1837+
text = textarea.getSelectedText().trim();
1838+
1839+
try {
1840+
int current = textarea.getCaretPosition();
1841+
int startOffset = 0;
1842+
int endIndex = current;
1843+
String tmp = textarea.getDocument().getText(current, 1);
1844+
// TODO probably a regexp that matches Arduino lang special chars
1845+
// already exists.
1846+
String regexp = "[\\s\\n();\\\\.!='\\[\\]{}]";
1847+
1848+
while (!tmp.matches(regexp)) {
1849+
endIndex++;
1850+
tmp = textarea.getDocument().getText(endIndex, 1);
1851+
}
1852+
// For some reason document index start at 2.
1853+
// if( current - start < 2 ) return;
1854+
1855+
tmp = "";
1856+
while (!tmp.matches(regexp)) {
1857+
startOffset++;
1858+
if (current - startOffset < 0) {
1859+
tmp = textarea.getDocument().getText(0, 1);
1860+
break;
1861+
} else
1862+
tmp = textarea.getDocument().getText(current - startOffset, 1);
1863+
}
1864+
startOffset--;
1865+
1866+
int length = endIndex - current + startOffset;
1867+
text = textarea.getDocument().getText(current - startOffset, length);
1868+
1869+
} catch (BadLocationException bl) {
1870+
bl.printStackTrace();
1871+
} finally {
1872+
return text;
1873+
}
1874+
}
1875+
1876+
protected void handleFindReference() {
1877+
String text = getCurrentKeyword();
1878+
1879+
String referenceFile = PdeKeywords.getReference(text);
1880+
if (referenceFile == null) {
1881+
statusNotice(I18n.format(_("No reference available for \"{0}\""), text));
1882+
} else {
1883+
Base.showReference(I18n.format(_("{0}.html"), referenceFile));
1884+
}
1885+
}
18521886

18531887

18541888
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
@@ -2775,16 +2809,15 @@ public void show(Component component, int x, int y) {
27752809
copyItem.setEnabled(true);
27762810
discourseItem.setEnabled(true);
27772811

2778-
String sel = textarea.getSelectedText().trim();
2779-
referenceFile = PdeKeywords.getReference(sel);
2780-
referenceItem.setEnabled(referenceFile != null);
2781-
27822812
} else {
27832813
cutItem.setEnabled(false);
27842814
copyItem.setEnabled(false);
27852815
discourseItem.setEnabled(false);
2786-
referenceItem.setEnabled(false);
27872816
}
2817+
2818+
referenceFile = PdeKeywords.getReference(getCurrentKeyword());
2819+
referenceItem.setEnabled(referenceFile != null);
2820+
27882821
super.show(component, x, y);
27892822
}
27902823
}

app/src/processing/app/Resources_en.properties

-3
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,6 @@
178178
#: Editor.java:1255
179179
!Use\ Selection\ For\ Find=
180180

181-
#: Editor.java:1816
182-
!First\ select\ a\ word\ to\ find\ in\ the\ reference.=
183-
184181
#: Editor.java:1823
185182
#, java-format
186183
!No\ reference\ available\ for\ "{0}"=

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

+27-8
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public int writePrefix(String program, String buildPath,
110110
}
111111

112112
//String importRegexp = "(?:^|\\s|;)(import\\s+)(\\S+)(\\s*;)";
113-
String importRegexp = "^\\s*#include\\s+[<\"](\\S+)[\">]";
113+
String importRegexp = "^\\s*#include\\s*[<\"](\\S+)[\">]";
114114
programImports = new ArrayList<String>();
115115

116116
String[][] pieces = PApplet.matchAll(program, importRegexp);
@@ -205,7 +205,8 @@ protected void writeProgram(PrintStream out, String program, List<String> protot
205205
for (int i = 0; i < prototypes.size(); i++) {
206206
out.print(prototypes.get(i) + "\n");
207207
}
208-
out.println("#line 1");
208+
String[] lines = program.substring(0, prototypeInsertionPoint).split("\n", -1);
209+
out.println("#line " + (lines.length - 1));
209210
out.print(program.substring(prototypeInsertionPoint));
210211
}
211212

@@ -316,13 +317,31 @@ public ArrayList<String> prototypes(String in) {
316317

317318
// XXX: doesn't handle ... varargs
318319
// XXX: doesn't handle function pointers
319-
Pattern pattern = Pattern.compile("[\\w\\[\\]\\*]+\\s+[&\\[\\]\\*\\w\\s]+\\([&,\\[\\]\\*\\w\\s]*\\)(?=\\s*\\{)");
320+
Pattern prototypePattern = Pattern.compile("[\\w\\[\\]\\*]+\\s+[&\\[\\]\\*\\w\\s]+\\([&,\\[\\]\\*\\w\\s]*\\)(?=\\s*;)");
321+
Pattern functionPattern = Pattern.compile("[\\w\\[\\]\\*]+\\s+[&\\[\\]\\*\\w\\s]+\\([&,\\[\\]\\*\\w\\s]*\\)(?=\\s*\\{)");
320322

321-
ArrayList<String> matches = new ArrayList<String>();
322-
Matcher matcher = pattern.matcher(in);
323-
while (matcher.find())
324-
matches.add(matcher.group(0) + ";");
323+
// Find already declared prototypes
324+
ArrayList<String> prototypeMatches = new ArrayList<String>();
325+
Matcher prototypeMatcher = prototypePattern.matcher(in);
326+
while (prototypeMatcher.find())
327+
prototypeMatches.add(prototypeMatcher.group(0) + ";");
328+
329+
// Find all functions and generate prototypes for them
330+
ArrayList<String> functionMatches = new ArrayList<String>();
331+
Matcher functionMatcher = functionPattern.matcher(in);
332+
while (functionMatcher.find())
333+
functionMatches.add(functionMatcher.group(0) + ";");
334+
335+
// Remove generated prototypes that exactly match ones found in the source file
336+
for (int functionIndex=functionMatches.size() - 1; functionIndex >= 0; functionIndex--) {
337+
for (int prototypeIndex=0; prototypeIndex < prototypeMatches.size(); prototypeIndex++) {
338+
if ((functionMatches.get(functionIndex)).equals(prototypeMatches.get(prototypeIndex))) {
339+
functionMatches.remove(functionIndex);
340+
break;
341+
}
342+
}
343+
}
325344

326-
return matches;
345+
return functionMatches;
327346
}
328347
}

app/src/processing/app/tools/AutoFormat.java

+16-13
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public void comment() throws IOException {
9999
c = string[j++] = getchr(); // extra char
100100
while (done == 0) {
101101
c = string[j++] = getchr();
102-
while ((c != '/') && (j < string.length)) {
102+
while ((c != '/') && (j < string.length) && EOF == 0) {
103103
if(c == '\n' || c == '\r') {
104104
lineNumber++;
105105
putcoms();
@@ -111,7 +111,9 @@ public void comment() throws IOException {
111111
if (j>1 && string[j-2] == '*') {
112112
done = 1;
113113
jdoc = 0;
114-
}
114+
} else if (EOF != 0) {
115+
done = 1;
116+
}
115117
}
116118

117119
putcoms();
@@ -134,7 +136,7 @@ public char get_string() throws IOException {
134136
}
135137
if (ch == '\'' || ch == '"') {
136138
cc = string[j++] = getchr();
137-
while (cc != ch) {
139+
while (cc != ch && EOF == 0) {
138140
if (cc == '\\') string[j++] = getchr();
139141
cc = string[j++] = getchr();
140142
}
@@ -207,7 +209,7 @@ public void putcoms()
207209
}
208210
string[j] = '\0';
209211
i = 0;
210-
while (string[i] == ' ') i++;
212+
while (string[i] == ' ' && EOF == 0) i++;
211213
if (lookup_com(w_jdoc) == 1) jdoc = 1;
212214
String strBuffer = new String(string,0,j);
213215
if (string[i] == '/' && string[i+1]=='*')
@@ -241,7 +243,7 @@ public void putcoms()
241243
public void cpp_comment() throws IOException
242244
{
243245
c = getchr();
244-
while(c != '\n' && c != '\r' && j<133)
246+
while(c != '\n' && c != '\r' && EOF == 0)
245247
{
246248
string[j++] = c;
247249
c = getchr();
@@ -337,7 +339,7 @@ public int getnl() throws IOException
337339
peekc = getchr();
338340
//while ((peekc == '\t' || peekc == ' ') &&
339341
// (j < string.length)) {
340-
while (peekc == '\t' || peekc == ' ') {
342+
while ((peekc == '\t' || peekc == ' ') && EOF == 0) {
341343
string[j++] = peekc;
342344
peek = -1;
343345
peekc = '`';
@@ -398,7 +400,7 @@ public int lookup (String keyword)
398400

399401
if (j<1) return (0);
400402
kk=0;
401-
while(string[kk] == ' ')kk++;
403+
while(string[kk] == ' ' && EOF == 0)kk++;
402404
l=0;
403405
l = j_string.indexOf(keyword);
404406
if (l<0 || l!=kk)
@@ -421,7 +423,7 @@ public int lookup_com (String keyword)
421423

422424
if (j<1) return (0);
423425
kk=0;
424-
while(string[kk] == ' ')kk++;
426+
while(string[kk] == ' ' && EOF == 0) kk++;
425427
l=0;
426428
l = j_string.indexOf(keyword);
427429
if (l<0 || l!=kk)
@@ -637,7 +639,8 @@ public void run() {
637639
case '\'':
638640
string[j++] = c;
639641
cc = getchr();
640-
while(cc != c)
642+
int count = 0;
643+
while(cc != c && EOF == 0)
641644
{
642645
// max. length of line should be 256
643646
string[j++] = cc;
@@ -784,7 +787,7 @@ public void run() {
784787
case '#':
785788
string[j++] = c;
786789
cc = getchr();
787-
while(cc != '\n')
790+
while(cc != '\n' && EOF == 0)
788791
{
789792
string[j++] = cc;
790793
cc = getchr();
@@ -827,13 +830,13 @@ else if(tabs > 0)
827830
if ((lookup(w_for) == 1))
828831
{
829832
c = get_string();
830-
while(c != ';') c = get_string();
833+
while(c != ';' && EOF == 0) c = get_string();
831834
ct=0;
832835
int for_done = 0;
833-
while (for_done==0)
836+
while (for_done == 0 && EOF == 0)
834837
{
835838
c = get_string();
836-
while(c != ')')
839+
while(c != ')' && EOF == 0)
837840
{
838841
if(c == '(') ct++;
839842
c = get_string();

build/build.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -723,8 +723,8 @@
723723
prefix="arduino-${version}"
724724
excludes="**/*.tgz,
725725
**/*.bz2,
726-
**/macosx/,
727-
**/windows/,
726+
**/build/macosx/,
727+
**/build/windows/,
728728
**/work/,
729729
**/.git/,
730730
**/*.class"

build/create_reference.pl

+5-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
my $env = create_page('environment.html', "$ARDUINO/Main/Environment");
2727
my $css = create_page('arduinoUno.css', "$ARDUINO/pub/skins/arduinoUno/arduinoUno.css");
2828
my $css2 = create_page('arduinoWide.css', "$ARDUINO/pub/skins/arduinoWide/arduinoWide.css");
29-
my $css2 = create_page('arduinoWideRender.css', "$ARDUINO/pub/skins/arduinoWideRender/arduinoWideRender.css");
29+
my $css3 = create_page('arduinoWideRender.css', "$ARDUINO/pub/skins/arduinoWideRender/arduinoWideRender.css");
3030
my $eeprom = create_page('EEPROM.html', "$ARDUINO/Reference/EEPROM");
3131
my $stepper = create_page('Stepper.html', "$ARDUINO/Reference/Stepper");
3232
my $softser = create_page('SoftwareSerial.html', "$ARDUINO/Reference/SoftwareSerial");
@@ -38,7 +38,8 @@
3838
my $lcd = create_page('LiquidCrystal.html', "$ARDUINO/Reference/LiquidCrystal");
3939
my $ethernet = create_page('Ethernet.html', "$ARDUINO/Reference/Ethernet");
4040
my $serial = create_page('Serial.html', "$ARDUINO/Reference/Serial");
41-
my $string = create_page('StringClass.html', "$ARDUINO/Reference/StringClass");
41+
my $stream = create_page('Stream.html', "$ARDUINO/Reference/Stream");
42+
my $string = create_page('StringObject.html', "$ARDUINO/Reference/StringObject");
4243

4344
create_linked_pages($guide, qr!$ARDUINO/Guide/(\w+)!, 'Guide_%%.html');
4445
create_linked_pages($softser, qr!$ARDUINO/Reference/(SoftwareSerial\w+)!, '%%.html');
@@ -57,6 +58,8 @@
5758
create_linked_pages($ethernet, qr!$ARDUINO/Reference/(Client\w+)!, '%%.html');
5859
create_linked_pages($serial, qr!$ARDUINO/Serial/(\w+)!, 'Serial_%%.html');
5960
create_linked_pages($string, qr!$ARDUINO/Reference/(String\w+)!, '%%.html');
61+
create_linked_pages($stream, qr!$ARDUINO/Reference/(Stream\w+)!, '%%.html');
62+
create_linked_pages($string, qr!$ARDUINO/Reference/(String\w+)!, '%%.html');
6063

6164
my $index = create_page('index.html', "$ARDUINO/Reference/HomePage");
6265

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

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
<string>VERSION</string>
1515
<!-- now stop changing things and get outta here -->
1616

17+
<key>NSHighResolutionCapable</key>
18+
<true/>
1719
<key>CFBundleAllowMixedLocalizations</key>
1820
<string>true</string>
1921
<key>CFBundleExecutable</key>

build/shared/examples/04.Communication/MIDI/Midi.ino

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
Attach a MIDI cable to the jack, then to a MIDI synth, and play music.
1414
1515
created 13 Jun 2006
16-
modified 30 Aug 2011
16+
modified 13 Aug 2012
1717
by Tom Igoe
1818
1919
This example code is in the public domain.
2020
21-
http://www.arduino.cc/en/Tutorial/MIDI
21+
http://www.arduino.cc/en/Tutorial/Midi
2222
2323
*/
2424

0 commit comments

Comments
 (0)