Skip to content

Instantly share code, notes, and snippets.

@phausler
Created September 27, 2013 07:21
Show Gist options
  • Save phausler/6725188 to your computer and use it in GitHub Desktop.
Save phausler/6725188 to your computer and use it in GitHub Desktop.
just because...
#import <objc/message.h>
typedef struct class_t {
struct class_t *isa;
struct class_t *superclass;
void *cache;
IMP *vtable;
uintptr_t data_NEVER_USE;
} class_t;
typedef struct class_ro_t {
uint32_t flags;
uint32_t instanceStart;
uint32_t instanceSize;
const uint8_t * ivarLayout;
const char * name;
const void * baseMethods;
const void * baseProtocols;
const void * ivars;
const uint8_t * weakIvarLayout;
const void *baseProperties;
} class_ro_t;
typedef struct {
SEL name;
void *unused;
IMP imp;
} cache_entry;
struct objc_cache {
uintptr_t mask;
uintptr_t occupied;
cache_entry *buckets[1];
};
extern class_t OBJC_METACLASS_$_NSObject;
extern class_t OBJC_CLASS_$_NSObject;
static struct objc_cache objc_empty_cache_s = {
0,
0,
{ NULL }
};
static IMP objc_empty_vtable_s[] = {
(IMP)&objc_msgSend
};
class_ro_t OBJC_METACLASS_RO_$_Foo = {
1, sizeof(class_t), sizeof(class_t),
0,
"Foo",
0,
0,
0,
0,
0,
};
class_ro_t OBJC_CLASS_RO_$_Foo = {
1, sizeof(class_t), sizeof(class_t),
0,
"Foo",
0,
0,
0,
0,
0,
};
class_t OBJC_METACLASS_$_Foo = {
&OBJC_METACLASS_$_NSObject,
&OBJC_METACLASS_$_NSObject,
&objc_empty_cache_s,
&objc_empty_vtable_s,
&OBJC_METACLASS_RO_$_Foo,
};
class_t OBJC_CLASS_$_Foo = {
&OBJC_METACLASS_$_Foo,
&OBJC_CLASS_$_NSObject,
&objc_empty_cache_s,
&objc_empty_vtable_s,
&OBJC_CLASS_RO_$_Foo
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment