add a each_pair to indexed and use in types
This commit is contained in:
@ -103,8 +103,6 @@ module Parfait
|
||||
end
|
||||
|
||||
def each
|
||||
# not sure how to do this with define_method, because of the double block issue.
|
||||
# probably some clever way around that, but not important
|
||||
index = 1
|
||||
while index <= self.get_length
|
||||
item = get(index)
|
||||
@ -114,6 +112,17 @@ module Parfait
|
||||
self
|
||||
end
|
||||
|
||||
def each_pair
|
||||
index = 1
|
||||
while index <= self.get_length
|
||||
key = get( index )
|
||||
value = get(index + 1)
|
||||
yield key , value
|
||||
index = index + 2
|
||||
end
|
||||
self
|
||||
end
|
||||
|
||||
def set_length len
|
||||
was = self.get_length
|
||||
return if was == len
|
||||
|
@ -46,6 +46,7 @@ module Parfait
|
||||
def get_internal_word(index)
|
||||
@memory[index]
|
||||
end
|
||||
|
||||
# 1 -based index
|
||||
def set_internal_word(index , value)
|
||||
raise "failed init for #{self.class}" unless @memory
|
||||
@ -132,6 +133,7 @@ module Parfait
|
||||
def instance_variables
|
||||
get_instance_variables.to_a.collect{ |n| "@#{n}".to_sym }
|
||||
end
|
||||
|
||||
# name comes in as a ruby @var name
|
||||
def instance_variable_get name
|
||||
var = get_instance_variable name.to_s[1 .. -1].to_sym
|
||||
|
@ -66,10 +66,8 @@ module Parfait
|
||||
|
||||
def instance_names
|
||||
names = List.new
|
||||
name = true
|
||||
each do |item|
|
||||
names.push(item) if name
|
||||
name = ! name
|
||||
each_pair do |name , type|
|
||||
names.push(name)
|
||||
end
|
||||
names
|
||||
end
|
||||
@ -110,5 +108,8 @@ module Parfait
|
||||
nil # stop resolve recursing up metaclasses
|
||||
end
|
||||
|
||||
def hash
|
||||
h = name.hash
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user