/// \brief A means of accepting "out" parameters from Objective-C /// functions taking the parameters by pointer func withOutArgument( arg: @inout T, f: (UnsafePointer)->Result ) -> Result { return f(UnsafePointer(Builtin.addressof(&arg))) } /// \brief A means of accepting @autorelease "out" parameters from /// Objective-C functions, which can be tricky because they are /// not handed to us at +1 like other objects. func withAutoReleasedOutArgument( arg: @inout T?, f: (UnsafePointer)->Result ) -> Result { var buffer: Builtin.RawPointer = Builtin.inttoptr_Int64(0.value) var address = UnsafePointer(Builtin.addressof(&buffer)) var result = f(address) arg = Int64(Builtin.ptrtoint_Int64(buffer)) == 0 ? .None : .Some(address.get()) return result }