Sha256: ea595ec5688242af9ae02f55fd0ab300be39c62a072296d16391940ecb9e79bc

Contents?: true

Size: 1.95 KB

Versions: 3

Compression:

Stored size: 1.95 KB

Contents

#include "reflex/ruby/event.h"


#include "reflex/ruby/timer.h"
#include "reflex/ruby/view.h"
#include "defs.h"


RUCY_DEFINE_VALUE_FROM_TO(REFLEX_EXPORT, Reflex::TimerEvent)

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

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


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

static
VALUE initialize(VALUE self, VALUE timer)
{
	CHECK;

	*THIS = Reflex::TimerEvent(to<Reflex::Timer*>(timer));

	return rb_call_super(0, NULL);
}

static
VALUE initialize_copy(VALUE self, VALUE obj)
{
	CHECK;
	*THIS = to<Reflex::TimerEvent&>(obj).dup();
	return self;
}

static
VALUE timer(VALUE self)
{
	CHECK;
	return value(THIS->timer());
}

static
VALUE owner(VALUE self)
{
	CHECK;
	return value(THIS->owner());
}

static
VALUE id(VALUE self)
{
	CHECK;
	return value(THIS->id());
}

static
VALUE interval(VALUE self)
{
	CHECK;
	return value(THIS->interval());
}

static
VALUE count(VALUE self)
{
	CHECK;
	return value(THIS->count());
}

static
VALUE is_finished(VALUE self)
{
	CHECK;
	return value(THIS->is_finished());
}


static Class cTimerEvent;

void
Init_reflex_timer_event ()
{
	Module mReflex = rb_define_module("Reflex");

	cTimerEvent = mReflex.define_class("TimerEvent", Reflex::event_class());
	rb_define_alloc_func(cTimerEvent, alloc);
	rb_define_private_method(cTimerEvent, "initialize", RUBY_METHOD_FUNC(initialize), 1);
	rb_define_private_method(cTimerEvent, "initialize_copy", RUBY_METHOD_FUNC(initialize_copy), 1);
	rb_define_method(cTimerEvent, "timer", RUBY_METHOD_FUNC(timer), 0);
	rb_define_method(cTimerEvent, "owner", RUBY_METHOD_FUNC(owner), 0);
	rb_define_method(cTimerEvent, "id", RUBY_METHOD_FUNC(id), 0);
	rb_define_method(cTimerEvent, "interval", RUBY_METHOD_FUNC(interval), 0);
	rb_define_method(cTimerEvent, "count", RUBY_METHOD_FUNC(count), 0);
	cTimerEvent.define_method("finished?", is_finished);
}


namespace Reflex
{


	Class
	timer_event_class ()
	{
		return cTimerEvent;
	}


}// Reflex

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
reflexion-0.3.2 .doc/ext/reflex/timer_event.cpp
reflexion-0.3.1 .doc/ext/reflex/timer_event.cpp
reflexion-0.3 .doc/ext/reflex/timer_event.cpp