.doc/ext/rays/font.cpp in rays-0.1.6 vs .doc/ext/rays/font.cpp in rays-0.1.7
- old
+ new
@@ -10,108 +10,71 @@
using Rays::coord;
static Class cFont;
+RUCY_DEFINE_VALUE_FROM_TO(Rays::Font, cFont)
-namespace Rays
-{
+#define THIS to<Rays::Font*>(self)
+#define CHECK RUCY_CHECK_OBJECT(Rays::Font, cFont, self)
- 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);
+ RUCY_CHECK_OBJ(Rays::Font, cFont, self);
+ check_arg_count(__FILE__, __LINE__, "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 initialize_copy(VALUE self, VALUE obj)
+{
+ RUCY_CHECK_OBJ(Rays::Font, cFont, self);
+
+ *THIS = to<Rays::Font&>(obj).copy();
+ 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);
+ return value(THIS->get_width(str.c_str()));
}
static
VALUE height(VALUE self)
{
CHECK;
-
- coord height = 0;
- if (!THIS->get_height(&height))
- rays_error("Font#height() failed.");
-
- return value(height);
+ return value(THIS->get_height());
}
void
Init_font ()
@@ -119,10 +82,25 @@
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_private_method(cFont, "initialize_copy", RUBY_METHOD_FUNC(initialize_copy), 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);
}
+
+
+namespace Rays
+{
+
+
+ Class
+ font_class ()
+ {
+ return cFont;
+ }
+
+
+}// Rays