     let protocolName = e.protocolName
     let parentType = e.parentType
     let hasParent = parentType != nil
-    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 scode = signalNameCode(indentation: indentation)
     let ncode = signalNameCode(indentation: indentation, prefixes: ("notify", "notify::"))
     let ccode = convenienceConstructorCode(classType, indentation: indentation, override: "override ", hasParent: hasParent)(e)

    let fcode = fieldCode(indentation, record: e, avoiding: propertyNames, publicDesignation: "", ptr: ptrName)
    let methods = allMethods.filter { method in
        !method.name.hasPrefix("is_") || !gsPairs.contains { $0.getter === method } }
    let ctype = e.ctype.isEmpty ? e.type.swift : e.ctype.swift
    let subTypeProperties = e.records.map { subRecordProperty(e, ptr: ptrName, $0, indentation: indentation, publicDesignation: "") }.joined()
    let code = "// MARK: \(e.name) \(e.kind): \(e.protocolName) extension (methods and fields)\n" +
        "public extension \(e.protocolName) {\n" + indentation +

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 }
