#include "reflex/ruby/event.h" #include "rays/ruby/point.h" #include "defs.h" RUCY_DEFINE_VALUE_FROM_TO(Reflex::WheelEvent) #define THIS to(self) #define CHECK RUCY_CHECK_OBJ(Reflex::WheelEvent, self) static VALUE alloc(VALUE klass) { return new_type(klass); } static VALUE initialize(VALUE self, VALUE x, VALUE y, VALUE z, VALUE dx, VALUE dy, VALUE dz, VALUE modifiers) { CHECK; *THIS = Reflex::WheelEvent( to( x), to( y), to( z), to(dx), to(dy), to(dz), to(modifiers)); return rb_call_super(0, NULL); } static VALUE initialize_copy(VALUE self, VALUE obj) { CHECK; *THIS = to(obj).dup(); return self; } static VALUE x(VALUE self) { CHECK; return value(THIS->position().x); } static VALUE y(VALUE self) { CHECK; return value(THIS->position().y); } static VALUE z(VALUE self) { CHECK; return value(THIS->position().z); } static VALUE dx(VALUE self) { CHECK; return value(THIS->dposition().x); } static VALUE dy(VALUE self) { CHECK; return value(THIS->dposition().y); } static VALUE dz(VALUE self) { CHECK; return value(THIS->dposition().z); } static VALUE position(VALUE self) { CHECK; return value(THIS->position()); } static VALUE dposition(VALUE self) { CHECK; return value(THIS->dposition()); } static VALUE modifiers(VALUE self) { CHECK; return value(THIS->modifiers()); } static Class cWheelEvent; void Init_reflex_wheel_event () { Module mReflex = rb_define_module("Reflex"); cWheelEvent = mReflex.define_class("WheelEvent", Reflex::event_class()); rb_define_alloc_func(cWheelEvent, alloc); rb_define_private_method(cWheelEvent, "initialize", RUBY_METHOD_FUNC(initialize), 7); rb_define_private_method(cWheelEvent, "initialize_copy", RUBY_METHOD_FUNC(initialize_copy), 1); rb_define_method(cWheelEvent, "x", RUBY_METHOD_FUNC(x), 0); rb_define_method(cWheelEvent, "y", RUBY_METHOD_FUNC(y), 0); rb_define_method(cWheelEvent, "z", RUBY_METHOD_FUNC(z), 0); rb_define_method(cWheelEvent, "dx", RUBY_METHOD_FUNC(dx), 0); rb_define_method(cWheelEvent, "dy", RUBY_METHOD_FUNC(dy), 0); rb_define_method(cWheelEvent, "dz", RUBY_METHOD_FUNC(dz), 0); rb_define_method(cWheelEvent, "position", RUBY_METHOD_FUNC(position), 0); rb_define_method(cWheelEvent, "dposition", RUBY_METHOD_FUNC(dposition), 0); rb_define_method(cWheelEvent, "modifiers", RUBY_METHOD_FUNC(modifiers), 0); } namespace Reflex { Class wheel_event_class () { return cWheelEvent; } }// Reflex