<commit_before>//
//  NSObject+ThemeKit.swift
//  ThemeKit
//
//  Created by <NAME> on 24/09/2016.
//  Copyright © 2016 Paw Inc. All rights reserved.
//

import Foundation

extension NSObject {
    
    /// Swizzle instance methods.
    internal class func swizzleInstanceMethod(cls: AnyClass?, selector originalSelector: Selector, withSelector swizzledSelector: Selector) {
        guard cls != nil else {
            print("Unable to swizzle \(cls).\(originalSelector): dynamic system color override will not be available.")
            return
        }
        
        // methods
        let originalMethod = class_getInstanceMethod(cls, originalSelector)
        let swizzledMethod = class_getInstanceMethod(cls, swizzledSelector)
        
        // add new method
        let didAddMethod = class_addMethod(cls, originalSelector, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod))
        
        // switch implementations
        if didAddMethod {
            class_replaceMethod(cls, swizzledSelector, method_getImplementation(originalMethod), method_getTypeEncoding(originalMethod))
        } else {
            method_exchangeImplementations(originalMethod, swizzledMethod)
        }
    }
    
    /// Returns class method names.
    internal class func classMethodNames(for cls: AnyClass?) -> Array<String> {
        var results: Array<String> = []
        
        // retrieve class method list
        var count: UInt32 = 0
        let methods : UnsafeMutablePointer<Method?>! = class_copyMethodList(object_getClass(cls), &count)
        
        // iterate class methods<commit_msg>Fixed logging<commit_after>//
//  NSObject+ThemeKit.swift
//  ThemeKit
//
//  Created by <NAME> on 24/09/2016.
//  Copyright © 2016 Paw Inc. All rights reserved.
//

import Foundation

extension NSObject {
    
    /// Swizzle instance methods.
    internal class func swizzleInstanceMethod(cls: AnyClass?, selector originalSelector: Selector, withSelector swizzledSelector: Selector) {
        guard cls != nil else {
            print("Unable to swizzle \(originalSelector): dynamic system color override will not be available.")
            return
        }
        
        // methods
        let originalMethod = class_getInstanceMethod(cls, originalSelector)
        let swizzledMethod = class_getInstanceMethod(cls, swizzledSelector)
        
        // add new method
        let didAddMethod = class_addMethod(cls, originalSelector, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod))
        
        // switch implementations
        if didAddMethod {
            class_replaceMethod(cls, swizzledSelector, method_getImplementation(originalMethod), method_getTypeEncoding(originalMethod))
        } else {
            method_exchangeImplementations(originalMethod, swizzledMethod)
        }
    }
    
    /// Returns class method names.
    internal class func classMethodNames(for cls: AnyClass?) -> Array<String> {
        var results: Array<String> = []
        
        // retrieve class method list
        var count: UInt32 = 0
        let methods : UnsafeMutablePointer<Method?>! = class_copyMethodList(object_getClass(cls), &count)
        
        // iterate class methods
{'fraction_non_alphanumeric': 0.0823854903166308, 'fraction_numerical': 0.009222256378727329, 'mean_word_length': 2.680995475113122, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, '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': '3493601', 'n_tokens_mistral': 852, 'n_tokens_neox': 828, 'n_words': 220}