iOS method_t

2021-11-03  本文已影响0人  山杨
struct method_t {
    // "big" method传统意义上的方法(用selector、类型和实现的三指针结构体)
    struct big {
        SEL name;// 函数名
        const char *types;// 编码(返回值类型、参数类型)
        MethodListIMP imp;// 指向函数的指针
    };
private:
    // "small" method是用名称、类型和实现3个相对偏移指针
    struct small {
        // 名称字段指向一个selector(共享缓存中),或者指向一个selref(在其他地方)
        RelativePointer<const void *> name;
        RelativePointer<const char *> types;
        RelativePointer<IMP> imp;
        ...
    };

public:
    // 与方法列表一起使用的指针修饰符。当方法列表中包含小方法时,设置指针的底部位。
    // 我们在其他地方使用底部位来区分大方法和小方法。
    struct pointer_modifier {
        template <typename ListType>
        static method_t *modify(const ListType &list, method_t *ptr) {...}
    };
    ...
};
上一篇 下一篇

猜你喜欢

热点阅读