Sha256: aad35ed4b3bbe1d9c99746e2fc98882f2d36e9e4771b831a62b69a89d803930d
Contents?: true
Size: 1.69 KB
Versions: 16
Compression:
Stored size: 1.69 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 VALUE alloc(VALUE klass) { return value(new Reflex::RubyShape<Reflex::LineShape>, klass); } static VALUE add_point(VALUE self) { CHECK; check_arg_count(__FILE__, __LINE__, "LineShape#add_point", argc, 1, 2, 3); THIS->add_point(to<Rays::Point>(argc, argv)); return self; } static VALUE add_points(VALUE self) { 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; } static VALUE set_loop(VALUE self, VALUE loop) { CHECK; THIS->set_loop(loop); return loop; } static VALUE get_loop(VALUE self) { CHECK; return value(THIS->loop()); } static Class cLineShape; void Init_line_shape () { Module mReflex = rb_define_module("Reflex"); cLineShape = mReflex.define_class("LineShape", Reflex::shape_class()); rb_define_alloc_func(cLineShape, alloc); rb_define_method(cLineShape, "add_point", RUBY_METHOD_FUNC(add_point), -1); rb_define_method(cLineShape, "add_points", RUBY_METHOD_FUNC(add_points), -1); rb_define_method(cLineShape, "loop=", RUBY_METHOD_FUNC(set_loop), 1); rb_define_method(cLineShape, "loop", RUBY_METHOD_FUNC(get_loop), 0); } namespace Reflex { Class line_shape_class () { return cLineShape; } }// Reflex
Version data entries
16 entries across 16 versions & 1 rubygems