#include "beeps/ruby/sound.h" #include #include "beeps/exception.h" #include "defs.h" using namespace Rucy; RUCY_DEFINE_VALUE_FROM_TO(Beeps::Sound) #define THIS to(self) #define CHECK RUCY_CHECK_OBJECT(Beeps::Sound, self) static VALUE alloc(VALUE klass) { return new_type(klass); } static VALUE initialize(VALUE self, VALUE processor, VALUE seconds) { RUCY_CHECK_OBJ(Beeps::Sound, self); *THIS = Beeps::Sound(to(processor), to(seconds)); return self; } static VALUE play(VALUE self) { CHECK; THIS->play(); return self; } static Class cSound; void Init_sound () { Module mBeeps = rb_define_module("Beeps"); cSound = rb_define_class_under(mBeeps, "Sound", rb_cObject); rb_define_alloc_func(cSound, alloc); rb_define_private_method(cSound, "initialize", RUBY_METHOD_FUNC(initialize), 2); rb_define_method(cSound, "play", RUBY_METHOD_FUNC(play), 0); } namespace Beeps { Class sound_class () { return cSound; } }// Beeps