Class: Emfsvg::ObjectTable

Inherits:
Object
  • Object
show all
Defined in:
lib/emfsvg/object_table.rb

Overview

1-indexed GDI object table (matches EMF's handle numbering). SELECTOBJECT copies from the table into the current DeviceContext. DELETEOBJECT removes the slot.

Defined Under Namespace

Classes: Entry

Instance Method Summary collapse

Constructor Details

#initializeObjectTable

Returns a new instance of ObjectTable.



22
23
24
# File 'lib/emfsvg/object_table.rb', line 22

def initialize
  @entries = [] # 0-indexed internally; EMF indices are 1-based
end

Instance Method Details

#delete(index) ⇒ Object



35
36
37
# File 'lib/emfsvg/object_table.rb', line 35

def delete(index)
  @entries[index - 1] = nil
end

#lookup(index) ⇒ Object



31
32
33
# File 'lib/emfsvg/object_table.rb', line 31

def lookup(index)
  @entries[index - 1]
end

#sizeObject



39
40
41
# File 'lib/emfsvg/object_table.rb', line 39

def size
  @entries.compact.size
end

#store(index, type, object) ⇒ Object



26
27
28
29
# File 'lib/emfsvg/object_table.rb', line 26

def store(index, type, object)
  ensure_capacity(index)
  @entries[index - 1] = Entry.new(type: type, object: object)
end