swiftcoreとfoundationを読んでみた

21
SwiftCoreFoundationを読んで みた Mercari Inc. @kitasuke

Upload: yusuke-kita

Post on 18-Jan-2017

1.375 views

Category:

Engineering


5 download

TRANSCRIPT

Page 1: SwiftCoreとFoundationを読んでみた

SwiftCoreとFoundationを読んで

みたMercari Inc.@kitasuke

Page 2: SwiftCoreとFoundationを読んでみた

Swift open sourced!

Page 4: SwiftCoreとFoundationを読んでみた

準備段階で出来なかったこと

.gybファイルが開かない?Swift Package Managerのプロジェクトが

生成されない?

Page 5: SwiftCoreとFoundationを読んでみた

概要

Page 6: SwiftCoreとFoundationを読んでみた

主に使用されている言語

→ Swift→ C++→ C

Page 7: SwiftCoreとFoundationを読んでみた

Swiftで書かれている主な箇所→ SwiftCore→ Foundation

→ TestFoundation→ Swift Package Manager

Page 8: SwiftCoreとFoundationを読んでみた

未実装・修正すべき箇所

→ fatalError("not implemented")→ FIXME

→ NSUnimplemented()

Page 9: SwiftCoreとFoundationを読んでみた

Contributor出来そうな箇所→ バグ修正→ テスト修正

→ 未実装機能の追加

Page 10: SwiftCoreとFoundationを読んでみた

参考になったもの(SwiftCore)

Page 11: SwiftCoreとFoundationを読んでみた

swift/docsにあるドキュメント→ Array.rst

→ Generics.rst→ Literals.rst

→ Pattern Matching.rst→ Testing.rst

Page 12: SwiftCoreとFoundationを読んでみた

LangRefNew.rst→ Whitespace and Comments→ Reserved Punctuation Tokens

→ Reserved Keywords→ Contextual Keywords→ Integer Literals→ Operator Tokens

Page 13: SwiftCoreとFoundationを読んでみた

良く見たもの

→ nonmutating set→ public prefix func→ infix operator

Page 14: SwiftCoreとFoundationを読んでみた

Attr.def→ TYPEATTR(objcblock)

→ SIMPLEDECLATTR(noreturn, NoReturn, OnFunc, 7)

→ DECL_ATTR(autoclosure, AutoClosure, OnParam, 28)

Page 15: SwiftCoreとFoundationを読んでみた

良く見たもの

→ @_transparent→ @silgenname→ @inline(never)

→ @effects(readonly)

Page 16: SwiftCoreとFoundationを読んでみた

Swift Intermediate Language (SIL.rst)

→ Address Types→ Local Storage Types

→ Box Types→ Function Types

→ Properties of Types

Page 17: SwiftCoreとFoundationを読んでみた

Builtin.def→ BUILTINSILOPERATION(Retain, "retain",

Special)→ BUILTINMISCOPERATION(Sizeof, "sizeof",

"n", Special)→

BUILTINSILOPERATION(CastToNativeObject, "castToNativeObject", Special)

Page 18: SwiftCoreとFoundationを読んでみた

良く見たもの

→ Builtin.addressof($0)→ Builtin.NativeObject

→ Builtin.castFromNativeObject($0)→ Builtin.bridgeToRawPointer($0)

Page 19: SwiftCoreとFoundationを読んでみた

参考になったもの(Foundation)

Page 20: SwiftCoreとFoundationを読んでみた

TestFoundation→ TestNSArray.swift

→ TestNSFileManager.swift→ TestNSURL.swift→ TestNSNull.swift

Page 21: SwiftCoreとFoundationを読んでみた

まとめ

→ Foundationの方が読みやすい→ Swiftを勉強するためにC++を勉強する

→ 読んでるだけで楽しい!