@strongify(self)解析
①通过
#define strongify(...) \try {} @finally {} \_Pragma("clang diagnostic push") \_Pragma("clang diagnostic ignored \"-Wshadow\"") \metamacro_foreach(rac_strongify_,, __VA_ARGS__) \_Pragma("clang diagnostic pop")
替换结果为:
@try {} @finally {}metamacro_foreach(rac_strongify_,, __VA_ARGS__)
②通过
#define metamacro_foreach(MACRO, SEP, ...) \metamacro_foreach_cxt(metamacro_foreach_iter, SEP, MACRO, __VA_ARGS__)
替换结果为:
@try {} @finally {}metamacro_foreach_cxt(metamacro_foreach_iter, , rac_strongify_, self)
③通过
#define metamacro_foreach_cxt(MACRO, SEP, CONTEXT, ...) \metamacro_concat(metamacro_foreach_cxt, metamacro_argcount(__VA_ARGS__))(MACRO, SEP, CONTEXT, __VA_ARGS__)
替换结果为:
@try {} @finally {}metamacro_concat(metamacro_foreach_cxt, metamacro_argcount(self))(metamacro_foreach_iter,, rac_strongify_, self)
【@strongify(self)解析】④通过
#define metamacro_argcount(...) \metamacro_at(20, __VA_ARGS__, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1)
//返回当前参数的个数
替换结果为:
@try {} @finally {}metamacro_concat(metamacro_foreach_cxt, 1)(metamacro_foreach_iter,, rac_strongify_, self)
⑤通过
#define metamacro_concat_(A, B) A ## B
替换结果为:
@try {} @finally {}metamacro_foreach_cxt1(metamacro_foreach_iter,, rac_strongify_, self)
⑥通过
#define metamacro_foreach_cxt1(MACRO, SEP, CONTEXT, _0) MACRO(0, CONTEXT, _0)
替换结果为:
@try {} @finally {}metamacro_foreach_iter(0,rac_strongify_, self)
⑦通过
#define metamacro_foreach_iter(INDEX, MACRO, ARG) MACRO(INDEX, ARG)
替换结果为:
@try {} @finally {}rac_strongify_(0,self)
⑧通过
#define rac_strongify_(INDEX, VAR) \__strong __typeof__(VAR) VAR = metamacro_concat(VAR, _weak_);
替换结果为:
@try {} @finally {}__strong __typeof__(self) self = self_weak_;
注:Xcode 分屏preprocess显示:
@try {} @finally {}
__attribute__((objc_ownership(strong))) __typeof__(self) self = self_weak_;
推荐阅读
- OneFlow源码解析(Op、Kernel与解释器)
- Golang|Golang map实践及实现原理解析
- WPF|【wpf】wpf中的那些模板之深度解析
- Go|Go 语言 json解析框架与 gjson 详解
- MySQL|MySQL Redo与Undo日志详细解析
- Java 并发编程解析 | 如何正确理解Java领域中的内存模型,主要是解决了什么问题()
- Java|【面试资料】 Java中高级核心面试知识解析
- ssm中使用kindedit|springboot项目中需要配置文件上传解析器吗_Spring Boot2 系列教程(一)纯 Java 搭建 SSM 项目...
- PrivacyIN隐私学院|PrivacyIN隐私学院 | 详尽解析ZK重要协议的设计理念
- PrivacyIN隐私学院|PrivacyIN隐私学院 | 解析零知识证明的基本密码学基础