This file contains 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 UIKit | |
/// `Label` is an `UILabel` subclass that simplifies line height and letter spacing manipulation. | |
public final class Label: UILabel { | |
/// Since line spacing is always absolute in iOS, we need to compute the correct line spacing for given | |
/// font and scale. | |
public enum LineHeight { | |
case absoluteSpacing(CGFloat) | |
case fraction(CGFloat) |
This file contains 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
(source_file "Sources/swift-c-article01/main.swift" | |
(func_decl range=[Sources/swift-c-article01/main.swift:1:1 - line:3:1] "fce(_:)" interface type='(UnsafeMutablePointer<Int8>) -> ()' access=internal | |
(parameter_list | |
(parameter "ptr" interface type='UnsafeMutablePointer<Int8>') range=[Sources/swift-c-article01/main.swift:1:9 - line:1:43]) | |
(brace_stmt range=[Sources/swift-c-article01/main.swift:1:45 - line:3:1] | |
(call_expr type='()' location=Sources/swift-c-article01/main.swift:2:5 range=[Sources/swift-c-article01/main.swift:2:5 - line:2:14] nothrow arg_labels=_: | |
(declref_expr type='(Any..., String, String) -> ()' location=Sources/swift-c-article01/main.swift:2:5 range=[Sources/swift-c-article01/main.swift:2:5 - line:2:5] decl=Swift.(file).print(_:separator:terminator:) function_ref=single) | |
(tuple_shuffle_expr implicit type='(Any..., separator: String, terminator: String)' location=Sources/swift-c-article01/main.swift:2:11 range=[Sources/swift-c-article01/main.swift:2:10 - |
This file contains 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
(source_file "Sources/swift-c-article01/main.swift" | |
(func_decl range=[Sources/swift-c-article01/main.swift:1:1 - line:3:1] "fce(_:)" | |
(parameter_list | |
(parameter "ptr") range=[Sources/swift-c-article01/main.swift:1:9 - line:1:43]) | |
(brace_stmt range=[Sources/swift-c-article01/main.swift:1:45 - line:3:1] | |
(call_expr type='<null>' arg_labels=_: | |
(unresolved_decl_ref_expr type='<null>' name=print function_ref=unapplied) | |
(paren_expr type='<null>' | |
(declref_expr type='<null>' decl=main.(file).fce(_:).ptr@Sources/swift-c-article01/main.swift:1:12 function_ref=unapplied))))) | |
(top_level_code_decl range=[Sources/swift-c-article01/main.swift:5:1 - line:5:17] |
This file contains 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
var fce: @convention(c) (UnsafeMutablePointer<Int8>) -> Void = { ptr in | |
print(ptr) | |
} | |
let myMessage = "🐱 and 🐶 in my 🏠 likes each others!" | |
var cString = Array(myMessage.utf8CString) | |
fce(&cString) |
This file contains 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
func fce(_ ptr: UnsafeMutablePointer<Int8>) { | |
print(ptr) | |
} | |
let myMessage = "🐱 and 🐶 in my 🏠 likes each others!" | |
var cString = Array(myMessage.utf8CString) | |
fce(&cString) |
This file contains 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 CswiftLib | |
let myMessage = "🐱 and 🐶 in my 🏠 likes each others!" | |
let myCString = Array(myMessage.str.utf8CString) | |
safely_print_message(myCString) | |
decorate_my_message(myCString) |
This file contains 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
$ head -c 15000 main.sil | |
[1/2] Compiling Swift Module 'swift_c_article01' (1 sources) | |
*** SIL module before Guaranteed Passes *** | |
sil_stage raw | |
import Builtin | |
import Swift | |
import SwiftShims | |
// myMessage |
This file contains 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
func unconst_print(_ string: UnsafeMutablePointer<Int8>) | |
let myMessage = "Greetings!" | |
var cString = Array(myMessage.utf8CString) | |
unconst_print(&cString) |
This file contains 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
func unconst_print(_ string: UnsafeMutablePointer<Int8>) | |
let myMessage = "Greetings!" | |
var cString = myMessage.utf8CString | |
unconst_print(&cString) |
This file contains 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
func unconst_print(_ string: UnsafeMutablePointer<Int8>) | |
var myMessage = "Greetings!" | |
unconst_print(&myMessage) // main.swift:5:16: error: cannot convert value of type 'String' to expected argument type 'Int8' |
NewerOlder