#-- # this code is generated by mkprims.rb #++ require_relative "typespec" module Gogyou class Primitive < ::Struct.new(:name, :bytesize, :bytealign) BasicStruct = superclass undef :name=, :bytesize=, :bytealign= def initialize(name, bytesize, bytealign, aset, aref) super(name.intern, bytesize.to_i, bytealign.to_i) define_singleton_method(:aset, aset) define_singleton_method(:aref, aref) end def extensible? false end def to_s "\#<#{self.class}:#{name} bytesize=#{bytesize.inspect}, bytealign=#{bytealign.inspect}>" 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 module Primitives SIZE_T = Primitive[:size_t, TypeSpec::SIZEOF_SIZE_T, TypeSpec::SIZEOF_SIZE_T, ->(buf, offset, num) { buf.store_sizet(offset, num) }, ->(buf, offset) { buf.load_sizet(offset) }].freeze SSIZE_T = Primitive[:ssize_t, TypeSpec::SIZEOF_SIZE_T, TypeSpec::SIZEOF_SIZE_T, ->(buf, offset, num) { buf.store_sizet(offset, num) }, ->(buf, offset) { buf.load_ssizet(offset) }].freeze INTPTR_T = Primitive[:intptr_t, TypeSpec::SIZEOF_SIZE_T, TypeSpec::SIZEOF_SIZE_T, ->(buf, offset, num) { buf.store_sizet(offset, num) }, ->(buf, offset) { buf.load_ssizet(offset) }].freeze UINTPTR_T = Primitive[:uintptr_t, TypeSpec::SIZEOF_SIZE_T, TypeSpec::SIZEOF_SIZE_T, ->(buf, offset, num) { buf.store_sizet(offset, num) }, ->(buf, offset) { buf.load_sizet(offset) }].freeze INT8_T = Primitive[:int8_t, 1, 1, ->(buf, offset, num) { buf.store8(offset, num) }, ->(buf, offset) { buf.loadi8(offset) }].freeze UINT8_T = Primitive[:uint8_t, 1, 1, ->(buf, offset, num) { buf.store8(offset, num) }, ->(buf, offset) { buf.loadu8(offset) }].freeze INT16_T = Primitive[:int16_t, 2, 2, ->(buf, offset, num) { buf.store16(offset, num) }, ->(buf, offset) { buf.loadi16(offset) }].freeze UINT16_T = Primitive[:uint16_t, 2, 2, ->(buf, offset, num) { buf.store16(offset, num) }, ->(buf, offset) { buf.loadu16(offset) }].freeze INT32_T = Primitive[:int32_t, 4, 4, ->(buf, offset, num) { buf.store32(offset, num) }, ->(buf, offset) { buf.loadi32(offset) }].freeze UINT32_T = Primitive[:uint32_t, 4, 4, ->(buf, offset, num) { buf.store32(offset, num) }, ->(buf, offset) { buf.loadu32(offset) }].freeze INT64_T = Primitive[:int64_t, 8, 8, ->(buf, offset, num) { buf.store64(offset, num) }, ->(buf, offset) { buf.loadi64(offset) }].freeze UINT64_T = Primitive[:uint64_t, 8, 8, ->(buf, offset, num) { buf.store64(offset, num) }, ->(buf, offset) { buf.loadu64(offset) }].freeze INT16_BE = Primitive[:int16_be, 2, 2, ->(buf, offset, num) { buf.store16be(offset, num) }, ->(buf, offset) { buf.loadi16be(offset) }].freeze UINT16_BE = Primitive[:uint16_be, 2, 2, ->(buf, offset, num) { buf.store16be(offset, num) }, ->(buf, offset) { buf.loadu16be(offset) }].freeze INT24_BE = Primitive[:int24_be, 3, 1, ->(buf, offset, num) { buf.store24be(offset, num) }, ->(buf, offset) { buf.loadi24be(offset) }].freeze UINT24_BE = Primitive[:uint24_be, 3, 1, ->(buf, offset, num) { buf.store24be(offset, num) }, ->(buf, offset) { buf.loadu24be(offset) }].freeze INT32_BE = Primitive[:int32_be, 4, 4, ->(buf, offset, num) { buf.store32be(offset, num) }, ->(buf, offset) { buf.loadi32be(offset) }].freeze UINT32_BE = Primitive[:uint32_be, 4, 4, ->(buf, offset, num) { buf.store32be(offset, num) }, ->(buf, offset) { buf.loadu32be(offset) }].freeze INT48_BE = Primitive[:int48_be, 6, 2, ->(buf, offset, num) { buf.store48be(offset, num) }, ->(buf, offset) { buf.loadi48be(offset) }].freeze UINT48_BE = Primitive[:uint48_be, 6, 2, ->(buf, offset, num) { buf.store48be(offset, num) }, ->(buf, offset) { buf.loadu48be(offset) }].freeze INT64_BE = Primitive[:int64_be, 8, 8, ->(buf, offset, num) { buf.store64be(offset, num) }, ->(buf, offset) { buf.loadi64be(offset) }].freeze UINT64_BE = Primitive[:uint64_be, 8, 8, ->(buf, offset, num) { buf.store64be(offset, num) }, ->(buf, offset) { buf.loadu64be(offset) }].freeze INT16_LE = Primitive[:int16_le, 2, 2, ->(buf, offset, num) { buf.store16le(offset, num) }, ->(buf, offset) { buf.loadi16le(offset) }].freeze UINT16_LE = Primitive[:uint16_le, 2, 2, ->(buf, offset, num) { buf.store16le(offset, num) }, ->(buf, offset) { buf.loadu16le(offset) }].freeze INT24_LE = Primitive[:int24_le, 3, 1, ->(buf, offset, num) { buf.store24le(offset, num) }, ->(buf, offset) { buf.loadi24le(offset) }].freeze UINT24_LE = Primitive[:uint24_le, 3, 1, ->(buf, offset, num) { buf.store24le(offset, num) }, ->(buf, offset) { buf.loadu24le(offset) }].freeze INT32_LE = Primitive[:int32_le, 4, 4, ->(buf, offset, num) { buf.store32le(offset, num) }, ->(buf, offset) { buf.loadi32le(offset) }].freeze UINT32_LE = Primitive[:uint32_le, 4, 4, ->(buf, offset, num) { buf.store32le(offset, num) }, ->(buf, offset) { buf.loadu32le(offset) }].freeze INT48_LE = Primitive[:int48_le, 6, 2, ->(buf, offset, num) { buf.store48le(offset, num) }, ->(buf, offset) { buf.loadi48le(offset) }].freeze UINT48_LE = Primitive[:uint48_le, 6, 2, ->(buf, offset, num) { buf.store48le(offset, num) }, ->(buf, offset) { buf.loadu48le(offset) }].freeze INT64_LE = Primitive[:int64_le, 8, 8, ->(buf, offset, num) { buf.store64le(offset, num) }, ->(buf, offset) { buf.loadi64le(offset) }].freeze UINT64_LE = Primitive[:uint64_le, 8, 8, ->(buf, offset, num) { buf.store64le(offset, num) }, ->(buf, offset) { buf.loadu64le(offset) }].freeze INT16_SWAP = Primitive[:int16_swap, 2, 2, ->(buf, offset, num) { buf.store16swap(offset, num) }, ->(buf, offset) { buf.loadi16swap(offset) }].freeze UINT16_SWAP = Primitive[:uint16_swap, 2, 2, ->(buf, offset, num) { buf.store16swap(offset, num) }, ->(buf, offset) { buf.loadu16swap(offset) }].freeze INT32_SWAP = Primitive[:int32_swap, 4, 4, ->(buf, offset, num) { buf.store32swap(offset, num) }, ->(buf, offset) { buf.loadi32swap(offset) }].freeze UINT32_SWAP = Primitive[:uint32_swap, 4, 4, ->(buf, offset, num) { buf.store32swap(offset, num) }, ->(buf, offset) { buf.loadu32swap(offset) }].freeze INT64_SWAP = Primitive[:int64_swap, 8, 8, ->(buf, offset, num) { buf.store64swap(offset, num) }, ->(buf, offset) { buf.loadi64swap(offset) }].freeze UINT64_SWAP = Primitive[:uint64_swap, 8, 8, ->(buf, offset, num) { buf.store64swap(offset, num) }, ->(buf, offset) { buf.loadu64swap(offset) }].freeze CHAR = Primitive[:char, 1, 1, ->(buf, offset, num) { buf.store8(offset, num) }, ->(buf, offset) { buf.loadi8(offset) }].freeze UCHAR = Primitive[:uchar, 1, 1, ->(buf, offset, num) { buf.store8(offset, num) }, ->(buf, offset) { buf.loadu8(offset) }].freeze SHORT = Primitive[:short, TypeSpec::SIZEOF_SHORT, TypeSpec::SIZEOF_SHORT, ->(buf, offset, num) { buf.store_short(offset, num) }, ->(buf, offset) { buf.load_short(offset) }].freeze USHORT = Primitive[:ushort, TypeSpec::SIZEOF_SHORT, TypeSpec::SIZEOF_SHORT, ->(buf, offset, num) { buf.store_short(offset, num) }, ->(buf, offset) { buf.load_ushort(offset) }].freeze INT = Primitive[:int, TypeSpec::SIZEOF_INT, TypeSpec::SIZEOF_INT, ->(buf, offset, num) { buf.store_int(offset, num) }, ->(buf, offset) { buf.load_int(offset) }].freeze UINT = Primitive[:uint, TypeSpec::SIZEOF_INT, TypeSpec::SIZEOF_INT, ->(buf, offset, num) { buf.store_int(offset, num) }, ->(buf, offset) { buf.load_uint(offset) }].freeze LONG = Primitive[:long, TypeSpec::SIZEOF_LONG, TypeSpec::SIZEOF_LONG, ->(buf, offset, num) { buf.store_long(offset, num) }, ->(buf, offset) { buf.load_long(offset) }].freeze ULONG = Primitive[:ulong, TypeSpec::SIZEOF_LONG, TypeSpec::SIZEOF_LONG, ->(buf, offset, num) { buf.store_long(offset, num) }, ->(buf, offset) { buf.load_ulong(offset) }].freeze LONGLONG = Primitive[:longlong, TypeSpec::SIZEOF_LONGLONG, TypeSpec::SIZEOF_LONGLONG, ->(buf, offset, num) { buf.store_longlong(offset, num) }, ->(buf, offset) { buf.load_longlong(offset) }].freeze ULONGLONG = Primitive[:ulonglong, TypeSpec::SIZEOF_LONGLONG, TypeSpec::SIZEOF_LONGLONG, ->(buf, offset, num) { buf.store_longlong(offset, num) }, ->(buf, offset) { buf.load_ulonglong(offset) }].freeze FLOAT = Primitive[:float, TypeSpec::SIZEOF_FLOAT, TypeSpec::SIZEOF_FLOAT, ->(buf, offset, num) { buf.store_float(offset, num) }, ->(buf, offset) { buf.load_float(offset) }].freeze DOUBLE = Primitive[:double, TypeSpec::SIZEOF_DOUBLE, TypeSpec::SIZEOF_DOUBLE, ->(buf, offset, num) { buf.store_double(offset, num) }, ->(buf, offset) { buf.load_double(offset) }].freeze FLOAT_BE = Primitive[:float_be, 4, 4, ->(buf, offset, num) { buf.storef32be(offset, num) }, ->(buf, offset) { buf.loadf32be(offset) }].freeze DOUBLE_BE = Primitive[:double_be, 8, 8, ->(buf, offset, num) { buf.storef64be(offset, num) }, ->(buf, offset) { buf.loadf64be(offset) }].freeze FLOAT_LE = Primitive[:float_le, 4, 4, ->(buf, offset, num) { buf.storef32le(offset, num) }, ->(buf, offset) { buf.loadf32le(offset) }].freeze DOUBLE_LE = Primitive[:double_le, 8, 8, ->(buf, offset, num) { buf.storef64le(offset, num) }, ->(buf, offset) { buf.loadf64le(offset) }].freeze FLOAT_SWAP = Primitive[:float_swap, 4, 4, ->(buf, offset, num) { buf.storef32swap(offset, num) }, ->(buf, offset) { buf.loadf32swap(offset) }].freeze DOUBLE_SWAP = Primitive[:double_swap, 8, 8, ->(buf, offset, num) { buf.storef64swap(offset, num) }, ->(buf, offset) { buf.loadf64swap(offset) }].freeze FLOAT16_T = Primitive[:float16_t, 2, 2, ->(buf, offset, num) { buf.storef16(offset, num) }, ->(buf, offset) { buf.loadf16(offset) }].freeze FLOAT16_SWAP = Primitive[:float16_swap, 2, 2, ->(buf, offset, num) { buf.storef16swap(offset, num) }, ->(buf, offset) { buf.loadf16swap(offset) }].freeze FLOAT16_BE = Primitive[:float16_be, 2, 2, ->(buf, offset, num) { buf.storef16be(offset, num) }, ->(buf, offset) { buf.loadf16be(offset) }].freeze FLOAT16_LE = Primitive[:float16_le, 2, 2, ->(buf, offset, num) { buf.storef16le(offset, num) }, ->(buf, offset) { buf.loadf16le(offset) }].freeze FLOAT32_T = Primitive[:float32_t, 4, 4, ->(buf, offset, num) { buf.storef32(offset, num) }, ->(buf, offset) { buf.loadf32(offset) }].freeze FLOAT32_SWAP = Primitive[:float32_swap, 4, 4, ->(buf, offset, num) { buf.storef32swap(offset, num) }, ->(buf, offset) { buf.loadf32swap(offset) }].freeze FLOAT32_BE = Primitive[:float32_be, 4, 4, ->(buf, offset, num) { buf.storef32be(offset, num) }, ->(buf, offset) { buf.loadf32be(offset) }].freeze FLOAT32_LE = Primitive[:float32_le, 4, 4, ->(buf, offset, num) { buf.storef32le(offset, num) }, ->(buf, offset) { buf.loadf32le(offset) }].freeze FLOAT64_T = Primitive[:float64_t, 8, 8, ->(buf, offset, num) { buf.storef64(offset, num) }, ->(buf, offset) { buf.loadf64(offset) }].freeze FLOAT64_SWAP = Primitive[:float64_swap, 8, 8, ->(buf, offset, num) { buf.storef64swap(offset, num) }, ->(buf, offset) { buf.loadf64swap(offset) }].freeze FLOAT64_BE = Primitive[:float64_be, 8, 8, ->(buf, offset, num) { buf.storef64be(offset, num) }, ->(buf, offset) { buf.loadf64be(offset) }].freeze FLOAT64_LE = Primitive[:float64_le, 8, 8, ->(buf, offset, num) { buf.storef64le(offset, num) }, ->(buf, offset) { buf.loadf64le(offset) }].freeze FIXED16Q8_T = Primitive[:fixed16q8_t, 2, 2, ->(buf, offset, num) { buf.store16q8(offset, num) }, ->(buf, offset) { buf.loadi16q8(offset) }].freeze FIXED16Q8_SWAP = Primitive[:fixed16q8_swap, 2, 2, ->(buf, offset, num) { buf.store16q8swap(offset, num) }, ->(buf, offset) { buf.loadi16q8swap(offset) }].freeze FIXED16Q8_BE = Primitive[:fixed16q8_be, 2, 2, ->(buf, offset, num) { buf.store16q8be(offset, num) }, ->(buf, offset) { buf.loadi16q8be(offset) }].freeze FIXED16Q8_LE = Primitive[:fixed16q8_le, 2, 2, ->(buf, offset, num) { buf.store16q8le(offset, num) }, ->(buf, offset) { buf.loadi16q8le(offset) }].freeze FIXED32Q6_T = Primitive[:fixed32q6_t, 4, 4, ->(buf, offset, num) { buf.store32q6(offset, num) }, ->(buf, offset) { buf.loadi32q6(offset) }].freeze FIXED32Q6_SWAP = Primitive[:fixed32q6_swap, 4, 4, ->(buf, offset, num) { buf.store32q6swap(offset, num) }, ->(buf, offset) { buf.loadi32q6swap(offset) }].freeze FIXED32Q6_BE = Primitive[:fixed32q6_be, 4, 4, ->(buf, offset, num) { buf.store32q6be(offset, num) }, ->(buf, offset) { buf.loadi32q6be(offset) }].freeze FIXED32Q6_LE = Primitive[:fixed32q6_le, 4, 4, ->(buf, offset, num) { buf.store32q6le(offset, num) }, ->(buf, offset) { buf.loadi32q6le(offset) }].freeze FIXED32Q8_T = Primitive[:fixed32q8_t, 4, 4, ->(buf, offset, num) { buf.store32q8(offset, num) }, ->(buf, offset) { buf.loadi32q8(offset) }].freeze FIXED32Q8_SWAP = Primitive[:fixed32q8_swap, 4, 4, ->(buf, offset, num) { buf.store32q8swap(offset, num) }, ->(buf, offset) { buf.loadi32q8swap(offset) }].freeze FIXED32Q8_BE = Primitive[:fixed32q8_be, 4, 4, ->(buf, offset, num) { buf.store32q8be(offset, num) }, ->(buf, offset) { buf.loadi32q8be(offset) }].freeze FIXED32Q8_LE = Primitive[:fixed32q8_le, 4, 4, ->(buf, offset, num) { buf.store32q8le(offset, num) }, ->(buf, offset) { buf.loadi32q8le(offset) }].freeze FIXED32Q12_T = Primitive[:fixed32q12_t, 4, 4, ->(buf, offset, num) { buf.store32q12(offset, num) }, ->(buf, offset) { buf.loadi32q12(offset) }].freeze FIXED32Q12_SWAP = Primitive[:fixed32q12_swap, 4, 4, ->(buf, offset, num) { buf.store32q12swap(offset, num) }, ->(buf, offset) { buf.loadi32q12swap(offset) }].freeze FIXED32Q12_BE = Primitive[:fixed32q12_be, 4, 4, ->(buf, offset, num) { buf.store32q12be(offset, num) }, ->(buf, offset) { buf.loadi32q12be(offset) }].freeze FIXED32Q12_LE = Primitive[:fixed32q12_le, 4, 4, ->(buf, offset, num) { buf.store32q12le(offset, num) }, ->(buf, offset) { buf.loadi32q12le(offset) }].freeze FIXED32Q16_T = Primitive[:fixed32q16_t, 4, 4, ->(buf, offset, num) { buf.store32q16(offset, num) }, ->(buf, offset) { buf.loadi32q16(offset) }].freeze FIXED32Q16_SWAP = Primitive[:fixed32q16_swap, 4, 4, ->(buf, offset, num) { buf.store32q16swap(offset, num) }, ->(buf, offset) { buf.loadi32q16swap(offset) }].freeze FIXED32Q16_BE = Primitive[:fixed32q16_be, 4, 4, ->(buf, offset, num) { buf.store32q16be(offset, num) }, ->(buf, offset) { buf.loadi32q16be(offset) }].freeze FIXED32Q16_LE = Primitive[:fixed32q16_le, 4, 4, ->(buf, offset, num) { buf.store32q16le(offset, num) }, ->(buf, offset) { buf.loadi32q16le(offset) }].freeze FIXED32Q24_T = Primitive[:fixed32q24_t, 4, 4, ->(buf, offset, num) { buf.store32q24(offset, num) }, ->(buf, offset) { buf.loadi32q24(offset) }].freeze FIXED32Q24_SWAP = Primitive[:fixed32q24_swap, 4, 4, ->(buf, offset, num) { buf.store32q24swap(offset, num) }, ->(buf, offset) { buf.loadi32q24swap(offset) }].freeze FIXED32Q24_BE = Primitive[:fixed32q24_be, 4, 4, ->(buf, offset, num) { buf.store32q24be(offset, num) }, ->(buf, offset) { buf.loadi32q24be(offset) }].freeze FIXED32Q24_LE = Primitive[:fixed32q24_le, 4, 4, ->(buf, offset, num) { buf.store32q24le(offset, num) }, ->(buf, offset) { buf.loadi32q24le(offset) }].freeze end end