Start documenting the Objective-C ABI#7923
Conversation
|
Thanks for your pull request and interest in making D better, @jacob-carlborg! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. |
|
@JinShil @ibuclaw @WalterBright @wilzbach @UplinkCoder please have a look. |
JinShil
left a comment
There was a problem hiding this comment.
I can't say I understand all of this, but if I were maintaining the Objective-C features of DMD, I think it would come in handy. My review is mostly just a bunch of nits.
docs/objective-c_abi.md
Outdated
| from implementation stand point is that in D and C++ a vtable is used which | ||
| is an array of function pointers and the compiler uses an index into that array | ||
| to determine which method to call. In Objective-C it's the runtime that is | ||
| responsible to find the correct implementation when a message is sent to an |
| int result = objc_msgSend(receiver, selector); | ||
| ``` | ||
|
|
||
| If the method expects any arguments they're passed after the selector argument: |
There was a problem hiding this comment.
But arguments is plural?
There was a problem hiding this comment.
Sorry, I don't know what I was thinking. Just ignore anything stupid in my comments.
docs/objective-c_abi.md
Outdated
| id objc_msgSend(id self, SEL op, ...); | ||
| ``` | ||
|
|
||
| * The first parameter is the receiver (this/self pointer) |
There was a problem hiding this comment.
should "this" and "self" be surrounded by tick marks?
docs/objective-c_abi.md
Outdated
|
|
||
| The call to `objc_msgSend` should not be performed as a variadic call but | ||
| instead as if it had the same signature as the method that should be called but | ||
| with the two additional parameter, `self` and `op`, added first. The |
There was a problem hiding this comment.
That first sentence is a little hard to follow. Maybe it can be rephrased.
There was a problem hiding this comment.
I changed it slightly, but I'm not sure if it's any better. Writing is not my strongest skill. Suggestions are welcome.
docs/objective-c_abi.md
Outdated
| implementation of `objc_msgSend` will jump to the method instead of calling it. | ||
|
|
||
| Because of the above, multiple versions of `objc_msgSend` exist. Depending on | ||
| the return type of the method that is called the correct version need to be |
There was a problem hiding this comment.
comma after "called".
s/the correct version need to be used/the correct version will be used
|
|
||
| For each selector that is used, a symbol is generated in the resulting binary. | ||
| The symbol has the name `L_OBJC_METH_VAR_NAME_.<number>`, where `<number>` is an | ||
| incrementing number. The selector is stored as a null terminated C string as the |
There was a problem hiding this comment.
s/as the section data/in the data section?
There was a problem hiding this comment.
Not sure how to best describe it but the data stored in this section is the selector.
docs/objective-c_abi.md
Outdated
| For each externally defined class that is referenced, a symbol is generated in | ||
| the resulting binary. The symbol has the name | ||
| `L_OBJC_CLASSLIST_REFERENCES_$_.<number>`, where `<number>` is an incrementing | ||
| number. The content of the symbols is a reference to an externally defined |
There was a problem hiding this comment.
Should "symbols" be singular here?
docs/objective-c_abi.md
Outdated
|
|
||
| ### `L_OBJC_IMAGE_INFO` | ||
|
|
||
| For any binary that is built the `L_OBJC_IMAGE_INFO` symbols is generated. The |
docs/objective-c_abi.md
Outdated
|
|
||
| Indicates if features like: garbage collector, automatic reference counting | ||
| (ARC) or class properties are supported. These features can be enabled/disabled | ||
| in the Clang compiler using command line switches. The exact values used or the |
There was a problem hiding this comment.
comma after "used" and "supported"?
docs/objective-c_abi.md
Outdated
|
|
||
| ## Tools | ||
|
|
||
| Here follows a list of useful tools that can/has been used to get the |
This does not include the complete ABI, only what's necessary to call instance methods and class methods. This document will be extended when additional features are added.
a896506 to
696f41b
Compare
|
Fixed all comments, except two, where I asked for more input. |
This does not include the complete ABI, only what's necessary to call instance methods and class methods. This document will be extended when additional features are added.