#include "reflex/ruby/event.h" #include "defs.h" RUCY_DEFINE_VALUE_FROM_TO(Reflex::UpdateEvent) #define THIS to(self) #define CHECK RUCY_CHECK_OBJ(Reflex::UpdateEvent, self) static VALUE alloc(VALUE klass) { return new_type(klass); } static VALUE initialize(VALUE self, VALUE now, VALUE dt) { CHECK; THIS->now = to(now); THIS->dt = to(dt); return rb_call_super(0, NULL); } static VALUE initialize_copy(VALUE self, VALUE obj) { CHECK; *THIS = to(obj); return self; } static VALUE now(VALUE self) { CHECK; return value(THIS->now); } static VALUE dt(VALUE self) { CHECK; return value(THIS->dt); } static Class cUpdateEvent; void Init_update_event () { Module mReflex = rb_define_module("Reflex"); cUpdateEvent = mReflex.define_class("UpdateEvent", Reflex::event_class()); rb_define_alloc_func(cUpdateEvent, alloc); rb_define_private_method(cUpdateEvent, "initialize", RUBY_METHOD_FUNC(initialize), 2); rb_define_private_method(cUpdateEvent, "initialize_copy", RUBY_METHOD_FUNC(initialize_copy), 1); rb_define_method(cUpdateEvent, "now", RUBY_METHOD_FUNC(now), 0); rb_define_method(cUpdateEvent, "dt", RUBY_METHOD_FUNC(dt), 0); } namespace Reflex { Class update_event_class () { return cUpdateEvent; } }// Reflex