#!/bin/env ruby path = File.join(File.dirname(__FILE__), "lib", "gogyou", "primitives.rb") # type name, byte bytesize, alignment bytesize, store method, load method records = <(buf, offset, num) { buf.#{aset}(offset, num) }, ->(buf, offset) { buf.#{aref}(offset) }].freeze EOS end f.puts <<-EOS end class Model TYPEMAP = { EOS records.each do |typename, bytesize, bytealign, aset, aref| sym = typename.to_sym.inspect f.puts <<-EOS % ["#{typename}:".ljust(17, " "), typename.upcase] %s Primitives::%s, EOS end f.puts <<-EOS } EOS [ %w(unsigned_char uchar), %w(unsigned_short ushort), %w(unsigned_int uint), %w(unsigned_long ulong), %w(unsigned_long_long ulonglong), %w(long_long longlong), ].each do |link, name| f.puts <<-EOS TYPEMAP[:#{link}] = TYPEMAP[:#{name}] EOS end f.puts <<-EOS end end EOS end