fixing indexed stuff

layout returns layout as first name (offsets indexes)
object internal length is gone  into layouts functionality
This commit is contained in:
Torsten Ruger
2015-10-26 12:22:32 +02:00
parent bb3d211c04
commit 979ebb7612
8 changed files with 28 additions and 36 deletions

View File

@ -69,7 +69,6 @@ module Parfait
found = get_instance_method( method.name )
if found
self.instance_methods.delete(found)
#raise "existed in #{self.name} #{Sof.write found.source.blocks}"
end
self.instance_methods.push method
#puts "#{self.name} add #{method.name}"
@ -104,7 +103,7 @@ module Parfait
def super_class
Parfait::Space.object_space.get_class_by_name(self.super_class_name)
end
def get_instance_method fname
raise "get_instance_method #{fname}.#{fname.class}" unless fname.is_a?(Symbol)
#if we had a hash this would be easier. Detect or find would help too

View File

@ -26,6 +26,7 @@ module Parfait
# return nil if no such item
def index_of item
max = self.get_length
#puts "length #{max} #{max.class}"
counter = 1
while( counter <= max )
if( get(counter) == item)
@ -103,7 +104,7 @@ module Parfait
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 + get_offset
index = 1
while index <= self.get_length
item = get(index)
yield item
@ -175,7 +176,7 @@ module Parfait
raise "Only positive lenths, #{len}" if len < 0
old_length = self.get_length
return if old_length >= len
raise "bounds error at #{len}" if( len + offset > 16 )
# raise "bounds error at #{len}" if( len + offset > 16 )
# be nice to use the indexed_length , but that relies on booted space
internal_object_set( offset + 1 , len) #one for layout
end

View File

@ -22,11 +22,11 @@
module Parfait
class Layout < Object
include Indexed
self.offset(0)
attribute :object_class
include Indexed
self.offset(2)
def initialize( object_class )
super()
self.object_class = object_class
@ -43,24 +43,20 @@ module Parfait
# TODO , later we would need to COPY the layout to keep the old constant
# but now we are concerned with booting, ie getting a working structure
def add_instance_variable name
self.push(1) if self.get_length == 0
self.push(name)
self.get_length
end
def object_instance_names
names = List.new
index = 3
while index <= self.get_length
item = get(index)
each do |item|
names.push item
index = index + 1
end
names
end
def object_instance_length
self.get_length - 2
self.get_length
end
alias :list_index :index_of
@ -74,8 +70,8 @@ module Parfait
def variable_index name
has = list_index(name)
return nil unless has
raise "internal error #{name}:#{has}" if has < 2
has - 1
raise "internal error #{name}:#{has}" if has < 1
has
end
def inspect