Sha256: 40cd994a61ba44cc39333cfe62f71830f23a6ec22696842afdf55f852a31f209
Contents?: true
Size: 1.88 KB
Versions: 3
Compression:
Stored size: 1.88 KB
Contents
#include "rays/ruby/font.h" #include <rucy.h> #include "defs.h" using namespace Rucy; using Rays::coord; static Class cFont; namespace Rays { Class font_class () { return cFont; } }// Rays namespace Rucy { Value value (const Rays::Font& obj) { return new_type(cFont, new Rays::Font(obj)); } Value value (const Rays::Font* obj) { return obj ? value(*obj) : nil(); } }// Rucy #define THIS to<Rays::Font*>(self) #define CHECK RUCY_CHECK_OBJECT(self, Rays::Font, cFont) static VALUE alloc(VALUE klass) { return new_type<Rays::Font>(klass); } static VALUE initialize(VALUE self) { RUCY_CHECK_OBJ(self, Rays::Font, cFont); if (argc < 0 || 2 < argc) arg_count_error("Font#initialize", argc, 0, 1, 2); const char* name = (argc >= 1) ? argv[0].c_str() : NULL; float size = (argc >= 2) ? to<float>(argv[1]) : 0; *THIS = Rays::Font(name, size); return self; } static VALUE name(VALUE self) { CHECK; return value(THIS->name().c_str()); } static VALUE size(VALUE self) { CHECK; return value(THIS->size()); } static VALUE width(VALUE self, VALUE str) { CHECK; coord width = 0; if (!THIS->get_width(&width, str.c_str())) rays_error("Font#width(%s) failed.", str.inspect().c_str()); return value(width); } static VALUE height(VALUE self) { CHECK; coord height = 0; if (!THIS->get_height(&height)) rays_error("Font#height() failed."); return value(height); } void Init_font () { Module mRays = rb_define_module("Rays"); cFont = rb_define_class_under(mRays, "Font", rb_cObject); rb_define_alloc_func(cFont, alloc); rb_define_private_method(cFont, "initialize", RUBY_METHOD_FUNC(initialize), -1); rb_define_method(cFont, "name", RUBY_METHOD_FUNC(name), 0); rb_define_method(cFont, "size", RUBY_METHOD_FUNC(size), 0); rb_define_method(cFont, "width", RUBY_METHOD_FUNC(width), 1); rb_define_method(cFont, "height", RUBY_METHOD_FUNC(height), 0); }
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rays-0.1.6 | .doc/ext/rays/font.cpp |
rays-0.1.5 | .doc/ext/rays/font.cpp |
rays-0.1.4 | .doc/ext/rays/font.cpp |