class Blender3d::PointerType

Attributes

type[R]

Public Class Methods

new(type) click to toggle source
# File lib/blender-3d/types/pointer_type.rb, line 5
def initialize(type)
  @type = type
end

Public Instance Methods

inspect() click to toggle source
# File lib/blender-3d/types/pointer_type.rb, line 13
def inspect
  "#{@type.inspect}*"
end
read(reader) click to toggle source
# File lib/blender-3d/types/pointer_type.rb, line 17
def read(reader)
  pointer = Pointer.new(reader.read_pointer)

  model = reader.model
  block = model.pointers[pointer]
  if block && block.data.is_a?(String) && !block.type
    block.type = get_type(block, model)
    block.parse_data(reader.model) unless block.type.is_a?(SimpleType) && block.type.name == 'void'
  end

  pointer
end
to_s() click to toggle source
# File lib/blender-3d/types/pointer_type.rb, line 9
def to_s
  "Pointer(#@type)"
end

Private Instance Methods

get_size(model) click to toggle source
# File lib/blender-3d/types/pointer_type.rb, line 39
def get_size(model)
  if @type.is_a?(PointerType)
    model.header.pointer_size
  else
    model.dna_block.data.types.find { |type, _| type == @type.name }.last
  end
end
get_type(block, model) click to toggle source
# File lib/blender-3d/types/pointer_type.rb, line 32
def get_type(block, model)
  return @type if block.count > 1
  size = get_size(model)
  return @type unless size > 0 && block.size > size && block.size % size == 0
  ArrayType.new(@type, block.size / size)
end