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; }
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); }
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); } }
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); }
PRIMITIVE VALUE vm_ocval_to_rval(void *ocval) { return OC2RB(ocval); }
static void rb_set_each_callback(const void *value, void *context) { rb_yield((VALUE)OC2RB(value)); }
static void imp_rhash_removeObjectForKey(void *rcv, SEL sel, void *key) { VALUE rkey = OC2RB(key); st_delete(RHASH(rcv)->tbl, &rkey, NULL); }
static void imp_rhash_setObjectForKey(void *rcv, SEL sel, void *val, void *key) { st_insert(RHASH(rcv)->tbl, OC2RB(key), OC2RB(val)); }