diff options
author | David Robillard <d@drobilla.net> | 2012-11-22 06:16:10 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2012-11-22 06:16:10 +0000 |
commit | c4b51e0935f75d118164fab6bfcefc6ddf69867e (patch) | |
tree | f4f6bfc5e0a19561dd7860f82976dff3fdbb68a6 | |
parent | 5642368878114fd99cb6bf877258945a38c3c0b9 (diff) | |
download | raul-c4b51e0935f75d118164fab6bfcefc6ddf69867e.tar.gz raul-c4b51e0935f75d118164fab6bfcefc6ddf69867e.tar.bz2 raul-c4b51e0935f75d118164fab6bfcefc6ddf69867e.zip |
Tidy.
git-svn-id: http://svn.drobilla.net/lad/trunk/raul@4851 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r-- | raul/Array.hpp | 28 | ||||
-rw-r--r-- | raul/Atom.hpp | 8 | ||||
-rw-r--r-- | raul/AtomLiblo.hpp | 3 | ||||
-rw-r--r-- | raul/DoubleBuffer.hpp | 11 | ||||
-rw-r--r-- | raul/Path.hpp | 4 | ||||
-rw-r--r-- | raul/Process.hpp | 4 | ||||
-rw-r--r-- | raul/SRMWQueue.hpp | 9 | ||||
-rw-r--r-- | raul/Symbol.hpp | 2 | ||||
-rw-r--r-- | raul/ThreadVar.hpp | 6 | ||||
-rw-r--r-- | raul/TimeSlice.hpp | 2 | ||||
-rw-r--r-- | raul/TimeStamp.hpp | 13 | ||||
-rw-r--r-- | wscript | 2 |
12 files changed, 54 insertions, 38 deletions
diff --git a/raul/Array.hpp b/raul/Array.hpp index 96797d4..485f3cf 100644 --- a/raul/Array.hpp +++ b/raul/Array.hpp @@ -36,12 +36,18 @@ template <class T> class Array : public Disposable { public: - explicit Array(size_t size = 0) : _size(size), _elems(NULL) { + explicit Array(size_t size = 0) + : _size(size) + , _elems(NULL) + { if (size > 0) _elems = new T[size]; } - Array(size_t size, T initial_value) : _size(size), _elems(NULL) { + Array(size_t size, T initial_value) + : _size(size) + , _elems(NULL) + { if (size > 0) { _elems = new T[size]; for (size_t i = 0; i < size; ++i) @@ -49,14 +55,18 @@ public: } } - Array(size_t size, const Array<T>& contents) : _size(size) { + Array(size_t size, const Array<T>& contents) + : _size(size) + { assert(contents.size() >= size); _elems = new T[size]; for (size_t i = 0; i < std::min(size, contents.size()); ++i) _elems[i] = contents[i]; } - Array(size_t size, const Array<T>& contents, T initial_value=T()) : _size(size) { + Array(size_t size, const Array<T>& contents, T initial_value = T()) + : _size(size) + { _elems = new T[size]; const size_t end = std::min(size, contents.size()); for (size_t i = 0; i < end; ++i) @@ -91,9 +101,15 @@ public: inline size_t size() const { return _size; } - inline T& operator[](size_t i) const { assert(i < _size); return _elems[i]; } + inline T& operator[](size_t i) const { + assert(i < _size); + return _elems[i]; + } - inline T& at(size_t i) const { assert(i < _size); return _elems[i]; } + inline T& at(size_t i) const { + assert(i < _size); + return _elems[i]; + } private: size_t _size; diff --git a/raul/Atom.hpp b/raul/Atom.hpp index 92d0d07..b1a2485 100644 --- a/raul/Atom.hpp +++ b/raul/Atom.hpp @@ -81,7 +81,9 @@ public: return false; } - inline bool operator!=(const Atom& other) const { return ! operator==(other); } + inline bool operator!=(const Atom& other) const { + return !operator==(other); + } inline bool operator<(const Atom& other) const { if (_type == other.type()) { @@ -162,8 +164,8 @@ public: virtual ~Forge() {} Atom make() { return Atom(); } - Atom make(int32_t v) { return Atom(sizeof(int32_t), Int, &v); } - Atom make(float v) { return Atom(sizeof(float), Float, &v); } + Atom make(int32_t v) { return Atom(sizeof(v), Int, &v); } + Atom make(float v) { return Atom(sizeof(v), Float, &v); } Atom make(bool v) { const int32_t iv = v ? 1 : 0; return Atom(sizeof(int32_t), Bool, &iv); diff --git a/raul/AtomLiblo.hpp b/raul/AtomLiblo.hpp index 8cefda3..76d106c 100644 --- a/raul/AtomLiblo.hpp +++ b/raul/AtomLiblo.hpp @@ -55,7 +55,8 @@ lo_message_add_atom(lo_message m, const Atom& atom) break; case Atom::BLOB: if (atom.data_size() > 0) - lo_message_add_blob(m, lo_blob_new(atom.data_size(), atom.get_blob())); + lo_message_add_blob( + m, lo_blob_new(atom.data_size(), atom.get_blob())); else lo_message_add_nil(m); break; diff --git a/raul/DoubleBuffer.hpp b/raul/DoubleBuffer.hpp index 1c159e9..28080d6 100644 --- a/raul/DoubleBuffer.hpp +++ b/raul/DoubleBuffer.hpp @@ -35,7 +35,6 @@ namespace Raul { template<typename T> class DoubleBuffer { public: - inline DoubleBuffer(T val) : _state(RAUL_DB_READ_WRITE) { @@ -56,8 +55,8 @@ public: } inline bool set(T new_val) { - if (_state.compare_and_exchange(RAUL_DB_READ_WRITE, RAUL_DB_READ_LOCK)) { - + if (_state.compare_and_exchange(RAUL_DB_READ_WRITE, + RAUL_DB_READ_LOCK)) { // locked _vals[1] for write _vals[1] = new_val; _read_val = &_vals[1]; @@ -67,8 +66,8 @@ public: // concurrent calls here are fine. good, actually - caught // the WRITE_READ state immediately after it was set above - } else if (_state.compare_and_exchange(RAUL_DB_WRITE_READ, RAUL_DB_LOCK_READ)) { - + } else if (_state.compare_and_exchange(RAUL_DB_WRITE_READ, + RAUL_DB_LOCK_READ)) { // locked _vals[0] for write _vals[0] = new_val; _read_val = &_vals[0]; @@ -76,9 +75,7 @@ public: return true; } else { - return false; - } } diff --git a/raul/Path.hpp b/raul/Path.hpp index 867e2e3..ee8444a 100644 --- a/raul/Path.hpp +++ b/raul/Path.hpp @@ -17,6 +17,7 @@ #ifndef RAUL_PATH_HPP #define RAUL_PATH_HPP +#include <algorithm> #include <string> #include "raul/Exception.hpp" @@ -148,7 +149,8 @@ public: } else { const size_t first_sep = find('/'); const size_t last_sep = find_last_of('/'); - return (first_sep == last_sep) ? Path("/") : Path(substr(0, last_sep)); + return (first_sep == last_sep) + ? Path("/") : Path(substr(0, last_sep)); } } diff --git a/raul/Process.hpp b/raul/Process.hpp index 96ac831..4226a46 100644 --- a/raul/Process.hpp +++ b/raul/Process.hpp @@ -68,11 +68,11 @@ public: case -1: // (second) fork failed, there is no grandchild - _exit (-1); + _exit(-1); /* exit the child process here */ default: - _exit (0); + _exit(0); } } diff --git a/raul/SRMWQueue.hpp b/raul/SRMWQueue.hpp index 446250a..ac790ea 100644 --- a/raul/SRMWQueue.hpp +++ b/raul/SRMWQueue.hpp @@ -96,7 +96,7 @@ SRMWQueue<T>::SRMWQueue(size_t size) assert(size > 1); assert(_size-1 == (unsigned)_write_space.get()); - for (unsigned i=0; i < _size; ++i) { + for (unsigned i = 0; i < _size; ++i) { assert(_valid[i].get() == 0); } } @@ -129,15 +129,14 @@ template <typename T> inline bool SRMWQueue<T>::push(const T& elem) { - const int old_write_space = _write_space.exchange_and_add(-1); - const bool already_full = ( old_write_space <= 0 ); + const int old_write_space = _write_space.exchange_and_add(-1); + const bool already_full = (old_write_space <= 0); /* Technically right here pop could be called in the reader thread and * make space available, but no harm in failing anyway - this queue * really isn't designed to be filled... */ if (already_full) { - /* if multiple threads simultaneously get here, _write_space may be 0 * or negative. The next call to pop() will set _write_space back to * a sane value. Note that _write_space is not exposed, so this is okay @@ -146,7 +145,6 @@ SRMWQueue<T>::push(const T& elem) return false; } else { - // Note: _size must be a power of 2 for this to not explode when _back overflows const unsigned write_index = (unsigned)_back.exchange_and_add(1) % _size; @@ -155,7 +153,6 @@ SRMWQueue<T>::push(const T& elem) ++(_valid[write_index]); return true; - } } diff --git a/raul/Symbol.hpp b/raul/Symbol.hpp index 0aa8ed0..7af99ba 100644 --- a/raul/Symbol.hpp +++ b/raul/Symbol.hpp @@ -73,7 +73,7 @@ public: * Note this is faster than constructing a Symbol from another Symbol's * string since validation is unnecessary. */ - Symbol(const Raul::Symbol& symbol) + Symbol(const Symbol& symbol) : std::basic_string<char>(symbol) {} diff --git a/raul/ThreadVar.hpp b/raul/ThreadVar.hpp index f786f9c..7f5cf92 100644 --- a/raul/ThreadVar.hpp +++ b/raul/ThreadVar.hpp @@ -17,10 +17,10 @@ #ifndef RAUL_THREADVAR_HPP #define RAUL_THREADVAR_HPP -#include "raul/Noncopyable.hpp" - #include <pthread.h> +#include "raul/Noncopyable.hpp" + namespace Raul { /** Thread-specific variable. @@ -31,7 +31,7 @@ template<typename T> class ThreadVar : public Noncopyable { public: - ThreadVar(const T& default_value) + explicit ThreadVar(const T& default_value) : _default_value(default_value) { pthread_key_create(&_key, destroy_value); diff --git a/raul/TimeSlice.hpp b/raul/TimeSlice.hpp index a8b82f6..5cc1dc2 100644 --- a/raul/TimeSlice.hpp +++ b/raul/TimeSlice.hpp @@ -148,7 +148,7 @@ private: TimeStamp _start_beats; ///< Current window start in beats TimeDuration _length_beats; ///< Current window length in beats - TimeDuration _offset_ticks; ///< Offset to global time (ie Jack sub-cycle offset) + TimeDuration _offset_ticks; ///< Offset to global time }; } // namespace Raul diff --git a/raul/TimeStamp.hpp b/raul/TimeStamp.hpp index f644c6f..9c510f5 100644 --- a/raul/TimeStamp.hpp +++ b/raul/TimeStamp.hpp @@ -17,11 +17,12 @@ #ifndef RAUL_TIME_STAMP_HPP #define RAUL_TIME_STAMP_HPP -#include <limits> -#include <stdint.h> #include <math.h> +#include <stdint.h> + #include <cassert> #include <iostream> +#include <limits> namespace Raul { @@ -76,7 +77,7 @@ private: */ class TimeStamp { public: - inline TimeStamp(TimeUnit unit, uint32_t ticks=0, uint32_t subticks=0) + inline TimeStamp(TimeUnit unit, uint32_t ticks = 0, uint32_t subticks = 0) : _ticks(ticks) , _subticks(subticks) , _unit(unit) @@ -123,7 +124,7 @@ public: } inline bool operator!=(const TimeStamp& rhs) const { - return ! operator==(rhs); + return !operator==(rhs); } inline bool operator<(const TimeStamp& rhs) const { @@ -211,14 +212,14 @@ operator<<(std::ostream& os, const TimeStamp& t) class FrameStamp : public TimeStamp { public: - inline FrameStamp(uint32_t rate, uint32_t ticks=0, uint32_t subticks=0) + inline FrameStamp(uint32_t rate, uint32_t ticks = 0, uint32_t subticks = 0) : TimeStamp(TimeUnit(TimeUnit::FRAMES, rate), ticks, subticks) {} }; class BeatStamp : public TimeStamp { public: - inline BeatStamp(uint32_t ppqn, uint32_t ticks=0, uint32_t subticks=0) + inline BeatStamp(uint32_t ppqn, uint32_t ticks = 0, uint32_t subticks = 0) : TimeStamp(TimeUnit(TimeUnit::BEATS, ppqn), ticks, subticks) {} }; @@ -136,4 +136,4 @@ def test(ctx): autowaf.post_test(ctx, APPNAME, dirs=['.', 'src', 'test']) def lint(ctx): - subprocess.call('cpplint.py --filter=-whitespace/comments,-whitespace/tab,-whitespace/braces,-whitespace/labels,-build/header_guard,-readability/casting,-readability/todo,-build/namespaces,-whitespace/line_length,-runtime/rtti,-runtime/references,-whitespace/blank_line,-runtime/sizeof,-readability/streams,-whitespace/operators,-whitespace/parens,-build/include,-whitespace/comma,-whitespace/newline `find -name *.cpp -or -name *.hpp`', shell=True) + subprocess.call('cpplint.py --filter=-whitespace/comments,-whitespace/tab,-whitespace/braces,-whitespace/labels,-build/header_guard,-readability/casting,-whitespace/line_length,-runtime/references,-readability/streams,-build/include_order raul/*', shell=True) |