Skip to content

Commit 6e71801

Browse files
committed
Rename _PointerParam to _SwiftifyInfo
1 parent fa5fbfa commit 6e71801

File tree

5 files changed

+13
-9
lines changed

5 files changed

+13
-9
lines changed

lib/Macros/Sources/SwiftMacros/SwiftifyImportMacro.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ public struct SwiftifyImportMacro: PeerMacro {
466466
guard let calledExpr = enumConstructorExpr.calledExpression.as(MemberAccessExprSyntax.self)
467467
else {
468468
throw DiagnosticError(
469-
"expected _PointerParam enum literal as argument, got '\(enumConstructorExpr)'",
469+
"expected _SwiftifyInfo enum literal as argument, got '\(enumConstructorExpr)'",
470470
node: enumConstructorExpr)
471471
}
472472
return calledExpr.declName.baseName.text
@@ -564,7 +564,7 @@ public struct SwiftifyImportMacro: PeerMacro {
564564
let paramExpr = paramAST.expression
565565
guard let enumConstructorExpr = paramExpr.as(FunctionCallExprSyntax.self) else {
566566
throw DiagnosticError(
567-
"expected _PointerParam enum literal as argument, got '\(paramExpr)'", node: paramExpr)
567+
"expected _SwiftifyInfo enum literal as argument, got '\(paramExpr)'", node: paramExpr)
568568
}
569569
let enumName = try parseEnumName(enumConstructorExpr)
570570
switch enumName {
@@ -627,7 +627,7 @@ public struct SwiftifyImportMacro: PeerMacro {
627627
}
628628
if argByIndex[i] != nil {
629629
throw DiagnosticError(
630-
"multiple _PointerParams referring to parameter with index "
630+
"multiple _SwiftifyInfos referring to parameter with index "
631631
+ "\(i): \(pointerArg) and \(argByIndex[i]!)", node: pointerArg.original)
632632
}
633633
argByIndex[i] = pointerArg

stdlib/public/core/SwiftifyImport.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
/// __must__ be string literals, because their contents are parsed by the `@_SwiftifyImport` macro.
44
/// Only 1 instance of `countedBy`, `sizedBy` or `endedBy` can refer to each pointer index, however
55
/// `nonescaping` is orthogonal to the rest and can (and should) overlap with other annotations.
6-
public enum _PointerParam {
6+
///
7+
/// This is not marked @available, because _SwiftifyImport is available for any target. Instances
8+
/// of _SwiftifyInfo should ONLY be passed as arguments directly to _SwiftifyImport, so they should
9+
/// not affect linkage since there are never any instances at runtime.
10+
public enum _SwiftifyInfo {
711
/// Corresponds to the C `__counted_by(count)` attribute.
812
/// Parameter pointer: index of pointer in function parameter list. Must be of type
913
/// `Unsafe[Mutable]Pointer<T>[?]`, i.e. not an `UnsafeRawPointer`.
@@ -40,5 +44,5 @@ public enum _PointerParam {
4044
/// Parameter paramInfo: information about how the function uses the pointer passed to it. The
4145
/// safety of the generated wrapper function depends on this info being extensive and accurate.
4246
@attached(peer, names: overloaded)
43-
public macro _SwiftifyImport(_ paramInfo: _PointerParam...) =
47+
public macro _SwiftifyImport(_ paramInfo: _SwiftifyInfo...) =
4448
#externalMacro(module: "SwiftMacros", type: "SwiftifyImportMacro")

test/Macros/SwiftifyImport/MacroErrors/DynamicEnum.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
// RUN: %target-typecheck-verify-swift %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -verify
44

5-
let countedBy = _PointerParam.countedBy(pointer: 1, count: "len")
6-
// expected-error@+1{{expected _PointerParam enum literal as argument, got 'countedBy'}}
5+
let countedBy = _SwiftifyInfo.countedBy(pointer: 1, count: "len")
6+
// expected-error@+1{{expected _SwiftifyInfo enum literal as argument, got 'countedBy'}}
77
@_SwiftifyImport(countedBy)
88
func myFunc(_ ptr: UnsafePointer<CInt>, _ len: String) {
99
}

test/Macros/SwiftifyImport/MacroErrors/SamePointer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// RUN: %target-typecheck-verify-swift %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir
44

5-
// expected-error@+1{{multiple _PointerParams referring to parameter with index 1: .countedBy(pointer: 1, count: "dummy", nonescaping: false) and .countedBy(pointer: 1, count: "len", nonescaping: false)}}
5+
// expected-error@+1{{multiple _SwiftifyInfos referring to parameter with index 1: .countedBy(pointer: 1, count: "dummy", nonescaping: false) and .countedBy(pointer: 1, count: "len", nonescaping: false)}}
66
@_SwiftifyImport(.countedBy(pointer: 1, count: "len"), .countedBy(pointer: 1, count: "dummy"))
77
func myFunc(_ ptr: UnsafePointer<CInt>, _ len: CInt, _ dummy: CInt) {
88
}

test/api-digester/stability-stdlib-abi-without-asserts.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -822,5 +822,5 @@ Func _SliceBuffer.withUnsafeMutableBufferPointer(_:) has mangled name changing f
822822

823823
Struct String.Index has added a conformance to an existing protocol CustomDebugStringConvertible
824824

825-
Enum _PointerParam is a new API without @available attribute
825+
Enum _SwiftifyInfo is a new API without @available attribute
826826
// *** DO NOT DISABLE OR XFAIL THIS TEST. *** (See comment above.)

0 commit comments

Comments
 (0)