 public func recordStructCode(_ e: GIR.Record, indentation: String = "    ", ptr: String = "ptr") -> String {
     let structType = "\(e.name)Ref"
     let protocolName = e.protocolName
-//    let parent = e.parentType
-//    let root = parent?.rootType
-//    let p = parent ?? e
-//    let r = root ?? p
-    let ctype = e.ctype.isEmpty ? e.type.swift : e.ctype.swift
-//    let rtype = r.ctype.isEmpty ? r.type.swift : r.ctype.swift
+    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 }

/// 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 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 cOriginalType = e.ctype.isEmpty ? e.type.swift : e.ctype.swift
    let ctype = cOriginalType.isEmpty ? e.name.swift : cOriginalType
    let scode = signalNameCode(indentation: indentation)
    let ncode = signalNameCode(indentation: indentation, prefixes: ("notify", "notify::"))
    let ccode = convenienceConstructorCode(classType, indentation: indentation, override: "override ", hasParent: hasParent)(e)
