Added formats conversion

Functor, NonCopyable, Tuple are now parts of NazaraCore (NazaraCore no
longer needs NazaraUtility)
Added loadFormat image parameter (ask loader to load image in specific
format)
Fixed utility project building
It is now possible to convert, get validity or get name of pixel formats
Changed endianness macros' name
Removed useless NazaraEndianness macro
Removed unused files
This commit is contained in:
Lynix
2012-05-24 18:55:48 +02:00
parent 570e0a8070
commit b243d15c74
40 changed files with 1609 additions and 150 deletions

View File

@@ -8,8 +8,8 @@
#define NAZARA_DYNLIB_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/NonCopyable.hpp>
#include <Nazara/Core/String.hpp>
#include <Nazara/Utility/NonCopyable.hpp>
#define NAZARA_CLASS_DYNLIB
#include <Nazara/Core/ThreadSafety.hpp>

View File

@@ -9,26 +9,18 @@
#include <Nazara/Prerequesites.hpp>
#if defined(NAZARA_ENDIANNESS_BIGENDIAN)
#define NAZARA_ENDIANNESS_DETECTED 1
#define NazaraEndianness nzEndianness_BigEndian
#elif defined(NAZARA_ENDIANNESS_LITTLEENDIAN)
#define NAZARA_ENDIANNESS_DETECTED 1
#define NazaraEndianness nzEndianness_LittleEndian
#else
#if !defined(NAZARA_BIG_ENDIAN) && !defined(NAZARA_LITTLE_ENDIAN)
// Détection automatique selon les macros du compilateur
#if defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || (defined(__MIPS__) && defined(__MISPEB__)) || \
defined(__ppc__) || defined(__POWERPC__) || defined(_M_PPC) || defined(__sparc__) || defined(__hppa__)
#define NAZARA_ENDIANNESS_DETECTED 1
#define NAZARA_ENDIANNESS_BIGENDIAN
#define NazaraEndianness nzEndianness_BigEndian
#define NAZARA_BIG_ENDIAN
#elif defined(__i386__) || defined(__i386) || defined(__X86__) || defined (__x86_64)
#define NAZARA_ENDIANNESS_DETECTED 1
#define NAZARA_ENDIANNESS_LITTLEENDIAN
#define NazaraEndianness nzEndianness_LittleEndian
#define NAZARA_LITTLE_ENDIAN
#else
#define NAZARA_ENDIANNESS_DETECTED 0
#define NazaraEndianness NzGetPlatformEndianness()
#error Failed to identify endianness, you must define either NAZARA_BIG_ENDIAN or NAZARA_LITTLE_ENDIAN
#endif
#elif defined(NAZARA_BIG_ENDIAN) && defined(NAZARA_LITTLE_ENDIAN)
#error You cannot define both NAZARA_BIG_ENDIAN and NAZARA_LITTLE_ENDIAN
#endif
enum nzEndianness

View File

@@ -17,27 +17,11 @@ inline void NzByteSwap(void* buffer, unsigned int size)
inline nzEndianness NzGetPlatformEndianness()
{
#if NAZARA_ENDIANNESS_DETECTED
return NazaraEndianness;
#else
static nzEndianness endianness = nzEndianness_Unknown;
static bool tested = false;
if (!tested)
{
nzUInt32 i = 1;
nzUInt8* p = reinterpret_cast<nzUInt8*>(&i);
// Méthode de récupération de l'endianness au runtime
if (p[0] == 1)
endianness = nzEndianness_LittleEndian;
else if (p[3] == 1)
endianness = nzEndianness_BigEndian;
tested = true;
}
return endianness;
#endif
#if defined(NAZARA_BIG_ENDIAN)
return nzEndianness_BigEndian;
#elif defined(NAZARA_LITTLE_ENDIAN)
return nzEndianness_LittleEndian;
#endif
}
#include <Nazara/Core/DebugOff.hpp>

View File

@@ -13,8 +13,8 @@
#include <Nazara/Core/Hashable.hpp>
#include <Nazara/Core/HashDigest.hpp>
#include <Nazara/Core/InputStream.hpp>
#include <Nazara/Core/NonCopyable.hpp>
#include <Nazara/Core/String.hpp>
#include <Nazara/Utility/NonCopyable.hpp>
#define NAZARA_CLASS_FILE
#include <Nazara/Core/ThreadSafety.hpp>

View File

@@ -0,0 +1,45 @@
// Copyright (C) 2012 Jérôme Leclercq
// This file is part of the "Nazara Engine".
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_FUNCTOR_HPP
#define NAZARA_FUNCTOR_HPP
#include <Nazara/Core/Tuple.hpp>
// Inspiré du code de la SFML par Laurent Gomila
struct NzFunctor
{
virtual ~NzFunctor() {}
virtual void Run() = 0;
};
template<typename F> struct NzFunctorWithoutArgs : NzFunctor
{
NzFunctorWithoutArgs(F func);
void Run();
F function;
};
template<typename F, typename... Args> struct NzFunctorWithArgs : NzFunctor
{
NzFunctorWithArgs(F func, Args&... args);
void Run();
F function;
std::tuple<Args...> arguments;
};
template<typename F> struct NzFunctorWithoutArgs;
template<typename F, typename... Args> struct NzFunctorWithArgs;
#include <Nazara/Core/Functor.inl>
#endif // NAZARA_FUNCTOR_HPP

View File

@@ -0,0 +1,24 @@
// Copyright (C) 2012 Jérôme Leclercq
// This file is part of the "Nazara Engine".
// For conditions of distribution and use, see copyright notice in Config.hpp
template<typename F> NzFunctorWithoutArgs<F>::NzFunctorWithoutArgs(F func) :
function(func)
{
}
template<typename F> void NzFunctorWithoutArgs<F>::Run()
{
function();
}
template<typename F, typename... Args> NzFunctorWithArgs<F, Args...>::NzFunctorWithArgs(F func, Args&... args) :
function(func),
arguments(args...)
{
}
template<typename F, typename... Args> void NzFunctorWithArgs<F, Args...>::Run()
{
NzUnpackTuple(function, arguments);
}

View File

@@ -11,7 +11,7 @@
#include <Nazara/Core/Hashable.hpp>
#include <Nazara/Core/HashDigest.hpp>
#include <Nazara/Core/HashImpl.hpp>
#include <Nazara/Utility/NonCopyable.hpp>
#include <Nazara/Core/NonCopyable.hpp>
class NAZARA_API NzHash : NzNonCopyable
{

View File

@@ -8,7 +8,7 @@
#define NAZARA_HASHIMPL_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Utility/NonCopyable.hpp>
#include <Nazara/Core/NonCopyable.hpp>
class NzHashDigest;

View File

@@ -9,8 +9,8 @@
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/Error.hpp>
#include <Nazara/Core/NonCopyable.hpp>
#include <Nazara/Core/String.hpp>
#include <Nazara/Utility/NonCopyable.hpp>
#define NAZARA_CLASS_LOG
#include <Nazara/Core/ThreadSafety.hpp>

View File

@@ -8,7 +8,7 @@
#define NAZARA_MUTEX_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Utility/NonCopyable.hpp>
#include <Nazara/Core/NonCopyable.hpp>
class NzMutexImpl;
class NzThreadCondition;

View File

@@ -0,0 +1,20 @@
// Copyright (C) 2012 Jérôme Leclercq
// This file is part of the "Nazara Engine".
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_NONCOPYABLE_HPP
#define NAZARA_NONCOPYABLE_HPP
#include <Nazara/Prerequesites.hpp>
class NAZARA_API NzNonCopyable
{
protected:
NzNonCopyable() = default;
NzNonCopyable(const NzNonCopyable&) = delete;
NzNonCopyable& operator=(const NzNonCopyable&) = delete;
};
#endif // NAZARA_NONCOPYABLE_HPP

View File

@@ -8,7 +8,7 @@
#define NAZARA_SEMAPHORE_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Utility/NonCopyable.hpp>
#include <Nazara/Core/NonCopyable.hpp>
class NzSemaphoreImpl;

View File

@@ -10,8 +10,8 @@
#define NAZARA_THREAD_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Utility/Functor.hpp>
#include <Nazara/Utility/NonCopyable.hpp>
#include <Nazara/Core/Functor.hpp>
#include <Nazara/Core/NonCopyable.hpp>
class NzThreadImpl;

View File

@@ -0,0 +1,16 @@
// Copyright (C) 2012 Jérôme Leclercq
// This file is part of the "Nazara Engine".
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_TUPLE_HPP
#define NAZARA_TUPLE_HPP
#include <tuple>
template<typename F, typename... ArgsT> void NzUnpackTuple(F func, const std::tuple<ArgsT...>& t);
#include <Nazara/Core/Tuple.inl>
#endif // NAZARA_TUPLE_HPP

View File

@@ -0,0 +1,35 @@
// Copyright (C) 2012 Jérôme Leclercq
// This file is part of the "Nazara Engine".
// For conditions of distribution and use, see copyright notice in Config.hpp
// http://stackoverflow.com/questions/687490/c0x-how-do-i-expand-a-tuple-into-variadic-template-function-arguments
// Merci à Ryan "FullMetal Alchemist" Lahfa
// Merci aussi à Freedom de siteduzero.com
#include <Nazara/Utility/Debug.hpp>
template<unsigned int N> struct NzTupleUnpack
{
template <typename F, typename... ArgsT, typename... Args>
void operator()(F func, const std::tuple<ArgsT...>& t, Args&... args)
{
NzTupleUnpack<N-1>()(func, t, std::get<N-1>(t), args...);
}
};
template<> struct NzTupleUnpack<0>
{
template <typename F, typename... ArgsT, typename... Args>
void operator()(F func, const std::tuple<ArgsT...>&, Args&... args)
{
func(args...);
}
};
template<typename F, typename... ArgsT>
void NzUnpackTuple(F func, const std::tuple<ArgsT...>& t )
{
NzTupleUnpack<sizeof...(ArgsT)>()(func, t);
}
#include <Nazara/Utility/DebugOff.hpp>