small rename and new test for layout

This commit is contained in:
Torsten Ruger
2015-08-08 18:08:47 +03:00
parent 0a54d030b5
commit 5d838056fa
4 changed files with 44 additions and 12 deletions

View File

@ -60,12 +60,18 @@ module Parfait
names
end
alias :list_index :index_of
# private inheritance is something to think off, we don't really want the list api exported
def index_of name
raise "should not rely on layout internal structure, use variable_index"
end
# index of a variable name into the layout.
# layout is a list, so lowest index is 1
# :layout is a variable for every object, so 1 is taken for :layout
# still, the index is the same.
def variable_index name
index_of(name)
list_index(name)
end
def sof_reference_name

View File

@ -98,7 +98,7 @@ module Register
real_name = clazz_name.to_s.split('_').last.capitalize.to_sym
clazz = Parfait::Space.object_space.get_class_by_name(real_name)
raise "Class name not given #{real_name}" unless clazz
index = clazz.object_layout.index_of( instance_name )
index = clazz.object_layout.variable_index( instance_name )
raise "Instance name=#{instance_name} not found on #{real_name}" unless index.is_a?(Numeric)
return index # the type word is at index 0, but layout is a list and starts at 1 == layout
end