Upgrade to Pro — share decks privately, control downloads, hide ads and more …

メタプログラミング向けのテンプレートエンジン gysb を作った

omochimetaru
November 21, 2017

メタプログラミング向けのテンプレートエンジン gysb を作った

2017/11/21 関西モバイルアプリ研究会 in 関東
https://kanmoba.connpass.com/event/70685/

omochimetaru

November 21, 2017
Tweet

More Decks by omochimetaru

Other Decks in Programming

Transcript

  1. Array ͱ ஥ؒͨͪ Array - startIndex, endIndex, subscript, _ArrayBuffer ArraySlice

    - startIndex, endIndex, subscript, _SliceBuffer ContiguousArray - startIndex, endIndex, subscript, _ContiguousArrayBuffer
  2. gyb Generate Your Boilerplate ࣮ߦ: %{ <python code> }% ࣮ߦ:

    % <python code> (ߦ຤) ࣜల։: ${ <python code> }
  3. %{ arrayTypes = [ ('ContiguousArray', 'a `ContiguousArray` instance'), ('ArraySlice', 'an

    `ArraySlice` instance'), ('Array', 'an array'), ] }% % for (Self, a_Self) in arrayTypes: public struct ${Self}<Element> { %if Self == 'Array': internal typealias _Buffer = _ArrayBuffer<Element> %elif Self == 'ArraySlice': internal typealias _Buffer = _SliceBuffer<Element> %else: internal typealias _Buffer = _${Self.strip('_')}Buffer<Element> %end internal var _buffer: _Buffer } %end
  4. public struct ContiguousArray<Element> { internal typealias _Buffer = _ContiguousBuffer<Element> internal

    var _buffer: _Buffer } public struct ArraySlice<Element> { internal typealias _Buffer = _SliceBuffer<Element> internal var _buffer: _Buffer } public struct Array<Element> { internal typealias _Buffer = _ArrayBuffer<Element> internal var _buffer: _Buffer }
  5. gysb Generate Your Swifty Boilerplate https://github.com/omochi/gysb ࣮ߦ: %{ <swift code>

    }% ࣮ߦ: % <swift code> (ߦ຤) ࣜల։: ${ <swift code> }
  6. Sourceryͱͷҧ͍ Sourcery ͸ ܕ৘ใऔಘ + ςϯϓϨʔτ(ෳ਺ݴޠ) gysb ͸ ςϯϓϨʔτ Sourcery

    ͷ swift ςϯϓϨʔτ͸ϥΠϒϥϦඇରԠ gysb ͸ gysb.json Ͱ SwiftPM ʹରԠ