Example #1
0
/*
 * Returns an existing Ruby Proc for a given owning "object" and hook type.
 * Qnil will be returned if no Proc was associated with the owner
 */
static VALUE get_proc(void* owner, int hook) {
  if (owner == 0) return Qnil;
  {
	 VALUE owner_adress  = INT2NUM((long)(owner));
	 VALUE proc_hash     = get_proc_hash(hook);
	 VALUE proc          = rb_hash_aref(proc_hash, owner_adress);
	 return proc;
  }
}
Example #2
0
/*
 * Registers the Proc object with a given owner "object" and hook type.
 * If proc is Qnil, the hook is unregistered instead.
 */
static void reg_proc(void *owner, int hook, VALUE proc)
{
  if (owner == NULL) return;
  {
	 VALUE proc_hash      = get_proc_hash(hook);
	 VALUE owner_address  = INT2NUM((long)(owner));

	 if (proc == Qnil)
		rb_hash_delete(proc_hash, owner_address);
	 else
		rb_hash_aset(proc_hash, owner_address, proc);
  }
}