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)
This commit is contained in:
Fischlurch 2013-09-21 00:22:36 +02:00
parent 4f698f1bbb
commit 4ea20f0e74
20 changed files with 109 additions and 84 deletions

View file

@ -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<typename SIG>
class CombineSequenced;
struct CombineSequenced;
template<typename ARG, typename RET>
struct CombineSequenced<RET(ARG)>

View file

@ -92,17 +92,17 @@ namespace meta {
typedef Tuple<NullType> 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<uint> struct ShiftedTuple { typedef Tail Type;};
template<uint> Tail& getShifted () { return *this; }
template<uint> NullType& getAt () { return getHead(); }
template<uint> 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<TupleType&> (*this);
}
NullType&
bottom() const
{
return (NullType&) (*this);
}
};

View file

@ -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<class SUB>
static SUB*
SUB*
access ()
{
BA * asBase = &getObj();

View file

@ -84,6 +84,7 @@ namespace lib {
public:
typedef size_t size_type;
typedef T value_type;
typedef T & reference;
typedef T const& const_reference;

View file

@ -50,8 +50,9 @@ namespace singleton {
* Policy placing the Singleton instance into a statically allocated buffer
*/
template<class S>
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<class S>
struct HeapCreate
class HeapCreate
{
public:
static S* create () { return new S; }
static void destroy (S* pS) { delete pS; }
};

View file

@ -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<class MTX>
@ -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 ==== */

View file

@ -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<TAR,ToolBase>::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;
};

View file

@ -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 );
}

View file

@ -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++
};

View file

@ -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!!!
}

View file

@ -52,7 +52,7 @@ namespace asset {
friend class MediaFactory;
virtual PClip getClipAsset ();
virtual PMedia checkCompound ();
virtual PMedia checkCompound () const;
};

View file

@ -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

View file

@ -55,6 +55,8 @@ namespace asset {
{
InstructionSequence instructions_;
~ProcPatt();
ProcPatt (const Asset::Ident&, const InstructionSequence&);
protected:

View file

@ -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;

View file

@ -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

View file

@ -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.

View file

@ -5,7 +5,8 @@
#include <stdio.h>
int main(int argc, char* argv[])
int
main (int argc, char* argv[])
{
(void)argc;
(void)argv;

View file

@ -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; i<SAMPLE_RATE; i++)
{
int
main()
{
for (int i = 0; i < SAMPLE_RATE; i++)
{
quiet[i] = 0;
noisy[i] = i%30000;
}
audio_start(44100, 2);
for (int i=0; i<10; i++)
{
audio_write(noisy, SAMPLE_RATE);
printf("=================================\n");
audio_write(quiet, SAMPLE_RATE);
printf("\n");
}
audio_stop();
}
noisy[i] = i % 30000;
}
audio_start (44100, 2);
for (int i = 0; i < 10; i++)
{
audio_write (noisy, SAMPLE_RATE);
printf ("=================================\n");
audio_write (quiet, SAMPLE_RATE);
printf ("\n");
}
audio_stop ();
return 0;
}

View file

@ -211,11 +211,11 @@ namespace test {
// later, when it comes to actually *locking* those buffers...
typedef char RawBuffer[SIZE_B];
void* storage = malloc (2*SIZE_B);
// do the necessary memory allocations behind the scenes
TestFrame* frames = new TestFrame[3];
RawBuffer* rawbuf = new RawBuffer[2]; // coding explicit allocations here for sake of clarity;
// a real-world BufferProvider would use some kind of allocator
// do the necessary memory allocations behind the scenes...
RawBuffer* rawbuf = (RawBuffer*)storage; // coding explicit allocations here for sake of clarity;
TestFrame* frames = new TestFrame[3]; // a real-world BufferProvider would use some kind of allocator
// track individual buffers by metadata entries
metadata::Entry& f0 = meta_->markLocked(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));

View file

@ -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) ));