Comments (3)
clang -rewrite-objc
这个操作转换的代码和实际上编译出来的结果是有出入的(之前我在调试的时候有个很明显的例子,但是我现在忘了🤤),单步调试就可以发现会进入 objc_initWeak
函数。
__attribute__((objc_ownership(weak)))
就是 __weak
预处理后的结果,当然还会有 __strong
的那些,同样的道理。
from ios-source-probe.
原文表述确实有些问题,不能说是 Clang 对于代码的转换。感谢提出。
在 Clang 的官方文档中有以下描述:
If value is a null pointer or the object to which it points has begun deallocation, object is zero-initialized. Otherwise, object is registered as a
__weak
object pointing to value. Equivalent to the following code:
id objc_initWeak(id *object, id value) {
*addr = 0;
if (!val) return nil;
return objc_storeWeak(object, value);
}
objc_initWeak
作为 __weak
对象的初始化入口,也是 __weak
对象生命周期的第一过程。严格意义上来说只能是 Clang 对于 __weak
对象初始化的动作,说转换确实有些不太恰当。
objc_ownership
这个方法之前在 RAC 的源码中看见过,是 @weakify
和 @strongify
宏展开后调用的方法。没有看到过它的实现,但是从行为上来看应该是用来描述两个对象间的持有关系(从 Ownership 这个命名也能看出来..😂)。
最后还是多谢勘误。
from ios-source-probe.
楼上所有的应该是Block的内存布局吧。block_impl结构体内的函数指针是FuncPtr *fn。但是查看clang关于block的描述,其实应该是void (*invoke)(void *, ...);具体见这里
from ios-source-probe.
Related Issues (8)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ios-source-probe.