class Gogyou::Model::Array
C の配列を模造するクラス。
Public Instance Methods
aref(buffer, offset)
click to toggle source
# File lib/gogyou/model.rb, line 571 def aref(buffer, offset) raise NotImplementedError accessor = Accessor::Array[buffer, offset, self] accessor.instance_eval do field = fields[0] type = field.type elements = field.vector[-1] define_singleton_method(:check_index, ->(i) { i = i.to_i raise IndexError unless i >= 0 && (elements.nil? || i < elements) i }) define_singleton_method(:[], ->(i) { v = type.aref(buffer__GOGYOU__, offset__GOGYOU__ + type.bytesize * check_index(i)) v.infect_from(self, buffer) unless v.frozen? v.freeze if frozen? || buffer.frozen? || field.const? v }) define_singleton_method(:[]=, ->(i, v) { type.aset(buffer__GOGYOU__, offset__GOGYOU__ + type.bytesize * check_index(i), v) }) end accessor end
aset(buffer, offset, value)
click to toggle source
# File lib/gogyou/model.rb, line 567 def aset(buffer, offset, value) raise NotImplementedError end
extensible?()
click to toggle source
# File lib/gogyou/model.rb, line 563 def extensible? fields[-1] == 0 ? true : false end