#!/bin/env ruby path = File.join(File.dirname(__FILE__), "lib", "gogyou", "primitives.rb") # type name, byte bytesize, alignment bytesize, store method, load method records = <" end alias inspect to_s def pretty_print(q) #name, bytesize, bytealign q.group(1, "\\\#<\#{self.class}:\#{name}") do q.breakable " " q.text "bytesize=" q.pp bytesize q.text "," q.breakable " " q.text "bytealign=" q.pp bytealign end q.text ">" end end EOS records = records.split(/\n/) records.map! { |r| r.split(/\s+/) } records.each do |typename, bytesize, bytealign, aset, aref| name = typename.upcase f.puts <<-EOS #{name.ljust(9)} = Primitive[#{typename.intern.inspect}, #{bytesize}, #{bytealign}, ->(buf, offset, num) { buf.#{aset}(offset, num) }, ->(buf, offset) { buf.#{aref}(offset) }].freeze EOS end f.puts <<-EOS end end EOS end