| 1 |
typedef __SIZE_TYPE__ size_t; |
| 2 |
typedef const struct objc_selector |
| 3 |
{ |
| 4 |
void *sel_id; |
| 5 |
} |
| 6 |
*SEL; |
| 7 |
typedef struct objc_object |
| 8 |
{ |
| 9 |
} |
| 10 |
*id; |
| 11 |
typedef struct objc_class *Class; |
| 12 |
struct objc_class |
| 13 |
{ |
| 14 |
struct sarray *dtable; |
| 15 |
}; |
| 16 |
typedef size_t sidx; |
| 17 |
struct soffset |
| 18 |
{ |
| 19 |
unsigned int boffset:(sizeof (size_t) * 8) / 2; |
| 20 |
unsigned int eoffset:(sizeof (size_t) * 8) / 2; |
| 21 |
}; |
| 22 |
union sofftype |
| 23 |
{ |
| 24 |
struct soffset off; |
| 25 |
sidx idx; |
| 26 |
}; |
| 27 |
struct sarray |
| 28 |
{ |
| 29 |
size_t capacity; |
| 30 |
}; |
| 31 |
static __inline__ unsigned int |
| 32 |
soffset_decode (sidx indx) |
| 33 |
{ |
| 34 |
union sofftype x; |
| 35 |
x.idx = indx; |
| 36 |
return x.off.eoffset + (x.off.boffset * (1 << 5)); |
| 37 |
} |
| 38 |
void *sarray_get (struct sarray *array, sidx indx); |
| 39 |
static __inline__ void * |
| 40 |
sarray_get_safe (struct sarray *array, sidx indx) |
| 41 |
{ |
| 42 |
if (soffset_decode (indx) < array->capacity) |
| 43 |
return (void *)sarray_get (array, indx); |
| 44 |
} |
| 45 |
void * |
| 46 |
get_imp (Class class, SEL sel) |
| 47 |
{ |
| 48 |
void *res = sarray_get_safe (class->dtable, (size_t) sel->sel_id); |
| 49 |
if (res == 0) |
| 50 |
{ |
| 51 |
{ |
| 52 |
res = get_imp (class, sel); |
| 53 |
} |
| 54 |
} |
| 55 |
} |