 /// Swift protocol representation of a record/class as a wrapper of a pointer
 public func recordProtocolCode(_ e: GIR.Record, parent: String, indentation: String = "    ", ptr: String = "ptr") -> String {
     let p = (parent.isEmpty ? "" : ": \(parent)")
-    let ctype = e.ctype.isEmpty ? e.type.swift : e.ctype.swift
+    let cOriginalType = e.ctype.isEmpty ? e.type.swift : e.ctype.swift
+    let ctype = cOriginalType.isEmpty ? e.name.swift : cOriginalType
     let subTypeAliases = e.records.map { subTypeAlias(e, $0, publicDesignation: "") }.joined()
     let documentation = commentCode(e)
     let code = "// MARK: - \(e.name) \(e.kind)\n\n" +

    let protocolName = e.protocolName
    let parentType = e.parentType
    let hasParent = parentType != nil
    let ctype = e.ctype.isEmpty ? e.type.swift : e.ctype.swift
    let scode = signalNameCode(indentation: indentation)
    let ncode = signalNameCode(indentation: indentation, prefixes: ("notify", "notify::"))
    let ccode = convenienceConstructorCode(classType, indentation: indentation, override: "override ", hasParent: hasParent)(e)

public func recordStructCode(_ e: GIR.Record, indentation: String = "    ", ptr: String = "ptr") -> String {
    let structType = "\(e.name)Ref"
    let protocolName = e.protocolName
    let cOriginalType = e.ctype.isEmpty ? e.type.swift : e.ctype.swift
    let ctype = cOriginalType.isEmpty ? e.name.swift : cOriginalType
    let ccode = convenienceConstructorCode(structType, indentation: indentation, publicDesignation: "")(e)
    let fcode = convenienceConstructorCode(structType, indentation: indentation, publicDesignation: "", factory: true)(e)
    let constructors = e.constructors.filter { $0.isConstructorOf(e) && !$0.isBareFactory }
