24 |
25 | class BridgeClient;
26 |
27 | class BridgeServer : public Server {
28 | public:
29 | // Constructor with a user provided BridgeClass instance
30 | BridgeServer(uint16_t port = 5555, BridgeClass &_b = Bridge);
31 |
32 | void begin();
33 | BridgeClient accept();
34 |
35 | virtual size_t write(uint8_t c);
36 |
37 | void listenOnLocalhost() {
38 | useLocalhost = true;
39 | }
40 | void noListenOnLocalhost() {
41 | useLocalhost = false;
42 | }
43 |
44 | private:
45 | BridgeClass &bridge;
46 | uint16_t port;
47 | bool listening;
48 | bool useLocalhost;
49 | };
50 |
51 | #endif // _BRIDGE_SERVER_H_
52 |
--------------------------------------------------------------------------------
/arduino-core/src/processing/app/debug/MessageConsumer.java:
--------------------------------------------------------------------------------
1 | /* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2 |
3 | /*
4 | Part of the Processing project - http://processing.org
5 |
6 | Copyright (c) 2004-06 Ben Fry and Casey Reas
7 | Copyright (c) 2001-04 Massachusetts Institute of Technology
8 |
9 | This program is free software; you can redistribute it and/or modify
10 | it under the terms of the GNU General Public License as published by
11 | the Free Software Foundation; either version 2 of the License, or
12 | (at your option) any later version.
13 |
14 | This program is distributed in the hope that it will be useful,
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | GNU General Public License for more details.
18 |
19 | You should have received a copy of the GNU General Public License
20 | along with this program; if not, write to the Free Software Foundation,
21 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 | */
23 |
24 | package processing.app.debug;
25 |
26 |
27 | /**
28 | * Interface for dealing with parser/compiler output.
29 | *
30 | * Different instances of MessageStream need to do different things with
31 | * messages. In particular, a stream instance used for parsing output from
32 | * the compiler compiler has to interpret its messages differently than one
33 | * parsing output from the runtime.
34 | *
35 | * Classes which consume messages and do something with them
36 | * should implement this interface.
37 | */
38 | public interface MessageConsumer {
39 |
40 | void message(String s);
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/app/src/cc/arduino/contributions/ui/DropdownItem.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Arduino.
3 | *
4 | * Copyright 2015 Arduino LLC (http://www.arduino.cc/)
5 | *
6 | * Arduino is free software; you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation; either version 2 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 | *
20 | * As a special exception, you may use this file as part of a free software
21 | * library without restriction. Specifically, if other files instantiate
22 | * templates or use macros or inline functions from this file, or you compile
23 | * this file and link it with other files to produce an executable, this
24 | * file does not by itself cause the resulting executable to be covered by
25 | * the GNU General Public License. This exception does not however
26 | * invalidate any other reasons why the executable file might be covered by
27 | * the GNU General Public License.
28 | */
29 |
30 | package cc.arduino.contributions.ui;
31 |
32 | import java.util.function.Predicate;
33 |
34 | public interface DropdownItem {
35 |
36 | Predicate getFilterPredicate();
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/arduino-core/src/cc/arduino/contributions/ProgressListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Arduino.
3 | *
4 | * Copyright 2015 Arduino LLC (http://www.arduino.cc/)
5 | *
6 | * Arduino is free software; you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation; either version 2 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 | *
20 | * As a special exception, you may use this file as part of a free software
21 | * library without restriction. Specifically, if other files instantiate
22 | * templates or use macros or inline functions from this file, or you compile
23 | * this file and link it with other files to produce an executable, this
24 | * file does not by itself cause the resulting executable to be covered by
25 | * the GNU General Public License. This exception does not however
26 | * invalidate any other reasons why the executable file might be covered by
27 | * the GNU General Public License.
28 | */
29 |
30 | package cc.arduino.contributions;
31 |
32 | import cc.arduino.utils.Progress;
33 |
34 | public interface ProgressListener {
35 |
36 | void onProgress(Progress progress);
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/arduino-core/src/cc/arduino/contributions/packages/ContributedBoard.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Arduino.
3 | *
4 | * Copyright 2014 Arduino LLC (http://www.arduino.cc/)
5 | *
6 | * Arduino is free software; you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation; either version 2 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 | *
20 | * As a special exception, you may use this file as part of a free software
21 | * library without restriction. Specifically, if other files instantiate
22 | * templates or use macros or inline functions from this file, or you compile
23 | * this file and link it with other files to produce an executable, this
24 | * file does not by itself cause the resulting executable to be covered by
25 | * the GNU General Public License. This exception does not however
26 | * invalidate any other reasons why the executable file might be covered by
27 | * the GNU General Public License.
28 | */
29 |
30 | package cc.arduino.contributions.packages;
31 |
32 | public class ContributedBoard {
33 |
34 | private String name;
35 | public String getName() { return name; }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/arduino-core/src/cc/arduino/contributions/packages/ContributedHelp.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Arduino.
3 | *
4 | * Copyright 2015 Arduino LLC (http://www.arduino.cc/)
5 | *
6 | * Arduino is free software; you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation; either version 2 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 | *
20 | * As a special exception, you may use this file as part of a free software
21 | * library without restriction. Specifically, if other files instantiate
22 | * templates or use macros or inline functions from this file, or you compile
23 | * this file and link it with other files to produce an executable, this
24 | * file does not by itself cause the resulting executable to be covered by
25 | * the GNU General Public License. This exception does not however
26 | * invalidate any other reasons why the executable file might be covered by
27 | * the GNU General Public License.
28 | */
29 |
30 | package cc.arduino.contributions.packages;
31 |
32 | public class ContributedHelp {
33 |
34 | private String online;
35 | public String getOnline() { return online; }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/app/testdata/libraries/SD_1.1.1/SD/examples/DumpFile/DumpFile.ino:
--------------------------------------------------------------------------------
1 | /*
2 | SD card file dump
3 |
4 | This example shows how to read a file from the SD card using the
5 | SD library and send it over the serial port.
6 |
7 | The circuit:
8 | * SD card attached to SPI bus as follows:
9 | ** MOSI - pin 11
10 | ** MISO - pin 12
11 | ** CLK - pin 13
12 | ** CS - pin 4 (for MKRZero SD: SDCARD_SS_PIN)
13 |
14 | created 22 December 2010
15 | by Limor Fried
16 | modified 9 Apr 2012
17 | by Tom Igoe
18 |
19 | This example code is in the public domain.
20 |
21 | */
22 |
23 | #include
24 | #include
25 |
26 | const int chipSelect = 4;
27 |
28 | void setup() {
29 | // Open serial communications and wait for port to open:
30 | Serial.begin(9600);
31 | while (!Serial) {
32 | ; // wait for serial port to connect. Needed for native USB port only
33 | }
34 |
35 |
36 | Serial.print("Initializing SD card...");
37 |
38 | // see if the card is present and can be initialized:
39 | if (!SD.begin(chipSelect)) {
40 | Serial.println("Card failed, or not present");
41 | // don't do anything more:
42 | return;
43 | }
44 | Serial.println("card initialized.");
45 |
46 | // open the file. note that only one file can be open at a time,
47 | // so you have to close this one before opening another.
48 | File dataFile = SD.open("datalog.txt");
49 |
50 | // if the file is available, write to it:
51 | if (dataFile) {
52 | while (dataFile.available()) {
53 | Serial.write(dataFile.read());
54 | }
55 | dataFile.close();
56 | }
57 | // if the file isn't open, pop up an error:
58 | else {
59 | Serial.println("error opening datalog.txt");
60 | }
61 | }
62 |
63 | void loop() {
64 | }
65 |
66 |
--------------------------------------------------------------------------------
/app/testdata/libraries/SD_1.2.1/SD/examples/DumpFile/DumpFile.ino:
--------------------------------------------------------------------------------
1 | /*
2 | SD card file dump
3 |
4 | This example shows how to read a file from the SD card using the
5 | SD library and send it over the serial port.
6 |
7 | The circuit:
8 | * SD card attached to SPI bus as follows:
9 | ** MOSI - pin 11
10 | ** MISO - pin 12
11 | ** CLK - pin 13
12 | ** CS - pin 4 (for MKRZero SD: SDCARD_SS_PIN)
13 |
14 | created 22 December 2010
15 | by Limor Fried
16 | modified 9 Apr 2012
17 | by Tom Igoe
18 |
19 | This example code is in the public domain.
20 |
21 | */
22 |
23 | #include
24 | #include
25 |
26 | const int chipSelect = 4;
27 |
28 | void setup() {
29 | // Open serial communications and wait for port to open:
30 | Serial.begin(9600);
31 | while (!Serial) {
32 | ; // wait for serial port to connect. Needed for native USB port only
33 | }
34 |
35 |
36 | Serial.print("Initializing SD card...");
37 |
38 | // see if the card is present and can be initialized:
39 | if (!SD.begin(chipSelect)) {
40 | Serial.println("Card failed, or not present");
41 | // don't do anything more:
42 | while (1);
43 | }
44 | Serial.println("card initialized.");
45 |
46 | // open the file. note that only one file can be open at a time,
47 | // so you have to close this one before opening another.
48 | File dataFile = SD.open("datalog.txt");
49 |
50 | // if the file is available, write to it:
51 | if (dataFile) {
52 | while (dataFile.available()) {
53 | Serial.write(dataFile.read());
54 | }
55 | dataFile.close();
56 | }
57 | // if the file isn't open, pop up an error:
58 | else {
59 | Serial.println("error opening datalog.txt");
60 | }
61 | }
62 |
63 | void loop() {
64 | }
65 |
66 |
--------------------------------------------------------------------------------
/arduino-core/src/cc/arduino/utils/Progress.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Arduino.
3 | *
4 | * Copyright 2014 Arduino LLC (http://www.arduino.cc/)
5 | *
6 | * Arduino is free software; you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation; either version 2 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 | *
20 | * As a special exception, you may use this file as part of a free software
21 | * library without restriction. Specifically, if other files instantiate
22 | * templates or use macros or inline functions from this file, or you compile
23 | * this file and link it with other files to produce an executable, this
24 | * file does not by itself cause the resulting executable to be covered by
25 | * the GNU General Public License. This exception does not however
26 | * invalidate any other reasons why the executable file might be covered by
27 | * the GNU General Public License.
28 | */
29 |
30 | package cc.arduino.utils;
31 |
32 | public interface Progress {
33 |
34 | void setProgress(double progress);
35 |
36 | double getProgress();
37 |
38 | void setStatus(String _status);
39 |
40 | String getStatus();
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/arduino-core/src/processing/app/helpers/filefilters/OnlyDirs.java:
--------------------------------------------------------------------------------
1 | /*
2 | OnlyDirs - FilenameFilter that accepts only directories (CVS, .svn,
3 | .DS_Store files are excluded as well)
4 | Part of the Arduino project - http://www.arduino.cc/
5 |
6 | Copyright (c) 2011 Cristian Maglie
7 |
8 | This program is free software; you can redistribute it and/or modify
9 | it under the terms of the GNU General Public License as published by
10 | the Free Software Foundation; either version 2 of the License, or
11 | (at your option) any later version.
12 |
13 | This program is distributed in the hope that it will be useful,
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | GNU General Public License for more details.
17 |
18 | You should have received a copy of the GNU General Public License
19 | along with this program; if not, write to the Free Software Foundation,
20 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 | */
22 | package processing.app.helpers.filefilters;
23 |
24 | import java.io.File;
25 | import java.io.FilenameFilter;
26 |
27 | /**
28 | * This filter accepts only directories (excluding .DS_Store files, .svn
29 | * folders, etc)
30 | *
31 | * @author Cristian Maglie
32 | */
33 | public class OnlyDirs implements FilenameFilter {
34 |
35 | @Override
36 | public boolean accept(File dir, String name) {
37 | if (name.charAt(0) == '.')
38 | return false;
39 | if (name.equals("CVS"))
40 | return false;
41 | return new File(dir, name).isDirectory();
42 | }
43 |
44 | /**
45 | * An handy pre-instantiated object
46 | */
47 | public static final OnlyDirs ONLY_DIRS = new OnlyDirs();
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/arduino-core/src/cc/arduino/contributions/NoopProgressListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Arduino.
3 | *
4 | * Copyright 2015 Arduino LLC (http://www.arduino.cc/)
5 | *
6 | * Arduino is free software; you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation; either version 2 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 | *
20 | * As a special exception, you may use this file as part of a free software
21 | * library without restriction. Specifically, if other files instantiate
22 | * templates or use macros or inline functions from this file, or you compile
23 | * this file and link it with other files to produce an executable, this
24 | * file does not by itself cause the resulting executable to be covered by
25 | * the GNU General Public License. This exception does not however
26 | * invalidate any other reasons why the executable file might be covered by
27 | * the GNU General Public License.
28 | */
29 |
30 | package cc.arduino.contributions;
31 |
32 | import cc.arduino.utils.Progress;
33 |
34 | public class NoopProgressListener implements ProgressListener {
35 |
36 | @Override
37 | public void onProgress(Progress progress) {
38 |
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/arduino-core/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/arduino-core/src/processing/app/i18n/update.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | #
4 | # Extract the text catalog from the source code,
5 | # and merge with the already translated texts.
6 | #
7 | # Please be aware that this OVERWRITES the existing *.po and *.properties files.
8 | # You may want to commit to your repository before running this script.
9 | #
10 |
11 | # by Shigeru KANEMOTO at SWITCHSCIENCE.
12 | # on 2011-10-15
13 |
14 | catalog="/tmp/$$.po"
15 | files="/tmp/$$.files"
16 |
17 | trap "rm -f '$catalog' '$files'" 0 1 2 15
18 |
19 | catalog()
20 | {
21 | # Generate the new text catalog without the already translated texts.
22 | # The 'merge existing' option for xgetext does not work propery for our purpose.
23 | find ../../../../../app/ -name '*.java' -print > "$files"
24 | find ../../../../../arduino-core/ -name '*.java' -print >> "$files"
25 | xgettext -s -L Java --from-code=utf-8 --keyword=tr --output="$catalog" --files-from="$files"
26 | }
27 |
28 | update()
29 | {
30 | echo -e "Updating $1...\c"
31 | cat "$catalog" | python2 python/update.py "$1"
32 | msgcat -p "$1" > $(basename "$1" .po).properties
33 | # msgcat may complain about "CHARSET" if you didn't replace "CHARSET" with
34 | # your correct charset.
35 | echo
36 | }
37 |
38 | if [ $0 != "./update.sh" ]; then
39 | echo "update.sh: Invoke this script as ./update.sh"
40 | exit 1
41 | fi
42 |
43 | while [ $# -gt 0 ]; do
44 | if [ $1 = '-a' ]; then
45 | targets=Resources_*.po
46 | else
47 | targets="$targets Resources_$1.po"
48 | fi
49 | shift
50 | done
51 |
52 | if [ "$targets" = "" ]; then
53 | echo "update.sh: Give at least one language code or '-a'."
54 | exit 1
55 | fi
56 |
57 | # Then, merge with already translated texts.
58 | catalog
59 | for target in $targets; do
60 | update $target
61 | done
62 |
--------------------------------------------------------------------------------
/arduino-core/build.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
23 |
24 |
25 |
29 |
30 |
31 |
32 |
33 |
34 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/arduino-core/src/cc/arduino/DefaultUncaughtExceptionHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Arduino.
3 | *
4 | * Copyright 2015 Arduino LLC (http://www.arduino.cc/)
5 | *
6 | * Arduino is free software; you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation; either version 2 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 | *
20 | * As a special exception, you may use this file as part of a free software
21 | * library without restriction. Specifically, if other files instantiate
22 | * templates or use macros or inline functions from this file, or you compile
23 | * this file and link it with other files to produce an executable, this
24 | * file does not by itself cause the resulting executable to be covered by
25 | * the GNU General Public License. This exception does not however
26 | * invalidate any other reasons why the executable file might be covered by
27 | * the GNU General Public License.
28 | */
29 |
30 | package cc.arduino;
31 |
32 | public class DefaultUncaughtExceptionHandler implements Thread.UncaughtExceptionHandler {
33 |
34 | @Override
35 | public void uncaughtException(Thread t, Throwable e) {
36 | System.err.println(t);
37 | e.printStackTrace();
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/arduino-core/src/processing/app/i18n/python/update.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python2
2 | #vim:set fileencoding=utf-8 sw=2 expandtab
3 |
4 | def unquote(s):
5 | s = s.strip()
6 | if s[0] != '"' or s[-1] != '"':
7 | raise RuntimeError
8 | return s[1:-1]
9 |
10 | def read_po(fp):
11 | if isinstance(fp, str):
12 | fp = open(fp)
13 |
14 | d = {}
15 | st = 1
16 | comment = key = rkey = rvalue = ''
17 | for line in fp:
18 | if line[0] == '#' or line.strip() == '':
19 | if st == 2:
20 | d[key] = (comment, rkey, rvalue)
21 | st = 1
22 | comment = key = rkey = rvalue = ''
23 | comment += line
24 | elif line[0] == '"':
25 | if st == 1:
26 | key += unquote(line)
27 | rkey += line
28 | else:
29 | rvalue += line
30 | elif line.startswith('msgid '):
31 | st = 1
32 | key = unquote(line[6:])
33 | rkey = line
34 | elif line.startswith('msgstr '):
35 | st = 2
36 | rvalue = line
37 | else:
38 | raise RuntimeError
39 |
40 | if st == 2:
41 | d[key] = (comment, rkey, rvalue)
42 |
43 | return d
44 |
45 | def dump(d, dstFile):
46 | out = open(dstFile, 'w')
47 |
48 | # The first block in file should go first because the key is ''.
49 | for key in sorted(d.keys()):
50 | (comment, rkey, rvalue) = d[key]
51 | out.write(comment)
52 | out.write(rkey)
53 | out.write(rvalue)
54 |
55 | out.close()
56 |
57 | def merge(d, dd):
58 | for key in dd.keys():
59 | if d.has_key(key):
60 | d[key] = dd[key]
61 | return d
62 |
63 | # Remove currently unused catalog text lines from ".po" file.
64 | def main():
65 | import sys
66 | d = read_po(sys.stdin)
67 | dd = read_po(sys.argv[1])
68 | dump(merge(d, dd), sys.argv[1])
69 |
70 | if __name__ == '__main__':
71 | main()
72 |
--------------------------------------------------------------------------------
/app/src/processing/app/helpers/CircularBuffer.java:
--------------------------------------------------------------------------------
1 | package processing.app.helpers;
2 |
3 | import java.util.NoSuchElementException;
4 |
5 | public class CircularBuffer {
6 |
7 | private final double[] elements;
8 | private int start = -1;
9 | private int end = -1;
10 | private final int capacity;
11 |
12 | public void add(double num) {
13 | end = (end + 1) % capacity;
14 | elements[end] = num;
15 | if (start == end || start == -1) {
16 | start = (start + 1) % capacity;
17 | }
18 | }
19 |
20 | public double get(int index) {
21 | if (index >= capacity) {
22 | throw new IndexOutOfBoundsException();
23 | }
24 | if (index >= size()) {
25 | throw new IndexOutOfBoundsException();
26 | }
27 |
28 | return elements[(start + index) % capacity];
29 | }
30 |
31 | public boolean isEmpty() {
32 | return start == -1 && end == -1;
33 | }
34 |
35 | public CircularBuffer(int capacity) {
36 | this.capacity = capacity;
37 | elements = new double[capacity];
38 | }
39 |
40 | public double min() {
41 | if (size() == 0) {
42 | throw new NoSuchElementException();
43 | }
44 |
45 | double out = get(0);
46 | for (int i = 1; i < size(); ++i) {
47 | out = Math.min(out, get(i));
48 | }
49 |
50 | return out;
51 | }
52 |
53 | public double max() {
54 | if (size() == 0) {
55 | throw new NoSuchElementException();
56 | }
57 |
58 | double out = get(0);
59 | for (int i = 1; i < size(); ++i) {
60 | out = Math.max(out, get(i));
61 | }
62 |
63 | return out;
64 | }
65 |
66 | public int size() {
67 | if (end == -1) {
68 | return 0;
69 | }
70 |
71 | return (end - start + capacity) % capacity + 1;
72 | }
73 |
74 | public int capacity() {
75 | return capacity;
76 | }
77 |
78 | }
79 |
--------------------------------------------------------------------------------
/app/testdata/libraries/Bridge_1.6.3/Bridge/examples/ConsoleRead/ConsoleRead.ino:
--------------------------------------------------------------------------------
1 | /*
2 | Console Read example for YunShield/Yún
3 |
4 | Read data coming from bridge using the Console.read() function
5 | and store it in a string.
6 |
7 | To see the Console, pick your Yún's name and IP address in the Port menu
8 | then open the Port Monitor. You can also see it by opening a terminal window
9 | and typing:
10 | ssh root@ yourYunsName.local 'telnet localhost 6571'
11 | then pressing enter. When prompted for the password, enter it.
12 |
13 | created 13 Jun 2013
14 | by Angelo Scialabba
15 | modified 16 June 2013
16 | by Tom Igoe
17 |
18 | This example code is in the public domain.
19 |
20 | http://www.arduino.cc/en/Tutorial/ConsoleRead
21 |
22 | */
23 |
24 | #include
25 |
26 | String name;
27 |
28 | void setup() {
29 | // Initialize Console and wait for port to open:
30 | Bridge.begin();
31 | Console.begin();
32 |
33 | // Wait for Console port to connect
34 | while (!Console);
35 |
36 | Console.println("Hi, what's your name?");
37 | }
38 |
39 | void loop() {
40 | if (Console.available() > 0) {
41 | char c = Console.read(); // read the next char received
42 | // look for the newline character, this is the last character in the string
43 | if (c == '\n') {
44 | //print text with the name received
45 | Console.print("Hi ");
46 | Console.print(name);
47 | Console.println("! Nice to meet you!");
48 | Console.println();
49 | // Ask again for name and clear the old name
50 | Console.println("Hi, what's your name?");
51 | name = ""; // clear the name string
52 | } else { // if the buffer is empty Cosole.read() returns -1
53 | name += c; // append the read char from Console to the name string
54 | }
55 | } else {
56 | delay(100);
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/app/testdata/libraries/Bridge_1.7.0/Bridge/examples/ConsoleRead/ConsoleRead.ino:
--------------------------------------------------------------------------------
1 | /*
2 | Console Read example for YunShield/Yún
3 |
4 | Read data coming from bridge using the Console.read() function
5 | and store it in a string.
6 |
7 | To see the Console, pick your Yún's name and IP address in the Port menu
8 | then open the Port Monitor. You can also see it by opening a terminal window
9 | and typing:
10 | ssh root@ yourYunsName.local 'telnet localhost 6571'
11 | then pressing enter. When prompted for the password, enter it.
12 |
13 | created 13 Jun 2013
14 | by Angelo Scialabba
15 | modified 16 June 2013
16 | by Tom Igoe
17 |
18 | This example code is in the public domain.
19 |
20 | http://www.arduino.cc/en/Tutorial/ConsoleRead
21 |
22 | */
23 |
24 | #include
25 |
26 | String name;
27 |
28 | void setup() {
29 | // Initialize Console and wait for port to open:
30 | Bridge.begin();
31 | Console.begin();
32 |
33 | // Wait for Console port to connect
34 | while (!Console);
35 |
36 | Console.println("Hi, what's your name?");
37 | }
38 |
39 | void loop() {
40 | if (Console.available() > 0) {
41 | char c = Console.read(); // read the next char received
42 | // look for the newline character, this is the last character in the string
43 | if (c == '\n') {
44 | //print text with the name received
45 | Console.print("Hi ");
46 | Console.print(name);
47 | Console.println("! Nice to meet you!");
48 | Console.println();
49 | // Ask again for name and clear the old name
50 | Console.println("Hi, what's your name?");
51 | name = ""; // clear the name string
52 | } else { // if the buffer is empty Cosole.read() returns -1
53 | name += c; // append the read char from Console to the name string
54 | }
55 | } else {
56 | delay(100);
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/app/src/processing/app/helpers/GUIUserNotifier.java:
--------------------------------------------------------------------------------
1 | package processing.app.helpers;
2 |
3 | import processing.app.Base;
4 |
5 | import static processing.app.I18n.tr;
6 |
7 | import javax.swing.JOptionPane;
8 |
9 | public class GUIUserNotifier extends UserNotifier {
10 |
11 | private final Base base;
12 |
13 | public GUIUserNotifier(Base base) {
14 | this.base = base;
15 | }
16 |
17 | /**
18 | * Show an error message that's actually fatal to the program.
19 | * This is an error that can't be recovered. Use showWarning()
20 | * for errors that allow P5 to continue running.
21 | */
22 | public void showError(String title, String message, Throwable e, int exit_code) {
23 | if (title == null) title = tr("Error");
24 |
25 | JOptionPane.showMessageDialog(base.getActiveEditor(), message, title,
26 | JOptionPane.ERROR_MESSAGE);
27 |
28 | if (e != null) e.printStackTrace();
29 | System.exit(exit_code);
30 | }
31 |
32 | /**
33 | * "No cookie for you" type messages. Nothing fatal or all that
34 | * much of a bummer, but something to notify the user about.
35 | */
36 | public void showMessage(String title, String message) {
37 | if (title == null) title = tr("Message");
38 |
39 | JOptionPane.showMessageDialog(base.getActiveEditor(), message, title,
40 | JOptionPane.INFORMATION_MESSAGE);
41 | }
42 |
43 | /**
44 | * Non-fatal error message with optional stack trace side dish.
45 | */
46 | public void showWarning(String title, String message, Exception e) {
47 | if (title == null) title = tr("Warning");
48 |
49 | JOptionPane.showMessageDialog(base.getActiveEditor(), message, title,
50 | JOptionPane.WARNING_MESSAGE);
51 |
52 | if (e != null) e.printStackTrace();
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/arduino-core/src/cc/arduino/utils/Pair.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Arduino.
3 | *
4 | * Copyright 2015 Arduino LLC (http://www.arduino.cc/)
5 | *
6 | * Arduino is free software; you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation; either version 2 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 | *
20 | * As a special exception, you may use this file as part of a free software
21 | * library without restriction. Specifically, if other files instantiate
22 | * templates or use macros or inline functions from this file, or you compile
23 | * this file and link it with other files to produce an executable, this
24 | * file does not by itself cause the resulting executable to be covered by
25 | * the GNU General Public License. This exception does not however
26 | * invalidate any other reasons why the executable file might be covered by
27 | * the GNU General Public License.
28 | */
29 |
30 | package cc.arduino.utils;
31 |
32 | public class Pair {
33 |
34 | public final K key;
35 | public final V value;
36 |
37 | public Pair(K key, V value) {
38 | this.key = key;
39 | this.value = value;
40 | }
41 |
42 | @Override
43 | public String toString() {
44 | return "key: " + key + ", value: " + value;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/arduino-core/src/cc/arduino/filters/FileExecutablePredicate.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Arduino.
3 | *
4 | * Copyright 2015 Arduino LLC (http://www.arduino.cc/)
5 | *
6 | * Arduino is free software; you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation; either version 2 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 | *
20 | * As a special exception, you may use this file as part of a free software
21 | * library without restriction. Specifically, if other files instantiate
22 | * templates or use macros or inline functions from this file, or you compile
23 | * this file and link it with other files to produce an executable, this
24 | * file does not by itself cause the resulting executable to be covered by
25 | * the GNU General Public License. This exception does not however
26 | * invalidate any other reasons why the executable file might be covered by
27 | * the GNU General Public License.
28 | */
29 |
30 | package cc.arduino.filters;
31 |
32 | import java.io.File;
33 | import java.util.function.Predicate;
34 |
35 | public class FileExecutablePredicate implements Predicate {
36 |
37 | @Override
38 | public boolean test(File file) {
39 | return file.isFile() && file.exists() && file.canRead() && file.canExecute();
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/app/testdata/libraries/Bridge_1.6.3/Bridge/src/BridgeServer.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2013 Arduino LLC. All right reserved.
3 |
4 | This library is free software; you can redistribute it and/or
5 | modify it under the terms of the GNU Lesser General Public
6 | License as published by the Free Software Foundation; either
7 | version 2.1 of the License, or (at your option) any later version.
8 |
9 | This library is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public
15 | License along with this library; if not, write to the Free Software
16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 | */
18 |
19 | #include
20 | #include
21 |
22 | BridgeServer::BridgeServer(uint16_t _p, BridgeClass &_b) :
23 | bridge(_b), port(_p), listening(false), useLocalhost(false) {
24 | }
25 |
26 | void BridgeServer::begin() {
27 | uint8_t tmp[] = {
28 | 'N',
29 | static_cast(port >> 8),
30 | static_cast(port)
31 | };
32 | uint8_t res[1];
33 | String address = F("127.0.0.1");
34 | if (!useLocalhost)
35 | address = F("0.0.0.0");
36 | bridge.transfer(tmp, 3, (const uint8_t *)address.c_str(), address.length(), res, 1);
37 | listening = (res[0] == 1);
38 | }
39 |
40 | BridgeClient BridgeServer::accept() {
41 | uint8_t cmd[] = {'k'};
42 | uint8_t res[1];
43 | unsigned int l = bridge.transfer(cmd, 1, res, 1);
44 | if (l == 0)
45 | return BridgeClient();
46 | return BridgeClient(res[0]);
47 | }
48 |
49 | size_t BridgeServer::write(uint8_t c) {
50 | uint8_t cmd[] = { 'b', c };
51 | bridge.transfer(cmd, 2);
52 | return 1;
53 | }
54 |
55 |
--------------------------------------------------------------------------------
/app/testdata/libraries/Bridge_1.7.0/Bridge/src/BridgeServer.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2013 Arduino LLC. All right reserved.
3 |
4 | This library is free software; you can redistribute it and/or
5 | modify it under the terms of the GNU Lesser General Public
6 | License as published by the Free Software Foundation; either
7 | version 2.1 of the License, or (at your option) any later version.
8 |
9 | This library is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public
15 | License along with this library; if not, write to the Free Software
16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 | */
18 |
19 | #include
20 | #include
21 |
22 | BridgeServer::BridgeServer(uint16_t _p, BridgeClass &_b) :
23 | bridge(_b), port(_p), listening(false), useLocalhost(false) {
24 | }
25 |
26 | void BridgeServer::begin() {
27 | uint8_t tmp[] = {
28 | 'N',
29 | static_cast(port >> 8),
30 | static_cast(port)
31 | };
32 | uint8_t res[1];
33 | String address = F("127.0.0.1");
34 | if (!useLocalhost)
35 | address = F("0.0.0.0");
36 | bridge.transfer(tmp, 3, (const uint8_t *)address.c_str(), address.length(), res, 1);
37 | listening = (res[0] == 1);
38 | }
39 |
40 | BridgeClient BridgeServer::accept() {
41 | uint8_t cmd[] = {'k'};
42 | uint8_t res[1];
43 | unsigned int l = bridge.transfer(cmd, 1, res, 1);
44 | if (l == 0)
45 | return BridgeClient();
46 | return BridgeClient(res[0]);
47 | }
48 |
49 | size_t BridgeServer::write(uint8_t c) {
50 | uint8_t cmd[] = { 'b', c };
51 | bridge.transfer(cmd, 2);
52 | return 1;
53 | }
54 |
55 |
--------------------------------------------------------------------------------
/app/testdata/libraries/SD_1.1.1/SD/examples/listfiles/listfiles.ino:
--------------------------------------------------------------------------------
1 | /*
2 | Listfiles
3 |
4 | This example shows how print out the files in a
5 | directory on a SD card
6 |
7 | The circuit:
8 | * SD card attached to SPI bus as follows:
9 | ** MOSI - pin 11
10 | ** MISO - pin 12
11 | ** CLK - pin 13
12 | ** CS - pin 4 (for MKRZero SD: SDCARD_SS_PIN)
13 |
14 | created Nov 2010
15 | by David A. Mellis
16 | modified 9 Apr 2012
17 | by Tom Igoe
18 | modified 2 Feb 2014
19 | by Scott Fitzgerald
20 |
21 | This example code is in the public domain.
22 |
23 | */
24 | #include
25 | #include
26 |
27 | File root;
28 |
29 | void setup() {
30 | // Open serial communications and wait for port to open:
31 | Serial.begin(9600);
32 | while (!Serial) {
33 | ; // wait for serial port to connect. Needed for native USB port only
34 | }
35 |
36 | Serial.print("Initializing SD card...");
37 |
38 | if (!SD.begin(4)) {
39 | Serial.println("initialization failed!");
40 | return;
41 | }
42 | Serial.println("initialization done.");
43 |
44 | root = SD.open("/");
45 |
46 | printDirectory(root, 0);
47 |
48 | Serial.println("done!");
49 | }
50 |
51 | void loop() {
52 | // nothing happens after setup finishes.
53 | }
54 |
55 | void printDirectory(File dir, int numTabs) {
56 | while (true) {
57 |
58 | File entry = dir.openNextFile();
59 | if (! entry) {
60 | // no more files
61 | break;
62 | }
63 | for (uint8_t i = 0; i < numTabs; i++) {
64 | Serial.print('\t');
65 | }
66 | Serial.print(entry.name());
67 | if (entry.isDirectory()) {
68 | Serial.println("/");
69 | printDirectory(entry, numTabs + 1);
70 | } else {
71 | // files have sizes, directories do not
72 | Serial.print("\t\t");
73 | Serial.println(entry.size(), DEC);
74 | }
75 | entry.close();
76 | }
77 | }
78 |
79 |
80 |
81 |
--------------------------------------------------------------------------------
/arduino-core/src/processing/app/i18n/python/requests/packages/charade/euctwprober.py:
--------------------------------------------------------------------------------
1 | ######################## BEGIN LICENSE BLOCK ########################
2 | # The Original Code is mozilla.org code.
3 | #
4 | # The Initial Developer of the Original Code is
5 | # Netscape Communications Corporation.
6 | # Portions created by the Initial Developer are Copyright (C) 1998
7 | # the Initial Developer. All Rights Reserved.
8 | #
9 | # Contributor(s):
10 | # Mark Pilgrim - port to Python
11 | #
12 | # This library is free software; you can redistribute it and/or
13 | # modify it under the terms of the GNU Lesser General Public
14 | # License as published by the Free Software Foundation; either
15 | # version 2.1 of the License, or (at your option) any later version.
16 | #
17 | # This library is distributed in the hope that it will be useful,
18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 | # Lesser General Public License for more details.
21 | #
22 | # You should have received a copy of the GNU Lesser General Public
23 | # License along with this library; if not, write to the Free Software
24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
25 | # 02110-1301 USA
26 | ######################### END LICENSE BLOCK #########################
27 |
28 | from .mbcharsetprober import MultiByteCharSetProber
29 | from .codingstatemachine import CodingStateMachine
30 | from .chardistribution import EUCTWDistributionAnalysis
31 | from .mbcssm import EUCTWSMModel
32 |
33 | class EUCTWProber(MultiByteCharSetProber):
34 | def __init__(self):
35 | MultiByteCharSetProber.__init__(self)
36 | self._mCodingSM = CodingStateMachine(EUCTWSMModel)
37 | self._mDistributionAnalyzer = EUCTWDistributionAnalysis()
38 | self.reset()
39 |
40 | def get_charset_name(self):
41 | return "EUC-TW"
42 |
--------------------------------------------------------------------------------
/app/testdata/libraries/SD_1.2.1/SD/examples/listfiles/listfiles.ino:
--------------------------------------------------------------------------------
1 | /*
2 | Listfiles
3 |
4 | This example shows how print out the files in a
5 | directory on a SD card
6 |
7 | The circuit:
8 | * SD card attached to SPI bus as follows:
9 | ** MOSI - pin 11
10 | ** MISO - pin 12
11 | ** CLK - pin 13
12 | ** CS - pin 4 (for MKRZero SD: SDCARD_SS_PIN)
13 |
14 | created Nov 2010
15 | by David A. Mellis
16 | modified 9 Apr 2012
17 | by Tom Igoe
18 | modified 2 Feb 2014
19 | by Scott Fitzgerald
20 |
21 | This example code is in the public domain.
22 |
23 | */
24 | #include
25 | #include
26 |
27 | File root;
28 |
29 | void setup() {
30 | // Open serial communications and wait for port to open:
31 | Serial.begin(9600);
32 | while (!Serial) {
33 | ; // wait for serial port to connect. Needed for native USB port only
34 | }
35 |
36 | Serial.print("Initializing SD card...");
37 |
38 | if (!SD.begin(4)) {
39 | Serial.println("initialization failed!");
40 | while (1);
41 | }
42 | Serial.println("initialization done.");
43 |
44 | root = SD.open("/");
45 |
46 | printDirectory(root, 0);
47 |
48 | Serial.println("done!");
49 | }
50 |
51 | void loop() {
52 | // nothing happens after setup finishes.
53 | }
54 |
55 | void printDirectory(File dir, int numTabs) {
56 | while (true) {
57 |
58 | File entry = dir.openNextFile();
59 | if (! entry) {
60 | // no more files
61 | break;
62 | }
63 | for (uint8_t i = 0; i < numTabs; i++) {
64 | Serial.print('\t');
65 | }
66 | Serial.print(entry.name());
67 | if (entry.isDirectory()) {
68 | Serial.println("/");
69 | printDirectory(entry, numTabs + 1);
70 | } else {
71 | // files have sizes, directories do not
72 | Serial.print("\t\t");
73 | Serial.println(entry.size(), DEC);
74 | }
75 | entry.close();
76 | }
77 | }
78 |
79 |
80 |
81 |
--------------------------------------------------------------------------------
/arduino-core/src/processing/app/i18n/python/requests/packages/charade/euckrprober.py:
--------------------------------------------------------------------------------
1 | ######################## BEGIN LICENSE BLOCK ########################
2 | # The Original Code is mozilla.org code.
3 | #
4 | # The Initial Developer of the Original Code is
5 | # Netscape Communications Corporation.
6 | # Portions created by the Initial Developer are Copyright (C) 1998
7 | # the Initial Developer. All Rights Reserved.
8 | #
9 | # Contributor(s):
10 | # Mark Pilgrim - port to Python
11 | #
12 | # This library is free software; you can redistribute it and/or
13 | # modify it under the terms of the GNU Lesser General Public
14 | # License as published by the Free Software Foundation; either
15 | # version 2.1 of the License, or (at your option) any later version.
16 | #
17 | # This library is distributed in the hope that it will be useful,
18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 | # Lesser General Public License for more details.
21 | #
22 | # You should have received a copy of the GNU Lesser General Public
23 | # License along with this library; if not, write to the Free Software
24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
25 | # 02110-1301 USA
26 | ######################### END LICENSE BLOCK #########################
27 |
28 | from .mbcharsetprober import MultiByteCharSetProber
29 | from .codingstatemachine import CodingStateMachine
30 | from .chardistribution import EUCKRDistributionAnalysis
31 | from .mbcssm import EUCKRSMModel
32 |
33 |
34 | class EUCKRProber(MultiByteCharSetProber):
35 | def __init__(self):
36 | MultiByteCharSetProber.__init__(self)
37 | self._mCodingSM = CodingStateMachine(EUCKRSMModel)
38 | self._mDistributionAnalyzer = EUCKRDistributionAnalysis()
39 | self.reset()
40 |
41 | def get_charset_name(self):
42 | return "EUC-KR"
43 |
--------------------------------------------------------------------------------
/arduino-core/src/processing/app/i18n/python/requests/packages/charade/gb2312prober.py:
--------------------------------------------------------------------------------
1 | ######################## BEGIN LICENSE BLOCK ########################
2 | # The Original Code is mozilla.org code.
3 | #
4 | # The Initial Developer of the Original Code is
5 | # Netscape Communications Corporation.
6 | # Portions created by the Initial Developer are Copyright (C) 1998
7 | # the Initial Developer. All Rights Reserved.
8 | #
9 | # Contributor(s):
10 | # Mark Pilgrim - port to Python
11 | #
12 | # This library is free software; you can redistribute it and/or
13 | # modify it under the terms of the GNU Lesser General Public
14 | # License as published by the Free Software Foundation; either
15 | # version 2.1 of the License, or (at your option) any later version.
16 | #
17 | # This library is distributed in the hope that it will be useful,
18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 | # Lesser General Public License for more details.
21 | #
22 | # You should have received a copy of the GNU Lesser General Public
23 | # License along with this library; if not, write to the Free Software
24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
25 | # 02110-1301 USA
26 | ######################### END LICENSE BLOCK #########################
27 |
28 | from .mbcharsetprober import MultiByteCharSetProber
29 | from .codingstatemachine import CodingStateMachine
30 | from .chardistribution import GB2312DistributionAnalysis
31 | from .mbcssm import GB2312SMModel
32 |
33 | class GB2312Prober(MultiByteCharSetProber):
34 | def __init__(self):
35 | MultiByteCharSetProber.__init__(self)
36 | self._mCodingSM = CodingStateMachine(GB2312SMModel)
37 | self._mDistributionAnalyzer = GB2312DistributionAnalysis()
38 | self.reset()
39 |
40 | def get_charset_name(self):
41 | return "GB2312"
42 |
--------------------------------------------------------------------------------
/arduino-core/src/cc/arduino/utils/ReverseComparator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Arduino.
3 | *
4 | * Copyright 2015 Arduino LLC (http://www.arduino.cc/)
5 | *
6 | * Arduino is free software; you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation; either version 2 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 | *
20 | * As a special exception, you may use this file as part of a free software
21 | * library without restriction. Specifically, if other files instantiate
22 | * templates or use macros or inline functions from this file, or you compile
23 | * this file and link it with other files to produce an executable, this
24 | * file does not by itself cause the resulting executable to be covered by
25 | * the GNU General Public License. This exception does not however
26 | * invalidate any other reasons why the executable file might be covered by
27 | * the GNU General Public License.
28 | */
29 |
30 | package cc.arduino.utils;
31 |
32 | import java.util.Comparator;
33 |
34 | public class ReverseComparator implements Comparator {
35 |
36 | private final Comparator orig;
37 |
38 | public ReverseComparator(Comparator orig) {
39 | this.orig = orig;
40 | }
41 |
42 | @Override
43 | public int compare(T t, T t1) {
44 | return -1 * orig.compare(t, t1);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/arduino-core/src/processing/app/i18n/python/requests/packages/charade/big5prober.py:
--------------------------------------------------------------------------------
1 | ######################## BEGIN LICENSE BLOCK ########################
2 | # The Original Code is Mozilla Communicator client code.
3 | #
4 | # The Initial Developer of the Original Code is
5 | # Netscape Communications Corporation.
6 | # Portions created by the Initial Developer are Copyright (C) 1998
7 | # the Initial Developer. All Rights Reserved.
8 | #
9 | # Contributor(s):
10 | # Mark Pilgrim - port to Python
11 | #
12 | # This library is free software; you can redistribute it and/or
13 | # modify it under the terms of the GNU Lesser General Public
14 | # License as published by the Free Software Foundation; either
15 | # version 2.1 of the License, or (at your option) any later version.
16 | #
17 | # This library is distributed in the hope that it will be useful,
18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 | # Lesser General Public License for more details.
21 | #
22 | # You should have received a copy of the GNU Lesser General Public
23 | # License along with this library; if not, write to the Free Software
24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
25 | # 02110-1301 USA
26 | ######################### END LICENSE BLOCK #########################
27 |
28 | from .mbcharsetprober import MultiByteCharSetProber
29 | from .codingstatemachine import CodingStateMachine
30 | from .chardistribution import Big5DistributionAnalysis
31 | from .mbcssm import Big5SMModel
32 |
33 |
34 | class Big5Prober(MultiByteCharSetProber):
35 | def __init__(self):
36 | MultiByteCharSetProber.__init__(self)
37 | self._mCodingSM = CodingStateMachine(Big5SMModel)
38 | self._mDistributionAnalyzer = Big5DistributionAnalysis()
39 | self.reset()
40 |
41 | def get_charset_name(self):
42 | return "Big5"
43 |
--------------------------------------------------------------------------------
/app/src/cc/arduino/view/StubMenuListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Arduino.
3 | *
4 | * Copyright 2015 Arduino LLC (http://www.arduino.cc/)
5 | *
6 | * Arduino is free software; you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation; either version 2 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 | *
20 | * As a special exception, you may use this file as part of a free software
21 | * library without restriction. Specifically, if other files instantiate
22 | * templates or use macros or inline functions from this file, or you compile
23 | * this file and link it with other files to produce an executable, this
24 | * file does not by itself cause the resulting executable to be covered by
25 | * the GNU General Public License. This exception does not however
26 | * invalidate any other reasons why the executable file might be covered by
27 | * the GNU General Public License.
28 | */
29 |
30 | package cc.arduino.view;
31 |
32 | import javax.swing.event.MenuEvent;
33 | import javax.swing.event.MenuListener;
34 |
35 | public class StubMenuListener implements MenuListener {
36 |
37 | @Override
38 | public void menuSelected(MenuEvent e) {
39 | }
40 |
41 | @Override
42 | public void menuDeselected(MenuEvent e) {
43 | }
44 |
45 | @Override
46 | public void menuCanceled(MenuEvent e) {
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/arduino-core/src/cc/arduino/packages/discoverers/PluggableDiscoveryMessage.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Arduino.
3 | *
4 | * Arduino is free software; you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation; either version 2 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 | *
18 | * As a special exception, you may use this file as part of a free software
19 | * library without restriction. Specifically, if other files instantiate
20 | * templates or use macros or inline functions from this file, or you compile
21 | * this file and link it with other files to produce an executable, this
22 | * file does not by itself cause the resulting executable to be covered by
23 | * the GNU General Public License. This exception does not however
24 | * invalidate any other reasons why the executable file might be covered by
25 | * the GNU General Public License.
26 | *
27 | * Copyright 2018 Arduino SA (http://www.arduino.cc/)
28 | */
29 |
30 | package cc.arduino.packages.discoverers;
31 |
32 | public class PluggableDiscoveryMessage {
33 | private String eventType; // "add", "remove", "error"
34 | private String message; // optional message, e.g. "START_SYNC not supported"
35 |
36 | public String getEventType() {
37 | return eventType;
38 | }
39 |
40 | public String getMessage() {
41 | return message;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/arduino-core/src/cc/arduino/contributions/libraries/ContributedLibraryDependency.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Arduino.
3 | *
4 | * Copyright 2014 Arduino LLC (http://www.arduino.cc/)
5 | *
6 | * Arduino is free software; you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation; either version 2 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 | *
20 | * As a special exception, you may use this file as part of a free software
21 | * library without restriction. Specifically, if other files instantiate
22 | * templates or use macros or inline functions from this file, or you compile
23 | * this file and link it with other files to produce an executable, this
24 | * file does not by itself cause the resulting executable to be covered by
25 | * the GNU General Public License. This exception does not however
26 | * invalidate any other reasons why the executable file might be covered by
27 | * the GNU General Public License.
28 | */
29 |
30 | package cc.arduino.contributions.libraries;
31 |
32 | public class ContributedLibraryDependency {
33 |
34 | private String name;
35 | private String version;
36 |
37 | public String getName() { return name; }
38 |
39 | public String getVersion() { return version; }
40 |
41 | @Override
42 | public String toString() {
43 | return getName() + " " + getVersion();
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/app/src/cc/arduino/view/JMenuUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Arduino.
3 | *
4 | * Arduino is free software; you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation; either version 2 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 | *
18 | * As a special exception, you may use this file as part of a free software
19 | * library without restriction. Specifically, if other files instantiate
20 | * templates or use macros or inline functions from this file, or you compile
21 | * this file and link it with other files to produce an executable, this
22 | * file does not by itself cause the resulting executable to be covered by
23 | * the GNU General Public License. This exception does not however
24 | * invalidate any other reasons why the executable file might be covered by
25 | * the GNU General Public License.
26 | *
27 | * Copyright 2015 Arduino LLC (http://www.arduino.cc/)
28 | */
29 |
30 | package cc.arduino.view;
31 |
32 | import javax.swing.*;
33 | import java.awt.*;
34 |
35 | public class JMenuUtils {
36 |
37 | public static JMenu findSubMenuWithLabel(JMenu menu, String text) {
38 | for (Component submenu : menu.getMenuComponents()) {
39 | if (submenu instanceof JMenu && text.equals(((JMenu) submenu).getText())) {
40 | return (JMenu) submenu;
41 | }
42 | }
43 | return null;
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/app/testdata/libraries/SD_1.1.1/SD/examples/Files/Files.ino:
--------------------------------------------------------------------------------
1 | /*
2 | SD card basic file example
3 |
4 | This example shows how to create and destroy an SD card file
5 | The circuit:
6 | * SD card attached to SPI bus as follows:
7 | ** MOSI - pin 11
8 | ** MISO - pin 12
9 | ** CLK - pin 13
10 | ** CS - pin 4 (for MKRZero SD: SDCARD_SS_PIN)
11 |
12 | created Nov 2010
13 | by David A. Mellis
14 | modified 9 Apr 2012
15 | by Tom Igoe
16 |
17 | This example code is in the public domain.
18 |
19 | */
20 | #include
21 | #include
22 |
23 | File myFile;
24 |
25 | void setup() {
26 | // Open serial communications and wait for port to open:
27 | Serial.begin(9600);
28 | while (!Serial) {
29 | ; // wait for serial port to connect. Needed for native USB port only
30 | }
31 |
32 |
33 | Serial.print("Initializing SD card...");
34 |
35 | if (!SD.begin(4)) {
36 | Serial.println("initialization failed!");
37 | return;
38 | }
39 | Serial.println("initialization done.");
40 |
41 | if (SD.exists("example.txt")) {
42 | Serial.println("example.txt exists.");
43 | } else {
44 | Serial.println("example.txt doesn't exist.");
45 | }
46 |
47 | // open a new file and immediately close it:
48 | Serial.println("Creating example.txt...");
49 | myFile = SD.open("example.txt", FILE_WRITE);
50 | myFile.close();
51 |
52 | // Check to see if the file exists:
53 | if (SD.exists("example.txt")) {
54 | Serial.println("example.txt exists.");
55 | } else {
56 | Serial.println("example.txt doesn't exist.");
57 | }
58 |
59 | // delete the file:
60 | Serial.println("Removing example.txt...");
61 | SD.remove("example.txt");
62 |
63 | if (SD.exists("example.txt")) {
64 | Serial.println("example.txt exists.");
65 | } else {
66 | Serial.println("example.txt doesn't exist.");
67 | }
68 | }
69 |
70 | void loop() {
71 | // nothing happens after setup finishes.
72 | }
73 |
74 |
75 |
76 |
--------------------------------------------------------------------------------
/app/testdata/libraries/SD_1.2.1/SD/examples/Files/Files.ino:
--------------------------------------------------------------------------------
1 | /*
2 | SD card basic file example
3 |
4 | This example shows how to create and destroy an SD card file
5 | The circuit:
6 | * SD card attached to SPI bus as follows:
7 | ** MOSI - pin 11
8 | ** MISO - pin 12
9 | ** CLK - pin 13
10 | ** CS - pin 4 (for MKRZero SD: SDCARD_SS_PIN)
11 |
12 | created Nov 2010
13 | by David A. Mellis
14 | modified 9 Apr 2012
15 | by Tom Igoe
16 |
17 | This example code is in the public domain.
18 |
19 | */
20 | #include
21 | #include
22 |
23 | File myFile;
24 |
25 | void setup() {
26 | // Open serial communications and wait for port to open:
27 | Serial.begin(9600);
28 | while (!Serial) {
29 | ; // wait for serial port to connect. Needed for native USB port only
30 | }
31 |
32 |
33 | Serial.print("Initializing SD card...");
34 |
35 | if (!SD.begin(4)) {
36 | Serial.println("initialization failed!");
37 | while (1);
38 | }
39 | Serial.println("initialization done.");
40 |
41 | if (SD.exists("example.txt")) {
42 | Serial.println("example.txt exists.");
43 | } else {
44 | Serial.println("example.txt doesn't exist.");
45 | }
46 |
47 | // open a new file and immediately close it:
48 | Serial.println("Creating example.txt...");
49 | myFile = SD.open("example.txt", FILE_WRITE);
50 | myFile.close();
51 |
52 | // Check to see if the file exists:
53 | if (SD.exists("example.txt")) {
54 | Serial.println("example.txt exists.");
55 | } else {
56 | Serial.println("example.txt doesn't exist.");
57 | }
58 |
59 | // delete the file:
60 | Serial.println("Removing example.txt...");
61 | SD.remove("example.txt");
62 |
63 | if (SD.exists("example.txt")) {
64 | Serial.println("example.txt exists.");
65 | } else {
66 | Serial.println("example.txt doesn't exist.");
67 | }
68 | }
69 |
70 | void loop() {
71 | // nothing happens after setup finishes.
72 | }
73 |
74 |
75 |
76 |
--------------------------------------------------------------------------------
/app/testdata/libraries/Bridge_1.6.3/Bridge/examples/ShellCommands/ShellCommands.ino:
--------------------------------------------------------------------------------
1 | /*
2 | Running shell commands using Process class.
3 |
4 | This sketch demonstrate how to run linux shell commands
5 | using a YunShield/Yún. It runs the wifiCheck script on the Linux side
6 | of the Yún, then uses grep to get just the signal strength line.
7 | Then it uses parseInt() to read the wifi signal strength as an integer,
8 | and finally uses that number to fade an LED using analogWrite().
9 |
10 | The circuit:
11 | * YunShield/Yún with LED connected to pin 9
12 |
13 | created 12 Jun 2013
14 | by Cristian Maglie
15 | modified 25 June 2013
16 | by Tom Igoe
17 |
18 | This example code is in the public domain.
19 |
20 | http://www.arduino.cc/en/Tutorial/ShellCommands
21 |
22 | */
23 |
24 | #include
25 |
26 | void setup() {
27 | Bridge.begin(); // Initialize the Bridge
28 | SerialUSB.begin(9600); // Initialize the Serial
29 |
30 | // Wait until a Serial Monitor is connected.
31 | while (!SerialUSB);
32 | }
33 |
34 | void loop() {
35 | Process p;
36 | // This command line runs the WifiStatus script, (/usr/bin/pretty-wifi-info.lua), then
37 | // sends the result to the grep command to look for a line containing the word
38 | // "Signal:" the result is passed to this sketch:
39 | p.runShellCommand("/usr/bin/pretty-wifi-info.lua | grep Signal");
40 |
41 | // do nothing until the process finishes, so you get the whole output:
42 | while (p.running());
43 |
44 | // Read command output. runShellCommand() should have passed "Signal: xx&":
45 | while (p.available()) {
46 | int result = p.parseInt(); // look for an integer
47 | int signal = map(result, 0, 100, 0, 255); // map result from 0-100 range to 0-255
48 | analogWrite(9, signal); // set the brightness of LED on pin 9
49 | SerialUSB.println(result); // print the number as well
50 | }
51 | delay(5000); // wait 5 seconds before you do it again
52 | }
53 |
--------------------------------------------------------------------------------
/app/testdata/libraries/Bridge_1.7.0/Bridge/examples/ShellCommands/ShellCommands.ino:
--------------------------------------------------------------------------------
1 | /*
2 | Running shell commands using Process class.
3 |
4 | This sketch demonstrate how to run linux shell commands
5 | using a YunShield/Yún. It runs the wifiCheck script on the Linux side
6 | of the Yún, then uses grep to get just the signal strength line.
7 | Then it uses parseInt() to read the wifi signal strength as an integer,
8 | and finally uses that number to fade an LED using analogWrite().
9 |
10 | The circuit:
11 | * YunShield/Yún with LED connected to pin 9
12 |
13 | created 12 Jun 2013
14 | by Cristian Maglie
15 | modified 25 June 2013
16 | by Tom Igoe
17 |
18 | This example code is in the public domain.
19 |
20 | http://www.arduino.cc/en/Tutorial/ShellCommands
21 |
22 | */
23 |
24 | #include
25 |
26 | void setup() {
27 | Bridge.begin(); // Initialize the Bridge
28 | SerialUSB.begin(9600); // Initialize the Serial
29 |
30 | // Wait until a Serial Monitor is connected.
31 | while (!SerialUSB);
32 | }
33 |
34 | void loop() {
35 | Process p;
36 | // This command line runs the WifiStatus script, (/usr/bin/pretty-wifi-info.lua), then
37 | // sends the result to the grep command to look for a line containing the word
38 | // "Signal:" the result is passed to this sketch:
39 | p.runShellCommand("/usr/bin/pretty-wifi-info.lua | grep Signal");
40 |
41 | // do nothing until the process finishes, so you get the whole output:
42 | while (p.running());
43 |
44 | // Read command output. runShellCommand() should have passed "Signal: xx&":
45 | while (p.available()) {
46 | int result = p.parseInt(); // look for an integer
47 | int signal = map(result, 0, 100, 0, 255); // map result from 0-100 range to 0-255
48 | analogWrite(9, signal); // set the brightness of LED on pin 9
49 | SerialUSB.println(result); // print the number as well
50 | }
51 | delay(5000); // wait 5 seconds before you do it again
52 | }
53 |
--------------------------------------------------------------------------------
/app/testdata/libraries/Bridge_1.6.3/Bridge/src/Mailbox.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2013 Arduino LLC. All right reserved.
3 |
4 | This library is free software; you can redistribute it and/or
5 | modify it under the terms of the GNU Lesser General Public
6 | License as published by the Free Software Foundation; either
7 | version 2.1 of the License, or (at your option) any later version.
8 |
9 | This library is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public
15 | License along with this library; if not, write to the Free Software
16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 | */
18 |
19 | #ifndef _MAILBOX_CLASS_H_INCLUDED_
20 | #define _MAILBOX_CLASS_H_INCLUDED_
21 |
22 | #include
23 |
24 | class MailboxClass {
25 | public:
26 | MailboxClass(BridgeClass &b = Bridge) : bridge(b) { }
27 |
28 | void begin() { }
29 | void end() { }
30 |
31 | // Receive a message and store it inside a buffer
32 | unsigned int readMessage(uint8_t *buffer, unsigned int size);
33 | // Receive a message and store it inside a String
34 | void readMessage(String &str, unsigned int maxLength = 128);
35 |
36 | // Send a message
37 | void writeMessage(const uint8_t *buffer, unsigned int size);
38 | // Send a message
39 | void writeMessage(const String& str);
40 | // Send a JSON message
41 | void writeJSON(const String& str);
42 |
43 | // Return the size of the next available message, 0 if there are
44 | // no messages in queue.
45 | unsigned int messageAvailable();
46 |
47 | private:
48 | BridgeClass &bridge;
49 | };
50 |
51 | extern MailboxClass Mailbox;
52 |
53 | #endif // _MAILBOX_CLASS_H_INCLUDED_
54 |
--------------------------------------------------------------------------------
/app/testdata/libraries/Bridge_1.7.0/Bridge/src/Mailbox.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2013 Arduino LLC. All right reserved.
3 |
4 | This library is free software; you can redistribute it and/or
5 | modify it under the terms of the GNU Lesser General Public
6 | License as published by the Free Software Foundation; either
7 | version 2.1 of the License, or (at your option) any later version.
8 |
9 | This library is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public
15 | License along with this library; if not, write to the Free Software
16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 | */
18 |
19 | #ifndef _MAILBOX_CLASS_H_INCLUDED_
20 | #define _MAILBOX_CLASS_H_INCLUDED_
21 |
22 | #include
23 |
24 | class MailboxClass {
25 | public:
26 | MailboxClass(BridgeClass &b = Bridge) : bridge(b) { }
27 |
28 | void begin() { }
29 | void end() { }
30 |
31 | // Receive a message and store it inside a buffer
32 | unsigned int readMessage(uint8_t *buffer, unsigned int size);
33 | // Receive a message and store it inside a String
34 | void readMessage(String &str, unsigned int maxLength = 128);
35 |
36 | // Send a message
37 | void writeMessage(const uint8_t *buffer, unsigned int size);
38 | // Send a message
39 | void writeMessage(const String& str);
40 | // Send a JSON message
41 | void writeJSON(const String& str);
42 |
43 | // Return the size of the next available message, 0 if there are
44 | // no messages in queue.
45 | unsigned int messageAvailable();
46 |
47 | private:
48 | BridgeClass &bridge;
49 | };
50 |
51 | extern MailboxClass Mailbox;
52 |
53 | #endif // _MAILBOX_CLASS_H_INCLUDED_
54 |
--------------------------------------------------------------------------------
/arduino-core/src/processing/app/packages/UserLibraryFolder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Arduino.
3 | *
4 | * Copyright 2017 Arduino AG (http://www.arduino.cc/)
5 | *
6 | * Arduino is free software; you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation; either version 2 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 | *
20 | * As a special exception, you may use this file as part of a free software
21 | * library without restriction. Specifically, if other files instantiate
22 | * templates or use macros or inline functions from this file, or you compile
23 | * this file and link it with other files to produce an executable, this
24 | * file does not by itself cause the resulting executable to be covered by
25 | * the GNU General Public License. This exception does not however
26 | * invalidate any other reasons why the executable file might be covered by
27 | * the GNU General Public License.
28 | */
29 |
30 | package processing.app.packages;
31 |
32 | import java.io.File;
33 |
34 | public class UserLibraryFolder {
35 |
36 | public enum Location {
37 | SKETCHBOOK, CORE, REFERENCED_CORE, IDE_BUILTIN,
38 | }
39 |
40 | public File folder;
41 |
42 | public Location location;
43 |
44 | public UserLibraryFolder(File folder, Location location) {
45 | this.folder = folder;
46 | this.location = location;
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/arduino-core/src/cc/arduino/contributions/DownloadableContributionVersionComparator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Arduino.
3 | *
4 | * Copyright 2015 Arduino LLC (http://www.arduino.cc/)
5 | *
6 | * Arduino is free software; you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation; either version 2 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 | *
20 | * As a special exception, you may use this file as part of a free software
21 | * library without restriction. Specifically, if other files instantiate
22 | * templates or use macros or inline functions from this file, or you compile
23 | * this file and link it with other files to produce an executable, this
24 | * file does not by itself cause the resulting executable to be covered by
25 | * the GNU General Public License. This exception does not however
26 | * invalidate any other reasons why the executable file might be covered by
27 | * the GNU General Public License.
28 | */
29 |
30 | package cc.arduino.contributions;
31 |
32 | import java.util.Comparator;
33 |
34 | public class DownloadableContributionVersionComparator implements Comparator {
35 |
36 | @Override
37 | public int compare(DownloadableContribution lib1, DownloadableContribution lib2) {
38 | return VersionComparator.compareTo(lib1.getParsedVersion(), lib2.getParsedVersion());
39 | }
40 |
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/arduino-core/src/processing/app/debug/LegacyTargetPackage.java:
--------------------------------------------------------------------------------
1 | /*
2 | TargetPackage - Represents a hardware package
3 | Part of the Arduino project - http://www.arduino.cc/
4 |
5 | Copyright (c) 2011 Cristian Maglie
6 |
7 | This program is free software; you can redistribute it and/or modify
8 | it under the terms of the GNU General Public License as published by
9 | the Free Software Foundation; either version 2 of the License, or
10 | (at your option) any later version.
11 |
12 | This program is distributed in the hope that it will be useful,
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | GNU General Public License for more details.
16 |
17 | You should have received a copy of the GNU General Public License
18 | along with this program; if not, write to the Free Software Foundation,
19 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 | */
21 | package processing.app.debug;
22 |
23 | import java.util.Collection;
24 | import java.util.LinkedHashMap;
25 | import java.util.Map;
26 |
27 | public class LegacyTargetPackage implements TargetPackage {
28 |
29 | private final String id;
30 | private final Map platforms;
31 |
32 | public LegacyTargetPackage(String _id) {
33 | id = _id;
34 | platforms = new LinkedHashMap<>();
35 | }
36 |
37 | @Override
38 | public Map getPlatforms() {
39 | return platforms;
40 | }
41 |
42 | @Override
43 | public Collection platforms() {
44 | return platforms.values();
45 | }
46 |
47 | @Override
48 | public TargetPlatform get(String platform) {
49 | return platforms.get(platform);
50 | }
51 |
52 | @Override
53 | public boolean hasPlatform(TargetPlatform platform) {
54 | return platforms.containsKey(platform.getId());
55 | }
56 |
57 | @Override
58 | public String getId() {
59 | return id;
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/arduino-core/src/processing/app/i18n/python/requests/packages/urllib3/__init__.py:
--------------------------------------------------------------------------------
1 | # urllib3/__init__.py
2 | # Copyright 2008-2012 Andrey Petrov and contributors (see CONTRIBUTORS.txt)
3 | #
4 | # This module is part of urllib3 and is released under
5 | # the MIT License: http://www.opensource.org/licenses/mit-license.php
6 |
7 | """
8 | urllib3 - Thread-safe connection pooling and re-using.
9 | """
10 |
11 | __author__ = 'Andrey Petrov (andrey.petrov@shazow.net)'
12 | __license__ = 'MIT'
13 | __version__ = 'dev'
14 |
15 |
16 | from .connectionpool import (
17 | HTTPConnectionPool,
18 | HTTPSConnectionPool,
19 | connection_from_url
20 | )
21 |
22 | from . import exceptions
23 | from .filepost import encode_multipart_formdata
24 | from .poolmanager import PoolManager, ProxyManager, proxy_from_url
25 | from .response import HTTPResponse
26 | from .util import make_headers, get_host
27 |
28 |
29 | # Set default logging handler to avoid "No handler found" warnings.
30 | import logging
31 | try: # Python 2.7+
32 | from logging import NullHandler
33 | except ImportError:
34 | class NullHandler(logging.Handler):
35 | def emit(self, record):
36 | pass
37 |
38 | logging.getLogger(__name__).addHandler(NullHandler())
39 |
40 | def add_stderr_logger(level=logging.DEBUG):
41 | """
42 | Helper for quickly adding a StreamHandler to the logger. Useful for
43 | debugging.
44 |
45 | Returns the handler after adding it.
46 | """
47 | # This method needs to be in this __init__.py to get the __name__ correct
48 | # even if urllib3 is vendored within another package.
49 | logger = logging.getLogger(__name__)
50 | handler = logging.StreamHandler()
51 | handler.setFormatter(logging.Formatter('%(asctime)s %(levelname)s %(message)s'))
52 | logger.addHandler(handler)
53 | logger.setLevel(level)
54 | logger.debug('Added an stderr logging handler to logger: %s' % __name__)
55 | return handler
56 |
57 | # ... Clean up.
58 | del NullHandler
59 |
--------------------------------------------------------------------------------
/app/testdata/libraries/Bridge_1.6.3/Bridge/examples/ConsolePixel/ConsolePixel.ino:
--------------------------------------------------------------------------------
1 | /*
2 | Console Pixel
3 |
4 | An example of using YunShield/Yún board to receive data from the
5 | Console on the Yún. In this case, the board turns on an LED when
6 | it receives the character 'H', and turns off the LED when it
7 | receives the character 'L'.
8 |
9 | To see the Console, pick your Yún's name and IP address in the Port menu
10 | then open the Port Monitor. You can also see it by opening a terminal window
11 | and typing
12 | ssh root@ yourYunsName.local 'telnet localhost 6571'
13 | then pressing enter. When prompted for the password, enter it.
14 |
15 |
16 | The circuit:
17 | * LED connected from digital pin 13 to ground
18 |
19 | created 2006
20 | by David A. Mellis
21 | modified 25 Jun 2013
22 | by Tom Igoe
23 |
24 | This example code is in the public domain.
25 |
26 | http://www.arduino.cc/en/Tutorial/ConsolePixel
27 |
28 | */
29 |
30 | #include
31 |
32 | const int ledPin = 13; // the pin that the LED is attached to
33 | char incomingByte; // a variable to read incoming Console data into
34 |
35 | void setup() {
36 | Bridge.begin(); // Initialize Bridge
37 | Console.begin(); // Initialize Console
38 |
39 | // Wait for the Console port to connect
40 | while (!Console);
41 |
42 | Console.println("type H or L to turn pin 13 on or off");
43 |
44 | // initialize the LED pin as an output:
45 | pinMode(ledPin, OUTPUT);
46 | }
47 |
48 | void loop() {
49 | // see if there's incoming Console data:
50 | if (Console.available() > 0) {
51 | // read the oldest byte in the Console buffer:
52 | incomingByte = Console.read();
53 | Console.println(incomingByte);
54 | // if it's a capital H (ASCII 72), turn on the LED:
55 | if (incomingByte == 'H') {
56 | digitalWrite(ledPin, HIGH);
57 | }
58 | // if it's an L (ASCII 76) turn off the LED:
59 | if (incomingByte == 'L') {
60 | digitalWrite(ledPin, LOW);
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/app/testdata/libraries/Bridge_1.7.0/Bridge/examples/ConsolePixel/ConsolePixel.ino:
--------------------------------------------------------------------------------
1 | /*
2 | Console Pixel
3 |
4 | An example of using YunShield/Yún board to receive data from the
5 | Console on the Yún. In this case, the board turns on an LED when
6 | it receives the character 'H', and turns off the LED when it
7 | receives the character 'L'.
8 |
9 | To see the Console, pick your Yún's name and IP address in the Port menu
10 | then open the Port Monitor. You can also see it by opening a terminal window
11 | and typing
12 | ssh root@ yourYunsName.local 'telnet localhost 6571'
13 | then pressing enter. When prompted for the password, enter it.
14 |
15 |
16 | The circuit:
17 | * LED connected from digital pin 13 to ground
18 |
19 | created 2006
20 | by David A. Mellis
21 | modified 25 Jun 2013
22 | by Tom Igoe
23 |
24 | This example code is in the public domain.
25 |
26 | http://www.arduino.cc/en/Tutorial/ConsolePixel
27 |
28 | */
29 |
30 | #include
31 |
32 | const int ledPin = 13; // the pin that the LED is attached to
33 | char incomingByte; // a variable to read incoming Console data into
34 |
35 | void setup() {
36 | Bridge.begin(); // Initialize Bridge
37 | Console.begin(); // Initialize Console
38 |
39 | // Wait for the Console port to connect
40 | while (!Console);
41 |
42 | Console.println("type H or L to turn pin 13 on or off");
43 |
44 | // initialize the LED pin as an output:
45 | pinMode(ledPin, OUTPUT);
46 | }
47 |
48 | void loop() {
49 | // see if there's incoming Console data:
50 | if (Console.available() > 0) {
51 | // read the oldest byte in the Console buffer:
52 | incomingByte = Console.read();
53 | Console.println(incomingByte);
54 | // if it's a capital H (ASCII 72), turn on the LED:
55 | if (incomingByte == 'H') {
56 | digitalWrite(ledPin, HIGH);
57 | }
58 | // if it's an L (ASCII 76) turn off the LED:
59 | if (incomingByte == 'L') {
60 | digitalWrite(ledPin, LOW);
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/app/src/cc/arduino/contributions/ui/listeners/AbstractKeyListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Arduino.
3 | *
4 | * Copyright 2015 Arduino LLC (http://www.arduino.cc/)
5 | *
6 | * Arduino is free software; you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation; either version 2 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 | *
20 | * As a special exception, you may use this file as part of a free software
21 | * library without restriction. Specifically, if other files instantiate
22 | * templates or use macros or inline functions from this file, or you compile
23 | * this file and link it with other files to produce an executable, this
24 | * file does not by itself cause the resulting executable to be covered by
25 | * the GNU General Public License. This exception does not however
26 | * invalidate any other reasons why the executable file might be covered by
27 | * the GNU General Public License.
28 | */
29 |
30 | package cc.arduino.contributions.ui.listeners;
31 |
32 | import java.awt.event.KeyEvent;
33 | import java.awt.event.KeyListener;
34 |
35 | public abstract class AbstractKeyListener implements KeyListener {
36 |
37 | @Override
38 | public void keyTyped(KeyEvent keyEvent) {
39 |
40 | }
41 |
42 | @Override
43 | public void keyPressed(KeyEvent keyEvent) {
44 |
45 | }
46 |
47 | @Override
48 | public void keyReleased(KeyEvent keyEvent) {
49 |
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/app/test/processing/app/linux/UDevAdmParserTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Arduino.
3 | *
4 | * Copyright 2015 Arduino LLC (http://www.arduino.cc/)
5 | *
6 | * Arduino is free software; you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation; either version 2 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 | *
20 | * As a special exception, you may use this file as part of a free software
21 | * library without restriction. Specifically, if other files instantiate
22 | * templates or use macros or inline functions from this file, or you compile
23 | * this file and link it with other files to produce an executable, this
24 | * file does not by itself cause the resulting executable to be covered by
25 | * the GNU General Public License. This exception does not however
26 | * invalidate any other reasons why the executable file might be covered by
27 | * the GNU General Public License.
28 | */
29 |
30 | package processing.app.linux;
31 |
32 | import org.junit.Test;
33 | import processing.app.TestHelper;
34 |
35 | import static org.junit.Assert.assertEquals;
36 |
37 | public class UDevAdmParserTest {
38 |
39 | @Test
40 | public void shouldCorrectlyParse() throws Exception {
41 | String output = TestHelper.inputStreamToString(UDevAdmParserTest.class.getResourceAsStream("udev_output.txt"));
42 |
43 | assertEquals("0X2341_0X0036", new UDevAdmParser().extractVIDAndPID(output));
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/arduino-core/src/processing/app/i18n/python/requests/__init__.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | # __
4 | # /__) _ _ _ _ _/ _
5 | # / ( (- (/ (/ (- _) / _)
6 | # /
7 |
8 | """
9 | requests HTTP library
10 | ~~~~~~~~~~~~~~~~~~~~~
11 |
12 | Requests is an HTTP library, written in Python, for human beings. Basic GET
13 | usage:
14 |
15 | >>> import requests
16 | >>> r = requests.get('http://python.org')
17 | >>> r.status_code
18 | 200
19 | >>> 'Python is a programming language' in r.content
20 | True
21 |
22 | ... or POST:
23 |
24 | >>> payload = dict(key1='value1', key2='value2')
25 | >>> r = requests.post("http://httpbin.org/post", data=payload)
26 | >>> print r.text
27 | {
28 | ...
29 | "form": {
30 | "key2": "value2",
31 | "key1": "value1"
32 | },
33 | ...
34 | }
35 |
36 | The other HTTP methods are supported - see `requests.api`. Full documentation
37 | is at .
38 |
39 | :copyright: (c) 2013 by Kenneth Reitz.
40 | :license: Apache 2.0, see LICENSE for more details.
41 |
42 | """
43 |
44 | __title__ = 'requests'
45 | __version__ = '1.1.0'
46 | __build__ = 0x010100
47 | __author__ = 'Kenneth Reitz'
48 | __license__ = 'Apache 2.0'
49 | __copyright__ = 'Copyright 2013 Kenneth Reitz'
50 |
51 |
52 | from . import utils
53 | from .models import Request, Response, PreparedRequest
54 | from .api import request, get, head, post, patch, put, delete, options
55 | from .sessions import session, Session
56 | from .status_codes import codes
57 | from .exceptions import (
58 | RequestException, Timeout, URLRequired,
59 | TooManyRedirects, HTTPError, ConnectionError
60 | )
61 |
62 | # Set default logging handler to avoid "No handler found" warnings.
63 | import logging
64 | try: # Python 2.7+
65 | from logging import NullHandler
66 | except ImportError:
67 | class NullHandler(logging.Handler):
68 | def emit(self, record):
69 | pass
70 |
71 | logging.getLogger(__name__).addHandler(NullHandler())
72 |
--------------------------------------------------------------------------------
/arduino-core/src/processing/app/i18n/python/transifex.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python2
2 | #vim:set fileencoding=utf-8 sw=2 expandtab
3 |
4 | import update
5 | import requests
6 | import json
7 |
8 | class Transifex(object):
9 | def __init__(self, user, passwd):
10 | self.auth_ = (user, passwd)
11 |
12 | r = requests.get(
13 | 'http://www.transifex.com/api/2/project/'
14 | 'arduino-ide-15/resource/ide-15/?details',
15 | auth=self.auth_
16 | )
17 | r.raise_for_status()
18 | d = r.json()
19 | self.languages_ = set(lang['code'] for lang in d['available_languages'])
20 |
21 | def canonical_lang(self, lang):
22 | lang = lang.lower()
23 |
24 | for l in self.languages_:
25 | if l.lower() == lang:
26 | return l
27 |
28 | match = []
29 | for l in self.languages_:
30 | if l.split('_', 1)[0].lower() == lang:
31 | match.append(l)
32 | if len(match) > 1:
33 | raise RuntimeError('Two or more candidates for %s: %s' % (lang, ' '.join(match)))
34 | if len(match) == 0:
35 | raise RuntimeError('No language code %s' % lang)
36 | return match[0]
37 |
38 | def translation(self, lang):
39 | r = requests.get(
40 | 'https://www.transifex.com/api/2/project/arduino-ide-15/resource/ide-15/translation/%s/?file' % lang,
41 | auth=self.auth_
42 | )
43 | r.raise_for_status()
44 | r.encoding = 'utf-8' # workaround for a Transifex issue.
45 | return r.text
46 |
47 | def pull(self, lang, fname):
48 | new = self.translation(lang).encode('utf-8')
49 | new = map(lambda a: a + '\n', new.split('\n'))
50 | new = update.read_po(new)
51 |
52 | update.dump(new, fname)
53 |
54 | def push(self, lang, data):
55 | r = requests.put(
56 | 'http://www.transifex.com/api/2/project/'
57 | 'arduino-ide-15/resource/ide-15/translation/%s/' % lang,
58 | data=json.dumps({ 'content': data }),
59 | headers={ 'content-type': 'application/json' },
60 | auth=self.auth_
61 | )
62 | r.raise_for_status()
63 |
--------------------------------------------------------------------------------