diff --git a/CMakeLists.txt b/CMakeLists.txt index 14f00956..bbcf8d89 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -81,13 +81,13 @@ if(NOT WIN32 AND NOT BUILD_FRAMEWORK) endif() include_directories(${CMAKE_CURRENT_BINARY_DIR}) -configure_file(config-taglib.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h) +configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h) if(WITH_ASF) - set(TAGLIB_WITH_ASF TRUE) + set(TAGLIB_WITH_ASF TRUE) endif() if(WITH_MP4) - set(TAGLIB_WITH_MP4 TRUE) + set(TAGLIB_WITH_MP4 TRUE) endif() configure_file(taglib/taglib_config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/taglib_config.h) diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake index 1b6f4310..41be3f76 100644 --- a/ConfigureChecks.cmake +++ b/ConfigureChecks.cmake @@ -7,41 +7,44 @@ include(CheckTypeSize) include(CheckCXXSourceCompiles) include(TestBigEndian) -# Determine the CPU byte order. -test_big_endian(TAGLIB_BIG_ENDIAN) +# Check if the size of integral types are suitable. -if(NOT TAGLIB_BIG_ENDIAN) - set(TAGLIB_LITTLE_ENDIAN 1) +check_type_size("short" SIZEOF_SHORT) +if(NOT ${SIZEOF_SHORT} EQUAL 2) + MESSAGE(FATAL_ERROR "TagLib requires that short is 16-bit wide.") endif() -# Determine the size of numeric types. -check_type_size("short" SIZEOF_SHORT) -check_type_size("int" SIZEOF_INT) -check_type_size("long long" SIZEOF_LONGLONG) -check_type_size("wchar_t" SIZEOF_WCHAR_T) +check_type_size("int" SIZEOF_INT) +if(NOT ${SIZEOF_INT} EQUAL 4) + MESSAGE(FATAL_ERROR "TagLib requires that int is 32-bit wide.") +endif() + +check_type_size("long long" SIZEOF_LONGLONG) +if(NOT ${SIZEOF_LONGLONG} EQUAL 8) + MESSAGE(FATAL_ERROR "TagLib requires that long long is 64-bit wide.") +endif() + +check_type_size("wchar_t" SIZEOF_WCHAR_T) +if(${SIZEOF_WCHAR_T} LESS 2) + MESSAGE(FATAL_ERROR "TagLib requires that wchar_t is sufficient to store a UTF-16 char.") +endif() + +# Determine the CPU byte order. + +test_big_endian(IS_BIG_ENDIAN) + +if(NOT IS_BIG_ENDIAN) + set(SYSTEM_BYTEORDER 1) +else() + set(SYSTEM_BYTEORDER 2) +endif() + +# Determine the size of floating point types. + check_type_size("float" SIZEOF_FLOAT) check_type_size("double" SIZEOF_DOUBLE) check_type_size("long double" SIZEOF_LONGDOUBLE) -# Determine whether or not your compiler supports move semantics. -check_cxx_source_compiles(" - #ifdef __clang__ - # pragma clang diagnostic error \"-Wc++11-extensions\" - #endif - #include - int func(int &&x) { return x - 1; } - int main() { return func(std::move(1)); } -" SUPPORT_MOVE_SEMANTICS) - -# Determine if your compiler supports std::wstring. -check_cxx_source_compiles(" - #include - int main() { - std::wstring x(L\"ABC\"); - return 0; - } -" HAVE_STD_WSTRING) - # Determine which kind of byte swap functions your compiler supports. # GCC's __builtin_bswap* should be checked individually @@ -115,75 +118,8 @@ if(NOT HAVE_GCC_BYTESWAP_16 OR NOT HAVE_GCC_BYTESWAP_32 OR NOT HAVE_GCC_BYTESWAP endif() endif() -# Determine where shared_ptr is defined regardless of C++11 support. -check_cxx_source_compiles(" - #include - int main() { std::tr1::shared_ptr x; return 0; } -" HAVE_STD_SHARED_PTR) - -if(NOT HAVE_STD_SHARED_PTR) - check_cxx_source_compiles(" - #include - int main() { std::tr1::shared_ptr x; return 0; } - " HAVE_TR1_SHARED_PTR) - - if(NOT HAVE_TR1_SHARED_PTR) - check_cxx_source_compiles(" - #include - int main() { boost::shared_ptr x; return 0; } - " HAVE_BOOST_SHARED_PTR) - endif() -endif() - -# Determine which kind of atomic operations your compiler supports. -if(NOT HAVE_STD_SHARED_PTR AND NOT HAVE_TR1_SHARED_PTR AND NOT HAVE_BOOST_SHARED_PTR) - check_cxx_source_compiles(" - int main() { - volatile int x; - __sync_add_and_fetch(&x, 1); - int y = __sync_sub_and_fetch(&x, 1); - return 0; - } - " HAVE_GCC_ATOMIC) - - if(NOT HAVE_GCC_ATOMIC) - check_cxx_source_compiles(" - #include - int main() { - volatile int32_t x; - OSAtomicIncrement32Barrier(&x); - int32_t y = OSAtomicDecrement32Barrier(&x); - return 0; - } - " HAVE_MAC_ATOMIC) - - if(NOT HAVE_MAC_ATOMIC) - check_cxx_source_compiles(" - #include - int main() { - volatile LONG x; - InterlockedIncrement(&x); - LONG y = InterlockedDecrement(&x); - return 0; - } - " HAVE_WIN_ATOMIC) - - if(NOT HAVE_WIN_ATOMIC) - check_cxx_source_compiles(" - #include - int main() { - volatile int x; - __sync_add_and_fetch(&x, 1); - int y = __sync_sub_and_fetch(&x, 1); - return 0; - } - " HAVE_IA64_ATOMIC) - endif() - endif() - endif() -endif() - # Determine whether your compiler supports some safer version of sprintf. + check_cxx_source_compiles(" #include int main() { char buf[20]; snprintf(buf, 20, \"%d\", 1); return 0; } @@ -197,6 +133,7 @@ if(NOT HAVE_SNPRINTF) endif() # Determine whether your compiler supports codecvt. + check_cxx_source_compiles(" #include int main() { @@ -205,7 +142,8 @@ check_cxx_source_compiles(" } " HAVE_STD_CODECVT) -# Check for libz using the cmake supplied FindZLIB.cmake +# Determine whether zlib is installed. + find_package(ZLIB) if(ZLIB_FOUND) set(HAVE_ZLIB 1) @@ -213,6 +151,88 @@ else() set(HAVE_ZLIB 0) endif() +# Determine whether your compiler supports move semantics. + +check_cxx_source_compiles(" + #ifdef __clang__ + # pragma clang diagnostic error \"-Wc++11-extensions\" + #endif + #include + int func(int &&x) { return x - 1; } + int main() { return func(std::move(1)); } +" TAGLIB_USE_MOVE_SEMANTICS) + +# Determine where shared_ptr is defined regardless of C++11 support. + +check_cxx_source_compiles(" + #include + int main() { std::tr1::shared_ptr x; return 0; } +" TAGLIB_USE_STD_SHARED_PTR) + +if(NOT TAGLIB_USE_STD_SHARED_PTR) + check_cxx_source_compiles(" + #include + int main() { std::tr1::shared_ptr x; return 0; } + " TAGLIB_USE_TR1_SHARED_PTR) + + if(NOT TAGLIB_USE_TR1_SHARED_PTR) + check_cxx_source_compiles(" + #include + int main() { boost::shared_ptr x; return 0; } + " TAGLIB_USE_BOOST_SHARED_PTR) + endif() +endif() + +# Determine which kind of atomic operations your compiler supports. + +if(NOT TAGLIB_USE_STD_SHARED_PTR AND NOT TAGLIB_USE_TR1_SHARED_PTR AND NOT TAGLIB_USE_BOOST_SHARED_PTR) + check_cxx_source_compiles(" + int main() { + volatile int x; + __sync_add_and_fetch(&x, 1); + int y = __sync_sub_and_fetch(&x, 1); + return 0; + } + " TAGLIB_USE_GCC_ATOMIC) + + if(NOT TAGLIB_USE_GCC_ATOMIC) + check_cxx_source_compiles(" + #include + int main() { + volatile int32_t x; + OSAtomicIncrement32Barrier(&x); + int32_t y = OSAtomicDecrement32Barrier(&x); + return 0; + } + " TAGLIB_USE_MAC_ATOMIC) + + if(NOT TAGLIB_USE_MAC_ATOMIC) + check_cxx_source_compiles(" + #include + int main() { + volatile LONG x; + InterlockedIncrement(&x); + LONG y = InterlockedDecrement(&x); + return 0; + } + " TAGLIB_USE_WIN_ATOMIC) + + if(NOT TAGLIB_USE_WIN_ATOMIC) + check_cxx_source_compiles(" + #include + int main() { + volatile int x; + __sync_add_and_fetch(&x, 1); + int y = __sync_sub_and_fetch(&x, 1); + return 0; + } + " TAGLIB_USE_IA64_ATOMIC) + endif() + endif() + endif() +endif() + +# Determine whether CppUnit is installed. set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules) find_package(CppUnit) diff --git a/bindings/c/tag_c.cpp b/bindings/c/tag_c.cpp index b1af613c..5b739d6f 100644 --- a/bindings/c/tag_c.cpp +++ b/bindings/c/tag_c.cpp @@ -19,10 +19,7 @@ * USA * ***************************************************************************/ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - +#include "taglib_config.h" #include #include #include diff --git a/config-taglib.h.cmake b/config-taglib.h.cmake deleted file mode 100644 index 39b53400..00000000 --- a/config-taglib.h.cmake +++ /dev/null @@ -1,56 +0,0 @@ -/* config-taglib.h. Generated by cmake from config-taglib.h.cmake */ - -/* Indicates the endianness of your target system */ -#cmakedefine TAGLIB_LITTLE_ENDIAN 1 -#cmakedefine TAGLIB_BIG_ENDIAN 1 - -/* Size of integral types */ -#cmakedefine SIZEOF_SHORT ${SIZEOF_SHORT} -#cmakedefine SIZEOF_INT ${SIZEOF_INT} -#cmakedefine SIZEOF_LONGLONG ${SIZEOF_LONGLONG} -#cmakedefine SIZEOF_WCHAR_T ${SIZEOF_WCHAR_T} -#cmakedefine SIZEOF_FLOAT ${SIZEOF_FLOAT} -#cmakedefine SIZEOF_DOUBLE ${SIZEOF_DOUBLE} -#cmakedefine SIZEOF_LONGDOUBLE ${SIZEOF_LONGDOUBLE} - -/* Defined if your compiler supports the move semantics */ -#cmakedefine SUPPORT_MOVE_SEMANTICS 1 - -/* Defined if your compiler supports std::wstring */ -#cmakedefine HAVE_STD_WSTRING 1 - -/* Defined if your compiler supports some byte swap functions */ -#cmakedefine HAVE_GCC_BYTESWAP_16 1 -#cmakedefine HAVE_GCC_BYTESWAP_32 1 -#cmakedefine HAVE_GCC_BYTESWAP_64 1 -#cmakedefine HAVE_GLIBC_BYTESWAP 1 -#cmakedefine HAVE_MSC_BYTESWAP 1 -#cmakedefine HAVE_MAC_BYTESWAP 1 -#cmakedefine HAVE_OPENBSD_BYTESWAP 1 - -/* Defined if your compiler supports shared_ptr */ -#cmakedefine HAVE_STD_SHARED_PTR 1 -#cmakedefine HAVE_TR1_SHARED_PTR 1 -#cmakedefine HAVE_BOOST_SHARED_PTR 1 - -/* Defined if your compiler supports some atomic operations */ -#cmakedefine HAVE_GCC_ATOMIC 1 -#cmakedefine HAVE_MAC_ATOMIC 1 -#cmakedefine HAVE_WIN_ATOMIC 1 -#cmakedefine HAVE_IA64_ATOMIC 1 - -/* Defined if your compiler supports some safer version of sprintf */ -#cmakedefine HAVE_SNPRINTF 1 -#cmakedefine HAVE_SPRINTF_S 1 - -/* Defined if your compiler supports codecvt */ -#cmakedefine HAVE_STD_CODECVT 1 - -/* Defined if you have libz */ -#cmakedefine HAVE_ZLIB 1 - -#cmakedefine NO_ITUNES_HACKS 1 -#cmakedefine WITH_ASF 1 -#cmakedefine WITH_MP4 1 - -#cmakedefine TESTS_DIR "@TESTS_DIR@" diff --git a/config.h.cmake b/config.h.cmake new file mode 100644 index 00000000..9fe798ef --- /dev/null +++ b/config.h.cmake @@ -0,0 +1,32 @@ +/* config.h. Generated by cmake from config.h.cmake */ + +/* Indicates the byte order of your target system */ +/* 1 if little-endian, 2 if big-endian. */ +#cmakedefine SYSTEM_BYTEORDER ${SYSTEM_BYTEORDER} + +/* Size of floating point types */ +#cmakedefine SIZEOF_FLOAT ${SIZEOF_FLOAT} +#cmakedefine SIZEOF_DOUBLE ${SIZEOF_DOUBLE} +#cmakedefine SIZEOF_LONGDOUBLE ${SIZEOF_LONGDOUBLE} + +/* Defined if your compiler supports some byte swap functions */ +#cmakedefine HAVE_GCC_BYTESWAP_16 1 +#cmakedefine HAVE_GCC_BYTESWAP_32 1 +#cmakedefine HAVE_GCC_BYTESWAP_64 1 +#cmakedefine HAVE_GLIBC_BYTESWAP 1 +#cmakedefine HAVE_MSC_BYTESWAP 1 +#cmakedefine HAVE_MAC_BYTESWAP 1 +#cmakedefine HAVE_OPENBSD_BYTESWAP 1 + +/* Defined if your compiler supports some safer version of sprintf */ +#cmakedefine HAVE_SNPRINTF 1 +#cmakedefine HAVE_SPRINTF_S 1 + +/* Defined if your compiler supports codecvt */ +#cmakedefine HAVE_STD_CODECVT 1 + +/* Defined if you have libz */ +#cmakedefine HAVE_ZLIB 1 + +#cmakedefine TESTS_DIR "@TESTS_DIR@" + diff --git a/taglib/asf/asfattribute.cpp b/taglib/asf/asfattribute.cpp index a626eeb4..302af77f 100644 --- a/taglib/asf/asfattribute.cpp +++ b/taglib/asf/asfattribute.cpp @@ -125,7 +125,7 @@ ASF::Attribute &ASF::Attribute::operator=(const ASF::Attribute &other) return *this; } -#ifdef SUPPORT_MOVE_SEMANTICS +#ifdef TAGLIB_USE_MOVE_SEMANTICS ASF::Attribute &ASF::Attribute::operator=(ASF::Attribute &&other) { diff --git a/taglib/asf/asfattribute.h b/taglib/asf/asfattribute.h index 6bc9a847..9740cb18 100644 --- a/taglib/asf/asfattribute.h +++ b/taglib/asf/asfattribute.h @@ -115,12 +115,12 @@ namespace TagLib */ ASF::Attribute &operator=(const Attribute &other); -#ifdef SUPPORT_MOVE_SEMANTICS +#ifdef TAGLIB_USE_MOVE_SEMANTICS /*! * Moves the contents of \a other into this item. * - * \note Not available unless SUPPORT_MOVE_SEMANTICS macro is defined. + * \note Not available unless TAGLIB_USE_MOVE_SEMANTICS macro is defined. */ ASF::Attribute &operator=(Attribute &&other); diff --git a/taglib/asf/asfpicture.cpp b/taglib/asf/asfpicture.cpp index 3e23dbb7..62477585 100644 --- a/taglib/asf/asfpicture.cpp +++ b/taglib/asf/asfpicture.cpp @@ -56,7 +56,7 @@ ASF::Picture::Picture(const Picture& other) { } -#ifdef SUPPORT_MOVE_SEMANTICS +#ifdef TAGLIB_USE_MOVE_SEMANTICS ASF::Picture::Picture(Picture &&other) : d(std::move(other.d)) @@ -127,7 +127,7 @@ ASF::Picture& ASF::Picture::operator=(const ASF::Picture& other) return *this; } -#ifdef SUPPORT_MOVE_SEMANTICS +#ifdef TAGLIB_USE_MOVE_SEMANTICS ASF::Picture& ASF::Picture::operator=(ASF::Picture &&other) { diff --git a/taglib/asf/asfpicture.h b/taglib/asf/asfpicture.h index e493428a..5f688898 100644 --- a/taglib/asf/asfpicture.h +++ b/taglib/asf/asfpicture.h @@ -107,12 +107,12 @@ namespace TagLib */ Picture(const Picture& other); -#ifdef SUPPORT_MOVE_SEMANTICS +#ifdef TAGLIB_USE_MOVE_SEMANTICS /*! * Constructs an picture equivalent to \a other. * - * \note Not available unless SUPPORT_MOVE_SEMANTICS macro is defined. + * \note Not available unless TAGLIB_USE_MOVE_SEMANTICS macro is defined. */ Picture(Picture &&other); @@ -128,12 +128,12 @@ namespace TagLib */ Picture& operator=(const Picture& other); -#ifdef SUPPORT_MOVE_SEMANTICS +#ifdef TAGLIB_USE_MOVE_SEMANTICS /*! * Moves the contents of \a other into this picture. * - * \note Not available unless SUPPORT_MOVE_SEMANTICS macro is defined. + * \note Not available unless TAGLIB_USE_MOVE_SEMANTICS macro is defined. */ Picture& operator=(Picture &&other); diff --git a/taglib/asf/asfproperties.cpp b/taglib/asf/asfproperties.cpp index 11d43b9d..638baf6e 100644 --- a/taglib/asf/asfproperties.cpp +++ b/taglib/asf/asfproperties.cpp @@ -23,8 +23,7 @@ * http://www.mozilla.org/MPL/ * ***************************************************************************/ -#include "config.h" - +#include "taglib_config.h" #include #include #include "asfproperties.h" diff --git a/taglib/asf/asftag.cpp b/taglib/asf/asftag.cpp index 70881209..0767817f 100644 --- a/taglib/asf/asftag.cpp +++ b/taglib/asf/asftag.cpp @@ -23,8 +23,7 @@ * http://www.mozilla.org/MPL/ * ***************************************************************************/ -#include "config.h" - +#include "taglib_config.h" #include #include "asftag.h" diff --git a/taglib/fileref.cpp b/taglib/fileref.cpp index e7ee7d52..f923f3ad 100644 --- a/taglib/fileref.cpp +++ b/taglib/fileref.cpp @@ -27,7 +27,7 @@ * http://www.mozilla.org/MPL/ * ***************************************************************************/ -#include +#include "taglib_config.h" #ifdef _WIN32 # include @@ -96,7 +96,7 @@ FileRef::FileRef(const FileRef &ref) { } -#ifdef SUPPORT_MOVE_SEMANTICS +#ifdef TAGLIB_USE_MOVE_SEMANTICS FileRef::FileRef(FileRef &&ref) : d(std::move(ref.d)) @@ -193,7 +193,7 @@ FileRef &FileRef::operator=(const FileRef &ref) return *this; } -#ifdef SUPPORT_MOVE_SEMANTICS +#ifdef TAGLIB_USE_MOVE_SEMANTICS FileRef &FileRef::operator=(FileRef &&ref) { diff --git a/taglib/fileref.h b/taglib/fileref.h index 4d7670c3..f11e3d5d 100644 --- a/taglib/fileref.h +++ b/taglib/fileref.h @@ -143,12 +143,12 @@ namespace TagLib { */ FileRef(const FileRef &ref); -#ifdef SUPPORT_MOVE_SEMANTICS +#ifdef TAGLIB_USE_MOVE_SEMANTICS /*! * Move \a ref into the FileRef. * - * \note Not available unless SUPPORT_MOVE_SEMANTICS macro is defined. + * \note Not available unless TAGLIB_USE_MOVE_SEMANTICS macro is defined. */ FileRef(FileRef &&ref); @@ -242,12 +242,12 @@ namespace TagLib { */ FileRef &operator=(const FileRef &ref); -#ifdef SUPPORT_MOVE_SEMANTICS +#ifdef TAGLIB_USE_MOVE_SEMANTICS /*! * Moves \a ref into this FileRef. * - * \note Not available unless SUPPORT_MOVE_SEMANTICS macro is defined. + * \note Not available unless TAGLIB_USE_MOVE_SEMANTICS macro is defined. */ FileRef &operator=(FileRef &&ref); diff --git a/taglib/mp4/mp4coverart.cpp b/taglib/mp4/mp4coverart.cpp index 76abf706..56e6aa52 100644 --- a/taglib/mp4/mp4coverart.cpp +++ b/taglib/mp4/mp4coverart.cpp @@ -56,7 +56,7 @@ MP4::CoverArt & return *this; } -#ifdef SUPPORT_MOVE_SEMANTICS +#ifdef TAGLIB_USE_MOVE_SEMANTICS MP4::CoverArt & MP4::CoverArt::operator=(CoverArt &&item) diff --git a/taglib/mp4/mp4coverart.h b/taglib/mp4/mp4coverart.h index 3b78d747..e2b82c79 100644 --- a/taglib/mp4/mp4coverart.h +++ b/taglib/mp4/mp4coverart.h @@ -54,7 +54,7 @@ namespace TagLib { CoverArt(const CoverArt &item); CoverArt &operator=(const CoverArt &item); -#ifdef SUPPORT_MOVE_SEMANTICS +#ifdef TAGLIB_USE_MOVE_SEMANTICS CoverArt &operator=(CoverArt &&item); #endif diff --git a/taglib/mp4/mp4item.cpp b/taglib/mp4/mp4item.cpp index 2de06133..23749e76 100644 --- a/taglib/mp4/mp4item.cpp +++ b/taglib/mp4/mp4item.cpp @@ -36,7 +36,7 @@ namespace String format(const char *fmt, ...) { va_list args; - va_start(args,fmt); + va_start(args, fmt); char buf[256]; @@ -93,7 +93,7 @@ MP4::Item::Item(const Item &item) { } -#ifdef SUPPORT_MOVE_SEMANTICS +#ifdef TAGLIB_USE_MOVE_SEMANTICS MP4::Item::Item(Item &&item) : d(std::move(item.d)) @@ -109,7 +109,7 @@ MP4::Item & return *this; } -#ifdef SUPPORT_MOVE_SEMANTICS +#ifdef TAGLIB_USE_MOVE_SEMANTICS MP4::Item & MP4::Item::operator=(Item &&item) diff --git a/taglib/mp4/mp4item.h b/taglib/mp4/mp4item.h index e78acee5..91fd4c15 100644 --- a/taglib/mp4/mp4item.h +++ b/taglib/mp4/mp4item.h @@ -56,12 +56,12 @@ namespace TagLib { Item(); Item(const Item &item); -#ifdef SUPPORT_MOVE_SEMANTICS +#ifdef TAGLIB_USE_MOVE_SEMANTICS Item(Item &&item); #endif Item &operator=(const Item &item); -#ifdef SUPPORT_MOVE_SEMANTICS +#ifdef TAGLIB_USE_MOVE_SEMANTICS Item &operator=(Item &&item); #endif ~Item(); diff --git a/taglib/mp4/mp4properties.cpp b/taglib/mp4/mp4properties.cpp index 933180b1..5daf867d 100644 --- a/taglib/mp4/mp4properties.cpp +++ b/taglib/mp4/mp4properties.cpp @@ -23,8 +23,7 @@ * http://www.mozilla.org/MPL/ * ***************************************************************************/ -#include "config.h" - +#include "taglib_config.h" #include #include #include "mp4file.h" diff --git a/taglib/mp4/mp4tag.cpp b/taglib/mp4/mp4tag.cpp index 6c0174ca..e5df102f 100644 --- a/taglib/mp4/mp4tag.cpp +++ b/taglib/mp4/mp4tag.cpp @@ -23,8 +23,7 @@ * http://www.mozilla.org/MPL/ * ***************************************************************************/ -#include "config.h" - +#include "taglib_config.h" #include #include #include diff --git a/taglib/mpeg/id3v2/id3v2frame.cpp b/taglib/mpeg/id3v2/id3v2frame.cpp index 60e0a248..ad015e43 100644 --- a/taglib/mpeg/id3v2/id3v2frame.cpp +++ b/taglib/mpeg/id3v2/id3v2frame.cpp @@ -24,6 +24,7 @@ ***************************************************************************/ #include "config.h" +#include "taglib_config.h" #if HAVE_ZLIB #include diff --git a/taglib/mpeg/id3v2/id3v2framefactory.cpp b/taglib/mpeg/id3v2/id3v2framefactory.cpp index 4dceb26a..534eeefc 100644 --- a/taglib/mpeg/id3v2/id3v2framefactory.cpp +++ b/taglib/mpeg/id3v2/id3v2framefactory.cpp @@ -24,7 +24,7 @@ ***************************************************************************/ #include "config.h" - +#include "taglib_config.h" #include #include "id3v2framefactory.h" @@ -134,7 +134,7 @@ Frame *FrameFactory::createFrame(const ByteVector &origData, Header *tagHeader) // TagLib doesn't mess with encrypted frames, so just treat them // as unknown frames. -#if HAVE_ZLIB == 0 +#if !defined(HAVE_ZLIB) || HAVE_ZLIB == 0 if(header->compression()) { debug("Compressed frames are currently not supported."); return new UnknownFrame(data, header); diff --git a/taglib/mpeg/mpegheader.cpp b/taglib/mpeg/mpegheader.cpp index 348cb81d..a71035b7 100644 --- a/taglib/mpeg/mpegheader.cpp +++ b/taglib/mpeg/mpegheader.cpp @@ -28,7 +28,6 @@ #include #include #include - #include "mpegheader.h" using namespace TagLib; @@ -78,7 +77,7 @@ MPEG::Header::Header(const Header &h) { } -#ifdef SUPPORT_MOVE_SEMANTICS +#ifdef TAGLIB_USE_MOVE_SEMANTICS MPEG::Header::Header(Header &&h) : d(std::move(h.d)) @@ -157,7 +156,7 @@ MPEG::Header &MPEG::Header::operator=(const Header &h) return *this; } -#ifdef SUPPORT_MOVE_SEMANTICS +#ifdef TAGLIB_USE_MOVE_SEMANTICS MPEG::Header &MPEG::Header::operator=(Header &&h) { diff --git a/taglib/mpeg/mpegheader.h b/taglib/mpeg/mpegheader.h index 330746ce..5041b01e 100644 --- a/taglib/mpeg/mpegheader.h +++ b/taglib/mpeg/mpegheader.h @@ -57,12 +57,12 @@ namespace TagLib { */ Header(const Header &h); -#ifdef SUPPORT_MOVE_SEMANTICS +#ifdef TAGLIB_USE_MOVE_SEMANTICS /*! * Moves \a h into this Header. * - * \note Not available unless SUPPORT_MOVE_SEMANTICS macro is defined. + * \note Not available unless TAGLIB_USE_MOVE_SEMANTICS macro is defined. */ Header(Header &&h); @@ -166,12 +166,12 @@ namespace TagLib { */ Header &operator=(const Header &h); -#ifdef SUPPORT_MOVE_SEMANTICS +#ifdef TAGLIB_USE_MOVE_SEMANTICS /*! * Moves \a h into this Header. * - * \note Not available unless SUPPORT_MOVE_SEMANTICS macro is defined. + * \note Not available unless TAGLIB_USE_MOVE_SEMANTICS macro is defined. */ Header &operator=(Header &&h); diff --git a/taglib/taglib_config.h.cmake b/taglib/taglib_config.h.cmake index 0f499e2c..8231bff0 100644 --- a/taglib/taglib_config.h.cmake +++ b/taglib/taglib_config.h.cmake @@ -1,4 +1,19 @@ /* taglib_config.h. Generated by cmake from taglib_config.h.cmake */ -#define TAGLIB_WITH_ASF 1 -#define TAGLIB_WITH_MP4 1 +/* The variables below indicate the compiler capability. */ +/* DO NOT MODIFY them manually. It may break the binary compatibility. */ + +/* Defined if your compiler supports the move semantics */ +#cmakedefine TAGLIB_USE_MOVE_SEMANTICS 1 + +/* Defined if your compiler supports shared_ptr */ +#cmakedefine TAGLIB_USE_STD_SHARED_PTR 1 +#cmakedefine TAGLIB_USE_TR1_SHARED_PTR 1 +#cmakedefine TAGLIB_USE_BOOST_SHARED_PTR 1 + +/* Defined if your compiler supports some atomic operations */ +#cmakedefine TAGLIB_USE_GCC_ATOMIC 1 +#cmakedefine TAGLIB_USE_MAC_ATOMIC 1 +#cmakedefine TAGLIB_USE_WIN_ATOMIC 1 +#cmakedefine TAGLIB_USE_IA64_ATOMIC 1 + diff --git a/taglib/taglib_export.h b/taglib/taglib_export.h index 3e868551..737ae644 100644 --- a/taglib/taglib_export.h +++ b/taglib/taglib_export.h @@ -40,8 +40,4 @@ #define TAGLIB_EXPORT #endif -#ifndef TAGLIB_NO_CONFIG -#include "taglib_config.h" -#endif - #endif diff --git a/taglib/toolkit/taglib.h b/taglib/toolkit/taglib.h index 567ca723..d52c1c18 100644 --- a/taglib/toolkit/taglib.h +++ b/taglib/toolkit/taglib.h @@ -26,7 +26,7 @@ #ifndef TAGLIB_H #define TAGLIB_H -#include "config.h" +#include "taglib_config.h" #define TAGLIB_MAJOR_VERSION 1 #define TAGLIB_MINOR_VERSION 8 @@ -38,8 +38,6 @@ #define TAGLIB_CONSTRUCT_BITSET(x) static_cast(x) #endif -#include - #ifdef _WIN32 # if !defined(NOMINMAX) # define NOMINMAX @@ -53,72 +51,6 @@ # include #endif -// Check the widths of integral types. - -#if SIZEOF_SHORT != 2 -# error TagLib requires that short is 16-bit wide. -#endif - -#if SIZEOF_INT != 4 -# error TagLib requires that int is 32-bit wide. -#endif - -#if SIZEOF_LONGLONG != 8 -# error TagLib requires that long long is 64-bit wide. -#endif - -#if SIZEOF_WCHAR_T < 2 -# error TagLib requires that wchar_t is sufficient to store a UTF-16 char. -#endif - -// Optimized byte swap functions. - -#if defined(HAVE_MSC_BYTESWAP) -# include -#elif defined(HAVE_GLIBC_BYTESWAP) -# include -#elif defined(HAVE_MAC_BYTESWAP) -# include -#elif defined(HAVE_OPENBSD_BYTESWAP) -# include -#endif - -#if defined(HAVE_GCC_BYTESWAP_16) -# define TAGLIB_BYTESWAP_16(x) __builtin_bswap16(x) -#elif defined(HAVE_MSC_BYTESWAP) -# define TAGLIB_BYTESWAP_16(x) _byteswap_ushort(x) -#elif defined(HAVE_GLIBC_BYTESWAP) -# define TAGLIB_BYTESWAP_16(x) __bswap_16(x) -#elif defined(HAVE_MAC_BYTESWAP) -# define TAGLIB_BYTESWAP_16(x) OSSwapInt16(x) -#elif defined(HAVE_OPENBSD_BYTESWAP) -# define TAGLIB_BYTESWAP_16(x) swap16(x) -#endif - -#if defined(HAVE_GCC_BYTESWAP_32) -# define TAGLIB_BYTESWAP_32(x) __builtin_bswap32(x) -#elif defined(HAVE_MSC_BYTESWAP) -# define TAGLIB_BYTESWAP_32(x) _byteswap_ulong(x) -#elif defined(HAVE_GLIBC_BYTESWAP) -# define TAGLIB_BYTESWAP_32(x) __bswap_32(x) -#elif defined(HAVE_MAC_BYTESWAP) -# define TAGLIB_BYTESWAP_32(x) OSSwapInt32(x) -#elif defined(HAVE_OPENBSD_BYTESWAP) -# define TAGLIB_BYTESWAP_32(x) swap32(x) -#endif - -#if defined(HAVE_GCC_BYTESWAP_64) -# define TAGLIB_BYTESWAP_64(x) __builtin_bswap64(x) -#elif defined(HAVE_MSC_BYTESWAP) -# define TAGLIB_BYTESWAP_64(x) _byteswap_uint64(x) -#elif defined(HAVE_GLIBC_BYTESWAP) -# define TAGLIB_BYTESWAP_64(x) __bswap_64(x) -#elif defined(HAVE_MAC_BYTESWAP) -# define TAGLIB_BYTESWAP_64(x) OSSwapInt64(x) -#elif defined(HAVE_OPENBSD_BYTESWAP) -# define TAGLIB_BYTESWAP_64(x) swap64(x) -#endif - //! A namespace for all TagLib related classes and functions /*! @@ -143,22 +75,12 @@ namespace TagLib { typedef unsigned long ulong; // Offset or length type for I/O streams. - // In Win32, always 64bit. Otherwise, equivalent to off_t. + // In Win32, always signed 64-bit. Otherwise, equivalent to off_t. #ifdef _WIN32 typedef LONGLONG offset_t; #else typedef off_t offset_t; #endif - - /*! - * Unfortunately std::wstring isn't defined on some systems, (i.e. GCC < 3) - * so I'm providing something here that should be constant. - */ -#ifdef HAVE_STD_WSTRING - typedef std::wstring wstring; -#else - typedef std::basic_string wstring; -#endif } /*! diff --git a/taglib/toolkit/tbytevector.cpp b/taglib/toolkit/tbytevector.cpp index b4f732f8..c58dbb3d 100644 --- a/taglib/toolkit/tbytevector.cpp +++ b/taglib/toolkit/tbytevector.cpp @@ -23,14 +23,26 @@ * http://www.mozilla.org/MPL/ * ***************************************************************************/ +#include "config.h" + #include #include #include #include #include + +#if defined(HAVE_MSC_BYTESWAP) +# include +#elif defined(HAVE_GLIBC_BYTESWAP) +# include +#elif defined(HAVE_MAC_BYTESWAP) +# include +#elif defined(HAVE_OPENBSD_BYTESWAP) +# include +#endif + #include #include - #include "tbytevector.h" // This is a bit ugly to keep writing over and over again. @@ -187,9 +199,25 @@ inline T byteSwap(T x) template <> inline ushort byteSwap(ushort x) { -#ifdef TAGLIB_BYTESWAP_16 +#if defined(HAVE_GCC_BYTESWAP_16) - return TAGLIB_BYTESWAP_16(x); + return __builtin_bswap16(x); + +#elif defined(HAVE_MSC_BYTESWAP) + + return _byteswap_ushort(x); + +#elif defined(HAVE_GLIBC_BYTESWAP) + + return __bswap_16(x); + +#elif defined(HAVE_MAC_BYTESWAP) + + return OSSwapInt16(x); + +#elif defined(HAVE_OPENBSD_BYTESWAP) + + return swap16(x); #else @@ -201,9 +229,25 @@ inline ushort byteSwap(ushort x) template <> inline uint byteSwap(uint x) { -#ifdef TAGLIB_BYTESWAP_32 +#if defined(HAVE_GCC_BYTESWAP_32) - return TAGLIB_BYTESWAP_32(x); + return __builtin_bswap32(x); + +#elif defined(HAVE_MSC_BYTESWAP) + + return _byteswap_ulong(x); + +#elif defined(HAVE_GLIBC_BYTESWAP) + + return __bswap_32(x); + +#elif defined(HAVE_MAC_BYTESWAP) + + return OSSwapInt32(x); + +#elif defined(HAVE_OPENBSD_BYTESWAP) + + return swap32(x); #else @@ -218,9 +262,25 @@ inline uint byteSwap(uint x) template <> inline ulonglong byteSwap(ulonglong x) { -#ifdef TAGLIB_BYTESWAP_64 +#if defined(HAVE_GCC_BYTESWAP_64) - return TAGLIB_BYTESWAP_64(x); + return __builtin_bswap64(x); + +#elif defined(HAVE_MSC_BYTESWAP) + + return _byteswap_uint64(x); + +#elif defined(HAVE_GLIBC_BYTESWAP) + + return __bswap_64(x); + +#elif defined(HAVE_MAC_BYTESWAP) + + return OSSwapInt64(x); + +#elif defined(HAVE_OPENBSD_BYTESWAP) + + return swap64(x); #else @@ -246,7 +306,7 @@ namespace { template inline T toNumber(const ByteVector &v, size_t offset) { -#ifdef TAGLIB_LITTLE_ENDIAN +#if SYSTEM_BYTEORDER == 1 static const bool swap = (ENDIAN == BigEndian); #else static const bool swap = (ENDIAN == LittleEndian); @@ -281,7 +341,7 @@ inline T toNumber(const ByteVector &v, size_t offset) template inline ByteVector fromNumber(T value) { -#ifdef TAGLIB_LITTLE_ENDIAN +#if SYSTEM_BYTEORDER == 1 static const bool swap = (ENDIAN == BigEndian); #else static const bool swap = (ENDIAN == LittleEndian); @@ -293,23 +353,6 @@ inline ByteVector fromNumber(T value) return ByteVector(reinterpret_cast(&value), sizeof(T)); } -template -inline void appendNumber(ByteVector &v, T value) -{ -#ifdef TAGLIB_LITTLE_ENDIAN - static const bool swap = !IS_LITTLE_ENDIAN; -#else - static const bool swap = IS_LITTLE_ENDIAN; -#endif - - if(swap) - value = byteSwap(value); - - const size_t offset = v.size(); - v.resize(offset + sizeof(T)); - ::memcpy(v.data() + offset, reinterpret_cast(&value), sizeof(T)); -} - class ByteVector::ByteVectorPrivate { public: @@ -443,7 +486,7 @@ ByteVector::ByteVector(const ByteVector &v, size_t offset, size_t length) { } -#ifdef SUPPORT_MOVE_SEMANTICS +#ifdef TAGLIB_USE_MOVE_SEMANTICS ByteVector::ByteVector(ByteVector &&v) : d(std::move(v.d)) @@ -809,7 +852,7 @@ float ByteVector::toFloat32BE(size_t offset) const uint tmp; ::memcpy(&tmp, data() + offset, 4); -# ifdef TAGLIB_LITTLE_ENDIAN +# if SYSTEM_BYTEORDER == 1 tmp = byteSwap(tmp); # endif @@ -867,7 +910,7 @@ double ByteVector::toFloat64BE(size_t offset) const ulonglong tmp; ::memcpy(&tmp, data() + offset, 8); -# ifdef TAGLIB_LITTLE_ENDIAN +# if SYSTEM_BYTEORDER == 1 tmp = byteSwap(tmp); # endif @@ -1022,7 +1065,7 @@ ByteVector &ByteVector::operator=(const ByteVector &v) return *this; } -#ifdef SUPPORT_MOVE_SEMANTICS +#ifdef TAGLIB_USE_MOVE_SEMANTICS ByteVector &ByteVector::operator=(ByteVector &&v) { diff --git a/taglib/toolkit/tbytevector.h b/taglib/toolkit/tbytevector.h index 1075afbf..e564e3d3 100644 --- a/taglib/toolkit/tbytevector.h +++ b/taglib/toolkit/tbytevector.h @@ -68,12 +68,12 @@ namespace TagLib { */ ByteVector(const ByteVector &v); -#ifdef SUPPORT_MOVE_SEMANTICS +#ifdef TAGLIB_USE_MOVE_SEMANTICS /*! * Constructs a byte vector equivalent to \a v. * - * \note Not available unless SUPPORT_MOVE_SEMANTICS macro is defined. + * \note Not available unless TAGLIB_USE_MOVE_SEMANTICS macro is defined. */ ByteVector(ByteVector &&v); @@ -502,12 +502,12 @@ namespace TagLib { */ ByteVector &operator=(const ByteVector &v); -#ifdef SUPPORT_MOVE_SEMANTICS +#ifdef TAGLIB_USE_MOVE_SEMANTICS /*! * Moves \a v into this ByteVector. * - * \note Not available unless SUPPORT_MOVE_SEMANTICS macro is defined. + * \note Not available unless TAGLIB_USE_MOVE_SEMANTICS macro is defined. */ ByteVector &operator=(ByteVector &&v); diff --git a/taglib/toolkit/tbytevectorlist.cpp b/taglib/toolkit/tbytevectorlist.cpp index 505c3bf8..d0d89b4c 100644 --- a/taglib/toolkit/tbytevectorlist.cpp +++ b/taglib/toolkit/tbytevectorlist.cpp @@ -73,7 +73,7 @@ ByteVectorList::ByteVectorList(const ByteVectorList &l) : List(l) { } -#ifdef SUPPORT_MOVE_SEMANTICS +#ifdef TAGLIB_USE_MOVE_SEMANTICS ByteVectorList::ByteVectorList(ByteVectorList &&l) : List(l) { @@ -87,7 +87,7 @@ ByteVectorList &ByteVectorList::operator=(const ByteVectorList &l) return *this; } -#ifdef SUPPORT_MOVE_SEMANTICS +#ifdef TAGLIB_USE_MOVE_SEMANTICS ByteVectorList &ByteVectorList::operator=(ByteVectorList &&l) { diff --git a/taglib/toolkit/tbytevectorlist.h b/taglib/toolkit/tbytevectorlist.h index ce7cc800..ab099e8b 100644 --- a/taglib/toolkit/tbytevectorlist.h +++ b/taglib/toolkit/tbytevectorlist.h @@ -54,12 +54,12 @@ namespace TagLib { */ ByteVectorList(const ByteVectorList &l); -#ifdef SUPPORT_MOVE_SEMANTICS +#ifdef TAGLIB_USE_MOVE_SEMANTICS /*! * Moves \a l into this ByteVectorList. * - * \note Not available unless SUPPORT_MOVE_SEMANTICS macro is defined. + * \note Not available unless TAGLIB_USE_MOVE_SEMANTICS macro is defined. */ ByteVectorList(ByteVectorList &&l); @@ -72,12 +72,12 @@ namespace TagLib { */ ByteVectorList &operator=(const ByteVectorList &l); -#ifdef SUPPORT_MOVE_SEMANTICS +#ifdef TAGLIB_USE_MOVE_SEMANTICS /*! * Moves \a l into this ByteVectorList. * - * \note Not available unless SUPPORT_MOVE_SEMANTICS macro is defined. + * \note Not available unless TAGLIB_USE_MOVE_SEMANTICS macro is defined. */ ByteVectorList &operator=(ByteVectorList &&l); diff --git a/taglib/toolkit/tfilestream.cpp b/taglib/toolkit/tfilestream.cpp index e3ef13d5..0f120ac0 100644 --- a/taglib/toolkit/tfilestream.cpp +++ b/taglib/toolkit/tfilestream.cpp @@ -98,7 +98,7 @@ namespace if(len == 0) return String::null; - wstring wstr(len, L'\0'); + std::wstring wstr(len, L'\0'); MultiByteToWideChar(CP_ACP, 0, name.str().c_str(), -1, &wstr[0], len); return String(wstr); diff --git a/taglib/toolkit/tlist.h b/taglib/toolkit/tlist.h index 48a1d356..b8aa6641 100644 --- a/taglib/toolkit/tlist.h +++ b/taglib/toolkit/tlist.h @@ -70,12 +70,12 @@ namespace TagLib { */ List(const List &l); -#ifdef SUPPORT_MOVE_SEMANTICS +#ifdef TAGLIB_USE_MOVE_SEMANTICS /*! * Moves \a l into this List. * - * \note Not available unless SUPPORT_MOVE_SEMANTICS macro is defined. + * \note Not available unless TAGLIB_USE_MOVE_SEMANTICS macro is defined. */ List(List &&l); @@ -135,13 +135,13 @@ namespace TagLib { */ List &append(const List &l); -#ifdef SUPPORT_MOVE_SEMANTICS +#ifdef TAGLIB_USE_MOVE_SEMANTICS /*! * Appends \a item to the end of the list and returns a reference to the * list. * - * \note Not available unless SUPPORT_MOVE_SEMANTICS macro is defined. + * \note Not available unless TAGLIB_USE_MOVE_SEMANTICS macro is defined. */ List &append(T &&item); @@ -149,7 +149,7 @@ namespace TagLib { * Appends all of the values in \a l to the end of the list and returns a * reference to the list. * - * \note Not available unless SUPPORT_MOVE_SEMANTICS macro is defined. + * \note Not available unless TAGLIB_USE_MOVE_SEMANTICS macro is defined. */ List &append(List &&l); @@ -167,13 +167,13 @@ namespace TagLib { */ List &prepend(const List &l); -#ifdef SUPPORT_MOVE_SEMANTICS +#ifdef TAGLIB_USE_MOVE_SEMANTICS /*! * Prepends \a item to the beginning list and returns a reference to the * list. * - * \note Not available unless SUPPORT_MOVE_SEMANTICS macro is defined. + * \note Not available unless TAGLIB_USE_MOVE_SEMANTICS macro is defined. */ List &prepend(T &&item); @@ -181,7 +181,7 @@ namespace TagLib { * Prepends all of the items in \a l to the beginning list and returns a * reference to the list. * - * \note Not available unless SUPPORT_MOVE_SEMANTICS macro is defined. + * \note Not available unless TAGLIB_USE_MOVE_SEMANTICS macro is defined. */ List &prepend(List &&l); @@ -272,12 +272,12 @@ namespace TagLib { */ List &operator=(const List &l); -#ifdef SUPPORT_MOVE_SEMANTICS +#ifdef TAGLIB_USE_MOVE_SEMANTICS /*! * Moves \a l into this List. * - * \note Not available unless SUPPORT_MOVE_SEMANTICS macro is defined. + * \note Not available unless TAGLIB_USE_MOVE_SEMANTICS macro is defined. */ List &operator=(List &&l); diff --git a/taglib/toolkit/tlist.tcc b/taglib/toolkit/tlist.tcc index 6a2baf2e..85d0ca72 100644 --- a/taglib/toolkit/tlist.tcc +++ b/taglib/toolkit/tlist.tcc @@ -55,7 +55,7 @@ public: ListPrivate() : ListPrivateBase() {} ListPrivate(const std::list &l) : ListPrivateBase(), list(l) {} -#ifdef SUPPORT_MOVE_SEMANTICS +#ifdef TAGLIB_USE_MOVE_SEMANTICS ListPrivate(std::list &&l) : ListPrivateBase(), list(l) {} @@ -77,7 +77,7 @@ public: ListPrivate() : ListPrivateBase() {} ListPrivate(const std::list &l) : ListPrivateBase(), list(l) {} -#ifdef SUPPORT_MOVE_SEMANTICS +#ifdef TAGLIB_USE_MOVE_SEMANTICS ListPrivate(std::list &&l) : ListPrivateBase(), list(l) {} @@ -121,7 +121,7 @@ List::List(const List &l) { } -#ifdef SUPPORT_MOVE_SEMANTICS +#ifdef TAGLIB_USE_MOVE_SEMANTICS template List::List(List &&l) @@ -198,7 +198,7 @@ List &List::append(const List &l) return *this; } -#ifdef SUPPORT_MOVE_SEMANTICS +#ifdef TAGLIB_USE_MOVE_SEMANTICS template List &List::append(T &&item) @@ -237,7 +237,7 @@ List &List::prepend(const List &l) return *this; } -#ifdef SUPPORT_MOVE_SEMANTICS +#ifdef TAGLIB_USE_MOVE_SEMANTICS template List &List::prepend(T &&item) @@ -365,7 +365,7 @@ List &List::operator=(const List &l) return *this; } -#ifdef SUPPORT_MOVE_SEMANTICS +#ifdef TAGLIB_USE_MOVE_SEMANTICS template List &List::operator=(List &&l) diff --git a/taglib/toolkit/tmap.h b/taglib/toolkit/tmap.h index b9d4a8fd..927e9f2b 100644 --- a/taglib/toolkit/tmap.h +++ b/taglib/toolkit/tmap.h @@ -73,12 +73,12 @@ namespace TagLib { */ Map(const Map &m); -#ifdef SUPPORT_MOVE_SEMANTICS +#ifdef TAGLIB_USE_MOVE_SEMANTICS /*! * Moves \a m into this Map. * - * \note Not available unless SUPPORT_MOVE_SEMANTICS macro is defined. + * \note Not available unless TAGLIB_USE_MOVE_SEMANTICS macro is defined. */ Map(Map &&m); @@ -119,13 +119,13 @@ namespace TagLib { */ Map &insert(const Key &key, const T &value); -#ifdef SUPPORT_MOVE_SEMANTICS +#ifdef TAGLIB_USE_MOVE_SEMANTICS /*! * Inserts \a value under \a key in the map. If a value for \a key already * exists it will be overwritten. * - * \note Not available unless SUPPORT_MOVE_SEMANTICS macro is defined. + * \note Not available unless TAGLIB_USE_MOVE_SEMANTICS macro is defined. */ Map &insert(const Key &key, T &&value); @@ -197,12 +197,12 @@ namespace TagLib { */ Map &operator=(const Map &m); -#ifdef SUPPORT_MOVE_SEMANTICS +#ifdef TAGLIB_USE_MOVE_SEMANTICS /*! * Moves \a m into this Map. * - * \note Not available unless SUPPORT_MOVE_SEMANTICS macro is defined. + * \note Not available unless TAGLIB_USE_MOVE_SEMANTICS macro is defined. */ Map &operator=(Map &&m); diff --git a/taglib/toolkit/tmap.tcc b/taglib/toolkit/tmap.tcc index 4c224b61..e1c7ac6d 100644 --- a/taglib/toolkit/tmap.tcc +++ b/taglib/toolkit/tmap.tcc @@ -23,8 +23,6 @@ * http://www.mozilla.org/MPL/ * ***************************************************************************/ -#include - namespace TagLib { //////////////////////////////////////////////////////////////////////////////// @@ -42,7 +40,7 @@ public: MapPrivate(const std::map &m) : RefCounter(), map(m) {} -# ifdef SUPPORT_MOVE_SEMANTICS +# ifdef TAGLIB_USE_MOVE_SEMANTICS MapPrivate(std::map &&m) : RefCounter(), map(m) {} @@ -58,7 +56,7 @@ public: MapPrivate(const std::map& m) : map(m) {} -# ifdef SUPPORT_MOVE_SEMANTICS +# ifdef TAGLIB_USE_MOVE_SEMANTICS MapPrivate(std::map &&m) : map(m) {} @@ -85,7 +83,7 @@ Map::Map(const Map &m) { } -#ifdef SUPPORT_MOVE_SEMANTICS +#ifdef TAGLIB_USE_MOVE_SEMANTICS template TagLib::Map::Map(Map &&m) @@ -134,7 +132,7 @@ Map &Map::insert(const Key &key, const T &value) return *this; } -#ifdef SUPPORT_MOVE_SEMANTICS +#ifdef TAGLIB_USE_MOVE_SEMANTICS template Map &Map::insert(const Key &key, T &&value) @@ -223,7 +221,7 @@ Map &Map::operator=(const Map &m) return *this; } -#ifdef SUPPORT_MOVE_SEMANTICS +#ifdef TAGLIB_USE_MOVE_SEMANTICS template Map &Map::operator=(Map &&m) diff --git a/taglib/toolkit/trefcountptr.h b/taglib/toolkit/trefcountptr.h index 56bd9f15..8868861e 100644 --- a/taglib/toolkit/trefcountptr.h +++ b/taglib/toolkit/trefcountptr.h @@ -26,21 +26,21 @@ #ifndef TAGLIB_REFCOUNTPTR_H #define TAGLIB_REFCOUNTPTR_H -#include "config.h" +#include "taglib_config.h" -#if defined(HAVE_STD_SHARED_PTR) +#if defined(TAGLIB_USE_STD_SHARED_PTR) # include -#elif defined(HAVE_TR1_SHARED_PTR) +#elif defined(TAGLIB_USE_TR1_SHARED_PTR) # include -#elif defined(HAVE_BOOST_SHARED_PTR) +#elif defined(TAGLIB_USE_BOOST_SHARED_PTR) # include #else # include -# if defined(HAVE_GCC_ATOMIC) +# if defined(TAGLIB_USE_GCC_ATOMIC) # define TAGLIB_ATOMIC_INT int # define TAGLIB_ATOMIC_INC(x) __sync_add_and_fetch(&x, 1) # define TAGLIB_ATOMIC_DEC(x) __sync_sub_and_fetch(&x, 1) -# elif defined(HAVE_WIN_ATOMIC) +# elif defined(TAGLIB_USE_WIN_ATOMIC) # if !defined(NOMINMAX) # define NOMINMAX # endif @@ -48,12 +48,12 @@ # define TAGLIB_ATOMIC_INT long # define TAGLIB_ATOMIC_INC(x) InterlockedIncrement(&x) # define TAGLIB_ATOMIC_DEC(x) InterlockedDecrement(&x) -# elif defined(HAVE_MAC_ATOMIC) +# elif defined(TAGLIB_USE_MAC_ATOMIC) # include # define TAGLIB_ATOMIC_INT int32_t # define TAGLIB_ATOMIC_INC(x) OSAtomicIncrement32Barrier(&x) # define TAGLIB_ATOMIC_DEC(x) OSAtomicDecrement32Barrier(&x) -# elif defined(HAVE_IA64_ATOMIC) +# elif defined(TAGLIB_USE_IA64_ATOMIC) # include # define TAGLIB_ATOMIC_INT int # define TAGLIB_ATOMIC_INC(x) __sync_add_and_fetch(&x, 1) @@ -75,15 +75,15 @@ namespace TagLib { -#if defined(HAVE_STD_SHARED_PTR) || defined(HAVE_TR1_SHARED_PTR) +#if defined(TAGLIB_USE_STD_SHARED_PTR) || defined(TAGLIB_USE_TR1_SHARED_PTR) #define TAGLIB_SHARED_PTR std::tr1::shared_ptr -#elif defined(HAVE_BOOST_SHARED_PTR) +#elif defined(TAGLIB_USE_BOOST_SHARED_PTR) #define TAGLIB_SHARED_PTR boost::shared_ptr -#else // HAVE_*_SHARED_PTR +#else // TAGLIB_USE_*_SHARED_PTR // Self-implements RefCountPtr if shared_ptr is not available. // I STRONGLY RECOMMEND using standard shared_ptr rather than this class. @@ -295,7 +295,7 @@ namespace TagLib { a.swap(b); } -#endif // HAVE_*_SHARED_PTR +#endif // TAGLIB_USE_*_SHARED_PTR } #endif // DO_NOT_DOCUMENT diff --git a/taglib/toolkit/tstring.cpp b/taglib/toolkit/tstring.cpp index 63a7970a..242f11a9 100644 --- a/taglib/toolkit/tstring.cpp +++ b/taglib/toolkit/tstring.cpp @@ -25,16 +25,23 @@ // This class assumes that std::basic_string has a contiguous and null-terminated buffer. +#include + +#include "config.h" + #include "tstring.h" #include "tdebug.h" #include "tstringlist.h" -#include -// x86 CPUs are alignment-tolerant or allow pointer casts from smaller types to larger types. -#if defined(__i386__) || defined(_M_IX86) || defined(__amd64) || defined(__amd64__) \ - || defined(_M_AMD64) || defined(__x86_64) || defined(__x86_64__) || defined(_M_X64) -# define TAGLIB_ALIGNMENT_TOLERANT 1 +#if defined(HAVE_MSC_BYTESWAP) +# include +#elif defined(HAVE_GLIBC_BYTESWAP) +# include +#elif defined(HAVE_MAC_BYTESWAP) +# include +#elif defined(HAVE_OPENBSD_BYTESWAP) +# include #endif #ifdef HAVE_STD_CODECVT @@ -47,13 +54,29 @@ namespace { inline TagLib::ushort byteSwap(TagLib::ushort x) { -#ifdef TAGLIB_BYTESWAP_16 +#if defined(HAVE_GCC_BYTESWAP_16) - return TAGLIB_BYTESWAP_16(x); + return __builtin_bswap16(x); + +#elif defined(HAVE_MSC_BYTESWAP) + + return _byteswap_ushort(x); + +#elif defined(HAVE_GLIBC_BYTESWAP) + + return __bswap_16(x); + +#elif defined(HAVE_MAC_BYTESWAP) + + return OSSwapInt16(x); + +#elif defined(HAVE_OPENBSD_BYTESWAP) + + return swap16(x); #else - return((x >> 8) & 0xff) | ((x & 0xff) << 8); + return ((x >> 8) & 0xff) | ((x & 0xff) << 8); #endif } @@ -165,14 +188,14 @@ public: { } - StringPrivate(const wstring &s) + StringPrivate(const std::wstring &s) : data(s) { } -#ifdef SUPPORT_MOVE_SEMANTICS +#ifdef TAGLIB_USE_MOVE_SEMANTICS - StringPrivate(wstring &&s) + StringPrivate(std::wstring &&s) : data(s) { } @@ -187,7 +210,7 @@ public: /*! * Stores string in UTF-16. The byte order depends on the CPU endian. */ - TagLib::wstring data; + std::wstring data; /*! * This is only used to hold the the most recent value of toCString(). @@ -198,7 +221,7 @@ public: const String String::null; // Actual value is -1. -const size_t String::npos = wstring::npos; +const size_t String::npos = std::wstring::npos; //////////////////////////////////////////////////////////////////////////////// @@ -212,7 +235,7 @@ String::String(const String &s) { } -#ifdef SUPPORT_MOVE_SEMANTICS +#ifdef TAGLIB_USE_MOVE_SEMANTICS String::String(String &&s) : d(std::move(s.d)) @@ -233,13 +256,13 @@ String::String(const std::string &s, Type t) } } -String::String(const wstring &s, Type t) +String::String(const std::wstring &s, Type t) : d(new StringPrivate()) { if(t == UTF16 || t == UTF16BE || t == UTF16LE) copyFromUTF16(s.c_str(), s.length(), t); else { - debug("String::String() -- A TagLib::wstring should not contain Latin1 or UTF-8."); + debug("String::String() -- A TagLib::std::wstring should not contain Latin1 or UTF-8."); } } @@ -311,7 +334,7 @@ std::string String::to8Bit(bool unicode) const s.resize(d->data.size()); std::string::iterator targetIt = s.begin(); - for(wstring::const_iterator it = d->data.begin(); it != d->data.end(); it++) { + for(std::wstring::const_iterator it = d->data.begin(); it != d->data.end(); it++) { *targetIt = static_cast(*it); ++targetIt; } @@ -326,7 +349,7 @@ std::string String::to8Bit(bool unicode) const return s; } -const TagLib::wstring &String::toWString() const +const std::wstring &String::toWString() const { return d->data; } @@ -415,7 +438,7 @@ String String::upper() const s.d->data.resize(d->data.size()); wchar_t *p = &s.d->data[0]; - for(wstring::const_iterator it = d->data.begin(); it != d->data.end(); ++it) { + for(std::wstring::const_iterator it = d->data.begin(); it != d->data.end(); ++it) { if(*it >= 'a' && *it <= 'z') *p++ = *it + shift; else @@ -454,7 +477,7 @@ ByteVector String::data(Type t) const ByteVector v(size(), 0); char *p = v.data(); - for(wstring::const_iterator it = d->data.begin(); it != d->data.end(); it++) + for(std::wstring::const_iterator it = d->data.begin(); it != d->data.end(); it++) *p++ = static_cast(*it); return v; @@ -479,7 +502,7 @@ ByteVector String::data(Type t) const *p++ = '\xff'; *p++ = '\xfe'; - for(wstring::const_iterator it = d->data.begin(); it != d->data.end(); it++) { + for(std::wstring::const_iterator it = d->data.begin(); it != d->data.end(); it++) { *p++ = static_cast(*it & 0xff); *p++ = static_cast(*it >> 8); } @@ -491,7 +514,7 @@ ByteVector String::data(Type t) const ByteVector v(size() * 2, 0); char *p = v.data(); - for(wstring::const_iterator it = d->data.begin(); it != d->data.end(); it++) { + for(std::wstring::const_iterator it = d->data.begin(); it != d->data.end(); it++) { *p++ = static_cast(*it >> 8); *p++ = static_cast(*it & 0xff); } @@ -503,7 +526,7 @@ ByteVector String::data(Type t) const ByteVector v(size() * 2, 0); char *p = v.data(); - for(wstring::const_iterator it = d->data.begin(); it != d->data.end(); it++) { + for(std::wstring::const_iterator it = d->data.begin(); it != d->data.end(); it++) { *p++ = static_cast(*it & 0xff); *p++ = static_cast(*it >> 8); } @@ -541,8 +564,8 @@ int String::toInt(bool *ok) const String String::stripWhiteSpace() const { - wstring::const_iterator begin = d->data.begin(); - wstring::const_iterator end = d->data.end(); + std::wstring::const_iterator begin = d->data.begin(); + std::wstring::const_iterator end = d->data.end(); while(begin != end && (*begin == '\t' || *begin == '\n' || *begin == '\f' || @@ -562,12 +585,12 @@ String String::stripWhiteSpace() const } while(*end == '\t' || *end == '\n' || *end == '\f' || *end == '\r' || *end == ' '); - return String(wstring(begin, end + 1)); + return String(std::wstring(begin, end + 1)); } bool String::isLatin1() const { - for(wstring::const_iterator it = d->data.begin(); it != d->data.end(); it++) { + for(std::wstring::const_iterator it = d->data.begin(); it != d->data.end(); it++) { if(*it >= 256) return false; } @@ -576,7 +599,7 @@ bool String::isLatin1() const bool String::isAscii() const { - for(wstring::const_iterator it = d->data.begin(); it != d->data.end(); it++) { + for(std::wstring::const_iterator it = d->data.begin(); it != d->data.end(); it++) { if(*it >= 128) return false; } @@ -630,7 +653,7 @@ bool String::operator==(const String &s) const bool String::operator==(const char *s) const { - for(wstring::const_iterator it = d->data.begin(); it != d->data.end(); it++) { + for(std::wstring::const_iterator it = d->data.begin(); it != d->data.end(); it++) { if(*it != static_cast(*s)) return false; @@ -697,7 +720,7 @@ String &String::operator=(const String &s) return *this; } -#ifdef SUPPORT_MOVE_SEMANTICS +#ifdef TAGLIB_USE_MOVE_SEMANTICS String &String::operator=(String &&s) { @@ -715,15 +738,15 @@ String &String::operator=(const std::string &s) return *this; } -String &String::operator=(const wstring &s) +String &String::operator=(const std::wstring &s) { d.reset(new StringPrivate(s)); return *this; } -#ifdef SUPPORT_MOVE_SEMANTICS +#ifdef TAGLIB_USE_MOVE_SEMANTICS -String &String::operator=(wstring &&s) +String &String::operator=(std::wstring &&s) { d.reset(new StringPrivate(s)); return *this; @@ -835,12 +858,6 @@ void String::copyFromUTF16(const wchar_t *s, size_t length, Type t) void String::copyFromUTF16(const char *s, size_t length, Type t) { -#if SIZEOF_WCHAR_T == 2 && defined(TAGLIB_ALIGNMENT_TOLERANT) - - copyFromUTF16(reinterpret_cast(s), length / 2, t); - -#else - bool swap; if(t == UTF16) { if(length < 2) { @@ -872,11 +889,9 @@ void String::copyFromUTF16(const char *s, size_t length, Type t) d->data[i] = swap ? combine(*s, *(s + 1)) : combine(*(s + 1), *s); s += 2; } - -#endif } -#ifdef TAGLIB_LITTLE_ENDIAN +#if SYSTEM_BYTEORDER == 1 const String::Type String::WCharByteOrder = String::UTF16LE; diff --git a/taglib/toolkit/tstring.h b/taglib/toolkit/tstring.h index 01398fc9..d599107d 100644 --- a/taglib/toolkit/tstring.h +++ b/taglib/toolkit/tstring.h @@ -58,9 +58,9 @@ namespace TagLib { /*! * This is an implicitly shared \e wide string. For storage it uses - * TagLib::wstring, but as this is an implementation detail this of - * course could change. Strings are stored internally as UTF-16BE. (Without - * the BOM (Byte Order Mark) + * TagLib::std::wstring, but as this is an implementation detail this of + * course could change. Strings are stored internally as UTF-16(without BOM/ + * CPU byte order) * * The use of implicit sharing means that copying a string is cheap, the only * \e cost comes into play when the copy is modified. Prior to that the string @@ -119,12 +119,12 @@ namespace TagLib { */ String(const String &s); -#ifdef SUPPORT_MOVE_SEMANTICS +#ifdef TAGLIB_USE_MOVE_SEMANTICS /*! * Constructs a String equivalent to \a s. * - * \note Not available unless SUPPORT_MOVE_SEMANTICS macro is defined. + * \note Not available unless TAGLIB_USE_MOVE_SEMANTICS macro is defined. */ String(String &&s); @@ -141,7 +141,7 @@ namespace TagLib { /*! * Makes a deep copy of the data in \a s. */ - String(const wstring &s, Type t = WCharByteOrder); + String(const std::wstring &s, Type t = WCharByteOrder); /*! * Makes a deep copy of the data in \a s. @@ -185,15 +185,15 @@ namespace TagLib { /*! * If \a unicode if false (the default) this will return a \e Latin1 encoded - * std::string. If it is true the returned std::wstring will be UTF-8 + * std::string. If it is true the returned std::std::wstring will be UTF-8 * encoded. */ std::string to8Bit(bool unicode = false) const; /*! - * Returns a wstring version of the TagLib string as a wide string. + * Returns a std::wstring version of the TagLib string as a wide string. */ - const TagLib::wstring &toWString() const; + const std::wstring &toWString() const; /*! * Creates and returns a C-String based on the data. This string is still @@ -403,12 +403,12 @@ namespace TagLib { */ String &operator=(const String &s); -#ifdef SUPPORT_MOVE_SEMANTICS +#ifdef TAGLIB_USE_MOVE_SEMANTICS /*! * Moves \a s into this String. * - * \note Not available unless SUPPORT_MOVE_SEMANTICS macro is defined. + * \note Not available unless TAGLIB_USE_MOVE_SEMANTICS macro is defined. */ String &operator=(String &&s); @@ -422,16 +422,16 @@ namespace TagLib { /*! * Performs a deep copy of the data in \a s. */ - String &operator=(const wstring &s); + String &operator=(const std::wstring &s); -#ifdef SUPPORT_MOVE_SEMANTICS +#ifdef TAGLIB_USE_MOVE_SEMANTICS /*! * Moves \a s into this String. * - * \note Not available unless SUPPORT_MOVE_SEMANTICS macro is defined. + * \note Not available unless TAGLIB_USE_MOVE_SEMANTICS macro is defined. */ - String &operator=(wstring &&s); + String &operator=(std::wstring &&s); #endif diff --git a/taglib/toolkit/tstringlist.cpp b/taglib/toolkit/tstringlist.cpp index 49650f49..59221b11 100644 --- a/taglib/toolkit/tstringlist.cpp +++ b/taglib/toolkit/tstringlist.cpp @@ -61,7 +61,7 @@ StringList::StringList(const StringList &l) : List(l) { } -#ifdef SUPPORT_MOVE_SEMANTICS +#ifdef TAGLIB_USE_MOVE_SEMANTICS StringList::StringList(StringList &&l) : List(l) { @@ -111,7 +111,7 @@ StringList &StringList::append(const StringList &l) return *this; } -#ifdef SUPPORT_MOVE_SEMANTICS +#ifdef TAGLIB_USE_MOVE_SEMANTICS StringList &StringList::append(String &&s) { @@ -133,7 +133,7 @@ StringList &StringList::operator=(const StringList &l) return *this; } -#ifdef SUPPORT_MOVE_SEMANTICS +#ifdef TAGLIB_USE_MOVE_SEMANTICS StringList &StringList::operator=(StringList &&l) { diff --git a/taglib/toolkit/tstringlist.h b/taglib/toolkit/tstringlist.h index 75466063..e2119a92 100644 --- a/taglib/toolkit/tstringlist.h +++ b/taglib/toolkit/tstringlist.h @@ -58,12 +58,12 @@ namespace TagLib { */ StringList(const StringList &l); -#ifdef SUPPORT_MOVE_SEMANTICS +#ifdef TAGLIB_USE_MOVE_SEMANTICS /*! * Constructs a StringList equivalent to \a l. * - * \note Not available unless SUPPORT_MOVE_SEMANTICS macro is defined. + * \note Not available unless TAGLIB_USE_MOVE_SEMANTICS macro is defined. */ StringList(StringList &&l); @@ -99,13 +99,13 @@ namespace TagLib { */ StringList &append(const StringList &l); -#ifdef SUPPORT_MOVE_SEMANTICS +#ifdef TAGLIB_USE_MOVE_SEMANTICS /*! * Appends \a s to the end of the list and returns a reference to the * list. * - * \note Not available unless SUPPORT_MOVE_SEMANTICS macro is defined. + * \note Not available unless TAGLIB_USE_MOVE_SEMANTICS macro is defined. */ StringList &append(String &&s); @@ -113,7 +113,7 @@ namespace TagLib { * Appends all of the values in \a l to the end of the list and returns a * reference to the list. * - * \note Not available unless SUPPORT_MOVE_SEMANTICS macro is defined. + * \note Not available unless TAGLIB_USE_MOVE_SEMANTICS macro is defined. */ StringList &append(StringList &&l); @@ -126,12 +126,12 @@ namespace TagLib { */ StringList &operator=(const StringList &l); -#ifdef SUPPORT_MOVE_SEMANTICS +#ifdef TAGLIB_USE_MOVE_SEMANTICS /*! * Moves \a l into this StringList. * - * \note Not available unless SUPPORT_MOVE_SEMANTICS macro is defined. + * \note Not available unless TAGLIB_USE_MOVE_SEMANTICS macro is defined. */ StringList &operator=(StringList &&l); diff --git a/tests/test_fileref.cpp b/tests/test_fileref.cpp index 5500ae7f..06663c97 100644 --- a/tests/test_fileref.cpp +++ b/tests/test_fileref.cpp @@ -6,9 +6,6 @@ #include #include #include "utils.h" -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif using namespace std; using namespace TagLib; diff --git a/tests/utils.h b/tests/utils.h index b69bfa50..a2d997eb 100644 --- a/tests/utils.h +++ b/tests/utils.h @@ -1,6 +1,5 @@ -#ifdef HAVE_CONFIG_H -#include -#endif +#include "config.h" + #ifdef _WIN32 #include #else