Sha256: cda98f59e8af85390d801ee18521e86091d50091589baae3b4e0213997a0334c

Contents?: true

Size: 1.81 KB

Versions: 2

Compression:

Stored size: 1.81 KB

Contents

#include "reflex/ruby/event.h"


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


RUCY_DEFINE_VALUE_FROM_TO(Reflex::ContactEvent)

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

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


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

static
VALUE initialize(VALUE self, VALUE type, VALUE shape)
{
	CHECK;

	THIS->type  = (Reflex::ContactEvent::Type) to<int>(type);
	THIS->shape = to<Reflex::Shape*>(shape);

	return rb_call_super(0, NULL);
}

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

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

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

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


static Class cContactEvent;

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

	cContactEvent = mReflex.define_class("ContactEvent", Reflex::event_class());
	rb_define_alloc_func(cContactEvent, alloc);
	rb_define_private_method(cContactEvent, "initialize", RUBY_METHOD_FUNC(initialize), 2);
	rb_define_private_method(cContactEvent, "initialize_copy", RUBY_METHOD_FUNC(initialize_copy), 1);
	rb_define_method(cContactEvent, "type", RUBY_METHOD_FUNC(get_type), 0);
	rb_define_method(cContactEvent, "shape", RUBY_METHOD_FUNC(get_shape), 0);
	rb_define_method(cContactEvent, "view", RUBY_METHOD_FUNC(get_view), 0);
	cContactEvent.define_const("TYPE_NONE",  Reflex::ContactEvent::NONE);
	cContactEvent.define_const("TYPE_BEGIN", Reflex::ContactEvent::BEGIN);
	cContactEvent.define_const("TYPE_END",   Reflex::ContactEvent::END);
}


namespace Reflex
{


	Class
	contact_event_class ()
	{
		return cContactEvent;
	}


}// Reflex

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
reflexion-0.1.23 .doc/ext/reflex/contact_event.cpp
reflexion-0.1.22 .doc/ext/reflex/contact_event.cpp