Added a #initialize_copy method to all classes which are wrapped around a C++ object in order to properly copy the values.

git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1740 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
groogy 2010-12-03 19:47:41 +00:00
parent 0920da5d8e
commit bb7a6fac1f
14 changed files with 156 additions and 8 deletions

View file

@ -193,6 +193,15 @@ static VALUE SoundBuffer_GetDuration( VALUE self )
return rb_float_new( object->GetDuration() );
}
static VALUE SoundBuffer_InitializeCopy( VALUE self, VALUE aSource )
{
sf::SoundBuffer *object = NULL;
Data_Get_Struct( self, sf::SoundBuffer, object );
sf::SoundBuffer *source = NULL;
Data_Get_Struct( aSource, sf::SoundBuffer, source );
*object = *source;
}
/* call-seq:
* SoundBuffer.new() -> sound_buffer
*
@ -264,6 +273,7 @@ void Init_SoundBuffer( void )
rb_define_singleton_method( globalSoundBufferClass, "new", SoundBuffer_New, -1 );
// Instance methods
rb_define_method( globalSoundBufferClass, "initialize_copy", SoundBuffer_InitializeCopy, 1 );
rb_define_method( globalSoundBufferClass, "loadFromFile", SoundBuffer_LoadFromFile, 1 );
rb_define_method( globalSoundBufferClass, "loadFromSamples", SoundBuffer_LoadFromSamples, 4 );
rb_define_method( globalSoundBufferClass, "saveToFile", SoundBuffer_SaveToFile, 1 );

View file

@ -237,6 +237,15 @@ static VALUE SoundSource_SetVolume( VALUE self, VALUE aValue )
return Qnil;
}
static VALUE SoundSource_InitializeCopy( VALUE self, VALUE aSource )
{
sf::SoundSource *object = NULL;
Data_Get_Struct( self, sf::SoundSource, object );
sf::SoundSource *source = NULL;
Data_Get_Struct( aSource, sf::SoundSource, source );
*object = *source;
}
static void DefineStatusEnum( void )
{
rb_define_const( globalSoundSourceClass, "Stopped", INT2FIX( sf::SoundSource::Stopped ) );
@ -260,6 +269,7 @@ void Init_SoundSource( void )
DefineStatusEnum();
// Instance methods
rb_define_method( globalSoundSourceClass, "initialize_copy", SoundSource_InitializeCopy, 1 );
rb_define_method( globalSoundSourceClass, "getAttenuation", SoundSource_GetAttenuation, 0 );
rb_define_method( globalSoundSourceClass, "getMinDistance", SoundSource_GetMinDistance, 0 );
rb_define_method( globalSoundSourceClass, "getPitch", SoundSource_GetPitch, 0 );