rb_funcall (self, id, 2, INT2FIX ((int) a), INT2FIX ((int) b)); \
}
-static ID id_smart_object;
+typedef struct {
+ Evas_Smart_Class smart_class;
+ Evas_Smart *smart;
+
+ VALUE name;
+} SmartData;
+
+static ID id_smart_data;
SMART_CB (delete);
SMART_CB (show);
static VALUE c_inherited (VALUE klass, VALUE child)
{
- rb_const_set (child, id_smart_object, Qnil);
+ rb_const_set (child, id_smart_data, Qnil);
return Qnil;
}
+static void
+c_data_mark (SmartData *sd)
+{
+ rb_gc_mark (sd->name);
+}
+
static VALUE c_init (VALUE self, VALUE evas)
{
- VALUE klass, smart, name;
- Evas_Smart **s = NULL;
+ VALUE klass, data;
+ SmartData *sd;
CHECK_CLASS (evas, cEvas);
GET_OBJ (evas, RbEvas, e);
klass = rb_obj_class (self);
/* check whether the smart object has been created already */
- smart = rb_const_get (klass, id_smart_object);
- if (!NIL_P (smart))
- Data_Get_Struct (smart, Evas_Smart *, s);
+ data = rb_const_get (klass, id_smart_data);
+ if (!NIL_P (data))
+ Data_Get_Struct (data, SmartData, sd);
else {
- name = rb_class_path (klass);
+ data = Data_Make_Struct (rb_cObject, SmartData,
+ c_data_mark, NULL, sd);
+
+ sd->name = rb_class_path (klass);
+
+ sd->smart_class.name = StringValuePtr (sd->name);
+ sd->smart_class.version = EVAS_SMART_CLASS_VERSION;
- smart = Data_Make_Struct (rb_cObject, Evas_Smart *, NULL, NULL, s);
+ sd->smart_class.add = NULL;
+ sd->smart_class.del = smart_delete;
+ sd->smart_class.move = smart_move;
+ sd->smart_class.resize = smart_resize;
+ sd->smart_class.show = smart_show;
+ sd->smart_class.hide = smart_hide;
+ sd->smart_class.color_set = smart_color_set;
+ sd->smart_class.clip_set = smart_clip_set;
+ sd->smart_class.clip_unset = smart_clip_unset;
- *s = evas_smart_new (StringValuePtr (name),
- NULL, smart_delete, NULL,
- NULL, NULL, NULL, NULL,
- smart_move, smart_resize,
- smart_show, smart_hide,
- smart_color_set,
- smart_clip_set, smart_clip_unset,
- NULL);
+ sd->smart = evas_smart_class_new (&sd->smart_class);
- rb_mod_remove_const(klass, ID2SYM (id_smart_object));
- rb_const_set (klass, id_smart_object, smart);
+ rb_mod_remove_const (klass, ID2SYM (id_smart_data));
+ rb_const_set (klass, id_smart_data, data);
}
- s2->real = evas_object_smart_add (e->real, *s);
+ s2->real = evas_object_smart_add (e->real, sd->smart);
rb_call_super (1, &evas);
rb_define_method (c, "initialize", c_init, 1);
rb_define_method (c, "add_member", c_add_member, 1);
- id_smart_object = rb_intern ("SMART_OBJECT");
+ id_smart_data = rb_intern ("SMART_DATA");
}