Skip to content

Commit dea554d

Browse files
committed
wip: convention
1 parent afa0e5e commit dea554d

File tree

1 file changed

+19
-23
lines changed

1 file changed

+19
-23
lines changed

swift-6-beta.docc/ReferenceManual/Attributes.md

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2435,37 +2435,33 @@ Swift 提供了以下 Interface Builder 特性:
24352435

24362436
### convention
24372437

2438-
Apply this attribute to the type of a function
2439-
to indicate its calling conventions.
2438+
将此特性应用于函数的类型,以指示其调用约定。
24402439

2441-
The `convention` attribute always appears with
2442-
one of the following arguments:
2440+
`convention` 特性总是与以下参数之一一起出现:
24432441

2444-
- The `swift` argument indicates a Swift function reference.
2445-
This is the standard calling convention for function values in Swift.
2446-
- The `block` argument indicates an Objective-C compatible block reference.
2447-
The function value is represented as a reference to the block object,
2448-
which is an `id`-compatible Objective-C object that embeds its invocation
2449-
function within the object.
2450-
The invocation function uses the C calling convention.
2451-
- The `c` argument indicates a C function reference.
2452-
The function value carries no context and uses the C calling convention.
2442+
- `swift` 参数表示一个 Swift 函数引用。这是 Swift 中函数值的标准调用约定。
2443+
- `block` 参数表示一个与 Objective-C 兼容的块引用。
2444+
函数值表示为对块对象的引用,
2445+
该对象是一个 `id` 类型兼容的 Objective-C 对象,
2446+
嵌入了其调用函数。
2447+
调用函数使用 C 调用约定。
2448+
- `c` 参数表示一个 C 函数引用。函数值不携带上下文,并使用 C 调用约定。
24532449

24542450
<!--
24552451
Note: @convention(thin) is private, even though it doesn't have an underscore
24562452
https://forums.swift.org/t/12087/6
24572453
-->
24582454

2459-
With a few exceptions,
2460-
a function of any calling convention can be used
2461-
when a function any other calling convention is needed.
2462-
A nongeneric global function,
2463-
a local function that doesn't capture any local variables,
2464-
or a closure that doesn't capture any local variables
2465-
can be converted to the C calling convention.
2466-
Other Swift functions can't be converted to the C calling convention.
2467-
A function with the Objective-C block calling convention
2468-
can't be converted to the C calling convention.
2455+
除了少数例外,
2456+
任何调用约定的函数都
2457+
可以在需要其他调用约定的函数时使用。
2458+
一个非泛型的全局函数、
2459+
一个不捕获任何局部变量的局部函数,
2460+
或者一个不捕获任何局部变量的闭包
2461+
可以转换为 C 调用约定。
2462+
其他 Swift 函数无法转换为 C 调用约定。
2463+
具有 Objective-C 块调用约定的函数
2464+
无法转换为 C 调用约定。
24692465

24702466
### escaping
24712467

0 commit comments

Comments
 (0)