class Gogyou::Model::Field

構造体の各メンバの情報を保持する

Constants

BasicStruct
CONST_BITMASK
PACKSIZE_BITMASK
PACKSIZE_NOTDEFINE

Public Class Methods

new(offset, name, vector, type, flags = 0 | PACKSIZE_NOTDEFINE) click to toggle source
Calls superclass method
# File lib/gogyou/model.rb, line 86
def initialize(offset, name, vector, type, flags = 0 | PACKSIZE_NOTDEFINE)
  super(offset, name, vector, type, flags)
end

Public Instance Methods

bytesize() click to toggle source
# File lib/gogyou/model.rb, line 98
def bytesize
  s = type.bytesize
  vector ? vector.inject(&:*) * s : s
end
const?() click to toggle source
# File lib/gogyou/model.rb, line 103
def const?
  ((flags & CONST_BITMASK) == CONST_BITMASK) ? true : false
end
extensible?() click to toggle source
# File lib/gogyou/model.rb, line 90
def extensible?
  if vector
    vector[-1] == 0 ? true : false
  else
    type.extensible?
  end
end
inspect()
Alias for: to_s
packed?() click to toggle source
# File lib/gogyou/model.rb, line 107
def packed?
  ((flags & PACKSIZE_BITMASK) == PACKSIZE_NOTDEFINE) ? false : true
end
packsize() click to toggle source
# File lib/gogyou/model.rb, line 122
def packsize
  1 << flags.getbit(0, 8)
end
pretty_print(q) click to toggle source
# File lib/gogyou/model.rb, line 144
def pretty_print(q)
  q.group(1, "#{self.class}[") do
    #q.breakable
    q.text "offset="
    q.pp offset
    q.text ", "
    #q.breakable
    q.text "name="
    q.pp name
    q.text ", "
    #q.breakable
    q.text "vector="
    q.pp vector
    q.text ", "
    #q.breakable
    q.text "flags=0x%02x%s" % [flags, strflags_with_paren]
    q.text ","
    q.breakable(" ")
    q.text "type="
    q.pp type
  end
  q.text "]"
end
set_const() click to toggle source
# File lib/gogyou/model.rb, line 111
def set_const
  self.flags |= CONST_BITMASK
  self
end
set_packsize(pack_exponent) click to toggle source
# File lib/gogyou/model.rb, line 116
def set_packsize(pack_exponent)
  pack_exponent = PACKSIZE_NOTDEFINE if pack_exponent > PACKSIZE_NOTDEFINE
  self.flags = flags.setbit(0, 8, pack_exponent)
  self
end
strflags() click to toggle source
# File lib/gogyou/model.rb, line 126
def strflags
  set = [const? ? "const" : nil, packed? ? "packed(#{packsize})" : nil]
  set.compact!
  return nil if set.empty?
  set.join(",")
end
strflags_with_paren() click to toggle source
# File lib/gogyou/model.rb, line 133
def strflags_with_paren
  set = strflags
  set ? "(#{set})" : ""
end
to_s() click to toggle source
# File lib/gogyou/model.rb, line 138
def to_s
  "#{self.class}[offset=#{offset.inspect}, name=#{name.inspect}, vector=#{vector.inspect}, type=#{type.inspect}, flags=0x#{flags.to_s(16)}#{strflags_with_paren}]"
end
Also aliased as: inspect