Skip to content

Instantly share code, notes, and snippets.

@vagase
Last active January 3, 2019 06:56
id c_objc_msgSend( struct objc_class /* ahem */ *self, SEL _cmd, ...)
{
struct objc_class *cls;
struct objc_cache *cache;
unsigned int hash;
struct objc_method *method;
unsigned int index;
if( self)
{
cls = self->isa;
cache = cls->cache;
hash = cache->mask;
index = (unsigned int) _cmd & hash;
do
{
method = cache->buckets[ index];
if( ! method)
goto recache;
index = (index + 1) & cache->mask;
}
while( method->method_name != _cmd);
return( (*method->method_imp)( (id) self, _cmd));
}
return( (id) self);
recache:
/*
* internal call _class_lookupMethodAndLoadCache to
* look method and load into cache
*/
return( 0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment