/*
- * $Id: rb_evas_object_events.c 306 2005-03-23 17:29:37Z tilman $
+ * $Id: rb_evas_object_events.c 315 2005-04-07 18:27:26Z tilman $
*
* Copyright (C) 2005 Tilman Sauerbeck (tilman at code-monkey de)
*
#define CALLBACK_REGISTER2(name) \
rb_define_method (cEvasObject, "on_"#name, c_on_##name, 0);
+#define TO_STR(s) \
+ (s) ? rb_str_new2 ((s)) : Qnil
+
static VALUE event_classes, cPos;
static VALUE c_ev_mouse_in_init (VALUE self, VALUE ev)
{
Evas_Event_Key_Down *e = (Evas_Event_Key_Down *) ev;
- rb_iv_set (self, "@keyname", rb_str_new2 (e->keyname));
- rb_iv_set (self, "@key", rb_str_new2 (e->key));
- rb_iv_set (self, "@string", rb_str_new2 (e->string));
- rb_iv_set (self, "@compose", rb_str_new2 (e->compose));
+ rb_iv_set (self, "@keyname", TO_STR (e->keyname));
+ rb_iv_set (self, "@key", TO_STR (e->key));
+ rb_iv_set (self, "@string", TO_STR (e->string));
+ rb_iv_set (self, "@compose", TO_STR (e->compose));
return self;
}
{
Evas_Event_Key_Up *e = (Evas_Event_Key_Up *) ev;
- rb_iv_set (self, "@keyname", rb_str_new2 (e->keyname));
- rb_iv_set (self, "@key", rb_str_new2 (e->key));
- rb_iv_set (self, "@string", rb_str_new2 (e->string));
- rb_iv_set (self, "@compose", rb_str_new2 (e->compose));
+ rb_iv_set (self, "@keyname", TO_STR (e->keyname));
+ rb_iv_set (self, "@key", TO_STR (e->key));
+ rb_iv_set (self, "@string", TO_STR (e->string));
+ rb_iv_set (self, "@compose", TO_STR (e->compose));
return self;
}