     func swiftSignalArgumentConversion(at index: Int) -> String {
         switch knownType {
         case is GIR.Record:
+            if isNullable {
+                return "arg\(index).flatMap(\(typeRef.type.swiftName)Ref.init(raw:))"
+            }
             return typeRef.type.swiftName + "Ref" + "(raw: arg\(index))"
-        case let type as GIR.Alias: // use containedTypes
+        case is GIR.Alias: // use containedTypes
             return ""
         case is GIR.Bitfield:
+            if isNullable {
+                return "arg\(index).flatMap(\(self.argumentTypeName).init(_:))"
+            }
             return self.argumentTypeName + "(arg\(index))"
         case is GIR.Enumeration:
+            if isNullable {
+                return "arg\(index).flatMap(\(self.argumentTypeName).init(_:))"
+            }
             return self.argumentTypeName + "(arg\(index))"
         case nil where swiftReturnRef == GIR.stringRef:
-            return swiftReturnRef.cast(expression: "arg\(index)", from: typeRef) + "!"
+            return swiftReturnRef.cast(expression: "arg\(index)", from: typeRef) + (isNullable ? "" : "!")
         default: // Treat as fundamental (if not a fundamental, report error)
             return swiftReturnRef.cast(expression: "arg\(index)", from: typeRef)
         }

    
    return Code.block(indentation: nil) {
        
        "// MARK: Signals of \(record.kind) named \(record.name.swift)"

        Code.block {
            Code.loop(over: record.signals.compactMap({ signalSanityCheck($0) })) { error in

    func swiftIdiomaticType() -> String {
        switch knownType {
        case is GIR.Record:
            return typeRef.type.swiftName + "Ref" + (isNullable ? "?" : "")
        case is GIR.Alias: // use containedTypes
            return ""
        case is GIR.Bitfield:
            return self.argumentTypeName + (isNullable ? "?" : "")
        case is GIR.Enumeration:
            return self.argumentTypeName + (isNullable ? "?" : "")
        default: // Treat as fundamental (if not a fundamental, report error)
            return self.swiftReturnRef.fullSwiftTypeName + (isNullable ? "?" : "")
        }
    }
    
    func swiftCCompatibleType() -> String {
        switch knownType {
        case is GIR.Record:
            return GIR.gpointerType.typeName + (isNullable ? "?" : "")
        case is GIR.Alias: // use containedTypes
            return ""
        case is GIR.Bitfield:
            return GIR.uint32Type.typeName + (isNullable ? "?" : "")
        case is GIR.Enumeration:
            return GIR.uint32Type.typeName + (isNullable ? "?" : "")
        default: // Treat as fundamental (if not a fundamental, report error)
            return self.callbackArgumentTypeName
        }
