taglib-ruby 1.0.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +33 -0
  3. data/.yardopts +1 -1
  4. data/{CHANGES.md → CHANGELOG.md} +35 -14
  5. data/Gemfile +2 -0
  6. data/Guardfile +4 -2
  7. data/README.md +56 -38
  8. data/Rakefile +8 -8
  9. data/docs/taglib/aiff.rb +0 -3
  10. data/docs/taglib/base.rb +0 -4
  11. data/docs/taglib/flac.rb +1 -3
  12. data/docs/taglib/id3v2.rb +1 -1
  13. data/docs/taglib/mp4.rb +2 -4
  14. data/docs/taglib/mpeg.rb +0 -1
  15. data/docs/taglib/ogg.rb +0 -4
  16. data/docs/taglib/vorbis.rb +0 -1
  17. data/docs/taglib/wav.rb +0 -4
  18. data/ext/extconf_common.rb +24 -28
  19. data/ext/taglib_aiff/extconf.rb +2 -0
  20. data/ext/taglib_aiff/taglib_aiff_wrap.cxx +217 -178
  21. data/ext/taglib_base/extconf.rb +2 -0
  22. data/ext/taglib_base/includes.i +25 -0
  23. data/ext/taglib_base/taglib_base.i +18 -0
  24. data/ext/taglib_base/taglib_base_wrap.cxx +233 -191
  25. data/ext/taglib_flac/extconf.rb +2 -0
  26. data/ext/taglib_flac/taglib_flac.i +7 -0
  27. data/ext/taglib_flac/taglib_flac_wrap.cxx +235 -189
  28. data/ext/taglib_flac_picture/extconf.rb +2 -0
  29. data/ext/taglib_flac_picture/taglib_flac_picture_wrap.cxx +210 -168
  30. data/ext/taglib_id3v1/extconf.rb +2 -0
  31. data/ext/taglib_id3v1/taglib_id3v1_wrap.cxx +223 -182
  32. data/ext/taglib_id3v2/extconf.rb +2 -0
  33. data/ext/taglib_id3v2/taglib_id3v2.i +17 -0
  34. data/ext/taglib_id3v2/taglib_id3v2_wrap.cxx +2922 -993
  35. data/ext/taglib_mp4/extconf.rb +2 -0
  36. data/ext/taglib_mp4/taglib_mp4_wrap.cxx +295 -260
  37. data/ext/taglib_mpeg/extconf.rb +2 -0
  38. data/ext/taglib_mpeg/taglib_mpeg_wrap.cxx +243 -206
  39. data/ext/taglib_ogg/extconf.rb +2 -0
  40. data/ext/taglib_ogg/taglib_ogg_wrap.cxx +214 -171
  41. data/ext/taglib_vorbis/extconf.rb +2 -0
  42. data/ext/taglib_vorbis/taglib_vorbis_wrap.cxx +217 -178
  43. data/ext/taglib_wav/extconf.rb +2 -0
  44. data/ext/taglib_wav/taglib_wav_wrap.cxx +217 -178
  45. data/lib/taglib/aiff.rb +2 -0
  46. data/lib/taglib/base.rb +3 -1
  47. data/lib/taglib/flac.rb +2 -0
  48. data/lib/taglib/id3v1.rb +2 -0
  49. data/lib/taglib/id3v2.rb +2 -0
  50. data/lib/taglib/mp4.rb +10 -13
  51. data/lib/taglib/mpeg.rb +2 -0
  52. data/lib/taglib/ogg.rb +2 -0
  53. data/lib/taglib/version.rb +4 -2
  54. data/lib/taglib/vorbis.rb +2 -0
  55. data/lib/taglib/wav.rb +2 -1
  56. data/lib/taglib.rb +4 -3
  57. data/taglib-ruby.gemspec +165 -162
  58. data/tasks/docs_coverage.rake +10 -8
  59. data/tasks/ext.rake +26 -25
  60. data/tasks/gemspec_check.rake +7 -5
  61. data/tasks/swig.rake +10 -11
  62. data/test/aiff_examples_test.rb +8 -13
  63. data/test/aiff_file_test.rb +29 -29
  64. data/test/aiff_file_write_test.rb +19 -20
  65. data/test/base_test.rb +4 -2
  66. data/test/data/add-relative-volume.cpp +7 -3
  67. data/test/data/flac-create.cpp +15 -5
  68. data/test/data/flac_nopic.flac +0 -0
  69. data/test/data/get_picture_data.cpp +5 -1
  70. data/test/data/id3v1-create.cpp +6 -3
  71. data/test/data/mp4-create.cpp +12 -4
  72. data/test/data/vorbis-create.cpp +12 -5
  73. data/test/data/wav-create.cpp +18 -3
  74. data/test/file_test.rb +7 -5
  75. data/test/fileref_open_test.rb +12 -10
  76. data/test/fileref_properties_test.rb +6 -4
  77. data/test/fileref_write_test.rb +14 -13
  78. data/test/flac_file_test.rb +32 -27
  79. data/test/flac_file_write_test.rb +17 -18
  80. data/test/flac_picture_memory_test.rb +39 -0
  81. data/test/helper.rb +3 -1
  82. data/test/id3v1_genres_test.rb +14 -12
  83. data/test/id3v1_tag_test.rb +7 -5
  84. data/test/id3v2_frames_test.rb +98 -34
  85. data/test/id3v2_header_test.rb +14 -13
  86. data/test/id3v2_memory_test.rb +21 -20
  87. data/test/id3v2_relative_volume_test.rb +11 -9
  88. data/test/id3v2_tag_test.rb +16 -14
  89. data/test/id3v2_unicode_test.rb +12 -10
  90. data/test/id3v2_unknown_frames_test.rb +7 -5
  91. data/test/id3v2_write_test.rb +28 -29
  92. data/test/mp4_file_test.rb +27 -26
  93. data/test/mp4_file_write_test.rb +12 -13
  94. data/test/mp4_items_test.rb +78 -79
  95. data/test/mpeg_file_test.rb +32 -30
  96. data/test/tag_test.rb +5 -3
  97. data/test/unicode_filename_test.rb +7 -7
  98. data/test/vorbis_file_test.rb +14 -12
  99. data/test/vorbis_tag_test.rb +46 -44
  100. data/test/wav_examples_test.rb +8 -16
  101. data/test/wav_file_test.rb +29 -29
  102. data/test/wav_file_write_test.rb +22 -23
  103. metadata +26 -23
@@ -1,6 +1,6 @@
1
1
  /* ----------------------------------------------------------------------------
2
2
  * This file was automatically generated by SWIG (http://www.swig.org).
3
- * Version 3.0.7
3
+ * Version 4.0.2
4
4
  *
5
5
  * This file is not intended to be easily readable and contains a number of
6
6
  * coding conventions designed to improve portability and efficiency. Do not make
@@ -11,7 +11,11 @@
11
11
  static void free_taglib_flac_file(void *ptr);
12
12
 
13
13
 
14
+
15
+ #ifndef SWIGRUBY
14
16
  #define SWIGRUBY
17
+ #endif
18
+
15
19
 
16
20
 
17
21
  #ifdef __cplusplus
@@ -104,9 +108,11 @@ template <typename T> T SwigValueInit() {
104
108
  #endif
105
109
 
106
110
  /* exporting methods */
107
- #if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
108
- # ifndef GCC_HASCLASSVISIBILITY
109
- # define GCC_HASCLASSVISIBILITY
111
+ #if defined(__GNUC__)
112
+ # if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
113
+ # ifndef GCC_HASCLASSVISIBILITY
114
+ # define GCC_HASCLASSVISIBILITY
115
+ # endif
110
116
  # endif
111
117
  #endif
112
118
 
@@ -226,9 +232,11 @@ template <typename T> T SwigValueInit() {
226
232
  #endif
227
233
 
228
234
  /* exporting methods */
229
- #if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
230
- # ifndef GCC_HASCLASSVISIBILITY
231
- # define GCC_HASCLASSVISIBILITY
235
+ #if defined(__GNUC__)
236
+ # if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
237
+ # ifndef GCC_HASCLASSVISIBILITY
238
+ # define GCC_HASCLASSVISIBILITY
239
+ # endif
232
240
  # endif
233
241
  #endif
234
242
 
@@ -326,6 +334,7 @@ template <typename T> T SwigValueInit() {
326
334
  /* Flags for pointer conversions */
327
335
  #define SWIG_POINTER_DISOWN 0x1
328
336
  #define SWIG_CAST_NEW_MEMORY 0x2
337
+ #define SWIG_POINTER_NO_NULL 0x4
329
338
 
330
339
  /* Flags for new pointer objects */
331
340
  #define SWIG_POINTER_OWN 0x1
@@ -778,16 +787,16 @@ SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
778
787
  char d = *(c++);
779
788
  unsigned char uu;
780
789
  if ((d >= '0') && (d <= '9'))
781
- uu = ((d - '0') << 4);
790
+ uu = (unsigned char)((d - '0') << 4);
782
791
  else if ((d >= 'a') && (d <= 'f'))
783
- uu = ((d - ('a'-10)) << 4);
792
+ uu = (unsigned char)((d - ('a'-10)) << 4);
784
793
  else
785
794
  return (char *) 0;
786
795
  d = *(c++);
787
796
  if ((d >= '0') && (d <= '9'))
788
- uu |= (d - '0');
797
+ uu |= (unsigned char)(d - '0');
789
798
  else if ((d >= 'a') && (d <= 'f'))
790
- uu |= (d - ('a'-10));
799
+ uu |= (unsigned char)(d - ('a'-10));
791
800
  else
792
801
  return (char *) 0;
793
802
  *u = uu;
@@ -964,42 +973,53 @@ SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) {
964
973
  #ifndef RSTRUCT_PTR
965
974
  # define RSTRUCT_PTR(x) RSTRUCT(x)->ptr
966
975
  #endif
976
+ #ifndef RTYPEDDATA_P
977
+ # define RTYPEDDATA_P(x) (TYPE(x) != T_DATA)
978
+ #endif
967
979
 
968
980
 
969
981
 
970
982
  /*
971
- * Need to be very careful about how these macros are defined, especially
972
- * when compiling C++ code or C code with an ANSI C compiler.
983
+ * The following macros are used for providing the correct type of a
984
+ * function pointer to the Ruby C API.
985
+ * Starting with Ruby 2.7 (corresponding to RB_METHOD_DEFINITION_DECL being
986
+ * defined) these macros act transparently due to Ruby's moving away from
987
+ * ANYARGS and instead employing strict function signatures.
988
+ *
989
+ * Note: In case of C (not C++) the macros are transparent even before
990
+ * Ruby 2.7 due to the fact that the Ruby C API used function declarators
991
+ * with empty parentheses, which allows for an unspecified number of
992
+ * arguments.
973
993
  *
974
- * VALUEFUNC(f) is a macro used to typecast a C function that implements
975
- * a Ruby method so that it can be passed as an argument to API functions
976
- * like rb_define_method() and rb_define_singleton_method().
994
+ * PROTECTFUNC(f) is used for the function pointer argument of the Ruby
995
+ * C API function rb_protect().
977
996
  *
978
- * VOIDFUNC(f) is a macro used to typecast a C function that implements
979
- * either the "mark" or "free" stuff for a Ruby Data object, so that it
980
- * can be passed as an argument to API functions like Data_Wrap_Struct()
997
+ * VALUEFUNC(f) is used for the function pointer argument(s) of Ruby C API
998
+ * functions like rb_define_method() and rb_define_singleton_method().
999
+ *
1000
+ * VOIDFUNC(f) is used to typecast a C function that implements either
1001
+ * the "mark" or "free" stuff for a Ruby Data object, so that it can be
1002
+ * passed as an argument to Ruby C API functions like Data_Wrap_Struct()
981
1003
  * and Data_Make_Struct().
1004
+ *
1005
+ * SWIG_RUBY_VOID_ANYARGS_FUNC(f) is used for the function pointer
1006
+ * argument(s) of Ruby C API functions like rb_define_virtual_variable().
1007
+ *
1008
+ * SWIG_RUBY_INT_ANYARGS_FUNC(f) is used for the function pointer
1009
+ * argument(s) of Ruby C API functions like st_foreach().
982
1010
  */
983
-
984
- #ifdef __cplusplus
985
- # ifndef RUBY_METHOD_FUNC /* These definitions should work for Ruby 1.4.6 */
986
- # define PROTECTFUNC(f) ((VALUE (*)()) f)
987
- # define VALUEFUNC(f) ((VALUE (*)()) f)
988
- # define VOIDFUNC(f) ((void (*)()) f)
989
- # else
990
- # ifndef ANYARGS /* These definitions should work for Ruby 1.6 */
991
- # define PROTECTFUNC(f) ((VALUE (*)()) f)
992
- # define VALUEFUNC(f) ((VALUE (*)()) f)
993
- # define VOIDFUNC(f) ((RUBY_DATA_FUNC) f)
994
- # else /* These definitions should work for Ruby 1.7+ */
995
- # define PROTECTFUNC(f) ((VALUE (*)(VALUE)) f)
996
- # define VALUEFUNC(f) ((VALUE (*)(ANYARGS)) f)
997
- # define VOIDFUNC(f) ((RUBY_DATA_FUNC) f)
998
- # endif
999
- # endif
1011
+ #if defined(__cplusplus) && !defined(RB_METHOD_DEFINITION_DECL)
1012
+ # define PROTECTFUNC(f) ((VALUE (*)(VALUE)) f)
1013
+ # define VALUEFUNC(f) ((VALUE (*)(ANYARGS)) f)
1014
+ # define VOIDFUNC(f) ((RUBY_DATA_FUNC) f)
1015
+ # define SWIG_RUBY_VOID_ANYARGS_FUNC(f) ((void (*)(ANYARGS))(f))
1016
+ # define SWIG_RUBY_INT_ANYARGS_FUNC(f) ((int (*)(ANYARGS))(f))
1000
1017
  #else
1018
+ # define PROTECTFUNC(f) (f)
1001
1019
  # define VALUEFUNC(f) (f)
1002
1020
  # define VOIDFUNC(f) (f)
1021
+ # define SWIG_RUBY_VOID_ANYARGS_FUNC(f) (f)
1022
+ # define SWIG_RUBY_INT_ANYARGS_FUNC(f) (f)
1003
1023
  #endif
1004
1024
 
1005
1025
  /* Don't use for expressions have side effect */
@@ -1187,7 +1207,7 @@ void Ruby_Format_OverloadedError(
1187
1207
  /* -----------------------------------------------------------------------------
1188
1208
  * rubytracking.swg
1189
1209
  *
1190
- * This file contains support for tracking mappings from
1210
+ * This file contains support for tracking mappings from
1191
1211
  * Ruby objects to C++ objects. This functionality is needed
1192
1212
  * to implement mark functions for Ruby's mark and sweep
1193
1213
  * garbage collector.
@@ -1197,6 +1217,11 @@ void Ruby_Format_OverloadedError(
1197
1217
  extern "C" {
1198
1218
  #endif
1199
1219
 
1220
+ #if !defined(ST_DATA_T_DEFINED)
1221
+ /* Needs to be explicitly included for Ruby 1.8 and earlier */
1222
+ #include <st.h>
1223
+ #endif
1224
+
1200
1225
  /* Ruby 1.8 actually assumes the first case. */
1201
1226
  #if SIZEOF_VOIDP == SIZEOF_LONG
1202
1227
  # define SWIG2NUM(v) LONG2NUM((unsigned long)v)
@@ -1208,109 +1233,69 @@ extern "C" {
1208
1233
  # error sizeof(void*) is not the same as long or long long
1209
1234
  #endif
1210
1235
 
1211
-
1212
- /* Global Ruby hash table to store Trackings from C/C++
1213
- structs to Ruby Objects.
1236
+ /* Global hash table to store Trackings from C/C++
1237
+ structs to Ruby Objects.
1214
1238
  */
1215
- static VALUE swig_ruby_trackings = Qnil;
1239
+ static st_table* swig_ruby_trackings = NULL;
1216
1240
 
1217
- /* Global variable that stores a reference to the ruby
1218
- hash table delete function. */
1219
- static ID swig_ruby_hash_delete;
1241
+ static VALUE swig_ruby_trackings_count(ID id, VALUE *var) {
1242
+ return SWIG2NUM(swig_ruby_trackings->num_entries);
1243
+ }
1220
1244
 
1221
- /* Setup a Ruby hash table to store Trackings */
1245
+
1246
+ /* Setup a hash table to store Trackings */
1222
1247
  SWIGRUNTIME void SWIG_RubyInitializeTrackings(void) {
1223
- /* Create a ruby hash table to store Trackings from C++
1248
+ /* Create a hash table to store Trackings from C++
1224
1249
  objects to Ruby objects. */
1225
1250
 
1226
- /* Try to see if some other .so has already created a
1251
+ /* Try to see if some other .so has already created a
1227
1252
  tracking hash table, which we keep hidden in an instance var
1228
1253
  in the SWIG module.
1229
1254
  This is done to allow multiple DSOs to share the same
1230
1255
  tracking table.
1231
1256
  */
1232
- ID trackings_id = rb_intern( "@__trackings__" );
1257
+ VALUE trackings_value = Qnil;
1258
+ /* change the variable name so that we can mix modules
1259
+ compiled with older SWIG's - this used to be called "@__trackings__" */
1260
+ ID trackings_id = rb_intern( "@__safetrackings__" );
1233
1261
  VALUE verbose = rb_gv_get("VERBOSE");
1234
1262
  rb_gv_set("VERBOSE", Qfalse);
1235
- swig_ruby_trackings = rb_ivar_get( _mSWIG, trackings_id );
1263
+ trackings_value = rb_ivar_get( _mSWIG, trackings_id );
1236
1264
  rb_gv_set("VERBOSE", verbose);
1237
1265
 
1238
- /* No, it hasn't. Create one ourselves */
1239
- if ( swig_ruby_trackings == Qnil )
1240
- {
1241
- swig_ruby_trackings = rb_hash_new();
1242
- rb_ivar_set( _mSWIG, trackings_id, swig_ruby_trackings );
1243
- }
1244
-
1245
- /* Now store a reference to the hash table delete function
1246
- so that we only have to look it up once.*/
1247
- swig_ruby_hash_delete = rb_intern("delete");
1248
- }
1249
-
1250
- /* Get a Ruby number to reference a pointer */
1251
- SWIGRUNTIME VALUE SWIG_RubyPtrToReference(void* ptr) {
1252
- /* We cast the pointer to an unsigned long
1253
- and then store a reference to it using
1254
- a Ruby number object. */
1255
-
1256
- /* Convert the pointer to a Ruby number */
1257
- return SWIG2NUM(ptr);
1258
- }
1259
-
1260
- /* Get a Ruby number to reference an object */
1261
- SWIGRUNTIME VALUE SWIG_RubyObjectToReference(VALUE object) {
1262
- /* We cast the object to an unsigned long
1263
- and then store a reference to it using
1264
- a Ruby number object. */
1265
-
1266
- /* Convert the Object to a Ruby number */
1267
- return SWIG2NUM(object);
1268
- }
1269
-
1270
- /* Get a Ruby object from a previously stored reference */
1271
- SWIGRUNTIME VALUE SWIG_RubyReferenceToObject(VALUE reference) {
1272
- /* The provided Ruby number object is a reference
1273
- to the Ruby object we want.*/
1266
+ /* The trick here is that we have to store the hash table
1267
+ pointer in a Ruby variable. We do not want Ruby's GC to
1268
+ treat this pointer as a Ruby object, so we convert it to
1269
+ a Ruby numeric value. */
1270
+ if (trackings_value == Qnil) {
1271
+ /* No, it hasn't. Create one ourselves */
1272
+ swig_ruby_trackings = st_init_numtable();
1273
+ rb_ivar_set( _mSWIG, trackings_id, SWIG2NUM(swig_ruby_trackings) );
1274
+ } else {
1275
+ swig_ruby_trackings = (st_table*)NUM2SWIG(trackings_value);
1276
+ }
1274
1277
 
1275
- /* Convert the Ruby number to a Ruby object */
1276
- return NUM2SWIG(reference);
1278
+ rb_define_virtual_variable("SWIG_TRACKINGS_COUNT",
1279
+ VALUEFUNC(swig_ruby_trackings_count),
1280
+ SWIG_RUBY_VOID_ANYARGS_FUNC((rb_gvar_setter_t*)NULL));
1277
1281
  }
1278
1282
 
1279
1283
  /* Add a Tracking from a C/C++ struct to a Ruby object */
1280
1284
  SWIGRUNTIME void SWIG_RubyAddTracking(void* ptr, VALUE object) {
1281
- /* In a Ruby hash table we store the pointer and
1282
- the associated Ruby object. The trick here is
1283
- that we cannot store the Ruby object directly - if
1284
- we do then it cannot be garbage collected. So
1285
- instead we typecast it as a unsigned long and
1286
- convert it to a Ruby number object.*/
1287
-
1288
- /* Get a reference to the pointer as a Ruby number */
1289
- VALUE key = SWIG_RubyPtrToReference(ptr);
1290
-
1291
- /* Get a reference to the Ruby object as a Ruby number */
1292
- VALUE value = SWIG_RubyObjectToReference(object);
1293
-
1294
1285
  /* Store the mapping to the global hash table. */
1295
- rb_hash_aset(swig_ruby_trackings, key, value);
1286
+ st_insert(swig_ruby_trackings, (st_data_t)ptr, object);
1296
1287
  }
1297
1288
 
1298
1289
  /* Get the Ruby object that owns the specified C/C++ struct */
1299
1290
  SWIGRUNTIME VALUE SWIG_RubyInstanceFor(void* ptr) {
1300
- /* Get a reference to the pointer as a Ruby number */
1301
- VALUE key = SWIG_RubyPtrToReference(ptr);
1302
-
1303
1291
  /* Now lookup the value stored in the global hash table */
1304
- VALUE value = rb_hash_aref(swig_ruby_trackings, key);
1305
-
1306
- if (value == Qnil) {
1307
- /* No object exists - return nil. */
1292
+ VALUE value;
1293
+
1294
+ if (st_lookup(swig_ruby_trackings, (st_data_t)ptr, &value)) {
1295
+ return value;
1296
+ } else {
1308
1297
  return Qnil;
1309
1298
  }
1310
- else {
1311
- /* Convert this value to Ruby object */
1312
- return SWIG_RubyReferenceToObject(value);
1313
- }
1314
1299
  }
1315
1300
 
1316
1301
  /* Remove a Tracking from a C/C++ struct to a Ruby object. It
@@ -1318,25 +1303,39 @@ SWIGRUNTIME VALUE SWIG_RubyInstanceFor(void* ptr) {
1318
1303
  since the same memory address may be reused later to create
1319
1304
  a new object. */
1320
1305
  SWIGRUNTIME void SWIG_RubyRemoveTracking(void* ptr) {
1321
- /* Get a reference to the pointer as a Ruby number */
1322
- VALUE key = SWIG_RubyPtrToReference(ptr);
1323
-
1324
- /* Delete the object from the hash table by calling Ruby's
1325
- do this we need to call the Hash.delete method.*/
1326
- rb_funcall(swig_ruby_trackings, swig_ruby_hash_delete, 1, key);
1306
+ /* Delete the object from the hash table */
1307
+ st_delete(swig_ruby_trackings, (st_data_t *)&ptr, NULL);
1327
1308
  }
1328
1309
 
1329
1310
  /* This is a helper method that unlinks a Ruby object from its
1330
1311
  underlying C++ object. This is needed if the lifetime of the
1331
- Ruby object is longer than the C++ object */
1312
+ Ruby object is longer than the C++ object. */
1332
1313
  SWIGRUNTIME void SWIG_RubyUnlinkObjects(void* ptr) {
1333
1314
  VALUE object = SWIG_RubyInstanceFor(ptr);
1334
1315
 
1335
1316
  if (object != Qnil) {
1317
+ // object might have the T_ZOMBIE type, but that's just
1318
+ // because the GC has flagged it as such for a deferred
1319
+ // destruction. Until then, it's still a T_DATA object.
1336
1320
  DATA_PTR(object) = 0;
1337
1321
  }
1338
1322
  }
1339
1323
 
1324
+ /* This is a helper method that iterates over all the trackings
1325
+ passing the C++ object pointer and its related Ruby object
1326
+ to the passed callback function. */
1327
+
1328
+ /* Proxy method to abstract the internal trackings datatype */
1329
+ static int swig_ruby_internal_iterate_callback(st_data_t ptr, st_data_t obj, st_data_t meth) {
1330
+ ((void (*) (void *, VALUE))meth)((void *)ptr, (VALUE)obj);
1331
+ return ST_CONTINUE;
1332
+ }
1333
+
1334
+ SWIGRUNTIME void SWIG_RubyIterateTrackings( void(*meth)(void* ptr, VALUE obj) ) {
1335
+ st_foreach(swig_ruby_trackings,
1336
+ SWIG_RUBY_INT_ANYARGS_FUNC(swig_ruby_internal_iterate_callback),
1337
+ (st_data_t)meth);
1338
+ }
1340
1339
 
1341
1340
  #ifdef __cplusplus
1342
1341
  }
@@ -1395,7 +1394,7 @@ SWIG_Ruby_AppendOutput(VALUE target, VALUE o) {
1395
1394
  #define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Ruby_ConvertPtrAndOwn(obj, pptr, type, flags, own)
1396
1395
  #define SWIG_NewPointerObj(ptr, type, flags) SWIG_Ruby_NewPointerObj(ptr, type, flags)
1397
1396
  #define SWIG_AcquirePtr(ptr, own) SWIG_Ruby_AcquirePtr(ptr, own)
1398
- #define swig_owntype ruby_owntype
1397
+ #define swig_owntype swig_ruby_owntype
1399
1398
 
1400
1399
  /* for raw packed data */
1401
1400
  #define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Ruby_ConvertPacked(obj, ptr, sz, ty, flags)
@@ -1552,10 +1551,11 @@ SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags)
1552
1551
  swig_class *sklass;
1553
1552
  VALUE klass;
1554
1553
  VALUE obj;
1555
-
1554
+
1556
1555
  if (!ptr)
1557
1556
  return Qnil;
1558
-
1557
+
1558
+ assert(type);
1559
1559
  if (type->clientdata) {
1560
1560
  sklass = (swig_class *) type->clientdata;
1561
1561
 
@@ -1563,7 +1563,7 @@ SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags)
1563
1563
  track = sklass->trackObjects;
1564
1564
  if (track) {
1565
1565
  obj = SWIG_RubyInstanceFor(ptr);
1566
-
1566
+
1567
1567
  /* Check the object's type and make sure it has the correct type.
1568
1568
  It might not in cases where methods do things like
1569
1569
  downcast methods. */
@@ -1595,7 +1595,7 @@ SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags)
1595
1595
  obj = Data_Wrap_Struct(klass, 0, 0, ptr);
1596
1596
  }
1597
1597
  rb_iv_set(obj, "@__swigtype__", rb_str_new2(type->name));
1598
-
1598
+
1599
1599
  return obj;
1600
1600
  }
1601
1601
 
@@ -1615,26 +1615,30 @@ SWIGRUNTIMEINLINE char *
1615
1615
  SWIG_Ruby_MangleStr(VALUE obj)
1616
1616
  {
1617
1617
  VALUE stype = rb_iv_get(obj, "@__swigtype__");
1618
+ if (NIL_P(stype))
1619
+ return NULL;
1618
1620
  return StringValuePtr(stype);
1619
1621
  }
1620
1622
 
1621
1623
  /* Acquire a pointer value */
1622
- typedef void (*ruby_owntype)(void*);
1623
-
1624
- SWIGRUNTIME ruby_owntype
1625
- SWIG_Ruby_AcquirePtr(VALUE obj, ruby_owntype own) {
1626
- if (obj) {
1627
- ruby_owntype oldown = RDATA(obj)->dfree;
1628
- RDATA(obj)->dfree = own;
1629
- return oldown;
1630
- } else {
1631
- return 0;
1632
- }
1624
+ typedef struct {
1625
+ void (*datafree)(void *);
1626
+ int own;
1627
+ } swig_ruby_owntype;
1628
+
1629
+ SWIGRUNTIME swig_ruby_owntype
1630
+ SWIG_Ruby_AcquirePtr(VALUE obj, swig_ruby_owntype own) {
1631
+ swig_ruby_owntype oldown = {0, 0};
1632
+ if (TYPE(obj) == T_DATA && !RTYPEDDATA_P(obj)) {
1633
+ oldown.datafree = RDATA(obj)->dfree;
1634
+ RDATA(obj)->dfree = own.datafree;
1635
+ }
1636
+ return oldown;
1633
1637
  }
1634
1638
 
1635
1639
  /* Convert a pointer value */
1636
1640
  SWIGRUNTIME int
1637
- SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, ruby_owntype *own)
1641
+ SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, swig_ruby_owntype *own)
1638
1642
  {
1639
1643
  char *c;
1640
1644
  swig_cast_info *tc;
@@ -1642,16 +1646,20 @@ SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags,
1642
1646
 
1643
1647
  /* Grab the pointer */
1644
1648
  if (NIL_P(obj)) {
1645
- *ptr = 0;
1646
- return SWIG_OK;
1649
+ if (ptr)
1650
+ *ptr = 0;
1651
+ return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK;
1647
1652
  } else {
1648
- if (TYPE(obj) != T_DATA) {
1653
+ if (TYPE(obj) != T_DATA || (TYPE(obj) == T_DATA && RTYPEDDATA_P(obj))) {
1649
1654
  return SWIG_ERROR;
1650
1655
  }
1651
1656
  Data_Get_Struct(obj, void, vptr);
1652
1657
  }
1653
1658
 
1654
- if (own) *own = RDATA(obj)->dfree;
1659
+ if (own) {
1660
+ own->datafree = RDATA(obj)->dfree;
1661
+ own->own = 0;
1662
+ }
1655
1663
 
1656
1664
  /* Check to see if the input object is giving up ownership
1657
1665
  of the underlying C struct or C++ object. If so then we
@@ -1686,8 +1694,6 @@ SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags,
1686
1694
  /* The object has already been deleted */
1687
1695
  return SWIG_ObjectPreviouslyDeletedError;
1688
1696
  }
1689
- *ptr = vptr;
1690
- return SWIG_OK;
1691
1697
  }
1692
1698
  }
1693
1699
  if ((c = SWIG_MangleStr(obj)) == NULL) {
@@ -1697,12 +1703,23 @@ SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags,
1697
1703
  if (!tc) {
1698
1704
  return SWIG_ERROR;
1699
1705
  } else {
1700
- int newmemory = 0;
1701
- *ptr = SWIG_TypeCast(tc, vptr, &newmemory);
1702
- assert(!newmemory); /* newmemory handling not yet implemented */
1706
+ if (ptr) {
1707
+ if (tc->type == ty) {
1708
+ *ptr = vptr;
1709
+ } else {
1710
+ int newmemory = 0;
1711
+ *ptr = SWIG_TypeCast(tc, vptr, &newmemory);
1712
+ if (newmemory == SWIG_CAST_NEW_MEMORY) {
1713
+ assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */
1714
+ if (own)
1715
+ own->own = own->own | SWIG_CAST_NEW_MEMORY;
1716
+ }
1717
+ }
1718
+ }
1703
1719
  }
1704
1720
  } else {
1705
- *ptr = vptr;
1721
+ if (ptr)
1722
+ *ptr = vptr;
1706
1723
  }
1707
1724
 
1708
1725
  return SWIG_OK;
@@ -1728,7 +1745,7 @@ SWIG_Ruby_NewPackedObj(void *ptr, int sz, swig_type_info *type) {
1728
1745
  return rb_str_new2(result);
1729
1746
  }
1730
1747
 
1731
- /* Convert a packed value value */
1748
+ /* Convert a packed pointer value */
1732
1749
  SWIGRUNTIME int
1733
1750
  SWIG_Ruby_ConvertPacked(VALUE obj, void *ptr, int sz, swig_type_info *ty) {
1734
1751
  swig_cast_info *tc;
@@ -1863,7 +1880,7 @@ static VALUE mFLAC;
1863
1880
  #define SWIG_RUBY_THREAD_END_BLOCK
1864
1881
 
1865
1882
 
1866
- #define SWIGVERSION 0x030007
1883
+ #define SWIGVERSION 0x040002
1867
1884
  #define SWIG_VERSION SWIGVERSION
1868
1885
 
1869
1886
 
@@ -1883,6 +1900,8 @@ static VALUE mFLAC;
1883
1900
 
1884
1901
  #include <taglib/tstring.h>
1885
1902
  #include <taglib/tstringlist.h>
1903
+ #include <taglib/tbytevector.h>
1904
+ #include <taglib/tbytevectorlist.h>
1886
1905
  #include <taglib/tfile.h>
1887
1906
 
1888
1907
  #if defined(HAVE_RUBY_ENCODING_H) && HAVE_RUBY_ENCODING_H
@@ -1952,6 +1971,28 @@ TagLib::StringList ruby_array_to_taglib_string_list(VALUE ary) {
1952
1971
  return result;
1953
1972
  }
1954
1973
 
1974
+ VALUE taglib_bytevectorlist_to_ruby_array(const TagLib::ByteVectorList & list) {
1975
+ VALUE ary = rb_ary_new2(list.size());
1976
+ for (TagLib::ByteVectorList::ConstIterator it = list.begin(); it != list.end(); it++) {
1977
+ VALUE s = taglib_bytevector_to_ruby_string(*it);
1978
+ rb_ary_push(ary, s);
1979
+ }
1980
+ return ary;
1981
+ }
1982
+
1983
+ TagLib::ByteVectorList ruby_array_to_taglib_bytevectorlist(VALUE ary) {
1984
+ TagLib::ByteVectorList result = TagLib::ByteVectorList();
1985
+ if (NIL_P(ary)) {
1986
+ return result;
1987
+ }
1988
+ for (long i = 0; i < RARRAY_LEN(ary); i++) {
1989
+ VALUE e = rb_ary_entry(ary, i);
1990
+ TagLib::ByteVector s = ruby_string_to_taglib_bytevector(e);
1991
+ result.append(s);
1992
+ }
1993
+ return result;
1994
+ }
1995
+
1955
1996
  VALUE taglib_filename_to_ruby_string(TagLib::FileName filename) {
1956
1997
  VALUE result;
1957
1998
  #ifdef _WIN32
@@ -2005,15 +2046,16 @@ VALUE taglib_flac_picturelist_to_ruby_array(const TagLib::List<TagLib::FLAC::Pic
2005
2046
 
2006
2047
 
2007
2048
  SWIGINTERN VALUE
2008
- SWIG_ruby_failed(void)
2049
+ SWIG_ruby_failed(VALUE SWIGUNUSEDPARM(arg1), VALUE SWIGUNUSEDPARM(arg2))
2009
2050
  {
2010
2051
  return Qnil;
2011
2052
  }
2012
2053
 
2013
2054
 
2014
- /*@SWIG:/usr/local/share/swig/3.0.7/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
2015
- SWIGINTERN VALUE SWIG_AUX_NUM2LONG(VALUE *args)
2055
+ /*@SWIG:/usr/local/Cellar/swig/4.0.2/share/swig/4.0.2/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
2056
+ SWIGINTERN VALUE SWIG_AUX_NUM2LONG(VALUE arg)
2016
2057
  {
2058
+ VALUE *args = (VALUE *)arg;
2017
2059
  VALUE obj = args[0];
2018
2060
  VALUE type = TYPE(obj);
2019
2061
  long *res = (long *)(args[1]);
@@ -2031,7 +2073,7 @@ SWIG_AsVal_long (VALUE obj, long* val)
2031
2073
  VALUE a[2];
2032
2074
  a[0] = obj;
2033
2075
  a[1] = (VALUE)(&v);
2034
- if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2LONG), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) {
2076
+ if (rb_rescue(VALUEFUNC(SWIG_AUX_NUM2LONG), (VALUE)a, VALUEFUNC(SWIG_ruby_failed), 0) != Qnil) {
2035
2077
  if (val) *val = v;
2036
2078
  return SWIG_OK;
2037
2079
  }
@@ -2076,18 +2118,18 @@ SWIG_From_int (int value)
2076
2118
  }
2077
2119
 
2078
2120
 
2079
- SWIGINTERNINLINE VALUE
2080
- SWIG_From_long_SS_long (long long value)
2081
- {
2082
- return LL2NUM(value);
2083
- }
2121
+ #if defined(LLONG_MAX) && !defined(SWIG_LONG_LONG_AVAILABLE)
2122
+ # define SWIG_LONG_LONG_AVAILABLE
2123
+ #endif
2084
2124
 
2085
2125
 
2126
+ #ifdef SWIG_LONG_LONG_AVAILABLE
2086
2127
  SWIGINTERNINLINE VALUE
2087
2128
  SWIG_From_unsigned_SS_long_SS_long (unsigned long long value)
2088
2129
  {
2089
2130
  return ULL2NUM(value);
2090
2131
  }
2132
+ #endif
2091
2133
 
2092
2134
 
2093
2135
  SWIGINTERN int
@@ -2132,7 +2174,7 @@ SWIG_AsCharPtrAndSize(VALUE obj, char** cptr, size_t* psize, int *alloc)
2132
2174
  if (cptr) {
2133
2175
  if (alloc) {
2134
2176
  if (*alloc == SWIG_NEWOBJ) {
2135
- *cptr = reinterpret_cast< char* >(memcpy((new char[size]), cstr, sizeof(char)*(size)));
2177
+ *cptr = reinterpret_cast< char* >(memcpy(new char[size], cstr, sizeof(char)*(size)));
2136
2178
  } else {
2137
2179
  *cptr = cstr;
2138
2180
  *alloc = SWIG_OLDOBJ;
@@ -2210,6 +2252,13 @@ SWIGINTERN void TagLib_FLAC_File_close(TagLib::FLAC::File *self){
2210
2252
  SWIG_RubyRemoveTracking(properties);
2211
2253
  }
2212
2254
 
2255
+ TagLib::List<TagLib::FLAC::Picture *> list = file->pictureList();
2256
+ for (TagLib::List<TagLib::FLAC::Picture *>::ConstIterator it = list.begin(); it != list.end(); it++) {
2257
+ TagLib::FLAC::Picture *picture = (*it);
2258
+ SWIG_RubyUnlinkObjects(picture);
2259
+ SWIG_RubyRemoveTracking(picture);
2260
+ }
2261
+
2213
2262
  SWIG_RubyUnlinkObjects(ptr);
2214
2263
  SWIG_RubyRemoveTracking(ptr);
2215
2264
 
@@ -2334,22 +2383,20 @@ fail:
2334
2383
  }
2335
2384
 
2336
2385
 
2337
- #ifdef HAVE_RB_DEFINE_ALLOC_FUNC
2338
2386
  SWIGINTERN VALUE
2339
- _wrap_Properties_allocate(VALUE self) {
2387
+ #ifdef HAVE_RB_DEFINE_ALLOC_FUNC
2388
+ _wrap_Properties_allocate(VALUE self)
2340
2389
  #else
2341
- SWIGINTERN VALUE
2342
- _wrap_Properties_allocate(int argc, VALUE *argv, VALUE self) {
2390
+ _wrap_Properties_allocate(int argc, VALUE *argv, VALUE self)
2343
2391
  #endif
2344
-
2345
-
2346
- VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__FLAC__Properties);
2392
+ {
2393
+ VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__FLAC__Properties);
2347
2394
  #ifndef HAVE_RB_DEFINE_ALLOC_FUNC
2348
- rb_obj_call_init(vresult, argc, argv);
2395
+ rb_obj_call_init(vresult, argc, argv);
2349
2396
  #endif
2350
- return vresult;
2351
- }
2352
-
2397
+ return vresult;
2398
+ }
2399
+
2353
2400
 
2354
2401
  SWIGINTERN VALUE
2355
2402
  _wrap_new_Properties__SWIG_3(int argc, VALUE *argv, VALUE self) {
@@ -2412,7 +2459,7 @@ SWIGINTERN VALUE _wrap_new_Properties(int nargs, VALUE *args, VALUE self) {
2412
2459
  if (argc == 2) {
2413
2460
  int _v;
2414
2461
  void *vptr = 0;
2415
- int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_TagLib__ByteVector, 0);
2462
+ int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_TagLib__ByteVector, SWIG_POINTER_NO_NULL);
2416
2463
  _v = SWIG_CheckState(res);
2417
2464
  if (_v) {
2418
2465
  {
@@ -2427,7 +2474,7 @@ SWIGINTERN VALUE _wrap_new_Properties(int nargs, VALUE *args, VALUE self) {
2427
2474
  if (argc == 3) {
2428
2475
  int _v;
2429
2476
  void *vptr = 0;
2430
- int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_TagLib__ByteVector, 0);
2477
+ int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_TagLib__ByteVector, SWIG_POINTER_NO_NULL);
2431
2478
  _v = SWIG_CheckState(res);
2432
2479
  if (_v) {
2433
2480
  {
@@ -2458,7 +2505,8 @@ fail:
2458
2505
 
2459
2506
 
2460
2507
  SWIGINTERN void
2461
- free_TagLib_FLAC_Properties(TagLib::FLAC::Properties *arg1) {
2508
+ free_TagLib_FLAC_Properties(void *self) {
2509
+ TagLib::FLAC::Properties *arg1 = (TagLib::FLAC::Properties *)self;
2462
2510
  SWIG_RubyRemoveTracking(arg1);
2463
2511
  delete arg1;
2464
2512
  }
@@ -2838,22 +2886,20 @@ fail:
2838
2886
  }
2839
2887
 
2840
2888
 
2841
- #ifdef HAVE_RB_DEFINE_ALLOC_FUNC
2842
2889
  SWIGINTERN VALUE
2843
- _wrap_File_allocate(VALUE self) {
2890
+ #ifdef HAVE_RB_DEFINE_ALLOC_FUNC
2891
+ _wrap_File_allocate(VALUE self)
2844
2892
  #else
2845
- SWIGINTERN VALUE
2846
- _wrap_File_allocate(int argc, VALUE *argv, VALUE self) {
2893
+ _wrap_File_allocate(int argc, VALUE *argv, VALUE self)
2847
2894
  #endif
2848
-
2849
-
2850
- VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__FLAC__File);
2895
+ {
2896
+ VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__FLAC__File);
2851
2897
  #ifndef HAVE_RB_DEFINE_ALLOC_FUNC
2852
- rb_obj_call_init(vresult, argc, argv);
2898
+ rb_obj_call_init(vresult, argc, argv);
2853
2899
  #endif
2854
- return vresult;
2855
- }
2856
-
2900
+ return vresult;
2901
+ }
2902
+
2857
2903
 
2858
2904
  SWIGINTERN VALUE
2859
2905
  _wrap_new_File__SWIG_5(int argc, VALUE *argv, VALUE self) {
@@ -3175,7 +3221,7 @@ SWIGINTERN VALUE _wrap_File_id3v2_tag(int nargs, VALUE *args, VALUE self) {
3175
3221
 
3176
3222
  fail:
3177
3223
  Ruby_Format_OverloadedError( argc, 3, "File.id3v2_tag",
3178
- " TagLib::ID3v2::Tag * File.id3v2_tag(bool create)\n"
3224
+ " TagLib::ID3v2::Tag File.id3v2_tag(bool create)\n"
3179
3225
  " TagLib::ID3v2::Tag * File.id3v2_tag()\n");
3180
3226
 
3181
3227
  return Qnil;
@@ -3276,7 +3322,7 @@ SWIGINTERN VALUE _wrap_File_id3v1_tag(int nargs, VALUE *args, VALUE self) {
3276
3322
 
3277
3323
  fail:
3278
3324
  Ruby_Format_OverloadedError( argc, 3, "File.id3v1_tag",
3279
- " TagLib::ID3v1::Tag * File.id3v1_tag(bool create)\n"
3325
+ " TagLib::ID3v1::Tag File.id3v1_tag(bool create)\n"
3280
3326
  " TagLib::ID3v1::Tag * File.id3v1_tag()\n");
3281
3327
 
3282
3328
  return Qnil;
@@ -3377,7 +3423,7 @@ SWIGINTERN VALUE _wrap_File_xiph_comment(int nargs, VALUE *args, VALUE self) {
3377
3423
 
3378
3424
  fail:
3379
3425
  Ruby_Format_OverloadedError( argc, 3, "File.xiph_comment",
3380
- " TagLib::Ogg::XiphComment * File.xiph_comment(bool create)\n"
3426
+ " TagLib::Ogg::XiphComment File.xiph_comment(bool create)\n"
3381
3427
  " TagLib::Ogg::XiphComment * File.xiph_comment()\n");
3382
3428
 
3383
3429
  return Qnil;
@@ -3944,7 +3990,7 @@ SWIG_InitializeModule(void *clientdata) {
3944
3990
 
3945
3991
  /* Now work on filling in swig_module.types */
3946
3992
  #ifdef SWIGRUNTIME_DEBUG
3947
- printf("SWIG_InitializeModule: size %d\n", swig_module.size);
3993
+ printf("SWIG_InitializeModule: size %lu\n", (unsigned long)swig_module.size);
3948
3994
  #endif
3949
3995
  for (i = 0; i < swig_module.size; ++i) {
3950
3996
  swig_type_info *type = 0;
@@ -3952,7 +3998,7 @@ SWIG_InitializeModule(void *clientdata) {
3952
3998
  swig_cast_info *cast;
3953
3999
 
3954
4000
  #ifdef SWIGRUNTIME_DEBUG
3955
- printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name);
4001
+ printf("SWIG_InitializeModule: type %lu %s\n", (unsigned long)i, swig_module.type_initial[i]->name);
3956
4002
  #endif
3957
4003
 
3958
4004
  /* if there is another module already loaded */
@@ -4028,7 +4074,7 @@ SWIG_InitializeModule(void *clientdata) {
4028
4074
  for (i = 0; i < swig_module.size; ++i) {
4029
4075
  int j = 0;
4030
4076
  swig_cast_info *cast = swig_module.cast_initial[i];
4031
- printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name);
4077
+ printf("SWIG_InitializeModule: type %lu %s\n", (unsigned long)i, swig_module.type_initial[i]->name);
4032
4078
  while (cast->type) {
4033
4079
  printf("SWIG_InitializeModule: cast type %s\n", cast->type->name);
4034
4080
  cast++;