diff --git a/ext/taglib_aiff/taglib_aiff.i b/ext/taglib_aiff/taglib_aiff.i index 410fb75..276406a 100644 --- a/ext/taglib_aiff/taglib_aiff.i +++ b/ext/taglib_aiff/taglib_aiff.i @@ -4,6 +4,8 @@ #include #include #include +#include +using namespace TagLib; %} %include "../taglib_base/includes.i" diff --git a/ext/taglib_base/includes.i b/ext/taglib_base/includes.i index 097545a..3743974 100644 --- a/ext/taglib_base/includes.i +++ b/ext/taglib_base/includes.i @@ -5,6 +5,7 @@ #define TAGLIB_IGNORE_MISSING_DESTRUCTOR #define TAGLIB_DEPRECATED #define TAGLIB_MSVC_SUPPRESS_WARNING_NEEDS_TO_HAVE_DLL_INTERFACE +%include // Replaces the typemap from swigtype.swg and just adds the line // SWIG_RubyUnlinkObjects. This is done to be safe in the case when a @@ -24,6 +25,7 @@ #include #include #include +#include #if defined(HAVE_RUBY_ENCODING_H) && HAVE_RUBY_ENCODING_H # include @@ -37,34 +39,26 @@ #endif VALUE taglib_bytevector_to_ruby_string(const TagLib::ByteVector &byteVector) { - if (byteVector.isNull()) { - return Qnil; - } else { - return rb_str_new(byteVector.data(), byteVector.size()); - } + return rb_str_new(byteVector.data(), byteVector.size()); } TagLib::ByteVector ruby_string_to_taglib_bytevector(VALUE s) { if (NIL_P(s)) { - return TagLib::ByteVector::null; + return TagLib::ByteVector(); } else { return TagLib::ByteVector(RSTRING_PTR(StringValue(s)), RSTRING_LEN(s)); } } VALUE taglib_string_to_ruby_string(const TagLib::String & string) { - if (string.isNull()) { - return Qnil; - } else { - VALUE result = rb_str_new2(string.toCString(true)); - ASSOCIATE_UTF8_ENCODING(result); - return result; - } + VALUE result = rb_str_new2(string.toCString(true)); + ASSOCIATE_UTF8_ENCODING(result); + return result; } TagLib::String ruby_string_to_taglib_string(VALUE s) { if (NIL_P(s)) { - return TagLib::String::null; + return TagLib::String(); } else { return TagLib::String(RSTRING_PTR(CONVERT_TO_UTF8(StringValue(s))), TagLib::String::UTF8); } diff --git a/ext/taglib_base/taglib_base.i b/ext/taglib_base/taglib_base.i index 7ad38dd..08878fc 100644 --- a/ext/taglib_base/taglib_base.i +++ b/ext/taglib_base/taglib_base.i @@ -6,6 +6,10 @@ #include #include #include +#include +#include +#include +using namespace TagLib; %} %include "includes.i" diff --git a/ext/taglib_flac/taglib_flac.i b/ext/taglib_flac/taglib_flac.i index 2dded03..8e3c6f0 100644 --- a/ext/taglib_flac/taglib_flac.i +++ b/ext/taglib_flac/taglib_flac.i @@ -5,6 +5,7 @@ #include #include #include +using namespace TagLib; %} %include "../taglib_base/includes.i" diff --git a/ext/taglib_id3v1/taglib_id3v1.i b/ext/taglib_id3v1/taglib_id3v1.i index c1cf49f..f751f22 100644 --- a/ext/taglib_id3v1/taglib_id3v1.i +++ b/ext/taglib_id3v1/taglib_id3v1.i @@ -2,6 +2,8 @@ %{ #include #include +#include +using namespace TagLib; %} %include "../taglib_base/includes.i" diff --git a/ext/taglib_id3v2/taglib_id3v2.i b/ext/taglib_id3v2/taglib_id3v2.i index 07f3e3c..2ed4e6c 100644 --- a/ext/taglib_id3v2/taglib_id3v2.i +++ b/ext/taglib_id3v2/taglib_id3v2.i @@ -20,6 +20,7 @@ #include #include #include +using namespace TagLib; %} %include "../taglib_base/includes.i" @@ -81,6 +82,7 @@ VALUE taglib_id3v2_framelist_to_ruby_array(TagLib::ID3v2::FrameList *list) { } %} +%include %include // Only useful internally. diff --git a/ext/taglib_mp4/taglib_mp4.i b/ext/taglib_mp4/taglib_mp4.i index be1c9fe..0092177 100644 --- a/ext/taglib_mp4/taglib_mp4.i +++ b/ext/taglib_mp4/taglib_mp4.i @@ -5,8 +5,10 @@ #include #include #include +#include // To resolve some symbols, like AtomDataType in Item. using namespace TagLib::MP4; +using namespace TagLib; %} %include "../taglib_base/includes.i" diff --git a/ext/taglib_mpeg/taglib_mpeg.i b/ext/taglib_mpeg/taglib_mpeg.i index 51a75ac..8509f06 100644 --- a/ext/taglib_mpeg/taglib_mpeg.i +++ b/ext/taglib_mpeg/taglib_mpeg.i @@ -6,6 +6,8 @@ #include #include #include +#include +using namespace TagLib; %} %include "../taglib_base/includes.i" diff --git a/ext/taglib_wav/taglib_wav.i b/ext/taglib_wav/taglib_wav.i index 76b8434..2ca3afe 100644 --- a/ext/taglib_wav/taglib_wav.i +++ b/ext/taglib_wav/taglib_wav.i @@ -4,7 +4,10 @@ #include #include #include +#include using namespace TagLib::RIFF; +using namespace TagLib; +using StripTags = TagLib::File::StripTags; %} %include "../taglib_base/includes.i" @@ -55,7 +58,11 @@ namespace TagLib { static void free_taglib_riff_wav_file(void *ptr) { TagLib::RIFF::WAV::File *file = (TagLib::RIFF::WAV::File *) ptr; +#if TAGLIB_MAJOR_VERSION >= 2 + TagLib::ID3v2::Tag *id3v2tag = file->ID3v2Tag(); +#else TagLib::ID3v2::Tag *id3v2tag = file->tag(); +#endif if (id3v2tag) { TagLib::ID3v2::FrameList frames = id3v2tag->frameList(); for (TagLib::ID3v2::FrameList::ConstIterator it = frames.begin(); it != frames.end(); it++) { diff --git a/tasks/ext.rake b/tasks/ext.rake index 2bab667..2de4874 100644 --- a/tasks/ext.rake +++ b/tasks/ext.rake @@ -13,6 +13,7 @@ taglib_url = "https://github.com/taglib/taglib/archive/v#{Build.version}.tar.gz" taglib_options = ['-DCMAKE_BUILD_TYPE=Release', '-DBUILD_EXAMPLES=OFF', '-DBUILD_TESTS=OFF', + '-DBUILD_TESTING=OFF', # used since 1.13 instead of BUILD_TESTS '-DBUILD_BINDINGS=OFF', # 1.11 builds bindings by default '-DBUILD_SHARED_LIBS=ON', # 1.11 builds static by default '-DWITH_MP4=ON', # WITH_MP4, WITH_ASF only needed with taglib 1.7, will be default in 1.8 diff --git a/test/id3v2_write_test.rb b/test/id3v2_write_test.rb index bc14e89..e093640 100644 --- a/test/id3v2_write_test.rb +++ b/test/id3v2_write_test.rb @@ -54,7 +54,7 @@ def reloaded(&block) end should 'be able to save ID3v2.3' do - success = @file.save(TagLib::MPEG::File::ID3v2, true, 3) + success = @file.save(TagLib::MPEG::File::ID3v2, TagLib::File::StripOthers, TagLib::ID3v2::V3) assert_equal true, success @file.close @file = nil diff --git a/test/wav_examples_test.rb b/test/wav_examples_test.rb index 4c982bd..3b0a3fc 100644 --- a/test/wav_examples_test.rb +++ b/test/wav_examples_test.rb @@ -19,7 +19,7 @@ class WAVExamples < Test::Unit::TestCase # Saving ID3v2 cover-art to disk TagLib::RIFF::WAV::File.open("#{DATA_FILE_PREFIX}sample.wav") do |file| - id3v2_tag = file.tag + id3v2_tag = file.id3v2_tag cover = id3v2_tag.frame_list('APIC').first ext = cover.mime_type.rpartition('/')[2] File.open("#{DATA_FILE_PREFIX}cover-art.#{ext}", 'wb') { |f| f.write cover.picture } diff --git a/test/wav_file_test.rb b/test/wav_file_test.rb index 9368ac4..4082dcc 100644 --- a/test/wav_file_test.rb +++ b/test/wav_file_test.rb @@ -40,7 +40,7 @@ class WAVFileTest < Test::Unit::TestCase context 'ID3V2 tag' do setup do - @tag = @file.tag + @tag = @file.id3v2_tag end should 'exist' do diff --git a/test/wav_file_write_test.rb b/test/wav_file_write_test.rb index ac61d0e..c0d2865 100644 --- a/test/wav_file_write_test.rb +++ b/test/wav_file_write_test.rb @@ -33,18 +33,18 @@ def reloaded(&block) end should 'have one picture frame' do - assert_equal 2, @file.tag.frame_list('APIC').size + assert_equal 2, @file.id3v2_tag.frame_list('APIC').size end should 'be able to remove all picture frames' do - @file.tag.remove_frames('APIC') + @file.id3v2_tag.remove_frames('APIC') success = @file.save assert success @file.close @file = nil reloaded do |file| - assert_equal 0, file.tag.frame_list('APIC').size + assert_equal 0, file.id3v2_tag.frame_list('APIC').size end end @@ -58,18 +58,18 @@ def reloaded(&block) apic.picture = picture_data apic.type = TagLib::ID3v2::AttachedPictureFrame::BackCover - @file.tag.add_frame(apic) + @file.id3v2_tag.add_frame(apic) success = @file.save assert success @file.close @file = nil reloaded do |file| - assert_equal 3, file.tag.frame_list('APIC').size + assert_equal 3, file.id3v2_tag.frame_list('APIC').size end reloaded do |file| - written_apic = file.tag.frame_list('APIC')[2] + written_apic = file.id3v2_tag.frame_list('APIC')[2] assert_equal 'image/jpeg', written_apic.mime_type assert_equal 'desc', written_apic.description assert_equal picture_data, written_apic.picture