Skip to content

Commit 1c9f9c3

Browse files
committed
Merge pull request #1713 from esp8266/core_cleanup
Clean up core files
2 parents aa67d1c + 1f32b7f commit 1c9f9c3

File tree

8 files changed

+634
-582
lines changed

8 files changed

+634
-582
lines changed

cores/esp8266/FS.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
#ifndef FS_H
2222
#define FS_H
2323

24-
#include <Arduino.h>
2524
#include <memory>
25+
#include <Arduino.h>
2626

2727
namespace fs {
2828

cores/esp8266/Print.cpp

+31-35
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
/*
22
Print.cpp - Base class that provides print() and println()
33
Copyright (c) 2008 David A. Mellis. All right reserved.
4-
4+
55
This library is free software; you can redistribute it and/or
66
modify it under the terms of the GNU Lesser General Public
77
License as published by the Free Software Foundation; either
88
version 2.1 of the License, or (at your option) any later version.
9-
9+
1010
This library is distributed in the hope that it will be useful,
1111
but WITHOUT ANY WARRANTY; without even the implied warranty of
1212
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1313
Lesser General Public License for more details.
14-
14+
1515
You should have received a copy of the GNU Lesser General Public
1616
License along with this library; if not, write to the Free Software
1717
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18-
18+
1919
Modified 23 November 2006 by David A. Mellis
2020
Modified December 2014 by Ivan Grokhotkov
2121
Modified May 2015 by Michael C. Miller - esp8266 progmem support
@@ -25,18 +25,14 @@
2525
#include <stdio.h>
2626
#include <string.h>
2727
#include <math.h>
28-
#include "Arduino.h"
28+
#include <Arduino.h>
2929

3030
#include "Print.h"
31-
extern "C" {
32-
#include "c_types.h"
33-
#include "ets_sys.h"
34-
}
3531

3632
// Public Methods //////////////////////////////////////////////////////////////
3733

3834
/* default implementation: may be overridden */
39-
size_t ICACHE_FLASH_ATTR Print::write(const uint8_t *buffer, size_t size) {
35+
size_t Print::write(const uint8_t *buffer, size_t size) {
4036
size_t n = 0;
4137
while(size--) {
4238
n += write(*buffer++);
@@ -67,7 +63,7 @@ size_t Print::printf(const char *format, ...) {
6763
return len;
6864
}
6965

70-
size_t ICACHE_FLASH_ATTR Print::print(const __FlashStringHelper *ifsh) {
66+
size_t Print::print(const __FlashStringHelper *ifsh) {
7167
PGM_P p = reinterpret_cast<PGM_P>(ifsh);
7268

7369
size_t n = 0;
@@ -79,31 +75,31 @@ size_t ICACHE_FLASH_ATTR Print::print(const __FlashStringHelper *ifsh) {
7975
return n;
8076
}
8177

82-
size_t ICACHE_FLASH_ATTR Print::print(const String &s) {
78+
size_t Print::print(const String &s) {
8379
return write(s.c_str(), s.length());
8480
}
8581

86-
size_t ICACHE_FLASH_ATTR Print::print(const char str[]) {
82+
size_t Print::print(const char str[]) {
8783
return write(str);
8884
}
8985

90-
size_t ICACHE_FLASH_ATTR Print::print(char c) {
86+
size_t Print::print(char c) {
9187
return write(c);
9288
}
9389

94-
size_t ICACHE_FLASH_ATTR Print::print(unsigned char b, int base) {
90+
size_t Print::print(unsigned char b, int base) {
9591
return print((unsigned long) b, base);
9692
}
9793

98-
size_t ICACHE_FLASH_ATTR Print::print(int n, int base) {
94+
size_t Print::print(int n, int base) {
9995
return print((long) n, base);
10096
}
10197

102-
size_t ICACHE_FLASH_ATTR Print::print(unsigned int n, int base) {
98+
size_t Print::print(unsigned int n, int base) {
10399
return print((unsigned long) n, base);
104100
}
105101

106-
size_t ICACHE_FLASH_ATTR Print::print(long n, int base) {
102+
size_t Print::print(long n, int base) {
107103
if(base == 0) {
108104
return write(n);
109105
} else if(base == 10) {
@@ -118,94 +114,94 @@ size_t ICACHE_FLASH_ATTR Print::print(long n, int base) {
118114
}
119115
}
120116

121-
size_t ICACHE_FLASH_ATTR Print::print(unsigned long n, int base) {
117+
size_t Print::print(unsigned long n, int base) {
122118
if(base == 0)
123119
return write(n);
124120
else
125121
return printNumber(n, base);
126122
}
127123

128-
size_t ICACHE_FLASH_ATTR Print::print(double n, int digits) {
124+
size_t Print::print(double n, int digits) {
129125
return printFloat(n, digits);
130126
}
131127

132-
size_t ICACHE_FLASH_ATTR Print::println(const __FlashStringHelper *ifsh) {
128+
size_t Print::println(const __FlashStringHelper *ifsh) {
133129
size_t n = print(ifsh);
134130
n += println();
135131
return n;
136132
}
137133

138-
size_t ICACHE_FLASH_ATTR Print::print(const Printable& x) {
134+
size_t Print::print(const Printable& x) {
139135
return x.printTo(*this);
140136
}
141137

142-
size_t ICACHE_FLASH_ATTR Print::println(void) {
138+
size_t Print::println(void) {
143139
return print("\r\n");
144140
}
145141

146-
size_t ICACHE_FLASH_ATTR Print::println(const String &s) {
142+
size_t Print::println(const String &s) {
147143
size_t n = print(s);
148144
n += println();
149145
return n;
150146
}
151147

152-
size_t ICACHE_FLASH_ATTR Print::println(const char c[]) {
148+
size_t Print::println(const char c[]) {
153149
size_t n = print(c);
154150
n += println();
155151
return n;
156152
}
157153

158-
size_t ICACHE_FLASH_ATTR Print::println(char c) {
154+
size_t Print::println(char c) {
159155
size_t n = print(c);
160156
n += println();
161157
return n;
162158
}
163159

164-
size_t ICACHE_FLASH_ATTR Print::println(unsigned char b, int base) {
160+
size_t Print::println(unsigned char b, int base) {
165161
size_t n = print(b, base);
166162
n += println();
167163
return n;
168164
}
169165

170-
size_t ICACHE_FLASH_ATTR Print::println(int num, int base) {
166+
size_t Print::println(int num, int base) {
171167
size_t n = print(num, base);
172168
n += println();
173169
return n;
174170
}
175171

176-
size_t ICACHE_FLASH_ATTR Print::println(unsigned int num, int base) {
172+
size_t Print::println(unsigned int num, int base) {
177173
size_t n = print(num, base);
178174
n += println();
179175
return n;
180176
}
181177

182-
size_t ICACHE_FLASH_ATTR Print::println(long num, int base) {
178+
size_t Print::println(long num, int base) {
183179
size_t n = print(num, base);
184180
n += println();
185181
return n;
186182
}
187183

188-
size_t ICACHE_FLASH_ATTR Print::println(unsigned long num, int base) {
184+
size_t Print::println(unsigned long num, int base) {
189185
size_t n = print(num, base);
190186
n += println();
191187
return n;
192188
}
193189

194-
size_t ICACHE_FLASH_ATTR Print::println(double num, int digits) {
190+
size_t Print::println(double num, int digits) {
195191
size_t n = print(num, digits);
196192
n += println();
197193
return n;
198194
}
199195

200-
size_t ICACHE_FLASH_ATTR Print::println(const Printable& x) {
196+
size_t Print::println(const Printable& x) {
201197
size_t n = print(x);
202198
n += println();
203199
return n;
204200
}
205201

206202
// Private Methods /////////////////////////////////////////////////////////////
207203

208-
size_t ICACHE_FLASH_ATTR Print::printNumber(unsigned long n, uint8_t base) {
204+
size_t Print::printNumber(unsigned long n, uint8_t base) {
209205
char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte.
210206
char *str = &buf[sizeof(buf) - 1];
211207

@@ -225,7 +221,7 @@ size_t ICACHE_FLASH_ATTR Print::printNumber(unsigned long n, uint8_t base) {
225221
return write(str);
226222
}
227223

228-
size_t ICACHE_FLASH_ATTR Print::printFloat(double number, uint8_t digits) {
224+
size_t Print::printFloat(double number, uint8_t digits) {
229225
size_t n = 0;
230226

231227
if(isnan(number))

cores/esp8266/Stream.cpp

+18-21
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,13 @@
2020
parsing functions based on TextFinder library by Michael Margolis
2121
*/
2222

23-
#include "Arduino.h"
24-
#include "Stream.h"
25-
extern "C" {
26-
#include "c_types.h"
27-
}
23+
#include <Arduino.h>
24+
#include <Stream.h>
2825
#define PARSE_TIMEOUT 1000 // default number of milli-seconds to wait
2926
#define NO_SKIP_CHAR 1 // a magic char not found in a valid ASCII numeric field
3027

3128
// private method to read stream with timeout
32-
int ICACHE_FLASH_ATTR Stream::timedRead() {
29+
int Stream::timedRead() {
3330
int c;
3431
_startMillis = millis();
3532
do {
@@ -42,7 +39,7 @@ int ICACHE_FLASH_ATTR Stream::timedRead() {
4239
}
4340

4441
// private method to peek stream with timeout
45-
int ICACHE_FLASH_ATTR Stream::timedPeek() {
42+
int Stream::timedPeek() {
4643
int c;
4744
_startMillis = millis();
4845
do {
@@ -56,7 +53,7 @@ int ICACHE_FLASH_ATTR Stream::timedPeek() {
5653

5754
// returns peek of the next digit in the stream or -1 if timeout
5855
// discards non-numeric characters
59-
int ICACHE_FLASH_ATTR Stream::peekNextDigit() {
56+
int Stream::peekNextDigit() {
6057
int c;
6158
while(1) {
6259
c = timedPeek();
@@ -73,31 +70,31 @@ int ICACHE_FLASH_ATTR Stream::peekNextDigit() {
7370
// Public Methods
7471
//////////////////////////////////////////////////////////////
7572

76-
void ICACHE_FLASH_ATTR Stream::setTimeout(unsigned long timeout) // sets the maximum number of milliseconds to wait
73+
void Stream::setTimeout(unsigned long timeout) // sets the maximum number of milliseconds to wait
7774
{
7875
_timeout = timeout;
7976
}
8077

8178
// find returns true if the target string is found
82-
bool ICACHE_FLASH_ATTR Stream::find(const char *target) {
79+
bool Stream::find(const char *target) {
8380
return findUntil(target, (char*) "");
8481
}
8582

8683
// reads data from the stream until the target string of given length is found
8784
// returns true if target string is found, false if timed out
88-
bool ICACHE_FLASH_ATTR Stream::find(const char *target, size_t length) {
85+
bool Stream::find(const char *target, size_t length) {
8986
return findUntil(target, length, NULL, 0);
9087
}
9188

9289
// as find but search ends if the terminator string is found
93-
bool ICACHE_FLASH_ATTR Stream::findUntil(const char *target, const char *terminator) {
90+
bool Stream::findUntil(const char *target, const char *terminator) {
9491
return findUntil(target, strlen(target), terminator, strlen(terminator));
9592
}
9693

9794
// reads data from the stream until the target string of the given length is found
9895
// search terminated if the terminator string is found
9996
// returns true if target string is found, false if terminated or timed out
100-
bool ICACHE_FLASH_ATTR Stream::findUntil(const char *target, size_t targetLen, const char *terminator, size_t termLen) {
97+
bool Stream::findUntil(const char *target, size_t targetLen, const char *terminator, size_t termLen) {
10198
size_t index = 0; // maximum target string length is 64k bytes!
10299
size_t termIndex = 0;
103100
int c;
@@ -128,13 +125,13 @@ bool ICACHE_FLASH_ATTR Stream::findUntil(const char *target, size_t targetLen, c
128125
// returns the first valid (long) integer value from the current position.
129126
// initial characters that are not digits (or the minus sign) are skipped
130127
// function is terminated by the first character that is not a digit.
131-
long ICACHE_FLASH_ATTR Stream::parseInt() {
128+
long Stream::parseInt() {
132129
return parseInt(NO_SKIP_CHAR); // terminate on first non-digit character (or timeout)
133130
}
134131

135132
// as above but a given skipChar is ignored
136133
// this allows format characters (typically commas) in values to be ignored
137-
long ICACHE_FLASH_ATTR Stream::parseInt(char skipChar) {
134+
long Stream::parseInt(char skipChar) {
138135
boolean isNegative = false;
139136
long value = 0;
140137
int c;
@@ -161,13 +158,13 @@ long ICACHE_FLASH_ATTR Stream::parseInt(char skipChar) {
161158
}
162159

163160
// as parseInt but returns a floating point value
164-
float ICACHE_FLASH_ATTR Stream::parseFloat() {
161+
float Stream::parseFloat() {
165162
return parseFloat(NO_SKIP_CHAR);
166163
}
167164

168165
// as above but the given skipChar is ignored
169166
// this allows format characters (typically commas) in values to be ignored
170-
float ICACHE_FLASH_ATTR Stream::parseFloat(char skipChar) {
167+
float Stream::parseFloat(char skipChar) {
171168
boolean isNegative = false;
172169
boolean isFraction = false;
173170
long value = 0;
@@ -208,7 +205,7 @@ float ICACHE_FLASH_ATTR Stream::parseFloat(char skipChar) {
208205
// returns the number of characters placed in the buffer
209206
// the buffer is NOT null terminated.
210207
//
211-
size_t ICACHE_FLASH_ATTR Stream::readBytes(char *buffer, size_t length) {
208+
size_t Stream::readBytes(char *buffer, size_t length) {
212209
size_t count = 0;
213210
while(count < length) {
214211
int c = timedRead();
@@ -224,7 +221,7 @@ size_t ICACHE_FLASH_ATTR Stream::readBytes(char *buffer, size_t length) {
224221
// terminates if length characters have been read, timeout, or if the terminator character detected
225222
// returns the number of characters placed in the buffer (0 means no valid data found)
226223

227-
size_t ICACHE_FLASH_ATTR Stream::readBytesUntil(char terminator, char *buffer, size_t length) {
224+
size_t Stream::readBytesUntil(char terminator, char *buffer, size_t length) {
228225
if(length < 1)
229226
return 0;
230227
size_t index = 0;
@@ -238,7 +235,7 @@ size_t ICACHE_FLASH_ATTR Stream::readBytesUntil(char terminator, char *buffer, s
238235
return index; // return number of characters, not including null terminator
239236
}
240237

241-
String ICACHE_FLASH_ATTR Stream::readString() {
238+
String Stream::readString() {
242239
String ret;
243240
int c = timedRead();
244241
while(c >= 0) {
@@ -248,7 +245,7 @@ String ICACHE_FLASH_ATTR Stream::readString() {
248245
return ret;
249246
}
250247

251-
String ICACHE_FLASH_ATTR Stream::readStringUntil(char terminator) {
248+
String Stream::readStringUntil(char terminator) {
252249
String ret;
253250
int c = timedRead();
254251
while(c >= 0 && c != terminator) {

0 commit comments

Comments
 (0)