 
 /// Swift code for calling the underlying function and assigning the raw return value
 public func callCode(_ indentation: String, _ record: GIR.Record? = nil) -> (GIR.Method) -> String {
-    let toSwift = convertArgumentToSwiftFor(record)
+    var hadInstance = false
+    let toSwift: (GIR.Argument) -> String = { arg in
+        let name = arg.nonClashingName
+        guard !arg.isScalarArray else { return "&" + name }
+        let instance = !hadInstance && (arg.instance || arg.isInstanceOf(record))
+        if instance { hadInstance = true }
+        let types = typeCastTuple(arg.ctype, arg.type.swift, varName: instance ? "ptr" : (name + (arg.isKnownRecord ? ".ptr" : "")))
+        let param = types.toC.hasSuffix("ptr") ? "cast(\(types.toC))" : types.toC
+        return param
+    }
     return { method in
+        hadInstance = false
         let throwsError = method.throwsError
         let args = method.args // not .lazy
         let n = args.count


/// Swift code for the parameters of a method or function
public func funcParam(_ method: GIR.Method, _ record: GIR.Record? = nil) -> String {
    return method.args.lazy.filter { !$0.instance && !$0.isInstanceOf(record) } .map(argumentCode).joined(separator: ", ")
}



    let types = typeCastTuple(arg.ctype, arg.type.swift, varName: arg.instance ? "ptr" : (arg.nonClashingName + (arg.isKnownRecord ? ".ptr" : "")))
    let param = types.toC.hasSuffix("ptr") ? "cast(\(types.toC))" : types.toC
    return param
}


