- klass = rb_hash_aref (event_classes, INT2NUM (type));
- if (NIL_P (klass))
- rb_raise (rb_eException, "Cannot find event class "
- "for event %i\n", type);
-
- /* now create and init the object */
- tmp = (VALUE) event;
- obj = rb_class_new_instance (1, &tmp, klass);
-
- len = RARRAY (handlers)->len;
-
- for (i = 0; i < len; i++) {
- handler = rb_ary_entry (handlers, i);
- handler_type = NUM2INT (rb_iv_get (handler, "@type"));
-
- if (handler_type == type) {
- Data_Get_Struct (handler, RbEventHandler, h);
- res = rb_funcall (h->callback, rb_intern ("call"), 1, obj);
-
- /* if the block returned false, don't call the other
- * event handlers
- */
- if (res == Qfalse)
- break;
- }
- }
-
- /* call other event handlers, too */
- return 1;