Sha256: 54f3dc650ad3e60de1fb8aab771aac0e23c3adadfbd4d01fa28926346dd517f4

Contents?: true

Size: 1.6 KB

Versions: 30

Compression:

Stored size: 1.6 KB

Contents

#include "reflex/ruby/shape.h"


#include <rays/ruby/point.h>
#include "defs.h"


RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(Reflex::LineShape)

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

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

#define CALL(fun) RUCY_CALL_SUPER(THIS, fun)


static
RUCY_DEF_ALLOC(alloc, klass)
{
	return value(new Reflex::RubyShape<Reflex::LineShape>, klass);
}
RUCY_END

static
RUCY_DEFN(add_point)
{
	CHECK;
	check_arg_count(__FILE__, __LINE__, "LineShape#add_point", argc, 1, 2, 3);

	THIS->add_point(to<Rays::Point>(argc, argv));
	return self;
}
RUCY_END

static
RUCY_DEFN(add_points)
{
	CHECK;

	if (argc <= 0) return self;

	if (argv[0].is_num())
	{
		if (argc % 2 != 0)
			argument_error(__FILE__, __LINE__);

		for (int i = 0; i < argc; i += 2)
			THIS->add_point(to<coord>(argv[i]), to<coord>(argv[i + 1]));
	}
	else
	{
		for (int i = 0; i < argc; ++i)
			THIS->add_point(to<Rays::Point>(argv[i]));
	}
	return self;
}
RUCY_END

static
RUCY_DEF1(set_loop, loop)
{
	CHECK;
	THIS->set_loop(loop);
	return loop;
}
RUCY_END

static
RUCY_DEF0(get_loop)
{
	CHECK;
	return value(THIS->loop());
}
RUCY_END


static Class cLineShape;

void
Init_reflex_line_shape ()
{
	Module mReflex = define_module("Reflex");

	cLineShape = mReflex.define_class("LineShape", Reflex::shape_class());
	cLineShape.define_alloc_func(alloc);
	cLineShape.define_method("add_point",  add_point);
	cLineShape.define_method("add_points", add_points);
	cLineShape.define_method("loop=", set_loop);
	cLineShape.define_method("loop",  get_loop);
}


namespace Reflex
{


	Class
	line_shape_class ()
	{
		return cLineShape;
	}


}// Reflex

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
reflexion-0.2.1 ext/reflex/line_shape.cpp
reflexion-0.2 ext/reflex/line_shape.cpp
reflexion-0.1.57 ext/reflex/line_shape.cpp
reflexion-0.1.56 ext/reflex/line_shape.cpp
reflexion-0.1.55 ext/reflex/line_shape.cpp
reflexion-0.1.54 ext/reflex/line_shape.cpp
reflexion-0.1.53 ext/reflex/line_shape.cpp
reflexion-0.1.52 ext/reflex/line_shape.cpp
reflexion-0.1.51 ext/reflex/line_shape.cpp
reflexion-0.1.50 ext/reflex/line_shape.cpp
reflexion-0.1.49 ext/reflex/line_shape.cpp
reflexion-0.1.48 ext/reflex/line_shape.cpp
reflexion-0.1.47 ext/reflex/line_shape.cpp
reflexion-0.1.46 ext/reflex/line_shape.cpp
reflexion-0.1.45 ext/reflex/line_shape.cpp
reflexion-0.1.44 ext/reflex/line_shape.cpp
reflexion-0.1.43 ext/reflex/line_shape.cpp
reflexion-0.1.42 ext/reflex/line_shape.cpp
reflexion-0.1.41 ext/reflex/line_shape.cpp
reflexion-0.1.40 ext/reflex/line_shape.cpp