diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fb5b7dd..d5b65eb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,7 @@ jobs: MAKEFLAGS: -j2 PLATFORM: x86_64-linux TAGLIB_VERSION: 1.11.1 - SWIG_DIR: .swig-v3.0.7 + SWIG_DIR: .swig-v4.0.2 steps: - uses: actions/checkout@v2 @@ -34,17 +34,17 @@ jobs: with: ruby-version: ${{ matrix.ruby }} - - name: Cache SWIG v3.0.7 + - name: Cache SWIG v4.0.2 id: cache-swig uses: actions/cache@v2 with: path: ~/${{ env.SWIG_DIR }} - key: swig-${{ matrix.os }}-v3.0.7 + key: swig-${{ matrix.os }}-v4.0.2 - - name: Install SWIG v3.0.7 + - name: Install SWIG v4.0.2 run: | sudo apt install yodl - git clone --depth 1 --branch v3.0.7 https://github.com/swig/swig.git + git clone --depth 1 --branch v4.0.2 https://github.com/swig/swig.git cd swig ./autogen.sh ./configure --prefix=$HOME/$SWIG_DIR --with-ruby=$(which ruby) --without-alllang diff --git a/ext/taglib_aiff/taglib_aiff_wrap.cxx b/ext/taglib_aiff/taglib_aiff_wrap.cxx index 09467d5..495259b 100644 --- a/ext/taglib_aiff/taglib_aiff_wrap.cxx +++ b/ext/taglib_aiff/taglib_aiff_wrap.cxx @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 3.0.7 + * Version 4.0.2 * * This file is not intended to be easily readable and contains a number of * coding conventions designed to improve portability and efficiency. Do not make @@ -11,7 +11,11 @@ static void free_taglib_riff_aiff_file(void *ptr); + +#ifndef SWIGRUBY #define SWIGRUBY +#endif + #ifdef __cplusplus @@ -104,9 +108,11 @@ template T SwigValueInit() { #endif /* exporting methods */ -#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) -# ifndef GCC_HASCLASSVISIBILITY -# define GCC_HASCLASSVISIBILITY +#if defined(__GNUC__) +# if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +# ifndef GCC_HASCLASSVISIBILITY +# define GCC_HASCLASSVISIBILITY +# endif # endif #endif @@ -226,9 +232,11 @@ template T SwigValueInit() { #endif /* exporting methods */ -#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) -# ifndef GCC_HASCLASSVISIBILITY -# define GCC_HASCLASSVISIBILITY +#if defined(__GNUC__) +# if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +# ifndef GCC_HASCLASSVISIBILITY +# define GCC_HASCLASSVISIBILITY +# endif # endif #endif @@ -326,6 +334,7 @@ template T SwigValueInit() { /* Flags for pointer conversions */ #define SWIG_POINTER_DISOWN 0x1 #define SWIG_CAST_NEW_MEMORY 0x2 +#define SWIG_POINTER_NO_NULL 0x4 /* Flags for new pointer objects */ #define SWIG_POINTER_OWN 0x1 @@ -778,16 +787,16 @@ SWIG_UnpackData(const char *c, void *ptr, size_t sz) { char d = *(c++); unsigned char uu; if ((d >= '0') && (d <= '9')) - uu = ((d - '0') << 4); + uu = (unsigned char)((d - '0') << 4); else if ((d >= 'a') && (d <= 'f')) - uu = ((d - ('a'-10)) << 4); + uu = (unsigned char)((d - ('a'-10)) << 4); else return (char *) 0; d = *(c++); if ((d >= '0') && (d <= '9')) - uu |= (d - '0'); + uu |= (unsigned char)(d - '0'); else if ((d >= 'a') && (d <= 'f')) - uu |= (d - ('a'-10)); + uu |= (unsigned char)(d - ('a'-10)); else return (char *) 0; *u = uu; @@ -964,42 +973,53 @@ SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { #ifndef RSTRUCT_PTR # define RSTRUCT_PTR(x) RSTRUCT(x)->ptr #endif +#ifndef RTYPEDDATA_P +# define RTYPEDDATA_P(x) (TYPE(x) != T_DATA) +#endif /* - * Need to be very careful about how these macros are defined, especially - * when compiling C++ code or C code with an ANSI C compiler. + * The following macros are used for providing the correct type of a + * function pointer to the Ruby C API. + * Starting with Ruby 2.7 (corresponding to RB_METHOD_DEFINITION_DECL being + * defined) these macros act transparently due to Ruby's moving away from + * ANYARGS and instead employing strict function signatures. * - * VALUEFUNC(f) is a macro used to typecast a C function that implements - * a Ruby method so that it can be passed as an argument to API functions - * like rb_define_method() and rb_define_singleton_method(). + * Note: In case of C (not C++) the macros are transparent even before + * Ruby 2.7 due to the fact that the Ruby C API used function declarators + * with empty parentheses, which allows for an unspecified number of + * arguments. * - * VOIDFUNC(f) is a macro used to typecast a C function that implements - * either the "mark" or "free" stuff for a Ruby Data object, so that it - * can be passed as an argument to API functions like Data_Wrap_Struct() + * PROTECTFUNC(f) is used for the function pointer argument of the Ruby + * C API function rb_protect(). + * + * VALUEFUNC(f) is used for the function pointer argument(s) of Ruby C API + * functions like rb_define_method() and rb_define_singleton_method(). + * + * VOIDFUNC(f) is used to typecast a C function that implements either + * the "mark" or "free" stuff for a Ruby Data object, so that it can be + * passed as an argument to Ruby C API functions like Data_Wrap_Struct() * and Data_Make_Struct(). + * + * SWIG_RUBY_VOID_ANYARGS_FUNC(f) is used for the function pointer + * argument(s) of Ruby C API functions like rb_define_virtual_variable(). + * + * SWIG_RUBY_INT_ANYARGS_FUNC(f) is used for the function pointer + * argument(s) of Ruby C API functions like st_foreach(). */ - -#ifdef __cplusplus -# ifndef RUBY_METHOD_FUNC /* These definitions should work for Ruby 1.4.6 */ -# define PROTECTFUNC(f) ((VALUE (*)()) f) -# define VALUEFUNC(f) ((VALUE (*)()) f) -# define VOIDFUNC(f) ((void (*)()) f) -# else -# ifndef ANYARGS /* These definitions should work for Ruby 1.6 */ -# define PROTECTFUNC(f) ((VALUE (*)()) f) -# define VALUEFUNC(f) ((VALUE (*)()) f) -# define VOIDFUNC(f) ((RUBY_DATA_FUNC) f) -# else /* These definitions should work for Ruby 1.7+ */ -# define PROTECTFUNC(f) ((VALUE (*)(VALUE)) f) -# define VALUEFUNC(f) ((VALUE (*)(ANYARGS)) f) -# define VOIDFUNC(f) ((RUBY_DATA_FUNC) f) -# endif -# endif +#if defined(__cplusplus) && !defined(RB_METHOD_DEFINITION_DECL) +# define PROTECTFUNC(f) ((VALUE (*)(VALUE)) f) +# define VALUEFUNC(f) ((VALUE (*)(ANYARGS)) f) +# define VOIDFUNC(f) ((RUBY_DATA_FUNC) f) +# define SWIG_RUBY_VOID_ANYARGS_FUNC(f) ((void (*)(ANYARGS))(f)) +# define SWIG_RUBY_INT_ANYARGS_FUNC(f) ((int (*)(ANYARGS))(f)) #else +# define PROTECTFUNC(f) (f) # define VALUEFUNC(f) (f) # define VOIDFUNC(f) (f) +# define SWIG_RUBY_VOID_ANYARGS_FUNC(f) (f) +# define SWIG_RUBY_INT_ANYARGS_FUNC(f) (f) #endif /* Don't use for expressions have side effect */ @@ -1187,7 +1207,7 @@ void Ruby_Format_OverloadedError( /* ----------------------------------------------------------------------------- * rubytracking.swg * - * This file contains support for tracking mappings from + * This file contains support for tracking mappings from * Ruby objects to C++ objects. This functionality is needed * to implement mark functions for Ruby's mark and sweep * garbage collector. @@ -1197,6 +1217,11 @@ void Ruby_Format_OverloadedError( extern "C" { #endif +#if !defined(ST_DATA_T_DEFINED) +/* Needs to be explicitly included for Ruby 1.8 and earlier */ +#include +#endif + /* Ruby 1.8 actually assumes the first case. */ #if SIZEOF_VOIDP == SIZEOF_LONG # define SWIG2NUM(v) LONG2NUM((unsigned long)v) @@ -1208,109 +1233,69 @@ extern "C" { # error sizeof(void*) is not the same as long or long long #endif - -/* Global Ruby hash table to store Trackings from C/C++ - structs to Ruby Objects. +/* Global hash table to store Trackings from C/C++ + structs to Ruby Objects. */ -static VALUE swig_ruby_trackings = Qnil; +static st_table* swig_ruby_trackings = NULL; + +static VALUE swig_ruby_trackings_count(ID id, VALUE *var) { + return SWIG2NUM(swig_ruby_trackings->num_entries); +} -/* Global variable that stores a reference to the ruby - hash table delete function. */ -static ID swig_ruby_hash_delete; -/* Setup a Ruby hash table to store Trackings */ +/* Setup a hash table to store Trackings */ SWIGRUNTIME void SWIG_RubyInitializeTrackings(void) { - /* Create a ruby hash table to store Trackings from C++ + /* Create a hash table to store Trackings from C++ objects to Ruby objects. */ - /* Try to see if some other .so has already created a + /* Try to see if some other .so has already created a tracking hash table, which we keep hidden in an instance var in the SWIG module. This is done to allow multiple DSOs to share the same tracking table. */ - ID trackings_id = rb_intern( "@__trackings__" ); + VALUE trackings_value = Qnil; + /* change the variable name so that we can mix modules + compiled with older SWIG's - this used to be called "@__trackings__" */ + ID trackings_id = rb_intern( "@__safetrackings__" ); VALUE verbose = rb_gv_get("VERBOSE"); rb_gv_set("VERBOSE", Qfalse); - swig_ruby_trackings = rb_ivar_get( _mSWIG, trackings_id ); + trackings_value = rb_ivar_get( _mSWIG, trackings_id ); rb_gv_set("VERBOSE", verbose); - /* No, it hasn't. Create one ourselves */ - if ( swig_ruby_trackings == Qnil ) - { - swig_ruby_trackings = rb_hash_new(); - rb_ivar_set( _mSWIG, trackings_id, swig_ruby_trackings ); - } - - /* Now store a reference to the hash table delete function - so that we only have to look it up once.*/ - swig_ruby_hash_delete = rb_intern("delete"); -} - -/* Get a Ruby number to reference a pointer */ -SWIGRUNTIME VALUE SWIG_RubyPtrToReference(void* ptr) { - /* We cast the pointer to an unsigned long - and then store a reference to it using - a Ruby number object. */ - - /* Convert the pointer to a Ruby number */ - return SWIG2NUM(ptr); -} - -/* Get a Ruby number to reference an object */ -SWIGRUNTIME VALUE SWIG_RubyObjectToReference(VALUE object) { - /* We cast the object to an unsigned long - and then store a reference to it using - a Ruby number object. */ - - /* Convert the Object to a Ruby number */ - return SWIG2NUM(object); -} - -/* Get a Ruby object from a previously stored reference */ -SWIGRUNTIME VALUE SWIG_RubyReferenceToObject(VALUE reference) { - /* The provided Ruby number object is a reference - to the Ruby object we want.*/ + /* The trick here is that we have to store the hash table + pointer in a Ruby variable. We do not want Ruby's GC to + treat this pointer as a Ruby object, so we convert it to + a Ruby numeric value. */ + if (trackings_value == Qnil) { + /* No, it hasn't. Create one ourselves */ + swig_ruby_trackings = st_init_numtable(); + rb_ivar_set( _mSWIG, trackings_id, SWIG2NUM(swig_ruby_trackings) ); + } else { + swig_ruby_trackings = (st_table*)NUM2SWIG(trackings_value); + } - /* Convert the Ruby number to a Ruby object */ - return NUM2SWIG(reference); + rb_define_virtual_variable("SWIG_TRACKINGS_COUNT", + VALUEFUNC(swig_ruby_trackings_count), + SWIG_RUBY_VOID_ANYARGS_FUNC((rb_gvar_setter_t*)NULL)); } /* Add a Tracking from a C/C++ struct to a Ruby object */ SWIGRUNTIME void SWIG_RubyAddTracking(void* ptr, VALUE object) { - /* In a Ruby hash table we store the pointer and - the associated Ruby object. The trick here is - that we cannot store the Ruby object directly - if - we do then it cannot be garbage collected. So - instead we typecast it as a unsigned long and - convert it to a Ruby number object.*/ - - /* Get a reference to the pointer as a Ruby number */ - VALUE key = SWIG_RubyPtrToReference(ptr); - - /* Get a reference to the Ruby object as a Ruby number */ - VALUE value = SWIG_RubyObjectToReference(object); - /* Store the mapping to the global hash table. */ - rb_hash_aset(swig_ruby_trackings, key, value); + st_insert(swig_ruby_trackings, (st_data_t)ptr, object); } /* Get the Ruby object that owns the specified C/C++ struct */ SWIGRUNTIME VALUE SWIG_RubyInstanceFor(void* ptr) { - /* Get a reference to the pointer as a Ruby number */ - VALUE key = SWIG_RubyPtrToReference(ptr); - /* Now lookup the value stored in the global hash table */ - VALUE value = rb_hash_aref(swig_ruby_trackings, key); - - if (value == Qnil) { - /* No object exists - return nil. */ + VALUE value; + + if (st_lookup(swig_ruby_trackings, (st_data_t)ptr, &value)) { + return value; + } else { return Qnil; } - else { - /* Convert this value to Ruby object */ - return SWIG_RubyReferenceToObject(value); - } } /* Remove a Tracking from a C/C++ struct to a Ruby object. It @@ -1318,25 +1303,39 @@ SWIGRUNTIME VALUE SWIG_RubyInstanceFor(void* ptr) { since the same memory address may be reused later to create a new object. */ SWIGRUNTIME void SWIG_RubyRemoveTracking(void* ptr) { - /* Get a reference to the pointer as a Ruby number */ - VALUE key = SWIG_RubyPtrToReference(ptr); - - /* Delete the object from the hash table by calling Ruby's - do this we need to call the Hash.delete method.*/ - rb_funcall(swig_ruby_trackings, swig_ruby_hash_delete, 1, key); + /* Delete the object from the hash table */ + st_delete(swig_ruby_trackings, (st_data_t *)&ptr, NULL); } /* This is a helper method that unlinks a Ruby object from its underlying C++ object. This is needed if the lifetime of the - Ruby object is longer than the C++ object */ + Ruby object is longer than the C++ object. */ SWIGRUNTIME void SWIG_RubyUnlinkObjects(void* ptr) { VALUE object = SWIG_RubyInstanceFor(ptr); if (object != Qnil) { + // object might have the T_ZOMBIE type, but that's just + // because the GC has flagged it as such for a deferred + // destruction. Until then, it's still a T_DATA object. DATA_PTR(object) = 0; } } +/* This is a helper method that iterates over all the trackings + passing the C++ object pointer and its related Ruby object + to the passed callback function. */ + +/* Proxy method to abstract the internal trackings datatype */ +static int swig_ruby_internal_iterate_callback(st_data_t ptr, st_data_t obj, st_data_t meth) { + ((void (*) (void *, VALUE))meth)((void *)ptr, (VALUE)obj); + return ST_CONTINUE; +} + +SWIGRUNTIME void SWIG_RubyIterateTrackings( void(*meth)(void* ptr, VALUE obj) ) { + st_foreach(swig_ruby_trackings, + SWIG_RUBY_INT_ANYARGS_FUNC(swig_ruby_internal_iterate_callback), + (st_data_t)meth); +} #ifdef __cplusplus } @@ -1395,7 +1394,7 @@ SWIG_Ruby_AppendOutput(VALUE target, VALUE o) { #define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Ruby_ConvertPtrAndOwn(obj, pptr, type, flags, own) #define SWIG_NewPointerObj(ptr, type, flags) SWIG_Ruby_NewPointerObj(ptr, type, flags) #define SWIG_AcquirePtr(ptr, own) SWIG_Ruby_AcquirePtr(ptr, own) -#define swig_owntype ruby_owntype +#define swig_owntype swig_ruby_owntype /* for raw packed data */ #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) swig_class *sklass; VALUE klass; VALUE obj; - + if (!ptr) return Qnil; - + + assert(type); if (type->clientdata) { sklass = (swig_class *) type->clientdata; @@ -1563,7 +1563,7 @@ SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags) track = sklass->trackObjects; if (track) { obj = SWIG_RubyInstanceFor(ptr); - + /* Check the object's type and make sure it has the correct type. It might not in cases where methods do things like downcast methods. */ @@ -1595,7 +1595,7 @@ SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags) obj = Data_Wrap_Struct(klass, 0, 0, ptr); } rb_iv_set(obj, "@__swigtype__", rb_str_new2(type->name)); - + return obj; } @@ -1615,26 +1615,30 @@ SWIGRUNTIMEINLINE char * SWIG_Ruby_MangleStr(VALUE obj) { VALUE stype = rb_iv_get(obj, "@__swigtype__"); + if (NIL_P(stype)) + return NULL; return StringValuePtr(stype); } /* Acquire a pointer value */ -typedef void (*ruby_owntype)(void*); - -SWIGRUNTIME ruby_owntype -SWIG_Ruby_AcquirePtr(VALUE obj, ruby_owntype own) { - if (obj) { - ruby_owntype oldown = RDATA(obj)->dfree; - RDATA(obj)->dfree = own; - return oldown; - } else { - return 0; +typedef struct { + void (*datafree)(void *); + int own; +} swig_ruby_owntype; + +SWIGRUNTIME swig_ruby_owntype +SWIG_Ruby_AcquirePtr(VALUE obj, swig_ruby_owntype own) { + swig_ruby_owntype oldown = {0, 0}; + if (TYPE(obj) == T_DATA && !RTYPEDDATA_P(obj)) { + oldown.datafree = RDATA(obj)->dfree; + RDATA(obj)->dfree = own.datafree; } + return oldown; } /* Convert a pointer value */ SWIGRUNTIME int -SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, ruby_owntype *own) +SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, swig_ruby_owntype *own) { char *c; swig_cast_info *tc; @@ -1642,16 +1646,20 @@ SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, /* Grab the pointer */ if (NIL_P(obj)) { - *ptr = 0; - return SWIG_OK; + if (ptr) + *ptr = 0; + return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK; } else { - if (TYPE(obj) != T_DATA) { + if (TYPE(obj) != T_DATA || (TYPE(obj) == T_DATA && RTYPEDDATA_P(obj))) { return SWIG_ERROR; } Data_Get_Struct(obj, void, vptr); } - if (own) *own = RDATA(obj)->dfree; + if (own) { + own->datafree = RDATA(obj)->dfree; + own->own = 0; + } /* Check to see if the input object is giving up ownership 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, /* The object has already been deleted */ return SWIG_ObjectPreviouslyDeletedError; } - *ptr = vptr; - return SWIG_OK; } } if ((c = SWIG_MangleStr(obj)) == NULL) { @@ -1697,12 +1703,23 @@ SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, if (!tc) { return SWIG_ERROR; } else { - int newmemory = 0; - *ptr = SWIG_TypeCast(tc, vptr, &newmemory); - assert(!newmemory); /* newmemory handling not yet implemented */ + if (ptr) { + if (tc->type == ty) { + *ptr = vptr; + } else { + int newmemory = 0; + *ptr = SWIG_TypeCast(tc, vptr, &newmemory); + if (newmemory == SWIG_CAST_NEW_MEMORY) { + assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */ + if (own) + own->own = own->own | SWIG_CAST_NEW_MEMORY; + } + } + } } } else { - *ptr = vptr; + if (ptr) + *ptr = vptr; } return SWIG_OK; @@ -1728,7 +1745,7 @@ SWIG_Ruby_NewPackedObj(void *ptr, int sz, swig_type_info *type) { return rb_str_new2(result); } -/* Convert a packed value value */ +/* Convert a packed pointer value */ SWIGRUNTIME int SWIG_Ruby_ConvertPacked(VALUE obj, void *ptr, int sz, swig_type_info *ty) { swig_cast_info *tc; @@ -1855,7 +1872,7 @@ static VALUE mAIFF; #define SWIG_RUBY_THREAD_END_BLOCK -#define SWIGVERSION 0x030007 +#define SWIGVERSION 0x040002 #define SWIG_VERSION SWIGVERSION @@ -1874,6 +1891,8 @@ static VALUE mAIFF; #include #include +#include +#include #include #if defined(HAVE_RUBY_ENCODING_H) && HAVE_RUBY_ENCODING_H @@ -1943,6 +1962,28 @@ TagLib::StringList ruby_array_to_taglib_string_list(VALUE ary) { return result; } +VALUE taglib_bytevectorlist_to_ruby_array(const TagLib::ByteVectorList & list) { + VALUE ary = rb_ary_new2(list.size()); + for (TagLib::ByteVectorList::ConstIterator it = list.begin(); it != list.end(); it++) { + VALUE s = taglib_bytevector_to_ruby_string(*it); + rb_ary_push(ary, s); + } + return ary; +} + +TagLib::ByteVectorList ruby_array_to_taglib_bytevectorlist(VALUE ary) { + TagLib::ByteVectorList result = TagLib::ByteVectorList(); + if (NIL_P(ary)) { + return result; + } + for (long i = 0; i < RARRAY_LEN(ary); i++) { + VALUE e = rb_ary_entry(ary, i); + TagLib::ByteVector s = ruby_string_to_taglib_bytevector(e); + result.append(s); + } + return result; +} + VALUE taglib_filename_to_ruby_string(TagLib::FileName filename) { VALUE result; #ifdef _WIN32 @@ -1995,15 +2036,16 @@ TagLib::FileName ruby_string_to_taglib_filename(VALUE s) { SWIGINTERN VALUE -SWIG_ruby_failed(void) +SWIG_ruby_failed(VALUE SWIGUNUSEDPARM(arg1), VALUE SWIGUNUSEDPARM(arg2)) { return Qnil; } -/*@SWIG:/usr/local/share/swig/3.0.7/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/ -SWIGINTERN VALUE SWIG_AUX_NUM2LONG(VALUE *args) +/*@SWIG:/usr/local/Cellar/swig/4.0.2/share/swig/4.0.2/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/ +SWIGINTERN VALUE SWIG_AUX_NUM2LONG(VALUE arg) { + VALUE *args = (VALUE *)arg; VALUE obj = args[0]; VALUE type = TYPE(obj); long *res = (long *)(args[1]); @@ -2021,7 +2063,7 @@ SWIG_AsVal_long (VALUE obj, long* val) VALUE a[2]; a[0] = obj; a[1] = (VALUE)(&v); - if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2LONG), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) { + if (rb_rescue(VALUEFUNC(SWIG_AUX_NUM2LONG), (VALUE)a, VALUEFUNC(SWIG_ruby_failed), 0) != Qnil) { if (val) *val = v; return SWIG_OK; } @@ -2119,7 +2161,7 @@ SWIG_AsCharPtrAndSize(VALUE obj, char** cptr, size_t* psize, int *alloc) if (cptr) { if (alloc) { if (*alloc == SWIG_NEWOBJ) { - *cptr = reinterpret_cast< char* >(memcpy((new char[size]), cstr, sizeof(char)*(size))); + *cptr = reinterpret_cast< char* >(memcpy(new char[size], cstr, sizeof(char)*(size))); } else { *cptr = cstr; *alloc = SWIG_OLDOBJ; @@ -2180,22 +2222,20 @@ SWIGINTERN void TagLib_RIFF_AIFF_File_close(TagLib::RIFF::AIFF::File *self){ static swig_class SwigClassProperties; -#ifdef HAVE_RB_DEFINE_ALLOC_FUNC SWIGINTERN VALUE -_wrap_Properties_allocate(VALUE self) { +#ifdef HAVE_RB_DEFINE_ALLOC_FUNC +_wrap_Properties_allocate(VALUE self) #else - SWIGINTERN VALUE - _wrap_Properties_allocate(int argc, VALUE *argv, VALUE self) { +_wrap_Properties_allocate(int argc, VALUE *argv, VALUE self) #endif - - - VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__RIFF__AIFF__Properties); +{ + VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__RIFF__AIFF__Properties); #ifndef HAVE_RB_DEFINE_ALLOC_FUNC - rb_obj_call_init(vresult, argc, argv); + rb_obj_call_init(vresult, argc, argv); #endif - return vresult; - } - + return vresult; +} + SWIGINTERN VALUE _wrap_new_Properties(int argc, VALUE *argv, VALUE self) { @@ -2230,7 +2270,8 @@ _wrap_new_Properties(int argc, VALUE *argv, VALUE self) { SWIGINTERN void -free_TagLib_RIFF_AIFF_Properties(TagLib::RIFF::AIFF::Properties *arg1) { +free_TagLib_RIFF_AIFF_Properties(void *self) { + TagLib::RIFF::AIFF::Properties *arg1 = (TagLib::RIFF::AIFF::Properties *)self; SWIG_RubyRemoveTracking(arg1); delete arg1; } @@ -2551,22 +2592,20 @@ _wrap_new_File__SWIG_1(int argc, VALUE *argv, VALUE self) { } -#ifdef HAVE_RB_DEFINE_ALLOC_FUNC SWIGINTERN VALUE -_wrap_File_allocate(VALUE self) { +#ifdef HAVE_RB_DEFINE_ALLOC_FUNC +_wrap_File_allocate(VALUE self) #else - SWIGINTERN VALUE - _wrap_File_allocate(int argc, VALUE *argv, VALUE self) { +_wrap_File_allocate(int argc, VALUE *argv, VALUE self) #endif - - - VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__RIFF__AIFF__File); +{ + VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__RIFF__AIFF__File); #ifndef HAVE_RB_DEFINE_ALLOC_FUNC - rb_obj_call_init(vresult, argc, argv); + rb_obj_call_init(vresult, argc, argv); #endif - return vresult; - } - + return vresult; +} + SWIGINTERN VALUE _wrap_new_File__SWIG_2(int argc, VALUE *argv, VALUE self) { @@ -2924,7 +2963,7 @@ SWIG_InitializeModule(void *clientdata) { /* Now work on filling in swig_module.types */ #ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: size %d\n", swig_module.size); + printf("SWIG_InitializeModule: size %lu\n", (unsigned long)swig_module.size); #endif for (i = 0; i < swig_module.size; ++i) { swig_type_info *type = 0; @@ -2932,7 +2971,7 @@ SWIG_InitializeModule(void *clientdata) { swig_cast_info *cast; #ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); + printf("SWIG_InitializeModule: type %lu %s\n", (unsigned long)i, swig_module.type_initial[i]->name); #endif /* if there is another module already loaded */ @@ -3008,7 +3047,7 @@ SWIG_InitializeModule(void *clientdata) { for (i = 0; i < swig_module.size; ++i) { int j = 0; swig_cast_info *cast = swig_module.cast_initial[i]; - printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); + printf("SWIG_InitializeModule: type %lu %s\n", (unsigned long)i, swig_module.type_initial[i]->name); while (cast->type) { printf("SWIG_InitializeModule: cast type %s\n", cast->type->name); cast++; diff --git a/ext/taglib_base/includes.i b/ext/taglib_base/includes.i index 84f95be..f416b94 100644 --- a/ext/taglib_base/includes.i +++ b/ext/taglib_base/includes.i @@ -3,6 +3,7 @@ // Undefine macros we don't need for wrapping #define TAGLIB_EXPORT #define TAGLIB_IGNORE_MISSING_DESTRUCTOR +#define TAGLIB_DEPRECATED // Replaces the typemap from swigtype.swg and just adds the line // SWIG_RubyUnlinkObjects. This is done to be safe in the case when a diff --git a/ext/taglib_base/taglib_base_wrap.cxx b/ext/taglib_base/taglib_base_wrap.cxx index 260683c..72cd5af 100644 --- a/ext/taglib_base/taglib_base_wrap.cxx +++ b/ext/taglib_base/taglib_base_wrap.cxx @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 3.0.7 + * Version 4.0.2 * * This file is not intended to be easily readable and contains a number of * coding conventions designed to improve portability and efficiency. Do not make @@ -11,7 +11,11 @@ static void free_taglib_fileref(void *ptr); + +#ifndef SWIGRUBY #define SWIGRUBY +#endif + #ifdef __cplusplus @@ -104,9 +108,11 @@ template T SwigValueInit() { #endif /* exporting methods */ -#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) -# ifndef GCC_HASCLASSVISIBILITY -# define GCC_HASCLASSVISIBILITY +#if defined(__GNUC__) +# if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +# ifndef GCC_HASCLASSVISIBILITY +# define GCC_HASCLASSVISIBILITY +# endif # endif #endif @@ -226,9 +232,11 @@ template T SwigValueInit() { #endif /* exporting methods */ -#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) -# ifndef GCC_HASCLASSVISIBILITY -# define GCC_HASCLASSVISIBILITY +#if defined(__GNUC__) +# if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +# ifndef GCC_HASCLASSVISIBILITY +# define GCC_HASCLASSVISIBILITY +# endif # endif #endif @@ -326,6 +334,7 @@ template T SwigValueInit() { /* Flags for pointer conversions */ #define SWIG_POINTER_DISOWN 0x1 #define SWIG_CAST_NEW_MEMORY 0x2 +#define SWIG_POINTER_NO_NULL 0x4 /* Flags for new pointer objects */ #define SWIG_POINTER_OWN 0x1 @@ -778,16 +787,16 @@ SWIG_UnpackData(const char *c, void *ptr, size_t sz) { char d = *(c++); unsigned char uu; if ((d >= '0') && (d <= '9')) - uu = ((d - '0') << 4); + uu = (unsigned char)((d - '0') << 4); else if ((d >= 'a') && (d <= 'f')) - uu = ((d - ('a'-10)) << 4); + uu = (unsigned char)((d - ('a'-10)) << 4); else return (char *) 0; d = *(c++); if ((d >= '0') && (d <= '9')) - uu |= (d - '0'); + uu |= (unsigned char)(d - '0'); else if ((d >= 'a') && (d <= 'f')) - uu |= (d - ('a'-10)); + uu |= (unsigned char)(d - ('a'-10)); else return (char *) 0; *u = uu; @@ -964,42 +973,53 @@ SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { #ifndef RSTRUCT_PTR # define RSTRUCT_PTR(x) RSTRUCT(x)->ptr #endif +#ifndef RTYPEDDATA_P +# define RTYPEDDATA_P(x) (TYPE(x) != T_DATA) +#endif /* - * Need to be very careful about how these macros are defined, especially - * when compiling C++ code or C code with an ANSI C compiler. + * The following macros are used for providing the correct type of a + * function pointer to the Ruby C API. + * Starting with Ruby 2.7 (corresponding to RB_METHOD_DEFINITION_DECL being + * defined) these macros act transparently due to Ruby's moving away from + * ANYARGS and instead employing strict function signatures. + * + * Note: In case of C (not C++) the macros are transparent even before + * Ruby 2.7 due to the fact that the Ruby C API used function declarators + * with empty parentheses, which allows for an unspecified number of + * arguments. * - * VALUEFUNC(f) is a macro used to typecast a C function that implements - * a Ruby method so that it can be passed as an argument to API functions - * like rb_define_method() and rb_define_singleton_method(). + * PROTECTFUNC(f) is used for the function pointer argument of the Ruby + * C API function rb_protect(). * - * VOIDFUNC(f) is a macro used to typecast a C function that implements - * either the "mark" or "free" stuff for a Ruby Data object, so that it - * can be passed as an argument to API functions like Data_Wrap_Struct() + * VALUEFUNC(f) is used for the function pointer argument(s) of Ruby C API + * functions like rb_define_method() and rb_define_singleton_method(). + * + * VOIDFUNC(f) is used to typecast a C function that implements either + * the "mark" or "free" stuff for a Ruby Data object, so that it can be + * passed as an argument to Ruby C API functions like Data_Wrap_Struct() * and Data_Make_Struct(). + * + * SWIG_RUBY_VOID_ANYARGS_FUNC(f) is used for the function pointer + * argument(s) of Ruby C API functions like rb_define_virtual_variable(). + * + * SWIG_RUBY_INT_ANYARGS_FUNC(f) is used for the function pointer + * argument(s) of Ruby C API functions like st_foreach(). */ - -#ifdef __cplusplus -# ifndef RUBY_METHOD_FUNC /* These definitions should work for Ruby 1.4.6 */ -# define PROTECTFUNC(f) ((VALUE (*)()) f) -# define VALUEFUNC(f) ((VALUE (*)()) f) -# define VOIDFUNC(f) ((void (*)()) f) -# else -# ifndef ANYARGS /* These definitions should work for Ruby 1.6 */ -# define PROTECTFUNC(f) ((VALUE (*)()) f) -# define VALUEFUNC(f) ((VALUE (*)()) f) -# define VOIDFUNC(f) ((RUBY_DATA_FUNC) f) -# else /* These definitions should work for Ruby 1.7+ */ -# define PROTECTFUNC(f) ((VALUE (*)(VALUE)) f) -# define VALUEFUNC(f) ((VALUE (*)(ANYARGS)) f) -# define VOIDFUNC(f) ((RUBY_DATA_FUNC) f) -# endif -# endif +#if defined(__cplusplus) && !defined(RB_METHOD_DEFINITION_DECL) +# define PROTECTFUNC(f) ((VALUE (*)(VALUE)) f) +# define VALUEFUNC(f) ((VALUE (*)(ANYARGS)) f) +# define VOIDFUNC(f) ((RUBY_DATA_FUNC) f) +# define SWIG_RUBY_VOID_ANYARGS_FUNC(f) ((void (*)(ANYARGS))(f)) +# define SWIG_RUBY_INT_ANYARGS_FUNC(f) ((int (*)(ANYARGS))(f)) #else +# define PROTECTFUNC(f) (f) # define VALUEFUNC(f) (f) # define VOIDFUNC(f) (f) +# define SWIG_RUBY_VOID_ANYARGS_FUNC(f) (f) +# define SWIG_RUBY_INT_ANYARGS_FUNC(f) (f) #endif /* Don't use for expressions have side effect */ @@ -1187,7 +1207,7 @@ void Ruby_Format_OverloadedError( /* ----------------------------------------------------------------------------- * rubytracking.swg * - * This file contains support for tracking mappings from + * This file contains support for tracking mappings from * Ruby objects to C++ objects. This functionality is needed * to implement mark functions for Ruby's mark and sweep * garbage collector. @@ -1197,6 +1217,11 @@ void Ruby_Format_OverloadedError( extern "C" { #endif +#if !defined(ST_DATA_T_DEFINED) +/* Needs to be explicitly included for Ruby 1.8 and earlier */ +#include +#endif + /* Ruby 1.8 actually assumes the first case. */ #if SIZEOF_VOIDP == SIZEOF_LONG # define SWIG2NUM(v) LONG2NUM((unsigned long)v) @@ -1208,109 +1233,69 @@ extern "C" { # error sizeof(void*) is not the same as long or long long #endif - -/* Global Ruby hash table to store Trackings from C/C++ - structs to Ruby Objects. +/* Global hash table to store Trackings from C/C++ + structs to Ruby Objects. */ -static VALUE swig_ruby_trackings = Qnil; +static st_table* swig_ruby_trackings = NULL; + +static VALUE swig_ruby_trackings_count(ID id, VALUE *var) { + return SWIG2NUM(swig_ruby_trackings->num_entries); +} -/* Global variable that stores a reference to the ruby - hash table delete function. */ -static ID swig_ruby_hash_delete; -/* Setup a Ruby hash table to store Trackings */ +/* Setup a hash table to store Trackings */ SWIGRUNTIME void SWIG_RubyInitializeTrackings(void) { - /* Create a ruby hash table to store Trackings from C++ + /* Create a hash table to store Trackings from C++ objects to Ruby objects. */ - /* Try to see if some other .so has already created a + /* Try to see if some other .so has already created a tracking hash table, which we keep hidden in an instance var in the SWIG module. This is done to allow multiple DSOs to share the same tracking table. */ - ID trackings_id = rb_intern( "@__trackings__" ); + VALUE trackings_value = Qnil; + /* change the variable name so that we can mix modules + compiled with older SWIG's - this used to be called "@__trackings__" */ + ID trackings_id = rb_intern( "@__safetrackings__" ); VALUE verbose = rb_gv_get("VERBOSE"); rb_gv_set("VERBOSE", Qfalse); - swig_ruby_trackings = rb_ivar_get( _mSWIG, trackings_id ); + trackings_value = rb_ivar_get( _mSWIG, trackings_id ); rb_gv_set("VERBOSE", verbose); - /* No, it hasn't. Create one ourselves */ - if ( swig_ruby_trackings == Qnil ) - { - swig_ruby_trackings = rb_hash_new(); - rb_ivar_set( _mSWIG, trackings_id, swig_ruby_trackings ); - } - - /* Now store a reference to the hash table delete function - so that we only have to look it up once.*/ - swig_ruby_hash_delete = rb_intern("delete"); -} - -/* Get a Ruby number to reference a pointer */ -SWIGRUNTIME VALUE SWIG_RubyPtrToReference(void* ptr) { - /* We cast the pointer to an unsigned long - and then store a reference to it using - a Ruby number object. */ - - /* Convert the pointer to a Ruby number */ - return SWIG2NUM(ptr); -} - -/* Get a Ruby number to reference an object */ -SWIGRUNTIME VALUE SWIG_RubyObjectToReference(VALUE object) { - /* We cast the object to an unsigned long - and then store a reference to it using - a Ruby number object. */ - - /* Convert the Object to a Ruby number */ - return SWIG2NUM(object); -} - -/* Get a Ruby object from a previously stored reference */ -SWIGRUNTIME VALUE SWIG_RubyReferenceToObject(VALUE reference) { - /* The provided Ruby number object is a reference - to the Ruby object we want.*/ + /* The trick here is that we have to store the hash table + pointer in a Ruby variable. We do not want Ruby's GC to + treat this pointer as a Ruby object, so we convert it to + a Ruby numeric value. */ + if (trackings_value == Qnil) { + /* No, it hasn't. Create one ourselves */ + swig_ruby_trackings = st_init_numtable(); + rb_ivar_set( _mSWIG, trackings_id, SWIG2NUM(swig_ruby_trackings) ); + } else { + swig_ruby_trackings = (st_table*)NUM2SWIG(trackings_value); + } - /* Convert the Ruby number to a Ruby object */ - return NUM2SWIG(reference); + rb_define_virtual_variable("SWIG_TRACKINGS_COUNT", + VALUEFUNC(swig_ruby_trackings_count), + SWIG_RUBY_VOID_ANYARGS_FUNC((rb_gvar_setter_t*)NULL)); } /* Add a Tracking from a C/C++ struct to a Ruby object */ SWIGRUNTIME void SWIG_RubyAddTracking(void* ptr, VALUE object) { - /* In a Ruby hash table we store the pointer and - the associated Ruby object. The trick here is - that we cannot store the Ruby object directly - if - we do then it cannot be garbage collected. So - instead we typecast it as a unsigned long and - convert it to a Ruby number object.*/ - - /* Get a reference to the pointer as a Ruby number */ - VALUE key = SWIG_RubyPtrToReference(ptr); - - /* Get a reference to the Ruby object as a Ruby number */ - VALUE value = SWIG_RubyObjectToReference(object); - /* Store the mapping to the global hash table. */ - rb_hash_aset(swig_ruby_trackings, key, value); + st_insert(swig_ruby_trackings, (st_data_t)ptr, object); } /* Get the Ruby object that owns the specified C/C++ struct */ SWIGRUNTIME VALUE SWIG_RubyInstanceFor(void* ptr) { - /* Get a reference to the pointer as a Ruby number */ - VALUE key = SWIG_RubyPtrToReference(ptr); - /* Now lookup the value stored in the global hash table */ - VALUE value = rb_hash_aref(swig_ruby_trackings, key); - - if (value == Qnil) { - /* No object exists - return nil. */ + VALUE value; + + if (st_lookup(swig_ruby_trackings, (st_data_t)ptr, &value)) { + return value; + } else { return Qnil; } - else { - /* Convert this value to Ruby object */ - return SWIG_RubyReferenceToObject(value); - } } /* Remove a Tracking from a C/C++ struct to a Ruby object. It @@ -1318,25 +1303,39 @@ SWIGRUNTIME VALUE SWIG_RubyInstanceFor(void* ptr) { since the same memory address may be reused later to create a new object. */ SWIGRUNTIME void SWIG_RubyRemoveTracking(void* ptr) { - /* Get a reference to the pointer as a Ruby number */ - VALUE key = SWIG_RubyPtrToReference(ptr); - - /* Delete the object from the hash table by calling Ruby's - do this we need to call the Hash.delete method.*/ - rb_funcall(swig_ruby_trackings, swig_ruby_hash_delete, 1, key); + /* Delete the object from the hash table */ + st_delete(swig_ruby_trackings, (st_data_t *)&ptr, NULL); } /* This is a helper method that unlinks a Ruby object from its underlying C++ object. This is needed if the lifetime of the - Ruby object is longer than the C++ object */ + Ruby object is longer than the C++ object. */ SWIGRUNTIME void SWIG_RubyUnlinkObjects(void* ptr) { VALUE object = SWIG_RubyInstanceFor(ptr); if (object != Qnil) { + // object might have the T_ZOMBIE type, but that's just + // because the GC has flagged it as such for a deferred + // destruction. Until then, it's still a T_DATA object. DATA_PTR(object) = 0; } } +/* This is a helper method that iterates over all the trackings + passing the C++ object pointer and its related Ruby object + to the passed callback function. */ + +/* Proxy method to abstract the internal trackings datatype */ +static int swig_ruby_internal_iterate_callback(st_data_t ptr, st_data_t obj, st_data_t meth) { + ((void (*) (void *, VALUE))meth)((void *)ptr, (VALUE)obj); + return ST_CONTINUE; +} + +SWIGRUNTIME void SWIG_RubyIterateTrackings( void(*meth)(void* ptr, VALUE obj) ) { + st_foreach(swig_ruby_trackings, + SWIG_RUBY_INT_ANYARGS_FUNC(swig_ruby_internal_iterate_callback), + (st_data_t)meth); +} #ifdef __cplusplus } @@ -1395,7 +1394,7 @@ SWIG_Ruby_AppendOutput(VALUE target, VALUE o) { #define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Ruby_ConvertPtrAndOwn(obj, pptr, type, flags, own) #define SWIG_NewPointerObj(ptr, type, flags) SWIG_Ruby_NewPointerObj(ptr, type, flags) #define SWIG_AcquirePtr(ptr, own) SWIG_Ruby_AcquirePtr(ptr, own) -#define swig_owntype ruby_owntype +#define swig_owntype swig_ruby_owntype /* for raw packed data */ #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) swig_class *sklass; VALUE klass; VALUE obj; - + if (!ptr) return Qnil; - + + assert(type); if (type->clientdata) { sklass = (swig_class *) type->clientdata; @@ -1563,7 +1563,7 @@ SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags) track = sklass->trackObjects; if (track) { obj = SWIG_RubyInstanceFor(ptr); - + /* Check the object's type and make sure it has the correct type. It might not in cases where methods do things like downcast methods. */ @@ -1595,7 +1595,7 @@ SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags) obj = Data_Wrap_Struct(klass, 0, 0, ptr); } rb_iv_set(obj, "@__swigtype__", rb_str_new2(type->name)); - + return obj; } @@ -1615,26 +1615,30 @@ SWIGRUNTIMEINLINE char * SWIG_Ruby_MangleStr(VALUE obj) { VALUE stype = rb_iv_get(obj, "@__swigtype__"); + if (NIL_P(stype)) + return NULL; return StringValuePtr(stype); } /* Acquire a pointer value */ -typedef void (*ruby_owntype)(void*); - -SWIGRUNTIME ruby_owntype -SWIG_Ruby_AcquirePtr(VALUE obj, ruby_owntype own) { - if (obj) { - ruby_owntype oldown = RDATA(obj)->dfree; - RDATA(obj)->dfree = own; - return oldown; - } else { - return 0; +typedef struct { + void (*datafree)(void *); + int own; +} swig_ruby_owntype; + +SWIGRUNTIME swig_ruby_owntype +SWIG_Ruby_AcquirePtr(VALUE obj, swig_ruby_owntype own) { + swig_ruby_owntype oldown = {0, 0}; + if (TYPE(obj) == T_DATA && !RTYPEDDATA_P(obj)) { + oldown.datafree = RDATA(obj)->dfree; + RDATA(obj)->dfree = own.datafree; } + return oldown; } /* Convert a pointer value */ SWIGRUNTIME int -SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, ruby_owntype *own) +SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, swig_ruby_owntype *own) { char *c; swig_cast_info *tc; @@ -1642,16 +1646,20 @@ SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, /* Grab the pointer */ if (NIL_P(obj)) { - *ptr = 0; - return SWIG_OK; + if (ptr) + *ptr = 0; + return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK; } else { - if (TYPE(obj) != T_DATA) { + if (TYPE(obj) != T_DATA || (TYPE(obj) == T_DATA && RTYPEDDATA_P(obj))) { return SWIG_ERROR; } Data_Get_Struct(obj, void, vptr); } - if (own) *own = RDATA(obj)->dfree; + if (own) { + own->datafree = RDATA(obj)->dfree; + own->own = 0; + } /* Check to see if the input object is giving up ownership 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, /* The object has already been deleted */ return SWIG_ObjectPreviouslyDeletedError; } - *ptr = vptr; - return SWIG_OK; } } if ((c = SWIG_MangleStr(obj)) == NULL) { @@ -1697,12 +1703,23 @@ SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, if (!tc) { return SWIG_ERROR; } else { - int newmemory = 0; - *ptr = SWIG_TypeCast(tc, vptr, &newmemory); - assert(!newmemory); /* newmemory handling not yet implemented */ + if (ptr) { + if (tc->type == ty) { + *ptr = vptr; + } else { + int newmemory = 0; + *ptr = SWIG_TypeCast(tc, vptr, &newmemory); + if (newmemory == SWIG_CAST_NEW_MEMORY) { + assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */ + if (own) + own->own = own->own | SWIG_CAST_NEW_MEMORY; + } + } + } } } else { - *ptr = vptr; + if (ptr) + *ptr = vptr; } return SWIG_OK; @@ -1728,7 +1745,7 @@ SWIG_Ruby_NewPackedObj(void *ptr, int sz, swig_type_info *type) { return rb_str_new2(result); } -/* Convert a packed value value */ +/* Convert a packed pointer value */ SWIGRUNTIME int SWIG_Ruby_ConvertPacked(VALUE obj, void *ptr, int sz, swig_type_info *ty) { swig_cast_info *tc; @@ -1857,7 +1874,7 @@ static VALUE mTagLib; #define SWIG_RUBY_THREAD_END_BLOCK -#define SWIGVERSION 0x030007 +#define SWIGVERSION 0x040002 #define SWIG_VERSION SWIGVERSION @@ -1870,6 +1887,7 @@ static VALUE mTagLib; #include #include +#include #include #include #include @@ -1877,6 +1895,8 @@ static VALUE mTagLib; #include #include +#include +#include #include #if defined(HAVE_RUBY_ENCODING_H) && HAVE_RUBY_ENCODING_H @@ -1946,6 +1966,28 @@ TagLib::StringList ruby_array_to_taglib_string_list(VALUE ary) { return result; } +VALUE taglib_bytevectorlist_to_ruby_array(const TagLib::ByteVectorList & list) { + VALUE ary = rb_ary_new2(list.size()); + for (TagLib::ByteVectorList::ConstIterator it = list.begin(); it != list.end(); it++) { + VALUE s = taglib_bytevector_to_ruby_string(*it); + rb_ary_push(ary, s); + } + return ary; +} + +TagLib::ByteVectorList ruby_array_to_taglib_bytevectorlist(VALUE ary) { + TagLib::ByteVectorList result = TagLib::ByteVectorList(); + if (NIL_P(ary)) { + return result; + } + for (long i = 0; i < RARRAY_LEN(ary); i++) { + VALUE e = rb_ary_entry(ary, i); + TagLib::ByteVector s = ruby_string_to_taglib_bytevector(e); + result.append(s); + } + return result; +} + VALUE taglib_filename_to_ruby_string(TagLib::FileName filename) { VALUE result; #ifdef _WIN32 @@ -2043,7 +2085,7 @@ SWIG_AsCharPtrAndSize(VALUE obj, char** cptr, size_t* psize, int *alloc) if (cptr) { if (alloc) { if (*alloc == SWIG_NEWOBJ) { - *cptr = reinterpret_cast< char* >(memcpy((new char[size]), cstr, sizeof(char)*(size))); + *cptr = reinterpret_cast< char* >(memcpy(new char[size], cstr, sizeof(char)*(size))); } else { *cptr = cstr; *alloc = SWIG_OLDOBJ; @@ -2072,15 +2114,16 @@ SWIG_AsCharPtrAndSize(VALUE obj, char** cptr, size_t* psize, int *alloc) SWIGINTERN VALUE -SWIG_ruby_failed(void) +SWIG_ruby_failed(VALUE SWIGUNUSEDPARM(arg1), VALUE SWIGUNUSEDPARM(arg2)) { return Qnil; } -/*@SWIG:/usr/local/share/swig/3.0.7/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/ -SWIGINTERN VALUE SWIG_AUX_NUM2ULONG(VALUE *args) +/*@SWIG:/usr/local/Cellar/swig/4.0.2/share/swig/4.0.2/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/ +SWIGINTERN VALUE SWIG_AUX_NUM2ULONG(VALUE arg) { + VALUE *args = (VALUE *)arg; VALUE obj = args[0]; VALUE type = TYPE(obj); unsigned long *res = (unsigned long *)(args[1]); @@ -2098,7 +2141,7 @@ SWIG_AsVal_unsigned_SS_long (VALUE obj, unsigned long *val) VALUE a[2]; a[0] = obj; a[1] = (VALUE)(&v); - if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2ULONG), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) { + if (rb_rescue(VALUEFUNC(SWIG_AUX_NUM2ULONG), (VALUE)a, VALUEFUNC(SWIG_ruby_failed), 0) != Qnil) { if (val) *val = v; return SWIG_OK; } @@ -2130,9 +2173,10 @@ SWIG_From_bool (bool value) } -/*@SWIG:/usr/local/share/swig/3.0.7/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/ -SWIGINTERN VALUE SWIG_AUX_NUM2LONG(VALUE *args) +/*@SWIG:/usr/local/Cellar/swig/4.0.2/share/swig/4.0.2/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/ +SWIGINTERN VALUE SWIG_AUX_NUM2LONG(VALUE arg) { + VALUE *args = (VALUE *)arg; VALUE obj = args[0]; VALUE type = TYPE(obj); long *res = (long *)(args[1]); @@ -2150,7 +2194,7 @@ SWIG_AsVal_long (VALUE obj, long* val) VALUE a[2]; a[0] = obj; a[1] = (VALUE)(&v); - if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2LONG), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) { + if (rb_rescue(VALUEFUNC(SWIG_AUX_NUM2LONG), (VALUE)a, VALUEFUNC(SWIG_ruby_failed), 0) != Qnil) { if (val) *val = v; return SWIG_OK; } @@ -2221,22 +2265,20 @@ SWIGINTERN void TagLib_FileRef_close(TagLib::FileRef *self){ static swig_class SwigClassString; -#ifdef HAVE_RB_DEFINE_ALLOC_FUNC SWIGINTERN VALUE -_wrap_String_allocate(VALUE self) { +#ifdef HAVE_RB_DEFINE_ALLOC_FUNC +_wrap_String_allocate(VALUE self) #else - SWIGINTERN VALUE - _wrap_String_allocate(int argc, VALUE *argv, VALUE self) { +_wrap_String_allocate(int argc, VALUE *argv, VALUE self) #endif - - - VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__String); +{ + VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__String); #ifndef HAVE_RB_DEFINE_ALLOC_FUNC - rb_obj_call_init(vresult, argc, argv); + rb_obj_call_init(vresult, argc, argv); #endif - return vresult; - } - + return vresult; +} + SWIGINTERN VALUE _wrap_new_String(int argc, VALUE *argv, VALUE self) { @@ -2255,7 +2297,8 @@ _wrap_new_String(int argc, VALUE *argv, VALUE self) { SWIGINTERN void -free_TagLib_String(TagLib::String *arg1) { +free_TagLib_String(void *self) { + TagLib::String *arg1 = (TagLib::String *)self; SWIG_RubyRemoveTracking(arg1); delete arg1; } @@ -2263,7 +2306,8 @@ free_TagLib_String(TagLib::String *arg1) { static swig_class SwigClassTag; SWIGINTERN void -free_TagLib_Tag(TagLib::Tag *arg1) { +free_TagLib_Tag(void *self) { + TagLib::Tag *arg1 = (TagLib::Tag *)self; SWIG_RubyRemoveTracking(arg1); delete arg1; } @@ -2786,7 +2830,8 @@ SWIGINTERN VALUE _wrap_Tag_duplicate(int nargs, VALUE *args, VALUE self) { static swig_class SwigClassAudioProperties; SWIGINTERN void -free_TagLib_AudioProperties(TagLib::AudioProperties *arg1) { +free_TagLib_AudioProperties(void *self) { + TagLib::AudioProperties *arg1 = (TagLib::AudioProperties *)self; SWIG_RubyRemoveTracking(arg1); delete arg1; } @@ -2914,7 +2959,8 @@ _wrap_AudioProperties_channels(int argc, VALUE *argv, VALUE self) { static swig_class SwigClassFile; SWIGINTERN void -free_TagLib_File(TagLib::File *arg1) { +free_TagLib_File(void *self) { + TagLib::File *arg1 = (TagLib::File *)self; SWIG_RubyRemoveTracking(arg1); delete arg1; } @@ -3078,7 +3124,6 @@ _wrap_File_write_block(int argc, VALUE *argv, VALUE self) { } - /* Document-method: TagLib::File.find @@ -3467,7 +3512,6 @@ SWIGINTERN VALUE _wrap_File_rfind(int nargs, VALUE *args, VALUE self) { } - /* Document-method: TagLib::File.insert @@ -4269,22 +4313,20 @@ _wrap_new_FileRef__SWIG_4(int argc, VALUE *argv, VALUE self) { } -#ifdef HAVE_RB_DEFINE_ALLOC_FUNC SWIGINTERN VALUE -_wrap_FileRef_allocate(VALUE self) { +#ifdef HAVE_RB_DEFINE_ALLOC_FUNC +_wrap_FileRef_allocate(VALUE self) #else - SWIGINTERN VALUE - _wrap_FileRef_allocate(int argc, VALUE *argv, VALUE self) { +_wrap_FileRef_allocate(int argc, VALUE *argv, VALUE self) #endif - - - VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__FileRef); +{ + VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__FileRef); #ifndef HAVE_RB_DEFINE_ALLOC_FUNC - rb_obj_call_init(vresult, argc, argv); + rb_obj_call_init(vresult, argc, argv); #endif - return vresult; - } - + return vresult; +} + SWIGINTERN VALUE _wrap_new_FileRef__SWIG_5(int argc, VALUE *argv, VALUE self) { @@ -4338,7 +4380,7 @@ SWIGINTERN VALUE _wrap_new_FileRef(int nargs, VALUE *args, VALUE self) { if (argc == 1) { int _v; void *vptr = 0; - int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_TagLib__FileRef, 0); + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_TagLib__FileRef, SWIG_POINTER_NO_NULL); _v = SWIG_CheckState(res); if (_v) { return _wrap_new_FileRef__SWIG_5(nargs, args, self); @@ -4401,7 +4443,8 @@ SWIGINTERN VALUE _wrap_new_FileRef(int nargs, VALUE *args, VALUE self) { SWIGINTERN void -free_TagLib_FileRef(TagLib::FileRef *arg1) { +free_TagLib_FileRef(void *self) { + TagLib::FileRef *arg1 = (TagLib::FileRef *)self; SWIG_RubyRemoveTracking(arg1); delete arg1; } @@ -4568,7 +4611,6 @@ _wrap_FileRef_nullq___(int argc, VALUE *argv, VALUE self) { } - /* Document-method: TagLib::FileRef.== @@ -4760,8 +4802,8 @@ SWIGINTERN VALUE _wrap_FileRef_create(int nargs, VALUE *args, VALUE self) { fail: Ruby_Format_OverloadedError( argc, 3, "FileRef.create", - " TagLib::File * FileRef.create(TagLib::FileName fileName, bool readAudioProperties, TagLib::AudioProperties::ReadStyle audioPropertiesStyle)\n" - " TagLib::File * FileRef.create(TagLib::FileName fileName, bool readAudioProperties)\n" + " TagLib::File FileRef.create(TagLib::FileName fileName, bool readAudioProperties, TagLib::AudioProperties::ReadStyle audioPropertiesStyle)\n" + " TagLib::File FileRef.create(TagLib::FileName fileName, bool readAudioProperties)\n" " TagLib::File * FileRef.create(TagLib::FileName fileName)\n"); return Qnil; @@ -4947,7 +4989,7 @@ SWIG_InitializeModule(void *clientdata) { /* Now work on filling in swig_module.types */ #ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: size %d\n", swig_module.size); + printf("SWIG_InitializeModule: size %lu\n", (unsigned long)swig_module.size); #endif for (i = 0; i < swig_module.size; ++i) { swig_type_info *type = 0; @@ -4955,7 +4997,7 @@ SWIG_InitializeModule(void *clientdata) { swig_cast_info *cast; #ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); + printf("SWIG_InitializeModule: type %lu %s\n", (unsigned long)i, swig_module.type_initial[i]->name); #endif /* if there is another module already loaded */ @@ -5031,7 +5073,7 @@ SWIG_InitializeModule(void *clientdata) { for (i = 0; i < swig_module.size; ++i) { int j = 0; swig_cast_info *cast = swig_module.cast_initial[i]; - printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); + printf("SWIG_InitializeModule: type %lu %s\n", (unsigned long)i, swig_module.type_initial[i]->name); while (cast->type) { printf("SWIG_InitializeModule: cast type %s\n", cast->type->name); cast++; diff --git a/ext/taglib_flac/taglib_flac_wrap.cxx b/ext/taglib_flac/taglib_flac_wrap.cxx index b3a41b2..47b5b68 100644 --- a/ext/taglib_flac/taglib_flac_wrap.cxx +++ b/ext/taglib_flac/taglib_flac_wrap.cxx @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 3.0.7 + * Version 4.0.2 * * This file is not intended to be easily readable and contains a number of * coding conventions designed to improve portability and efficiency. Do not make @@ -11,7 +11,11 @@ static void free_taglib_flac_file(void *ptr); + +#ifndef SWIGRUBY #define SWIGRUBY +#endif + #ifdef __cplusplus @@ -104,9 +108,11 @@ template T SwigValueInit() { #endif /* exporting methods */ -#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) -# ifndef GCC_HASCLASSVISIBILITY -# define GCC_HASCLASSVISIBILITY +#if defined(__GNUC__) +# if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +# ifndef GCC_HASCLASSVISIBILITY +# define GCC_HASCLASSVISIBILITY +# endif # endif #endif @@ -226,9 +232,11 @@ template T SwigValueInit() { #endif /* exporting methods */ -#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) -# ifndef GCC_HASCLASSVISIBILITY -# define GCC_HASCLASSVISIBILITY +#if defined(__GNUC__) +# if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +# ifndef GCC_HASCLASSVISIBILITY +# define GCC_HASCLASSVISIBILITY +# endif # endif #endif @@ -326,6 +334,7 @@ template T SwigValueInit() { /* Flags for pointer conversions */ #define SWIG_POINTER_DISOWN 0x1 #define SWIG_CAST_NEW_MEMORY 0x2 +#define SWIG_POINTER_NO_NULL 0x4 /* Flags for new pointer objects */ #define SWIG_POINTER_OWN 0x1 @@ -778,16 +787,16 @@ SWIG_UnpackData(const char *c, void *ptr, size_t sz) { char d = *(c++); unsigned char uu; if ((d >= '0') && (d <= '9')) - uu = ((d - '0') << 4); + uu = (unsigned char)((d - '0') << 4); else if ((d >= 'a') && (d <= 'f')) - uu = ((d - ('a'-10)) << 4); + uu = (unsigned char)((d - ('a'-10)) << 4); else return (char *) 0; d = *(c++); if ((d >= '0') && (d <= '9')) - uu |= (d - '0'); + uu |= (unsigned char)(d - '0'); else if ((d >= 'a') && (d <= 'f')) - uu |= (d - ('a'-10)); + uu |= (unsigned char)(d - ('a'-10)); else return (char *) 0; *u = uu; @@ -964,42 +973,53 @@ SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { #ifndef RSTRUCT_PTR # define RSTRUCT_PTR(x) RSTRUCT(x)->ptr #endif +#ifndef RTYPEDDATA_P +# define RTYPEDDATA_P(x) (TYPE(x) != T_DATA) +#endif /* - * Need to be very careful about how these macros are defined, especially - * when compiling C++ code or C code with an ANSI C compiler. + * The following macros are used for providing the correct type of a + * function pointer to the Ruby C API. + * Starting with Ruby 2.7 (corresponding to RB_METHOD_DEFINITION_DECL being + * defined) these macros act transparently due to Ruby's moving away from + * ANYARGS and instead employing strict function signatures. + * + * Note: In case of C (not C++) the macros are transparent even before + * Ruby 2.7 due to the fact that the Ruby C API used function declarators + * with empty parentheses, which allows for an unspecified number of + * arguments. * - * VALUEFUNC(f) is a macro used to typecast a C function that implements - * a Ruby method so that it can be passed as an argument to API functions - * like rb_define_method() and rb_define_singleton_method(). + * PROTECTFUNC(f) is used for the function pointer argument of the Ruby + * C API function rb_protect(). * - * VOIDFUNC(f) is a macro used to typecast a C function that implements - * either the "mark" or "free" stuff for a Ruby Data object, so that it - * can be passed as an argument to API functions like Data_Wrap_Struct() + * VALUEFUNC(f) is used for the function pointer argument(s) of Ruby C API + * functions like rb_define_method() and rb_define_singleton_method(). + * + * VOIDFUNC(f) is used to typecast a C function that implements either + * the "mark" or "free" stuff for a Ruby Data object, so that it can be + * passed as an argument to Ruby C API functions like Data_Wrap_Struct() * and Data_Make_Struct(). + * + * SWIG_RUBY_VOID_ANYARGS_FUNC(f) is used for the function pointer + * argument(s) of Ruby C API functions like rb_define_virtual_variable(). + * + * SWIG_RUBY_INT_ANYARGS_FUNC(f) is used for the function pointer + * argument(s) of Ruby C API functions like st_foreach(). */ - -#ifdef __cplusplus -# ifndef RUBY_METHOD_FUNC /* These definitions should work for Ruby 1.4.6 */ -# define PROTECTFUNC(f) ((VALUE (*)()) f) -# define VALUEFUNC(f) ((VALUE (*)()) f) -# define VOIDFUNC(f) ((void (*)()) f) -# else -# ifndef ANYARGS /* These definitions should work for Ruby 1.6 */ -# define PROTECTFUNC(f) ((VALUE (*)()) f) -# define VALUEFUNC(f) ((VALUE (*)()) f) -# define VOIDFUNC(f) ((RUBY_DATA_FUNC) f) -# else /* These definitions should work for Ruby 1.7+ */ -# define PROTECTFUNC(f) ((VALUE (*)(VALUE)) f) -# define VALUEFUNC(f) ((VALUE (*)(ANYARGS)) f) -# define VOIDFUNC(f) ((RUBY_DATA_FUNC) f) -# endif -# endif +#if defined(__cplusplus) && !defined(RB_METHOD_DEFINITION_DECL) +# define PROTECTFUNC(f) ((VALUE (*)(VALUE)) f) +# define VALUEFUNC(f) ((VALUE (*)(ANYARGS)) f) +# define VOIDFUNC(f) ((RUBY_DATA_FUNC) f) +# define SWIG_RUBY_VOID_ANYARGS_FUNC(f) ((void (*)(ANYARGS))(f)) +# define SWIG_RUBY_INT_ANYARGS_FUNC(f) ((int (*)(ANYARGS))(f)) #else +# define PROTECTFUNC(f) (f) # define VALUEFUNC(f) (f) # define VOIDFUNC(f) (f) +# define SWIG_RUBY_VOID_ANYARGS_FUNC(f) (f) +# define SWIG_RUBY_INT_ANYARGS_FUNC(f) (f) #endif /* Don't use for expressions have side effect */ @@ -1187,7 +1207,7 @@ void Ruby_Format_OverloadedError( /* ----------------------------------------------------------------------------- * rubytracking.swg * - * This file contains support for tracking mappings from + * This file contains support for tracking mappings from * Ruby objects to C++ objects. This functionality is needed * to implement mark functions for Ruby's mark and sweep * garbage collector. @@ -1197,6 +1217,11 @@ void Ruby_Format_OverloadedError( extern "C" { #endif +#if !defined(ST_DATA_T_DEFINED) +/* Needs to be explicitly included for Ruby 1.8 and earlier */ +#include +#endif + /* Ruby 1.8 actually assumes the first case. */ #if SIZEOF_VOIDP == SIZEOF_LONG # define SWIG2NUM(v) LONG2NUM((unsigned long)v) @@ -1208,109 +1233,69 @@ extern "C" { # error sizeof(void*) is not the same as long or long long #endif - -/* Global Ruby hash table to store Trackings from C/C++ - structs to Ruby Objects. +/* Global hash table to store Trackings from C/C++ + structs to Ruby Objects. */ -static VALUE swig_ruby_trackings = Qnil; +static st_table* swig_ruby_trackings = NULL; + +static VALUE swig_ruby_trackings_count(ID id, VALUE *var) { + return SWIG2NUM(swig_ruby_trackings->num_entries); +} -/* Global variable that stores a reference to the ruby - hash table delete function. */ -static ID swig_ruby_hash_delete; -/* Setup a Ruby hash table to store Trackings */ +/* Setup a hash table to store Trackings */ SWIGRUNTIME void SWIG_RubyInitializeTrackings(void) { - /* Create a ruby hash table to store Trackings from C++ + /* Create a hash table to store Trackings from C++ objects to Ruby objects. */ - /* Try to see if some other .so has already created a + /* Try to see if some other .so has already created a tracking hash table, which we keep hidden in an instance var in the SWIG module. This is done to allow multiple DSOs to share the same tracking table. */ - ID trackings_id = rb_intern( "@__trackings__" ); + VALUE trackings_value = Qnil; + /* change the variable name so that we can mix modules + compiled with older SWIG's - this used to be called "@__trackings__" */ + ID trackings_id = rb_intern( "@__safetrackings__" ); VALUE verbose = rb_gv_get("VERBOSE"); rb_gv_set("VERBOSE", Qfalse); - swig_ruby_trackings = rb_ivar_get( _mSWIG, trackings_id ); + trackings_value = rb_ivar_get( _mSWIG, trackings_id ); rb_gv_set("VERBOSE", verbose); - /* No, it hasn't. Create one ourselves */ - if ( swig_ruby_trackings == Qnil ) - { - swig_ruby_trackings = rb_hash_new(); - rb_ivar_set( _mSWIG, trackings_id, swig_ruby_trackings ); - } - - /* Now store a reference to the hash table delete function - so that we only have to look it up once.*/ - swig_ruby_hash_delete = rb_intern("delete"); -} - -/* Get a Ruby number to reference a pointer */ -SWIGRUNTIME VALUE SWIG_RubyPtrToReference(void* ptr) { - /* We cast the pointer to an unsigned long - and then store a reference to it using - a Ruby number object. */ - - /* Convert the pointer to a Ruby number */ - return SWIG2NUM(ptr); -} - -/* Get a Ruby number to reference an object */ -SWIGRUNTIME VALUE SWIG_RubyObjectToReference(VALUE object) { - /* We cast the object to an unsigned long - and then store a reference to it using - a Ruby number object. */ - - /* Convert the Object to a Ruby number */ - return SWIG2NUM(object); -} - -/* Get a Ruby object from a previously stored reference */ -SWIGRUNTIME VALUE SWIG_RubyReferenceToObject(VALUE reference) { - /* The provided Ruby number object is a reference - to the Ruby object we want.*/ + /* The trick here is that we have to store the hash table + pointer in a Ruby variable. We do not want Ruby's GC to + treat this pointer as a Ruby object, so we convert it to + a Ruby numeric value. */ + if (trackings_value == Qnil) { + /* No, it hasn't. Create one ourselves */ + swig_ruby_trackings = st_init_numtable(); + rb_ivar_set( _mSWIG, trackings_id, SWIG2NUM(swig_ruby_trackings) ); + } else { + swig_ruby_trackings = (st_table*)NUM2SWIG(trackings_value); + } - /* Convert the Ruby number to a Ruby object */ - return NUM2SWIG(reference); + rb_define_virtual_variable("SWIG_TRACKINGS_COUNT", + VALUEFUNC(swig_ruby_trackings_count), + SWIG_RUBY_VOID_ANYARGS_FUNC((rb_gvar_setter_t*)NULL)); } /* Add a Tracking from a C/C++ struct to a Ruby object */ SWIGRUNTIME void SWIG_RubyAddTracking(void* ptr, VALUE object) { - /* In a Ruby hash table we store the pointer and - the associated Ruby object. The trick here is - that we cannot store the Ruby object directly - if - we do then it cannot be garbage collected. So - instead we typecast it as a unsigned long and - convert it to a Ruby number object.*/ - - /* Get a reference to the pointer as a Ruby number */ - VALUE key = SWIG_RubyPtrToReference(ptr); - - /* Get a reference to the Ruby object as a Ruby number */ - VALUE value = SWIG_RubyObjectToReference(object); - /* Store the mapping to the global hash table. */ - rb_hash_aset(swig_ruby_trackings, key, value); + st_insert(swig_ruby_trackings, (st_data_t)ptr, object); } /* Get the Ruby object that owns the specified C/C++ struct */ SWIGRUNTIME VALUE SWIG_RubyInstanceFor(void* ptr) { - /* Get a reference to the pointer as a Ruby number */ - VALUE key = SWIG_RubyPtrToReference(ptr); - /* Now lookup the value stored in the global hash table */ - VALUE value = rb_hash_aref(swig_ruby_trackings, key); - - if (value == Qnil) { - /* No object exists - return nil. */ + VALUE value; + + if (st_lookup(swig_ruby_trackings, (st_data_t)ptr, &value)) { + return value; + } else { return Qnil; } - else { - /* Convert this value to Ruby object */ - return SWIG_RubyReferenceToObject(value); - } } /* Remove a Tracking from a C/C++ struct to a Ruby object. It @@ -1318,25 +1303,39 @@ SWIGRUNTIME VALUE SWIG_RubyInstanceFor(void* ptr) { since the same memory address may be reused later to create a new object. */ SWIGRUNTIME void SWIG_RubyRemoveTracking(void* ptr) { - /* Get a reference to the pointer as a Ruby number */ - VALUE key = SWIG_RubyPtrToReference(ptr); - - /* Delete the object from the hash table by calling Ruby's - do this we need to call the Hash.delete method.*/ - rb_funcall(swig_ruby_trackings, swig_ruby_hash_delete, 1, key); + /* Delete the object from the hash table */ + st_delete(swig_ruby_trackings, (st_data_t *)&ptr, NULL); } /* This is a helper method that unlinks a Ruby object from its underlying C++ object. This is needed if the lifetime of the - Ruby object is longer than the C++ object */ + Ruby object is longer than the C++ object. */ SWIGRUNTIME void SWIG_RubyUnlinkObjects(void* ptr) { VALUE object = SWIG_RubyInstanceFor(ptr); if (object != Qnil) { + // object might have the T_ZOMBIE type, but that's just + // because the GC has flagged it as such for a deferred + // destruction. Until then, it's still a T_DATA object. DATA_PTR(object) = 0; } } +/* This is a helper method that iterates over all the trackings + passing the C++ object pointer and its related Ruby object + to the passed callback function. */ + +/* Proxy method to abstract the internal trackings datatype */ +static int swig_ruby_internal_iterate_callback(st_data_t ptr, st_data_t obj, st_data_t meth) { + ((void (*) (void *, VALUE))meth)((void *)ptr, (VALUE)obj); + return ST_CONTINUE; +} + +SWIGRUNTIME void SWIG_RubyIterateTrackings( void(*meth)(void* ptr, VALUE obj) ) { + st_foreach(swig_ruby_trackings, + SWIG_RUBY_INT_ANYARGS_FUNC(swig_ruby_internal_iterate_callback), + (st_data_t)meth); +} #ifdef __cplusplus } @@ -1395,7 +1394,7 @@ SWIG_Ruby_AppendOutput(VALUE target, VALUE o) { #define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Ruby_ConvertPtrAndOwn(obj, pptr, type, flags, own) #define SWIG_NewPointerObj(ptr, type, flags) SWIG_Ruby_NewPointerObj(ptr, type, flags) #define SWIG_AcquirePtr(ptr, own) SWIG_Ruby_AcquirePtr(ptr, own) -#define swig_owntype ruby_owntype +#define swig_owntype swig_ruby_owntype /* for raw packed data */ #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) swig_class *sklass; VALUE klass; VALUE obj; - + if (!ptr) return Qnil; - + + assert(type); if (type->clientdata) { sklass = (swig_class *) type->clientdata; @@ -1563,7 +1563,7 @@ SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags) track = sklass->trackObjects; if (track) { obj = SWIG_RubyInstanceFor(ptr); - + /* Check the object's type and make sure it has the correct type. It might not in cases where methods do things like downcast methods. */ @@ -1595,7 +1595,7 @@ SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags) obj = Data_Wrap_Struct(klass, 0, 0, ptr); } rb_iv_set(obj, "@__swigtype__", rb_str_new2(type->name)); - + return obj; } @@ -1615,26 +1615,30 @@ SWIGRUNTIMEINLINE char * SWIG_Ruby_MangleStr(VALUE obj) { VALUE stype = rb_iv_get(obj, "@__swigtype__"); + if (NIL_P(stype)) + return NULL; return StringValuePtr(stype); } /* Acquire a pointer value */ -typedef void (*ruby_owntype)(void*); - -SWIGRUNTIME ruby_owntype -SWIG_Ruby_AcquirePtr(VALUE obj, ruby_owntype own) { - if (obj) { - ruby_owntype oldown = RDATA(obj)->dfree; - RDATA(obj)->dfree = own; - return oldown; - } else { - return 0; - } +typedef struct { + void (*datafree)(void *); + int own; +} swig_ruby_owntype; + +SWIGRUNTIME swig_ruby_owntype +SWIG_Ruby_AcquirePtr(VALUE obj, swig_ruby_owntype own) { + swig_ruby_owntype oldown = {0, 0}; + if (TYPE(obj) == T_DATA && !RTYPEDDATA_P(obj)) { + oldown.datafree = RDATA(obj)->dfree; + RDATA(obj)->dfree = own.datafree; + } + return oldown; } /* Convert a pointer value */ SWIGRUNTIME int -SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, ruby_owntype *own) +SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, swig_ruby_owntype *own) { char *c; swig_cast_info *tc; @@ -1642,16 +1646,20 @@ SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, /* Grab the pointer */ if (NIL_P(obj)) { - *ptr = 0; - return SWIG_OK; + if (ptr) + *ptr = 0; + return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK; } else { - if (TYPE(obj) != T_DATA) { + if (TYPE(obj) != T_DATA || (TYPE(obj) == T_DATA && RTYPEDDATA_P(obj))) { return SWIG_ERROR; } Data_Get_Struct(obj, void, vptr); } - if (own) *own = RDATA(obj)->dfree; + if (own) { + own->datafree = RDATA(obj)->dfree; + own->own = 0; + } /* Check to see if the input object is giving up ownership 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, /* The object has already been deleted */ return SWIG_ObjectPreviouslyDeletedError; } - *ptr = vptr; - return SWIG_OK; } } if ((c = SWIG_MangleStr(obj)) == NULL) { @@ -1697,12 +1703,23 @@ SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, if (!tc) { return SWIG_ERROR; } else { - int newmemory = 0; - *ptr = SWIG_TypeCast(tc, vptr, &newmemory); - assert(!newmemory); /* newmemory handling not yet implemented */ + if (ptr) { + if (tc->type == ty) { + *ptr = vptr; + } else { + int newmemory = 0; + *ptr = SWIG_TypeCast(tc, vptr, &newmemory); + if (newmemory == SWIG_CAST_NEW_MEMORY) { + assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */ + if (own) + own->own = own->own | SWIG_CAST_NEW_MEMORY; + } + } + } } } else { - *ptr = vptr; + if (ptr) + *ptr = vptr; } return SWIG_OK; @@ -1728,7 +1745,7 @@ SWIG_Ruby_NewPackedObj(void *ptr, int sz, swig_type_info *type) { return rb_str_new2(result); } -/* Convert a packed value value */ +/* Convert a packed pointer value */ SWIGRUNTIME int SWIG_Ruby_ConvertPacked(VALUE obj, void *ptr, int sz, swig_type_info *ty) { swig_cast_info *tc; @@ -1863,7 +1880,7 @@ static VALUE mFLAC; #define SWIG_RUBY_THREAD_END_BLOCK -#define SWIGVERSION 0x030007 +#define SWIGVERSION 0x040002 #define SWIG_VERSION SWIGVERSION @@ -1883,6 +1900,8 @@ static VALUE mFLAC; #include #include +#include +#include #include #if defined(HAVE_RUBY_ENCODING_H) && HAVE_RUBY_ENCODING_H @@ -1952,6 +1971,28 @@ TagLib::StringList ruby_array_to_taglib_string_list(VALUE ary) { return result; } +VALUE taglib_bytevectorlist_to_ruby_array(const TagLib::ByteVectorList & list) { + VALUE ary = rb_ary_new2(list.size()); + for (TagLib::ByteVectorList::ConstIterator it = list.begin(); it != list.end(); it++) { + VALUE s = taglib_bytevector_to_ruby_string(*it); + rb_ary_push(ary, s); + } + return ary; +} + +TagLib::ByteVectorList ruby_array_to_taglib_bytevectorlist(VALUE ary) { + TagLib::ByteVectorList result = TagLib::ByteVectorList(); + if (NIL_P(ary)) { + return result; + } + for (long i = 0; i < RARRAY_LEN(ary); i++) { + VALUE e = rb_ary_entry(ary, i); + TagLib::ByteVector s = ruby_string_to_taglib_bytevector(e); + result.append(s); + } + return result; +} + VALUE taglib_filename_to_ruby_string(TagLib::FileName filename) { VALUE result; #ifdef _WIN32 @@ -2005,15 +2046,16 @@ VALUE taglib_flac_picturelist_to_ruby_array(const TagLib::List(memcpy((new char[size]), cstr, sizeof(char)*(size))); + *cptr = reinterpret_cast< char* >(memcpy(new char[size], cstr, sizeof(char)*(size))); } else { *cptr = cstr; *alloc = SWIG_OLDOBJ; @@ -2341,22 +2383,20 @@ _wrap_new_Properties__SWIG_2(int argc, VALUE *argv, VALUE self) { } -#ifdef HAVE_RB_DEFINE_ALLOC_FUNC SWIGINTERN VALUE -_wrap_Properties_allocate(VALUE self) { +#ifdef HAVE_RB_DEFINE_ALLOC_FUNC +_wrap_Properties_allocate(VALUE self) #else - SWIGINTERN VALUE - _wrap_Properties_allocate(int argc, VALUE *argv, VALUE self) { +_wrap_Properties_allocate(int argc, VALUE *argv, VALUE self) #endif - - - VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__FLAC__Properties); +{ + VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__FLAC__Properties); #ifndef HAVE_RB_DEFINE_ALLOC_FUNC - rb_obj_call_init(vresult, argc, argv); + rb_obj_call_init(vresult, argc, argv); #endif - return vresult; - } - + return vresult; +} + SWIGINTERN VALUE _wrap_new_Properties__SWIG_3(int argc, VALUE *argv, VALUE self) { @@ -2419,7 +2459,7 @@ SWIGINTERN VALUE _wrap_new_Properties(int nargs, VALUE *args, VALUE self) { if (argc == 2) { int _v; void *vptr = 0; - int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_TagLib__ByteVector, 0); + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_TagLib__ByteVector, SWIG_POINTER_NO_NULL); _v = SWIG_CheckState(res); if (_v) { { @@ -2434,7 +2474,7 @@ SWIGINTERN VALUE _wrap_new_Properties(int nargs, VALUE *args, VALUE self) { if (argc == 3) { int _v; void *vptr = 0; - int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_TagLib__ByteVector, 0); + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_TagLib__ByteVector, SWIG_POINTER_NO_NULL); _v = SWIG_CheckState(res); if (_v) { { @@ -2465,7 +2505,8 @@ SWIGINTERN VALUE _wrap_new_Properties(int nargs, VALUE *args, VALUE self) { SWIGINTERN void -free_TagLib_FLAC_Properties(TagLib::FLAC::Properties *arg1) { +free_TagLib_FLAC_Properties(void *self) { + TagLib::FLAC::Properties *arg1 = (TagLib::FLAC::Properties *)self; SWIG_RubyRemoveTracking(arg1); delete arg1; } @@ -2845,22 +2886,20 @@ _wrap_new_File__SWIG_4(int argc, VALUE *argv, VALUE self) { } -#ifdef HAVE_RB_DEFINE_ALLOC_FUNC SWIGINTERN VALUE -_wrap_File_allocate(VALUE self) { +#ifdef HAVE_RB_DEFINE_ALLOC_FUNC +_wrap_File_allocate(VALUE self) #else - SWIGINTERN VALUE - _wrap_File_allocate(int argc, VALUE *argv, VALUE self) { +_wrap_File_allocate(int argc, VALUE *argv, VALUE self) #endif - - - VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__FLAC__File); +{ + VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__FLAC__File); #ifndef HAVE_RB_DEFINE_ALLOC_FUNC - rb_obj_call_init(vresult, argc, argv); + rb_obj_call_init(vresult, argc, argv); #endif - return vresult; - } - + return vresult; +} + SWIGINTERN VALUE _wrap_new_File__SWIG_5(int argc, VALUE *argv, VALUE self) { @@ -3182,7 +3221,7 @@ SWIGINTERN VALUE _wrap_File_id3v2_tag(int nargs, VALUE *args, VALUE self) { fail: Ruby_Format_OverloadedError( argc, 3, "File.id3v2_tag", - " TagLib::ID3v2::Tag * File.id3v2_tag(bool create)\n" + " TagLib::ID3v2::Tag File.id3v2_tag(bool create)\n" " TagLib::ID3v2::Tag * File.id3v2_tag()\n"); return Qnil; @@ -3283,7 +3322,7 @@ SWIGINTERN VALUE _wrap_File_id3v1_tag(int nargs, VALUE *args, VALUE self) { fail: Ruby_Format_OverloadedError( argc, 3, "File.id3v1_tag", - " TagLib::ID3v1::Tag * File.id3v1_tag(bool create)\n" + " TagLib::ID3v1::Tag File.id3v1_tag(bool create)\n" " TagLib::ID3v1::Tag * File.id3v1_tag()\n"); return Qnil; @@ -3384,7 +3423,7 @@ SWIGINTERN VALUE _wrap_File_xiph_comment(int nargs, VALUE *args, VALUE self) { fail: Ruby_Format_OverloadedError( argc, 3, "File.xiph_comment", - " TagLib::Ogg::XiphComment * File.xiph_comment(bool create)\n" + " TagLib::Ogg::XiphComment File.xiph_comment(bool create)\n" " TagLib::Ogg::XiphComment * File.xiph_comment()\n"); return Qnil; @@ -3951,7 +3990,7 @@ SWIG_InitializeModule(void *clientdata) { /* Now work on filling in swig_module.types */ #ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: size %d\n", swig_module.size); + printf("SWIG_InitializeModule: size %lu\n", (unsigned long)swig_module.size); #endif for (i = 0; i < swig_module.size; ++i) { swig_type_info *type = 0; @@ -3959,7 +3998,7 @@ SWIG_InitializeModule(void *clientdata) { swig_cast_info *cast; #ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); + printf("SWIG_InitializeModule: type %lu %s\n", (unsigned long)i, swig_module.type_initial[i]->name); #endif /* if there is another module already loaded */ @@ -4035,7 +4074,7 @@ SWIG_InitializeModule(void *clientdata) { for (i = 0; i < swig_module.size; ++i) { int j = 0; swig_cast_info *cast = swig_module.cast_initial[i]; - printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); + printf("SWIG_InitializeModule: type %lu %s\n", (unsigned long)i, swig_module.type_initial[i]->name); while (cast->type) { printf("SWIG_InitializeModule: cast type %s\n", cast->type->name); cast++; diff --git a/ext/taglib_flac_picture/taglib_flac_picture_wrap.cxx b/ext/taglib_flac_picture/taglib_flac_picture_wrap.cxx index 946918a..a7478e2 100644 --- a/ext/taglib_flac_picture/taglib_flac_picture_wrap.cxx +++ b/ext/taglib_flac_picture/taglib_flac_picture_wrap.cxx @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 3.0.7 + * Version 4.0.2 * * This file is not intended to be easily readable and contains a number of * coding conventions designed to improve portability and efficiency. Do not make @@ -8,7 +8,11 @@ * interface file instead. * ----------------------------------------------------------------------------- */ + +#ifndef SWIGRUBY #define SWIGRUBY +#endif + #ifdef __cplusplus @@ -101,9 +105,11 @@ template T SwigValueInit() { #endif /* exporting methods */ -#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) -# ifndef GCC_HASCLASSVISIBILITY -# define GCC_HASCLASSVISIBILITY +#if defined(__GNUC__) +# if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +# ifndef GCC_HASCLASSVISIBILITY +# define GCC_HASCLASSVISIBILITY +# endif # endif #endif @@ -223,9 +229,11 @@ template T SwigValueInit() { #endif /* exporting methods */ -#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) -# ifndef GCC_HASCLASSVISIBILITY -# define GCC_HASCLASSVISIBILITY +#if defined(__GNUC__) +# if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +# ifndef GCC_HASCLASSVISIBILITY +# define GCC_HASCLASSVISIBILITY +# endif # endif #endif @@ -323,6 +331,7 @@ template T SwigValueInit() { /* Flags for pointer conversions */ #define SWIG_POINTER_DISOWN 0x1 #define SWIG_CAST_NEW_MEMORY 0x2 +#define SWIG_POINTER_NO_NULL 0x4 /* Flags for new pointer objects */ #define SWIG_POINTER_OWN 0x1 @@ -775,16 +784,16 @@ SWIG_UnpackData(const char *c, void *ptr, size_t sz) { char d = *(c++); unsigned char uu; if ((d >= '0') && (d <= '9')) - uu = ((d - '0') << 4); + uu = (unsigned char)((d - '0') << 4); else if ((d >= 'a') && (d <= 'f')) - uu = ((d - ('a'-10)) << 4); + uu = (unsigned char)((d - ('a'-10)) << 4); else return (char *) 0; d = *(c++); if ((d >= '0') && (d <= '9')) - uu |= (d - '0'); + uu |= (unsigned char)(d - '0'); else if ((d >= 'a') && (d <= 'f')) - uu |= (d - ('a'-10)); + uu |= (unsigned char)(d - ('a'-10)); else return (char *) 0; *u = uu; @@ -961,42 +970,53 @@ SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { #ifndef RSTRUCT_PTR # define RSTRUCT_PTR(x) RSTRUCT(x)->ptr #endif +#ifndef RTYPEDDATA_P +# define RTYPEDDATA_P(x) (TYPE(x) != T_DATA) +#endif /* - * Need to be very careful about how these macros are defined, especially - * when compiling C++ code or C code with an ANSI C compiler. + * The following macros are used for providing the correct type of a + * function pointer to the Ruby C API. + * Starting with Ruby 2.7 (corresponding to RB_METHOD_DEFINITION_DECL being + * defined) these macros act transparently due to Ruby's moving away from + * ANYARGS and instead employing strict function signatures. * - * VALUEFUNC(f) is a macro used to typecast a C function that implements - * a Ruby method so that it can be passed as an argument to API functions - * like rb_define_method() and rb_define_singleton_method(). + * Note: In case of C (not C++) the macros are transparent even before + * Ruby 2.7 due to the fact that the Ruby C API used function declarators + * with empty parentheses, which allows for an unspecified number of + * arguments. * - * VOIDFUNC(f) is a macro used to typecast a C function that implements - * either the "mark" or "free" stuff for a Ruby Data object, so that it - * can be passed as an argument to API functions like Data_Wrap_Struct() + * PROTECTFUNC(f) is used for the function pointer argument of the Ruby + * C API function rb_protect(). + * + * VALUEFUNC(f) is used for the function pointer argument(s) of Ruby C API + * functions like rb_define_method() and rb_define_singleton_method(). + * + * VOIDFUNC(f) is used to typecast a C function that implements either + * the "mark" or "free" stuff for a Ruby Data object, so that it can be + * passed as an argument to Ruby C API functions like Data_Wrap_Struct() * and Data_Make_Struct(). + * + * SWIG_RUBY_VOID_ANYARGS_FUNC(f) is used for the function pointer + * argument(s) of Ruby C API functions like rb_define_virtual_variable(). + * + * SWIG_RUBY_INT_ANYARGS_FUNC(f) is used for the function pointer + * argument(s) of Ruby C API functions like st_foreach(). */ - -#ifdef __cplusplus -# ifndef RUBY_METHOD_FUNC /* These definitions should work for Ruby 1.4.6 */ -# define PROTECTFUNC(f) ((VALUE (*)()) f) -# define VALUEFUNC(f) ((VALUE (*)()) f) -# define VOIDFUNC(f) ((void (*)()) f) -# else -# ifndef ANYARGS /* These definitions should work for Ruby 1.6 */ -# define PROTECTFUNC(f) ((VALUE (*)()) f) -# define VALUEFUNC(f) ((VALUE (*)()) f) -# define VOIDFUNC(f) ((RUBY_DATA_FUNC) f) -# else /* These definitions should work for Ruby 1.7+ */ -# define PROTECTFUNC(f) ((VALUE (*)(VALUE)) f) -# define VALUEFUNC(f) ((VALUE (*)(ANYARGS)) f) -# define VOIDFUNC(f) ((RUBY_DATA_FUNC) f) -# endif -# endif +#if defined(__cplusplus) && !defined(RB_METHOD_DEFINITION_DECL) +# define PROTECTFUNC(f) ((VALUE (*)(VALUE)) f) +# define VALUEFUNC(f) ((VALUE (*)(ANYARGS)) f) +# define VOIDFUNC(f) ((RUBY_DATA_FUNC) f) +# define SWIG_RUBY_VOID_ANYARGS_FUNC(f) ((void (*)(ANYARGS))(f)) +# define SWIG_RUBY_INT_ANYARGS_FUNC(f) ((int (*)(ANYARGS))(f)) #else +# define PROTECTFUNC(f) (f) # define VALUEFUNC(f) (f) # define VOIDFUNC(f) (f) +# define SWIG_RUBY_VOID_ANYARGS_FUNC(f) (f) +# define SWIG_RUBY_INT_ANYARGS_FUNC(f) (f) #endif /* Don't use for expressions have side effect */ @@ -1184,7 +1204,7 @@ void Ruby_Format_OverloadedError( /* ----------------------------------------------------------------------------- * rubytracking.swg * - * This file contains support for tracking mappings from + * This file contains support for tracking mappings from * Ruby objects to C++ objects. This functionality is needed * to implement mark functions for Ruby's mark and sweep * garbage collector. @@ -1194,6 +1214,11 @@ void Ruby_Format_OverloadedError( extern "C" { #endif +#if !defined(ST_DATA_T_DEFINED) +/* Needs to be explicitly included for Ruby 1.8 and earlier */ +#include +#endif + /* Ruby 1.8 actually assumes the first case. */ #if SIZEOF_VOIDP == SIZEOF_LONG # define SWIG2NUM(v) LONG2NUM((unsigned long)v) @@ -1205,109 +1230,69 @@ extern "C" { # error sizeof(void*) is not the same as long or long long #endif - -/* Global Ruby hash table to store Trackings from C/C++ - structs to Ruby Objects. +/* Global hash table to store Trackings from C/C++ + structs to Ruby Objects. */ -static VALUE swig_ruby_trackings = Qnil; +static st_table* swig_ruby_trackings = NULL; -/* Global variable that stores a reference to the ruby - hash table delete function. */ -static ID swig_ruby_hash_delete; +static VALUE swig_ruby_trackings_count(ID id, VALUE *var) { + return SWIG2NUM(swig_ruby_trackings->num_entries); +} -/* Setup a Ruby hash table to store Trackings */ + +/* Setup a hash table to store Trackings */ SWIGRUNTIME void SWIG_RubyInitializeTrackings(void) { - /* Create a ruby hash table to store Trackings from C++ + /* Create a hash table to store Trackings from C++ objects to Ruby objects. */ - /* Try to see if some other .so has already created a + /* Try to see if some other .so has already created a tracking hash table, which we keep hidden in an instance var in the SWIG module. This is done to allow multiple DSOs to share the same tracking table. */ - ID trackings_id = rb_intern( "@__trackings__" ); + VALUE trackings_value = Qnil; + /* change the variable name so that we can mix modules + compiled with older SWIG's - this used to be called "@__trackings__" */ + ID trackings_id = rb_intern( "@__safetrackings__" ); VALUE verbose = rb_gv_get("VERBOSE"); rb_gv_set("VERBOSE", Qfalse); - swig_ruby_trackings = rb_ivar_get( _mSWIG, trackings_id ); + trackings_value = rb_ivar_get( _mSWIG, trackings_id ); rb_gv_set("VERBOSE", verbose); - /* No, it hasn't. Create one ourselves */ - if ( swig_ruby_trackings == Qnil ) - { - swig_ruby_trackings = rb_hash_new(); - rb_ivar_set( _mSWIG, trackings_id, swig_ruby_trackings ); - } - - /* Now store a reference to the hash table delete function - so that we only have to look it up once.*/ - swig_ruby_hash_delete = rb_intern("delete"); -} - -/* Get a Ruby number to reference a pointer */ -SWIGRUNTIME VALUE SWIG_RubyPtrToReference(void* ptr) { - /* We cast the pointer to an unsigned long - and then store a reference to it using - a Ruby number object. */ - - /* Convert the pointer to a Ruby number */ - return SWIG2NUM(ptr); -} - -/* Get a Ruby number to reference an object */ -SWIGRUNTIME VALUE SWIG_RubyObjectToReference(VALUE object) { - /* We cast the object to an unsigned long - and then store a reference to it using - a Ruby number object. */ - - /* Convert the Object to a Ruby number */ - return SWIG2NUM(object); -} - -/* Get a Ruby object from a previously stored reference */ -SWIGRUNTIME VALUE SWIG_RubyReferenceToObject(VALUE reference) { - /* The provided Ruby number object is a reference - to the Ruby object we want.*/ + /* The trick here is that we have to store the hash table + pointer in a Ruby variable. We do not want Ruby's GC to + treat this pointer as a Ruby object, so we convert it to + a Ruby numeric value. */ + if (trackings_value == Qnil) { + /* No, it hasn't. Create one ourselves */ + swig_ruby_trackings = st_init_numtable(); + rb_ivar_set( _mSWIG, trackings_id, SWIG2NUM(swig_ruby_trackings) ); + } else { + swig_ruby_trackings = (st_table*)NUM2SWIG(trackings_value); + } - /* Convert the Ruby number to a Ruby object */ - return NUM2SWIG(reference); + rb_define_virtual_variable("SWIG_TRACKINGS_COUNT", + VALUEFUNC(swig_ruby_trackings_count), + SWIG_RUBY_VOID_ANYARGS_FUNC((rb_gvar_setter_t*)NULL)); } /* Add a Tracking from a C/C++ struct to a Ruby object */ SWIGRUNTIME void SWIG_RubyAddTracking(void* ptr, VALUE object) { - /* In a Ruby hash table we store the pointer and - the associated Ruby object. The trick here is - that we cannot store the Ruby object directly - if - we do then it cannot be garbage collected. So - instead we typecast it as a unsigned long and - convert it to a Ruby number object.*/ - - /* Get a reference to the pointer as a Ruby number */ - VALUE key = SWIG_RubyPtrToReference(ptr); - - /* Get a reference to the Ruby object as a Ruby number */ - VALUE value = SWIG_RubyObjectToReference(object); - /* Store the mapping to the global hash table. */ - rb_hash_aset(swig_ruby_trackings, key, value); + st_insert(swig_ruby_trackings, (st_data_t)ptr, object); } /* Get the Ruby object that owns the specified C/C++ struct */ SWIGRUNTIME VALUE SWIG_RubyInstanceFor(void* ptr) { - /* Get a reference to the pointer as a Ruby number */ - VALUE key = SWIG_RubyPtrToReference(ptr); - /* Now lookup the value stored in the global hash table */ - VALUE value = rb_hash_aref(swig_ruby_trackings, key); - - if (value == Qnil) { - /* No object exists - return nil. */ + VALUE value; + + if (st_lookup(swig_ruby_trackings, (st_data_t)ptr, &value)) { + return value; + } else { return Qnil; } - else { - /* Convert this value to Ruby object */ - return SWIG_RubyReferenceToObject(value); - } } /* Remove a Tracking from a C/C++ struct to a Ruby object. It @@ -1315,25 +1300,39 @@ SWIGRUNTIME VALUE SWIG_RubyInstanceFor(void* ptr) { since the same memory address may be reused later to create a new object. */ SWIGRUNTIME void SWIG_RubyRemoveTracking(void* ptr) { - /* Get a reference to the pointer as a Ruby number */ - VALUE key = SWIG_RubyPtrToReference(ptr); - - /* Delete the object from the hash table by calling Ruby's - do this we need to call the Hash.delete method.*/ - rb_funcall(swig_ruby_trackings, swig_ruby_hash_delete, 1, key); + /* Delete the object from the hash table */ + st_delete(swig_ruby_trackings, (st_data_t *)&ptr, NULL); } /* This is a helper method that unlinks a Ruby object from its underlying C++ object. This is needed if the lifetime of the - Ruby object is longer than the C++ object */ + Ruby object is longer than the C++ object. */ SWIGRUNTIME void SWIG_RubyUnlinkObjects(void* ptr) { VALUE object = SWIG_RubyInstanceFor(ptr); if (object != Qnil) { + // object might have the T_ZOMBIE type, but that's just + // because the GC has flagged it as such for a deferred + // destruction. Until then, it's still a T_DATA object. DATA_PTR(object) = 0; } } +/* This is a helper method that iterates over all the trackings + passing the C++ object pointer and its related Ruby object + to the passed callback function. */ + +/* Proxy method to abstract the internal trackings datatype */ +static int swig_ruby_internal_iterate_callback(st_data_t ptr, st_data_t obj, st_data_t meth) { + ((void (*) (void *, VALUE))meth)((void *)ptr, (VALUE)obj); + return ST_CONTINUE; +} + +SWIGRUNTIME void SWIG_RubyIterateTrackings( void(*meth)(void* ptr, VALUE obj) ) { + st_foreach(swig_ruby_trackings, + SWIG_RUBY_INT_ANYARGS_FUNC(swig_ruby_internal_iterate_callback), + (st_data_t)meth); +} #ifdef __cplusplus } @@ -1392,7 +1391,7 @@ SWIG_Ruby_AppendOutput(VALUE target, VALUE o) { #define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Ruby_ConvertPtrAndOwn(obj, pptr, type, flags, own) #define SWIG_NewPointerObj(ptr, type, flags) SWIG_Ruby_NewPointerObj(ptr, type, flags) #define SWIG_AcquirePtr(ptr, own) SWIG_Ruby_AcquirePtr(ptr, own) -#define swig_owntype ruby_owntype +#define swig_owntype swig_ruby_owntype /* for raw packed data */ #define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Ruby_ConvertPacked(obj, ptr, sz, ty, flags) @@ -1549,10 +1548,11 @@ SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags) swig_class *sklass; VALUE klass; VALUE obj; - + if (!ptr) return Qnil; - + + assert(type); if (type->clientdata) { sklass = (swig_class *) type->clientdata; @@ -1560,7 +1560,7 @@ SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags) track = sklass->trackObjects; if (track) { obj = SWIG_RubyInstanceFor(ptr); - + /* Check the object's type and make sure it has the correct type. It might not in cases where methods do things like downcast methods. */ @@ -1592,7 +1592,7 @@ SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags) obj = Data_Wrap_Struct(klass, 0, 0, ptr); } rb_iv_set(obj, "@__swigtype__", rb_str_new2(type->name)); - + return obj; } @@ -1612,26 +1612,30 @@ SWIGRUNTIMEINLINE char * SWIG_Ruby_MangleStr(VALUE obj) { VALUE stype = rb_iv_get(obj, "@__swigtype__"); + if (NIL_P(stype)) + return NULL; return StringValuePtr(stype); } /* Acquire a pointer value */ -typedef void (*ruby_owntype)(void*); - -SWIGRUNTIME ruby_owntype -SWIG_Ruby_AcquirePtr(VALUE obj, ruby_owntype own) { - if (obj) { - ruby_owntype oldown = RDATA(obj)->dfree; - RDATA(obj)->dfree = own; - return oldown; - } else { - return 0; +typedef struct { + void (*datafree)(void *); + int own; +} swig_ruby_owntype; + +SWIGRUNTIME swig_ruby_owntype +SWIG_Ruby_AcquirePtr(VALUE obj, swig_ruby_owntype own) { + swig_ruby_owntype oldown = {0, 0}; + if (TYPE(obj) == T_DATA && !RTYPEDDATA_P(obj)) { + oldown.datafree = RDATA(obj)->dfree; + RDATA(obj)->dfree = own.datafree; } + return oldown; } /* Convert a pointer value */ SWIGRUNTIME int -SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, ruby_owntype *own) +SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, swig_ruby_owntype *own) { char *c; swig_cast_info *tc; @@ -1639,16 +1643,20 @@ SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, /* Grab the pointer */ if (NIL_P(obj)) { - *ptr = 0; - return SWIG_OK; + if (ptr) + *ptr = 0; + return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK; } else { - if (TYPE(obj) != T_DATA) { + if (TYPE(obj) != T_DATA || (TYPE(obj) == T_DATA && RTYPEDDATA_P(obj))) { return SWIG_ERROR; } Data_Get_Struct(obj, void, vptr); } - if (own) *own = RDATA(obj)->dfree; + if (own) { + own->datafree = RDATA(obj)->dfree; + own->own = 0; + } /* Check to see if the input object is giving up ownership of the underlying C struct or C++ object. If so then we @@ -1683,8 +1691,6 @@ SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, /* The object has already been deleted */ return SWIG_ObjectPreviouslyDeletedError; } - *ptr = vptr; - return SWIG_OK; } } if ((c = SWIG_MangleStr(obj)) == NULL) { @@ -1694,12 +1700,23 @@ SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, if (!tc) { return SWIG_ERROR; } else { - int newmemory = 0; - *ptr = SWIG_TypeCast(tc, vptr, &newmemory); - assert(!newmemory); /* newmemory handling not yet implemented */ + if (ptr) { + if (tc->type == ty) { + *ptr = vptr; + } else { + int newmemory = 0; + *ptr = SWIG_TypeCast(tc, vptr, &newmemory); + if (newmemory == SWIG_CAST_NEW_MEMORY) { + assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */ + if (own) + own->own = own->own | SWIG_CAST_NEW_MEMORY; + } + } + } } } else { - *ptr = vptr; + if (ptr) + *ptr = vptr; } return SWIG_OK; @@ -1725,7 +1742,7 @@ SWIG_Ruby_NewPackedObj(void *ptr, int sz, swig_type_info *type) { return rb_str_new2(result); } -/* Convert a packed value value */ +/* Convert a packed pointer value */ SWIGRUNTIME int SWIG_Ruby_ConvertPacked(VALUE obj, void *ptr, int sz, swig_type_info *ty) { swig_cast_info *tc; @@ -1851,7 +1868,7 @@ static VALUE mFLAC; #define SWIG_RUBY_THREAD_END_BLOCK -#define SWIGVERSION 0x030007 +#define SWIGVERSION 0x040002 #define SWIG_VERSION SWIGVERSION @@ -1868,6 +1885,8 @@ static VALUE mFLAC; #include #include +#include +#include #include #if defined(HAVE_RUBY_ENCODING_H) && HAVE_RUBY_ENCODING_H @@ -1937,6 +1956,28 @@ TagLib::StringList ruby_array_to_taglib_string_list(VALUE ary) { return result; } +VALUE taglib_bytevectorlist_to_ruby_array(const TagLib::ByteVectorList & list) { + VALUE ary = rb_ary_new2(list.size()); + for (TagLib::ByteVectorList::ConstIterator it = list.begin(); it != list.end(); it++) { + VALUE s = taglib_bytevector_to_ruby_string(*it); + rb_ary_push(ary, s); + } + return ary; +} + +TagLib::ByteVectorList ruby_array_to_taglib_bytevectorlist(VALUE ary) { + TagLib::ByteVectorList result = TagLib::ByteVectorList(); + if (NIL_P(ary)) { + return result; + } + for (long i = 0; i < RARRAY_LEN(ary); i++) { + VALUE e = rb_ary_entry(ary, i); + TagLib::ByteVector s = ruby_string_to_taglib_bytevector(e); + result.append(s); + } + return result; +} + VALUE taglib_filename_to_ruby_string(TagLib::FileName filename) { VALUE result; #ifdef _WIN32 @@ -2031,7 +2072,7 @@ SWIG_AsCharPtrAndSize(VALUE obj, char** cptr, size_t* psize, int *alloc) if (cptr) { if (alloc) { if (*alloc == SWIG_NEWOBJ) { - *cptr = reinterpret_cast< char* >(memcpy((new char[size]), cstr, sizeof(char)*(size))); + *cptr = reinterpret_cast< char* >(memcpy(new char[size], cstr, sizeof(char)*(size))); } else { *cptr = cstr; *alloc = SWIG_OLDOBJ; @@ -2060,15 +2101,16 @@ SWIG_AsCharPtrAndSize(VALUE obj, char** cptr, size_t* psize, int *alloc) SWIGINTERN VALUE -SWIG_ruby_failed(void) +SWIG_ruby_failed(VALUE SWIGUNUSEDPARM(arg1), VALUE SWIGUNUSEDPARM(arg2)) { return Qnil; } -/*@SWIG:/usr/local/share/swig/3.0.7/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/ -SWIGINTERN VALUE SWIG_AUX_NUM2LONG(VALUE *args) +/*@SWIG:/usr/local/Cellar/swig/4.0.2/share/swig/4.0.2/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/ +SWIGINTERN VALUE SWIG_AUX_NUM2LONG(VALUE arg) { + VALUE *args = (VALUE *)arg; VALUE obj = args[0]; VALUE type = TYPE(obj); long *res = (long *)(args[1]); @@ -2086,7 +2128,7 @@ SWIG_AsVal_long (VALUE obj, long* val) VALUE a[2]; a[0] = obj; a[1] = (VALUE)(&v); - if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2LONG), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) { + if (rb_rescue(VALUEFUNC(SWIG_AUX_NUM2LONG), (VALUE)a, VALUEFUNC(SWIG_ruby_failed), 0) != Qnil) { if (val) *val = v; return SWIG_OK; } @@ -2120,7 +2162,8 @@ SWIG_From_bool (bool value) static swig_class SwigClassMetadataBlock; SWIGINTERN void -free_TagLib_FLAC_MetadataBlock(TagLib::FLAC::MetadataBlock *arg1) { +free_TagLib_FLAC_MetadataBlock(void *self) { + TagLib::FLAC::MetadataBlock *arg1 = (TagLib::FLAC::MetadataBlock *)self; SWIG_RubyRemoveTracking(arg1); delete arg1; } @@ -2167,22 +2210,20 @@ _wrap_new_Picture__SWIG_0(int argc, VALUE *argv, VALUE self) { } -#ifdef HAVE_RB_DEFINE_ALLOC_FUNC SWIGINTERN VALUE -_wrap_Picture_allocate(VALUE self) { +#ifdef HAVE_RB_DEFINE_ALLOC_FUNC +_wrap_Picture_allocate(VALUE self) #else - SWIGINTERN VALUE - _wrap_Picture_allocate(int argc, VALUE *argv, VALUE self) { +_wrap_Picture_allocate(int argc, VALUE *argv, VALUE self) #endif - - - VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__FLAC__Picture); +{ + VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__FLAC__Picture); #ifndef HAVE_RB_DEFINE_ALLOC_FUNC - rb_obj_call_init(vresult, argc, argv); + rb_obj_call_init(vresult, argc, argv); #endif - return vresult; - } - + return vresult; +} + SWIGINTERN VALUE _wrap_new_Picture__SWIG_1(int argc, VALUE *argv, VALUE self) { @@ -2238,7 +2279,8 @@ SWIGINTERN VALUE _wrap_new_Picture(int nargs, VALUE *args, VALUE self) { SWIGINTERN void -free_TagLib_FLAC_Picture(TagLib::FLAC::Picture *arg1) { +free_TagLib_FLAC_Picture(void *self) { + TagLib::FLAC::Picture *arg1 = (TagLib::FLAC::Picture *)self; SWIG_RubyRemoveTracking(arg1); delete arg1; } @@ -2870,7 +2912,7 @@ SWIG_InitializeModule(void *clientdata) { /* Now work on filling in swig_module.types */ #ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: size %d\n", swig_module.size); + printf("SWIG_InitializeModule: size %lu\n", (unsigned long)swig_module.size); #endif for (i = 0; i < swig_module.size; ++i) { swig_type_info *type = 0; @@ -2878,7 +2920,7 @@ SWIG_InitializeModule(void *clientdata) { swig_cast_info *cast; #ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); + printf("SWIG_InitializeModule: type %lu %s\n", (unsigned long)i, swig_module.type_initial[i]->name); #endif /* if there is another module already loaded */ @@ -2954,7 +2996,7 @@ SWIG_InitializeModule(void *clientdata) { for (i = 0; i < swig_module.size; ++i) { int j = 0; swig_cast_info *cast = swig_module.cast_initial[i]; - printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); + printf("SWIG_InitializeModule: type %lu %s\n", (unsigned long)i, swig_module.type_initial[i]->name); while (cast->type) { printf("SWIG_InitializeModule: cast type %s\n", cast->type->name); cast++; diff --git a/ext/taglib_id3v1/taglib_id3v1_wrap.cxx b/ext/taglib_id3v1/taglib_id3v1_wrap.cxx index 867169d..0cbb4c6 100644 --- a/ext/taglib_id3v1/taglib_id3v1_wrap.cxx +++ b/ext/taglib_id3v1/taglib_id3v1_wrap.cxx @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 3.0.7 + * Version 4.0.2 * * This file is not intended to be easily readable and contains a number of * coding conventions designed to improve portability and efficiency. Do not make @@ -8,7 +8,11 @@ * interface file instead. * ----------------------------------------------------------------------------- */ + +#ifndef SWIGRUBY #define SWIGRUBY +#endif + #ifdef __cplusplus @@ -101,9 +105,11 @@ template T SwigValueInit() { #endif /* exporting methods */ -#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) -# ifndef GCC_HASCLASSVISIBILITY -# define GCC_HASCLASSVISIBILITY +#if defined(__GNUC__) +# if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +# ifndef GCC_HASCLASSVISIBILITY +# define GCC_HASCLASSVISIBILITY +# endif # endif #endif @@ -223,9 +229,11 @@ template T SwigValueInit() { #endif /* exporting methods */ -#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) -# ifndef GCC_HASCLASSVISIBILITY -# define GCC_HASCLASSVISIBILITY +#if defined(__GNUC__) +# if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +# ifndef GCC_HASCLASSVISIBILITY +# define GCC_HASCLASSVISIBILITY +# endif # endif #endif @@ -323,6 +331,7 @@ template T SwigValueInit() { /* Flags for pointer conversions */ #define SWIG_POINTER_DISOWN 0x1 #define SWIG_CAST_NEW_MEMORY 0x2 +#define SWIG_POINTER_NO_NULL 0x4 /* Flags for new pointer objects */ #define SWIG_POINTER_OWN 0x1 @@ -775,16 +784,16 @@ SWIG_UnpackData(const char *c, void *ptr, size_t sz) { char d = *(c++); unsigned char uu; if ((d >= '0') && (d <= '9')) - uu = ((d - '0') << 4); + uu = (unsigned char)((d - '0') << 4); else if ((d >= 'a') && (d <= 'f')) - uu = ((d - ('a'-10)) << 4); + uu = (unsigned char)((d - ('a'-10)) << 4); else return (char *) 0; d = *(c++); if ((d >= '0') && (d <= '9')) - uu |= (d - '0'); + uu |= (unsigned char)(d - '0'); else if ((d >= 'a') && (d <= 'f')) - uu |= (d - ('a'-10)); + uu |= (unsigned char)(d - ('a'-10)); else return (char *) 0; *u = uu; @@ -961,42 +970,53 @@ SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { #ifndef RSTRUCT_PTR # define RSTRUCT_PTR(x) RSTRUCT(x)->ptr #endif +#ifndef RTYPEDDATA_P +# define RTYPEDDATA_P(x) (TYPE(x) != T_DATA) +#endif /* - * Need to be very careful about how these macros are defined, especially - * when compiling C++ code or C code with an ANSI C compiler. + * The following macros are used for providing the correct type of a + * function pointer to the Ruby C API. + * Starting with Ruby 2.7 (corresponding to RB_METHOD_DEFINITION_DECL being + * defined) these macros act transparently due to Ruby's moving away from + * ANYARGS and instead employing strict function signatures. * - * VALUEFUNC(f) is a macro used to typecast a C function that implements - * a Ruby method so that it can be passed as an argument to API functions - * like rb_define_method() and rb_define_singleton_method(). + * Note: In case of C (not C++) the macros are transparent even before + * Ruby 2.7 due to the fact that the Ruby C API used function declarators + * with empty parentheses, which allows for an unspecified number of + * arguments. * - * VOIDFUNC(f) is a macro used to typecast a C function that implements - * either the "mark" or "free" stuff for a Ruby Data object, so that it - * can be passed as an argument to API functions like Data_Wrap_Struct() + * PROTECTFUNC(f) is used for the function pointer argument of the Ruby + * C API function rb_protect(). + * + * VALUEFUNC(f) is used for the function pointer argument(s) of Ruby C API + * functions like rb_define_method() and rb_define_singleton_method(). + * + * VOIDFUNC(f) is used to typecast a C function that implements either + * the "mark" or "free" stuff for a Ruby Data object, so that it can be + * passed as an argument to Ruby C API functions like Data_Wrap_Struct() * and Data_Make_Struct(). + * + * SWIG_RUBY_VOID_ANYARGS_FUNC(f) is used for the function pointer + * argument(s) of Ruby C API functions like rb_define_virtual_variable(). + * + * SWIG_RUBY_INT_ANYARGS_FUNC(f) is used for the function pointer + * argument(s) of Ruby C API functions like st_foreach(). */ - -#ifdef __cplusplus -# ifndef RUBY_METHOD_FUNC /* These definitions should work for Ruby 1.4.6 */ -# define PROTECTFUNC(f) ((VALUE (*)()) f) -# define VALUEFUNC(f) ((VALUE (*)()) f) -# define VOIDFUNC(f) ((void (*)()) f) -# else -# ifndef ANYARGS /* These definitions should work for Ruby 1.6 */ -# define PROTECTFUNC(f) ((VALUE (*)()) f) -# define VALUEFUNC(f) ((VALUE (*)()) f) -# define VOIDFUNC(f) ((RUBY_DATA_FUNC) f) -# else /* These definitions should work for Ruby 1.7+ */ -# define PROTECTFUNC(f) ((VALUE (*)(VALUE)) f) -# define VALUEFUNC(f) ((VALUE (*)(ANYARGS)) f) -# define VOIDFUNC(f) ((RUBY_DATA_FUNC) f) -# endif -# endif +#if defined(__cplusplus) && !defined(RB_METHOD_DEFINITION_DECL) +# define PROTECTFUNC(f) ((VALUE (*)(VALUE)) f) +# define VALUEFUNC(f) ((VALUE (*)(ANYARGS)) f) +# define VOIDFUNC(f) ((RUBY_DATA_FUNC) f) +# define SWIG_RUBY_VOID_ANYARGS_FUNC(f) ((void (*)(ANYARGS))(f)) +# define SWIG_RUBY_INT_ANYARGS_FUNC(f) ((int (*)(ANYARGS))(f)) #else +# define PROTECTFUNC(f) (f) # define VALUEFUNC(f) (f) # define VOIDFUNC(f) (f) +# define SWIG_RUBY_VOID_ANYARGS_FUNC(f) (f) +# define SWIG_RUBY_INT_ANYARGS_FUNC(f) (f) #endif /* Don't use for expressions have side effect */ @@ -1184,7 +1204,7 @@ void Ruby_Format_OverloadedError( /* ----------------------------------------------------------------------------- * rubytracking.swg * - * This file contains support for tracking mappings from + * This file contains support for tracking mappings from * Ruby objects to C++ objects. This functionality is needed * to implement mark functions for Ruby's mark and sweep * garbage collector. @@ -1194,6 +1214,11 @@ void Ruby_Format_OverloadedError( extern "C" { #endif +#if !defined(ST_DATA_T_DEFINED) +/* Needs to be explicitly included for Ruby 1.8 and earlier */ +#include +#endif + /* Ruby 1.8 actually assumes the first case. */ #if SIZEOF_VOIDP == SIZEOF_LONG # define SWIG2NUM(v) LONG2NUM((unsigned long)v) @@ -1205,109 +1230,69 @@ extern "C" { # error sizeof(void*) is not the same as long or long long #endif - -/* Global Ruby hash table to store Trackings from C/C++ - structs to Ruby Objects. +/* Global hash table to store Trackings from C/C++ + structs to Ruby Objects. */ -static VALUE swig_ruby_trackings = Qnil; +static st_table* swig_ruby_trackings = NULL; + +static VALUE swig_ruby_trackings_count(ID id, VALUE *var) { + return SWIG2NUM(swig_ruby_trackings->num_entries); +} -/* Global variable that stores a reference to the ruby - hash table delete function. */ -static ID swig_ruby_hash_delete; -/* Setup a Ruby hash table to store Trackings */ +/* Setup a hash table to store Trackings */ SWIGRUNTIME void SWIG_RubyInitializeTrackings(void) { - /* Create a ruby hash table to store Trackings from C++ + /* Create a hash table to store Trackings from C++ objects to Ruby objects. */ - /* Try to see if some other .so has already created a + /* Try to see if some other .so has already created a tracking hash table, which we keep hidden in an instance var in the SWIG module. This is done to allow multiple DSOs to share the same tracking table. */ - ID trackings_id = rb_intern( "@__trackings__" ); + VALUE trackings_value = Qnil; + /* change the variable name so that we can mix modules + compiled with older SWIG's - this used to be called "@__trackings__" */ + ID trackings_id = rb_intern( "@__safetrackings__" ); VALUE verbose = rb_gv_get("VERBOSE"); rb_gv_set("VERBOSE", Qfalse); - swig_ruby_trackings = rb_ivar_get( _mSWIG, trackings_id ); + trackings_value = rb_ivar_get( _mSWIG, trackings_id ); rb_gv_set("VERBOSE", verbose); - /* No, it hasn't. Create one ourselves */ - if ( swig_ruby_trackings == Qnil ) - { - swig_ruby_trackings = rb_hash_new(); - rb_ivar_set( _mSWIG, trackings_id, swig_ruby_trackings ); - } - - /* Now store a reference to the hash table delete function - so that we only have to look it up once.*/ - swig_ruby_hash_delete = rb_intern("delete"); -} - -/* Get a Ruby number to reference a pointer */ -SWIGRUNTIME VALUE SWIG_RubyPtrToReference(void* ptr) { - /* We cast the pointer to an unsigned long - and then store a reference to it using - a Ruby number object. */ - - /* Convert the pointer to a Ruby number */ - return SWIG2NUM(ptr); -} - -/* Get a Ruby number to reference an object */ -SWIGRUNTIME VALUE SWIG_RubyObjectToReference(VALUE object) { - /* We cast the object to an unsigned long - and then store a reference to it using - a Ruby number object. */ - - /* Convert the Object to a Ruby number */ - return SWIG2NUM(object); -} - -/* Get a Ruby object from a previously stored reference */ -SWIGRUNTIME VALUE SWIG_RubyReferenceToObject(VALUE reference) { - /* The provided Ruby number object is a reference - to the Ruby object we want.*/ + /* The trick here is that we have to store the hash table + pointer in a Ruby variable. We do not want Ruby's GC to + treat this pointer as a Ruby object, so we convert it to + a Ruby numeric value. */ + if (trackings_value == Qnil) { + /* No, it hasn't. Create one ourselves */ + swig_ruby_trackings = st_init_numtable(); + rb_ivar_set( _mSWIG, trackings_id, SWIG2NUM(swig_ruby_trackings) ); + } else { + swig_ruby_trackings = (st_table*)NUM2SWIG(trackings_value); + } - /* Convert the Ruby number to a Ruby object */ - return NUM2SWIG(reference); + rb_define_virtual_variable("SWIG_TRACKINGS_COUNT", + VALUEFUNC(swig_ruby_trackings_count), + SWIG_RUBY_VOID_ANYARGS_FUNC((rb_gvar_setter_t*)NULL)); } /* Add a Tracking from a C/C++ struct to a Ruby object */ SWIGRUNTIME void SWIG_RubyAddTracking(void* ptr, VALUE object) { - /* In a Ruby hash table we store the pointer and - the associated Ruby object. The trick here is - that we cannot store the Ruby object directly - if - we do then it cannot be garbage collected. So - instead we typecast it as a unsigned long and - convert it to a Ruby number object.*/ - - /* Get a reference to the pointer as a Ruby number */ - VALUE key = SWIG_RubyPtrToReference(ptr); - - /* Get a reference to the Ruby object as a Ruby number */ - VALUE value = SWIG_RubyObjectToReference(object); - /* Store the mapping to the global hash table. */ - rb_hash_aset(swig_ruby_trackings, key, value); + st_insert(swig_ruby_trackings, (st_data_t)ptr, object); } /* Get the Ruby object that owns the specified C/C++ struct */ SWIGRUNTIME VALUE SWIG_RubyInstanceFor(void* ptr) { - /* Get a reference to the pointer as a Ruby number */ - VALUE key = SWIG_RubyPtrToReference(ptr); - /* Now lookup the value stored in the global hash table */ - VALUE value = rb_hash_aref(swig_ruby_trackings, key); - - if (value == Qnil) { - /* No object exists - return nil. */ + VALUE value; + + if (st_lookup(swig_ruby_trackings, (st_data_t)ptr, &value)) { + return value; + } else { return Qnil; } - else { - /* Convert this value to Ruby object */ - return SWIG_RubyReferenceToObject(value); - } } /* Remove a Tracking from a C/C++ struct to a Ruby object. It @@ -1315,25 +1300,39 @@ SWIGRUNTIME VALUE SWIG_RubyInstanceFor(void* ptr) { since the same memory address may be reused later to create a new object. */ SWIGRUNTIME void SWIG_RubyRemoveTracking(void* ptr) { - /* Get a reference to the pointer as a Ruby number */ - VALUE key = SWIG_RubyPtrToReference(ptr); - - /* Delete the object from the hash table by calling Ruby's - do this we need to call the Hash.delete method.*/ - rb_funcall(swig_ruby_trackings, swig_ruby_hash_delete, 1, key); + /* Delete the object from the hash table */ + st_delete(swig_ruby_trackings, (st_data_t *)&ptr, NULL); } /* This is a helper method that unlinks a Ruby object from its underlying C++ object. This is needed if the lifetime of the - Ruby object is longer than the C++ object */ + Ruby object is longer than the C++ object. */ SWIGRUNTIME void SWIG_RubyUnlinkObjects(void* ptr) { VALUE object = SWIG_RubyInstanceFor(ptr); if (object != Qnil) { + // object might have the T_ZOMBIE type, but that's just + // because the GC has flagged it as such for a deferred + // destruction. Until then, it's still a T_DATA object. DATA_PTR(object) = 0; } } +/* This is a helper method that iterates over all the trackings + passing the C++ object pointer and its related Ruby object + to the passed callback function. */ + +/* Proxy method to abstract the internal trackings datatype */ +static int swig_ruby_internal_iterate_callback(st_data_t ptr, st_data_t obj, st_data_t meth) { + ((void (*) (void *, VALUE))meth)((void *)ptr, (VALUE)obj); + return ST_CONTINUE; +} + +SWIGRUNTIME void SWIG_RubyIterateTrackings( void(*meth)(void* ptr, VALUE obj) ) { + st_foreach(swig_ruby_trackings, + SWIG_RUBY_INT_ANYARGS_FUNC(swig_ruby_internal_iterate_callback), + (st_data_t)meth); +} #ifdef __cplusplus } @@ -1392,7 +1391,7 @@ SWIG_Ruby_AppendOutput(VALUE target, VALUE o) { #define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Ruby_ConvertPtrAndOwn(obj, pptr, type, flags, own) #define SWIG_NewPointerObj(ptr, type, flags) SWIG_Ruby_NewPointerObj(ptr, type, flags) #define SWIG_AcquirePtr(ptr, own) SWIG_Ruby_AcquirePtr(ptr, own) -#define swig_owntype ruby_owntype +#define swig_owntype swig_ruby_owntype /* for raw packed data */ #define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Ruby_ConvertPacked(obj, ptr, sz, ty, flags) @@ -1549,10 +1548,11 @@ SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags) swig_class *sklass; VALUE klass; VALUE obj; - + if (!ptr) return Qnil; - + + assert(type); if (type->clientdata) { sklass = (swig_class *) type->clientdata; @@ -1560,7 +1560,7 @@ SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags) track = sklass->trackObjects; if (track) { obj = SWIG_RubyInstanceFor(ptr); - + /* Check the object's type and make sure it has the correct type. It might not in cases where methods do things like downcast methods. */ @@ -1592,7 +1592,7 @@ SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags) obj = Data_Wrap_Struct(klass, 0, 0, ptr); } rb_iv_set(obj, "@__swigtype__", rb_str_new2(type->name)); - + return obj; } @@ -1612,26 +1612,30 @@ SWIGRUNTIMEINLINE char * SWIG_Ruby_MangleStr(VALUE obj) { VALUE stype = rb_iv_get(obj, "@__swigtype__"); + if (NIL_P(stype)) + return NULL; return StringValuePtr(stype); } /* Acquire a pointer value */ -typedef void (*ruby_owntype)(void*); - -SWIGRUNTIME ruby_owntype -SWIG_Ruby_AcquirePtr(VALUE obj, ruby_owntype own) { - if (obj) { - ruby_owntype oldown = RDATA(obj)->dfree; - RDATA(obj)->dfree = own; - return oldown; - } else { - return 0; +typedef struct { + void (*datafree)(void *); + int own; +} swig_ruby_owntype; + +SWIGRUNTIME swig_ruby_owntype +SWIG_Ruby_AcquirePtr(VALUE obj, swig_ruby_owntype own) { + swig_ruby_owntype oldown = {0, 0}; + if (TYPE(obj) == T_DATA && !RTYPEDDATA_P(obj)) { + oldown.datafree = RDATA(obj)->dfree; + RDATA(obj)->dfree = own.datafree; } + return oldown; } /* Convert a pointer value */ SWIGRUNTIME int -SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, ruby_owntype *own) +SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, swig_ruby_owntype *own) { char *c; swig_cast_info *tc; @@ -1639,16 +1643,20 @@ SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, /* Grab the pointer */ if (NIL_P(obj)) { - *ptr = 0; - return SWIG_OK; + if (ptr) + *ptr = 0; + return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK; } else { - if (TYPE(obj) != T_DATA) { + if (TYPE(obj) != T_DATA || (TYPE(obj) == T_DATA && RTYPEDDATA_P(obj))) { return SWIG_ERROR; } Data_Get_Struct(obj, void, vptr); } - if (own) *own = RDATA(obj)->dfree; + if (own) { + own->datafree = RDATA(obj)->dfree; + own->own = 0; + } /* Check to see if the input object is giving up ownership of the underlying C struct or C++ object. If so then we @@ -1683,8 +1691,6 @@ SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, /* The object has already been deleted */ return SWIG_ObjectPreviouslyDeletedError; } - *ptr = vptr; - return SWIG_OK; } } if ((c = SWIG_MangleStr(obj)) == NULL) { @@ -1694,12 +1700,23 @@ SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, if (!tc) { return SWIG_ERROR; } else { - int newmemory = 0; - *ptr = SWIG_TypeCast(tc, vptr, &newmemory); - assert(!newmemory); /* newmemory handling not yet implemented */ + if (ptr) { + if (tc->type == ty) { + *ptr = vptr; + } else { + int newmemory = 0; + *ptr = SWIG_TypeCast(tc, vptr, &newmemory); + if (newmemory == SWIG_CAST_NEW_MEMORY) { + assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */ + if (own) + own->own = own->own | SWIG_CAST_NEW_MEMORY; + } + } + } } } else { - *ptr = vptr; + if (ptr) + *ptr = vptr; } return SWIG_OK; @@ -1725,7 +1742,7 @@ SWIG_Ruby_NewPackedObj(void *ptr, int sz, swig_type_info *type) { return rb_str_new2(result); } -/* Convert a packed value value */ +/* Convert a packed pointer value */ SWIGRUNTIME int SWIG_Ruby_ConvertPacked(VALUE obj, void *ptr, int sz, swig_type_info *ty) { swig_cast_info *tc; @@ -1853,7 +1870,7 @@ static VALUE mID3v1; #define SWIG_RUBY_THREAD_END_BLOCK -#define SWIGVERSION 0x030007 +#define SWIGVERSION 0x040002 #define SWIG_VERSION SWIGVERSION @@ -1870,6 +1887,8 @@ static VALUE mID3v1; #include #include +#include +#include #include #if defined(HAVE_RUBY_ENCODING_H) && HAVE_RUBY_ENCODING_H @@ -1939,6 +1958,28 @@ TagLib::StringList ruby_array_to_taglib_string_list(VALUE ary) { return result; } +VALUE taglib_bytevectorlist_to_ruby_array(const TagLib::ByteVectorList & list) { + VALUE ary = rb_ary_new2(list.size()); + for (TagLib::ByteVectorList::ConstIterator it = list.begin(); it != list.end(); it++) { + VALUE s = taglib_bytevector_to_ruby_string(*it); + rb_ary_push(ary, s); + } + return ary; +} + +TagLib::ByteVectorList ruby_array_to_taglib_bytevectorlist(VALUE ary) { + TagLib::ByteVectorList result = TagLib::ByteVectorList(); + if (NIL_P(ary)) { + return result; + } + for (long i = 0; i < RARRAY_LEN(ary); i++) { + VALUE e = rb_ary_entry(ary, i); + TagLib::ByteVector s = ruby_string_to_taglib_bytevector(e); + result.append(s); + } + return result; +} + VALUE taglib_filename_to_ruby_string(TagLib::FileName filename) { VALUE result; #ifdef _WIN32 @@ -2002,7 +2043,7 @@ SWIG_AsCharPtrAndSize(VALUE obj, char** cptr, size_t* psize, int *alloc) if (cptr) { if (alloc) { if (*alloc == SWIG_NEWOBJ) { - *cptr = reinterpret_cast< char* >(memcpy((new char[size]), cstr, sizeof(char)*(size))); + *cptr = reinterpret_cast< char* >(memcpy(new char[size], cstr, sizeof(char)*(size))); } else { *cptr = cstr; *alloc = SWIG_OLDOBJ; @@ -2031,15 +2072,16 @@ SWIG_AsCharPtrAndSize(VALUE obj, char** cptr, size_t* psize, int *alloc) SWIGINTERN VALUE -SWIG_ruby_failed(void) +SWIG_ruby_failed(VALUE SWIGUNUSEDPARM(arg1), VALUE SWIGUNUSEDPARM(arg2)) { return Qnil; } -/*@SWIG:/usr/local/share/swig/3.0.7/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/ -SWIGINTERN VALUE SWIG_AUX_NUM2LONG(VALUE *args) +/*@SWIG:/usr/local/Cellar/swig/4.0.2/share/swig/4.0.2/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/ +SWIGINTERN VALUE SWIG_AUX_NUM2LONG(VALUE arg) { + VALUE *args = (VALUE *)arg; VALUE obj = args[0]; VALUE type = TYPE(obj); long *res = (long *)(args[1]); @@ -2057,7 +2099,7 @@ SWIG_AsVal_long (VALUE obj, long* val) VALUE a[2]; a[0] = obj; a[1] = (VALUE)(&v); - if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2LONG), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) { + if (rb_rescue(VALUEFUNC(SWIG_AUX_NUM2LONG), (VALUE)a, VALUEFUNC(SWIG_ruby_failed), 0) != Qnil) { if (val) *val = v; return SWIG_OK; } @@ -2093,9 +2135,10 @@ SWIG_From_unsigned_SS_int (unsigned int value) } -/*@SWIG:/usr/local/share/swig/3.0.7/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/ -SWIGINTERN VALUE SWIG_AUX_NUM2ULONG(VALUE *args) +/*@SWIG:/usr/local/Cellar/swig/4.0.2/share/swig/4.0.2/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/ +SWIGINTERN VALUE SWIG_AUX_NUM2ULONG(VALUE arg) { + VALUE *args = (VALUE *)arg; VALUE obj = args[0]; VALUE type = TYPE(obj); unsigned long *res = (unsigned long *)(args[1]); @@ -2113,7 +2156,7 @@ SWIG_AsVal_unsigned_SS_long (VALUE obj, unsigned long *val) VALUE a[2]; a[0] = obj; a[1] = (VALUE)(&v); - if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2ULONG), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) { + if (rb_rescue(VALUEFUNC(SWIG_AUX_NUM2ULONG), (VALUE)a, VALUEFUNC(SWIG_ruby_failed), 0) != Qnil) { if (val) *val = v; return SWIG_OK; } @@ -2173,22 +2216,20 @@ VALUE taglib_id3v1_genre_map_to_ruby_hash(const TagLib::ID3v1::GenreMap &map) { static swig_class SwigClassStringHandler; -#ifdef HAVE_RB_DEFINE_ALLOC_FUNC SWIGINTERN VALUE -_wrap_StringHandler_allocate(VALUE self) { +#ifdef HAVE_RB_DEFINE_ALLOC_FUNC +_wrap_StringHandler_allocate(VALUE self) #else - SWIGINTERN VALUE - _wrap_StringHandler_allocate(int argc, VALUE *argv, VALUE self) { +_wrap_StringHandler_allocate(int argc, VALUE *argv, VALUE self) #endif - - - VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__ID3v1__StringHandler); +{ + VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__ID3v1__StringHandler); #ifndef HAVE_RB_DEFINE_ALLOC_FUNC - rb_obj_call_init(vresult, argc, argv); + rb_obj_call_init(vresult, argc, argv); #endif - return vresult; - } - + return vresult; +} + SWIGINTERN VALUE _wrap_new_StringHandler(int argc, VALUE *argv, VALUE self) { @@ -2271,7 +2312,8 @@ _wrap_StringHandler_render(int argc, VALUE *argv, VALUE self) { SWIGINTERN void -free_TagLib_ID3v1_StringHandler(TagLib::ID3v1::StringHandler *arg1) { +free_TagLib_ID3v1_StringHandler(void *self) { + TagLib::ID3v1::StringHandler *arg1 = (TagLib::ID3v1::StringHandler *)self; SWIG_RubyRemoveTracking(arg1); delete arg1; } @@ -2294,22 +2336,20 @@ _wrap_new_Tag__SWIG_0(int argc, VALUE *argv, VALUE self) { } -#ifdef HAVE_RB_DEFINE_ALLOC_FUNC SWIGINTERN VALUE -_wrap_Tag_allocate(VALUE self) { +#ifdef HAVE_RB_DEFINE_ALLOC_FUNC +_wrap_Tag_allocate(VALUE self) #else - SWIGINTERN VALUE - _wrap_Tag_allocate(int argc, VALUE *argv, VALUE self) { +_wrap_Tag_allocate(int argc, VALUE *argv, VALUE self) #endif - - - VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__ID3v1__Tag); +{ + VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__ID3v1__Tag); #ifndef HAVE_RB_DEFINE_ALLOC_FUNC - rb_obj_call_init(vresult, argc, argv); + rb_obj_call_init(vresult, argc, argv); #endif - return vresult; - } - + return vresult; +} + SWIGINTERN VALUE _wrap_new_Tag__SWIG_1(int argc, VALUE *argv, VALUE self) { @@ -2382,7 +2422,8 @@ SWIGINTERN VALUE _wrap_new_Tag(int nargs, VALUE *args, VALUE self) { SWIGINTERN void -free_TagLib_ID3v1_Tag(TagLib::ID3v1::Tag *arg1) { +free_TagLib_ID3v1_Tag(void *self) { + TagLib::ID3v1::Tag *arg1 = (TagLib::ID3v1::Tag *)self; SWIG_RubyRemoveTracking(arg1); delete arg1; } @@ -3117,7 +3158,7 @@ SWIG_InitializeModule(void *clientdata) { /* Now work on filling in swig_module.types */ #ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: size %d\n", swig_module.size); + printf("SWIG_InitializeModule: size %lu\n", (unsigned long)swig_module.size); #endif for (i = 0; i < swig_module.size; ++i) { swig_type_info *type = 0; @@ -3125,7 +3166,7 @@ SWIG_InitializeModule(void *clientdata) { swig_cast_info *cast; #ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); + printf("SWIG_InitializeModule: type %lu %s\n", (unsigned long)i, swig_module.type_initial[i]->name); #endif /* if there is another module already loaded */ @@ -3201,7 +3242,7 @@ SWIG_InitializeModule(void *clientdata) { for (i = 0; i < swig_module.size; ++i) { int j = 0; swig_cast_info *cast = swig_module.cast_initial[i]; - printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); + printf("SWIG_InitializeModule: type %lu %s\n", (unsigned long)i, swig_module.type_initial[i]->name); while (cast->type) { printf("SWIG_InitializeModule: cast type %s\n", cast->type->name); cast++; diff --git a/ext/taglib_id3v2/taglib_id3v2_wrap.cxx b/ext/taglib_id3v2/taglib_id3v2_wrap.cxx index d3cf0da..563754c 100644 --- a/ext/taglib_id3v2/taglib_id3v2_wrap.cxx +++ b/ext/taglib_id3v2/taglib_id3v2_wrap.cxx @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 3.0.7 + * Version 4.0.2 * * This file is not intended to be easily readable and contains a number of * coding conventions designed to improve portability and efficiency. Do not make @@ -8,7 +8,11 @@ * interface file instead. * ----------------------------------------------------------------------------- */ + +#ifndef SWIGRUBY #define SWIGRUBY +#endif + #ifdef __cplusplus @@ -101,9 +105,11 @@ template T SwigValueInit() { #endif /* exporting methods */ -#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) -# ifndef GCC_HASCLASSVISIBILITY -# define GCC_HASCLASSVISIBILITY +#if defined(__GNUC__) +# if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +# ifndef GCC_HASCLASSVISIBILITY +# define GCC_HASCLASSVISIBILITY +# endif # endif #endif @@ -223,9 +229,11 @@ template T SwigValueInit() { #endif /* exporting methods */ -#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) -# ifndef GCC_HASCLASSVISIBILITY -# define GCC_HASCLASSVISIBILITY +#if defined(__GNUC__) +# if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +# ifndef GCC_HASCLASSVISIBILITY +# define GCC_HASCLASSVISIBILITY +# endif # endif #endif @@ -323,6 +331,7 @@ template T SwigValueInit() { /* Flags for pointer conversions */ #define SWIG_POINTER_DISOWN 0x1 #define SWIG_CAST_NEW_MEMORY 0x2 +#define SWIG_POINTER_NO_NULL 0x4 /* Flags for new pointer objects */ #define SWIG_POINTER_OWN 0x1 @@ -775,16 +784,16 @@ SWIG_UnpackData(const char *c, void *ptr, size_t sz) { char d = *(c++); unsigned char uu; if ((d >= '0') && (d <= '9')) - uu = ((d - '0') << 4); + uu = (unsigned char)((d - '0') << 4); else if ((d >= 'a') && (d <= 'f')) - uu = ((d - ('a'-10)) << 4); + uu = (unsigned char)((d - ('a'-10)) << 4); else return (char *) 0; d = *(c++); if ((d >= '0') && (d <= '9')) - uu |= (d - '0'); + uu |= (unsigned char)(d - '0'); else if ((d >= 'a') && (d <= 'f')) - uu |= (d - ('a'-10)); + uu |= (unsigned char)(d - ('a'-10)); else return (char *) 0; *u = uu; @@ -961,42 +970,53 @@ SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { #ifndef RSTRUCT_PTR # define RSTRUCT_PTR(x) RSTRUCT(x)->ptr #endif +#ifndef RTYPEDDATA_P +# define RTYPEDDATA_P(x) (TYPE(x) != T_DATA) +#endif /* - * Need to be very careful about how these macros are defined, especially - * when compiling C++ code or C code with an ANSI C compiler. + * The following macros are used for providing the correct type of a + * function pointer to the Ruby C API. + * Starting with Ruby 2.7 (corresponding to RB_METHOD_DEFINITION_DECL being + * defined) these macros act transparently due to Ruby's moving away from + * ANYARGS and instead employing strict function signatures. + * + * Note: In case of C (not C++) the macros are transparent even before + * Ruby 2.7 due to the fact that the Ruby C API used function declarators + * with empty parentheses, which allows for an unspecified number of + * arguments. + * + * PROTECTFUNC(f) is used for the function pointer argument of the Ruby + * C API function rb_protect(). * - * VALUEFUNC(f) is a macro used to typecast a C function that implements - * a Ruby method so that it can be passed as an argument to API functions - * like rb_define_method() and rb_define_singleton_method(). + * VALUEFUNC(f) is used for the function pointer argument(s) of Ruby C API + * functions like rb_define_method() and rb_define_singleton_method(). * - * VOIDFUNC(f) is a macro used to typecast a C function that implements - * either the "mark" or "free" stuff for a Ruby Data object, so that it - * can be passed as an argument to API functions like Data_Wrap_Struct() + * VOIDFUNC(f) is used to typecast a C function that implements either + * the "mark" or "free" stuff for a Ruby Data object, so that it can be + * passed as an argument to Ruby C API functions like Data_Wrap_Struct() * and Data_Make_Struct(). + * + * SWIG_RUBY_VOID_ANYARGS_FUNC(f) is used for the function pointer + * argument(s) of Ruby C API functions like rb_define_virtual_variable(). + * + * SWIG_RUBY_INT_ANYARGS_FUNC(f) is used for the function pointer + * argument(s) of Ruby C API functions like st_foreach(). */ - -#ifdef __cplusplus -# ifndef RUBY_METHOD_FUNC /* These definitions should work for Ruby 1.4.6 */ -# define PROTECTFUNC(f) ((VALUE (*)()) f) -# define VALUEFUNC(f) ((VALUE (*)()) f) -# define VOIDFUNC(f) ((void (*)()) f) -# else -# ifndef ANYARGS /* These definitions should work for Ruby 1.6 */ -# define PROTECTFUNC(f) ((VALUE (*)()) f) -# define VALUEFUNC(f) ((VALUE (*)()) f) -# define VOIDFUNC(f) ((RUBY_DATA_FUNC) f) -# else /* These definitions should work for Ruby 1.7+ */ -# define PROTECTFUNC(f) ((VALUE (*)(VALUE)) f) -# define VALUEFUNC(f) ((VALUE (*)(ANYARGS)) f) -# define VOIDFUNC(f) ((RUBY_DATA_FUNC) f) -# endif -# endif +#if defined(__cplusplus) && !defined(RB_METHOD_DEFINITION_DECL) +# define PROTECTFUNC(f) ((VALUE (*)(VALUE)) f) +# define VALUEFUNC(f) ((VALUE (*)(ANYARGS)) f) +# define VOIDFUNC(f) ((RUBY_DATA_FUNC) f) +# define SWIG_RUBY_VOID_ANYARGS_FUNC(f) ((void (*)(ANYARGS))(f)) +# define SWIG_RUBY_INT_ANYARGS_FUNC(f) ((int (*)(ANYARGS))(f)) #else +# define PROTECTFUNC(f) (f) # define VALUEFUNC(f) (f) # define VOIDFUNC(f) (f) +# define SWIG_RUBY_VOID_ANYARGS_FUNC(f) (f) +# define SWIG_RUBY_INT_ANYARGS_FUNC(f) (f) #endif /* Don't use for expressions have side effect */ @@ -1184,7 +1204,7 @@ void Ruby_Format_OverloadedError( /* ----------------------------------------------------------------------------- * rubytracking.swg * - * This file contains support for tracking mappings from + * This file contains support for tracking mappings from * Ruby objects to C++ objects. This functionality is needed * to implement mark functions for Ruby's mark and sweep * garbage collector. @@ -1194,6 +1214,11 @@ void Ruby_Format_OverloadedError( extern "C" { #endif +#if !defined(ST_DATA_T_DEFINED) +/* Needs to be explicitly included for Ruby 1.8 and earlier */ +#include +#endif + /* Ruby 1.8 actually assumes the first case. */ #if SIZEOF_VOIDP == SIZEOF_LONG # define SWIG2NUM(v) LONG2NUM((unsigned long)v) @@ -1205,109 +1230,69 @@ extern "C" { # error sizeof(void*) is not the same as long or long long #endif - -/* Global Ruby hash table to store Trackings from C/C++ - structs to Ruby Objects. +/* Global hash table to store Trackings from C/C++ + structs to Ruby Objects. */ -static VALUE swig_ruby_trackings = Qnil; +static st_table* swig_ruby_trackings = NULL; + +static VALUE swig_ruby_trackings_count(ID id, VALUE *var) { + return SWIG2NUM(swig_ruby_trackings->num_entries); +} -/* Global variable that stores a reference to the ruby - hash table delete function. */ -static ID swig_ruby_hash_delete; -/* Setup a Ruby hash table to store Trackings */ +/* Setup a hash table to store Trackings */ SWIGRUNTIME void SWIG_RubyInitializeTrackings(void) { - /* Create a ruby hash table to store Trackings from C++ + /* Create a hash table to store Trackings from C++ objects to Ruby objects. */ - /* Try to see if some other .so has already created a + /* Try to see if some other .so has already created a tracking hash table, which we keep hidden in an instance var in the SWIG module. This is done to allow multiple DSOs to share the same tracking table. */ - ID trackings_id = rb_intern( "@__trackings__" ); + VALUE trackings_value = Qnil; + /* change the variable name so that we can mix modules + compiled with older SWIG's - this used to be called "@__trackings__" */ + ID trackings_id = rb_intern( "@__safetrackings__" ); VALUE verbose = rb_gv_get("VERBOSE"); rb_gv_set("VERBOSE", Qfalse); - swig_ruby_trackings = rb_ivar_get( _mSWIG, trackings_id ); + trackings_value = rb_ivar_get( _mSWIG, trackings_id ); rb_gv_set("VERBOSE", verbose); - /* No, it hasn't. Create one ourselves */ - if ( swig_ruby_trackings == Qnil ) - { - swig_ruby_trackings = rb_hash_new(); - rb_ivar_set( _mSWIG, trackings_id, swig_ruby_trackings ); - } - - /* Now store a reference to the hash table delete function - so that we only have to look it up once.*/ - swig_ruby_hash_delete = rb_intern("delete"); -} - -/* Get a Ruby number to reference a pointer */ -SWIGRUNTIME VALUE SWIG_RubyPtrToReference(void* ptr) { - /* We cast the pointer to an unsigned long - and then store a reference to it using - a Ruby number object. */ - - /* Convert the pointer to a Ruby number */ - return SWIG2NUM(ptr); -} - -/* Get a Ruby number to reference an object */ -SWIGRUNTIME VALUE SWIG_RubyObjectToReference(VALUE object) { - /* We cast the object to an unsigned long - and then store a reference to it using - a Ruby number object. */ - - /* Convert the Object to a Ruby number */ - return SWIG2NUM(object); -} - -/* Get a Ruby object from a previously stored reference */ -SWIGRUNTIME VALUE SWIG_RubyReferenceToObject(VALUE reference) { - /* The provided Ruby number object is a reference - to the Ruby object we want.*/ + /* The trick here is that we have to store the hash table + pointer in a Ruby variable. We do not want Ruby's GC to + treat this pointer as a Ruby object, so we convert it to + a Ruby numeric value. */ + if (trackings_value == Qnil) { + /* No, it hasn't. Create one ourselves */ + swig_ruby_trackings = st_init_numtable(); + rb_ivar_set( _mSWIG, trackings_id, SWIG2NUM(swig_ruby_trackings) ); + } else { + swig_ruby_trackings = (st_table*)NUM2SWIG(trackings_value); + } - /* Convert the Ruby number to a Ruby object */ - return NUM2SWIG(reference); + rb_define_virtual_variable("SWIG_TRACKINGS_COUNT", + VALUEFUNC(swig_ruby_trackings_count), + SWIG_RUBY_VOID_ANYARGS_FUNC((rb_gvar_setter_t*)NULL)); } /* Add a Tracking from a C/C++ struct to a Ruby object */ SWIGRUNTIME void SWIG_RubyAddTracking(void* ptr, VALUE object) { - /* In a Ruby hash table we store the pointer and - the associated Ruby object. The trick here is - that we cannot store the Ruby object directly - if - we do then it cannot be garbage collected. So - instead we typecast it as a unsigned long and - convert it to a Ruby number object.*/ - - /* Get a reference to the pointer as a Ruby number */ - VALUE key = SWIG_RubyPtrToReference(ptr); - - /* Get a reference to the Ruby object as a Ruby number */ - VALUE value = SWIG_RubyObjectToReference(object); - /* Store the mapping to the global hash table. */ - rb_hash_aset(swig_ruby_trackings, key, value); + st_insert(swig_ruby_trackings, (st_data_t)ptr, object); } /* Get the Ruby object that owns the specified C/C++ struct */ SWIGRUNTIME VALUE SWIG_RubyInstanceFor(void* ptr) { - /* Get a reference to the pointer as a Ruby number */ - VALUE key = SWIG_RubyPtrToReference(ptr); - /* Now lookup the value stored in the global hash table */ - VALUE value = rb_hash_aref(swig_ruby_trackings, key); - - if (value == Qnil) { - /* No object exists - return nil. */ + VALUE value; + + if (st_lookup(swig_ruby_trackings, (st_data_t)ptr, &value)) { + return value; + } else { return Qnil; } - else { - /* Convert this value to Ruby object */ - return SWIG_RubyReferenceToObject(value); - } } /* Remove a Tracking from a C/C++ struct to a Ruby object. It @@ -1315,25 +1300,39 @@ SWIGRUNTIME VALUE SWIG_RubyInstanceFor(void* ptr) { since the same memory address may be reused later to create a new object. */ SWIGRUNTIME void SWIG_RubyRemoveTracking(void* ptr) { - /* Get a reference to the pointer as a Ruby number */ - VALUE key = SWIG_RubyPtrToReference(ptr); - - /* Delete the object from the hash table by calling Ruby's - do this we need to call the Hash.delete method.*/ - rb_funcall(swig_ruby_trackings, swig_ruby_hash_delete, 1, key); + /* Delete the object from the hash table */ + st_delete(swig_ruby_trackings, (st_data_t *)&ptr, NULL); } /* This is a helper method that unlinks a Ruby object from its underlying C++ object. This is needed if the lifetime of the - Ruby object is longer than the C++ object */ + Ruby object is longer than the C++ object. */ SWIGRUNTIME void SWIG_RubyUnlinkObjects(void* ptr) { VALUE object = SWIG_RubyInstanceFor(ptr); if (object != Qnil) { + // object might have the T_ZOMBIE type, but that's just + // because the GC has flagged it as such for a deferred + // destruction. Until then, it's still a T_DATA object. DATA_PTR(object) = 0; } } +/* This is a helper method that iterates over all the trackings + passing the C++ object pointer and its related Ruby object + to the passed callback function. */ + +/* Proxy method to abstract the internal trackings datatype */ +static int swig_ruby_internal_iterate_callback(st_data_t ptr, st_data_t obj, st_data_t meth) { + ((void (*) (void *, VALUE))meth)((void *)ptr, (VALUE)obj); + return ST_CONTINUE; +} + +SWIGRUNTIME void SWIG_RubyIterateTrackings( void(*meth)(void* ptr, VALUE obj) ) { + st_foreach(swig_ruby_trackings, + SWIG_RUBY_INT_ANYARGS_FUNC(swig_ruby_internal_iterate_callback), + (st_data_t)meth); +} #ifdef __cplusplus } @@ -1392,7 +1391,7 @@ SWIG_Ruby_AppendOutput(VALUE target, VALUE o) { #define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Ruby_ConvertPtrAndOwn(obj, pptr, type, flags, own) #define SWIG_NewPointerObj(ptr, type, flags) SWIG_Ruby_NewPointerObj(ptr, type, flags) #define SWIG_AcquirePtr(ptr, own) SWIG_Ruby_AcquirePtr(ptr, own) -#define swig_owntype ruby_owntype +#define swig_owntype swig_ruby_owntype /* for raw packed data */ #define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Ruby_ConvertPacked(obj, ptr, sz, ty, flags) @@ -1549,10 +1548,11 @@ SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags) swig_class *sklass; VALUE klass; VALUE obj; - + if (!ptr) return Qnil; - + + assert(type); if (type->clientdata) { sklass = (swig_class *) type->clientdata; @@ -1560,7 +1560,7 @@ SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags) track = sklass->trackObjects; if (track) { obj = SWIG_RubyInstanceFor(ptr); - + /* Check the object's type and make sure it has the correct type. It might not in cases where methods do things like downcast methods. */ @@ -1592,7 +1592,7 @@ SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags) obj = Data_Wrap_Struct(klass, 0, 0, ptr); } rb_iv_set(obj, "@__swigtype__", rb_str_new2(type->name)); - + return obj; } @@ -1612,26 +1612,30 @@ SWIGRUNTIMEINLINE char * SWIG_Ruby_MangleStr(VALUE obj) { VALUE stype = rb_iv_get(obj, "@__swigtype__"); + if (NIL_P(stype)) + return NULL; return StringValuePtr(stype); } /* Acquire a pointer value */ -typedef void (*ruby_owntype)(void*); - -SWIGRUNTIME ruby_owntype -SWIG_Ruby_AcquirePtr(VALUE obj, ruby_owntype own) { - if (obj) { - ruby_owntype oldown = RDATA(obj)->dfree; - RDATA(obj)->dfree = own; - return oldown; - } else { - return 0; +typedef struct { + void (*datafree)(void *); + int own; +} swig_ruby_owntype; + +SWIGRUNTIME swig_ruby_owntype +SWIG_Ruby_AcquirePtr(VALUE obj, swig_ruby_owntype own) { + swig_ruby_owntype oldown = {0, 0}; + if (TYPE(obj) == T_DATA && !RTYPEDDATA_P(obj)) { + oldown.datafree = RDATA(obj)->dfree; + RDATA(obj)->dfree = own.datafree; } + return oldown; } /* Convert a pointer value */ SWIGRUNTIME int -SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, ruby_owntype *own) +SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, swig_ruby_owntype *own) { char *c; swig_cast_info *tc; @@ -1639,16 +1643,20 @@ SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, /* Grab the pointer */ if (NIL_P(obj)) { - *ptr = 0; - return SWIG_OK; + if (ptr) + *ptr = 0; + return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK; } else { - if (TYPE(obj) != T_DATA) { + if (TYPE(obj) != T_DATA || (TYPE(obj) == T_DATA && RTYPEDDATA_P(obj))) { return SWIG_ERROR; } Data_Get_Struct(obj, void, vptr); } - if (own) *own = RDATA(obj)->dfree; + if (own) { + own->datafree = RDATA(obj)->dfree; + own->own = 0; + } /* Check to see if the input object is giving up ownership of the underlying C struct or C++ object. If so then we @@ -1683,8 +1691,6 @@ SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, /* The object has already been deleted */ return SWIG_ObjectPreviouslyDeletedError; } - *ptr = vptr; - return SWIG_OK; } } if ((c = SWIG_MangleStr(obj)) == NULL) { @@ -1694,12 +1700,23 @@ SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, if (!tc) { return SWIG_ERROR; } else { - int newmemory = 0; - *ptr = SWIG_TypeCast(tc, vptr, &newmemory); - assert(!newmemory); /* newmemory handling not yet implemented */ + if (ptr) { + if (tc->type == ty) { + *ptr = vptr; + } else { + int newmemory = 0; + *ptr = SWIG_TypeCast(tc, vptr, &newmemory); + if (newmemory == SWIG_CAST_NEW_MEMORY) { + assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */ + if (own) + own->own = own->own | SWIG_CAST_NEW_MEMORY; + } + } + } } } else { - *ptr = vptr; + if (ptr) + *ptr = vptr; } return SWIG_OK; @@ -1725,7 +1742,7 @@ SWIG_Ruby_NewPackedObj(void *ptr, int sz, swig_type_info *type) { return rb_str_new2(result); } -/* Convert a packed value value */ +/* Convert a packed pointer value */ SWIGRUNTIME int SWIG_Ruby_ConvertPacked(VALUE obj, void *ptr, int sz, swig_type_info *ty) { swig_cast_info *tc; @@ -1878,7 +1895,7 @@ static VALUE mID3v2; #define SWIG_RUBY_THREAD_END_BLOCK -#define SWIGVERSION 0x030007 +#define SWIGVERSION 0x040002 #define SWIG_VERSION SWIGVERSION @@ -2118,7 +2135,7 @@ SWIG_AsCharPtrAndSize(VALUE obj, char** cptr, size_t* psize, int *alloc) if (cptr) { if (alloc) { if (*alloc == SWIG_NEWOBJ) { - *cptr = reinterpret_cast< char* >(memcpy((new char[size]), cstr, sizeof(char)*(size))); + *cptr = reinterpret_cast< char* >(memcpy(new char[size], cstr, sizeof(char)*(size))); } else { *cptr = cstr; *alloc = SWIG_OLDOBJ; @@ -2174,15 +2191,16 @@ SWIG_From_unsigned_SS_int (unsigned int value) SWIGINTERN VALUE -SWIG_ruby_failed(void) +SWIG_ruby_failed(VALUE SWIGUNUSEDPARM(arg1), VALUE SWIGUNUSEDPARM(arg2)) { return Qnil; } -/*@SWIG:/usr/local/share/swig/3.0.7/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/ -SWIGINTERN VALUE SWIG_AUX_NUM2ULONG(VALUE *args) +/*@SWIG:/usr/local/Cellar/swig/4.0.2/share/swig/4.0.2/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/ +SWIGINTERN VALUE SWIG_AUX_NUM2ULONG(VALUE arg) { + VALUE *args = (VALUE *)arg; VALUE obj = args[0]; VALUE type = TYPE(obj); unsigned long *res = (unsigned long *)(args[1]); @@ -2200,7 +2218,7 @@ SWIG_AsVal_unsigned_SS_long (VALUE obj, unsigned long *val) VALUE a[2]; a[0] = obj; a[1] = (VALUE)(&v); - if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2ULONG), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) { + if (rb_rescue(VALUEFUNC(SWIG_AUX_NUM2ULONG), (VALUE)a, VALUEFUNC(SWIG_ruby_failed), 0) != Qnil) { if (val) *val = v; return SWIG_OK; } @@ -2232,9 +2250,10 @@ SWIG_From_bool (bool value) } -/*@SWIG:/usr/local/share/swig/3.0.7/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/ -SWIGINTERN VALUE SWIG_AUX_NUM2LONG(VALUE *args) +/*@SWIG:/usr/local/Cellar/swig/4.0.2/share/swig/4.0.2/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/ +SWIGINTERN VALUE SWIG_AUX_NUM2LONG(VALUE arg) { + VALUE *args = (VALUE *)arg; VALUE obj = args[0]; VALUE type = TYPE(obj); long *res = (long *)(args[1]); @@ -2252,7 +2271,7 @@ SWIG_AsVal_long (VALUE obj, long* val) VALUE a[2]; a[0] = obj; a[1] = (VALUE)(&v); - if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2LONG), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) { + if (rb_rescue(VALUEFUNC(SWIG_AUX_NUM2LONG), (VALUE)a, VALUEFUNC(SWIG_ruby_failed), 0) != Qnil) { if (val) *val = v; return SWIG_OK; } @@ -2345,8 +2364,31 @@ SWIG_From_float (float value) /* Getting isfinite working pre C99 across multiple platforms is non-trivial. Users can provide SWIG_isfinite on older platforms. */ #ifndef SWIG_isfinite +/* isfinite() is a macro for C99 */ # if defined(isfinite) # define SWIG_isfinite(X) (isfinite(X)) +# elif defined(__cplusplus) && __cplusplus >= 201103L +/* Use a template so that this works whether isfinite() is std::isfinite() or + * in the global namespace. The reality seems to vary between compiler + * versions. + * + * Make sure namespace std exists to avoid compiler warnings. + * + * extern "C++" is required as this fragment can end up inside an extern "C" { } block + */ +namespace std { } +extern "C++" template +inline int SWIG_isfinite_func(T x) { + using namespace std; + return isfinite(x); +} +# define SWIG_isfinite(X) (SWIG_isfinite_func(X)) +# elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)) +# define SWIG_isfinite(X) (__builtin_isfinite(X)) +# elif defined(__clang__) && defined(__has_builtin) +# if __has_builtin(__builtin_isfinite) +# define SWIG_isfinite(X) (__builtin_isfinite(X)) +# endif # elif defined(_MSC_VER) # define SWIG_isfinite(X) (_finite(X)) # elif defined(__sun) && defined(__SVR4) @@ -2364,9 +2406,10 @@ SWIG_From_float (float value) #endif -/*@SWIG:/usr/local/share/swig/3.0.7/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/ -SWIGINTERN VALUE SWIG_AUX_NUM2DBL(VALUE *args) +/*@SWIG:/usr/local/Cellar/swig/4.0.2/share/swig/4.0.2/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/ +SWIGINTERN VALUE SWIG_AUX_NUM2DBL(VALUE arg) { + VALUE *args = (VALUE *)arg; VALUE obj = args[0]; VALUE type = TYPE(obj); double *res = (double *)(args[1]); @@ -2384,7 +2427,7 @@ SWIG_AsVal_double (VALUE obj, double *val) VALUE a[2]; a[0] = obj; a[1] = (VALUE)(&v); - if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2DBL), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) { + if (rb_rescue(VALUEFUNC(SWIG_AUX_NUM2DBL), (VALUE)a, VALUEFUNC(SWIG_ruby_failed), 0) != Qnil) { if (val) *val = v; return SWIG_OK; } @@ -2449,22 +2492,20 @@ _wrap_new_Header__SWIG_0(int argc, VALUE *argv, VALUE self) { } -#ifdef HAVE_RB_DEFINE_ALLOC_FUNC SWIGINTERN VALUE -_wrap_Header_allocate(VALUE self) { +#ifdef HAVE_RB_DEFINE_ALLOC_FUNC +_wrap_Header_allocate(VALUE self) #else - SWIGINTERN VALUE - _wrap_Header_allocate(int argc, VALUE *argv, VALUE self) { +_wrap_Header_allocate(int argc, VALUE *argv, VALUE self) #endif - - - VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__ID3v2__Header); +{ + VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__ID3v2__Header); #ifndef HAVE_RB_DEFINE_ALLOC_FUNC - rb_obj_call_init(vresult, argc, argv); + rb_obj_call_init(vresult, argc, argv); #endif - return vresult; - } - + return vresult; +} + SWIGINTERN VALUE _wrap_new_Header__SWIG_1(int argc, VALUE *argv, VALUE self) { @@ -2520,7 +2561,8 @@ SWIGINTERN VALUE _wrap_new_Header(int nargs, VALUE *args, VALUE self) { SWIGINTERN void -free_TagLib_ID3v2_Header(TagLib::ID3v2::Header *arg1) { +free_TagLib_ID3v2_Header(void *self) { + TagLib::ID3v2::Header *arg1 = (TagLib::ID3v2::Header *)self; SWIG_RubyRemoveTracking(arg1); delete arg1; } @@ -2775,7 +2817,6 @@ _wrap_Header_tag_sizee___(int argc, VALUE *argv, VALUE self) { } - /* Document-method: TagLib::ID3v2::Header.size @@ -2874,7 +2915,8 @@ _wrap_Header_render(int argc, VALUE *argv, VALUE self) { static swig_class SwigClassFrame; SWIGINTERN void -free_TagLib_ID3v2_Frame(TagLib::ID3v2::Frame *arg1) { +free_TagLib_ID3v2_Frame(void *self) { + TagLib::ID3v2::Frame *arg1 = (TagLib::ID3v2::Frame *)self; SWIG_RubyRemoveTracking(arg1); delete arg1; } @@ -2905,7 +2947,6 @@ _wrap_Frame_frame_id(int argc, VALUE *argv, VALUE self) { } - /* Document-method: TagLib::ID3v2::Frame.size @@ -3128,22 +3169,20 @@ _wrap_new_Tag__SWIG_1(int argc, VALUE *argv, VALUE self) { } -#ifdef HAVE_RB_DEFINE_ALLOC_FUNC SWIGINTERN VALUE -_wrap_Tag_allocate(VALUE self) { +#ifdef HAVE_RB_DEFINE_ALLOC_FUNC +_wrap_Tag_allocate(VALUE self) #else - SWIGINTERN VALUE - _wrap_Tag_allocate(int argc, VALUE *argv, VALUE self) { +_wrap_Tag_allocate(int argc, VALUE *argv, VALUE self) #endif - - - VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__ID3v2__Tag); +{ + VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__ID3v2__Tag); #ifndef HAVE_RB_DEFINE_ALLOC_FUNC - rb_obj_call_init(vresult, argc, argv); + rb_obj_call_init(vresult, argc, argv); #endif - return vresult; - } - + return vresult; +} + SWIGINTERN VALUE _wrap_new_Tag__SWIG_2(int argc, VALUE *argv, VALUE self) { @@ -3237,7 +3276,8 @@ SWIGINTERN VALUE _wrap_new_Tag(int nargs, VALUE *args, VALUE self) { SWIGINTERN void -free_TagLib_ID3v2_Tag(TagLib::ID3v2::Tag *arg1) { +free_TagLib_ID3v2_Tag(void *self) { + TagLib::ID3v2::Tag *arg1 = (TagLib::ID3v2::Tag *)self; SWIG_RubyRemoveTracking(arg1); delete arg1; } @@ -3827,7 +3867,7 @@ SWIGINTERN VALUE _wrap_Tag_frame_list(int nargs, VALUE *args, VALUE self) { fail: Ruby_Format_OverloadedError( argc, 3, "Tag.frame_list", - " TagLib::ID3v2::FrameList const & Tag.frame_list()\n" + " TagLib::ID3v2::FrameList const Tag.frame_list()\n" " TagLib::ID3v2::FrameList const & Tag.frame_list(TagLib::ByteVector const &frameID)\n"); return Qnil; @@ -4164,9 +4204,9 @@ SWIGINTERN VALUE _wrap_FrameFactory_create_frame(int nargs, VALUE *args, VALUE s fail: Ruby_Format_OverloadedError( argc, 4, "FrameFactory.create_frame", - " TagLib::ID3v2::Frame * FrameFactory.create_frame(TagLib::ByteVector const &data, bool synchSafeInts)\n" - " TagLib::ID3v2::Frame * FrameFactory.create_frame(TagLib::ByteVector const &data, unsigned int version)\n" - " TagLib::ID3v2::Frame * FrameFactory.create_frame(TagLib::ByteVector const &data)\n" + " TagLib::ID3v2::Frame FrameFactory.create_frame(TagLib::ByteVector const &data, bool synchSafeInts)\n" + " TagLib::ID3v2::Frame FrameFactory.create_frame(TagLib::ByteVector const &data, unsigned int version)\n" + " TagLib::ID3v2::Frame FrameFactory.create_frame(TagLib::ByteVector const &data)\n" " TagLib::ID3v2::Frame * FrameFactory.create_frame(TagLib::ByteVector const &data, TagLib::ID3v2::Header *tagHeader)\n"); return Qnil; @@ -4244,22 +4284,20 @@ _wrap_new_RelativeVolumeFrame__SWIG_0(int argc, VALUE *argv, VALUE self) { } -#ifdef HAVE_RB_DEFINE_ALLOC_FUNC SWIGINTERN VALUE -_wrap_RelativeVolumeFrame_allocate(VALUE self) { +#ifdef HAVE_RB_DEFINE_ALLOC_FUNC +_wrap_RelativeVolumeFrame_allocate(VALUE self) #else - SWIGINTERN VALUE - _wrap_RelativeVolumeFrame_allocate(int argc, VALUE *argv, VALUE self) { +_wrap_RelativeVolumeFrame_allocate(int argc, VALUE *argv, VALUE self) #endif - - - VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__ID3v2__RelativeVolumeFrame); +{ + VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__ID3v2__RelativeVolumeFrame); #ifndef HAVE_RB_DEFINE_ALLOC_FUNC - rb_obj_call_init(vresult, argc, argv); + rb_obj_call_init(vresult, argc, argv); #endif - return vresult; - } - + return vresult; +} + SWIGINTERN VALUE _wrap_new_RelativeVolumeFrame__SWIG_1(int argc, VALUE *argv, VALUE self) { @@ -4315,7 +4353,8 @@ SWIGINTERN VALUE _wrap_new_RelativeVolumeFrame(int nargs, VALUE *args, VALUE sel SWIGINTERN void -free_TagLib_ID3v2_RelativeVolumeFrame(TagLib::ID3v2::RelativeVolumeFrame *arg1) { +free_TagLib_ID3v2_RelativeVolumeFrame(void *self) { + TagLib::ID3v2::RelativeVolumeFrame *arg1 = (TagLib::ID3v2::RelativeVolumeFrame *)self; SWIG_RubyRemoveTracking(arg1); delete arg1; } @@ -5070,7 +5109,7 @@ SWIGINTERN VALUE _wrap_RelativeVolumeFrame_set_peak_volume(int nargs, VALUE *arg _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; - int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_TagLib__ID3v2__RelativeVolumeFrame__PeakVolume, 0); + int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_TagLib__ID3v2__RelativeVolumeFrame__PeakVolume, SWIG_POINTER_NO_NULL); _v = SWIG_CheckState(res); if (_v) { return _wrap_RelativeVolumeFrame_set_peak_volume__SWIG_1(nargs, args, self); @@ -5084,7 +5123,7 @@ SWIGINTERN VALUE _wrap_RelativeVolumeFrame_set_peak_volume(int nargs, VALUE *arg _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; - int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_TagLib__ID3v2__RelativeVolumeFrame__PeakVolume, 0); + int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_TagLib__ID3v2__RelativeVolumeFrame__PeakVolume, SWIG_POINTER_NO_NULL); _v = SWIG_CheckState(res); if (_v) { { @@ -5162,22 +5201,20 @@ _wrap_RelativeVolumeFrame_identificatione___(int argc, VALUE *argv, VALUE self) static swig_class SwigClassPeakVolume; -#ifdef HAVE_RB_DEFINE_ALLOC_FUNC SWIGINTERN VALUE -_wrap_PeakVolume_allocate(VALUE self) { +#ifdef HAVE_RB_DEFINE_ALLOC_FUNC +_wrap_PeakVolume_allocate(VALUE self) #else - SWIGINTERN VALUE - _wrap_PeakVolume_allocate(int argc, VALUE *argv, VALUE self) { +_wrap_PeakVolume_allocate(int argc, VALUE *argv, VALUE self) #endif - - - VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__ID3v2__RelativeVolumeFrame__PeakVolume); +{ + VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__ID3v2__RelativeVolumeFrame__PeakVolume); #ifndef HAVE_RB_DEFINE_ALLOC_FUNC - rb_obj_call_init(vresult, argc, argv); + rb_obj_call_init(vresult, argc, argv); #endif - return vresult; - } - + return vresult; +} + SWIGINTERN VALUE _wrap_new_PeakVolume(int argc, VALUE *argv, VALUE self) { @@ -5302,7 +5339,8 @@ _wrap_PeakVolume_peak_volume_get(int argc, VALUE *argv, VALUE self) { SWIGINTERN void -free_TagLib_ID3v2_RelativeVolumeFrame_PeakVolume(TagLib::ID3v2::RelativeVolumeFrame::PeakVolume *arg1) { +free_TagLib_ID3v2_RelativeVolumeFrame_PeakVolume(void *self) { + TagLib::ID3v2::RelativeVolumeFrame::PeakVolume *arg1 = (TagLib::ID3v2::RelativeVolumeFrame::PeakVolume *)self; SWIG_RubyRemoveTracking(arg1); delete arg1; } @@ -5325,22 +5363,20 @@ _wrap_new_AttachedPictureFrame__SWIG_0(int argc, VALUE *argv, VALUE self) { } -#ifdef HAVE_RB_DEFINE_ALLOC_FUNC SWIGINTERN VALUE -_wrap_AttachedPictureFrame_allocate(VALUE self) { +#ifdef HAVE_RB_DEFINE_ALLOC_FUNC +_wrap_AttachedPictureFrame_allocate(VALUE self) #else - SWIGINTERN VALUE - _wrap_AttachedPictureFrame_allocate(int argc, VALUE *argv, VALUE self) { +_wrap_AttachedPictureFrame_allocate(int argc, VALUE *argv, VALUE self) #endif - - - VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__ID3v2__AttachedPictureFrame); +{ + VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__ID3v2__AttachedPictureFrame); #ifndef HAVE_RB_DEFINE_ALLOC_FUNC - rb_obj_call_init(vresult, argc, argv); + rb_obj_call_init(vresult, argc, argv); #endif - return vresult; - } - + return vresult; +} + SWIGINTERN VALUE _wrap_new_AttachedPictureFrame__SWIG_1(int argc, VALUE *argv, VALUE self) { @@ -5396,7 +5432,8 @@ SWIGINTERN VALUE _wrap_new_AttachedPictureFrame(int nargs, VALUE *args, VALUE se SWIGINTERN void -free_TagLib_ID3v2_AttachedPictureFrame(TagLib::ID3v2::AttachedPictureFrame *arg1) { +free_TagLib_ID3v2_AttachedPictureFrame(void *self) { + TagLib::ID3v2::AttachedPictureFrame *arg1 = (TagLib::ID3v2::AttachedPictureFrame *)self; SWIG_RubyRemoveTracking(arg1); delete arg1; } @@ -5695,7 +5732,8 @@ _wrap_AttachedPictureFrame_picturee___(int argc, VALUE *argv, VALUE self) { static swig_class SwigClassAttachedPictureFrameV22; SWIGINTERN void -free_TagLib_ID3v2_AttachedPictureFrameV22(TagLib::ID3v2::AttachedPictureFrameV22 *arg1) { +free_TagLib_ID3v2_AttachedPictureFrameV22(void *self) { + TagLib::ID3v2::AttachedPictureFrameV22 *arg1 = (TagLib::ID3v2::AttachedPictureFrameV22 *)self; SWIG_RubyRemoveTracking(arg1); delete arg1; } @@ -5797,22 +5835,20 @@ _wrap_new_ChapterFrame__SWIG_1(int argc, VALUE *argv, VALUE self) { } -#ifdef HAVE_RB_DEFINE_ALLOC_FUNC SWIGINTERN VALUE -_wrap_ChapterFrame_allocate(VALUE self) { +#ifdef HAVE_RB_DEFINE_ALLOC_FUNC +_wrap_ChapterFrame_allocate(VALUE self) #else - SWIGINTERN VALUE - _wrap_ChapterFrame_allocate(int argc, VALUE *argv, VALUE self) { +_wrap_ChapterFrame_allocate(int argc, VALUE *argv, VALUE self) #endif - - - VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__ID3v2__ChapterFrame); +{ + VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__ID3v2__ChapterFrame); #ifndef HAVE_RB_DEFINE_ALLOC_FUNC - rb_obj_call_init(vresult, argc, argv); + rb_obj_call_init(vresult, argc, argv); #endif - return vresult; - } - + return vresult; +} + SWIGINTERN VALUE _wrap_new_ChapterFrame__SWIG_2(int argc, VALUE *argv, VALUE self) { @@ -5949,7 +5985,7 @@ SWIGINTERN VALUE _wrap_new_ChapterFrame(int nargs, VALUE *args, VALUE self) { } if (_v) { void *vptr = 0; - int res = SWIG_ConvertPtr(argv[5], &vptr, SWIGTYPE_p_TagLib__ListT_TagLib__ID3v2__Frame_p_t, 0); + int res = SWIG_ConvertPtr(argv[5], &vptr, SWIGTYPE_p_TagLib__ListT_TagLib__ID3v2__Frame_p_t, SWIG_POINTER_NO_NULL); _v = SWIG_CheckState(res); if (_v) { return _wrap_new_ChapterFrame__SWIG_1(nargs, args, self); @@ -5972,7 +6008,8 @@ SWIGINTERN VALUE _wrap_new_ChapterFrame(int nargs, VALUE *args, VALUE self) { SWIGINTERN void -free_TagLib_ID3v2_ChapterFrame(TagLib::ID3v2::ChapterFrame *arg1) { +free_TagLib_ID3v2_ChapterFrame(void *self) { + TagLib::ID3v2::ChapterFrame *arg1 = (TagLib::ID3v2::ChapterFrame *)self; SWIG_RubyRemoveTracking(arg1); delete arg1; } @@ -6368,7 +6405,7 @@ SWIGINTERN VALUE _wrap_ChapterFrame_embedded_frame_list(int nargs, VALUE *args, fail: Ruby_Format_OverloadedError( argc, 3, "ChapterFrame.embedded_frame_list", - " TagLib::ID3v2::FrameList const & ChapterFrame.embedded_frame_list()\n" + " TagLib::ID3v2::FrameList const ChapterFrame.embedded_frame_list()\n" " TagLib::ID3v2::FrameList const & ChapterFrame.embedded_frame_list(TagLib::ByteVector const &frameID)\n"); return Qnil; @@ -6650,22 +6687,20 @@ _wrap_new_CommentsFrame__SWIG_1(int argc, VALUE *argv, VALUE self) { } -#ifdef HAVE_RB_DEFINE_ALLOC_FUNC SWIGINTERN VALUE -_wrap_CommentsFrame_allocate(VALUE self) { +#ifdef HAVE_RB_DEFINE_ALLOC_FUNC +_wrap_CommentsFrame_allocate(VALUE self) #else - SWIGINTERN VALUE - _wrap_CommentsFrame_allocate(int argc, VALUE *argv, VALUE self) { +_wrap_CommentsFrame_allocate(int argc, VALUE *argv, VALUE self) #endif - - - VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__ID3v2__CommentsFrame); +{ + VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__ID3v2__CommentsFrame); #ifndef HAVE_RB_DEFINE_ALLOC_FUNC - rb_obj_call_init(vresult, argc, argv); + rb_obj_call_init(vresult, argc, argv); #endif - return vresult; - } - + return vresult; +} + SWIGINTERN VALUE _wrap_new_CommentsFrame__SWIG_2(int argc, VALUE *argv, VALUE self) { @@ -6732,7 +6767,8 @@ SWIGINTERN VALUE _wrap_new_CommentsFrame(int nargs, VALUE *args, VALUE self) { SWIGINTERN void -free_TagLib_ID3v2_CommentsFrame(TagLib::ID3v2::CommentsFrame *arg1) { +free_TagLib_ID3v2_CommentsFrame(void *self) { + TagLib::ID3v2::CommentsFrame *arg1 = (TagLib::ID3v2::CommentsFrame *)self; SWIG_RubyRemoveTracking(arg1); delete arg1; } @@ -7023,22 +7059,20 @@ _wrap_new_GeneralEncapsulatedObjectFrame__SWIG_0(int argc, VALUE *argv, VALUE se } -#ifdef HAVE_RB_DEFINE_ALLOC_FUNC SWIGINTERN VALUE -_wrap_GeneralEncapsulatedObjectFrame_allocate(VALUE self) { +#ifdef HAVE_RB_DEFINE_ALLOC_FUNC +_wrap_GeneralEncapsulatedObjectFrame_allocate(VALUE self) #else - SWIGINTERN VALUE - _wrap_GeneralEncapsulatedObjectFrame_allocate(int argc, VALUE *argv, VALUE self) { +_wrap_GeneralEncapsulatedObjectFrame_allocate(int argc, VALUE *argv, VALUE self) #endif - - - VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__ID3v2__GeneralEncapsulatedObjectFrame); +{ + VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__ID3v2__GeneralEncapsulatedObjectFrame); #ifndef HAVE_RB_DEFINE_ALLOC_FUNC - rb_obj_call_init(vresult, argc, argv); + rb_obj_call_init(vresult, argc, argv); #endif - return vresult; - } - + return vresult; +} + SWIGINTERN VALUE _wrap_new_GeneralEncapsulatedObjectFrame__SWIG_1(int argc, VALUE *argv, VALUE self) { @@ -7094,7 +7128,8 @@ SWIGINTERN VALUE _wrap_new_GeneralEncapsulatedObjectFrame(int nargs, VALUE *args SWIGINTERN void -free_TagLib_ID3v2_GeneralEncapsulatedObjectFrame(TagLib::ID3v2::GeneralEncapsulatedObjectFrame *arg1) { +free_TagLib_ID3v2_GeneralEncapsulatedObjectFrame(void *self) { + TagLib::ID3v2::GeneralEncapsulatedObjectFrame *arg1 = (TagLib::ID3v2::GeneralEncapsulatedObjectFrame *)self; SWIG_RubyRemoveTracking(arg1); delete arg1; } @@ -7408,22 +7443,20 @@ _wrap_new_PopularimeterFrame__SWIG_0(int argc, VALUE *argv, VALUE self) { } -#ifdef HAVE_RB_DEFINE_ALLOC_FUNC SWIGINTERN VALUE -_wrap_PopularimeterFrame_allocate(VALUE self) { +#ifdef HAVE_RB_DEFINE_ALLOC_FUNC +_wrap_PopularimeterFrame_allocate(VALUE self) #else - SWIGINTERN VALUE - _wrap_PopularimeterFrame_allocate(int argc, VALUE *argv, VALUE self) { +_wrap_PopularimeterFrame_allocate(int argc, VALUE *argv, VALUE self) #endif - - - VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__ID3v2__PopularimeterFrame); +{ + VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__ID3v2__PopularimeterFrame); #ifndef HAVE_RB_DEFINE_ALLOC_FUNC - rb_obj_call_init(vresult, argc, argv); + rb_obj_call_init(vresult, argc, argv); #endif - return vresult; - } - + return vresult; +} + SWIGINTERN VALUE _wrap_new_PopularimeterFrame__SWIG_1(int argc, VALUE *argv, VALUE self) { @@ -7479,7 +7512,8 @@ SWIGINTERN VALUE _wrap_new_PopularimeterFrame(int nargs, VALUE *args, VALUE self SWIGINTERN void -free_TagLib_ID3v2_PopularimeterFrame(TagLib::ID3v2::PopularimeterFrame *arg1) { +free_TagLib_ID3v2_PopularimeterFrame(void *self) { + TagLib::ID3v2::PopularimeterFrame *arg1 = (TagLib::ID3v2::PopularimeterFrame *)self; SWIG_RubyRemoveTracking(arg1); delete arg1; } @@ -7687,22 +7721,20 @@ _wrap_new_PrivateFrame__SWIG_0(int argc, VALUE *argv, VALUE self) { } -#ifdef HAVE_RB_DEFINE_ALLOC_FUNC SWIGINTERN VALUE -_wrap_PrivateFrame_allocate(VALUE self) { +#ifdef HAVE_RB_DEFINE_ALLOC_FUNC +_wrap_PrivateFrame_allocate(VALUE self) #else - SWIGINTERN VALUE - _wrap_PrivateFrame_allocate(int argc, VALUE *argv, VALUE self) { +_wrap_PrivateFrame_allocate(int argc, VALUE *argv, VALUE self) #endif - - - VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__ID3v2__PrivateFrame); +{ + VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__ID3v2__PrivateFrame); #ifndef HAVE_RB_DEFINE_ALLOC_FUNC - rb_obj_call_init(vresult, argc, argv); + rb_obj_call_init(vresult, argc, argv); #endif - return vresult; - } - + return vresult; +} + SWIGINTERN VALUE _wrap_new_PrivateFrame__SWIG_1(int argc, VALUE *argv, VALUE self) { @@ -7758,7 +7790,8 @@ SWIGINTERN VALUE _wrap_new_PrivateFrame(int nargs, VALUE *args, VALUE self) { SWIGINTERN void -free_TagLib_ID3v2_PrivateFrame(TagLib::ID3v2::PrivateFrame *arg1) { +free_TagLib_ID3v2_PrivateFrame(void *self) { + TagLib::ID3v2::PrivateFrame *arg1 = (TagLib::ID3v2::PrivateFrame *)self; SWIG_RubyRemoveTracking(arg1); delete arg1; } @@ -7994,22 +8027,20 @@ _wrap_new_TableOfContentsFrame__SWIG_2(int argc, VALUE *argv, VALUE self) { } -#ifdef HAVE_RB_DEFINE_ALLOC_FUNC SWIGINTERN VALUE -_wrap_TableOfContentsFrame_allocate(VALUE self) { +#ifdef HAVE_RB_DEFINE_ALLOC_FUNC +_wrap_TableOfContentsFrame_allocate(VALUE self) #else - SWIGINTERN VALUE - _wrap_TableOfContentsFrame_allocate(int argc, VALUE *argv, VALUE self) { +_wrap_TableOfContentsFrame_allocate(int argc, VALUE *argv, VALUE self) #endif - - - VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__ID3v2__TableOfContentsFrame); +{ + VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__ID3v2__TableOfContentsFrame); #ifndef HAVE_RB_DEFINE_ALLOC_FUNC - rb_obj_call_init(vresult, argc, argv); + rb_obj_call_init(vresult, argc, argv); #endif - return vresult; - } - + return vresult; +} + SWIGINTERN VALUE _wrap_new_TableOfContentsFrame__SWIG_3(int argc, VALUE *argv, VALUE self) { @@ -8070,7 +8101,7 @@ SWIGINTERN VALUE _wrap_new_TableOfContentsFrame(int nargs, VALUE *args, VALUE se _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; - int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_TagLib__ByteVectorList, 0); + int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_TagLib__ByteVectorList, SWIG_POINTER_NO_NULL); _v = SWIG_CheckState(res); if (_v) { return _wrap_new_TableOfContentsFrame__SWIG_2(nargs, args, self); @@ -8083,11 +8114,11 @@ SWIGINTERN VALUE _wrap_new_TableOfContentsFrame(int nargs, VALUE *args, VALUE se _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; - int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_TagLib__ByteVectorList, 0); + int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_TagLib__ByteVectorList, SWIG_POINTER_NO_NULL); _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; - int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_TagLib__ListT_TagLib__ID3v2__Frame_p_t, 0); + int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_TagLib__ListT_TagLib__ID3v2__Frame_p_t, SWIG_POINTER_NO_NULL); _v = SWIG_CheckState(res); if (_v) { return _wrap_new_TableOfContentsFrame__SWIG_1(nargs, args, self); @@ -8108,7 +8139,8 @@ SWIGINTERN VALUE _wrap_new_TableOfContentsFrame(int nargs, VALUE *args, VALUE se SWIGINTERN void -free_TagLib_ID3v2_TableOfContentsFrame(TagLib::ID3v2::TableOfContentsFrame *arg1) { +free_TagLib_ID3v2_TableOfContentsFrame(void *self) { + TagLib::ID3v2::TableOfContentsFrame *arg1 = (TagLib::ID3v2::TableOfContentsFrame *)self; SWIG_RubyRemoveTracking(arg1); delete arg1; } @@ -8525,7 +8557,7 @@ SWIGINTERN VALUE _wrap_TableOfContentsFrame_embedded_frame_list(int nargs, VALUE fail: Ruby_Format_OverloadedError( argc, 3, "TableOfContentsFrame.embedded_frame_list", - " TagLib::ID3v2::FrameList const & TableOfContentsFrame.embedded_frame_list()\n" + " TagLib::ID3v2::FrameList const TableOfContentsFrame.embedded_frame_list()\n" " TagLib::ID3v2::FrameList const & TableOfContentsFrame.embedded_frame_list(TagLib::ByteVector const &frameID)\n"); return Qnil; @@ -8791,22 +8823,20 @@ _wrap_TableOfContentsFrame_find_top_level(int argc, VALUE *argv, VALUE self) { static swig_class SwigClassTextIdentificationFrame; -#ifdef HAVE_RB_DEFINE_ALLOC_FUNC SWIGINTERN VALUE -_wrap_TextIdentificationFrame_allocate(VALUE self) { +#ifdef HAVE_RB_DEFINE_ALLOC_FUNC +_wrap_TextIdentificationFrame_allocate(VALUE self) #else - SWIGINTERN VALUE - _wrap_TextIdentificationFrame_allocate(int argc, VALUE *argv, VALUE self) { +_wrap_TextIdentificationFrame_allocate(int argc, VALUE *argv, VALUE self) #endif - - - VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__ID3v2__TextIdentificationFrame); +{ + VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__ID3v2__TextIdentificationFrame); #ifndef HAVE_RB_DEFINE_ALLOC_FUNC - rb_obj_call_init(vresult, argc, argv); + rb_obj_call_init(vresult, argc, argv); #endif - return vresult; - } - + return vresult; +} + SWIGINTERN VALUE _wrap_new_TextIdentificationFrame(int argc, VALUE *argv, VALUE self) { @@ -8838,22 +8868,20 @@ _wrap_new_TextIdentificationFrame(int argc, VALUE *argv, VALUE self) { } -#ifdef HAVE_RB_DEFINE_ALLOC_FUNC SWIGINTERN VALUE -_wrap_from_data_allocate(VALUE self) { +#ifdef HAVE_RB_DEFINE_ALLOC_FUNC +_wrap_from_data_allocate(VALUE self) #else - SWIGINTERN VALUE - _wrap_from_data_allocate(int argc, VALUE *argv, VALUE self) { +_wrap_from_data_allocate(int argc, VALUE *argv, VALUE self) #endif - - - VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__ID3v2__TextIdentificationFrame); +{ + VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__ID3v2__TextIdentificationFrame); #ifndef HAVE_RB_DEFINE_ALLOC_FUNC - rb_obj_call_init(vresult, argc, argv); + rb_obj_call_init(vresult, argc, argv); #endif - return vresult; - } - + return vresult; +} + SWIGINTERN VALUE _wrap_new_from_data(int argc, VALUE *argv, VALUE self) { @@ -8878,7 +8906,8 @@ _wrap_new_from_data(int argc, VALUE *argv, VALUE self) { SWIGINTERN void -free_TagLib_ID3v2_TextIdentificationFrame(TagLib::ID3v2::TextIdentificationFrame *arg1) { +free_TagLib_ID3v2_TextIdentificationFrame(void *self) { + TagLib::ID3v2::TextIdentificationFrame *arg1 = (TagLib::ID3v2::TextIdentificationFrame *)self; SWIG_RubyRemoveTracking(arg1); delete arg1; } @@ -9142,22 +9171,20 @@ _wrap_new_UserTextIdentificationFrame__SWIG_3(int argc, VALUE *argv, VALUE self) } -#ifdef HAVE_RB_DEFINE_ALLOC_FUNC SWIGINTERN VALUE -_wrap_UserTextIdentificationFrame_allocate(VALUE self) { +#ifdef HAVE_RB_DEFINE_ALLOC_FUNC +_wrap_UserTextIdentificationFrame_allocate(VALUE self) #else - SWIGINTERN VALUE - _wrap_UserTextIdentificationFrame_allocate(int argc, VALUE *argv, VALUE self) { +_wrap_UserTextIdentificationFrame_allocate(int argc, VALUE *argv, VALUE self) #endif - - - VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__ID3v2__UserTextIdentificationFrame); +{ + VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__ID3v2__UserTextIdentificationFrame); #ifndef HAVE_RB_DEFINE_ALLOC_FUNC - rb_obj_call_init(vresult, argc, argv); + rb_obj_call_init(vresult, argc, argv); #endif - return vresult; - } - + return vresult; +} + SWIGINTERN VALUE _wrap_new_UserTextIdentificationFrame__SWIG_4(int argc, VALUE *argv, VALUE self) { @@ -9224,7 +9251,7 @@ SWIGINTERN VALUE _wrap_new_UserTextIdentificationFrame(int nargs, VALUE *args, V _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; - int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_TagLib__StringList, 0); + int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_TagLib__StringList, SWIG_POINTER_NO_NULL); _v = SWIG_CheckState(res); if (_v) { return _wrap_new_UserTextIdentificationFrame__SWIG_4(nargs, args, self); @@ -9237,7 +9264,7 @@ SWIGINTERN VALUE _wrap_new_UserTextIdentificationFrame(int nargs, VALUE *args, V _v = SWIG_CheckState(res); if (_v) { void *vptr = 0; - int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_TagLib__StringList, 0); + int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_TagLib__StringList, SWIG_POINTER_NO_NULL); _v = SWIG_CheckState(res); if (_v) { { @@ -9422,7 +9449,6 @@ _wrap_UserTextIdentificationFrame_field_liste___(int argc, VALUE *argv, VALUE se } - /* Document-method: TagLib::ID3v2::UserTextIdentificationFrame.find @@ -9462,7 +9488,8 @@ _wrap_UserTextIdentificationFrame_find(int argc, VALUE *argv, VALUE self) { SWIGINTERN void -free_TagLib_ID3v2_UserTextIdentificationFrame(TagLib::ID3v2::UserTextIdentificationFrame *arg1) { +free_TagLib_ID3v2_UserTextIdentificationFrame(void *self) { + TagLib::ID3v2::UserTextIdentificationFrame *arg1 = (TagLib::ID3v2::UserTextIdentificationFrame *)self; SWIG_RubyRemoveTracking(arg1); delete arg1; } @@ -9491,22 +9518,20 @@ _wrap_new_UniqueFileIdentifierFrame__SWIG_0(int argc, VALUE *argv, VALUE self) { } -#ifdef HAVE_RB_DEFINE_ALLOC_FUNC SWIGINTERN VALUE -_wrap_UniqueFileIdentifierFrame_allocate(VALUE self) { +#ifdef HAVE_RB_DEFINE_ALLOC_FUNC +_wrap_UniqueFileIdentifierFrame_allocate(VALUE self) #else - SWIGINTERN VALUE - _wrap_UniqueFileIdentifierFrame_allocate(int argc, VALUE *argv, VALUE self) { +_wrap_UniqueFileIdentifierFrame_allocate(int argc, VALUE *argv, VALUE self) #endif - - - VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__ID3v2__UniqueFileIdentifierFrame); +{ + VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__ID3v2__UniqueFileIdentifierFrame); #ifndef HAVE_RB_DEFINE_ALLOC_FUNC - rb_obj_call_init(vresult, argc, argv); + rb_obj_call_init(vresult, argc, argv); #endif - return vresult; - } - + return vresult; +} + SWIGINTERN VALUE _wrap_new_UniqueFileIdentifierFrame__SWIG_1(int argc, VALUE *argv, VALUE self) { @@ -9577,7 +9602,8 @@ SWIGINTERN VALUE _wrap_new_UniqueFileIdentifierFrame(int nargs, VALUE *args, VAL SWIGINTERN void -free_TagLib_ID3v2_UniqueFileIdentifierFrame(TagLib::ID3v2::UniqueFileIdentifierFrame *arg1) { +free_TagLib_ID3v2_UniqueFileIdentifierFrame(void *self) { + TagLib::ID3v2::UniqueFileIdentifierFrame *arg1 = (TagLib::ID3v2::UniqueFileIdentifierFrame *)self; SWIG_RubyRemoveTracking(arg1); delete arg1; } @@ -9716,22 +9742,20 @@ _wrap_UniqueFileIdentifierFrame_to_string(int argc, VALUE *argv, VALUE self) { static swig_class SwigClassUnknownFrame; -#ifdef HAVE_RB_DEFINE_ALLOC_FUNC SWIGINTERN VALUE -_wrap_UnknownFrame_allocate(VALUE self) { +#ifdef HAVE_RB_DEFINE_ALLOC_FUNC +_wrap_UnknownFrame_allocate(VALUE self) #else - SWIGINTERN VALUE - _wrap_UnknownFrame_allocate(int argc, VALUE *argv, VALUE self) { +_wrap_UnknownFrame_allocate(int argc, VALUE *argv, VALUE self) #endif - - - VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__ID3v2__UnknownFrame); +{ + VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__ID3v2__UnknownFrame); #ifndef HAVE_RB_DEFINE_ALLOC_FUNC - rb_obj_call_init(vresult, argc, argv); + rb_obj_call_init(vresult, argc, argv); #endif - return vresult; - } - + return vresult; +} + SWIGINTERN VALUE _wrap_new_UnknownFrame(int argc, VALUE *argv, VALUE self) { @@ -9756,7 +9780,8 @@ _wrap_new_UnknownFrame(int argc, VALUE *argv, VALUE self) { SWIGINTERN void -free_TagLib_ID3v2_UnknownFrame(TagLib::ID3v2::UnknownFrame *arg1) { +free_TagLib_ID3v2_UnknownFrame(void *self) { + TagLib::ID3v2::UnknownFrame *arg1 = (TagLib::ID3v2::UnknownFrame *)self; SWIG_RubyRemoveTracking(arg1); delete arg1; } @@ -9855,22 +9880,20 @@ _wrap_new_UnsynchronizedLyricsFrame__SWIG_1(int argc, VALUE *argv, VALUE self) { } -#ifdef HAVE_RB_DEFINE_ALLOC_FUNC SWIGINTERN VALUE -_wrap_UnsynchronizedLyricsFrame_allocate(VALUE self) { +#ifdef HAVE_RB_DEFINE_ALLOC_FUNC +_wrap_UnsynchronizedLyricsFrame_allocate(VALUE self) #else - SWIGINTERN VALUE - _wrap_UnsynchronizedLyricsFrame_allocate(int argc, VALUE *argv, VALUE self) { +_wrap_UnsynchronizedLyricsFrame_allocate(int argc, VALUE *argv, VALUE self) #endif - - - VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__ID3v2__UnsynchronizedLyricsFrame); +{ + VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__ID3v2__UnsynchronizedLyricsFrame); #ifndef HAVE_RB_DEFINE_ALLOC_FUNC - rb_obj_call_init(vresult, argc, argv); + rb_obj_call_init(vresult, argc, argv); #endif - return vresult; - } - + return vresult; +} + SWIGINTERN VALUE _wrap_new_UnsynchronizedLyricsFrame__SWIG_2(int argc, VALUE *argv, VALUE self) { @@ -9937,7 +9960,8 @@ SWIGINTERN VALUE _wrap_new_UnsynchronizedLyricsFrame(int nargs, VALUE *args, VAL SWIGINTERN void -free_TagLib_ID3v2_UnsynchronizedLyricsFrame(TagLib::ID3v2::UnsynchronizedLyricsFrame *arg1) { +free_TagLib_ID3v2_UnsynchronizedLyricsFrame(void *self) { + TagLib::ID3v2::UnsynchronizedLyricsFrame *arg1 = (TagLib::ID3v2::UnsynchronizedLyricsFrame *)self; SWIG_RubyRemoveTracking(arg1); delete arg1; } @@ -10182,22 +10206,20 @@ _wrap_UnsynchronizedLyricsFrame_text_encodinge___(int argc, VALUE *argv, VALUE s static swig_class SwigClassUrlLinkFrame; -#ifdef HAVE_RB_DEFINE_ALLOC_FUNC SWIGINTERN VALUE -_wrap_UrlLinkFrame_allocate(VALUE self) { +#ifdef HAVE_RB_DEFINE_ALLOC_FUNC +_wrap_UrlLinkFrame_allocate(VALUE self) #else - SWIGINTERN VALUE - _wrap_UrlLinkFrame_allocate(int argc, VALUE *argv, VALUE self) { +_wrap_UrlLinkFrame_allocate(int argc, VALUE *argv, VALUE self) #endif - - - VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__ID3v2__UrlLinkFrame); +{ + VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__ID3v2__UrlLinkFrame); #ifndef HAVE_RB_DEFINE_ALLOC_FUNC - rb_obj_call_init(vresult, argc, argv); + rb_obj_call_init(vresult, argc, argv); #endif - return vresult; - } - + return vresult; +} + SWIGINTERN VALUE _wrap_new_UrlLinkFrame(int argc, VALUE *argv, VALUE self) { @@ -10222,7 +10244,8 @@ _wrap_new_UrlLinkFrame(int argc, VALUE *argv, VALUE self) { SWIGINTERN void -free_TagLib_ID3v2_UrlLinkFrame(TagLib::ID3v2::UrlLinkFrame *arg1) { +free_TagLib_ID3v2_UrlLinkFrame(void *self) { + TagLib::ID3v2::UrlLinkFrame *arg1 = (TagLib::ID3v2::UrlLinkFrame *)self; SWIG_RubyRemoveTracking(arg1); delete arg1; } @@ -10375,22 +10398,20 @@ _wrap_new_UserUrlLinkFrame__SWIG_1(int argc, VALUE *argv, VALUE self) { } -#ifdef HAVE_RB_DEFINE_ALLOC_FUNC SWIGINTERN VALUE -_wrap_UserUrlLinkFrame_allocate(VALUE self) { +#ifdef HAVE_RB_DEFINE_ALLOC_FUNC +_wrap_UserUrlLinkFrame_allocate(VALUE self) #else - SWIGINTERN VALUE - _wrap_UserUrlLinkFrame_allocate(int argc, VALUE *argv, VALUE self) { +_wrap_UserUrlLinkFrame_allocate(int argc, VALUE *argv, VALUE self) #endif - - - VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__ID3v2__UserUrlLinkFrame); +{ + VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__ID3v2__UserUrlLinkFrame); #ifndef HAVE_RB_DEFINE_ALLOC_FUNC - rb_obj_call_init(vresult, argc, argv); + rb_obj_call_init(vresult, argc, argv); #endif - return vresult; - } - + return vresult; +} + SWIGINTERN VALUE _wrap_new_UserUrlLinkFrame__SWIG_2(int argc, VALUE *argv, VALUE self) { @@ -10457,7 +10478,8 @@ SWIGINTERN VALUE _wrap_new_UserUrlLinkFrame(int nargs, VALUE *args, VALUE self) SWIGINTERN void -free_TagLib_ID3v2_UserUrlLinkFrame(TagLib::ID3v2::UserUrlLinkFrame *arg1) { +free_TagLib_ID3v2_UserUrlLinkFrame(void *self) { + TagLib::ID3v2::UserUrlLinkFrame *arg1 = (TagLib::ID3v2::UserUrlLinkFrame *)self; SWIG_RubyRemoveTracking(arg1); delete arg1; } @@ -10908,7 +10930,7 @@ SWIG_InitializeModule(void *clientdata) { /* Now work on filling in swig_module.types */ #ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: size %d\n", swig_module.size); + printf("SWIG_InitializeModule: size %lu\n", (unsigned long)swig_module.size); #endif for (i = 0; i < swig_module.size; ++i) { swig_type_info *type = 0; @@ -10916,7 +10938,7 @@ SWIG_InitializeModule(void *clientdata) { swig_cast_info *cast; #ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); + printf("SWIG_InitializeModule: type %lu %s\n", (unsigned long)i, swig_module.type_initial[i]->name); #endif /* if there is another module already loaded */ @@ -10992,7 +11014,7 @@ SWIG_InitializeModule(void *clientdata) { for (i = 0; i < swig_module.size; ++i) { int j = 0; swig_cast_info *cast = swig_module.cast_initial[i]; - printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); + printf("SWIG_InitializeModule: type %lu %s\n", (unsigned long)i, swig_module.type_initial[i]->name); while (cast->type) { printf("SWIG_InitializeModule: cast type %s\n", cast->type->name); cast++; diff --git a/ext/taglib_mp4/taglib_mp4_wrap.cxx b/ext/taglib_mp4/taglib_mp4_wrap.cxx index d3108ab..33d6f36 100644 --- a/ext/taglib_mp4/taglib_mp4_wrap.cxx +++ b/ext/taglib_mp4/taglib_mp4_wrap.cxx @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 3.0.7 + * Version 4.0.2 * * This file is not intended to be easily readable and contains a number of * coding conventions designed to improve portability and efficiency. Do not make @@ -11,7 +11,11 @@ static void free_taglib_mp4_file(void *ptr); + +#ifndef SWIGRUBY #define SWIGRUBY +#endif + #ifdef __cplusplus @@ -104,9 +108,11 @@ template T SwigValueInit() { #endif /* exporting methods */ -#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) -# ifndef GCC_HASCLASSVISIBILITY -# define GCC_HASCLASSVISIBILITY +#if defined(__GNUC__) +# if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +# ifndef GCC_HASCLASSVISIBILITY +# define GCC_HASCLASSVISIBILITY +# endif # endif #endif @@ -226,9 +232,11 @@ template T SwigValueInit() { #endif /* exporting methods */ -#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) -# ifndef GCC_HASCLASSVISIBILITY -# define GCC_HASCLASSVISIBILITY +#if defined(__GNUC__) +# if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +# ifndef GCC_HASCLASSVISIBILITY +# define GCC_HASCLASSVISIBILITY +# endif # endif #endif @@ -326,6 +334,7 @@ template T SwigValueInit() { /* Flags for pointer conversions */ #define SWIG_POINTER_DISOWN 0x1 #define SWIG_CAST_NEW_MEMORY 0x2 +#define SWIG_POINTER_NO_NULL 0x4 /* Flags for new pointer objects */ #define SWIG_POINTER_OWN 0x1 @@ -778,16 +787,16 @@ SWIG_UnpackData(const char *c, void *ptr, size_t sz) { char d = *(c++); unsigned char uu; if ((d >= '0') && (d <= '9')) - uu = ((d - '0') << 4); + uu = (unsigned char)((d - '0') << 4); else if ((d >= 'a') && (d <= 'f')) - uu = ((d - ('a'-10)) << 4); + uu = (unsigned char)((d - ('a'-10)) << 4); else return (char *) 0; d = *(c++); if ((d >= '0') && (d <= '9')) - uu |= (d - '0'); + uu |= (unsigned char)(d - '0'); else if ((d >= 'a') && (d <= 'f')) - uu |= (d - ('a'-10)); + uu |= (unsigned char)(d - ('a'-10)); else return (char *) 0; *u = uu; @@ -964,42 +973,53 @@ SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { #ifndef RSTRUCT_PTR # define RSTRUCT_PTR(x) RSTRUCT(x)->ptr #endif +#ifndef RTYPEDDATA_P +# define RTYPEDDATA_P(x) (TYPE(x) != T_DATA) +#endif /* - * Need to be very careful about how these macros are defined, especially - * when compiling C++ code or C code with an ANSI C compiler. + * The following macros are used for providing the correct type of a + * function pointer to the Ruby C API. + * Starting with Ruby 2.7 (corresponding to RB_METHOD_DEFINITION_DECL being + * defined) these macros act transparently due to Ruby's moving away from + * ANYARGS and instead employing strict function signatures. + * + * Note: In case of C (not C++) the macros are transparent even before + * Ruby 2.7 due to the fact that the Ruby C API used function declarators + * with empty parentheses, which allows for an unspecified number of + * arguments. + * + * PROTECTFUNC(f) is used for the function pointer argument of the Ruby + * C API function rb_protect(). * - * VALUEFUNC(f) is a macro used to typecast a C function that implements - * a Ruby method so that it can be passed as an argument to API functions - * like rb_define_method() and rb_define_singleton_method(). + * VALUEFUNC(f) is used for the function pointer argument(s) of Ruby C API + * functions like rb_define_method() and rb_define_singleton_method(). * - * VOIDFUNC(f) is a macro used to typecast a C function that implements - * either the "mark" or "free" stuff for a Ruby Data object, so that it - * can be passed as an argument to API functions like Data_Wrap_Struct() + * VOIDFUNC(f) is used to typecast a C function that implements either + * the "mark" or "free" stuff for a Ruby Data object, so that it can be + * passed as an argument to Ruby C API functions like Data_Wrap_Struct() * and Data_Make_Struct(). + * + * SWIG_RUBY_VOID_ANYARGS_FUNC(f) is used for the function pointer + * argument(s) of Ruby C API functions like rb_define_virtual_variable(). + * + * SWIG_RUBY_INT_ANYARGS_FUNC(f) is used for the function pointer + * argument(s) of Ruby C API functions like st_foreach(). */ - -#ifdef __cplusplus -# ifndef RUBY_METHOD_FUNC /* These definitions should work for Ruby 1.4.6 */ -# define PROTECTFUNC(f) ((VALUE (*)()) f) -# define VALUEFUNC(f) ((VALUE (*)()) f) -# define VOIDFUNC(f) ((void (*)()) f) -# else -# ifndef ANYARGS /* These definitions should work for Ruby 1.6 */ -# define PROTECTFUNC(f) ((VALUE (*)()) f) -# define VALUEFUNC(f) ((VALUE (*)()) f) -# define VOIDFUNC(f) ((RUBY_DATA_FUNC) f) -# else /* These definitions should work for Ruby 1.7+ */ -# define PROTECTFUNC(f) ((VALUE (*)(VALUE)) f) -# define VALUEFUNC(f) ((VALUE (*)(ANYARGS)) f) -# define VOIDFUNC(f) ((RUBY_DATA_FUNC) f) -# endif -# endif +#if defined(__cplusplus) && !defined(RB_METHOD_DEFINITION_DECL) +# define PROTECTFUNC(f) ((VALUE (*)(VALUE)) f) +# define VALUEFUNC(f) ((VALUE (*)(ANYARGS)) f) +# define VOIDFUNC(f) ((RUBY_DATA_FUNC) f) +# define SWIG_RUBY_VOID_ANYARGS_FUNC(f) ((void (*)(ANYARGS))(f)) +# define SWIG_RUBY_INT_ANYARGS_FUNC(f) ((int (*)(ANYARGS))(f)) #else +# define PROTECTFUNC(f) (f) # define VALUEFUNC(f) (f) # define VOIDFUNC(f) (f) +# define SWIG_RUBY_VOID_ANYARGS_FUNC(f) (f) +# define SWIG_RUBY_INT_ANYARGS_FUNC(f) (f) #endif /* Don't use for expressions have side effect */ @@ -1187,7 +1207,7 @@ void Ruby_Format_OverloadedError( /* ----------------------------------------------------------------------------- * rubytracking.swg * - * This file contains support for tracking mappings from + * This file contains support for tracking mappings from * Ruby objects to C++ objects. This functionality is needed * to implement mark functions for Ruby's mark and sweep * garbage collector. @@ -1197,6 +1217,11 @@ void Ruby_Format_OverloadedError( extern "C" { #endif +#if !defined(ST_DATA_T_DEFINED) +/* Needs to be explicitly included for Ruby 1.8 and earlier */ +#include +#endif + /* Ruby 1.8 actually assumes the first case. */ #if SIZEOF_VOIDP == SIZEOF_LONG # define SWIG2NUM(v) LONG2NUM((unsigned long)v) @@ -1208,109 +1233,69 @@ extern "C" { # error sizeof(void*) is not the same as long or long long #endif - -/* Global Ruby hash table to store Trackings from C/C++ - structs to Ruby Objects. +/* Global hash table to store Trackings from C/C++ + structs to Ruby Objects. */ -static VALUE swig_ruby_trackings = Qnil; +static st_table* swig_ruby_trackings = NULL; + +static VALUE swig_ruby_trackings_count(ID id, VALUE *var) { + return SWIG2NUM(swig_ruby_trackings->num_entries); +} -/* Global variable that stores a reference to the ruby - hash table delete function. */ -static ID swig_ruby_hash_delete; -/* Setup a Ruby hash table to store Trackings */ +/* Setup a hash table to store Trackings */ SWIGRUNTIME void SWIG_RubyInitializeTrackings(void) { - /* Create a ruby hash table to store Trackings from C++ + /* Create a hash table to store Trackings from C++ objects to Ruby objects. */ - /* Try to see if some other .so has already created a + /* Try to see if some other .so has already created a tracking hash table, which we keep hidden in an instance var in the SWIG module. This is done to allow multiple DSOs to share the same tracking table. */ - ID trackings_id = rb_intern( "@__trackings__" ); + VALUE trackings_value = Qnil; + /* change the variable name so that we can mix modules + compiled with older SWIG's - this used to be called "@__trackings__" */ + ID trackings_id = rb_intern( "@__safetrackings__" ); VALUE verbose = rb_gv_get("VERBOSE"); rb_gv_set("VERBOSE", Qfalse); - swig_ruby_trackings = rb_ivar_get( _mSWIG, trackings_id ); + trackings_value = rb_ivar_get( _mSWIG, trackings_id ); rb_gv_set("VERBOSE", verbose); - /* No, it hasn't. Create one ourselves */ - if ( swig_ruby_trackings == Qnil ) - { - swig_ruby_trackings = rb_hash_new(); - rb_ivar_set( _mSWIG, trackings_id, swig_ruby_trackings ); - } - - /* Now store a reference to the hash table delete function - so that we only have to look it up once.*/ - swig_ruby_hash_delete = rb_intern("delete"); -} - -/* Get a Ruby number to reference a pointer */ -SWIGRUNTIME VALUE SWIG_RubyPtrToReference(void* ptr) { - /* We cast the pointer to an unsigned long - and then store a reference to it using - a Ruby number object. */ - - /* Convert the pointer to a Ruby number */ - return SWIG2NUM(ptr); -} - -/* Get a Ruby number to reference an object */ -SWIGRUNTIME VALUE SWIG_RubyObjectToReference(VALUE object) { - /* We cast the object to an unsigned long - and then store a reference to it using - a Ruby number object. */ - - /* Convert the Object to a Ruby number */ - return SWIG2NUM(object); -} - -/* Get a Ruby object from a previously stored reference */ -SWIGRUNTIME VALUE SWIG_RubyReferenceToObject(VALUE reference) { - /* The provided Ruby number object is a reference - to the Ruby object we want.*/ + /* The trick here is that we have to store the hash table + pointer in a Ruby variable. We do not want Ruby's GC to + treat this pointer as a Ruby object, so we convert it to + a Ruby numeric value. */ + if (trackings_value == Qnil) { + /* No, it hasn't. Create one ourselves */ + swig_ruby_trackings = st_init_numtable(); + rb_ivar_set( _mSWIG, trackings_id, SWIG2NUM(swig_ruby_trackings) ); + } else { + swig_ruby_trackings = (st_table*)NUM2SWIG(trackings_value); + } - /* Convert the Ruby number to a Ruby object */ - return NUM2SWIG(reference); + rb_define_virtual_variable("SWIG_TRACKINGS_COUNT", + VALUEFUNC(swig_ruby_trackings_count), + SWIG_RUBY_VOID_ANYARGS_FUNC((rb_gvar_setter_t*)NULL)); } /* Add a Tracking from a C/C++ struct to a Ruby object */ SWIGRUNTIME void SWIG_RubyAddTracking(void* ptr, VALUE object) { - /* In a Ruby hash table we store the pointer and - the associated Ruby object. The trick here is - that we cannot store the Ruby object directly - if - we do then it cannot be garbage collected. So - instead we typecast it as a unsigned long and - convert it to a Ruby number object.*/ - - /* Get a reference to the pointer as a Ruby number */ - VALUE key = SWIG_RubyPtrToReference(ptr); - - /* Get a reference to the Ruby object as a Ruby number */ - VALUE value = SWIG_RubyObjectToReference(object); - /* Store the mapping to the global hash table. */ - rb_hash_aset(swig_ruby_trackings, key, value); + st_insert(swig_ruby_trackings, (st_data_t)ptr, object); } /* Get the Ruby object that owns the specified C/C++ struct */ SWIGRUNTIME VALUE SWIG_RubyInstanceFor(void* ptr) { - /* Get a reference to the pointer as a Ruby number */ - VALUE key = SWIG_RubyPtrToReference(ptr); - /* Now lookup the value stored in the global hash table */ - VALUE value = rb_hash_aref(swig_ruby_trackings, key); - - if (value == Qnil) { - /* No object exists - return nil. */ + VALUE value; + + if (st_lookup(swig_ruby_trackings, (st_data_t)ptr, &value)) { + return value; + } else { return Qnil; } - else { - /* Convert this value to Ruby object */ - return SWIG_RubyReferenceToObject(value); - } } /* Remove a Tracking from a C/C++ struct to a Ruby object. It @@ -1318,25 +1303,39 @@ SWIGRUNTIME VALUE SWIG_RubyInstanceFor(void* ptr) { since the same memory address may be reused later to create a new object. */ SWIGRUNTIME void SWIG_RubyRemoveTracking(void* ptr) { - /* Get a reference to the pointer as a Ruby number */ - VALUE key = SWIG_RubyPtrToReference(ptr); - - /* Delete the object from the hash table by calling Ruby's - do this we need to call the Hash.delete method.*/ - rb_funcall(swig_ruby_trackings, swig_ruby_hash_delete, 1, key); + /* Delete the object from the hash table */ + st_delete(swig_ruby_trackings, (st_data_t *)&ptr, NULL); } /* This is a helper method that unlinks a Ruby object from its underlying C++ object. This is needed if the lifetime of the - Ruby object is longer than the C++ object */ + Ruby object is longer than the C++ object. */ SWIGRUNTIME void SWIG_RubyUnlinkObjects(void* ptr) { VALUE object = SWIG_RubyInstanceFor(ptr); if (object != Qnil) { + // object might have the T_ZOMBIE type, but that's just + // because the GC has flagged it as such for a deferred + // destruction. Until then, it's still a T_DATA object. DATA_PTR(object) = 0; } } +/* This is a helper method that iterates over all the trackings + passing the C++ object pointer and its related Ruby object + to the passed callback function. */ + +/* Proxy method to abstract the internal trackings datatype */ +static int swig_ruby_internal_iterate_callback(st_data_t ptr, st_data_t obj, st_data_t meth) { + ((void (*) (void *, VALUE))meth)((void *)ptr, (VALUE)obj); + return ST_CONTINUE; +} + +SWIGRUNTIME void SWIG_RubyIterateTrackings( void(*meth)(void* ptr, VALUE obj) ) { + st_foreach(swig_ruby_trackings, + SWIG_RUBY_INT_ANYARGS_FUNC(swig_ruby_internal_iterate_callback), + (st_data_t)meth); +} #ifdef __cplusplus } @@ -1395,7 +1394,7 @@ SWIG_Ruby_AppendOutput(VALUE target, VALUE o) { #define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Ruby_ConvertPtrAndOwn(obj, pptr, type, flags, own) #define SWIG_NewPointerObj(ptr, type, flags) SWIG_Ruby_NewPointerObj(ptr, type, flags) #define SWIG_AcquirePtr(ptr, own) SWIG_Ruby_AcquirePtr(ptr, own) -#define swig_owntype ruby_owntype +#define swig_owntype swig_ruby_owntype /* for raw packed data */ #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) swig_class *sklass; VALUE klass; VALUE obj; - + if (!ptr) return Qnil; - + + assert(type); if (type->clientdata) { sklass = (swig_class *) type->clientdata; @@ -1563,7 +1563,7 @@ SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags) track = sklass->trackObjects; if (track) { obj = SWIG_RubyInstanceFor(ptr); - + /* Check the object's type and make sure it has the correct type. It might not in cases where methods do things like downcast methods. */ @@ -1595,7 +1595,7 @@ SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags) obj = Data_Wrap_Struct(klass, 0, 0, ptr); } rb_iv_set(obj, "@__swigtype__", rb_str_new2(type->name)); - + return obj; } @@ -1615,26 +1615,30 @@ SWIGRUNTIMEINLINE char * SWIG_Ruby_MangleStr(VALUE obj) { VALUE stype = rb_iv_get(obj, "@__swigtype__"); + if (NIL_P(stype)) + return NULL; return StringValuePtr(stype); } /* Acquire a pointer value */ -typedef void (*ruby_owntype)(void*); - -SWIGRUNTIME ruby_owntype -SWIG_Ruby_AcquirePtr(VALUE obj, ruby_owntype own) { - if (obj) { - ruby_owntype oldown = RDATA(obj)->dfree; - RDATA(obj)->dfree = own; - return oldown; - } else { - return 0; +typedef struct { + void (*datafree)(void *); + int own; +} swig_ruby_owntype; + +SWIGRUNTIME swig_ruby_owntype +SWIG_Ruby_AcquirePtr(VALUE obj, swig_ruby_owntype own) { + swig_ruby_owntype oldown = {0, 0}; + if (TYPE(obj) == T_DATA && !RTYPEDDATA_P(obj)) { + oldown.datafree = RDATA(obj)->dfree; + RDATA(obj)->dfree = own.datafree; } + return oldown; } /* Convert a pointer value */ SWIGRUNTIME int -SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, ruby_owntype *own) +SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, swig_ruby_owntype *own) { char *c; swig_cast_info *tc; @@ -1642,16 +1646,20 @@ SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, /* Grab the pointer */ if (NIL_P(obj)) { - *ptr = 0; - return SWIG_OK; + if (ptr) + *ptr = 0; + return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK; } else { - if (TYPE(obj) != T_DATA) { + if (TYPE(obj) != T_DATA || (TYPE(obj) == T_DATA && RTYPEDDATA_P(obj))) { return SWIG_ERROR; } Data_Get_Struct(obj, void, vptr); } - if (own) *own = RDATA(obj)->dfree; + if (own) { + own->datafree = RDATA(obj)->dfree; + own->own = 0; + } /* Check to see if the input object is giving up ownership 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, /* The object has already been deleted */ return SWIG_ObjectPreviouslyDeletedError; } - *ptr = vptr; - return SWIG_OK; } } if ((c = SWIG_MangleStr(obj)) == NULL) { @@ -1697,12 +1703,23 @@ SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, if (!tc) { return SWIG_ERROR; } else { - int newmemory = 0; - *ptr = SWIG_TypeCast(tc, vptr, &newmemory); - assert(!newmemory); /* newmemory handling not yet implemented */ + if (ptr) { + if (tc->type == ty) { + *ptr = vptr; + } else { + int newmemory = 0; + *ptr = SWIG_TypeCast(tc, vptr, &newmemory); + if (newmemory == SWIG_CAST_NEW_MEMORY) { + assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */ + if (own) + own->own = own->own | SWIG_CAST_NEW_MEMORY; + } + } + } } } else { - *ptr = vptr; + if (ptr) + *ptr = vptr; } return SWIG_OK; @@ -1728,7 +1745,7 @@ SWIG_Ruby_NewPackedObj(void *ptr, int sz, swig_type_info *type) { return rb_str_new2(result); } -/* Convert a packed value value */ +/* Convert a packed pointer value */ SWIGRUNTIME int SWIG_Ruby_ConvertPacked(VALUE obj, void *ptr, int sz, swig_type_info *ty) { swig_cast_info *tc; @@ -1864,7 +1881,7 @@ static VALUE mMP4; #define SWIG_RUBY_THREAD_END_BLOCK -#define SWIGVERSION 0x030007 +#define SWIGVERSION 0x040002 #define SWIG_VERSION SWIGVERSION @@ -1886,6 +1903,8 @@ using namespace TagLib::MP4; #include #include +#include +#include #include #if defined(HAVE_RUBY_ENCODING_H) && HAVE_RUBY_ENCODING_H @@ -1955,6 +1974,28 @@ TagLib::StringList ruby_array_to_taglib_string_list(VALUE ary) { return result; } +VALUE taglib_bytevectorlist_to_ruby_array(const TagLib::ByteVectorList & list) { + VALUE ary = rb_ary_new2(list.size()); + for (TagLib::ByteVectorList::ConstIterator it = list.begin(); it != list.end(); it++) { + VALUE s = taglib_bytevector_to_ruby_string(*it); + rb_ary_push(ary, s); + } + return ary; +} + +TagLib::ByteVectorList ruby_array_to_taglib_bytevectorlist(VALUE ary) { + TagLib::ByteVectorList result = TagLib::ByteVectorList(); + if (NIL_P(ary)) { + return result; + } + for (long i = 0; i < RARRAY_LEN(ary); i++) { + VALUE e = rb_ary_entry(ary, i); + TagLib::ByteVector s = ruby_string_to_taglib_bytevector(e); + result.append(s); + } + return result; +} + VALUE taglib_filename_to_ruby_string(TagLib::FileName filename) { VALUE result; #ifdef _WIN32 @@ -2058,15 +2099,16 @@ SWIG_From_int (int value) SWIGINTERN VALUE -SWIG_ruby_failed(void) +SWIG_ruby_failed(VALUE SWIGUNUSEDPARM(arg1), VALUE SWIGUNUSEDPARM(arg2)) { return Qnil; } -/*@SWIG:/usr/local/share/swig/3.0.7/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/ -SWIGINTERN VALUE SWIG_AUX_NUM2LONG(VALUE *args) +/*@SWIG:/usr/local/Cellar/swig/4.0.2/share/swig/4.0.2/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/ +SWIGINTERN VALUE SWIG_AUX_NUM2LONG(VALUE arg) { + VALUE *args = (VALUE *)arg; VALUE obj = args[0]; VALUE type = TYPE(obj); long *res = (long *)(args[1]); @@ -2084,7 +2126,7 @@ SWIG_AsVal_long (VALUE obj, long* val) VALUE a[2]; a[0] = obj; a[1] = (VALUE)(&v); - if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2LONG), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) { + if (rb_rescue(VALUEFUNC(SWIG_AUX_NUM2LONG), (VALUE)a, VALUEFUNC(SWIG_ruby_failed), 0) != Qnil) { if (val) *val = v; return SWIG_OK; } @@ -2152,7 +2194,7 @@ SWIG_AsCharPtrAndSize(VALUE obj, char** cptr, size_t* psize, int *alloc) if (cptr) { if (alloc) { if (*alloc == SWIG_NEWOBJ) { - *cptr = reinterpret_cast< char* >(memcpy((new char[size]), cstr, sizeof(char)*(size))); + *cptr = reinterpret_cast< char* >(memcpy(new char[size], cstr, sizeof(char)*(size))); } else { *cptr = cstr; *alloc = SWIG_OLDOBJ; @@ -2180,9 +2222,10 @@ SWIG_AsCharPtrAndSize(VALUE obj, char** cptr, size_t* psize, int *alloc) -/*@SWIG:/usr/local/share/swig/3.0.7/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/ -SWIGINTERN VALUE SWIG_AUX_NUM2ULONG(VALUE *args) +/*@SWIG:/usr/local/Cellar/swig/4.0.2/share/swig/4.0.2/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/ +SWIGINTERN VALUE SWIG_AUX_NUM2ULONG(VALUE arg) { + VALUE *args = (VALUE *)arg; VALUE obj = args[0]; VALUE type = TYPE(obj); unsigned long *res = (unsigned long *)(args[1]); @@ -2200,7 +2243,7 @@ SWIG_AsVal_unsigned_SS_long (VALUE obj, unsigned long *val) VALUE a[2]; a[0] = obj; a[1] = (VALUE)(&v); - if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2ULONG), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) { + if (rb_rescue(VALUEFUNC(SWIG_AUX_NUM2ULONG), (VALUE)a, VALUEFUNC(SWIG_ruby_failed), 0) != Qnil) { if (val) *val = v; return SWIG_OK; } @@ -2257,9 +2300,16 @@ SWIG_AsVal_unsigned_SS_char (VALUE obj, unsigned char *val) } -/*@SWIG:/usr/local/share/swig/3.0.7/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/ -SWIGINTERN VALUE SWIG_AUX_NUM2LL(VALUE *args) +#if defined(LLONG_MAX) && !defined(SWIG_LONG_LONG_AVAILABLE) +# define SWIG_LONG_LONG_AVAILABLE +#endif + + +#ifdef SWIG_LONG_LONG_AVAILABLE +/*@SWIG:/usr/local/Cellar/swig/4.0.2/share/swig/4.0.2/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/ +SWIGINTERN VALUE SWIG_AUX_NUM2LL(VALUE arg) { + VALUE *args = (VALUE *)arg; VALUE obj = args[0]; VALUE type = TYPE(obj); long long *res = (long long *)(args[1]); @@ -2277,13 +2327,14 @@ SWIG_AsVal_long_SS_long (VALUE obj, long long *val) VALUE a[2]; a[0] = obj; a[1] = (VALUE)(&v); - if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2LL), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) { + if (rb_rescue(VALUEFUNC(SWIG_AUX_NUM2LL), (VALUE)a, VALUEFUNC(SWIG_ruby_failed), 0) != Qnil) { if (val) *val = v; return SWIG_OK; } } return SWIG_TypeError; } +#endif SWIGINTERN int @@ -2313,11 +2364,13 @@ SWIG_From_unsigned_SS_char (unsigned char value) } +#ifdef SWIG_LONG_LONG_AVAILABLE SWIGINTERNINLINE VALUE SWIG_From_long_SS_long (long long value) { return LL2NUM(value); } +#endif SWIGINTERN TagLib::MP4::Item *TagLib_MP4_Item_from_bool(bool q){ return new TagLib::MP4::Item(q); @@ -2473,22 +2526,20 @@ _wrap_new_Properties__SWIG_0(int argc, VALUE *argv, VALUE self) { } -#ifdef HAVE_RB_DEFINE_ALLOC_FUNC SWIGINTERN VALUE -_wrap_Properties_allocate(VALUE self) { +#ifdef HAVE_RB_DEFINE_ALLOC_FUNC +_wrap_Properties_allocate(VALUE self) #else - SWIGINTERN VALUE - _wrap_Properties_allocate(int argc, VALUE *argv, VALUE self) { +_wrap_Properties_allocate(int argc, VALUE *argv, VALUE self) #endif - - - VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__MP4__Properties); +{ + VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__MP4__Properties); #ifndef HAVE_RB_DEFINE_ALLOC_FUNC - rb_obj_call_init(vresult, argc, argv); + rb_obj_call_init(vresult, argc, argv); #endif - return vresult; - } - + return vresult; +} + SWIGINTERN VALUE _wrap_new_Properties__SWIG_1(int argc, VALUE *argv, VALUE self) { @@ -2577,7 +2628,8 @@ SWIGINTERN VALUE _wrap_new_Properties(int nargs, VALUE *args, VALUE self) { SWIGINTERN void -free_TagLib_MP4_Properties(TagLib::MP4::Properties *arg1) { +free_TagLib_MP4_Properties(void *self) { + TagLib::MP4::Properties *arg1 = (TagLib::MP4::Properties *)self; SWIG_RubyRemoveTracking(arg1); delete arg1; } @@ -2792,22 +2844,20 @@ _wrap_new_Tag__SWIG_0(int argc, VALUE *argv, VALUE self) { } -#ifdef HAVE_RB_DEFINE_ALLOC_FUNC SWIGINTERN VALUE -_wrap_Tag_allocate(VALUE self) { +#ifdef HAVE_RB_DEFINE_ALLOC_FUNC +_wrap_Tag_allocate(VALUE self) #else - SWIGINTERN VALUE - _wrap_Tag_allocate(int argc, VALUE *argv, VALUE self) { +_wrap_Tag_allocate(int argc, VALUE *argv, VALUE self) #endif - - - VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__MP4__Tag); +{ + VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__MP4__Tag); #ifndef HAVE_RB_DEFINE_ALLOC_FUNC - rb_obj_call_init(vresult, argc, argv); + rb_obj_call_init(vresult, argc, argv); #endif - return vresult; - } - + return vresult; +} + SWIGINTERN VALUE _wrap_new_Tag__SWIG_1(int argc, VALUE *argv, VALUE self) { @@ -2879,7 +2929,8 @@ SWIGINTERN VALUE _wrap_new_Tag(int nargs, VALUE *args, VALUE self) { SWIGINTERN void -free_TagLib_MP4_Tag(TagLib::MP4::Tag *arg1) { +free_TagLib_MP4_Tag(void *self) { + TagLib::MP4::Tag *arg1 = (TagLib::MP4::Tag *)self; SWIG_RubyRemoveTracking(arg1); delete arg1; } @@ -3387,7 +3438,6 @@ _wrap_Tag_contains(int argc, VALUE *argv, VALUE self) { } - /* Document-method: TagLib::MP4::Tag.[]= @@ -3500,27 +3550,26 @@ _wrap_new_CoverArt__SWIG_0(int argc, VALUE *argv, VALUE self) { SWIGINTERN void -free_TagLib_MP4_CoverArt(TagLib::MP4::CoverArt *arg1) { +free_TagLib_MP4_CoverArt(void *self) { + TagLib::MP4::CoverArt *arg1 = (TagLib::MP4::CoverArt *)self; SWIG_RubyRemoveTracking(arg1); delete arg1; } -#ifdef HAVE_RB_DEFINE_ALLOC_FUNC SWIGINTERN VALUE -_wrap_CoverArt_allocate(VALUE self) { +#ifdef HAVE_RB_DEFINE_ALLOC_FUNC +_wrap_CoverArt_allocate(VALUE self) #else - SWIGINTERN VALUE - _wrap_CoverArt_allocate(int argc, VALUE *argv, VALUE self) { +_wrap_CoverArt_allocate(int argc, VALUE *argv, VALUE self) #endif - - - VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__MP4__CoverArt); +{ + VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__MP4__CoverArt); #ifndef HAVE_RB_DEFINE_ALLOC_FUNC - rb_obj_call_init(vresult, argc, argv); + rb_obj_call_init(vresult, argc, argv); #endif - return vresult; - } - + return vresult; +} + SWIGINTERN VALUE _wrap_new_CoverArt__SWIG_1(int argc, VALUE *argv, VALUE self) { @@ -3562,7 +3611,7 @@ SWIGINTERN VALUE _wrap_new_CoverArt(int nargs, VALUE *args, VALUE self) { if (argc == 1) { int _v; void *vptr = 0; - int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_TagLib__MP4__CoverArt, 0); + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_TagLib__MP4__CoverArt, SWIG_POINTER_NO_NULL); _v = SWIG_CheckState(res); if (_v) { return _wrap_new_CoverArt__SWIG_1(nargs, args, self); @@ -3688,7 +3737,8 @@ _wrap_new_Item__SWIG_1(int argc, VALUE *argv, VALUE self) { SWIGINTERN void -free_TagLib_MP4_Item(TagLib::MP4::Item *arg1) { +free_TagLib_MP4_Item(void *self) { + TagLib::MP4::Item *arg1 = (TagLib::MP4::Item *)self; SWIG_RubyRemoveTracking(arg1); delete arg1; } @@ -3870,21 +3920,16 @@ _wrap_new_Item__SWIG_8(int argc, VALUE *argv, VALUE self) { SWIGINTERN VALUE _wrap_new_Item__SWIG_9(int argc, VALUE *argv, VALUE self) { TagLib::ByteVectorList *arg1 = 0 ; - void *argp1 ; - int res1 = 0 ; + TagLib::ByteVectorList tmp1 ; TagLib::MP4::Item *result = 0 ; if ((argc < 1) || (argc > 1)) { rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; } - res1 = SWIG_ConvertPtr(argv[0], &argp1, SWIGTYPE_p_TagLib__ByteVectorList, 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "TagLib::ByteVectorList const &","Item", 1, argv[0] )); - } - if (!argp1) { - SWIG_exception_fail(SWIG_ValueError, Ruby_Format_TypeError("invalid null reference ", "TagLib::ByteVectorList const &","Item", 1, argv[0])); + { + tmp1 = ruby_array_to_taglib_bytevectorlist(argv[0]); + arg1 = &tmp1; } - arg1 = reinterpret_cast< TagLib::ByteVectorList * >(argp1); result = (TagLib::MP4::Item *)new TagLib::MP4::Item((TagLib::ByteVectorList const &)*arg1); DATA_PTR(self) = result; SWIG_RubyAddTracking(result, self); @@ -3894,22 +3939,20 @@ _wrap_new_Item__SWIG_9(int argc, VALUE *argv, VALUE self) { } -#ifdef HAVE_RB_DEFINE_ALLOC_FUNC SWIGINTERN VALUE -_wrap_Item_allocate(VALUE self) { +#ifdef HAVE_RB_DEFINE_ALLOC_FUNC +_wrap_Item_allocate(VALUE self) #else - SWIGINTERN VALUE - _wrap_Item_allocate(int argc, VALUE *argv, VALUE self) { +_wrap_Item_allocate(int argc, VALUE *argv, VALUE self) #endif - - - VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__MP4__Item); +{ + VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__MP4__Item); #ifndef HAVE_RB_DEFINE_ALLOC_FUNC - rb_obj_call_init(vresult, argc, argv); + rb_obj_call_init(vresult, argc, argv); #endif - return vresult; - } - + return vresult; +} + SWIGINTERN VALUE _wrap_new_Item__SWIG_10(int argc, VALUE *argv, VALUE self) { @@ -3949,7 +3992,7 @@ SWIGINTERN VALUE _wrap_new_Item(int nargs, VALUE *args, VALUE self) { if (argc == 1) { int _v; void *vptr = 0; - int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_TagLib__MP4__Item, 0); + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_TagLib__MP4__Item, SWIG_POINTER_NO_NULL); _v = SWIG_CheckState(res); if (_v) { return _wrap_new_Item__SWIG_1(nargs, args, self); @@ -3958,7 +4001,7 @@ SWIGINTERN VALUE _wrap_new_Item(int nargs, VALUE *args, VALUE self) { if (argc == 1) { int _v; void *vptr = 0; - int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_TagLib__StringList, 0); + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_TagLib__StringList, SWIG_POINTER_NO_NULL); _v = SWIG_CheckState(res); if (_v) { return _wrap_new_Item__SWIG_8(nargs, args, self); @@ -3967,7 +4010,7 @@ SWIGINTERN VALUE _wrap_new_Item(int nargs, VALUE *args, VALUE self) { if (argc == 1) { int _v; void *vptr = 0; - int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_TagLib__ByteVectorList, 0); + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_TagLib__ByteVectorList, SWIG_POINTER_NO_NULL); _v = SWIG_CheckState(res); if (_v) { return _wrap_new_Item__SWIG_9(nargs, args, self); @@ -3976,7 +4019,7 @@ SWIGINTERN VALUE _wrap_new_Item(int nargs, VALUE *args, VALUE self) { if (argc == 1) { int _v; void *vptr = 0; - int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_TagLib__MP4__CoverArtList, 0); + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_TagLib__MP4__CoverArtList, SWIG_POINTER_NO_NULL); _v = SWIG_CheckState(res); if (_v) { return _wrap_new_Item__SWIG_10(nargs, args, self); @@ -4256,7 +4299,9 @@ _wrap_Item_to_byte_vector_list(int argc, VALUE *argv, VALUE self) { } arg1 = reinterpret_cast< TagLib::MP4::Item * >(argp1); result = ((TagLib::MP4::Item const *)arg1)->toByteVectorList(); - vresult = SWIG_NewPointerObj((new TagLib::ByteVectorList(static_cast< const TagLib::ByteVectorList& >(result))), SWIGTYPE_p_TagLib__ByteVectorList, SWIG_POINTER_OWN | 0 ); + { + vresult = taglib_bytevectorlist_to_ruby_array(result); + } return vresult; fail: return Qnil; @@ -4480,22 +4525,17 @@ _wrap_Item_from_cover_art_list(int argc, VALUE *argv, VALUE self) { SWIGINTERN VALUE _wrap_Item_from_byte_vector_list(int argc, VALUE *argv, VALUE self) { TagLib::ByteVectorList *arg1 = 0 ; - void *argp1 ; - int res1 = 0 ; + TagLib::ByteVectorList tmp1 ; TagLib::MP4::Item *result = 0 ; VALUE vresult = Qnil; if ((argc < 1) || (argc > 1)) { rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; } - res1 = SWIG_ConvertPtr(argv[0], &argp1, SWIGTYPE_p_TagLib__ByteVectorList, 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "TagLib::ByteVectorList const &","TagLib_MP4_Item_from_byte_vector_list", 1, argv[0] )); - } - if (!argp1) { - SWIG_exception_fail(SWIG_ValueError, Ruby_Format_TypeError("invalid null reference ", "TagLib::ByteVectorList const &","TagLib_MP4_Item_from_byte_vector_list", 1, argv[0])); + { + tmp1 = ruby_array_to_taglib_bytevectorlist(argv[0]); + arg1 = &tmp1; } - arg1 = reinterpret_cast< TagLib::ByteVectorList * >(argp1); result = (TagLib::MP4::Item *)TagLib_MP4_Item_from_byte_vector_list((TagLib::ByteVectorList const &)*arg1); vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_TagLib__MP4__Item, 0 | 0 ); return vresult; @@ -4576,22 +4616,20 @@ _wrap_new_File__SWIG_1(int argc, VALUE *argv, VALUE self) { } -#ifdef HAVE_RB_DEFINE_ALLOC_FUNC SWIGINTERN VALUE -_wrap_File_allocate(VALUE self) { +#ifdef HAVE_RB_DEFINE_ALLOC_FUNC +_wrap_File_allocate(VALUE self) #else - SWIGINTERN VALUE - _wrap_File_allocate(int argc, VALUE *argv, VALUE self) { +_wrap_File_allocate(int argc, VALUE *argv, VALUE self) #endif - - - VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__MP4__File); +{ + VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__MP4__File); #ifndef HAVE_RB_DEFINE_ALLOC_FUNC - rb_obj_call_init(vresult, argc, argv); + rb_obj_call_init(vresult, argc, argv); #endif - return vresult; - } - + return vresult; +} + SWIGINTERN VALUE _wrap_new_File__SWIG_2(int argc, VALUE *argv, VALUE self) { @@ -4814,22 +4852,20 @@ _wrap_new_ItemMap__SWIG_0(int argc, VALUE *argv, VALUE self) { } -#ifdef HAVE_RB_DEFINE_ALLOC_FUNC SWIGINTERN VALUE -_wrap_ItemMap_allocate(VALUE self) { +#ifdef HAVE_RB_DEFINE_ALLOC_FUNC +_wrap_ItemMap_allocate(VALUE self) #else - SWIGINTERN VALUE - _wrap_ItemMap_allocate(int argc, VALUE *argv, VALUE self) { +_wrap_ItemMap_allocate(int argc, VALUE *argv, VALUE self) #endif - - - VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__MapT_TagLib__String_TagLib__MP4__Item_t); +{ + VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__MapT_TagLib__String_TagLib__MP4__Item_t); #ifndef HAVE_RB_DEFINE_ALLOC_FUNC - rb_obj_call_init(vresult, argc, argv); + rb_obj_call_init(vresult, argc, argv); #endif - return vresult; - } - + return vresult; +} + SWIGINTERN VALUE _wrap_new_ItemMap__SWIG_1(int argc, VALUE *argv, VALUE self) { @@ -4874,7 +4910,7 @@ SWIGINTERN VALUE _wrap_new_ItemMap(int nargs, VALUE *args, VALUE self) { if (argc == 1) { int _v; void *vptr = 0; - int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_TagLib__MapT_TagLib__String_TagLib__MP4__Item_t, 0); + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_TagLib__MapT_TagLib__String_TagLib__MP4__Item_t, SWIG_POINTER_NO_NULL); _v = SWIG_CheckState(res); if (_v) { return _wrap_new_ItemMap__SWIG_1(nargs, args, self); @@ -4891,12 +4927,12 @@ SWIGINTERN VALUE _wrap_new_ItemMap(int nargs, VALUE *args, VALUE self) { SWIGINTERN void -free_TagLib_Map_Sl_TagLib_String_Sc_TagLib_MP4_Item_Sg_(TagLib::Map< TagLib::String,TagLib::MP4::Item > *arg1) { +free_TagLib_Map_Sl_TagLib_String_Sc_TagLib_MP4_Item_Sg_(void *self) { + TagLib::Map< TagLib::String,TagLib::MP4::Item > *arg1 = (TagLib::Map< TagLib::String,TagLib::MP4::Item > *)self; SWIG_RubyRemoveTracking(arg1); delete arg1; } - /* Document-method: TagLib::MP4::ItemMap.size @@ -4983,7 +5019,6 @@ _wrap_ItemMap_contains(int argc, VALUE *argv, VALUE self) { } - /* Document-method: TagLib::MP4::ItemMap.to_a @@ -5360,7 +5395,7 @@ SWIG_InitializeModule(void *clientdata) { /* Now work on filling in swig_module.types */ #ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: size %d\n", swig_module.size); + printf("SWIG_InitializeModule: size %lu\n", (unsigned long)swig_module.size); #endif for (i = 0; i < swig_module.size; ++i) { swig_type_info *type = 0; @@ -5368,7 +5403,7 @@ SWIG_InitializeModule(void *clientdata) { swig_cast_info *cast; #ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); + printf("SWIG_InitializeModule: type %lu %s\n", (unsigned long)i, swig_module.type_initial[i]->name); #endif /* if there is another module already loaded */ @@ -5444,7 +5479,7 @@ SWIG_InitializeModule(void *clientdata) { for (i = 0; i < swig_module.size; ++i) { int j = 0; swig_cast_info *cast = swig_module.cast_initial[i]; - printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); + printf("SWIG_InitializeModule: type %lu %s\n", (unsigned long)i, swig_module.type_initial[i]->name); while (cast->type) { printf("SWIG_InitializeModule: cast type %s\n", cast->type->name); cast++; diff --git a/ext/taglib_mpeg/taglib_mpeg_wrap.cxx b/ext/taglib_mpeg/taglib_mpeg_wrap.cxx index 4f026e3..d3ca1a9 100644 --- a/ext/taglib_mpeg/taglib_mpeg_wrap.cxx +++ b/ext/taglib_mpeg/taglib_mpeg_wrap.cxx @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 3.0.7 + * Version 4.0.2 * * This file is not intended to be easily readable and contains a number of * coding conventions designed to improve portability and efficiency. Do not make @@ -11,7 +11,11 @@ static void free_taglib_mpeg_file(void *ptr); + +#ifndef SWIGRUBY #define SWIGRUBY +#endif + #ifdef __cplusplus @@ -104,9 +108,11 @@ template T SwigValueInit() { #endif /* exporting methods */ -#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) -# ifndef GCC_HASCLASSVISIBILITY -# define GCC_HASCLASSVISIBILITY +#if defined(__GNUC__) +# if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +# ifndef GCC_HASCLASSVISIBILITY +# define GCC_HASCLASSVISIBILITY +# endif # endif #endif @@ -226,9 +232,11 @@ template T SwigValueInit() { #endif /* exporting methods */ -#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) -# ifndef GCC_HASCLASSVISIBILITY -# define GCC_HASCLASSVISIBILITY +#if defined(__GNUC__) +# if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +# ifndef GCC_HASCLASSVISIBILITY +# define GCC_HASCLASSVISIBILITY +# endif # endif #endif @@ -326,6 +334,7 @@ template T SwigValueInit() { /* Flags for pointer conversions */ #define SWIG_POINTER_DISOWN 0x1 #define SWIG_CAST_NEW_MEMORY 0x2 +#define SWIG_POINTER_NO_NULL 0x4 /* Flags for new pointer objects */ #define SWIG_POINTER_OWN 0x1 @@ -778,16 +787,16 @@ SWIG_UnpackData(const char *c, void *ptr, size_t sz) { char d = *(c++); unsigned char uu; if ((d >= '0') && (d <= '9')) - uu = ((d - '0') << 4); + uu = (unsigned char)((d - '0') << 4); else if ((d >= 'a') && (d <= 'f')) - uu = ((d - ('a'-10)) << 4); + uu = (unsigned char)((d - ('a'-10)) << 4); else return (char *) 0; d = *(c++); if ((d >= '0') && (d <= '9')) - uu |= (d - '0'); + uu |= (unsigned char)(d - '0'); else if ((d >= 'a') && (d <= 'f')) - uu |= (d - ('a'-10)); + uu |= (unsigned char)(d - ('a'-10)); else return (char *) 0; *u = uu; @@ -964,42 +973,53 @@ SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { #ifndef RSTRUCT_PTR # define RSTRUCT_PTR(x) RSTRUCT(x)->ptr #endif +#ifndef RTYPEDDATA_P +# define RTYPEDDATA_P(x) (TYPE(x) != T_DATA) +#endif /* - * Need to be very careful about how these macros are defined, especially - * when compiling C++ code or C code with an ANSI C compiler. + * The following macros are used for providing the correct type of a + * function pointer to the Ruby C API. + * Starting with Ruby 2.7 (corresponding to RB_METHOD_DEFINITION_DECL being + * defined) these macros act transparently due to Ruby's moving away from + * ANYARGS and instead employing strict function signatures. + * + * Note: In case of C (not C++) the macros are transparent even before + * Ruby 2.7 due to the fact that the Ruby C API used function declarators + * with empty parentheses, which allows for an unspecified number of + * arguments. + * + * PROTECTFUNC(f) is used for the function pointer argument of the Ruby + * C API function rb_protect(). * - * VALUEFUNC(f) is a macro used to typecast a C function that implements - * a Ruby method so that it can be passed as an argument to API functions - * like rb_define_method() and rb_define_singleton_method(). + * VALUEFUNC(f) is used for the function pointer argument(s) of Ruby C API + * functions like rb_define_method() and rb_define_singleton_method(). * - * VOIDFUNC(f) is a macro used to typecast a C function that implements - * either the "mark" or "free" stuff for a Ruby Data object, so that it - * can be passed as an argument to API functions like Data_Wrap_Struct() + * VOIDFUNC(f) is used to typecast a C function that implements either + * the "mark" or "free" stuff for a Ruby Data object, so that it can be + * passed as an argument to Ruby C API functions like Data_Wrap_Struct() * and Data_Make_Struct(). + * + * SWIG_RUBY_VOID_ANYARGS_FUNC(f) is used for the function pointer + * argument(s) of Ruby C API functions like rb_define_virtual_variable(). + * + * SWIG_RUBY_INT_ANYARGS_FUNC(f) is used for the function pointer + * argument(s) of Ruby C API functions like st_foreach(). */ - -#ifdef __cplusplus -# ifndef RUBY_METHOD_FUNC /* These definitions should work for Ruby 1.4.6 */ -# define PROTECTFUNC(f) ((VALUE (*)()) f) -# define VALUEFUNC(f) ((VALUE (*)()) f) -# define VOIDFUNC(f) ((void (*)()) f) -# else -# ifndef ANYARGS /* These definitions should work for Ruby 1.6 */ -# define PROTECTFUNC(f) ((VALUE (*)()) f) -# define VALUEFUNC(f) ((VALUE (*)()) f) -# define VOIDFUNC(f) ((RUBY_DATA_FUNC) f) -# else /* These definitions should work for Ruby 1.7+ */ -# define PROTECTFUNC(f) ((VALUE (*)(VALUE)) f) -# define VALUEFUNC(f) ((VALUE (*)(ANYARGS)) f) -# define VOIDFUNC(f) ((RUBY_DATA_FUNC) f) -# endif -# endif +#if defined(__cplusplus) && !defined(RB_METHOD_DEFINITION_DECL) +# define PROTECTFUNC(f) ((VALUE (*)(VALUE)) f) +# define VALUEFUNC(f) ((VALUE (*)(ANYARGS)) f) +# define VOIDFUNC(f) ((RUBY_DATA_FUNC) f) +# define SWIG_RUBY_VOID_ANYARGS_FUNC(f) ((void (*)(ANYARGS))(f)) +# define SWIG_RUBY_INT_ANYARGS_FUNC(f) ((int (*)(ANYARGS))(f)) #else +# define PROTECTFUNC(f) (f) # define VALUEFUNC(f) (f) # define VOIDFUNC(f) (f) +# define SWIG_RUBY_VOID_ANYARGS_FUNC(f) (f) +# define SWIG_RUBY_INT_ANYARGS_FUNC(f) (f) #endif /* Don't use for expressions have side effect */ @@ -1187,7 +1207,7 @@ void Ruby_Format_OverloadedError( /* ----------------------------------------------------------------------------- * rubytracking.swg * - * This file contains support for tracking mappings from + * This file contains support for tracking mappings from * Ruby objects to C++ objects. This functionality is needed * to implement mark functions for Ruby's mark and sweep * garbage collector. @@ -1197,6 +1217,11 @@ void Ruby_Format_OverloadedError( extern "C" { #endif +#if !defined(ST_DATA_T_DEFINED) +/* Needs to be explicitly included for Ruby 1.8 and earlier */ +#include +#endif + /* Ruby 1.8 actually assumes the first case. */ #if SIZEOF_VOIDP == SIZEOF_LONG # define SWIG2NUM(v) LONG2NUM((unsigned long)v) @@ -1208,109 +1233,69 @@ extern "C" { # error sizeof(void*) is not the same as long or long long #endif - -/* Global Ruby hash table to store Trackings from C/C++ - structs to Ruby Objects. +/* Global hash table to store Trackings from C/C++ + structs to Ruby Objects. */ -static VALUE swig_ruby_trackings = Qnil; +static st_table* swig_ruby_trackings = NULL; + +static VALUE swig_ruby_trackings_count(ID id, VALUE *var) { + return SWIG2NUM(swig_ruby_trackings->num_entries); +} -/* Global variable that stores a reference to the ruby - hash table delete function. */ -static ID swig_ruby_hash_delete; -/* Setup a Ruby hash table to store Trackings */ +/* Setup a hash table to store Trackings */ SWIGRUNTIME void SWIG_RubyInitializeTrackings(void) { - /* Create a ruby hash table to store Trackings from C++ + /* Create a hash table to store Trackings from C++ objects to Ruby objects. */ - /* Try to see if some other .so has already created a + /* Try to see if some other .so has already created a tracking hash table, which we keep hidden in an instance var in the SWIG module. This is done to allow multiple DSOs to share the same tracking table. */ - ID trackings_id = rb_intern( "@__trackings__" ); + VALUE trackings_value = Qnil; + /* change the variable name so that we can mix modules + compiled with older SWIG's - this used to be called "@__trackings__" */ + ID trackings_id = rb_intern( "@__safetrackings__" ); VALUE verbose = rb_gv_get("VERBOSE"); rb_gv_set("VERBOSE", Qfalse); - swig_ruby_trackings = rb_ivar_get( _mSWIG, trackings_id ); + trackings_value = rb_ivar_get( _mSWIG, trackings_id ); rb_gv_set("VERBOSE", verbose); - /* No, it hasn't. Create one ourselves */ - if ( swig_ruby_trackings == Qnil ) - { - swig_ruby_trackings = rb_hash_new(); - rb_ivar_set( _mSWIG, trackings_id, swig_ruby_trackings ); - } - - /* Now store a reference to the hash table delete function - so that we only have to look it up once.*/ - swig_ruby_hash_delete = rb_intern("delete"); -} - -/* Get a Ruby number to reference a pointer */ -SWIGRUNTIME VALUE SWIG_RubyPtrToReference(void* ptr) { - /* We cast the pointer to an unsigned long - and then store a reference to it using - a Ruby number object. */ - - /* Convert the pointer to a Ruby number */ - return SWIG2NUM(ptr); -} - -/* Get a Ruby number to reference an object */ -SWIGRUNTIME VALUE SWIG_RubyObjectToReference(VALUE object) { - /* We cast the object to an unsigned long - and then store a reference to it using - a Ruby number object. */ - - /* Convert the Object to a Ruby number */ - return SWIG2NUM(object); -} - -/* Get a Ruby object from a previously stored reference */ -SWIGRUNTIME VALUE SWIG_RubyReferenceToObject(VALUE reference) { - /* The provided Ruby number object is a reference - to the Ruby object we want.*/ + /* The trick here is that we have to store the hash table + pointer in a Ruby variable. We do not want Ruby's GC to + treat this pointer as a Ruby object, so we convert it to + a Ruby numeric value. */ + if (trackings_value == Qnil) { + /* No, it hasn't. Create one ourselves */ + swig_ruby_trackings = st_init_numtable(); + rb_ivar_set( _mSWIG, trackings_id, SWIG2NUM(swig_ruby_trackings) ); + } else { + swig_ruby_trackings = (st_table*)NUM2SWIG(trackings_value); + } - /* Convert the Ruby number to a Ruby object */ - return NUM2SWIG(reference); + rb_define_virtual_variable("SWIG_TRACKINGS_COUNT", + VALUEFUNC(swig_ruby_trackings_count), + SWIG_RUBY_VOID_ANYARGS_FUNC((rb_gvar_setter_t*)NULL)); } /* Add a Tracking from a C/C++ struct to a Ruby object */ SWIGRUNTIME void SWIG_RubyAddTracking(void* ptr, VALUE object) { - /* In a Ruby hash table we store the pointer and - the associated Ruby object. The trick here is - that we cannot store the Ruby object directly - if - we do then it cannot be garbage collected. So - instead we typecast it as a unsigned long and - convert it to a Ruby number object.*/ - - /* Get a reference to the pointer as a Ruby number */ - VALUE key = SWIG_RubyPtrToReference(ptr); - - /* Get a reference to the Ruby object as a Ruby number */ - VALUE value = SWIG_RubyObjectToReference(object); - /* Store the mapping to the global hash table. */ - rb_hash_aset(swig_ruby_trackings, key, value); + st_insert(swig_ruby_trackings, (st_data_t)ptr, object); } /* Get the Ruby object that owns the specified C/C++ struct */ SWIGRUNTIME VALUE SWIG_RubyInstanceFor(void* ptr) { - /* Get a reference to the pointer as a Ruby number */ - VALUE key = SWIG_RubyPtrToReference(ptr); - /* Now lookup the value stored in the global hash table */ - VALUE value = rb_hash_aref(swig_ruby_trackings, key); - - if (value == Qnil) { - /* No object exists - return nil. */ + VALUE value; + + if (st_lookup(swig_ruby_trackings, (st_data_t)ptr, &value)) { + return value; + } else { return Qnil; } - else { - /* Convert this value to Ruby object */ - return SWIG_RubyReferenceToObject(value); - } } /* Remove a Tracking from a C/C++ struct to a Ruby object. It @@ -1318,25 +1303,39 @@ SWIGRUNTIME VALUE SWIG_RubyInstanceFor(void* ptr) { since the same memory address may be reused later to create a new object. */ SWIGRUNTIME void SWIG_RubyRemoveTracking(void* ptr) { - /* Get a reference to the pointer as a Ruby number */ - VALUE key = SWIG_RubyPtrToReference(ptr); - - /* Delete the object from the hash table by calling Ruby's - do this we need to call the Hash.delete method.*/ - rb_funcall(swig_ruby_trackings, swig_ruby_hash_delete, 1, key); + /* Delete the object from the hash table */ + st_delete(swig_ruby_trackings, (st_data_t *)&ptr, NULL); } /* This is a helper method that unlinks a Ruby object from its underlying C++ object. This is needed if the lifetime of the - Ruby object is longer than the C++ object */ + Ruby object is longer than the C++ object. */ SWIGRUNTIME void SWIG_RubyUnlinkObjects(void* ptr) { VALUE object = SWIG_RubyInstanceFor(ptr); if (object != Qnil) { + // object might have the T_ZOMBIE type, but that's just + // because the GC has flagged it as such for a deferred + // destruction. Until then, it's still a T_DATA object. DATA_PTR(object) = 0; } } +/* This is a helper method that iterates over all the trackings + passing the C++ object pointer and its related Ruby object + to the passed callback function. */ + +/* Proxy method to abstract the internal trackings datatype */ +static int swig_ruby_internal_iterate_callback(st_data_t ptr, st_data_t obj, st_data_t meth) { + ((void (*) (void *, VALUE))meth)((void *)ptr, (VALUE)obj); + return ST_CONTINUE; +} + +SWIGRUNTIME void SWIG_RubyIterateTrackings( void(*meth)(void* ptr, VALUE obj) ) { + st_foreach(swig_ruby_trackings, + SWIG_RUBY_INT_ANYARGS_FUNC(swig_ruby_internal_iterate_callback), + (st_data_t)meth); +} #ifdef __cplusplus } @@ -1395,7 +1394,7 @@ SWIG_Ruby_AppendOutput(VALUE target, VALUE o) { #define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Ruby_ConvertPtrAndOwn(obj, pptr, type, flags, own) #define SWIG_NewPointerObj(ptr, type, flags) SWIG_Ruby_NewPointerObj(ptr, type, flags) #define SWIG_AcquirePtr(ptr, own) SWIG_Ruby_AcquirePtr(ptr, own) -#define swig_owntype ruby_owntype +#define swig_owntype swig_ruby_owntype /* for raw packed data */ #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) swig_class *sklass; VALUE klass; VALUE obj; - + if (!ptr) return Qnil; - + + assert(type); if (type->clientdata) { sklass = (swig_class *) type->clientdata; @@ -1563,7 +1563,7 @@ SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags) track = sklass->trackObjects; if (track) { obj = SWIG_RubyInstanceFor(ptr); - + /* Check the object's type and make sure it has the correct type. It might not in cases where methods do things like downcast methods. */ @@ -1595,7 +1595,7 @@ SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags) obj = Data_Wrap_Struct(klass, 0, 0, ptr); } rb_iv_set(obj, "@__swigtype__", rb_str_new2(type->name)); - + return obj; } @@ -1615,26 +1615,30 @@ SWIGRUNTIMEINLINE char * SWIG_Ruby_MangleStr(VALUE obj) { VALUE stype = rb_iv_get(obj, "@__swigtype__"); + if (NIL_P(stype)) + return NULL; return StringValuePtr(stype); } /* Acquire a pointer value */ -typedef void (*ruby_owntype)(void*); - -SWIGRUNTIME ruby_owntype -SWIG_Ruby_AcquirePtr(VALUE obj, ruby_owntype own) { - if (obj) { - ruby_owntype oldown = RDATA(obj)->dfree; - RDATA(obj)->dfree = own; - return oldown; - } else { - return 0; +typedef struct { + void (*datafree)(void *); + int own; +} swig_ruby_owntype; + +SWIGRUNTIME swig_ruby_owntype +SWIG_Ruby_AcquirePtr(VALUE obj, swig_ruby_owntype own) { + swig_ruby_owntype oldown = {0, 0}; + if (TYPE(obj) == T_DATA && !RTYPEDDATA_P(obj)) { + oldown.datafree = RDATA(obj)->dfree; + RDATA(obj)->dfree = own.datafree; } + return oldown; } /* Convert a pointer value */ SWIGRUNTIME int -SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, ruby_owntype *own) +SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, swig_ruby_owntype *own) { char *c; swig_cast_info *tc; @@ -1642,16 +1646,20 @@ SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, /* Grab the pointer */ if (NIL_P(obj)) { - *ptr = 0; - return SWIG_OK; + if (ptr) + *ptr = 0; + return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK; } else { - if (TYPE(obj) != T_DATA) { + if (TYPE(obj) != T_DATA || (TYPE(obj) == T_DATA && RTYPEDDATA_P(obj))) { return SWIG_ERROR; } Data_Get_Struct(obj, void, vptr); } - if (own) *own = RDATA(obj)->dfree; + if (own) { + own->datafree = RDATA(obj)->dfree; + own->own = 0; + } /* Check to see if the input object is giving up ownership 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, /* The object has already been deleted */ return SWIG_ObjectPreviouslyDeletedError; } - *ptr = vptr; - return SWIG_OK; } } if ((c = SWIG_MangleStr(obj)) == NULL) { @@ -1697,12 +1703,23 @@ SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, if (!tc) { return SWIG_ERROR; } else { - int newmemory = 0; - *ptr = SWIG_TypeCast(tc, vptr, &newmemory); - assert(!newmemory); /* newmemory handling not yet implemented */ + if (ptr) { + if (tc->type == ty) { + *ptr = vptr; + } else { + int newmemory = 0; + *ptr = SWIG_TypeCast(tc, vptr, &newmemory); + if (newmemory == SWIG_CAST_NEW_MEMORY) { + assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */ + if (own) + own->own = own->own | SWIG_CAST_NEW_MEMORY; + } + } + } } } else { - *ptr = vptr; + if (ptr) + *ptr = vptr; } return SWIG_OK; @@ -1728,7 +1745,7 @@ SWIG_Ruby_NewPackedObj(void *ptr, int sz, swig_type_info *type) { return rb_str_new2(result); } -/* Convert a packed value value */ +/* Convert a packed pointer value */ SWIGRUNTIME int SWIG_Ruby_ConvertPacked(VALUE obj, void *ptr, int sz, swig_type_info *ty) { swig_cast_info *tc; @@ -1862,7 +1879,7 @@ static VALUE mMPEG; #define SWIG_RUBY_THREAD_END_BLOCK -#define SWIGVERSION 0x030007 +#define SWIGVERSION 0x040002 #define SWIG_VERSION SWIGVERSION @@ -1883,6 +1900,8 @@ static VALUE mMPEG; #include #include +#include +#include #include #if defined(HAVE_RUBY_ENCODING_H) && HAVE_RUBY_ENCODING_H @@ -1952,6 +1971,28 @@ TagLib::StringList ruby_array_to_taglib_string_list(VALUE ary) { return result; } +VALUE taglib_bytevectorlist_to_ruby_array(const TagLib::ByteVectorList & list) { + VALUE ary = rb_ary_new2(list.size()); + for (TagLib::ByteVectorList::ConstIterator it = list.begin(); it != list.end(); it++) { + VALUE s = taglib_bytevector_to_ruby_string(*it); + rb_ary_push(ary, s); + } + return ary; +} + +TagLib::ByteVectorList ruby_array_to_taglib_bytevectorlist(VALUE ary) { + TagLib::ByteVectorList result = TagLib::ByteVectorList(); + if (NIL_P(ary)) { + return result; + } + for (long i = 0; i < RARRAY_LEN(ary); i++) { + VALUE e = rb_ary_entry(ary, i); + TagLib::ByteVector s = ruby_string_to_taglib_bytevector(e); + result.append(s); + } + return result; +} + VALUE taglib_filename_to_ruby_string(TagLib::FileName filename) { VALUE result; #ifdef _WIN32 @@ -2035,7 +2076,7 @@ SWIG_AsCharPtrAndSize(VALUE obj, char** cptr, size_t* psize, int *alloc) if (cptr) { if (alloc) { if (*alloc == SWIG_NEWOBJ) { - *cptr = reinterpret_cast< char* >(memcpy((new char[size]), cstr, sizeof(char)*(size))); + *cptr = reinterpret_cast< char* >(memcpy(new char[size], cstr, sizeof(char)*(size))); } else { *cptr = cstr; *alloc = SWIG_OLDOBJ; @@ -2085,15 +2126,16 @@ SWIG_From_unsigned_SS_int (unsigned int value) SWIGINTERN VALUE -SWIG_ruby_failed(void) +SWIG_ruby_failed(VALUE SWIGUNUSEDPARM(arg1), VALUE SWIGUNUSEDPARM(arg2)) { return Qnil; } -/*@SWIG:/usr/local/share/swig/3.0.7/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/ -SWIGINTERN VALUE SWIG_AUX_NUM2LONG(VALUE *args) +/*@SWIG:/usr/local/Cellar/swig/4.0.2/share/swig/4.0.2/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/ +SWIGINTERN VALUE SWIG_AUX_NUM2LONG(VALUE arg) { + VALUE *args = (VALUE *)arg; VALUE obj = args[0]; VALUE type = TYPE(obj); long *res = (long *)(args[1]); @@ -2111,7 +2153,7 @@ SWIG_AsVal_long (VALUE obj, long* val) VALUE a[2]; a[0] = obj; a[1] = (VALUE)(&v); - if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2LONG), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) { + if (rb_rescue(VALUEFUNC(SWIG_AUX_NUM2LONG), (VALUE)a, VALUEFUNC(SWIG_ruby_failed), 0) != Qnil) { if (val) *val = v; return SWIG_OK; } @@ -2201,22 +2243,20 @@ SWIGINTERN void TagLib_MPEG_File_close(TagLib::MPEG::File *self){ static swig_class SwigClassXingHeader; -#ifdef HAVE_RB_DEFINE_ALLOC_FUNC SWIGINTERN VALUE -_wrap_XingHeader_allocate(VALUE self) { +#ifdef HAVE_RB_DEFINE_ALLOC_FUNC +_wrap_XingHeader_allocate(VALUE self) #else - SWIGINTERN VALUE - _wrap_XingHeader_allocate(int argc, VALUE *argv, VALUE self) { +_wrap_XingHeader_allocate(int argc, VALUE *argv, VALUE self) #endif - - - VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__MPEG__XingHeader); +{ + VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__MPEG__XingHeader); #ifndef HAVE_RB_DEFINE_ALLOC_FUNC - rb_obj_call_init(vresult, argc, argv); + rb_obj_call_init(vresult, argc, argv); #endif - return vresult; - } - + return vresult; +} + SWIGINTERN VALUE _wrap_new_XingHeader(int argc, VALUE *argv, VALUE self) { @@ -2241,7 +2281,8 @@ _wrap_new_XingHeader(int argc, VALUE *argv, VALUE self) { SWIGINTERN void -free_TagLib_MPEG_XingHeader(TagLib::MPEG::XingHeader *arg1) { +free_TagLib_MPEG_XingHeader(void *self) { + TagLib::MPEG::XingHeader *arg1 = (TagLib::MPEG::XingHeader *)self; SWIG_RubyRemoveTracking(arg1); delete arg1; } @@ -2470,22 +2511,20 @@ _wrap_new_Header__SWIG_2(int argc, VALUE *argv, VALUE self) { } -#ifdef HAVE_RB_DEFINE_ALLOC_FUNC SWIGINTERN VALUE -_wrap_Header_allocate(VALUE self) { +#ifdef HAVE_RB_DEFINE_ALLOC_FUNC +_wrap_Header_allocate(VALUE self) #else - SWIGINTERN VALUE - _wrap_Header_allocate(int argc, VALUE *argv, VALUE self) { +_wrap_Header_allocate(int argc, VALUE *argv, VALUE self) #endif - - - VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__MPEG__Header); +{ + VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__MPEG__Header); #ifndef HAVE_RB_DEFINE_ALLOC_FUNC - rb_obj_call_init(vresult, argc, argv); + rb_obj_call_init(vresult, argc, argv); #endif - return vresult; - } - + return vresult; +} + SWIGINTERN VALUE _wrap_new_Header__SWIG_3(int argc, VALUE *argv, VALUE self) { @@ -2527,7 +2566,7 @@ SWIGINTERN VALUE _wrap_new_Header(int nargs, VALUE *args, VALUE self) { if (argc == 1) { int _v; void *vptr = 0; - int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_TagLib__MPEG__Header, 0); + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_TagLib__MPEG__Header, SWIG_POINTER_NO_NULL); _v = SWIG_CheckState(res); if (_v) { return _wrap_new_Header__SWIG_3(nargs, args, self); @@ -2590,7 +2629,8 @@ SWIGINTERN VALUE _wrap_new_Header(int nargs, VALUE *args, VALUE self) { SWIGINTERN void -free_TagLib_MPEG_Header(TagLib::MPEG::Header *arg1) { +free_TagLib_MPEG_Header(void *self) { + TagLib::MPEG::Header *arg1 = (TagLib::MPEG::Header *)self; SWIG_RubyRemoveTracking(arg1); delete arg1; } @@ -2917,22 +2957,20 @@ _wrap_new_Properties__SWIG_0(int argc, VALUE *argv, VALUE self) { } -#ifdef HAVE_RB_DEFINE_ALLOC_FUNC SWIGINTERN VALUE -_wrap_Properties_allocate(VALUE self) { +#ifdef HAVE_RB_DEFINE_ALLOC_FUNC +_wrap_Properties_allocate(VALUE self) #else - SWIGINTERN VALUE - _wrap_Properties_allocate(int argc, VALUE *argv, VALUE self) { +_wrap_Properties_allocate(int argc, VALUE *argv, VALUE self) #endif - - - VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__MPEG__Properties); +{ + VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__MPEG__Properties); #ifndef HAVE_RB_DEFINE_ALLOC_FUNC - rb_obj_call_init(vresult, argc, argv); + rb_obj_call_init(vresult, argc, argv); #endif - return vresult; - } - + return vresult; +} + SWIGINTERN VALUE _wrap_new_Properties__SWIG_1(int argc, VALUE *argv, VALUE self) { @@ -3003,7 +3041,8 @@ SWIGINTERN VALUE _wrap_new_Properties(int nargs, VALUE *args, VALUE self) { SWIGINTERN void -free_TagLib_MPEG_Properties(TagLib::MPEG::Properties *arg1) { +free_TagLib_MPEG_Properties(void *self) { + TagLib::MPEG::Properties *arg1 = (TagLib::MPEG::Properties *)self; SWIG_RubyRemoveTracking(arg1); delete arg1; } @@ -3477,22 +3516,20 @@ _wrap_new_File__SWIG_4(int argc, VALUE *argv, VALUE self) { } -#ifdef HAVE_RB_DEFINE_ALLOC_FUNC SWIGINTERN VALUE -_wrap_File_allocate(VALUE self) { +#ifdef HAVE_RB_DEFINE_ALLOC_FUNC +_wrap_File_allocate(VALUE self) #else - SWIGINTERN VALUE - _wrap_File_allocate(int argc, VALUE *argv, VALUE self) { +_wrap_File_allocate(int argc, VALUE *argv, VALUE self) #endif - - - VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__MPEG__File); +{ + VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__MPEG__File); #ifndef HAVE_RB_DEFINE_ALLOC_FUNC - rb_obj_call_init(vresult, argc, argv); + rb_obj_call_init(vresult, argc, argv); #endif - return vresult; - } - + return vresult; +} + SWIGINTERN VALUE _wrap_new_File__SWIG_5(int argc, VALUE *argv, VALUE self) { @@ -4119,7 +4156,7 @@ SWIGINTERN VALUE _wrap_File_id3v2_tag(int nargs, VALUE *args, VALUE self) { fail: Ruby_Format_OverloadedError( argc, 3, "File.id3v2_tag", - " TagLib::ID3v2::Tag * File.id3v2_tag(bool create)\n" + " TagLib::ID3v2::Tag File.id3v2_tag(bool create)\n" " TagLib::ID3v2::Tag * File.id3v2_tag()\n"); return Qnil; @@ -4220,7 +4257,7 @@ SWIGINTERN VALUE _wrap_File_id3v1_tag(int nargs, VALUE *args, VALUE self) { fail: Ruby_Format_OverloadedError( argc, 3, "File.id3v1_tag", - " TagLib::ID3v1::Tag * File.id3v1_tag(bool create)\n" + " TagLib::ID3v1::Tag File.id3v1_tag(bool create)\n" " TagLib::ID3v1::Tag * File.id3v1_tag()\n"); return Qnil; @@ -4321,7 +4358,7 @@ SWIGINTERN VALUE _wrap_File_apetag(int nargs, VALUE *args, VALUE self) { fail: Ruby_Format_OverloadedError( argc, 3, "File.apetag", - " TagLib::APE::Tag * File.apetag(bool create)\n" + " TagLib::APE::Tag File.apetag(bool create)\n" " TagLib::APE::Tag * File.apetag()\n"); return Qnil; @@ -4909,7 +4946,7 @@ SWIG_InitializeModule(void *clientdata) { /* Now work on filling in swig_module.types */ #ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: size %d\n", swig_module.size); + printf("SWIG_InitializeModule: size %lu\n", (unsigned long)swig_module.size); #endif for (i = 0; i < swig_module.size; ++i) { swig_type_info *type = 0; @@ -4917,7 +4954,7 @@ SWIG_InitializeModule(void *clientdata) { swig_cast_info *cast; #ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); + printf("SWIG_InitializeModule: type %lu %s\n", (unsigned long)i, swig_module.type_initial[i]->name); #endif /* if there is another module already loaded */ @@ -4993,7 +5030,7 @@ SWIG_InitializeModule(void *clientdata) { for (i = 0; i < swig_module.size; ++i) { int j = 0; swig_cast_info *cast = swig_module.cast_initial[i]; - printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); + printf("SWIG_InitializeModule: type %lu %s\n", (unsigned long)i, swig_module.type_initial[i]->name); while (cast->type) { printf("SWIG_InitializeModule: cast type %s\n", cast->type->name); cast++; diff --git a/ext/taglib_ogg/taglib_ogg_wrap.cxx b/ext/taglib_ogg/taglib_ogg_wrap.cxx index 4a402cb..4c3313c 100644 --- a/ext/taglib_ogg/taglib_ogg_wrap.cxx +++ b/ext/taglib_ogg/taglib_ogg_wrap.cxx @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 3.0.7 + * Version 4.0.2 * * This file is not intended to be easily readable and contains a number of * coding conventions designed to improve portability and efficiency. Do not make @@ -8,7 +8,11 @@ * interface file instead. * ----------------------------------------------------------------------------- */ + +#ifndef SWIGRUBY #define SWIGRUBY +#endif + #ifdef __cplusplus @@ -101,9 +105,11 @@ template T SwigValueInit() { #endif /* exporting methods */ -#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) -# ifndef GCC_HASCLASSVISIBILITY -# define GCC_HASCLASSVISIBILITY +#if defined(__GNUC__) +# if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +# ifndef GCC_HASCLASSVISIBILITY +# define GCC_HASCLASSVISIBILITY +# endif # endif #endif @@ -223,9 +229,11 @@ template T SwigValueInit() { #endif /* exporting methods */ -#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) -# ifndef GCC_HASCLASSVISIBILITY -# define GCC_HASCLASSVISIBILITY +#if defined(__GNUC__) +# if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +# ifndef GCC_HASCLASSVISIBILITY +# define GCC_HASCLASSVISIBILITY +# endif # endif #endif @@ -323,6 +331,7 @@ template T SwigValueInit() { /* Flags for pointer conversions */ #define SWIG_POINTER_DISOWN 0x1 #define SWIG_CAST_NEW_MEMORY 0x2 +#define SWIG_POINTER_NO_NULL 0x4 /* Flags for new pointer objects */ #define SWIG_POINTER_OWN 0x1 @@ -775,16 +784,16 @@ SWIG_UnpackData(const char *c, void *ptr, size_t sz) { char d = *(c++); unsigned char uu; if ((d >= '0') && (d <= '9')) - uu = ((d - '0') << 4); + uu = (unsigned char)((d - '0') << 4); else if ((d >= 'a') && (d <= 'f')) - uu = ((d - ('a'-10)) << 4); + uu = (unsigned char)((d - ('a'-10)) << 4); else return (char *) 0; d = *(c++); if ((d >= '0') && (d <= '9')) - uu |= (d - '0'); + uu |= (unsigned char)(d - '0'); else if ((d >= 'a') && (d <= 'f')) - uu |= (d - ('a'-10)); + uu |= (unsigned char)(d - ('a'-10)); else return (char *) 0; *u = uu; @@ -961,42 +970,53 @@ SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { #ifndef RSTRUCT_PTR # define RSTRUCT_PTR(x) RSTRUCT(x)->ptr #endif +#ifndef RTYPEDDATA_P +# define RTYPEDDATA_P(x) (TYPE(x) != T_DATA) +#endif /* - * Need to be very careful about how these macros are defined, especially - * when compiling C++ code or C code with an ANSI C compiler. + * The following macros are used for providing the correct type of a + * function pointer to the Ruby C API. + * Starting with Ruby 2.7 (corresponding to RB_METHOD_DEFINITION_DECL being + * defined) these macros act transparently due to Ruby's moving away from + * ANYARGS and instead employing strict function signatures. * - * VALUEFUNC(f) is a macro used to typecast a C function that implements - * a Ruby method so that it can be passed as an argument to API functions - * like rb_define_method() and rb_define_singleton_method(). + * Note: In case of C (not C++) the macros are transparent even before + * Ruby 2.7 due to the fact that the Ruby C API used function declarators + * with empty parentheses, which allows for an unspecified number of + * arguments. * - * VOIDFUNC(f) is a macro used to typecast a C function that implements - * either the "mark" or "free" stuff for a Ruby Data object, so that it - * can be passed as an argument to API functions like Data_Wrap_Struct() + * PROTECTFUNC(f) is used for the function pointer argument of the Ruby + * C API function rb_protect(). + * + * VALUEFUNC(f) is used for the function pointer argument(s) of Ruby C API + * functions like rb_define_method() and rb_define_singleton_method(). + * + * VOIDFUNC(f) is used to typecast a C function that implements either + * the "mark" or "free" stuff for a Ruby Data object, so that it can be + * passed as an argument to Ruby C API functions like Data_Wrap_Struct() * and Data_Make_Struct(). + * + * SWIG_RUBY_VOID_ANYARGS_FUNC(f) is used for the function pointer + * argument(s) of Ruby C API functions like rb_define_virtual_variable(). + * + * SWIG_RUBY_INT_ANYARGS_FUNC(f) is used for the function pointer + * argument(s) of Ruby C API functions like st_foreach(). */ - -#ifdef __cplusplus -# ifndef RUBY_METHOD_FUNC /* These definitions should work for Ruby 1.4.6 */ -# define PROTECTFUNC(f) ((VALUE (*)()) f) -# define VALUEFUNC(f) ((VALUE (*)()) f) -# define VOIDFUNC(f) ((void (*)()) f) -# else -# ifndef ANYARGS /* These definitions should work for Ruby 1.6 */ -# define PROTECTFUNC(f) ((VALUE (*)()) f) -# define VALUEFUNC(f) ((VALUE (*)()) f) -# define VOIDFUNC(f) ((RUBY_DATA_FUNC) f) -# else /* These definitions should work for Ruby 1.7+ */ -# define PROTECTFUNC(f) ((VALUE (*)(VALUE)) f) -# define VALUEFUNC(f) ((VALUE (*)(ANYARGS)) f) -# define VOIDFUNC(f) ((RUBY_DATA_FUNC) f) -# endif -# endif +#if defined(__cplusplus) && !defined(RB_METHOD_DEFINITION_DECL) +# define PROTECTFUNC(f) ((VALUE (*)(VALUE)) f) +# define VALUEFUNC(f) ((VALUE (*)(ANYARGS)) f) +# define VOIDFUNC(f) ((RUBY_DATA_FUNC) f) +# define SWIG_RUBY_VOID_ANYARGS_FUNC(f) ((void (*)(ANYARGS))(f)) +# define SWIG_RUBY_INT_ANYARGS_FUNC(f) ((int (*)(ANYARGS))(f)) #else +# define PROTECTFUNC(f) (f) # define VALUEFUNC(f) (f) # define VOIDFUNC(f) (f) +# define SWIG_RUBY_VOID_ANYARGS_FUNC(f) (f) +# define SWIG_RUBY_INT_ANYARGS_FUNC(f) (f) #endif /* Don't use for expressions have side effect */ @@ -1184,7 +1204,7 @@ void Ruby_Format_OverloadedError( /* ----------------------------------------------------------------------------- * rubytracking.swg * - * This file contains support for tracking mappings from + * This file contains support for tracking mappings from * Ruby objects to C++ objects. This functionality is needed * to implement mark functions for Ruby's mark and sweep * garbage collector. @@ -1194,6 +1214,11 @@ void Ruby_Format_OverloadedError( extern "C" { #endif +#if !defined(ST_DATA_T_DEFINED) +/* Needs to be explicitly included for Ruby 1.8 and earlier */ +#include +#endif + /* Ruby 1.8 actually assumes the first case. */ #if SIZEOF_VOIDP == SIZEOF_LONG # define SWIG2NUM(v) LONG2NUM((unsigned long)v) @@ -1205,109 +1230,69 @@ extern "C" { # error sizeof(void*) is not the same as long or long long #endif - -/* Global Ruby hash table to store Trackings from C/C++ - structs to Ruby Objects. +/* Global hash table to store Trackings from C/C++ + structs to Ruby Objects. */ -static VALUE swig_ruby_trackings = Qnil; +static st_table* swig_ruby_trackings = NULL; -/* Global variable that stores a reference to the ruby - hash table delete function. */ -static ID swig_ruby_hash_delete; +static VALUE swig_ruby_trackings_count(ID id, VALUE *var) { + return SWIG2NUM(swig_ruby_trackings->num_entries); +} -/* Setup a Ruby hash table to store Trackings */ + +/* Setup a hash table to store Trackings */ SWIGRUNTIME void SWIG_RubyInitializeTrackings(void) { - /* Create a ruby hash table to store Trackings from C++ + /* Create a hash table to store Trackings from C++ objects to Ruby objects. */ - /* Try to see if some other .so has already created a + /* Try to see if some other .so has already created a tracking hash table, which we keep hidden in an instance var in the SWIG module. This is done to allow multiple DSOs to share the same tracking table. */ - ID trackings_id = rb_intern( "@__trackings__" ); + VALUE trackings_value = Qnil; + /* change the variable name so that we can mix modules + compiled with older SWIG's - this used to be called "@__trackings__" */ + ID trackings_id = rb_intern( "@__safetrackings__" ); VALUE verbose = rb_gv_get("VERBOSE"); rb_gv_set("VERBOSE", Qfalse); - swig_ruby_trackings = rb_ivar_get( _mSWIG, trackings_id ); + trackings_value = rb_ivar_get( _mSWIG, trackings_id ); rb_gv_set("VERBOSE", verbose); - /* No, it hasn't. Create one ourselves */ - if ( swig_ruby_trackings == Qnil ) - { - swig_ruby_trackings = rb_hash_new(); - rb_ivar_set( _mSWIG, trackings_id, swig_ruby_trackings ); - } - - /* Now store a reference to the hash table delete function - so that we only have to look it up once.*/ - swig_ruby_hash_delete = rb_intern("delete"); -} - -/* Get a Ruby number to reference a pointer */ -SWIGRUNTIME VALUE SWIG_RubyPtrToReference(void* ptr) { - /* We cast the pointer to an unsigned long - and then store a reference to it using - a Ruby number object. */ - - /* Convert the pointer to a Ruby number */ - return SWIG2NUM(ptr); -} - -/* Get a Ruby number to reference an object */ -SWIGRUNTIME VALUE SWIG_RubyObjectToReference(VALUE object) { - /* We cast the object to an unsigned long - and then store a reference to it using - a Ruby number object. */ - - /* Convert the Object to a Ruby number */ - return SWIG2NUM(object); -} - -/* Get a Ruby object from a previously stored reference */ -SWIGRUNTIME VALUE SWIG_RubyReferenceToObject(VALUE reference) { - /* The provided Ruby number object is a reference - to the Ruby object we want.*/ + /* The trick here is that we have to store the hash table + pointer in a Ruby variable. We do not want Ruby's GC to + treat this pointer as a Ruby object, so we convert it to + a Ruby numeric value. */ + if (trackings_value == Qnil) { + /* No, it hasn't. Create one ourselves */ + swig_ruby_trackings = st_init_numtable(); + rb_ivar_set( _mSWIG, trackings_id, SWIG2NUM(swig_ruby_trackings) ); + } else { + swig_ruby_trackings = (st_table*)NUM2SWIG(trackings_value); + } - /* Convert the Ruby number to a Ruby object */ - return NUM2SWIG(reference); + rb_define_virtual_variable("SWIG_TRACKINGS_COUNT", + VALUEFUNC(swig_ruby_trackings_count), + SWIG_RUBY_VOID_ANYARGS_FUNC((rb_gvar_setter_t*)NULL)); } /* Add a Tracking from a C/C++ struct to a Ruby object */ SWIGRUNTIME void SWIG_RubyAddTracking(void* ptr, VALUE object) { - /* In a Ruby hash table we store the pointer and - the associated Ruby object. The trick here is - that we cannot store the Ruby object directly - if - we do then it cannot be garbage collected. So - instead we typecast it as a unsigned long and - convert it to a Ruby number object.*/ - - /* Get a reference to the pointer as a Ruby number */ - VALUE key = SWIG_RubyPtrToReference(ptr); - - /* Get a reference to the Ruby object as a Ruby number */ - VALUE value = SWIG_RubyObjectToReference(object); - /* Store the mapping to the global hash table. */ - rb_hash_aset(swig_ruby_trackings, key, value); + st_insert(swig_ruby_trackings, (st_data_t)ptr, object); } /* Get the Ruby object that owns the specified C/C++ struct */ SWIGRUNTIME VALUE SWIG_RubyInstanceFor(void* ptr) { - /* Get a reference to the pointer as a Ruby number */ - VALUE key = SWIG_RubyPtrToReference(ptr); - /* Now lookup the value stored in the global hash table */ - VALUE value = rb_hash_aref(swig_ruby_trackings, key); - - if (value == Qnil) { - /* No object exists - return nil. */ + VALUE value; + + if (st_lookup(swig_ruby_trackings, (st_data_t)ptr, &value)) { + return value; + } else { return Qnil; } - else { - /* Convert this value to Ruby object */ - return SWIG_RubyReferenceToObject(value); - } } /* Remove a Tracking from a C/C++ struct to a Ruby object. It @@ -1315,25 +1300,39 @@ SWIGRUNTIME VALUE SWIG_RubyInstanceFor(void* ptr) { since the same memory address may be reused later to create a new object. */ SWIGRUNTIME void SWIG_RubyRemoveTracking(void* ptr) { - /* Get a reference to the pointer as a Ruby number */ - VALUE key = SWIG_RubyPtrToReference(ptr); - - /* Delete the object from the hash table by calling Ruby's - do this we need to call the Hash.delete method.*/ - rb_funcall(swig_ruby_trackings, swig_ruby_hash_delete, 1, key); + /* Delete the object from the hash table */ + st_delete(swig_ruby_trackings, (st_data_t *)&ptr, NULL); } /* This is a helper method that unlinks a Ruby object from its underlying C++ object. This is needed if the lifetime of the - Ruby object is longer than the C++ object */ + Ruby object is longer than the C++ object. */ SWIGRUNTIME void SWIG_RubyUnlinkObjects(void* ptr) { VALUE object = SWIG_RubyInstanceFor(ptr); if (object != Qnil) { + // object might have the T_ZOMBIE type, but that's just + // because the GC has flagged it as such for a deferred + // destruction. Until then, it's still a T_DATA object. DATA_PTR(object) = 0; } } +/* This is a helper method that iterates over all the trackings + passing the C++ object pointer and its related Ruby object + to the passed callback function. */ + +/* Proxy method to abstract the internal trackings datatype */ +static int swig_ruby_internal_iterate_callback(st_data_t ptr, st_data_t obj, st_data_t meth) { + ((void (*) (void *, VALUE))meth)((void *)ptr, (VALUE)obj); + return ST_CONTINUE; +} + +SWIGRUNTIME void SWIG_RubyIterateTrackings( void(*meth)(void* ptr, VALUE obj) ) { + st_foreach(swig_ruby_trackings, + SWIG_RUBY_INT_ANYARGS_FUNC(swig_ruby_internal_iterate_callback), + (st_data_t)meth); +} #ifdef __cplusplus } @@ -1392,7 +1391,7 @@ SWIG_Ruby_AppendOutput(VALUE target, VALUE o) { #define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Ruby_ConvertPtrAndOwn(obj, pptr, type, flags, own) #define SWIG_NewPointerObj(ptr, type, flags) SWIG_Ruby_NewPointerObj(ptr, type, flags) #define SWIG_AcquirePtr(ptr, own) SWIG_Ruby_AcquirePtr(ptr, own) -#define swig_owntype ruby_owntype +#define swig_owntype swig_ruby_owntype /* for raw packed data */ #define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Ruby_ConvertPacked(obj, ptr, sz, ty, flags) @@ -1549,10 +1548,11 @@ SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags) swig_class *sklass; VALUE klass; VALUE obj; - + if (!ptr) return Qnil; - + + assert(type); if (type->clientdata) { sklass = (swig_class *) type->clientdata; @@ -1560,7 +1560,7 @@ SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags) track = sklass->trackObjects; if (track) { obj = SWIG_RubyInstanceFor(ptr); - + /* Check the object's type and make sure it has the correct type. It might not in cases where methods do things like downcast methods. */ @@ -1592,7 +1592,7 @@ SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags) obj = Data_Wrap_Struct(klass, 0, 0, ptr); } rb_iv_set(obj, "@__swigtype__", rb_str_new2(type->name)); - + return obj; } @@ -1612,26 +1612,30 @@ SWIGRUNTIMEINLINE char * SWIG_Ruby_MangleStr(VALUE obj) { VALUE stype = rb_iv_get(obj, "@__swigtype__"); + if (NIL_P(stype)) + return NULL; return StringValuePtr(stype); } /* Acquire a pointer value */ -typedef void (*ruby_owntype)(void*); - -SWIGRUNTIME ruby_owntype -SWIG_Ruby_AcquirePtr(VALUE obj, ruby_owntype own) { - if (obj) { - ruby_owntype oldown = RDATA(obj)->dfree; - RDATA(obj)->dfree = own; - return oldown; - } else { - return 0; +typedef struct { + void (*datafree)(void *); + int own; +} swig_ruby_owntype; + +SWIGRUNTIME swig_ruby_owntype +SWIG_Ruby_AcquirePtr(VALUE obj, swig_ruby_owntype own) { + swig_ruby_owntype oldown = {0, 0}; + if (TYPE(obj) == T_DATA && !RTYPEDDATA_P(obj)) { + oldown.datafree = RDATA(obj)->dfree; + RDATA(obj)->dfree = own.datafree; } + return oldown; } /* Convert a pointer value */ SWIGRUNTIME int -SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, ruby_owntype *own) +SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, swig_ruby_owntype *own) { char *c; swig_cast_info *tc; @@ -1639,16 +1643,20 @@ SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, /* Grab the pointer */ if (NIL_P(obj)) { - *ptr = 0; - return SWIG_OK; + if (ptr) + *ptr = 0; + return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK; } else { - if (TYPE(obj) != T_DATA) { + if (TYPE(obj) != T_DATA || (TYPE(obj) == T_DATA && RTYPEDDATA_P(obj))) { return SWIG_ERROR; } Data_Get_Struct(obj, void, vptr); } - if (own) *own = RDATA(obj)->dfree; + if (own) { + own->datafree = RDATA(obj)->dfree; + own->own = 0; + } /* Check to see if the input object is giving up ownership of the underlying C struct or C++ object. If so then we @@ -1683,8 +1691,6 @@ SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, /* The object has already been deleted */ return SWIG_ObjectPreviouslyDeletedError; } - *ptr = vptr; - return SWIG_OK; } } if ((c = SWIG_MangleStr(obj)) == NULL) { @@ -1694,12 +1700,23 @@ SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, if (!tc) { return SWIG_ERROR; } else { - int newmemory = 0; - *ptr = SWIG_TypeCast(tc, vptr, &newmemory); - assert(!newmemory); /* newmemory handling not yet implemented */ + if (ptr) { + if (tc->type == ty) { + *ptr = vptr; + } else { + int newmemory = 0; + *ptr = SWIG_TypeCast(tc, vptr, &newmemory); + if (newmemory == SWIG_CAST_NEW_MEMORY) { + assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */ + if (own) + own->own = own->own | SWIG_CAST_NEW_MEMORY; + } + } + } } } else { - *ptr = vptr; + if (ptr) + *ptr = vptr; } return SWIG_OK; @@ -1725,7 +1742,7 @@ SWIG_Ruby_NewPackedObj(void *ptr, int sz, swig_type_info *type) { return rb_str_new2(result); } -/* Convert a packed value value */ +/* Convert a packed pointer value */ SWIGRUNTIME int SWIG_Ruby_ConvertPacked(VALUE obj, void *ptr, int sz, swig_type_info *ty) { swig_cast_info *tc; @@ -1856,7 +1873,7 @@ static VALUE mOgg; #define SWIG_RUBY_THREAD_END_BLOCK -#define SWIGVERSION 0x030007 +#define SWIGVERSION 0x040002 #define SWIG_VERSION SWIGVERSION @@ -1877,6 +1894,8 @@ using namespace TagLib; #include #include +#include +#include #include #if defined(HAVE_RUBY_ENCODING_H) && HAVE_RUBY_ENCODING_H @@ -1946,6 +1965,28 @@ TagLib::StringList ruby_array_to_taglib_string_list(VALUE ary) { return result; } +VALUE taglib_bytevectorlist_to_ruby_array(const TagLib::ByteVectorList & list) { + VALUE ary = rb_ary_new2(list.size()); + for (TagLib::ByteVectorList::ConstIterator it = list.begin(); it != list.end(); it++) { + VALUE s = taglib_bytevector_to_ruby_string(*it); + rb_ary_push(ary, s); + } + return ary; +} + +TagLib::ByteVectorList ruby_array_to_taglib_bytevectorlist(VALUE ary) { + TagLib::ByteVectorList result = TagLib::ByteVectorList(); + if (NIL_P(ary)) { + return result; + } + for (long i = 0; i < RARRAY_LEN(ary); i++) { + VALUE e = rb_ary_entry(ary, i); + TagLib::ByteVector s = ruby_string_to_taglib_bytevector(e); + result.append(s); + } + return result; +} + VALUE taglib_filename_to_ruby_string(TagLib::FileName filename) { VALUE result; #ifdef _WIN32 @@ -2009,15 +2050,16 @@ VALUE taglib_flac_picturelist_to_ruby_array(const TagLib::List(memcpy((new char[size]), cstr, sizeof(char)*(size))); + *cptr = reinterpret_cast< char* >(memcpy(new char[size], cstr, sizeof(char)*(size))); } else { *cptr = cstr; *alloc = SWIG_OLDOBJ; @@ -2134,9 +2176,10 @@ SWIG_From_unsigned_SS_int (unsigned int value) } -/*@SWIG:/usr/local/share/swig/3.0.7/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/ -SWIGINTERN VALUE SWIG_AUX_NUM2LONG(VALUE *args) +/*@SWIG:/usr/local/Cellar/swig/4.0.2/share/swig/4.0.2/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/ +SWIGINTERN VALUE SWIG_AUX_NUM2LONG(VALUE arg) { + VALUE *args = (VALUE *)arg; VALUE obj = args[0]; VALUE type = TYPE(obj); long *res = (long *)(args[1]); @@ -2154,7 +2197,7 @@ SWIG_AsVal_long (VALUE obj, long* val) VALUE a[2]; a[0] = obj; a[1] = (VALUE)(&v); - if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2LONG), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) { + if (rb_rescue(VALUEFUNC(SWIG_AUX_NUM2LONG), (VALUE)a, VALUEFUNC(SWIG_ruby_failed), 0) != Qnil) { if (val) *val = v; return SWIG_OK; } @@ -2214,7 +2257,8 @@ SWIG_AsVal_bool (VALUE obj, bool *val) static swig_class SwigClassFile; SWIGINTERN void -free_TagLib_Ogg_File(TagLib::Ogg::File *arg1) { +free_TagLib_Ogg_File(void *self) { + TagLib::Ogg::File *arg1 = (TagLib::Ogg::File *)self; SWIG_RubyRemoveTracking(arg1); delete arg1; } @@ -2378,22 +2422,20 @@ _wrap_new_XiphComment__SWIG_0(int argc, VALUE *argv, VALUE self) { } -#ifdef HAVE_RB_DEFINE_ALLOC_FUNC SWIGINTERN VALUE -_wrap_XiphComment_allocate(VALUE self) { +#ifdef HAVE_RB_DEFINE_ALLOC_FUNC +_wrap_XiphComment_allocate(VALUE self) #else - SWIGINTERN VALUE - _wrap_XiphComment_allocate(int argc, VALUE *argv, VALUE self) { +_wrap_XiphComment_allocate(int argc, VALUE *argv, VALUE self) #endif - - - VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__Ogg__XiphComment); +{ + VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__Ogg__XiphComment); #ifndef HAVE_RB_DEFINE_ALLOC_FUNC - rb_obj_call_init(vresult, argc, argv); + rb_obj_call_init(vresult, argc, argv); #endif - return vresult; - } - + return vresult; +} + SWIGINTERN VALUE _wrap_new_XiphComment__SWIG_1(int argc, VALUE *argv, VALUE self) { @@ -2449,7 +2491,8 @@ SWIGINTERN VALUE _wrap_new_XiphComment(int nargs, VALUE *args, VALUE self) { SWIGINTERN void -free_TagLib_Ogg_XiphComment(TagLib::Ogg::XiphComment *arg1) { +free_TagLib_Ogg_XiphComment(void *self) { + TagLib::Ogg::XiphComment *arg1 = (TagLib::Ogg::XiphComment *)self; SWIG_RubyRemoveTracking(arg1); delete arg1; } @@ -3718,7 +3761,7 @@ SWIG_InitializeModule(void *clientdata) { /* Now work on filling in swig_module.types */ #ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: size %d\n", swig_module.size); + printf("SWIG_InitializeModule: size %lu\n", (unsigned long)swig_module.size); #endif for (i = 0; i < swig_module.size; ++i) { swig_type_info *type = 0; @@ -3726,7 +3769,7 @@ SWIG_InitializeModule(void *clientdata) { swig_cast_info *cast; #ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); + printf("SWIG_InitializeModule: type %lu %s\n", (unsigned long)i, swig_module.type_initial[i]->name); #endif /* if there is another module already loaded */ @@ -3802,7 +3845,7 @@ SWIG_InitializeModule(void *clientdata) { for (i = 0; i < swig_module.size; ++i) { int j = 0; swig_cast_info *cast = swig_module.cast_initial[i]; - printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); + printf("SWIG_InitializeModule: type %lu %s\n", (unsigned long)i, swig_module.type_initial[i]->name); while (cast->type) { printf("SWIG_InitializeModule: cast type %s\n", cast->type->name); cast++; diff --git a/ext/taglib_vorbis/taglib_vorbis_wrap.cxx b/ext/taglib_vorbis/taglib_vorbis_wrap.cxx index f12ee28..a6a4836 100644 --- a/ext/taglib_vorbis/taglib_vorbis_wrap.cxx +++ b/ext/taglib_vorbis/taglib_vorbis_wrap.cxx @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 3.0.7 + * Version 4.0.2 * * This file is not intended to be easily readable and contains a number of * coding conventions designed to improve portability and efficiency. Do not make @@ -11,7 +11,11 @@ static void free_taglib_vorbis_file(void *ptr); + +#ifndef SWIGRUBY #define SWIGRUBY +#endif + #ifdef __cplusplus @@ -104,9 +108,11 @@ template T SwigValueInit() { #endif /* exporting methods */ -#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) -# ifndef GCC_HASCLASSVISIBILITY -# define GCC_HASCLASSVISIBILITY +#if defined(__GNUC__) +# if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +# ifndef GCC_HASCLASSVISIBILITY +# define GCC_HASCLASSVISIBILITY +# endif # endif #endif @@ -226,9 +232,11 @@ template T SwigValueInit() { #endif /* exporting methods */ -#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) -# ifndef GCC_HASCLASSVISIBILITY -# define GCC_HASCLASSVISIBILITY +#if defined(__GNUC__) +# if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +# ifndef GCC_HASCLASSVISIBILITY +# define GCC_HASCLASSVISIBILITY +# endif # endif #endif @@ -326,6 +334,7 @@ template T SwigValueInit() { /* Flags for pointer conversions */ #define SWIG_POINTER_DISOWN 0x1 #define SWIG_CAST_NEW_MEMORY 0x2 +#define SWIG_POINTER_NO_NULL 0x4 /* Flags for new pointer objects */ #define SWIG_POINTER_OWN 0x1 @@ -778,16 +787,16 @@ SWIG_UnpackData(const char *c, void *ptr, size_t sz) { char d = *(c++); unsigned char uu; if ((d >= '0') && (d <= '9')) - uu = ((d - '0') << 4); + uu = (unsigned char)((d - '0') << 4); else if ((d >= 'a') && (d <= 'f')) - uu = ((d - ('a'-10)) << 4); + uu = (unsigned char)((d - ('a'-10)) << 4); else return (char *) 0; d = *(c++); if ((d >= '0') && (d <= '9')) - uu |= (d - '0'); + uu |= (unsigned char)(d - '0'); else if ((d >= 'a') && (d <= 'f')) - uu |= (d - ('a'-10)); + uu |= (unsigned char)(d - ('a'-10)); else return (char *) 0; *u = uu; @@ -964,42 +973,53 @@ SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { #ifndef RSTRUCT_PTR # define RSTRUCT_PTR(x) RSTRUCT(x)->ptr #endif +#ifndef RTYPEDDATA_P +# define RTYPEDDATA_P(x) (TYPE(x) != T_DATA) +#endif /* - * Need to be very careful about how these macros are defined, especially - * when compiling C++ code or C code with an ANSI C compiler. + * The following macros are used for providing the correct type of a + * function pointer to the Ruby C API. + * Starting with Ruby 2.7 (corresponding to RB_METHOD_DEFINITION_DECL being + * defined) these macros act transparently due to Ruby's moving away from + * ANYARGS and instead employing strict function signatures. * - * VALUEFUNC(f) is a macro used to typecast a C function that implements - * a Ruby method so that it can be passed as an argument to API functions - * like rb_define_method() and rb_define_singleton_method(). + * Note: In case of C (not C++) the macros are transparent even before + * Ruby 2.7 due to the fact that the Ruby C API used function declarators + * with empty parentheses, which allows for an unspecified number of + * arguments. * - * VOIDFUNC(f) is a macro used to typecast a C function that implements - * either the "mark" or "free" stuff for a Ruby Data object, so that it - * can be passed as an argument to API functions like Data_Wrap_Struct() + * PROTECTFUNC(f) is used for the function pointer argument of the Ruby + * C API function rb_protect(). + * + * VALUEFUNC(f) is used for the function pointer argument(s) of Ruby C API + * functions like rb_define_method() and rb_define_singleton_method(). + * + * VOIDFUNC(f) is used to typecast a C function that implements either + * the "mark" or "free" stuff for a Ruby Data object, so that it can be + * passed as an argument to Ruby C API functions like Data_Wrap_Struct() * and Data_Make_Struct(). + * + * SWIG_RUBY_VOID_ANYARGS_FUNC(f) is used for the function pointer + * argument(s) of Ruby C API functions like rb_define_virtual_variable(). + * + * SWIG_RUBY_INT_ANYARGS_FUNC(f) is used for the function pointer + * argument(s) of Ruby C API functions like st_foreach(). */ - -#ifdef __cplusplus -# ifndef RUBY_METHOD_FUNC /* These definitions should work for Ruby 1.4.6 */ -# define PROTECTFUNC(f) ((VALUE (*)()) f) -# define VALUEFUNC(f) ((VALUE (*)()) f) -# define VOIDFUNC(f) ((void (*)()) f) -# else -# ifndef ANYARGS /* These definitions should work for Ruby 1.6 */ -# define PROTECTFUNC(f) ((VALUE (*)()) f) -# define VALUEFUNC(f) ((VALUE (*)()) f) -# define VOIDFUNC(f) ((RUBY_DATA_FUNC) f) -# else /* These definitions should work for Ruby 1.7+ */ -# define PROTECTFUNC(f) ((VALUE (*)(VALUE)) f) -# define VALUEFUNC(f) ((VALUE (*)(ANYARGS)) f) -# define VOIDFUNC(f) ((RUBY_DATA_FUNC) f) -# endif -# endif +#if defined(__cplusplus) && !defined(RB_METHOD_DEFINITION_DECL) +# define PROTECTFUNC(f) ((VALUE (*)(VALUE)) f) +# define VALUEFUNC(f) ((VALUE (*)(ANYARGS)) f) +# define VOIDFUNC(f) ((RUBY_DATA_FUNC) f) +# define SWIG_RUBY_VOID_ANYARGS_FUNC(f) ((void (*)(ANYARGS))(f)) +# define SWIG_RUBY_INT_ANYARGS_FUNC(f) ((int (*)(ANYARGS))(f)) #else +# define PROTECTFUNC(f) (f) # define VALUEFUNC(f) (f) # define VOIDFUNC(f) (f) +# define SWIG_RUBY_VOID_ANYARGS_FUNC(f) (f) +# define SWIG_RUBY_INT_ANYARGS_FUNC(f) (f) #endif /* Don't use for expressions have side effect */ @@ -1187,7 +1207,7 @@ void Ruby_Format_OverloadedError( /* ----------------------------------------------------------------------------- * rubytracking.swg * - * This file contains support for tracking mappings from + * This file contains support for tracking mappings from * Ruby objects to C++ objects. This functionality is needed * to implement mark functions for Ruby's mark and sweep * garbage collector. @@ -1197,6 +1217,11 @@ void Ruby_Format_OverloadedError( extern "C" { #endif +#if !defined(ST_DATA_T_DEFINED) +/* Needs to be explicitly included for Ruby 1.8 and earlier */ +#include +#endif + /* Ruby 1.8 actually assumes the first case. */ #if SIZEOF_VOIDP == SIZEOF_LONG # define SWIG2NUM(v) LONG2NUM((unsigned long)v) @@ -1208,109 +1233,69 @@ extern "C" { # error sizeof(void*) is not the same as long or long long #endif - -/* Global Ruby hash table to store Trackings from C/C++ - structs to Ruby Objects. +/* Global hash table to store Trackings from C/C++ + structs to Ruby Objects. */ -static VALUE swig_ruby_trackings = Qnil; +static st_table* swig_ruby_trackings = NULL; + +static VALUE swig_ruby_trackings_count(ID id, VALUE *var) { + return SWIG2NUM(swig_ruby_trackings->num_entries); +} -/* Global variable that stores a reference to the ruby - hash table delete function. */ -static ID swig_ruby_hash_delete; -/* Setup a Ruby hash table to store Trackings */ +/* Setup a hash table to store Trackings */ SWIGRUNTIME void SWIG_RubyInitializeTrackings(void) { - /* Create a ruby hash table to store Trackings from C++ + /* Create a hash table to store Trackings from C++ objects to Ruby objects. */ - /* Try to see if some other .so has already created a + /* Try to see if some other .so has already created a tracking hash table, which we keep hidden in an instance var in the SWIG module. This is done to allow multiple DSOs to share the same tracking table. */ - ID trackings_id = rb_intern( "@__trackings__" ); + VALUE trackings_value = Qnil; + /* change the variable name so that we can mix modules + compiled with older SWIG's - this used to be called "@__trackings__" */ + ID trackings_id = rb_intern( "@__safetrackings__" ); VALUE verbose = rb_gv_get("VERBOSE"); rb_gv_set("VERBOSE", Qfalse); - swig_ruby_trackings = rb_ivar_get( _mSWIG, trackings_id ); + trackings_value = rb_ivar_get( _mSWIG, trackings_id ); rb_gv_set("VERBOSE", verbose); - /* No, it hasn't. Create one ourselves */ - if ( swig_ruby_trackings == Qnil ) - { - swig_ruby_trackings = rb_hash_new(); - rb_ivar_set( _mSWIG, trackings_id, swig_ruby_trackings ); - } - - /* Now store a reference to the hash table delete function - so that we only have to look it up once.*/ - swig_ruby_hash_delete = rb_intern("delete"); -} - -/* Get a Ruby number to reference a pointer */ -SWIGRUNTIME VALUE SWIG_RubyPtrToReference(void* ptr) { - /* We cast the pointer to an unsigned long - and then store a reference to it using - a Ruby number object. */ - - /* Convert the pointer to a Ruby number */ - return SWIG2NUM(ptr); -} - -/* Get a Ruby number to reference an object */ -SWIGRUNTIME VALUE SWIG_RubyObjectToReference(VALUE object) { - /* We cast the object to an unsigned long - and then store a reference to it using - a Ruby number object. */ - - /* Convert the Object to a Ruby number */ - return SWIG2NUM(object); -} - -/* Get a Ruby object from a previously stored reference */ -SWIGRUNTIME VALUE SWIG_RubyReferenceToObject(VALUE reference) { - /* The provided Ruby number object is a reference - to the Ruby object we want.*/ + /* The trick here is that we have to store the hash table + pointer in a Ruby variable. We do not want Ruby's GC to + treat this pointer as a Ruby object, so we convert it to + a Ruby numeric value. */ + if (trackings_value == Qnil) { + /* No, it hasn't. Create one ourselves */ + swig_ruby_trackings = st_init_numtable(); + rb_ivar_set( _mSWIG, trackings_id, SWIG2NUM(swig_ruby_trackings) ); + } else { + swig_ruby_trackings = (st_table*)NUM2SWIG(trackings_value); + } - /* Convert the Ruby number to a Ruby object */ - return NUM2SWIG(reference); + rb_define_virtual_variable("SWIG_TRACKINGS_COUNT", + VALUEFUNC(swig_ruby_trackings_count), + SWIG_RUBY_VOID_ANYARGS_FUNC((rb_gvar_setter_t*)NULL)); } /* Add a Tracking from a C/C++ struct to a Ruby object */ SWIGRUNTIME void SWIG_RubyAddTracking(void* ptr, VALUE object) { - /* In a Ruby hash table we store the pointer and - the associated Ruby object. The trick here is - that we cannot store the Ruby object directly - if - we do then it cannot be garbage collected. So - instead we typecast it as a unsigned long and - convert it to a Ruby number object.*/ - - /* Get a reference to the pointer as a Ruby number */ - VALUE key = SWIG_RubyPtrToReference(ptr); - - /* Get a reference to the Ruby object as a Ruby number */ - VALUE value = SWIG_RubyObjectToReference(object); - /* Store the mapping to the global hash table. */ - rb_hash_aset(swig_ruby_trackings, key, value); + st_insert(swig_ruby_trackings, (st_data_t)ptr, object); } /* Get the Ruby object that owns the specified C/C++ struct */ SWIGRUNTIME VALUE SWIG_RubyInstanceFor(void* ptr) { - /* Get a reference to the pointer as a Ruby number */ - VALUE key = SWIG_RubyPtrToReference(ptr); - /* Now lookup the value stored in the global hash table */ - VALUE value = rb_hash_aref(swig_ruby_trackings, key); - - if (value == Qnil) { - /* No object exists - return nil. */ + VALUE value; + + if (st_lookup(swig_ruby_trackings, (st_data_t)ptr, &value)) { + return value; + } else { return Qnil; } - else { - /* Convert this value to Ruby object */ - return SWIG_RubyReferenceToObject(value); - } } /* Remove a Tracking from a C/C++ struct to a Ruby object. It @@ -1318,25 +1303,39 @@ SWIGRUNTIME VALUE SWIG_RubyInstanceFor(void* ptr) { since the same memory address may be reused later to create a new object. */ SWIGRUNTIME void SWIG_RubyRemoveTracking(void* ptr) { - /* Get a reference to the pointer as a Ruby number */ - VALUE key = SWIG_RubyPtrToReference(ptr); - - /* Delete the object from the hash table by calling Ruby's - do this we need to call the Hash.delete method.*/ - rb_funcall(swig_ruby_trackings, swig_ruby_hash_delete, 1, key); + /* Delete the object from the hash table */ + st_delete(swig_ruby_trackings, (st_data_t *)&ptr, NULL); } /* This is a helper method that unlinks a Ruby object from its underlying C++ object. This is needed if the lifetime of the - Ruby object is longer than the C++ object */ + Ruby object is longer than the C++ object. */ SWIGRUNTIME void SWIG_RubyUnlinkObjects(void* ptr) { VALUE object = SWIG_RubyInstanceFor(ptr); if (object != Qnil) { + // object might have the T_ZOMBIE type, but that's just + // because the GC has flagged it as such for a deferred + // destruction. Until then, it's still a T_DATA object. DATA_PTR(object) = 0; } } +/* This is a helper method that iterates over all the trackings + passing the C++ object pointer and its related Ruby object + to the passed callback function. */ + +/* Proxy method to abstract the internal trackings datatype */ +static int swig_ruby_internal_iterate_callback(st_data_t ptr, st_data_t obj, st_data_t meth) { + ((void (*) (void *, VALUE))meth)((void *)ptr, (VALUE)obj); + return ST_CONTINUE; +} + +SWIGRUNTIME void SWIG_RubyIterateTrackings( void(*meth)(void* ptr, VALUE obj) ) { + st_foreach(swig_ruby_trackings, + SWIG_RUBY_INT_ANYARGS_FUNC(swig_ruby_internal_iterate_callback), + (st_data_t)meth); +} #ifdef __cplusplus } @@ -1395,7 +1394,7 @@ SWIG_Ruby_AppendOutput(VALUE target, VALUE o) { #define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Ruby_ConvertPtrAndOwn(obj, pptr, type, flags, own) #define SWIG_NewPointerObj(ptr, type, flags) SWIG_Ruby_NewPointerObj(ptr, type, flags) #define SWIG_AcquirePtr(ptr, own) SWIG_Ruby_AcquirePtr(ptr, own) -#define swig_owntype ruby_owntype +#define swig_owntype swig_ruby_owntype /* for raw packed data */ #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) swig_class *sklass; VALUE klass; VALUE obj; - + if (!ptr) return Qnil; - + + assert(type); if (type->clientdata) { sklass = (swig_class *) type->clientdata; @@ -1563,7 +1563,7 @@ SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags) track = sklass->trackObjects; if (track) { obj = SWIG_RubyInstanceFor(ptr); - + /* Check the object's type and make sure it has the correct type. It might not in cases where methods do things like downcast methods. */ @@ -1595,7 +1595,7 @@ SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags) obj = Data_Wrap_Struct(klass, 0, 0, ptr); } rb_iv_set(obj, "@__swigtype__", rb_str_new2(type->name)); - + return obj; } @@ -1615,26 +1615,30 @@ SWIGRUNTIMEINLINE char * SWIG_Ruby_MangleStr(VALUE obj) { VALUE stype = rb_iv_get(obj, "@__swigtype__"); + if (NIL_P(stype)) + return NULL; return StringValuePtr(stype); } /* Acquire a pointer value */ -typedef void (*ruby_owntype)(void*); - -SWIGRUNTIME ruby_owntype -SWIG_Ruby_AcquirePtr(VALUE obj, ruby_owntype own) { - if (obj) { - ruby_owntype oldown = RDATA(obj)->dfree; - RDATA(obj)->dfree = own; - return oldown; - } else { - return 0; +typedef struct { + void (*datafree)(void *); + int own; +} swig_ruby_owntype; + +SWIGRUNTIME swig_ruby_owntype +SWIG_Ruby_AcquirePtr(VALUE obj, swig_ruby_owntype own) { + swig_ruby_owntype oldown = {0, 0}; + if (TYPE(obj) == T_DATA && !RTYPEDDATA_P(obj)) { + oldown.datafree = RDATA(obj)->dfree; + RDATA(obj)->dfree = own.datafree; } + return oldown; } /* Convert a pointer value */ SWIGRUNTIME int -SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, ruby_owntype *own) +SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, swig_ruby_owntype *own) { char *c; swig_cast_info *tc; @@ -1642,16 +1646,20 @@ SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, /* Grab the pointer */ if (NIL_P(obj)) { - *ptr = 0; - return SWIG_OK; + if (ptr) + *ptr = 0; + return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK; } else { - if (TYPE(obj) != T_DATA) { + if (TYPE(obj) != T_DATA || (TYPE(obj) == T_DATA && RTYPEDDATA_P(obj))) { return SWIG_ERROR; } Data_Get_Struct(obj, void, vptr); } - if (own) *own = RDATA(obj)->dfree; + if (own) { + own->datafree = RDATA(obj)->dfree; + own->own = 0; + } /* Check to see if the input object is giving up ownership 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, /* The object has already been deleted */ return SWIG_ObjectPreviouslyDeletedError; } - *ptr = vptr; - return SWIG_OK; } } if ((c = SWIG_MangleStr(obj)) == NULL) { @@ -1697,12 +1703,23 @@ SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, if (!tc) { return SWIG_ERROR; } else { - int newmemory = 0; - *ptr = SWIG_TypeCast(tc, vptr, &newmemory); - assert(!newmemory); /* newmemory handling not yet implemented */ + if (ptr) { + if (tc->type == ty) { + *ptr = vptr; + } else { + int newmemory = 0; + *ptr = SWIG_TypeCast(tc, vptr, &newmemory); + if (newmemory == SWIG_CAST_NEW_MEMORY) { + assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */ + if (own) + own->own = own->own | SWIG_CAST_NEW_MEMORY; + } + } + } } } else { - *ptr = vptr; + if (ptr) + *ptr = vptr; } return SWIG_OK; @@ -1728,7 +1745,7 @@ SWIG_Ruby_NewPackedObj(void *ptr, int sz, swig_type_info *type) { return rb_str_new2(result); } -/* Convert a packed value value */ +/* Convert a packed pointer value */ SWIGRUNTIME int SWIG_Ruby_ConvertPacked(VALUE obj, void *ptr, int sz, swig_type_info *ty) { swig_cast_info *tc; @@ -1859,7 +1876,7 @@ static VALUE mVorbis; #define SWIG_RUBY_THREAD_END_BLOCK -#define SWIGVERSION 0x030007 +#define SWIGVERSION 0x040002 #define SWIG_VERSION SWIGVERSION @@ -1877,6 +1894,8 @@ static VALUE mVorbis; #include #include +#include +#include #include #if defined(HAVE_RUBY_ENCODING_H) && HAVE_RUBY_ENCODING_H @@ -1946,6 +1965,28 @@ TagLib::StringList ruby_array_to_taglib_string_list(VALUE ary) { return result; } +VALUE taglib_bytevectorlist_to_ruby_array(const TagLib::ByteVectorList & list) { + VALUE ary = rb_ary_new2(list.size()); + for (TagLib::ByteVectorList::ConstIterator it = list.begin(); it != list.end(); it++) { + VALUE s = taglib_bytevector_to_ruby_string(*it); + rb_ary_push(ary, s); + } + return ary; +} + +TagLib::ByteVectorList ruby_array_to_taglib_bytevectorlist(VALUE ary) { + TagLib::ByteVectorList result = TagLib::ByteVectorList(); + if (NIL_P(ary)) { + return result; + } + for (long i = 0; i < RARRAY_LEN(ary); i++) { + VALUE e = rb_ary_entry(ary, i); + TagLib::ByteVector s = ruby_string_to_taglib_bytevector(e); + result.append(s); + } + return result; +} + VALUE taglib_filename_to_ruby_string(TagLib::FileName filename) { VALUE result; #ifdef _WIN32 @@ -1998,15 +2039,16 @@ TagLib::FileName ruby_string_to_taglib_filename(VALUE s) { SWIGINTERN VALUE -SWIG_ruby_failed(void) +SWIG_ruby_failed(VALUE SWIGUNUSEDPARM(arg1), VALUE SWIGUNUSEDPARM(arg2)) { return Qnil; } -/*@SWIG:/usr/local/share/swig/3.0.7/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/ -SWIGINTERN VALUE SWIG_AUX_NUM2LONG(VALUE *args) +/*@SWIG:/usr/local/Cellar/swig/4.0.2/share/swig/4.0.2/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/ +SWIGINTERN VALUE SWIG_AUX_NUM2LONG(VALUE arg) { + VALUE *args = (VALUE *)arg; VALUE obj = args[0]; VALUE type = TYPE(obj); long *res = (long *)(args[1]); @@ -2024,7 +2066,7 @@ SWIG_AsVal_long (VALUE obj, long* val) VALUE a[2]; a[0] = obj; a[1] = (VALUE)(&v); - if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2LONG), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) { + if (rb_rescue(VALUEFUNC(SWIG_AUX_NUM2LONG), (VALUE)a, VALUEFUNC(SWIG_ruby_failed), 0) != Qnil) { if (val) *val = v; return SWIG_OK; } @@ -2101,7 +2143,7 @@ SWIG_AsCharPtrAndSize(VALUE obj, char** cptr, size_t* psize, int *alloc) if (cptr) { if (alloc) { if (*alloc == SWIG_NEWOBJ) { - *cptr = reinterpret_cast< char* >(memcpy((new char[size]), cstr, sizeof(char)*(size))); + *cptr = reinterpret_cast< char* >(memcpy(new char[size], cstr, sizeof(char)*(size))); } else { *cptr = cstr; *alloc = SWIG_OLDOBJ; @@ -2194,22 +2236,20 @@ _wrap_new_Properties__SWIG_0(int argc, VALUE *argv, VALUE self) { } -#ifdef HAVE_RB_DEFINE_ALLOC_FUNC SWIGINTERN VALUE -_wrap_Properties_allocate(VALUE self) { +#ifdef HAVE_RB_DEFINE_ALLOC_FUNC +_wrap_Properties_allocate(VALUE self) #else - SWIGINTERN VALUE - _wrap_Properties_allocate(int argc, VALUE *argv, VALUE self) { +_wrap_Properties_allocate(int argc, VALUE *argv, VALUE self) #endif - - - VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__Vorbis__Properties); +{ + VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__Vorbis__Properties); #ifndef HAVE_RB_DEFINE_ALLOC_FUNC - rb_obj_call_init(vresult, argc, argv); + rb_obj_call_init(vresult, argc, argv); #endif - return vresult; - } - + return vresult; +} + SWIGINTERN VALUE _wrap_new_Properties__SWIG_1(int argc, VALUE *argv, VALUE self) { @@ -2280,7 +2320,8 @@ SWIGINTERN VALUE _wrap_new_Properties(int nargs, VALUE *args, VALUE self) { SWIGINTERN void -free_TagLib_Vorbis_Properties(TagLib::Vorbis::Properties *arg1) { +free_TagLib_Vorbis_Properties(void *self) { + TagLib::Vorbis::Properties *arg1 = (TagLib::Vorbis::Properties *)self; SWIG_RubyRemoveTracking(arg1); delete arg1; } @@ -2573,22 +2614,20 @@ _wrap_new_File__SWIG_1(int argc, VALUE *argv, VALUE self) { } -#ifdef HAVE_RB_DEFINE_ALLOC_FUNC SWIGINTERN VALUE -_wrap_File_allocate(VALUE self) { +#ifdef HAVE_RB_DEFINE_ALLOC_FUNC +_wrap_File_allocate(VALUE self) #else - SWIGINTERN VALUE - _wrap_File_allocate(int argc, VALUE *argv, VALUE self) { +_wrap_File_allocate(int argc, VALUE *argv, VALUE self) #endif - - - VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__Vorbis__File); +{ + VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__Vorbis__File); #ifndef HAVE_RB_DEFINE_ALLOC_FUNC - rb_obj_call_init(vresult, argc, argv); + rb_obj_call_init(vresult, argc, argv); #endif - return vresult; - } - + return vresult; +} + SWIGINTERN VALUE _wrap_new_File__SWIG_2(int argc, VALUE *argv, VALUE self) { @@ -2947,7 +2986,7 @@ SWIG_InitializeModule(void *clientdata) { /* Now work on filling in swig_module.types */ #ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: size %d\n", swig_module.size); + printf("SWIG_InitializeModule: size %lu\n", (unsigned long)swig_module.size); #endif for (i = 0; i < swig_module.size; ++i) { swig_type_info *type = 0; @@ -2955,7 +2994,7 @@ SWIG_InitializeModule(void *clientdata) { swig_cast_info *cast; #ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); + printf("SWIG_InitializeModule: type %lu %s\n", (unsigned long)i, swig_module.type_initial[i]->name); #endif /* if there is another module already loaded */ @@ -3031,7 +3070,7 @@ SWIG_InitializeModule(void *clientdata) { for (i = 0; i < swig_module.size; ++i) { int j = 0; swig_cast_info *cast = swig_module.cast_initial[i]; - printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); + printf("SWIG_InitializeModule: type %lu %s\n", (unsigned long)i, swig_module.type_initial[i]->name); while (cast->type) { printf("SWIG_InitializeModule: cast type %s\n", cast->type->name); cast++; diff --git a/ext/taglib_wav/taglib_wav_wrap.cxx b/ext/taglib_wav/taglib_wav_wrap.cxx index 602a781..0d8ca78 100644 --- a/ext/taglib_wav/taglib_wav_wrap.cxx +++ b/ext/taglib_wav/taglib_wav_wrap.cxx @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 3.0.7 + * Version 4.0.2 * * This file is not intended to be easily readable and contains a number of * coding conventions designed to improve portability and efficiency. Do not make @@ -11,7 +11,11 @@ static void free_taglib_riff_wav_file(void *ptr); + +#ifndef SWIGRUBY #define SWIGRUBY +#endif + #ifdef __cplusplus @@ -104,9 +108,11 @@ template T SwigValueInit() { #endif /* exporting methods */ -#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) -# ifndef GCC_HASCLASSVISIBILITY -# define GCC_HASCLASSVISIBILITY +#if defined(__GNUC__) +# if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +# ifndef GCC_HASCLASSVISIBILITY +# define GCC_HASCLASSVISIBILITY +# endif # endif #endif @@ -226,9 +232,11 @@ template T SwigValueInit() { #endif /* exporting methods */ -#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) -# ifndef GCC_HASCLASSVISIBILITY -# define GCC_HASCLASSVISIBILITY +#if defined(__GNUC__) +# if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +# ifndef GCC_HASCLASSVISIBILITY +# define GCC_HASCLASSVISIBILITY +# endif # endif #endif @@ -326,6 +334,7 @@ template T SwigValueInit() { /* Flags for pointer conversions */ #define SWIG_POINTER_DISOWN 0x1 #define SWIG_CAST_NEW_MEMORY 0x2 +#define SWIG_POINTER_NO_NULL 0x4 /* Flags for new pointer objects */ #define SWIG_POINTER_OWN 0x1 @@ -778,16 +787,16 @@ SWIG_UnpackData(const char *c, void *ptr, size_t sz) { char d = *(c++); unsigned char uu; if ((d >= '0') && (d <= '9')) - uu = ((d - '0') << 4); + uu = (unsigned char)((d - '0') << 4); else if ((d >= 'a') && (d <= 'f')) - uu = ((d - ('a'-10)) << 4); + uu = (unsigned char)((d - ('a'-10)) << 4); else return (char *) 0; d = *(c++); if ((d >= '0') && (d <= '9')) - uu |= (d - '0'); + uu |= (unsigned char)(d - '0'); else if ((d >= 'a') && (d <= 'f')) - uu |= (d - ('a'-10)); + uu |= (unsigned char)(d - ('a'-10)); else return (char *) 0; *u = uu; @@ -964,42 +973,53 @@ SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { #ifndef RSTRUCT_PTR # define RSTRUCT_PTR(x) RSTRUCT(x)->ptr #endif +#ifndef RTYPEDDATA_P +# define RTYPEDDATA_P(x) (TYPE(x) != T_DATA) +#endif /* - * Need to be very careful about how these macros are defined, especially - * when compiling C++ code or C code with an ANSI C compiler. + * The following macros are used for providing the correct type of a + * function pointer to the Ruby C API. + * Starting with Ruby 2.7 (corresponding to RB_METHOD_DEFINITION_DECL being + * defined) these macros act transparently due to Ruby's moving away from + * ANYARGS and instead employing strict function signatures. * - * VALUEFUNC(f) is a macro used to typecast a C function that implements - * a Ruby method so that it can be passed as an argument to API functions - * like rb_define_method() and rb_define_singleton_method(). + * Note: In case of C (not C++) the macros are transparent even before + * Ruby 2.7 due to the fact that the Ruby C API used function declarators + * with empty parentheses, which allows for an unspecified number of + * arguments. * - * VOIDFUNC(f) is a macro used to typecast a C function that implements - * either the "mark" or "free" stuff for a Ruby Data object, so that it - * can be passed as an argument to API functions like Data_Wrap_Struct() + * PROTECTFUNC(f) is used for the function pointer argument of the Ruby + * C API function rb_protect(). + * + * VALUEFUNC(f) is used for the function pointer argument(s) of Ruby C API + * functions like rb_define_method() and rb_define_singleton_method(). + * + * VOIDFUNC(f) is used to typecast a C function that implements either + * the "mark" or "free" stuff for a Ruby Data object, so that it can be + * passed as an argument to Ruby C API functions like Data_Wrap_Struct() * and Data_Make_Struct(). + * + * SWIG_RUBY_VOID_ANYARGS_FUNC(f) is used for the function pointer + * argument(s) of Ruby C API functions like rb_define_virtual_variable(). + * + * SWIG_RUBY_INT_ANYARGS_FUNC(f) is used for the function pointer + * argument(s) of Ruby C API functions like st_foreach(). */ - -#ifdef __cplusplus -# ifndef RUBY_METHOD_FUNC /* These definitions should work for Ruby 1.4.6 */ -# define PROTECTFUNC(f) ((VALUE (*)()) f) -# define VALUEFUNC(f) ((VALUE (*)()) f) -# define VOIDFUNC(f) ((void (*)()) f) -# else -# ifndef ANYARGS /* These definitions should work for Ruby 1.6 */ -# define PROTECTFUNC(f) ((VALUE (*)()) f) -# define VALUEFUNC(f) ((VALUE (*)()) f) -# define VOIDFUNC(f) ((RUBY_DATA_FUNC) f) -# else /* These definitions should work for Ruby 1.7+ */ -# define PROTECTFUNC(f) ((VALUE (*)(VALUE)) f) -# define VALUEFUNC(f) ((VALUE (*)(ANYARGS)) f) -# define VOIDFUNC(f) ((RUBY_DATA_FUNC) f) -# endif -# endif +#if defined(__cplusplus) && !defined(RB_METHOD_DEFINITION_DECL) +# define PROTECTFUNC(f) ((VALUE (*)(VALUE)) f) +# define VALUEFUNC(f) ((VALUE (*)(ANYARGS)) f) +# define VOIDFUNC(f) ((RUBY_DATA_FUNC) f) +# define SWIG_RUBY_VOID_ANYARGS_FUNC(f) ((void (*)(ANYARGS))(f)) +# define SWIG_RUBY_INT_ANYARGS_FUNC(f) ((int (*)(ANYARGS))(f)) #else +# define PROTECTFUNC(f) (f) # define VALUEFUNC(f) (f) # define VOIDFUNC(f) (f) +# define SWIG_RUBY_VOID_ANYARGS_FUNC(f) (f) +# define SWIG_RUBY_INT_ANYARGS_FUNC(f) (f) #endif /* Don't use for expressions have side effect */ @@ -1187,7 +1207,7 @@ void Ruby_Format_OverloadedError( /* ----------------------------------------------------------------------------- * rubytracking.swg * - * This file contains support for tracking mappings from + * This file contains support for tracking mappings from * Ruby objects to C++ objects. This functionality is needed * to implement mark functions for Ruby's mark and sweep * garbage collector. @@ -1197,6 +1217,11 @@ void Ruby_Format_OverloadedError( extern "C" { #endif +#if !defined(ST_DATA_T_DEFINED) +/* Needs to be explicitly included for Ruby 1.8 and earlier */ +#include +#endif + /* Ruby 1.8 actually assumes the first case. */ #if SIZEOF_VOIDP == SIZEOF_LONG # define SWIG2NUM(v) LONG2NUM((unsigned long)v) @@ -1208,109 +1233,69 @@ extern "C" { # error sizeof(void*) is not the same as long or long long #endif - -/* Global Ruby hash table to store Trackings from C/C++ - structs to Ruby Objects. +/* Global hash table to store Trackings from C/C++ + structs to Ruby Objects. */ -static VALUE swig_ruby_trackings = Qnil; +static st_table* swig_ruby_trackings = NULL; + +static VALUE swig_ruby_trackings_count(ID id, VALUE *var) { + return SWIG2NUM(swig_ruby_trackings->num_entries); +} -/* Global variable that stores a reference to the ruby - hash table delete function. */ -static ID swig_ruby_hash_delete; -/* Setup a Ruby hash table to store Trackings */ +/* Setup a hash table to store Trackings */ SWIGRUNTIME void SWIG_RubyInitializeTrackings(void) { - /* Create a ruby hash table to store Trackings from C++ + /* Create a hash table to store Trackings from C++ objects to Ruby objects. */ - /* Try to see if some other .so has already created a + /* Try to see if some other .so has already created a tracking hash table, which we keep hidden in an instance var in the SWIG module. This is done to allow multiple DSOs to share the same tracking table. */ - ID trackings_id = rb_intern( "@__trackings__" ); + VALUE trackings_value = Qnil; + /* change the variable name so that we can mix modules + compiled with older SWIG's - this used to be called "@__trackings__" */ + ID trackings_id = rb_intern( "@__safetrackings__" ); VALUE verbose = rb_gv_get("VERBOSE"); rb_gv_set("VERBOSE", Qfalse); - swig_ruby_trackings = rb_ivar_get( _mSWIG, trackings_id ); + trackings_value = rb_ivar_get( _mSWIG, trackings_id ); rb_gv_set("VERBOSE", verbose); - /* No, it hasn't. Create one ourselves */ - if ( swig_ruby_trackings == Qnil ) - { - swig_ruby_trackings = rb_hash_new(); - rb_ivar_set( _mSWIG, trackings_id, swig_ruby_trackings ); - } - - /* Now store a reference to the hash table delete function - so that we only have to look it up once.*/ - swig_ruby_hash_delete = rb_intern("delete"); -} - -/* Get a Ruby number to reference a pointer */ -SWIGRUNTIME VALUE SWIG_RubyPtrToReference(void* ptr) { - /* We cast the pointer to an unsigned long - and then store a reference to it using - a Ruby number object. */ - - /* Convert the pointer to a Ruby number */ - return SWIG2NUM(ptr); -} - -/* Get a Ruby number to reference an object */ -SWIGRUNTIME VALUE SWIG_RubyObjectToReference(VALUE object) { - /* We cast the object to an unsigned long - and then store a reference to it using - a Ruby number object. */ - - /* Convert the Object to a Ruby number */ - return SWIG2NUM(object); -} - -/* Get a Ruby object from a previously stored reference */ -SWIGRUNTIME VALUE SWIG_RubyReferenceToObject(VALUE reference) { - /* The provided Ruby number object is a reference - to the Ruby object we want.*/ + /* The trick here is that we have to store the hash table + pointer in a Ruby variable. We do not want Ruby's GC to + treat this pointer as a Ruby object, so we convert it to + a Ruby numeric value. */ + if (trackings_value == Qnil) { + /* No, it hasn't. Create one ourselves */ + swig_ruby_trackings = st_init_numtable(); + rb_ivar_set( _mSWIG, trackings_id, SWIG2NUM(swig_ruby_trackings) ); + } else { + swig_ruby_trackings = (st_table*)NUM2SWIG(trackings_value); + } - /* Convert the Ruby number to a Ruby object */ - return NUM2SWIG(reference); + rb_define_virtual_variable("SWIG_TRACKINGS_COUNT", + VALUEFUNC(swig_ruby_trackings_count), + SWIG_RUBY_VOID_ANYARGS_FUNC((rb_gvar_setter_t*)NULL)); } /* Add a Tracking from a C/C++ struct to a Ruby object */ SWIGRUNTIME void SWIG_RubyAddTracking(void* ptr, VALUE object) { - /* In a Ruby hash table we store the pointer and - the associated Ruby object. The trick here is - that we cannot store the Ruby object directly - if - we do then it cannot be garbage collected. So - instead we typecast it as a unsigned long and - convert it to a Ruby number object.*/ - - /* Get a reference to the pointer as a Ruby number */ - VALUE key = SWIG_RubyPtrToReference(ptr); - - /* Get a reference to the Ruby object as a Ruby number */ - VALUE value = SWIG_RubyObjectToReference(object); - /* Store the mapping to the global hash table. */ - rb_hash_aset(swig_ruby_trackings, key, value); + st_insert(swig_ruby_trackings, (st_data_t)ptr, object); } /* Get the Ruby object that owns the specified C/C++ struct */ SWIGRUNTIME VALUE SWIG_RubyInstanceFor(void* ptr) { - /* Get a reference to the pointer as a Ruby number */ - VALUE key = SWIG_RubyPtrToReference(ptr); - /* Now lookup the value stored in the global hash table */ - VALUE value = rb_hash_aref(swig_ruby_trackings, key); - - if (value == Qnil) { - /* No object exists - return nil. */ + VALUE value; + + if (st_lookup(swig_ruby_trackings, (st_data_t)ptr, &value)) { + return value; + } else { return Qnil; } - else { - /* Convert this value to Ruby object */ - return SWIG_RubyReferenceToObject(value); - } } /* Remove a Tracking from a C/C++ struct to a Ruby object. It @@ -1318,25 +1303,39 @@ SWIGRUNTIME VALUE SWIG_RubyInstanceFor(void* ptr) { since the same memory address may be reused later to create a new object. */ SWIGRUNTIME void SWIG_RubyRemoveTracking(void* ptr) { - /* Get a reference to the pointer as a Ruby number */ - VALUE key = SWIG_RubyPtrToReference(ptr); - - /* Delete the object from the hash table by calling Ruby's - do this we need to call the Hash.delete method.*/ - rb_funcall(swig_ruby_trackings, swig_ruby_hash_delete, 1, key); + /* Delete the object from the hash table */ + st_delete(swig_ruby_trackings, (st_data_t *)&ptr, NULL); } /* This is a helper method that unlinks a Ruby object from its underlying C++ object. This is needed if the lifetime of the - Ruby object is longer than the C++ object */ + Ruby object is longer than the C++ object. */ SWIGRUNTIME void SWIG_RubyUnlinkObjects(void* ptr) { VALUE object = SWIG_RubyInstanceFor(ptr); if (object != Qnil) { + // object might have the T_ZOMBIE type, but that's just + // because the GC has flagged it as such for a deferred + // destruction. Until then, it's still a T_DATA object. DATA_PTR(object) = 0; } } +/* This is a helper method that iterates over all the trackings + passing the C++ object pointer and its related Ruby object + to the passed callback function. */ + +/* Proxy method to abstract the internal trackings datatype */ +static int swig_ruby_internal_iterate_callback(st_data_t ptr, st_data_t obj, st_data_t meth) { + ((void (*) (void *, VALUE))meth)((void *)ptr, (VALUE)obj); + return ST_CONTINUE; +} + +SWIGRUNTIME void SWIG_RubyIterateTrackings( void(*meth)(void* ptr, VALUE obj) ) { + st_foreach(swig_ruby_trackings, + SWIG_RUBY_INT_ANYARGS_FUNC(swig_ruby_internal_iterate_callback), + (st_data_t)meth); +} #ifdef __cplusplus } @@ -1395,7 +1394,7 @@ SWIG_Ruby_AppendOutput(VALUE target, VALUE o) { #define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Ruby_ConvertPtrAndOwn(obj, pptr, type, flags, own) #define SWIG_NewPointerObj(ptr, type, flags) SWIG_Ruby_NewPointerObj(ptr, type, flags) #define SWIG_AcquirePtr(ptr, own) SWIG_Ruby_AcquirePtr(ptr, own) -#define swig_owntype ruby_owntype +#define swig_owntype swig_ruby_owntype /* for raw packed data */ #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) swig_class *sklass; VALUE klass; VALUE obj; - + if (!ptr) return Qnil; - + + assert(type); if (type->clientdata) { sklass = (swig_class *) type->clientdata; @@ -1563,7 +1563,7 @@ SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags) track = sklass->trackObjects; if (track) { obj = SWIG_RubyInstanceFor(ptr); - + /* Check the object's type and make sure it has the correct type. It might not in cases where methods do things like downcast methods. */ @@ -1595,7 +1595,7 @@ SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags) obj = Data_Wrap_Struct(klass, 0, 0, ptr); } rb_iv_set(obj, "@__swigtype__", rb_str_new2(type->name)); - + return obj; } @@ -1615,26 +1615,30 @@ SWIGRUNTIMEINLINE char * SWIG_Ruby_MangleStr(VALUE obj) { VALUE stype = rb_iv_get(obj, "@__swigtype__"); + if (NIL_P(stype)) + return NULL; return StringValuePtr(stype); } /* Acquire a pointer value */ -typedef void (*ruby_owntype)(void*); - -SWIGRUNTIME ruby_owntype -SWIG_Ruby_AcquirePtr(VALUE obj, ruby_owntype own) { - if (obj) { - ruby_owntype oldown = RDATA(obj)->dfree; - RDATA(obj)->dfree = own; - return oldown; - } else { - return 0; +typedef struct { + void (*datafree)(void *); + int own; +} swig_ruby_owntype; + +SWIGRUNTIME swig_ruby_owntype +SWIG_Ruby_AcquirePtr(VALUE obj, swig_ruby_owntype own) { + swig_ruby_owntype oldown = {0, 0}; + if (TYPE(obj) == T_DATA && !RTYPEDDATA_P(obj)) { + oldown.datafree = RDATA(obj)->dfree; + RDATA(obj)->dfree = own.datafree; } + return oldown; } /* Convert a pointer value */ SWIGRUNTIME int -SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, ruby_owntype *own) +SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, swig_ruby_owntype *own) { char *c; swig_cast_info *tc; @@ -1642,16 +1646,20 @@ SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, /* Grab the pointer */ if (NIL_P(obj)) { - *ptr = 0; - return SWIG_OK; + if (ptr) + *ptr = 0; + return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK; } else { - if (TYPE(obj) != T_DATA) { + if (TYPE(obj) != T_DATA || (TYPE(obj) == T_DATA && RTYPEDDATA_P(obj))) { return SWIG_ERROR; } Data_Get_Struct(obj, void, vptr); } - if (own) *own = RDATA(obj)->dfree; + if (own) { + own->datafree = RDATA(obj)->dfree; + own->own = 0; + } /* Check to see if the input object is giving up ownership 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, /* The object has already been deleted */ return SWIG_ObjectPreviouslyDeletedError; } - *ptr = vptr; - return SWIG_OK; } } if ((c = SWIG_MangleStr(obj)) == NULL) { @@ -1697,12 +1703,23 @@ SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, if (!tc) { return SWIG_ERROR; } else { - int newmemory = 0; - *ptr = SWIG_TypeCast(tc, vptr, &newmemory); - assert(!newmemory); /* newmemory handling not yet implemented */ + if (ptr) { + if (tc->type == ty) { + *ptr = vptr; + } else { + int newmemory = 0; + *ptr = SWIG_TypeCast(tc, vptr, &newmemory); + if (newmemory == SWIG_CAST_NEW_MEMORY) { + assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */ + if (own) + own->own = own->own | SWIG_CAST_NEW_MEMORY; + } + } + } } } else { - *ptr = vptr; + if (ptr) + *ptr = vptr; } return SWIG_OK; @@ -1728,7 +1745,7 @@ SWIG_Ruby_NewPackedObj(void *ptr, int sz, swig_type_info *type) { return rb_str_new2(result); } -/* Convert a packed value value */ +/* Convert a packed pointer value */ SWIGRUNTIME int SWIG_Ruby_ConvertPacked(VALUE obj, void *ptr, int sz, swig_type_info *ty) { swig_cast_info *tc; @@ -1855,7 +1872,7 @@ static VALUE mWAV; #define SWIG_RUBY_THREAD_END_BLOCK -#define SWIGVERSION 0x030007 +#define SWIGVERSION 0x040002 #define SWIG_VERSION SWIGVERSION @@ -1875,6 +1892,8 @@ using namespace TagLib::RIFF; #include #include +#include +#include #include #if defined(HAVE_RUBY_ENCODING_H) && HAVE_RUBY_ENCODING_H @@ -1944,6 +1963,28 @@ TagLib::StringList ruby_array_to_taglib_string_list(VALUE ary) { return result; } +VALUE taglib_bytevectorlist_to_ruby_array(const TagLib::ByteVectorList & list) { + VALUE ary = rb_ary_new2(list.size()); + for (TagLib::ByteVectorList::ConstIterator it = list.begin(); it != list.end(); it++) { + VALUE s = taglib_bytevector_to_ruby_string(*it); + rb_ary_push(ary, s); + } + return ary; +} + +TagLib::ByteVectorList ruby_array_to_taglib_bytevectorlist(VALUE ary) { + TagLib::ByteVectorList result = TagLib::ByteVectorList(); + if (NIL_P(ary)) { + return result; + } + for (long i = 0; i < RARRAY_LEN(ary); i++) { + VALUE e = rb_ary_entry(ary, i); + TagLib::ByteVector s = ruby_string_to_taglib_bytevector(e); + result.append(s); + } + return result; +} + VALUE taglib_filename_to_ruby_string(TagLib::FileName filename) { VALUE result; #ifdef _WIN32 @@ -1996,15 +2037,16 @@ TagLib::FileName ruby_string_to_taglib_filename(VALUE s) { SWIGINTERN VALUE -SWIG_ruby_failed(void) +SWIG_ruby_failed(VALUE SWIGUNUSEDPARM(arg1), VALUE SWIGUNUSEDPARM(arg2)) { return Qnil; } -/*@SWIG:/usr/local/share/swig/3.0.7/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/ -SWIGINTERN VALUE SWIG_AUX_NUM2LONG(VALUE *args) +/*@SWIG:/usr/local/Cellar/swig/4.0.2/share/swig/4.0.2/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/ +SWIGINTERN VALUE SWIG_AUX_NUM2LONG(VALUE arg) { + VALUE *args = (VALUE *)arg; VALUE obj = args[0]; VALUE type = TYPE(obj); long *res = (long *)(args[1]); @@ -2022,7 +2064,7 @@ SWIG_AsVal_long (VALUE obj, long* val) VALUE a[2]; a[0] = obj; a[1] = (VALUE)(&v); - if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2LONG), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) { + if (rb_rescue(VALUEFUNC(SWIG_AUX_NUM2LONG), (VALUE)a, VALUEFUNC(SWIG_ruby_failed), 0) != Qnil) { if (val) *val = v; return SWIG_OK; } @@ -2113,7 +2155,7 @@ SWIG_AsCharPtrAndSize(VALUE obj, char** cptr, size_t* psize, int *alloc) if (cptr) { if (alloc) { if (*alloc == SWIG_NEWOBJ) { - *cptr = reinterpret_cast< char* >(memcpy((new char[size]), cstr, sizeof(char)*(size))); + *cptr = reinterpret_cast< char* >(memcpy(new char[size], cstr, sizeof(char)*(size))); } else { *cptr = cstr; *alloc = SWIG_OLDOBJ; @@ -2181,22 +2223,20 @@ SWIGINTERN void TagLib_RIFF_WAV_File_close(TagLib::RIFF::WAV::File *self){ static swig_class SwigClassProperties; -#ifdef HAVE_RB_DEFINE_ALLOC_FUNC SWIGINTERN VALUE -_wrap_Properties_allocate(VALUE self) { +#ifdef HAVE_RB_DEFINE_ALLOC_FUNC +_wrap_Properties_allocate(VALUE self) #else - SWIGINTERN VALUE - _wrap_Properties_allocate(int argc, VALUE *argv, VALUE self) { +_wrap_Properties_allocate(int argc, VALUE *argv, VALUE self) #endif - - - VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__RIFF__WAV__Properties); +{ + VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__RIFF__WAV__Properties); #ifndef HAVE_RB_DEFINE_ALLOC_FUNC - rb_obj_call_init(vresult, argc, argv); + rb_obj_call_init(vresult, argc, argv); #endif - return vresult; - } - + return vresult; +} + SWIGINTERN VALUE _wrap_new_Properties(int argc, VALUE *argv, VALUE self) { @@ -2231,7 +2271,8 @@ _wrap_new_Properties(int argc, VALUE *argv, VALUE self) { SWIGINTERN void -free_TagLib_RIFF_WAV_Properties(TagLib::RIFF::WAV::Properties *arg1) { +free_TagLib_RIFF_WAV_Properties(void *self) { + TagLib::RIFF::WAV::Properties *arg1 = (TagLib::RIFF::WAV::Properties *)self; SWIG_RubyRemoveTracking(arg1); delete arg1; } @@ -2500,22 +2541,20 @@ _wrap_new_File__SWIG_1(int argc, VALUE *argv, VALUE self) { } -#ifdef HAVE_RB_DEFINE_ALLOC_FUNC SWIGINTERN VALUE -_wrap_File_allocate(VALUE self) { +#ifdef HAVE_RB_DEFINE_ALLOC_FUNC +_wrap_File_allocate(VALUE self) #else - SWIGINTERN VALUE - _wrap_File_allocate(int argc, VALUE *argv, VALUE self) { +_wrap_File_allocate(int argc, VALUE *argv, VALUE self) #endif - - - VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__RIFF__WAV__File); +{ + VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_TagLib__RIFF__WAV__File); #ifndef HAVE_RB_DEFINE_ALLOC_FUNC - rb_obj_call_init(vresult, argc, argv); + rb_obj_call_init(vresult, argc, argv); #endif - return vresult; - } - + return vresult; +} + SWIGINTERN VALUE _wrap_new_File__SWIG_2(int argc, VALUE *argv, VALUE self) { @@ -3231,7 +3270,7 @@ SWIG_InitializeModule(void *clientdata) { /* Now work on filling in swig_module.types */ #ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: size %d\n", swig_module.size); + printf("SWIG_InitializeModule: size %lu\n", (unsigned long)swig_module.size); #endif for (i = 0; i < swig_module.size; ++i) { swig_type_info *type = 0; @@ -3239,7 +3278,7 @@ SWIG_InitializeModule(void *clientdata) { swig_cast_info *cast; #ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); + printf("SWIG_InitializeModule: type %lu %s\n", (unsigned long)i, swig_module.type_initial[i]->name); #endif /* if there is another module already loaded */ @@ -3315,7 +3354,7 @@ SWIG_InitializeModule(void *clientdata) { for (i = 0; i < swig_module.size; ++i) { int j = 0; swig_cast_info *cast = swig_module.cast_initial[i]; - printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); + printf("SWIG_InitializeModule: type %lu %s\n", (unsigned long)i, swig_module.type_initial[i]->name); while (cast->type) { printf("SWIG_InitializeModule: cast type %s\n", cast->type->name); cast++;