#include "beeps/ruby/processor.h" #include "beeps/exception.h" #include "defs.h" RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(Beeps::Processor) #define THIS to(self) #define CHECK RUCY_CHECK_OBJ(Beeps::Processor, self) static VALUE alloc(VALUE klass) { Beeps::beeps_error(__FILE__, __LINE__); } static VALUE reset(VALUE self) { CHECK; THIS->reset(); return self; } static VALUE set_input(VALUE self, VALUE input) { CHECK; THIS->set_input(input ? to(input) : NULL); return input; } static VALUE get_input(VALUE self) { CHECK; return value(THIS->input()); } static Class cProcessor; void Init_beeps_processor () { Module mBeeps = rb_define_module("Beeps"); cProcessor = rb_define_class_under(mBeeps, "Processor", rb_cObject); rb_define_alloc_func(cProcessor, alloc); rb_define_method(cProcessor, "reset", RUBY_METHOD_FUNC(reset), 0); rb_define_method(cProcessor, "input=", RUBY_METHOD_FUNC(set_input), 1); rb_define_method(cProcessor, "input", RUBY_METHOD_FUNC(get_input), 0); } namespace Beeps { Class processor_class () { return cProcessor; } }// Beeps