-
Notifications
You must be signed in to change notification settings - Fork 0
/
dmd.objc-improvements.dd
38 lines (29 loc) · 1.35 KB
/
dmd.objc-improvements.dd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
Objective-C selectors are now automatically generated when not specified with @selector.
Additionally, the Objective-C selector generation rules have changed, following these steps:
1. Functions marked with @property will generate `setXYZ:` for the setters.
2. For property functions named with a "is" prefix, the `is` will be stripped off in the setter.
3. Selector generation now uses the names of the function parameters instead of their D mangled types.
Selectors may still be specified with the @selector UDA, in which case it takes precedence over the
automatically generated selectors.
These new rules apply both for extern and non-extern objective-c classes and protocols.
---
extern(Objective-C)
extern class NSObject {
static NSObject alloc(); // Generates as `alloc`
NSObject init(); // Generates as `init`
}
extern(Objective-C)
class Fox : NSObject {
bool fluffy;
@property bool isFluffy() => fluffy; // `isFluffy`
@property void isFluffy(bool value) { fluffy = value; } // `setFluffy:`
void yip(int a) @selector("bark:") { // `bark:`
// ...
}
void doSomething(int a, int b, int c) { // `doSomething:b:c:`
// ...
}
}
---
These changes should not break any existing code as the automatic selector generation
was not present before. And automatic selector generation only applies to extern(Objective-C) methods.