Xcode-6.3 (6D1002): ObjC -- objc_enumerateClassList()

Originator:segiddins
Number:rdar://21404245 Date Originated:16-Jun-2015 10:24 AM
Status:Open Resolved:
Product:Developer Tools Product Version:Xcode-6.3 (6D1002)
Classification:Feature (New) Reproducible:Always
 
Summary:
There should be a way to enumerate the set of ObjC classes registered with the runtime without allocating lots of memory

Steps to Reproduce:
objc_copyClassList() and objc_getClassList() both require large buffers to obtain the class list

Expected Results:
There should be a function like the following:

void
objc_enumerateClassList(void (^enumerator)(Class cls))
{
    if (!enumerator) {
        return;
    }

    mutex_lock(&classLock);
    unsigned int count = class_hash ? NXCountHashTable(class_hash) : 0;

    if (count > 0) {
        Class cls;
        NXHashState state = NXInitHashState(class_hash);
        result = (Class *)malloc((1+count) * sizeof(Class));
        while (NXNextHashState(class_hash, &state, (void **)&cls)) {
            enumerator(cls)
        }
    }
    mutex_unlock(&classLock);
}


Actual Results:
No such function exists

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!