Skip to content

Commit

Permalink
Merge pull request #161 from tishin/fix-arg-reference
Browse files Browse the repository at this point in the history
Fix argument reference handling
  • Loading branch information
migueldeicaza authored Oct 10, 2023
2 parents 76a0ec6 + 74a4869 commit b657cef
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions Generator/Generator/ClassGen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,12 @@ func generateVirtualProxy (_ p: Printer,
}
if arg.type == "String" {
argCall += "GString.stringFromGStringPtr (ptr: args [\(i)]!) ?? \"\""
} else if let cmap = classMap [arg.type] {
} else if classMap [arg.type] != nil {
//
// This idiom guarantees that: if this is a known object, we surface this
// object, but if it is not known, then we create the instance
//
if cmap.isRefcounted {
argPrep += "let resolved_\(i) = gi.ref_get_object (args [\(i)]!.load (as: UnsafeRawPointer.self))!\n"
} else {
argPrep += "let resolved_\(i) = args [\(i)]!.load (as: UnsafeRawPointer.self)\n"
}
argPrep += "let resolved_\(i) = args [\(i)]!.load (as: UnsafeRawPointer.self)\n"
argCall += "lookupLiveObject (handleAddress: resolved_\(i)) as? \(arg.type) ?? \(arg.type) (nativeHandle: resolved_\(i))"
} else if let storage = builtinClassStorage [arg.type] {
argCall += "\(mapTypeName (arg.type)) (content: args [\(i)]!.assumingMemoryBound (to: \(storage).self).pointee)"
Expand Down

0 comments on commit b657cef

Please sign in to comment.