This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <vector> | |
| #include <unordered_map> | |
| #include <memory> | |
| #include <stdio.h> | |
| typedef enum : int { | |
| TableKindSine, TableKindTriangle, TableKindSaw, TableKindSquare, | |
| TableKindCount | |
| } TableKind; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ cloc --exclude-ext=json --exclude-dir=Pods,node_modules,3rd\ Party . | |
| 6695 text files. | |
| 5975 unique files. | |
| 5297 files ignored. | |
| github.com/AlDanial/cloc v 1.84 T=3.96 s (354.3 files/s, 59697.4 lines/s) | |
| -------------------------------------------------------------------------------- | |
| Language files blank comment code | |
| -------------------------------------------------------------------------------- | |
| Swift 608 22679 10023 75483 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // This simple case works fine | |
| protocol BasicValueProvider { | |
| associatedtype Value | |
| static var value: Value { get } | |
| } | |
| struct False_Basic: BasicValueProvider { | |
| static var value: Bool { false } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| protocol ValueProvider { | |
| associatedtype Value | |
| static var value: Value { get } | |
| } | |
| @propertyWrapper | |
| struct Default<Provider: ValueProvider>: Codable, Hashable where Provider.Value: Codable & Hashable { | |
| typealias Value = Provider.Value |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import AppKit | |
| struct Icon {} | |
| struct Canvas {} | |
| protocol ToolController { | |
| var icon: Icon { get } | |
| var name: String { get } | |
| func apply(/*...*/) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # https://www.bignerdranch.com/blog/manual-swift-understanding-the-swift-objective-c-build-pipeline/ | |
| # create build folder | |
| mkdir -p build | |
| # create Swift->ObjC header and .o file | |
| xcrun -sdk macosx10.15 swift \ | |
| -frontend -c -primary-file SwiftFile.swift \ | |
| -module-name SwiftModule \ | |
| -emit-module-path build/SwiftModule.swiftmodule \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| class ThreadQueue { | |
| private var mutex = pthread_mutex_t() | |
| private var cond = pthread_cond_t() | |
| // these are shared variables and should only be modified within a `lock` block | |
| private var threadId: pthread_t? = nil | |
| private var isStopped = true | |
| private var queue: [() -> Void] = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| protocol CustomKeyCodable: Codable { | |
| static var keyEncodingStrategy: ([CodingKey]) -> CodingKey { get } | |
| static var keyDecodingStrategy: ([CodingKey]) -> CodingKey { get } | |
| init() | |
| } | |
| extension CustomKeyCodable { | |
| init(from decoder: Decoder) throws { | |
| self.init() |