@@ -185,6 +185,56 @@ public struct ArgumentTypeArray : RandomAccessCollection, FormattedLikeArray {
185185 }
186186}
187187
188+ public enum ArgumentConvention {
189+ /// This argument is passed indirectly, i.e. by directly passing the address
190+ /// of an object in memory. The callee is responsible for destroying the
191+ /// object. The callee may assume that the address does not alias any valid
192+ /// object.
193+ case indirectIn
194+
195+ /// This argument is passed indirectly, i.e. by directly passing the address
196+ /// of an object in memory. The callee must treat the object as read-only
197+ /// The callee may assume that the address does not alias any valid object.
198+ case indirectInConstant
199+
200+ /// This argument is passed indirectly, i.e. by directly passing the address
201+ /// of an object in memory. The callee may not modify and does not destroy
202+ /// the object.
203+ case indirectInGuaranteed
204+
205+ /// This argument is passed indirectly, i.e. by directly passing the address
206+ /// of an object in memory. The object is always valid, but the callee may
207+ /// assume that the address does not alias any valid object and reorder loads
208+ /// stores to the parameter as long as the whole object remains valid. Invalid
209+ /// single-threaded aliasing may produce inconsistent results, but should
210+ /// remain memory safe.
211+ case indirectInout
212+
213+ /// This argument is passed indirectly, i.e. by directly passing the address
214+ /// of an object in memory. The object is allowed to be aliased by other
215+ /// well-typed references, but is not allowed to be escaped. This is the
216+ /// convention used by mutable captures in @noescape closures.
217+ case indirectInoutAliasable
218+
219+ /// This argument represents an indirect return value address. The callee stores
220+ /// the returned value to this argument. At the time when the function is called,
221+ /// the memory location referenced by the argument is uninitialized.
222+ case indirectOut
223+
224+ /// This argument is passed directly. Its type is non-trivial, and the callee
225+ /// is responsible for destroying it.
226+ case directOwned
227+
228+ /// This argument is passed directly. Its type may be trivial, or it may
229+ /// simply be that the callee is not responsible for destroying it. Its
230+ /// validity is guaranteed only at the instant the call begins.
231+ case directUnowned
232+
233+ /// This argument is passed directly. Its type is non-trivial, and the caller
234+ /// guarantees its validity for the entirety of the call.
235+ case directGuaranteed
236+ }
237+
188238// Bridging utilities
189239
190240extension BridgedFunction {
@@ -194,3 +244,21 @@ extension BridgedFunction {
194244extension OptionalBridgedFunction {
195245 public var function : Function ? { obj. getAs ( Function . self) }
196246}
247+
248+ extension BridgedArgumentConvention {
249+ var convention : ArgumentConvention {
250+ switch self {
251+ case ArgumentConvention_Indirect_In: return . indirectIn
252+ case ArgumentConvention_Indirect_In_Constant: return . indirectInConstant
253+ case ArgumentConvention_Indirect_In_Guaranteed: return . indirectInGuaranteed
254+ case ArgumentConvention_Indirect_Inout: return . indirectInout
255+ case ArgumentConvention_Indirect_InoutAliasable: return . indirectInoutAliasable
256+ case ArgumentConvention_Indirect_Out: return . indirectOut
257+ case ArgumentConvention_Direct_Owned: return . directOwned
258+ case ArgumentConvention_Direct_Unowned: return . directUnowned
259+ case ArgumentConvention_Direct_Guaranteed: return . directGuaranteed
260+ default :
261+ fatalError ( " unsupported argument convention " )
262+ }
263+ }
264+ }
0 commit comments