<commit_before>//
//  gir+swift.swift
//  Gtk3Swift
//
//  Created by <NAME> on 2/04/2016.
//  Copyright © 2016 <NAME>. All rights reserved.
//

public extension GIR {
    /// code boiler plate
    public var boilerPlate: String {
        return "private func cast<S, T>(_ param: UnsafeMutablePointer<S>) -> UnsafeMutablePointer<T> {\n" +
        "    return UnsafeMutablePointer<T>(param)\n" +
        "}\n\n" +

        "private func cast<S, T>(_ param: UnsafeMutablePointer<S>) -> UnsafePointer<T> {\n" +
        "    return UnsafePointer<T>(param)\n" +
        "}\n\n" +

        "private func cast<S, T>(_ param: UnsafePointer<S>) -> UnsafePointer<T> {\n" +
        "    return UnsafePointer<T>(param)\n" +
        "}\n\n" +

        "private func cast<T>(_ param: COpaquePointer) -> UnsafeMutablePointer<T> {\n" +
        "    return UnsafeMutablePointer<T>(param)\n" +
        "}\n\n" +

        "private func cast<T>(_ param: COpaquePointer) -> UnsafePointer<T> {\n" +
        "    return UnsafePointer<T>(param)\n" +
        "}\n\n" +

        "private func mutable_cast<S, T>(_ param: UnsafePointer<S>) -> UnsafeMutablePointer<T> {\n" +
        "    return UnsafeMutablePointer<T>(param)\n" +
        "}\n\n" +

        "private func mutable_cast<T>(_ param: COpaquePointer) -> UnsafeMutablePointer<T> {\n" +
        "    return UnsafeMutablePointer<T>(param)\n" +
        "}\n\n" +

        "private func cast<T>(_ param: UnsafePointer<T>) -> COpaquePointer {\n" +
        "    return COpaquePointer(param)\n" +
        "}\n\n" +

        "private func cast<T>(_ param: UnsafeMutablePointer<T>) -> COpaquePointer {\n" +
        "    return COpaquePointer(param)\n" +
        "}\n\n" +

        "private extension gboolean {\n" +
        "    private init(_ b: Bool) { self = b ? gboolean(1) : gboolean(0) }\n" +
        "}\n\n" +

        "private func asStringArray<T>(_ param: UnsafePointer<UnsafePointer<CChar>>) -> [String] {\n" +
        "    var ptr = param\n" +
        "    var rv = [String]()\n" +
        "    while ptr.memory != nil {\n" +
        "        if let s = String.fromCString(ptr.memory) {\n" +
        "            rv.append(s)\n" +
        "        }\n" +
        "        ptr = ptr.successor()\n" +
        "    }\n" +
        "    return rv\n" +
        "}\n\n" +

        "private func asStringArray<T>(_ param: UnsafePointer<UnsafePointer<CChar>>, release: (UnsafePointer<T> -> Void)) -> [String] {\n" +
        "    let rv = asString(param)\n" +
        "    release(UnsafePointer<T>(param))\n" +
        "    return rv\n" +
        "}\n\n"
    }
}


/// Swift extension for arguments
public extension GIR.Argument {
    /// return whether the receiver is a known type
    public var isKnownType: Bool { return GIR.knownTypes[type.swift] != nil }

    /// return whether the receiver is a known class or record
    public var isKnownRecord: Bool { return GIR.knownRecords[type.swift] != nil }

    /// return whether the receiver is an instance of the given record (class)
    public func isInstanceOf(_ record: GIR.Record?) -> Bool {
        if let r = record where r.node == type.swift {
            return true
        } else {
            return false<commit_msg>Fix typo and remove superfluous template type<commit_after>//
//  gir+swift.swift
//  Gtk3Swift
//
//  Created by <NAME> on 2/04/2016.
//  Copyright © 2016 <NAME>. All rights reserved.
//

public extension GIR {
    /// code boiler plate
    public var boilerPlate: String {
        return "private func cast<S, T>(_ param: UnsafeMutablePointer<S>) -> UnsafeMutablePointer<T> {\n" +
        "    return UnsafeMutablePointer<T>(param)\n" +
        "}\n\n" +

        "private func cast<S, T>(_ param: UnsafeMutablePointer<S>) -> UnsafePointer<T> {\n" +
        "    return UnsafePointer<T>(param)\n" +
        "}\n\n" +

        "private func cast<S, T>(_ param: UnsafePointer<S>) -> UnsafePointer<T> {\n" +
        "    return UnsafePointer<T>(param)\n" +
        "}\n\n" +

        "private func cast<T>(_ param: COpaquePointer) -> UnsafeMutablePointer<T> {\n" +
        "    return UnsafeMutablePointer<T>(param)\n" +
        "}\n\n" +

        "private func cast<T>(_ param: COpaquePointer) -> UnsafePointer<T> {\n" +
        "    return UnsafePointer<T>(param)\n" +
        "}\n\n" +

        "private func mutable_cast<S, T>(_ param: UnsafePointer<S>) -> UnsafeMutablePointer<T> {\n" +
        "    return UnsafeMutablePointer<T>(param)\n" +
        "}\n\n" +

        "private func mutable_cast<T>(_ param: COpaquePointer) -> UnsafeMutablePointer<T> {\n" +
        "    return UnsafeMutablePointer<T>(param)\n" +
        "}\n\n" +

        "private func cast<T>(_ param: UnsafePointer<T>) -> COpaquePointer {\n" +
        "    return COpaquePointer(param)\n" +
        "}\n\n" +

        "private func cast<T>(_ param: UnsafeMutablePointer<T>) -> COpaquePointer {\n" +
        "    return COpaquePointer(param)\n" +
        "}\n\n" +

        "private extension gboolean {\n" +
        "    private init(_ b: Bool) { self = b ? gboolean(1) : gboolean(0) }\n" +
        "}\n\n" +

        "private func asStringArray(_ param: UnsafePointer<UnsafePointer<CChar>>) -> [String] {\n" +
        "    var ptr = param\n" +
        "    var rv = [String]()\n" +
        "    while ptr.memory != nil {\n" +
        "        if let s = String.fromCString(ptr.memory) {\n" +
        "            rv.append(s)\n" +
        "        }\n" +
        "        ptr = ptr.successor()\n" +
        "    }\n" +
        "    return rv\n" +
        "}\n\n" +

        "private func asStringArray<T>(_ param: UnsafePointer<UnsafePointer<CChar>>, release: (UnsafePointer<T> -> Void)) -> [String] {\n" +
        "    let rv = asStringArray(param)\n" +
        "    release(UnsafePointer<T>(param))\n" +
        "    return rv\n" +
        "}\n\n"
    }
}


/// Swift extension for arguments
public extension GIR.Argument {
    /// return whether the receiver is a known type
    public var isKnownType: Bool { return GIR.knownTypes[type.swift] != nil }

    /// return whether the receiver is a known class or record
    public var isKnownRecord: Bool { return GIR.knownRecords[type.swift] != nil }

    /// return whether the receiver is an instance of the given record (class)
    public func isInstanceOf(_ record: GIR.Record?) -> Bool {
        if let r = record where r.node == type.swift {
            return true
        } else {
            return false
{'fraction_non_alphanumeric': 0.15818858560794044, 'fraction_numerical': 0.004342431761786601, 'mean_word_length': 2.101972101972102, 'pattern_counts': {'":': 0, '<': 80, '<?xml version=': 0, '>': 106, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3362965', 'n_tokens_mistral': 2200, 'n_tokens_neox': 2097, 'n_words': 505}