Example #1
0
File: class.c Project: MSch/MacRuby
static BOOL
rb_obj_imp_isEqual(void *rcv, SEL sel, void *obj)
{
    if (obj == NULL) {
	return false;
    }
    VALUE arg = OC2RB(obj);
    return rb_vm_call((VALUE)rcv, selEq, 1, &arg) == Qtrue;
}
Example #2
0
static void *
imp_rhash_objectForKey(void *rcv, SEL sel, void *key)
{
    VALUE val;
    if (!st_lookup(RHASH(rcv)->tbl, OC2RB(key), &val)) {
	return NULL;
    }
    return RB2OC(val);
}
Example #3
0
static void
rb_set_delete_if_callback(const void *value, void *context)
{
    VALUE set = ((VALUE *)context)[0];
    VALUE *acted = ((VALUE **)context)[1];
    if (rb_yield(OC2RB(value)) == Qtrue) {
	*acted = Qtrue;
	rb_set_delete(set, 0, (VALUE)value);
    }
}
Example #4
0
File: class.c Project: MSch/MacRuby
static void *
rb_obj_imp_description(void *rcv, SEL sel)
{
    // If #description and #to_s are the same method (ex. when aliased)
    Class rcv_class = (Class)CLASS_OF(rcv);
    IMP desc_imp = class_getMethodImplementation(rcv_class, selDescription);
    IMP to_s_imp = class_getMethodImplementation(rcv_class, selToS);
    if (desc_imp == to_s_imp) {
	return (void *)rb_any_to_string((VALUE)rcv, sel);
    }
    return (void *)rb_vm_call(OC2RB(rcv), selToS, 0, NULL);
}
Example #5
0
PRIMITIVE VALUE
vm_ocval_to_rval(void *ocval)
{
    return OC2RB(ocval);
}
Example #6
0
static void
rb_set_each_callback(const void *value, void *context)
{
    rb_yield((VALUE)OC2RB(value));
}
Example #7
0
static void
imp_rhash_removeObjectForKey(void *rcv, SEL sel, void *key)
{
    VALUE rkey = OC2RB(key);
    st_delete(RHASH(rcv)->tbl, &rkey, NULL);
}
Example #8
0
static void
imp_rhash_setObjectForKey(void *rcv, SEL sel, void *val, void *key)
{
    st_insert(RHASH(rcv)->tbl, OC2RB(key), OC2RB(val));
}