8000 Change naming convention from `_member` to `member_` (fixes #1905) · smartcoder00/ArduinoJson@31ce648 · GitHub
[go: up one dir, main page]

Skip to content

Commit 31ce648

Browse files
committed
Change naming convention from _member to member_ (fixes bblanchon#1905)
1 parent 4ba9c1b commit 31ce648

Some content is hidden

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

64 files changed

+802
-794
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
ArduinoJson: change log
22
=======================
33

4+
HEAD
5+
----
6+
7+
* Fix compatibility with the Zephyr Project (issue #1905)
8+
49
v6.21.1 (2023-03-27)
510
-------
611

extras/tests/Helpers/CustomReader.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@
77
#include <sstream>
88

99
class CustomReader {
10-
std::stringstream _stream;
10+
std::stringstream stream_;
1111

1212
public:
13-
CustomReader(const char* input) : _stream(input) {}
13+
CustomReader(const char* input) : stream_(input) {}
1414
CustomReader(const CustomReader&) = delete;
1515

1616
int read() {
17-
return _stream.get();
17+
return stream_.get();
1818
}
1919

2020
size_t readBytes(char* buffer, size_t length) {
21-
_stream.read(buffer, static_cast<std::streamsize>(length));
22-
return static_cast<size_t>(_stream.gcount());
21+
stream_.read(buffer, static_cast<std::streamsize>(length));
22+
return static_cast<size_t>(stream_.gcount());
2323
}
2424
};

extras/tests/JsonDocument/BasicJsonDocument.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,41 +10,41 @@
1010

1111
class SpyingAllocator {
1212
public:
13-
SpyingAllocator(const SpyingAllocator& src) : _log(src._log) {}
14-
SpyingAllocator(std::ostream& log) : _log(log) {}
13+
SpyingAllocator(const SpyingAllocator& src) : log_(src.log_) {}
14+
SpyingAllocator(std::ostream& log) : log_(log) {}
1515
SpyingAllocator& operator=(const SpyingAllocator& src) = delete;
1616

1717
void* allocate(size_t n) {
18-
_log << "A" << n;
18+
log_ << "A" << n;
1919
return malloc(n);
2020
}
2121
void deallocate(void* p) {
22-
_log << "F";
22+
log_ << "F";
2323
free(p);
2424
}
2525

2626
private:
27-
std::ostream& _log;
27+
std::ostream& log_;
2828
};
2929

3030
class ControllableAllocator {
3131
public:
32-
ControllableAllocator() : _enabled(true) {}
32+
ControllableAllocator() : enabled_(true) {}
3333

3434
void* allocate(size_t n) {
35-
return _enabled ? malloc(n) : 0;
35+
return enabled_ ? malloc(n) : 0;
3636
}
3737

3838
void deallocate(void* p) {
3939
free(p);
4040
}
4141

4242
void disable() {
43-
_enabled = false;
43+
enabled_ = false;
4444
}
4545

4646
private:
47-
bool _enabled;
47+
bool enabled_;
4848
};
4949

5050
TEST_CASE("BasicJsonDocument") {

extras/tests/JsonDocument/shrinkToFit.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,36 +10,36 @@
1010

1111
class ArmoredAllocator {
1212
public:
13-
ArmoredAllocator() : _ptr(0), _size(0) {}
13+
ArmoredAllocator() : ptr_(0), size_(0) {}
1414

1515
void* allocate(size_t size) {
16-
_ptr = malloc(size);
17-
_size = size;
18-
return _ptr;
16+
ptr_ = malloc(size);
17+
size_ = size;
18+
return ptr_;
1919
}
2020

2121
void deallocate(void* ptr) {
22-
REQUIRE(ptr == _ptr);
22+
REQUIRE(ptr == ptr_);
2323
free(ptr);
24-
_ptr = 0;
25-
_size = 0;
24+
ptr_ = 0;
25+
size_ = 0;
2626
}
2727

2828
void* reallocate(void* ptr, size_t new_size) {
29-
REQUIRE(ptr == _ptr);
29+
REQUIRE(ptr == ptr_);
3030
// don't call realloc, instead alloc a new buffer and erase the old one
3131
// this way we make sure we support relocation
3232
void* new_ptr = malloc(new_size);
33-
memcpy(new_ptr, _ptr, std::min(new_size, _size));
34-
memset(_ptr, '#', _size); // erase
35-
free(_ptr);
36-
_ptr = new_ptr;
33+
memcpy(new_ptr, ptr_, std::min(new_size, size_));
34+
memset(ptr_, '#', size_); // erase
35+
free(ptr_);
36+
ptr_ = new_ptr;
3737
return new_ptr;
3838
}
3939

4040
private:
41-
void* _ptr;
42-
size_t _size;
41+
void* ptr_;
42+
size_t size_;
4343
};
4444

4545
typedef BasicJsonDocument<ArmoredAllocator> ShrinkToFitTestDocument;

extras/tests/JsonSerializer/CustomWriter.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,21 @@ class CustomWriter {
1212
CustomWriter& operator=(const CustomWriter&) = delete;
1313

1414
size_t write(uint8_t c) {
15-
_str.append(1, static_cast<char>(c));
15+
str_.append(1, static_cast<char>(c));
1616
return 1;
1717
}
1818

1919
size_t write(const uint8_t* s, size_t n) {
20-
_str.append(reinterpret_cast<const char*>(s), n);
20+
str_.append(reinterpret_cast<const char*>(s), n);
2121
return n;
2222
}
2323

2424
const std::string& str() const {
25-
return _str;
25+
return str_;
2626
}
2727

2828
private:
29-
std::string _str;
29+
std::string str_;
3030
};
3131

3232
TEST_CASE("CustomWriter") {

extras/tests/JsonVariant/converters.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,18 +74,18 @@ TEST_CASE("Custom converter with overloading") {
7474

7575
class Complex {
7676
public:
77-
explicit Complex(double r, double i) : _real(r), _imag(i) {}
77+
explicit Complex(double r, double i) : real_(r), imag_(i) {}
7878

7979
double real() const {
80-
return _real;
80+
return real_;
8181
}
8282

8383
double imag() const {
84-
return _imag;
84+
return imag_;
8585
}
8686

8787
private:
88-
double _real, _imag;
88+
double real_, imag_;
8989
};
9090

9191
namespace ArduinoJson {

extras/tests/Misc/Readers.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,19 +170,19 @@ TEST_CASE("IteratorReader") {
170170

171171
class StreamStub : public Stream {
172172
public:
173-
StreamStub(const char* s) : _stream(s) {}
173+
StreamStub(const char* s) : stream_(s) {}
174174

175175
int read() {
176-
return _stream.get();
176+
return stream_.get();
177177
}
178178

179179
size_t readBytes(char* buffer, size_t length) {
180-
_stream.read(buffer, static_cast<std::streamsize>(length));
181-
return static_cast<size_t>(_stream.gcount());
180+
stream_.read(buffer, static_cast<std::streamsize>(length));
181+
return static_cast<size_t>(stream_.gcount());
182182
}
183183

184184
private:
185-
std::istringstream _stream;
185+
std::istringstream stream_;
186186
};
187187

188188
TEST_CASE("Reader<Stream>") {

extras/tests/Misc/conflicts.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,8 @@
5252
#define BLOCKSIZE
5353
#define CAPACITY
5454

55+
// issue #1905
56+
#define _current
57+
5558
// catch.hpp mutes several warnings, this file also allows to detect them
5659
#include "ArduinoJson.h"

extras/tests/Misc/printable.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,21 @@ struct PrintAllAtOnce {
2929

3030
template <typename PrintPolicy>
3131
struct PrintableString : public Printable {
32-
PrintableString(const char* s) : _str(s), _total(0) {}
32+
PrintableString(const char* s) : str_(s), total_(0) {}
3333

3434
virtual size_t printTo(Print& p) const {
35-
size_t result = PrintPolicy::printStringTo(_str, p);
36-
_total += result;
35+
size_t result = PrintPolicy::printStringTo(str_, p);
36+
total_ += result;
3737
return result;
3838
}
3939

4040
size_t totalBytesWritten() const {
41-
return _total;
41+
return total_;
4242
}
4343

4444
private:
45-
std::string _str;
46-
mutable size_t _total;
45+
std::string str_;
46+
mutable size_t total_;
4747
};
4848

4949
TEST_CASE("Printable") {

src/ArduinoJson/Array/ElementProxy.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ class ElementProxy : public VariantRefBase<ElementProxy<TUpstream>>,
1717

1818
public:
1919
ElementProxy(TUpstream upstream, size_t index)
20-
: _upstream(upstream), _index(index) {}
20+
: upstream_(upstream), index_(index) {}
2121

2222
ElementProxy(const ElementProxy& src)
23-
: _upstream(src._upstream), _index(src._index) {}
23+
: upstream_(src.upstream_), index_(src.index_) {}
2424

2525
FORCE_INLINE ElementProxy& operator=(const ElementProxy& src) {
2626
this->set(src);
@@ -41,20 +41,20 @@ class ElementProxy : public VariantRefBase<ElementProxy<TUpstream>>,
4141

4242
private:
4343
FORCE_INLINE MemoryPool* getPool() const {
44-
return VariantAttorney::getPool(_upstream);
44+
return VariantAttorney::getPool(upstream_);
4545
}
4646

4747
FORCE_INLINE VariantData* getData() const {
48-
return variantGetElement(VariantAttorney::getData(_upstream), _index);
48+
return variantGetElement(VariantAttorney::getData(upstream_), index_);
4949
}
5050

5151
FORCE_INLINE VariantData* getOrCreateData() const {
52-
return variantGetOrAddElement(VariantAttorney::getOrCreateData(_upstream),
53-
_index, VariantAttorney::getPool(_upstream));
52+
return variantGetOrAddElement(VariantAttorney::getOrCreateData(upstream_),
53+
index_, VariantAttorney::getPool(upstream_));
5454
}
5555

56-
TUpstream _upstream;
57-
size_t _index;
56+
TUpstream upstream_;
57+
size_t index_;
5858
};
5959

6060
ARDUINOJSON_END_PRIVATE_NAMESPACE

0 commit comments

Comments
 (0)
0