From 0e0d1c2038c081c7f7a066653a7fae6549a4aeac Mon Sep 17 00:00:00 2001 From: Ian Katz Date: Wed, 7 Mar 2018 15:41:57 -0500 Subject: [PATCH 1/2] avoid name collisions with Queue and Table --- CHANGELOG.md | 1 + SampleProjects/TestSomething/test/queue.cpp | 6 +++--- SampleProjects/TestSomething/test/table.cpp | 6 +++--- cpp/arduino/PinHistory.h | 14 +++++++------- cpp/arduino/ci/DeviceUsingBytes.h | 2 +- cpp/arduino/ci/ObservableDataStream.h | 2 +- cpp/arduino/ci/Queue.h | 8 ++++---- cpp/arduino/ci/Table.h | 6 +++--- 8 files changed, 23 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fc039555..1651ed54 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Added ### Changed +- Queue and Table are now ArduinoCIQueue and ArduinoCITable to avoid name collisions ### Deprecated diff --git a/SampleProjects/TestSomething/test/queue.cpp b/SampleProjects/TestSomething/test/queue.cpp index 5b585234..892dc73d 100644 --- a/SampleProjects/TestSomething/test/queue.cpp +++ b/SampleProjects/TestSomething/test/queue.cpp @@ -3,7 +3,7 @@ unittest(basic_queue_dequeue_and_size) { - Queue q; + ArduinoCIQueue q; int data[5] = {11, 22, 33, 44, 55}; assertTrue(q.empty()); @@ -27,11 +27,11 @@ unittest(basic_queue_dequeue_and_size) unittest(copy_constructor) { - Queue q; + ArduinoCIQueue q; int data[5] = {11, 22, 33, 44, 55}; for (int i = 0; i < 5; ++i) q.push(data[i]); - Queue q2(q); + ArduinoCIQueue q2(q); for (int i = 0; i < 5; ++i) { assertEqual(5 - i, q2.size()); diff --git a/SampleProjects/TestSomething/test/table.cpp b/SampleProjects/TestSomething/test/table.cpp index 712b649d..152bac7d 100644 --- a/SampleProjects/TestSomething/test/table.cpp +++ b/SampleProjects/TestSomething/test/table.cpp @@ -20,7 +20,7 @@ void setResult3(long l, int k, int v) { unittest(basic_table) { - Table t; + ArduinoCITable t; assertTrue(t.empty()); int data[5] = {11, 22, 33, 44, 55}; @@ -47,7 +47,7 @@ unittest(basic_table) } unittest(iteration_no_arg) { - Table t; + ArduinoCITable t; for (int i = 0; i < 5; ++i) { results[i] = 0; t.add(i, 11 * (i + 1)); @@ -59,7 +59,7 @@ unittest(iteration_no_arg) { } unittest(iteration_one_arg) { - Table t; + ArduinoCITable t; for (int i = 0; i < 5; ++i) { results[i] = 0; t.add(i, 11 * (i + 1)); diff --git a/cpp/arduino/PinHistory.h b/cpp/arduino/PinHistory.h index 2e9a470c..6fadebce 100644 --- a/cpp/arduino/PinHistory.h +++ b/cpp/arduino/PinHistory.h @@ -7,8 +7,8 @@ template class PinHistory : public ObservableDataStream { private: - Queue qIn; - Queue qOut; + ArduinoCIQueue qIn; + ArduinoCIQueue qOut; void clear() { qOut.clear(); @@ -16,7 +16,7 @@ class PinHistory : public ObservableDataStream { } // enqueue ascii bits - void a2q(Queue &q, String input, bool bigEndian, bool advertise) { + void a2q(ArduinoCIQueue &q, String input, bool bigEndian, bool advertise) { // 8 chars at a time, form up for (int j = 0; j < input.length(); ++j) { for (int i = 0; i < 8; ++i) { @@ -31,10 +31,10 @@ class PinHistory : public ObservableDataStream { // convert a queue to a string as if it was serial bits // start from offset, consider endianness - String q2a(const Queue &q, unsigned int offset, bool bigEndian) const { + String q2a(const ArduinoCIQueue &q, unsigned int offset, bool bigEndian) const { String ret = ""; - Queue q2(q); + ArduinoCIQueue q2(q); while (offset) { q2.pop(); @@ -135,7 +135,7 @@ class PinHistory : public ObservableDataStream { // copy elements to an array, up to a given length // return the number of elements moved int toArray (T* arr, unsigned int length) const { - Queue q2(qOut); + ArduinoCIQueue q2(qOut); int ret = 0; for (int i = 0; i < length && q2.size(); ++i) { @@ -149,7 +149,7 @@ class PinHistory : public ObservableDataStream { // see if the array matches the elements in the queue bool hasElements (T const * const arr, unsigned int length) const { int i; - Queue q2(qOut); + ArduinoCIQueue q2(qOut); for (i = 0; i < length && q2.size(); ++i) { if (q2.front() != arr[i]) return false; q2.pop(); diff --git a/cpp/arduino/ci/DeviceUsingBytes.h b/cpp/arduino/ci/DeviceUsingBytes.h index 639a733a..2003a3d1 100644 --- a/cpp/arduino/ci/DeviceUsingBytes.h +++ b/cpp/arduino/ci/DeviceUsingBytes.h @@ -25,7 +25,7 @@ class DeviceUsingBytes : public DataStreamObserver { public: String mMessage; - Table mResponses; + ArduinoCITable mResponses; GodmodeState* state; diff --git a/cpp/arduino/ci/ObservableDataStream.h b/cpp/arduino/ci/ObservableDataStream.h index 48723480..f6ffb2f6 100644 --- a/cpp/arduino/ci/ObservableDataStream.h +++ b/cpp/arduino/ci/ObservableDataStream.h @@ -72,7 +72,7 @@ class DataStreamObserver { class ObservableDataStream { private: - Table mObservers; + ArduinoCITable mObservers; bool mAdvertisingBit; unsigned char mAdvertisingByte; diff --git a/cpp/arduino/ci/Queue.h b/cpp/arduino/ci/Queue.h index 87a0cf49..bbd9f7f4 100644 --- a/cpp/arduino/ci/Queue.h +++ b/cpp/arduino/ci/Queue.h @@ -1,7 +1,7 @@ #pragma once template -class Queue { +class ArduinoCIQueue { private: struct Node { T data; @@ -19,9 +19,9 @@ class Queue { } public: - Queue(): mNil() { init(); } + ArduinoCIQueue(): mNil() { init(); } - Queue(const Queue& q) { + ArduinoCIQueue(const ArduinoCIQueue& q) { init(); for (Node* n = q.mFront; n; n = n->next) push(n->data); } @@ -69,5 +69,5 @@ class Queue { void clear() { while (!empty()) pop(); } - ~Queue() { clear(); } + ~ArduinoCIQueue() { clear(); } }; diff --git a/cpp/arduino/ci/Table.h b/cpp/arduino/ci/Table.h index f984a3c2..cda5b750 100644 --- a/cpp/arduino/ci/Table.h +++ b/cpp/arduino/ci/Table.h @@ -5,7 +5,7 @@ // this is this stupidest table implementation ever but it's // an MVP for unit testing. O(n). template -class Table { +class ArduinoCITable { private: struct Node { K key; @@ -25,7 +25,7 @@ class Table { } public: - Table() : mNilK(), mNilV() { init(); } + ArduinoCITable() : mNilK(), mNilV() { init(); } // number of things in the table inline unsigned long size() const { return mSize; } @@ -121,5 +121,5 @@ class Table { } } - ~Table() { clear(); } + ~ArduinoCITable() { clear(); } }; From f93294795f9414484259f183001b3f1b381b0cbd Mon Sep 17 00:00:00 2001 From: Ian Katz Date: Wed, 7 Mar 2018 15:47:23 -0500 Subject: [PATCH 2/2] note to stash changes to avoid polluting build gem --- CONTRIBUTING.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 75b4fdbf..3f5d6983 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -24,7 +24,9 @@ Be prepared to write tests to accompany any code you would like to see merged. * `git add README.md CHANGELOG.md lib/arduino_ci/version.rb` * `git commit -m "vVERSION bump"` * `git tag -a vVERSION -m "Released version VERSION"` +* `git stash save` * `gem build arduino_ci.gemspec` +* `git stash pop` * `gem push arduino_ci-VERSION.gem` * `git push upstream` * `git push upstream --tags`