From 4ea20f0e74c57bba7a1972e58d9353a28eb97ab8 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sat, 21 Sep 2013 00:22:36 +0200 Subject: [PATCH] Clang(#928): fix inconsistencies and compilation problems Compilation with Clang 3.0 (which is available in Debian/stable) fails, mostly due to some scoping and naming inconsistencies which weren't detected by GCC. At some instances, Clang seems to have problems to figure out a perfectly valid type definition; these can be resolved by more explicit typing (which is preferrable anyway) --- src/lib/functor-util.hpp | 2 +- src/lib/meta/tuple.hpp | 14 +++-- src/lib/opaque-holder.hpp | 5 +- src/lib/scoped-ptrvect.hpp | 1 + src/lib/singleton-policies.hpp | 6 +- src/lib/sync.hpp | 62 +++++++++---------- src/lib/visitor.hpp | 14 +++-- src/proc/asset.cpp | 6 +- src/proc/asset/buildinstruct.hpp | 7 ++- src/proc/asset/clip.cpp | 2 +- src/proc/asset/clip.hpp | 2 +- src/proc/asset/procpatt.cpp | 5 ++ src/proc/asset/procpatt.hpp | 2 + src/proc/engine/buffer-metadata.hpp | 2 +- src/proc/engine/buffer-provider.hpp | 2 +- src/proc/mobject/mobject.cpp | 4 +- src/tool/hello.c | 3 +- src/tool/main.c | 42 +++++++------ .../core/proc/engine/buffer-metadata-test.cpp | 10 +-- tests/library/time/quantiser-basics-test.cpp | 2 +- 20 files changed, 109 insertions(+), 84 deletions(-) diff --git a/src/lib/functor-util.hpp b/src/lib/functor-util.hpp index 0e3a21577..05733edeb 100644 --- a/src/lib/functor-util.hpp +++ b/src/lib/functor-util.hpp @@ -54,7 +54,7 @@ namespace util { ////////////TODO: refactor namespace. But probably not directly /** "Combiner" which calls two functions one after another * returning the result of the second invocation. */ template - class CombineSequenced; + struct CombineSequenced; template struct CombineSequenced diff --git a/src/lib/meta/tuple.hpp b/src/lib/meta/tuple.hpp index 73e633f1b..c301e994d 100644 --- a/src/lib/meta/tuple.hpp +++ b/src/lib/meta/tuple.hpp @@ -92,17 +92,17 @@ namespace meta { typedef Tuple Tail; enum { SIZE = 0 }; - NullType getHead() { return NullType(); } - Tail& getTail() { return *this; } + NullType& getHead() { return bottom(); } + Tail& getTail() { return *this; } Tuple (HeadType const&, Tail const&) { } Tuple () { } template struct ShiftedTuple { typedef Tail Type;}; template Tail& getShifted () { return *this; } - template NullType& getAt () { return getHead(); } + template NullType& getAt () { return bottom(); } - const NullType getHead_const() const { return NullType();} + const NullType getHead_const() const { return bottom(); } const Tail& getTail_const() const { return *this; } TupleType& @@ -110,6 +110,12 @@ namespace meta { { return reinterpret_cast (*this); } + + NullType& + bottom() const + { + return (NullType&) (*this); + } }; diff --git a/src/lib/opaque-holder.hpp b/src/lib/opaque-holder.hpp index 7ffb2463b..555e49a22 100644 --- a/src/lib/opaque-holder.hpp +++ b/src/lib/opaque-holder.hpp @@ -584,7 +584,8 @@ namespace lib { /** - * Variation of the concept realised by OpaqueHolder, but implemented here + * Buffer to place and maintain an object instance privately within another object. + * Variation of a similar concept as with OpaqueHolder, but implemented here * with reduced security and lesser overhead. InPlaceBuffer is just a chunk of * storage, which can be accessed through a common base class interface and * allows to place new objects there. It has no way to keep track of the @@ -738,7 +739,7 @@ namespace lib { template - static SUB* + SUB* access () { BA * asBase = &getObj(); diff --git a/src/lib/scoped-ptrvect.hpp b/src/lib/scoped-ptrvect.hpp index 341f7c23b..241ada393 100644 --- a/src/lib/scoped-ptrvect.hpp +++ b/src/lib/scoped-ptrvect.hpp @@ -84,6 +84,7 @@ namespace lib { public: typedef size_t size_type; + typedef T value_type; typedef T & reference; typedef T const& const_reference; diff --git a/src/lib/singleton-policies.hpp b/src/lib/singleton-policies.hpp index 7c688c829..5bfd294d5 100644 --- a/src/lib/singleton-policies.hpp +++ b/src/lib/singleton-policies.hpp @@ -50,8 +50,9 @@ namespace singleton { * Policy placing the Singleton instance into a statically allocated buffer */ template - struct StaticCreate + class StaticCreate { + public: static S* create () { #if NOBUG_MODE_ALPHA @@ -72,8 +73,9 @@ namespace singleton { * Policy for creating the Singleton instance heap allocated */ template - struct HeapCreate + class HeapCreate { + public: static S* create () { return new S; } static void destroy (S* pS) { delete pS; } }; diff --git a/src/lib/sync.hpp b/src/lib/sync.hpp index e87e33a7b..b4381b48b 100644 --- a/src/lib/sync.hpp +++ b/src/lib/sync.hpp @@ -227,7 +227,37 @@ namespace lib { }; - class Timeout; + + /** + * helper for specifying an optional timeout for an timed wait. + * Wrapping a timespec-struct, it allows for easy initialisation + * by a given relative offset. + */ + struct Timeout + : timespec + { + Timeout() { tv_sec=tv_nsec=0; } + + /** initialise to NOW() + offset (in milliseconds) */ + Timeout& + setOffset (ulong offs) + { + if (offs) + { + clock_gettime(CLOCK_REALTIME, this); + tv_sec += offs / 1000; + tv_nsec += 1000000 * (offs % 1000); + if (tv_nsec >= 1000000000) + { + tv_sec += tv_nsec / 1000000000; + tv_nsec %= 1000000000; + } } + return *this; + } + + operator bool() { return 0 != tv_sec; } // allows if (timeout_).... + }; + template @@ -266,36 +296,6 @@ namespace lib { }; - /** - * helper for specifying an optional timeout for an timed wait. - * Wrapping a timespec-struct, it allows for easy initialisation - * by a given relative offset. - */ - struct Timeout - : timespec - { - Timeout() { tv_sec=tv_nsec=0; } - - /** initialise to NOW() + offset (in milliseconds) */ - Timeout& - setOffset (ulong offs) - { - if (offs) - { - clock_gettime(CLOCK_REALTIME, this); - tv_sec += offs / 1000; - tv_nsec += 1000000 * (offs % 1000); - if (tv_nsec >= 1000000000) - { - tv_sec += tv_nsec / 1000000000; - tv_nsec %= 1000000000; - } } - return *this; - } - - operator bool() { return 0 != tv_sec; } // allows if (timeout_).... - }; - /* ==== functor types for defining the waiting condition ==== */ diff --git a/src/lib/visitor.hpp b/src/lib/visitor.hpp index 851cfc14e..29fefeb65 100644 --- a/src/lib/visitor.hpp +++ b/src/lib/visitor.hpp @@ -191,12 +191,19 @@ namespace visitor { > class Visitable { + public: + typedef typename TOOL::ReturnType ReturnType; + + /** to be defined by the DEFINE_PROCESSABLE_BY macro + * in all classes wanting to be treated by some tool */ + virtual ReturnType apply (TOOL&) = 0; + + protected: virtual ~Visitable () { }; /// @note may differ from TOOL typedef typename TOOL::ToolBase ToolBase; - typedef typename TOOL::ReturnType ReturnType; /** @internal used by the #DEFINE_PROCESSABLE_BY macro. * Dispatches to the actual operation on the @@ -209,11 +216,6 @@ namespace visitor { { return Dispatcher::instance().forwardCall (target,tool); } - - public: - /** to be defined by the DEFINE_PROCESSABLE_BY macro - * in all classes wanting to be treated by some tool */ - virtual ReturnType apply (TOOL&) = 0; }; diff --git a/src/proc/asset.cpp b/src/proc/asset.cpp index 1b1ba2d58..bf1bb154e 100644 --- a/src/proc/asset.cpp +++ b/src/proc/asset.cpp @@ -47,8 +47,6 @@ using util::_Fmt; namespace proc { namespace asset { - using ::NOBUG_FLAG(memory); - NOBUG_CPP_DEFINE_FLAG_PARENT(assetmem, memory); Asset::Ident::Ident(const string& n, const Category& cat, const string& o, const uint ver) @@ -67,12 +65,12 @@ namespace asset { , id(AssetManager::reg (this, idi)) , enabled(true) { - TRACE (assetmem, "ctor Asset(id=%zu) : adr=%p %s", size_t(id), this, cStr(this->ident) ); + TRACE (asset_mem, "ctor Asset(id=%zu) : adr=%p %s", size_t(id), this, cStr(this->ident) ); } Asset::~Asset () { - TRACE (assetmem, "dtor Asset(id=%zu) : adr=%p", size_t(id), this ); + TRACE (asset_mem, "dtor Asset(id=%zu) : adr=%p", size_t(id), this ); } diff --git a/src/proc/asset/buildinstruct.hpp b/src/proc/asset/buildinstruct.hpp index 73ee094f2..e274cdf7a 100644 --- a/src/proc/asset/buildinstruct.hpp +++ b/src/proc/asset/buildinstruct.hpp @@ -116,12 +116,15 @@ namespace asset { BuildInstruct (T& instr) : InstructEntry() {} // TODO: this ctor is *not* correct, just to make it compile - // There is a strange problem with boost::variant, probably becausse the + // There is a strange problem with boost::variant, probably because the // template parameter T could be anything (but actually we know it's one // of our Instruction types. - // I have to reinvestigate this design anyway, and probably will replace + // I have to re-investigate this design anyway, and probably will replace // the boost::variant by something else, derive from a common base or such. // Note: as of 8/2008 ProcPatt is just a draft and not implemented. + + // Note: 9/2013 : meanwhile the obvious solution would be to use our "polymorphic value", + // which was invented exactly to solve this notorious design mismatch in C++ }; diff --git a/src/proc/asset/clip.cpp b/src/proc/asset/clip.cpp index 52d735259..60db3391a 100644 --- a/src/proc/asset/clip.cpp +++ b/src/proc/asset/clip.cpp @@ -99,7 +99,7 @@ namespace asset { * the media asset referred by this clip */ Media::PMedia - Clip::checkCompound () + Clip::checkCompound() const { return source_.checkCompound(); ////////////////////////TODO better interface!!! } diff --git a/src/proc/asset/clip.hpp b/src/proc/asset/clip.hpp index a73d4f4be..1fcf34e3e 100644 --- a/src/proc/asset/clip.hpp +++ b/src/proc/asset/clip.hpp @@ -52,7 +52,7 @@ namespace asset { friend class MediaFactory; virtual PClip getClipAsset (); - virtual PMedia checkCompound (); + virtual PMedia checkCompound () const; }; diff --git a/src/proc/asset/procpatt.cpp b/src/proc/asset/procpatt.cpp index 37de98de3..a40b398c0 100644 --- a/src/proc/asset/procpatt.cpp +++ b/src/proc/asset/procpatt.cpp @@ -33,6 +33,11 @@ namespace proc { namespace asset { + /// emit VTable and member destructors here... + ProcPatt::~ProcPatt() { } + + + /** new processing pattern with empty instruction list. * @todo preliminary implementation, storing the capabilities * in the asset name field. We can do better, when diff --git a/src/proc/asset/procpatt.hpp b/src/proc/asset/procpatt.hpp index 3ad8b26ef..4797badda 100644 --- a/src/proc/asset/procpatt.hpp +++ b/src/proc/asset/procpatt.hpp @@ -55,6 +55,8 @@ namespace asset { { InstructionSequence instructions_; + ~ProcPatt(); + ProcPatt (const Asset::Ident&, const InstructionSequence&); protected: diff --git a/src/proc/engine/buffer-metadata.hpp b/src/proc/engine/buffer-metadata.hpp index 2d9bfe5e0..d61f7f2d8 100644 --- a/src/proc/engine/buffer-metadata.hpp +++ b/src/proc/engine/buffer-metadata.hpp @@ -546,7 +546,7 @@ namespace engine { HashVal family_; metadata::Table table_; - + ///////////////////////////TICKET #854 : ensure proper locking happens "somewhere" when mutating metadata public: typedef metadata::Key Key; diff --git a/src/proc/engine/buffer-provider.hpp b/src/proc/engine/buffer-provider.hpp index 57c5acdff..a8f306f80 100644 --- a/src/proc/engine/buffer-provider.hpp +++ b/src/proc/engine/buffer-provider.hpp @@ -76,7 +76,7 @@ namespace engine { * @warning all of BufferProvider is assumed to run within a threadsafe environment. * * @todo as of 6/2011 buffer management within the engine is still a bit vague - * @todo as of 11/11 thread safety within the engine remains to be clarified + * @todo as of 11/11 thread safety within the engine remains to be clarified ///////////////////////////TICKET #854 */ class BufferProvider : boost::noncopyable diff --git a/src/proc/mobject/mobject.cpp b/src/proc/mobject/mobject.cpp index 1a563391d..48c187141 100644 --- a/src/proc/mobject/mobject.cpp +++ b/src/proc/mobject/mobject.cpp @@ -31,9 +31,7 @@ using util::isnil; namespace proc { namespace mobject { - - using ::NOBUG_FLAG(memory); - NOBUG_CPP_DEFINE_FLAG_PARENT(mobjectmem, memory); + /** Storage for the (single, static) MObject factory object. diff --git a/src/tool/hello.c b/src/tool/hello.c index befad1f21..43b3c3291 100644 --- a/src/tool/hello.c +++ b/src/tool/hello.c @@ -5,7 +5,8 @@ #include -int main(int argc, char* argv[]) +int +main (int argc, char* argv[]) { (void)argc; (void)argv; diff --git a/src/tool/main.c b/src/tool/main.c index e8a684705..86a027b41 100644 --- a/src/tool/main.c +++ b/src/tool/main.c @@ -30,24 +30,30 @@ #define SAMPLE_RATE 44100 -int16_t quiet[SAMPLE_RATE], noisy[SAMPLE_RATE]; +int16_t quiet[SAMPLE_RATE], + noisy[SAMPLE_RATE]; -void main () { - for (int i=0; imarkLocked(bufferType1, &frames[0]); @@ -298,7 +298,7 @@ namespace test { // manual cleanup of test allocations delete[] frames; - delete[] rawbuf; + free(storage); CHECK (!meta_->isLocked(handle_f0)); CHECK (!meta_->isLocked(handle_f1)); diff --git a/tests/library/time/quantiser-basics-test.cpp b/tests/library/time/quantiser-basics-test.cpp index a2656fa79..0313ab2ca 100644 --- a/tests/library/time/quantiser-basics-test.cpp +++ b/tests/library/time/quantiser-basics-test.cpp @@ -180,7 +180,7 @@ namespace test{ CHECK (Time::MIN == case2.gridAlign( secs(-2) )); // allowed range and thus will be clipped // maximum frame size is half the time range - Duration hugeFrame(Offset(Time::MAX)); + Duration hugeFrame(Time::MAX); FixedFrameQuantiser case3 (hugeFrame); CHECK (Time::MIN == case3.gridAlign(Time::MIN )); CHECK (Time::MIN == case3.gridAlign(Time::MIN +TimeValue(1) ));