Skip to content

Commit 857df29

Browse files
committed
Merge pull request #2434 from milseman/coregraphics
[CoreGraphics Renaming] Overhaul CG apinotes
2 parents 0883a96 + 8c65ef2 commit 857df29

File tree

8 files changed

+228
-53
lines changed

8 files changed

+228
-53
lines changed

apinotes/CoreGraphics.apinotes

Lines changed: 197 additions & 39 deletions
Large diffs are not rendered by default.

lib/ClangImporter/IAMInference.cpp

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ IAMOptions IAMOptions::getDefault() { return {}; }
8989
// As append, but skip a repeated word at the boundary. First-letter-case
9090
// insensitive.
9191
// Example: appendUniq("FooBar", "barBaz") ==> "FooBarBaz"
92-
void appendUniq(NameBuffer &src, StringRef toAppend) {
92+
static void appendUniq(NameBuffer &src, StringRef toAppend) {
9393
if (src.empty()) {
9494
src = toAppend;
9595
return;
@@ -103,7 +103,7 @@ void appendUniq(NameBuffer &src, StringRef toAppend) {
103103
src.append(wI.getRestOfStr());
104104
}
105105

106-
StringRef skipLeadingUnderscores(StringRef str) {
106+
static StringRef skipLeadingUnderscores(StringRef str) {
107107
while (!str.empty() && str.startswith("_"))
108108
str = str.drop_front(1);
109109
return str;
@@ -221,14 +221,31 @@ class IAMInference {
221221
EffectiveClangContext effectiveDC) {
222222
++SuccessImportAsConstructor;
223223
NameBuffer buf;
224+
StringRef prefix = buf;
224225
if (name != initSpecifier) {
225226
assert(name.size() > initSpecifier.size() &&
226227
"should have more words in it");
227-
auto didDrop = dropWordUniq(name, initSpecifier, buf);
228+
bool didDrop = dropWordUniq(name, initSpecifier, buf);
228229
(void)didDrop;
230+
prefix = buf;
231+
232+
// Skip "with"
233+
auto prefixWords = camel_case::getWords(prefix);
234+
if (prefixWords.begin() != prefixWords.end() &&
235+
(*prefixWords.begin() == "With" || *prefixWords.begin() == "with")) {
236+
prefix = prefix.drop_front(4);
237+
}
238+
239+
// Skip "CF" or "NS"
240+
prefixWords = camel_case::getWords(prefix);
241+
if (prefixWords.begin() != prefixWords.end() &&
242+
(*prefixWords.begin() == "CF" || *prefixWords.begin() == "NS")) {
243+
prefix = prefix.drop_front(2);
244+
}
245+
229246
assert(didDrop != 0 && "specifier not present?");
230247
}
231-
return {formDeclName("init", params, buf), effectiveDC};
248+
return {formDeclName("init", params, prefix), effectiveDC};
232249
}
233250

234251
// Instance computed property

test/IDE/infer_import_as_member.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ let mine = IAMStruct1()
8383
// PRINT-NEXT: }
8484
// PRINT-NEXT: extension IAMMutableStruct1 {
8585
// PRINT-NEXT: init(with withIAMStruct1: IAMStruct1)
86-
// PRINT-NEXT: init(withURL url: UnsafePointer<Int8>!)
86+
// PRINT-NEXT: init(url url: UnsafePointer<Int8>!)
8787
// PRINT-NEXT: func doSomething()
8888
// PRINT-NEXT: }
8989
//
@@ -93,7 +93,7 @@ let mine = IAMStruct1()
9393
// PRINT-NEXT: init(x x: Double)
9494
// PRINT-NEXT: }
9595
// PRINT-NEXT: extension TDStruct {
96-
// PRINT-NEXT: init(with Float: Float)
96+
// PRINT-NEXT: init(float Float: Float)
9797
// PRINT-NEXT: }
9898
//
9999
// PRINT-LABEL: /// Class

test/Interpreter/SDK/CALayer.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ func hangCanary(_ o: AnyObject) {
2222

2323
class FooLayer: CALayer {
2424
var black: CGColor
25-
var white: CGColor = CGColor.constantColorForName(CGColor.white)!
25+
var white: CGColor = CGColor.constantColor(for: CGColor.white)!
2626

2727
override init() {
28-
black = CGColor.constantColorForName(CGColor.black)!
28+
black = CGColor.constantColor(for: CGColor.black)!
2929
super.init()
3030
hangCanary(self)
3131
}

test/Interpreter/SDK/CGImportAsMember.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ import CoreGraphics
77

88
class Colors {
99
// TODO: when issue is fixed, migrate these to CGColor class properties
10-
static var black = CGColor.constantColorForName(CGColor.black)!
11-
static var white = CGColor.constantColorForName(CGColor.white)!
10+
static var black = CGColor.constantColor(for: CGColor.black)!
11+
static var white = CGColor.constantColor(for: CGColor.white)!
1212

1313
// FIXME: this triggers an assert in SILVerifier
14-
static var clear = CGColor.constantColorForName(CGColor.clear)!
14+
static var clear = CGColor.constantColor(for: CGColor.clear)!
1515

1616
class func printColors() {
1717
print("Colors") // CHECK: Colors

test/Interpreter/SDK/c_pointers.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ typealias XXColor = UIColor
2323
//
2424

2525
let rgb = CGColorSpaceCreateDeviceRGB()
26-
let cgRed = CGColor(withColorSpace: rgb, components: [1.0, 0.0, 0.0, 1.0])!
26+
let cgRed = CGColor(colorSpace: rgb, components: [1.0, 0.0, 0.0, 1.0])!
2727

2828
let nsRed = XXColor(cgColor: cgRed)
2929

test/Interpreter/SDK/cf_extensions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ extension CGColorSpace {
2222
extension CGColor {
2323
class func create(colorSpace colorSpace: CGColorSpace, components: [CGFloat])
2424
-> CGColor {
25-
return CGColor(withColorSpace: colorSpace, components: components)!
25+
return CGColor(colorSpace: colorSpace, components: components)!
2626
}
2727

2828
var r: CGFloat { return components![0] }

test/Interpreter/SDK/cf_type_bridging.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import UIKit
1111
#endif
1212

1313
let foo: [CGColor] =
14-
[CGColor(withColorSpace: CGColorSpaceCreateDeviceRGB(),
14+
[CGColor(colorSpace: CGColorSpaceCreateDeviceRGB(),
1515
components: [1.0, 0.0, 0.0, 1.0])!]
1616

1717
let bar = foo as NSArray

0 commit comments

Comments
 (0)