Sha256: 4118508d1cf4eaadbfb2cb429e5ed71216bb257ce5424b6a3dbfd5d2530bfecc

Contents?: true

Size: 1.41 KB

Versions: 3

Compression:

Stored size: 1.41 KB

Contents

#include "reflex/ruby/event.h"


#include "defs.h"


RUCY_DEFINE_VALUE_FROM_TO(Reflex::UpdateEvent)

#define THIS  to<Reflex::UpdateEvent*>(self)

#define CHECK RUCY_CHECK_OBJ(Reflex::UpdateEvent, self)


static
VALUE alloc(VALUE klass)
{
	return new_type<Reflex::UpdateEvent>(klass);
}

static
VALUE initialize(VALUE self)
{
	CHECK;
	check_arg_count(__FILE__, __LINE__, "UpdateEvent#initialize", argc, 0, 1, 2);

	THIS->now = (argc >= 1) ? to<double>(argv[0]) : 0;
	THIS->dt  = (argc >= 2) ? to<float>(argv[1])  : 0;

	return rb_call_super(0, NULL);
}

static
VALUE initialize_copy(VALUE self, VALUE obj)
{
	CHECK;
	*THIS = to<Reflex::UpdateEvent&>(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), -1);
	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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
reflexion-0.1.15 .doc/ext/reflex/update_event.cpp
reflexion-0.1.14 .doc/ext/reflex/update_event.cpp
reflexion-0.1.13 .doc/ext/reflex/update_event.cpp