Sha256: b1a267b5cb2784fc9c59b80ccfa09e9835d8f6f487aba65467af0b7039dc6f6c

Contents?: true

Size: 1.67 KB

Versions: 3

Compression:

Stored size: 1.67 KB

Contents

#include "reflex/ruby/event.h"


#include <rays/ruby/painter.h>
#include <rays/ruby/bounds.h>
#include "defs.h"


RUCY_DEFINE_VALUE_FROM_TO(Reflex::DrawEvent)

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

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


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

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

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

	return rb_call_super(0, NULL);
}

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

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

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

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

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


static Class cDrawEvent;

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

	cDrawEvent = mReflex.define_class("DrawEvent", Reflex::event_class());
	rb_define_alloc_func(cDrawEvent, alloc);
	rb_define_private_method(cDrawEvent, "initialize", RUBY_METHOD_FUNC(initialize), -1);
	rb_define_private_method(cDrawEvent, "initialize_copy", RUBY_METHOD_FUNC(initialize_copy), 1);
	rb_define_method(cDrawEvent, "painter", RUBY_METHOD_FUNC(painter), 0);
	rb_define_method(cDrawEvent, "bounds", RUBY_METHOD_FUNC(bounds), 0);
	rb_define_method(cDrawEvent, "dt", RUBY_METHOD_FUNC(dt), 0);
	rb_define_method(cDrawEvent, "fps", RUBY_METHOD_FUNC(fps), 0);
}


namespace Reflex
{


	Class
	draw_event_class ()
	{
		return cDrawEvent;
	}


}// Reflex

Version data entries

3 entries across 3 versions & 1 rubygems

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