@@ -2435,37 +2435,33 @@ Swift 提供了以下 Interface Builder 特性:
2435
2435
2436
2436
### convention
2437
2437
2438
- Apply this attribute to the type of a function
2439
- to indicate its calling conventions.
2438
+ 将此特性应用于函数的类型,以指示其调用约定。
2440
2439
2441
- The ` convention ` attribute always appears with
2442
- one of the following arguments:
2440
+ ` convention ` 特性总是与以下参数之一一起出现:
2443
2441
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 调用约定。
2453
2449
2454
2450
<!--
2455
2451
Note: @convention(thin) is private, even though it doesn't have an underscore
2456
2452
https://forums.swift.org/t/12087/6
2457
2453
-->
2458
2454
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 调用约定。
2469
2465
2470
2466
### escaping
2471
2467
0 commit comments