Skip to content

Commit 286c0c1

Browse files
authored
Merge pull request #22 from ifreecarve/2018-03-07_namespace
avoid name collisions with Queue and Table
2 parents 24333f4 + f932947 commit 286c0c1

File tree

9 files changed

+25
-22
lines changed

9 files changed

+25
-22
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
88
### Added
99

1010
### Changed
11+
- Queue and Table are now ArduinoCIQueue and ArduinoCITable to avoid name collisions
1112

1213
### Deprecated
1314

CONTRIBUTING.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ Be prepared to write tests to accompany any code you would like to see merged.
2424
* `git add README.md CHANGELOG.md lib/arduino_ci/version.rb`
2525
* `git commit -m "vVERSION bump"`
2626
* `git tag -a vVERSION -m "Released version VERSION"`
27+
* `git stash save`
2728
* `gem build arduino_ci.gemspec`
29+
* `git stash pop`
2830
* `gem push arduino_ci-VERSION.gem`
2931
* `git push upstream`
3032
* `git push upstream --tags`

SampleProjects/TestSomething/test/queue.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
unittest(basic_queue_dequeue_and_size)
55
{
6-
Queue<int> q;
6+
ArduinoCIQueue<int> q;
77
int data[5] = {11, 22, 33, 44, 55};
88

99
assertTrue(q.empty());
@@ -27,11 +27,11 @@ unittest(basic_queue_dequeue_and_size)
2727

2828
unittest(copy_constructor)
2929
{
30-
Queue<int> q;
30+
ArduinoCIQueue<int> q;
3131
int data[5] = {11, 22, 33, 44, 55};
3232
for (int i = 0; i < 5; ++i) q.push(data[i]);
3333

34-
Queue<int> q2(q);
34+
ArduinoCIQueue<int> q2(q);
3535

3636
for (int i = 0; i < 5; ++i) {
3737
assertEqual(5 - i, q2.size());

SampleProjects/TestSomething/test/table.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ void setResult3(long l, int k, int v) {
2020

2121
unittest(basic_table)
2222
{
23-
Table<String, int> t;
23+
ArduinoCITable<String, int> t;
2424
assertTrue(t.empty());
2525

2626
int data[5] = {11, 22, 33, 44, 55};
@@ -47,7 +47,7 @@ unittest(basic_table)
4747
}
4848

4949
unittest(iteration_no_arg) {
50-
Table<int, int> t;
50+
ArduinoCITable<int, int> t;
5151
for (int i = 0; i < 5; ++i) {
5252
results[i] = 0;
5353
t.add(i, 11 * (i + 1));
@@ -59,7 +59,7 @@ unittest(iteration_no_arg) {
5959
}
6060

6161
unittest(iteration_one_arg) {
62-
Table<int, int> t;
62+
ArduinoCITable<int, int> t;
6363
for (int i = 0; i < 5; ++i) {
6464
results[i] = 0;
6565
t.add(i, 11 * (i + 1));

cpp/arduino/PinHistory.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@
77
template <typename T>
88
class PinHistory : public ObservableDataStream {
99
private:
10-
Queue<T> qIn;
11-
Queue<T> qOut;
10+
ArduinoCIQueue<T> qIn;
11+
ArduinoCIQueue<T> qOut;
1212

1313
void clear() {
1414
qOut.clear();
1515
qIn.clear();
1616
}
1717

1818
// enqueue ascii bits
19-
void a2q(Queue<T> &q, String input, bool bigEndian, bool advertise) {
19+
void a2q(ArduinoCIQueue<T> &q, String input, bool bigEndian, bool advertise) {
2020
// 8 chars at a time, form up
2121
for (int j = 0; j < input.length(); ++j) {
2222
for (int i = 0; i < 8; ++i) {
@@ -31,10 +31,10 @@ class PinHistory : public ObservableDataStream {
3131

3232
// convert a queue to a string as if it was serial bits
3333
// start from offset, consider endianness
34-
String q2a(const Queue<T> &q, unsigned int offset, bool bigEndian) const {
34+
String q2a(const ArduinoCIQueue<T> &q, unsigned int offset, bool bigEndian) const {
3535
String ret = "";
3636

37-
Queue<T> q2(q);
37+
ArduinoCIQueue<T> q2(q);
3838

3939
while (offset) {
4040
q2.pop();
@@ -135,7 +135,7 @@ class PinHistory : public ObservableDataStream {
135135
// copy elements to an array, up to a given length
136136
// return the number of elements moved
137137
int toArray (T* arr, unsigned int length) const {
138-
Queue<T> q2(qOut);
138+
ArduinoCIQueue<T> q2(qOut);
139139

140140
int ret = 0;
141141
for (int i = 0; i < length && q2.size(); ++i) {
@@ -149,7 +149,7 @@ class PinHistory : public ObservableDataStream {
149149
// see if the array matches the elements in the queue
150150
bool hasElements (T const * const arr, unsigned int length) const {
151151
int i;
152-
Queue<T> q2(qOut);
152+
ArduinoCIQueue<T> q2(qOut);
153153
for (i = 0; i < length && q2.size(); ++i) {
154154
if (q2.front() != arr[i]) return false;
155155
q2.pop();

cpp/arduino/ci/DeviceUsingBytes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
class DeviceUsingBytes : public DataStreamObserver {
2626
public:
2727
String mMessage;
28-
Table<String, String> mResponses;
28+
ArduinoCITable<String, String> mResponses;
2929
GodmodeState* state;
3030

3131

cpp/arduino/ci/ObservableDataStream.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class DataStreamObserver {
7272
class ObservableDataStream
7373
{
7474
private:
75-
Table<String, DataStreamObserver*> mObservers;
75+
ArduinoCITable<String, DataStreamObserver*> mObservers;
7676
bool mAdvertisingBit;
7777
unsigned char mAdvertisingByte;
7878

cpp/arduino/ci/Queue.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#pragma once
22

33
template <typename T>
4-
class Queue {
4+
class ArduinoCIQueue {
55
private:
66
struct Node {
77
T data;
@@ -19,9 +19,9 @@ class Queue {
1919
}
2020

2121
public:
22-
Queue(): mNil() { init(); }
22+
ArduinoCIQueue(): mNil() { init(); }
2323

24-
Queue(const Queue<T>& q) {
24+
ArduinoCIQueue(const ArduinoCIQueue<T>& q) {
2525
init();
2626
for (Node* n = q.mFront; n; n = n->next) push(n->data);
2727
}
@@ -69,5 +69,5 @@ class Queue {
6969

7070
void clear() { while (!empty()) pop(); }
7171

72-
~Queue() { clear(); }
72+
~ArduinoCIQueue() { clear(); }
7373
};

cpp/arduino/ci/Table.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// this is this stupidest table implementation ever but it's
66
// an MVP for unit testing. O(n).
77
template <typename K, typename V>
8-
class Table {
8+
class ArduinoCITable {
99
private:
1010
struct Node {
1111
K key;
@@ -25,7 +25,7 @@ class Table {
2525
}
2626

2727
public:
28-
Table() : mNilK(), mNilV() { init(); }
28+
ArduinoCITable() : mNilK(), mNilV() { init(); }
2929

3030
// number of things in the table
3131
inline unsigned long size() const { return mSize; }
@@ -121,5 +121,5 @@ class Table {
121121
}
122122
}
123123

124-
~Table() { clear(); }
124+
~ArduinoCITable() { clear(); }
125125
};

0 commit comments

Comments
 (0)