ext/rays/font.cpp in rays-0.1.6 vs ext/rays/font.cpp in rays-0.1.7
- old
+ new
@@ -10,125 +10,104 @@
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
-RUBY_DEF_ALLOC(alloc, klass)
+RUCY_DEF_ALLOC(alloc, klass)
{
return new_type<Rays::Font>(klass);
}
-RUBY_END
+RUCY_END
static
-RUBY_DEFN(initialize)
+RUCY_DEFN(initialize)
{
- 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;
}
-RUBY_END
+RUCY_END
static
-RUBY_DEF0(name)
+RUCY_DEF1(initialize_copy, obj)
{
- CHECK;
+ RUCY_CHECK_OBJ(Rays::Font, cFont, self);
- return value(THIS->name().c_str());
+ *THIS = to<Rays::Font&>(obj).copy();
+ return self;
}
-RUBY_END
+RUCY_END
static
-RUBY_DEF0(size)
+RUCY_DEF0(name)
{
CHECK;
+ return value(THIS->name().c_str());
+}
+RUCY_END
+static
+RUCY_DEF0(size)
+{
+ CHECK;
return value(THIS->size());
}
-RUBY_END
+RUCY_END
static
-RUBY_DEF1(width, str)
+RUCY_DEF1(width, 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()));
}
-RUBY_END
+RUCY_END
static
-RUBY_DEF0(height)
+RUCY_DEF0(height)
{
CHECK;
-
- coord height = 0;
- if (!THIS->get_height(&height))
- rays_error("Font#height() failed.");
-
- return value(height);
+ return value(THIS->get_height());
}
-RUBY_END
+RUCY_END
void
Init_font ()
{
Module mRays = define_module("Rays");
cFont = mRays.define_class("Font");
cFont.define_alloc_func(alloc);
cFont.define_private_method("initialize", initialize);
+ cFont.define_private_method("initialize_copy", initialize_copy);
cFont.define_method("name", name);
cFont.define_method("size", size);
cFont.define_method("width", width);
cFont.define_method("height", height);
}
+
+
+namespace Rays
+{
+
+
+ Class
+ font_class ()
+ {
+ return cFont;
+ }
+
+
+}// Rays