arduino_ci 0.1.20 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +21 -19
- data/REFERENCE.md +625 -0
- data/cpp/arduino/Arduino.h +1 -2
- data/cpp/arduino/AvrMath.h +117 -17
- data/cpp/arduino/Client.h +26 -0
- data/cpp/arduino/EEPROM.h +64 -0
- data/cpp/arduino/Godmode.cpp +38 -19
- data/cpp/arduino/Godmode.h +88 -22
- data/cpp/arduino/HardwareSerial.h +9 -28
- data/cpp/arduino/IPAddress.h +59 -0
- data/cpp/arduino/MockEventQueue.h +86 -0
- data/cpp/arduino/PinHistory.h +64 -24
- data/cpp/arduino/Print.h +9 -12
- data/cpp/arduino/Printable.h +8 -0
- data/cpp/arduino/SPI.h +11 -3
- data/cpp/arduino/Server.h +5 -0
- data/cpp/arduino/Udp.h +27 -0
- data/cpp/arduino/Wire.h +234 -0
- data/cpp/arduino/avr/io.h +10 -1
- data/cpp/arduino/avr/pgmspace.h +76 -46
- data/cpp/arduino/ci/StreamTape.h +36 -0
- data/cpp/unittest/ArduinoUnitTests.h +1 -0
- data/cpp/unittest/Compare.h +91 -897
- data/cpp/unittest/OstreamHelpers.h +9 -0
- data/exe/arduino_ci.rb +401 -0
- data/exe/arduino_ci_remote.rb +2 -385
- data/lib/arduino_ci.rb +1 -0
- data/lib/arduino_ci/arduino_cmd.rb +13 -9
- data/lib/arduino_ci/arduino_downloader.rb +5 -4
- data/lib/arduino_ci/arduino_installation.rb +5 -5
- data/lib/arduino_ci/ci_config.rb +12 -0
- data/lib/arduino_ci/cpp_library.rb +152 -25
- data/lib/arduino_ci/installed_cpp_library.rb +0 -0
- data/lib/arduino_ci/library_properties.rb +86 -0
- data/lib/arduino_ci/version.rb +1 -1
- data/misc/default.yml +50 -3
- metadata +23 -13
- data/cpp/arduino/Arduino.h.orig +0 -143
- data/cpp/arduino/Nullptr.h +0 -7
- data/cpp/arduino/ci/Queue.h +0 -73
- data/exe/libasan.rb +0 -29
data/lib/arduino_ci/version.rb
CHANGED
data/misc/default.yml
CHANGED
@@ -4,6 +4,7 @@
|
|
4
4
|
|
5
5
|
packages:
|
6
6
|
# arduino:xxx are builtin, we don't need to include them here
|
7
|
+
# but if we did, it would be url: https://downloads.arduino.cc/packages/package_index.json
|
7
8
|
esp8266:esp8266:
|
8
9
|
url: http://arduino.esp8266.com/stable/package_esp8266com_index.json
|
9
10
|
adafruit:avr:
|
@@ -21,7 +22,10 @@ platforms:
|
|
21
22
|
gcc:
|
22
23
|
features:
|
23
24
|
defines:
|
25
|
+
- __AVR__
|
24
26
|
- __AVR_ATmega328P__
|
27
|
+
- ARDUINO_ARCH_AVR
|
28
|
+
- ARDUINO_AVR_UNO
|
25
29
|
warnings:
|
26
30
|
flags:
|
27
31
|
due:
|
@@ -30,7 +34,10 @@ platforms:
|
|
30
34
|
gcc:
|
31
35
|
features:
|
32
36
|
defines:
|
33
|
-
-
|
37
|
+
- __SAM3X8E__
|
38
|
+
- ARDUINO_ARCH_SAM
|
39
|
+
- ARDUINO_SAM_DUE
|
40
|
+
- NUM_SERIAL_PORTS=4
|
34
41
|
warnings:
|
35
42
|
flags:
|
36
43
|
zero:
|
@@ -39,8 +46,11 @@ platforms:
|
|
39
46
|
gcc:
|
40
47
|
features:
|
41
48
|
defines:
|
42
|
-
|
43
|
-
|
49
|
+
- __SAMD21G18A__
|
50
|
+
- ARDUINO_ARCH_SAMD
|
51
|
+
- ARDUINO_SAMD_ZERO
|
52
|
+
# This also has SerialUSB, which is not included here.
|
53
|
+
- NUM_SERIAL_PORTS=2
|
44
54
|
warnings:
|
45
55
|
flags:
|
46
56
|
esp32:
|
@@ -49,6 +59,10 @@ platforms:
|
|
49
59
|
gcc:
|
50
60
|
features:
|
51
61
|
defines:
|
62
|
+
- ESP32
|
63
|
+
- ARDUINO_ARCH_ESP32
|
64
|
+
- ARDUINO_FEATHER_ESP32
|
65
|
+
- NUM_SERIAL_PORTS=3
|
52
66
|
warnings:
|
53
67
|
flags:
|
54
68
|
esp8266:
|
@@ -57,6 +71,10 @@ platforms:
|
|
57
71
|
gcc:
|
58
72
|
features:
|
59
73
|
defines:
|
74
|
+
- ESP8266
|
75
|
+
- ARDUINO_ARCH_ESP8266
|
76
|
+
- ARDUINO_ESP8266_ESP12
|
77
|
+
- NUM_SERIAL_PORTS=2
|
60
78
|
warnings:
|
61
79
|
flags:
|
62
80
|
leonardo:
|
@@ -65,7 +83,10 @@ platforms:
|
|
65
83
|
gcc:
|
66
84
|
features:
|
67
85
|
defines:
|
86
|
+
- __AVR__
|
68
87
|
- __AVR_ATmega32U4__
|
88
|
+
- ARDUINO_ARCH_AVR
|
89
|
+
- ARDUINO_AVR_LEONARDO
|
69
90
|
warnings:
|
70
91
|
flags:
|
71
92
|
trinket:
|
@@ -74,6 +95,10 @@ platforms:
|
|
74
95
|
gcc:
|
75
96
|
features:
|
76
97
|
defines:
|
98
|
+
- __AVR__
|
99
|
+
- __AVR_ATtiny85__
|
100
|
+
- ARDUINO_ARCH_AVR
|
101
|
+
- ARDUINO_AVR_TRINKET5
|
77
102
|
warnings:
|
78
103
|
flags:
|
79
104
|
gemma:
|
@@ -82,6 +107,10 @@ platforms:
|
|
82
107
|
gcc:
|
83
108
|
features:
|
84
109
|
defines:
|
110
|
+
- __AVR__
|
111
|
+
- __AVR_ATtiny85__
|
112
|
+
- ARDUINO_ARCH_AVR
|
113
|
+
- ARDUINO_AVR_GEMMA
|
85
114
|
warnings:
|
86
115
|
flags:
|
87
116
|
m4:
|
@@ -90,6 +119,12 @@ platforms:
|
|
90
119
|
gcc:
|
91
120
|
features:
|
92
121
|
defines:
|
122
|
+
- __SAMD51__
|
123
|
+
- __SAMD51J19A__
|
124
|
+
- ARDUINO_ARCH_SAMD
|
125
|
+
- ARDUINO_METRO_M4
|
126
|
+
# Serial is actually USB virtual serial, not HardwareSerial
|
127
|
+
- NUM_SERIAL_PORTS=2
|
93
128
|
warnings:
|
94
129
|
flags:
|
95
130
|
mega2560:
|
@@ -98,7 +133,10 @@ platforms:
|
|
98
133
|
gcc:
|
99
134
|
features:
|
100
135
|
defines:
|
136
|
+
- __AVR__
|
101
137
|
- __AVR_ATmega2560__
|
138
|
+
- ARDUINO_ARCH_AVR
|
139
|
+
- ARDUINO_AVR_MEGA2560
|
102
140
|
warnings:
|
103
141
|
flags:
|
104
142
|
cplayClassic:
|
@@ -107,6 +145,10 @@ platforms:
|
|
107
145
|
gcc:
|
108
146
|
features:
|
109
147
|
defines:
|
148
|
+
- __AVR__
|
149
|
+
- __AVR_ATmega32U4__
|
150
|
+
- ARDUINO_ARCH_AVR
|
151
|
+
- ARDUINO_AVR_CIRCUITPLAY
|
110
152
|
warnings:
|
111
153
|
flags:
|
112
154
|
cplayExpress:
|
@@ -115,6 +157,11 @@ platforms:
|
|
115
157
|
gcc:
|
116
158
|
features:
|
117
159
|
defines:
|
160
|
+
- __SAMD21G18A__
|
161
|
+
- ARDUINO_ARCH_SAMD
|
162
|
+
- ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS
|
163
|
+
# Serial is actually an alias of SerialUSB, not a HardwareSerial
|
164
|
+
- NUM_SERIAL_PORTS=2
|
118
165
|
warnings:
|
119
166
|
flags:
|
120
167
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arduino_ci
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ian Katz
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-11-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: os
|
@@ -42,14 +42,14 @@ dependencies:
|
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '1.15'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1.15'
|
55
55
|
- !ruby/object:Gem::Dependency
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.0.
|
61
|
+
version: 0.0.2
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.0.
|
68
|
+
version: 0.0.2
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -110,33 +110,40 @@ dependencies:
|
|
110
110
|
version: 0.9.11
|
111
111
|
description: ''
|
112
112
|
email:
|
113
|
-
-
|
113
|
+
- arduino.continuous.integration@gmail.com
|
114
114
|
executables:
|
115
|
+
- arduino_ci.rb
|
115
116
|
- arduino_ci_remote.rb
|
116
117
|
- arduino_library_location.rb
|
117
118
|
- ensure_arduino_installation.rb
|
118
|
-
- libasan.rb
|
119
119
|
extensions: []
|
120
120
|
extra_rdoc_files: []
|
121
121
|
files:
|
122
122
|
- ".yardopts"
|
123
123
|
- README.md
|
124
|
+
- REFERENCE.md
|
124
125
|
- cpp/arduino/Arduino.cpp
|
125
126
|
- cpp/arduino/Arduino.h
|
126
|
-
- cpp/arduino/Arduino.h.orig
|
127
127
|
- cpp/arduino/ArduinoDefines.h
|
128
128
|
- cpp/arduino/AvrMath.h
|
129
|
+
- cpp/arduino/Client.h
|
130
|
+
- cpp/arduino/EEPROM.h
|
129
131
|
- cpp/arduino/Godmode.cpp
|
130
132
|
- cpp/arduino/Godmode.h
|
131
133
|
- cpp/arduino/HardwareSerial.h
|
132
|
-
- cpp/arduino/
|
134
|
+
- cpp/arduino/IPAddress.h
|
135
|
+
- cpp/arduino/MockEventQueue.h
|
133
136
|
- cpp/arduino/PinHistory.h
|
134
137
|
- cpp/arduino/Print.h
|
138
|
+
- cpp/arduino/Printable.h
|
135
139
|
- cpp/arduino/SPI.h
|
140
|
+
- cpp/arduino/Server.h
|
136
141
|
- cpp/arduino/SoftwareSerial.h
|
137
142
|
- cpp/arduino/Stream.h
|
143
|
+
- cpp/arduino/Udp.h
|
138
144
|
- cpp/arduino/WCharacter.h
|
139
145
|
- cpp/arduino/WString.h
|
146
|
+
- cpp/arduino/Wire.h
|
140
147
|
- cpp/arduino/avr/README.md
|
141
148
|
- cpp/arduino/avr/common.h
|
142
149
|
- cpp/arduino/avr/fuse.h
|
@@ -415,8 +422,8 @@ files:
|
|
415
422
|
- cpp/arduino/binary.h
|
416
423
|
- cpp/arduino/ci/DeviceUsingBytes.h
|
417
424
|
- cpp/arduino/ci/ObservableDataStream.h
|
418
|
-
- cpp/arduino/ci/Queue.h
|
419
425
|
- cpp/arduino/ci/README.md
|
426
|
+
- cpp/arduino/ci/StreamTape.h
|
420
427
|
- cpp/arduino/ci/Table.h
|
421
428
|
- cpp/arduino/stdlib.cpp
|
422
429
|
- cpp/arduino/stdlib.h
|
@@ -424,10 +431,11 @@ files:
|
|
424
431
|
- cpp/unittest/ArduinoUnitTests.h
|
425
432
|
- cpp/unittest/Assertion.h
|
426
433
|
- cpp/unittest/Compare.h
|
434
|
+
- cpp/unittest/OstreamHelpers.h
|
435
|
+
- exe/arduino_ci.rb
|
427
436
|
- exe/arduino_ci_remote.rb
|
428
437
|
- exe/arduino_library_location.rb
|
429
438
|
- exe/ensure_arduino_installation.rb
|
430
|
-
- exe/libasan.rb
|
431
439
|
- lib/arduino_ci.rb
|
432
440
|
- lib/arduino_ci/arduino_cmd.rb
|
433
441
|
- lib/arduino_ci/arduino_cmd_linux.rb
|
@@ -442,9 +450,11 @@ files:
|
|
442
450
|
- lib/arduino_ci/ci_config.rb
|
443
451
|
- lib/arduino_ci/cpp_library.rb
|
444
452
|
- lib/arduino_ci/host.rb
|
453
|
+
- lib/arduino_ci/installed_cpp_library.rb
|
454
|
+
- lib/arduino_ci/library_properties.rb
|
445
455
|
- lib/arduino_ci/version.rb
|
446
456
|
- misc/default.yml
|
447
|
-
homepage: http://github.com/
|
457
|
+
homepage: http://github.com/Arduino-CI/arduino_ci
|
448
458
|
licenses:
|
449
459
|
- Apache-2.0
|
450
460
|
metadata: {}
|
data/cpp/arduino/Arduino.h.orig
DELETED
@@ -1,143 +0,0 @@
|
|
1
|
-
#pragma once
|
2
|
-
/*
|
3
|
-
Mock Arduino.h library.
|
4
|
-
|
5
|
-
Where possible, variable names from the Arduino library are used to avoid conflicts
|
6
|
-
|
7
|
-
*/
|
8
|
-
// Chars and strings
|
9
|
-
|
10
|
-
#include "ArduinoDefines.h"
|
11
|
-
|
12
|
-
#include "WCharacter.h"
|
13
|
-
#include "WString.h"
|
14
|
-
#include "Print.h"
|
15
|
-
#include "Stream.h"
|
16
|
-
#include "HardwareSerial.h"
|
17
|
-
#include "SPI.h"
|
18
|
-
#include "Nullptr.h"
|
19
|
-
|
20
|
-
typedef bool boolean;
|
21
|
-
typedef uint8_t byte;
|
22
|
-
|
23
|
-
#include "binary.h"
|
24
|
-
|
25
|
-
// Math and Trig
|
26
|
-
#include "AvrMath.h"
|
27
|
-
|
28
|
-
#include "Godmode.h"
|
29
|
-
|
30
|
-
|
31
|
-
// Bits and Bytes
|
32
|
-
#define bit(b) (1UL << (b))
|
33
|
-
#define bitClear(value, bit) ((value) &= ~(1UL << (bit)))
|
34
|
-
#define bitRead(value, bit) (((value) >> (bit)) & 0x01)
|
35
|
-
#define bitSet(value, bit) ((value) |= (1UL << (bit)))
|
36
|
-
#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit))
|
37
|
-
#define highByte(w) ((uint8_t) ((w) >> 8))
|
38
|
-
#define lowByte(w) ((uint8_t) ((w) & 0xff))
|
39
|
-
|
40
|
-
// Arduino defines this
|
41
|
-
#define _NOP() do { 0; } while (0)
|
42
|
-
|
43
|
-
// might as well use that NO-op macro for these, while unit testing
|
44
|
-
// you need interrupts? interrupt yourself
|
45
|
-
#define yield() _NOP()
|
46
|
-
#define interrupts() _NOP()
|
47
|
-
#define noInterrupts() _NOP()
|
48
|
-
|
49
|
-
// TODO: correctly establish this per-board!
|
50
|
-
#define F_CPU 1000000UL
|
51
|
-
#define clockCyclesPerMicrosecond() ( F_CPU / 1000000L )
|
52
|
-
#define clockCyclesToMicroseconds(a) ( (a) / clockCyclesPerMicrosecond() )
|
53
|
-
#define microsecondsToClockCycles(a) ( (a) * clockCyclesPerMicrosecond() )
|
54
|
-
|
55
|
-
typedef unsigned int word;
|
56
|
-
|
57
|
-
#define bit(b) (1UL << (b))
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
/*
|
62
|
-
unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout);
|
63
|
-
unsigned long pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout);
|
64
|
-
|
65
|
-
void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val);
|
66
|
-
uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder);
|
67
|
-
|
68
|
-
*/
|
69
|
-
|
70
|
-
// Get the bit location within the hardware port of the given virtual pin.
|
71
|
-
// This comes from the pins_*.c file for the active board configuration.
|
72
|
-
|
73
|
-
#define analogInPinToBit(P) (P)
|
74
|
-
#define digitalPinToInterrupt(P) (P)
|
75
|
-
|
76
|
-
/*
|
77
|
-
// On the ATmega1280, the addresses of some of the port registers are
|
78
|
-
// greater than 255, so we can't store them in uint8_t's.
|
79
|
-
extern const uint16_t PROGMEM port_to_mode_PGM[];
|
80
|
-
extern const uint16_t PROGMEM port_to_input_PGM[];
|
81
|
-
extern const uint16_t PROGMEM port_to_output_PGM[];
|
82
|
-
|
83
|
-
extern const uint8_t PROGMEM digital_pin_to_port_PGM[];
|
84
|
-
// extern const uint8_t PROGMEM digital_pin_to_bit_PGM[];
|
85
|
-
extern const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[];
|
86
|
-
extern const uint8_t PROGMEM digital_pin_to_timer_PGM[];
|
87
|
-
|
88
|
-
// Get the bit location within the hardware port of the given virtual pin.
|
89
|
-
// This comes from the pins_*.c file for the active board configuration.
|
90
|
-
//
|
91
|
-
// These perform slightly better as macros compared to inline functions
|
92
|
-
//
|
93
|
-
#define digitalPinToPort(P) ( pgm_read_byte( digital_pin_to_port_PGM + (P) ) )
|
94
|
-
#define digitalPinToBitMask(P) ( pgm_read_byte( digital_pin_to_bit_mask_PGM + (P) ) )
|
95
|
-
#define digitalPinToTimer(P) ( pgm_read_byte( digital_pin_to_timer_PGM + (P) ) )
|
96
|
-
#define analogInPinToBit(P) (P)
|
97
|
-
#define portOutputRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_output_PGM + (P))) )
|
98
|
-
#define portInputRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_input_PGM + (P))) )
|
99
|
-
#define portModeRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_mode_PGM + (P))) )
|
100
|
-
|
101
|
-
*/
|
102
|
-
|
103
|
-
|
104
|
-
/* TODO
|
105
|
-
|
106
|
-
// USB
|
107
|
-
#include "USBAPI.h"
|
108
|
-
Keyboard
|
109
|
-
Mouse
|
110
|
-
|
111
|
-
*/
|
112
|
-
|
113
|
-
// uint16_t makeWord(uint16_t w);
|
114
|
-
// uint16_t makeWord(byte h, byte l);
|
115
|
-
inline unsigned int makeWord(unsigned int w) { return w; }
|
116
|
-
inline unsigned int makeWord(unsigned char h, unsigned char l) { return (h << 8) | l; }
|
117
|
-
|
118
|
-
#define word(...) makeWord(__VA_ARGS__)
|
119
|
-
|
120
|
-
<<<<<<< Updated upstream
|
121
|
-
|
122
|
-
=======
|
123
|
-
unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout = 1000000L);
|
124
|
-
unsigned long pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout = 1000000L);
|
125
|
-
|
126
|
-
// audio is taken care of in GODMODE
|
127
|
-
|
128
|
-
|
129
|
-
// BIG TODO ON THIS ONE
|
130
|
-
// $ find . | grep pins_
|
131
|
-
// ./arduino-1.8.5/hardware/arduino/avr/variants/circuitplay32u4/pins_arduino.h
|
132
|
-
// ./arduino-1.8.5/hardware/arduino/avr/variants/eightanaloginputs/pins_arduino.h
|
133
|
-
// ./arduino-1.8.5/hardware/arduino/avr/variants/ethernet/pins_arduino.h
|
134
|
-
// ./arduino-1.8.5/hardware/arduino/avr/variants/gemma/pins_arduino.h
|
135
|
-
// ./arduino-1.8.5/hardware/arduino/avr/variants/leonardo/pins_arduino.h
|
136
|
-
// ./arduino-1.8.5/hardware/arduino/avr/variants/mega/pins_arduino.h
|
137
|
-
// ./arduino-1.8.5/hardware/arduino/avr/variants/micro/pins_arduino.h
|
138
|
-
// ./arduino-1.8.5/hardware/arduino/avr/variants/robot_control/pins_arduino.h
|
139
|
-
// ./arduino-1.8.5/hardware/arduino/avr/variants/robot_motor/pins_arduino.h
|
140
|
-
// ./arduino-1.8.5/hardware/arduino/avr/variants/standard/pins_arduino.h
|
141
|
-
// ./arduino-1.8.5/hardware/arduino/avr/variants/yun/pins_arduino.h
|
142
|
-
// #include "pins_arduino.h"
|
143
|
-
>>>>>>> Stashed changes
|
data/cpp/arduino/Nullptr.h
DELETED
data/cpp/arduino/ci/Queue.h
DELETED
@@ -1,73 +0,0 @@
|
|
1
|
-
#pragma once
|
2
|
-
|
3
|
-
template <typename T>
|
4
|
-
class ArduinoCIQueue {
|
5
|
-
private:
|
6
|
-
struct Node {
|
7
|
-
T data;
|
8
|
-
Node* next;
|
9
|
-
};
|
10
|
-
|
11
|
-
Node* mFront;
|
12
|
-
Node* mBack;
|
13
|
-
unsigned long mSize;
|
14
|
-
T mNil;
|
15
|
-
|
16
|
-
void init() {
|
17
|
-
mFront = mBack = NULL;
|
18
|
-
mSize = 0;
|
19
|
-
}
|
20
|
-
|
21
|
-
public:
|
22
|
-
ArduinoCIQueue(): mNil() { init(); }
|
23
|
-
|
24
|
-
ArduinoCIQueue(const ArduinoCIQueue<T>& q) {
|
25
|
-
init();
|
26
|
-
for (Node* n = q.mFront; n; n = n->next) push(n->data);
|
27
|
-
}
|
28
|
-
|
29
|
-
inline unsigned long size() const { return mSize; }
|
30
|
-
|
31
|
-
inline bool empty() const { return 0 == mSize; }
|
32
|
-
|
33
|
-
T front() const { return empty() ? mNil : mFront->data; }
|
34
|
-
|
35
|
-
T back() const { return empty() ? mNil : mBack->data; }
|
36
|
-
|
37
|
-
bool push(const T& v)
|
38
|
-
{
|
39
|
-
Node *n = new Node;
|
40
|
-
if (n == NULL) return false;
|
41
|
-
|
42
|
-
n->data = v;
|
43
|
-
n->next = NULL;
|
44
|
-
|
45
|
-
if (mFront == NULL)
|
46
|
-
{
|
47
|
-
mFront = mBack = n;
|
48
|
-
} else {
|
49
|
-
mBack->next = n;
|
50
|
-
mBack = n;
|
51
|
-
}
|
52
|
-
|
53
|
-
++mSize;
|
54
|
-
return true;
|
55
|
-
}
|
56
|
-
|
57
|
-
void pop() {
|
58
|
-
if (empty()) return;
|
59
|
-
if (mFront == mBack) {
|
60
|
-
mFront = mBack = NULL;
|
61
|
-
} else {
|
62
|
-
Node* n = mFront;
|
63
|
-
mFront = mFront->next;
|
64
|
-
delete n;
|
65
|
-
}
|
66
|
-
|
67
|
-
--mSize;
|
68
|
-
}
|
69
|
-
|
70
|
-
void clear() { while (!empty()) pop(); }
|
71
|
-
|
72
|
-
~ArduinoCIQueue() { clear(); }
|
73
|
-
};
|