fix folded array bug by using object_id, fix ref bug but only counting first
This commit is contained in:
parent
9608e5f626
commit
0677069fc0
@ -14,15 +14,20 @@ module Sof
|
|||||||
|
|
||||||
def add object , level
|
def add object , level
|
||||||
return if is_value?(object)
|
return if is_value?(object)
|
||||||
if( occurence = @objects[object] )
|
if( occurence = @objects[object.object_id] )
|
||||||
#puts "reset level #{level} at #{occurence.level}"
|
#puts "reset level #{level} at #{occurence.level}"
|
||||||
occurence.level = level if occurence.level > level
|
if occurence.level > level
|
||||||
occurence.referenced = @counter
|
occurence.level = level
|
||||||
@counter = @counter + 1
|
end
|
||||||
|
unless occurence.referenced
|
||||||
|
#puts "referencing #{@counter} , at level #{level}/#{occurence.level} "
|
||||||
|
occurence.referenced = @counter
|
||||||
|
@counter = @counter + 1
|
||||||
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
o = Occurence.new( object , level )
|
o = Occurence.new( object , level )
|
||||||
@objects[object] = o
|
@objects[object.object_id] = o
|
||||||
attributes = attributes_for(object)
|
attributes = attributes_for(object)
|
||||||
attributes.each do |a|
|
attributes.each do |a|
|
||||||
val = get_value( object , a)
|
val = get_value( object , a)
|
||||||
|
@ -16,12 +16,13 @@ module Sof
|
|||||||
end
|
end
|
||||||
|
|
||||||
class SimpleNode < Node
|
class SimpleNode < Node
|
||||||
def initialize data
|
def initialize data , ref = nil
|
||||||
super(nil)
|
super(ref)
|
||||||
@data = data
|
@data = data
|
||||||
end
|
end
|
||||||
attr_reader :data
|
attr_reader :data
|
||||||
def out io , level
|
def out io , level
|
||||||
|
super
|
||||||
io.write(data)
|
io.write(data)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -16,10 +16,10 @@ module Sof
|
|||||||
if is_value?(object)
|
if is_value?(object)
|
||||||
return SimpleNode.new(object.to_sof())
|
return SimpleNode.new(object.to_sof())
|
||||||
end
|
end
|
||||||
occurence = @members.objects[object]
|
occurence = @members.objects[object.object_id]
|
||||||
raise "no object #{object}" unless occurence
|
raise "no object #{object}" unless occurence
|
||||||
if(level > occurence.level )
|
if(level > occurence.level )
|
||||||
#puts "level #{level} at #{occurence.level}"
|
#puts "ref #{occurence.referenced} level #{level} at #{occurence.level}"
|
||||||
return SimpleNode.new("*#{occurence.referenced}")
|
return SimpleNode.new("*#{occurence.referenced}")
|
||||||
end
|
end
|
||||||
ref = occurence.referenced
|
ref = occurence.referenced
|
||||||
@ -32,7 +32,7 @@ module Sof
|
|||||||
|
|
||||||
def object_sof_node( object , level , ref)
|
def object_sof_node( object , level , ref)
|
||||||
if( object.is_a? Class )
|
if( object.is_a? Class )
|
||||||
return SimpleNode.new( object.name )
|
return SimpleNode.new( object.name , ref )
|
||||||
end
|
end
|
||||||
head = object.class.name + "("
|
head = object.class.name + "("
|
||||||
atts = {}
|
atts = {}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user