static VALUE classname(VALUE klass) { VALUE path = Qnil; if (klass == 0) { klass = rb_cObject; } CFMutableDictionaryRef iv_dict = rb_class_ivar_dict(klass); if (iv_dict != NULL) { if (!CFDictionaryGetValueIfPresent((CFDictionaryRef)iv_dict, (const void *)id_classpath, (const void **)&path)) { if (!CFDictionaryGetValueIfPresent((CFDictionaryRef)iv_dict, (const void *)id_classid, (const void **)&path)) { return find_class_path(klass); } path = rb_str_dup(path); OBJ_FREEZE(path); CFDictionarySetValue(iv_dict, (const void *)id_classpath, (const void *)path); CFDictionaryRemoveValue(iv_dict, (const void *)id_classid); } if (TYPE(path) != T_STRING) { rb_bug("class path is not set properly"); } return path; } return find_class_path(klass); }
static VALUE classname(VALUE klass) { VALUE path = Qnil; st_data_t n; if (!klass) klass = rb_cObject; if (RCLASS_IV_TBL(klass)) { if (!st_lookup(RCLASS_IV_TBL(klass), (st_data_t)classpath, &n)) { if (!st_lookup(RCLASS_IV_TBL(klass), (st_data_t)classid, &n)) { return find_class_path(klass); } path = rb_str_dup(rb_id2str(SYM2ID((VALUE)n))); OBJ_FREEZE(path); st_insert(RCLASS_IV_TBL(klass), (st_data_t)classpath, (st_data_t)path); n = classid; st_delete(RCLASS_IV_TBL(klass), &n, 0); } else { path = (VALUE)n; } if (TYPE(path) != T_STRING) { rb_bug("class path is not set properly"); } return path; } return find_class_path(klass); }