/*
- * $Id: rb_evas.c 29 2004-07-08 18:47:44Z tilman $
+ * $Id: rb_evas.c 32 2004-07-10 14:07:49Z tilman $
*
* Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
*
static VALUE c_inspect (VALUE self)
{
- char buf[128];
-
- GET_OBJ (self, Evas, e, "Evas");
-
- snprintf (buf, sizeof (buf), "#<Evas::Evas:%p ptr=%p>",
- (void *) self, *e);
-
- return rb_str_new2 (buf);
+ INSPECT (self, Evas);
}
static VALUE c_render (VALUE self)
{
- GET_OBJ (self, Evas, e, "Evas");
+ GET_OBJ (self, Evas, e);
evas_render (*e);
static VALUE c_font_path_clear (VALUE self)
{
- GET_OBJ (self, Evas, e, "Evas");
+ GET_OBJ (self, Evas, e);
evas_font_path_clear (*e);
static VALUE c_font_path_append (VALUE self, VALUE path)
{
- GET_OBJ (self, Evas, e, "Evas");
+ GET_OBJ (self, Evas, e);
Check_Type (path, T_STRING);
static VALUE c_font_path_prepend (VALUE self, VALUE path)
{
- GET_OBJ (self, Evas, e, "Evas");
+ GET_OBJ (self, Evas, e);
Check_Type (path, T_STRING);
VALUE ary;
const Evas_List *list, *l;
- GET_OBJ (self, Evas, e, "Evas");
+ GET_OBJ (self, Evas, e);
if (!(list = evas_font_path_list (*e)))
return rb_ary_new ();
static VALUE c_font_cache_get (VALUE self)
{
- GET_OBJ (self, Evas, e, "Evas");
+ GET_OBJ (self, Evas, e);
return INT2FIX (evas_font_cache_get (*e));
}
static VALUE c_font_cache_set (VALUE self, VALUE val)
{
- GET_OBJ (self, Evas, e, "Evas");
+ GET_OBJ (self, Evas, e);
Check_Type (val, T_FIXNUM);
static VALUE c_font_cache_flush (VALUE self)
{
- GET_OBJ (self, Evas, e, "Evas");
+ GET_OBJ (self, Evas, e);
evas_font_cache_flush (*e);
static VALUE c_image_cache_get (VALUE self)
{
- GET_OBJ (self, Evas, e, "Evas");
+ GET_OBJ (self, Evas, e);
return INT2FIX (evas_image_cache_get (*e));
}
static VALUE c_image_cache_set (VALUE self, VALUE val)
{
- GET_OBJ (self, Evas, e, "Evas");
+ GET_OBJ (self, Evas, e);
Check_Type (val, T_FIXNUM);
static VALUE c_image_cache_reload (VALUE self)
{
- GET_OBJ (self, Evas, e, "Evas");
+ GET_OBJ (self, Evas, e);
evas_image_cache_reload (*e);
static VALUE c_image_cache_flush (VALUE self)
{
- GET_OBJ (self, Evas, e, "Evas");
+ GET_OBJ (self, Evas, e);
evas_image_cache_flush (*e);
Evas_Object *o;
void *obj;
- GET_OBJ (self, Evas, e, "Evas");
+ GET_OBJ (self, Evas, e);
if (!(o = evas_object_top_get (*e)))
return Qnil;
Evas_Object *o;
void *obj;
- GET_OBJ (self, Evas, e, "Evas");
+ GET_OBJ (self, Evas, e);
if (!(o = evas_object_bottom_get (*e)))
return Qnil;
Evas_Object *o;
void *obj;
- GET_OBJ (self, Evas, e, "Evas");
+ GET_OBJ (self, Evas, e);
Check_Type (name, T_STRING);
/*
- * $Id: rb_evas_main.h 23 2004-06-26 22:55:31Z tilman $
+ * $Id: rb_evas_main.h 32 2004-07-10 14:07:49Z tilman $
*
* Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
*
#ifndef __RB_EVAS_MAIN_H
#define __RB_EVAS_MAIN_H
-#define GET_OBJ(obj, type, o, desc) \
+#define GET_OBJ(obj, type, o) \
type **(o) = NULL; \
\
Data_Get_Struct ((obj), type *, (o)); \
\
if (!*(o)) { \
- rb_raise (rb_eException, desc " destroyed already"); \
+ rb_raise (rb_eException, \
+ "%s destroyed already", \
+ rb_obj_classname ((obj))); \
return Qnil; \
}
return Qnil; \
}
+#define CHECK_CLASS(val, klass) \
+ if (!rb_obj_is_kind_of ((val), (klass))) { \
+ rb_raise (rb_eTypeError, \
+ "wrong argument type %s (expected %s)", \
+ rb_obj_classname ((val)), \
+ rb_obj_classname ((klass))); \
+ return Qnil; \
+ }
+
+#define INSPECT(obj, type) \
+ char buf[128]; \
+\
+ GET_OBJ (obj, type, o); \
+\
+ snprintf (buf, sizeof (buf), \
+ "#<%s:%p ptr=%p>", rb_obj_classname ((obj)), \
+ (void *) obj, *o); \
+\
+ return rb_str_new2 (buf);
+
VALUE mEvas;
#endif
/*
- * $Id: rb_evas_object.c 29 2004-07-08 18:47:44Z tilman $
+ * $Id: rb_evas_object.c 32 2004-07-10 14:07:49Z tilman $
*
* Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
*
static VALUE c_init (VALUE self, VALUE parent)
{
- GET_OBJ (self, Evas_Object, e, "EvasObject");
+ GET_OBJ (self, Evas_Object, e);
evas_object_data_set (*e, RUBY_EVAS_OBJECT_KEY, (void *) self);
static VALUE c_inspect (VALUE self)
{
- char buf[128];
-
- GET_OBJ (self, Evas_Object, e, "EvasObject");
-
- snprintf (buf, sizeof (buf), "#<Evas::EvasObject:%p ptr=%p>",
- (void *) self, *e);
-
- return rb_str_new2 (buf);
+ INSPECT (self, Evas_Object);
}
static VALUE c_delete (VALUE self)
{
- GET_OBJ (self, Evas_Object, e, "EvasObject");
+ GET_OBJ (self, Evas_Object, e);
evas_object_del (*e);
*e = NULL;
static VALUE c_resize (VALUE self, VALUE w, VALUE h)
{
- GET_OBJ (self, Evas_Object, e, "EvasObject");
+ GET_OBJ (self, Evas_Object, e);
Check_Type (w, T_FIXNUM);
Check_Type (h, T_FIXNUM);
static VALUE c_move (VALUE self, VALUE x, VALUE y)
{
- GET_OBJ (self, Evas_Object, e, "EvasObject");
+ GET_OBJ (self, Evas_Object, e);
Check_Type (x, T_FIXNUM);
Check_Type (y, T_FIXNUM);
{
int x = 0, y = 0, w = 0, h = 0;
- GET_OBJ (self, Evas_Object, e, "EvasObject");
+ GET_OBJ (self, Evas_Object, e);
evas_object_geometry_get (*e, (Evas_Coord *) &x, (Evas_Coord *) &y,
(Evas_Coord *) & w, (Evas_Coord *) &h);
static VALUE c_show (VALUE self)
{
- GET_OBJ (self, Evas_Object, e, "EvasObject");
+ GET_OBJ (self, Evas_Object, e);
evas_object_show (*e);
static VALUE c_hide (VALUE self)
{
- GET_OBJ (self, Evas_Object, e, "EvasObject");
+ GET_OBJ (self, Evas_Object, e);
evas_object_hide (*e);
static VALUE c_visible_get (VALUE self)
{
- GET_OBJ (self, Evas_Object, e, "EvasObject");
+ GET_OBJ (self, Evas_Object, e);
return evas_object_visible_get (*e) ? Qtrue : Qfalse;
}
static VALUE c_evas_get (VALUE self)
{
- GET_OBJ (self, Evas_Object, e, "EvasObject");
+ GET_OBJ (self, Evas_Object, e);
return rb_hash_aref (parents, INT2NUM ((long) (e)));
}
{
const char *name;
- GET_OBJ (self, Evas_Object, e, "EvasObject");
+ GET_OBJ (self, Evas_Object, e);
if (!(name = evas_object_name_get (*e)))
return Qnil;
static VALUE c_name_set (VALUE self, VALUE val)
{
- GET_OBJ (self, Evas_Object, e, "EvasObject");
+ GET_OBJ (self, Evas_Object, e);
Check_Type (val, T_STRING);
static VALUE c_layer_get (VALUE self)
{
- GET_OBJ (self, Evas_Object, e, "EvasObject");
+ GET_OBJ (self, Evas_Object, e);
return INT2FIX (evas_object_layer_get (*e));
}
static VALUE c_layer_set (VALUE self, VALUE val)
{
- GET_OBJ (self, Evas_Object, e, "EvasObject");
+ GET_OBJ (self, Evas_Object, e);
Check_Type (val, T_FIXNUM);
{
int r = 0, g = 0, b = 0, a = 0;
- GET_OBJ (self, Evas_Object, e, "EvasObject");
+ GET_OBJ (self, Evas_Object, e);
evas_object_color_get (*e, &r, &g, &b, &a);
static VALUE c_set_color (VALUE self, VALUE r, VALUE g, VALUE b,
VALUE a)
{
- GET_OBJ (self, Evas_Object, e, "EvasObject");
+ GET_OBJ (self, Evas_Object, e);
Check_Type (r, T_FIXNUM);
Check_Type (g, T_FIXNUM);
static VALUE c_pass_events_get (VALUE self)
{
- GET_OBJ (self, Evas_Object, e, "EvasObject");
+ GET_OBJ (self, Evas_Object, e);
return evas_object_pass_events_get (*e) ? Qtrue : Qfalse;
}
static VALUE c_pass_events_set (VALUE self, VALUE val)
{
- GET_OBJ (self, Evas_Object, e, "EvasObject");
+ GET_OBJ (self, Evas_Object, e);
CHECK_BOOL (val);
static VALUE c_raise (VALUE self)
{
- GET_OBJ (self, Evas_Object, e, "EvasObject");
+ GET_OBJ (self, Evas_Object, e);
evas_object_raise (*e);
static VALUE c_lower (VALUE self)
{
- GET_OBJ (self, Evas_Object, e, "EvasObject");
+ GET_OBJ (self, Evas_Object, e);
evas_object_lower (*e);
static VALUE c_stack_above (VALUE self, VALUE target)
{
- GET_OBJ (self, Evas_Object, e, "EvasObject");
+ GET_OBJ (self, Evas_Object, e);
if (!rb_obj_is_kind_of (target, cEvasObject)) {
rb_raise (rb_eTypeError,
return Qnil;
}
- GET_OBJ (target, Evas_Object, target2, "EvasObject");
+ GET_OBJ (target, Evas_Object, target2);
evas_object_stack_above (*e, *target2);
static VALUE c_stack_below (VALUE self, VALUE target)
{
- GET_OBJ (self, Evas_Object, e, "EvasObject");
+ GET_OBJ (self, Evas_Object, e);
if (!rb_obj_is_kind_of (target, cEvasObject)) {
rb_raise (rb_eTypeError,
return Qnil;
}
- GET_OBJ (target, Evas_Object, target2, "EvasObject");
+ GET_OBJ (target, Evas_Object, target2);
evas_object_stack_below (*e, *target2);
Evas_Object *o;
void *obj;
- GET_OBJ (self, Evas_Object, e, "EvasObject");
+ GET_OBJ (self, Evas_Object, e);
if (!(evas_object_above_get (*e)))
return Qnil;
Evas_Object *o;
void *obj;
- GET_OBJ (self, Evas_Object, e, "EvasObject");
+ GET_OBJ (self, Evas_Object, e);
if (!(evas_object_below_get (*e)))
return Qnil;
/*
- * $Id: rb_gradient.c 23 2004-06-26 22:55:31Z tilman $
+ * $Id: rb_gradient.c 32 2004-07-10 14:07:49Z tilman $
*
* Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
*
VALUE self, argv[1];
Evas_Object **rect;
- if (!rb_obj_is_kind_of (evas, cEvas)) {
- rb_raise (rb_eTypeError,
- "wrong argument type %s (expected Evas)",
- rb_obj_classname (evas));
- return Qnil;
- }
-
- GET_OBJ (evas, Evas, e, "Evas");
+ CHECK_CLASS (evas, cEvas);
+ GET_OBJ (evas, Evas, e);
self = Data_Make_Struct (klass, Evas_Object *, c_evas_object_mark,
c_evas_object_free, rect);
static VALUE c_color_add (VALUE self, VALUE r, VALUE g, VALUE b,
VALUE a, VALUE distance)
{
- GET_OBJ (self, Evas_Object, e, "Gradient");
+ GET_OBJ (self, Evas_Object, e);
Check_Type (r, T_FIXNUM);
Check_Type (g, T_FIXNUM);
static VALUE c_colors_clear (VALUE self)
{
- GET_OBJ (self, Evas_Object, e, "Gradient");
+ GET_OBJ (self, Evas_Object, e);
evas_object_gradient_colors_clear (*e);
static VALUE c_angle_get (VALUE self)
{
- GET_OBJ (self, Evas_Object, e, "Gradient");
+ GET_OBJ (self, Evas_Object, e);
return INT2FIX (evas_object_gradient_angle_get (*e));
}
static VALUE c_angle_set (VALUE self, VALUE val)
{
- GET_OBJ (self, Evas_Object, e, "Gradient");
+ GET_OBJ (self, Evas_Object, e);
Check_Type (val, T_FIXNUM);
/*
- * $Id: rb_image.c 23 2004-06-26 22:55:31Z tilman $
+ * $Id: rb_image.c 32 2004-07-10 14:07:49Z tilman $
*
* Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
*
VALUE self, argv[1];
Evas_Object **rect;
- if (!rb_obj_is_kind_of (evas, cEvas)) {
- rb_raise (rb_eTypeError,
- "wrong argument type %s (expected Evas)",
- rb_obj_classname (evas));
- return Qnil;
- }
-
- GET_OBJ (evas, Evas, e, "Evas");
+ CHECK_CLASS (evas, cEvas);
+ GET_OBJ (evas, Evas, e);
self = Data_Make_Struct (klass, Evas_Object *, c_evas_object_mark,
c_evas_object_free, rect);
/*
- * $Id: rb_line.c 23 2004-06-26 22:55:31Z tilman $
+ * $Id: rb_line.c 32 2004-07-10 14:07:49Z tilman $
*
* Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
*
VALUE self, argv[1];
Evas_Object **rect;
- if (!rb_obj_is_kind_of (evas, cEvas)) {
- rb_raise (rb_eTypeError,
- "wrong argument type %s (expected Evas)",
- rb_obj_classname (evas));
- return Qnil;
- }
-
- GET_OBJ (evas, Evas, e, "Evas");
+ CHECK_CLASS (evas, cEvas);
+ GET_OBJ (evas, Evas, e);
self = Data_Make_Struct (klass, Evas_Object *, c_evas_object_mark,
c_evas_object_free, rect);
{
int coord[4] = {0, 0, 0, 0};
- GET_OBJ (self, Evas_Object, e, "Line");
+ GET_OBJ (self, Evas_Object, e);
evas_object_line_xy_get (*e, &coord[0], &coord[1],
&coord[2], &coord[3]);
static VALUE c_set_xy (VALUE self, VALUE x1, VALUE y1,
VALUE x2, VALUE y2)
{
- GET_OBJ (self, Evas_Object, e, "Line");
+ GET_OBJ (self, Evas_Object, e);
Check_Type (x1, T_FIXNUM);
Check_Type (y1, T_FIXNUM);
/*
- * $Id: rb_polygon.c 23 2004-06-26 22:55:31Z tilman $
+ * $Id: rb_polygon.c 32 2004-07-10 14:07:49Z tilman $
*
* Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
*
VALUE self, argv[1];
Evas_Object **rect;
- if (!rb_obj_is_kind_of (evas, cEvas)) {
- rb_raise (rb_eTypeError,
- "wrong argument type %s (expected Evas)",
- rb_obj_classname (evas));
- return Qnil;
- }
-
- GET_OBJ (evas, Evas, e, "Evas");
+ CHECK_CLASS (evas, cEvas);
+ GET_OBJ (evas, Evas, e);
self = Data_Make_Struct (klass, Evas_Object *, c_evas_object_mark,
c_evas_object_free, rect);
static VALUE c_point_add (VALUE self, VALUE x, VALUE y)
{
- GET_OBJ (self, Evas_Object, e, "Polygon");
+ GET_OBJ (self, Evas_Object, e);
Check_Type (x, T_FIXNUM);
Check_Type (y, T_FIXNUM);
static VALUE c_points_clear (VALUE self)
{
- GET_OBJ (self, Evas_Object, e, "Polygon");
+ GET_OBJ (self, Evas_Object, e);
evas_object_polygon_points_clear (*e);
/*
- * $Id: rb_rectangle.c 23 2004-06-26 22:55:31Z tilman $
+ * $Id: rb_rectangle.c 32 2004-07-10 14:07:49Z tilman $
*
* Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
*
VALUE self, argv[1];
Evas_Object **rect;
- if (!rb_obj_is_kind_of (evas, cEvas)) {
- rb_raise (rb_eTypeError,
- "wrong argument type %s (expected Evas)",
- rb_obj_classname (evas));
- return Qnil;
- }
-
- GET_OBJ (evas, Evas, e, "Evas");
+ CHECK_CLASS(evas, cEvas);
+ GET_OBJ (evas, Evas, e);
self = Data_Make_Struct (klass, Evas_Object *, c_evas_object_mark,
c_evas_object_free, rect);
/*
- * $Id: rb_text.c 23 2004-06-26 22:55:31Z tilman $
+ * $Id: rb_text.c 32 2004-07-10 14:07:49Z tilman $
*
* Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
*
VALUE self, argv[1];
Evas_Object **rect;
- if (!rb_obj_is_kind_of (evas, cEvas)) {
- rb_raise (rb_eTypeError,
- "wrong argument type %s (expected Evas)",
- rb_obj_classname (evas));
- return Qnil;
- }
-
- GET_OBJ (evas, Evas, e, "Evas");
+ CHECK_CLASS(evas, cEvas);
+ GET_OBJ (evas, Evas, e);
self = Data_Make_Struct (klass, Evas_Object *, c_evas_object_mark,
c_evas_object_free, rect);
{
const char *tmp;
- GET_OBJ (self, Evas_Object, e, "Text");
+ GET_OBJ (self, Evas_Object, e);
if (!(tmp = evas_object_text_font_source_get (*e)))
return Qnil;
static VALUE c_font_source_set (VALUE self, VALUE val)
{
- GET_OBJ (self, Evas_Object, e, "Text");
+ GET_OBJ (self, Evas_Object, e);
Check_Type (val, T_STRING);
char *font = NULL;
Evas_Font_Size size = 0;
- GET_OBJ (self, Evas_Object, e, "Text");
+ GET_OBJ (self, Evas_Object, e);
evas_object_text_font_get (*e, &font, &size);
static VALUE c_set_font (VALUE self, VALUE font, VALUE size)
{
- GET_OBJ (self, Evas_Object, e, "Text");
+ GET_OBJ (self, Evas_Object, e);
Check_Type (font, T_STRING);
Check_Type (font, T_FIXNUM);
{
const char *tmp;
- GET_OBJ (self, Evas_Object, e, "Text");
+ GET_OBJ (self, Evas_Object, e);
if (!(tmp = evas_object_text_text_get (*e)))
return Qnil;
static VALUE c_text_set (VALUE self, VALUE val)
{
- GET_OBJ (self, Evas_Object, e, "Text");
+ GET_OBJ (self, Evas_Object, e);
Check_Type (val, T_STRING);