move to parfait members

This commit is contained in:
Torsten Ruger 2015-05-22 22:50:19 +03:00
parent b4eb14e639
commit b687255976

View File

@ -24,20 +24,28 @@ module Parfait
def initialize def initialize
super() super()
Parfait::Space.set_object_space self
@classes = Parfait::Dictionary.new_object @classes = Parfait::Dictionary.new_object
# this is like asking for troubles, but if the space instance is not registered
# and the @classes up, one can not register classes.
# all is good after this init
#global objects (data) #global objects (data)
@objects = [] @objects = Parfait::List.new_object
@symbols = [] #@symbols = Parfait::List.new_object
end
attr_reader :classes , :objects , :symbols, :messages, :next_message , :next_frame
@@SPACE = { :names => [:classes,:objects,:symbols,:messages, :next_message , :next_frame] ,
:types => [Virtual::Reference,Virtual::Reference,Virtual::Reference,Virtual::Reference,Virtual::Reference]}
# need a two phase init for the object space (and generally parfait) because the space
# is an interconnected graph, so not everthing is ready
def late_init
@frames = 100.times.collect{ ::Parfait::Frame.new([],[])} @frames = 100.times.collect{ ::Parfait::Frame.new([],[])}
@messages = 100.times.collect{ ::Parfait::Message.new } @messages = 100.times.collect{ ::Parfait::Message.new }
@next_message = @messages.first @next_message = @messages.first
@next_frame = @frames.first @next_frame = @frames.first
Parfait::Space.set_object_space self
end end
attr_reader :classes , :objects , :symbols,:messages, :next_message , :next_frame
@@SPACE = { :names => [:classes,:objects,:symbols,:messages, :next_message , :next_frame] ,
:types => [Virtual::Reference,Virtual::Reference,Virtual::Reference,Virtual::Reference,Virtual::Reference]}
def old_layout def old_layout
@@SPACE @@SPACE
end end
@ -49,13 +57,13 @@ module Parfait
end end
# TODO Must get rid of the setter # TODO Must get rid of the setter
def self.set_object_space space def self.set_object_space space
@@space = space @@object_space = space
end end
# Objects are data and get assembled after functions # Objects are data and get assembled after functions
def add_object o def add_object o
return if @objects.include?(o) return if @objects.include?(o)
@objects << o @objects.push o
if o.is_a? Symbol if o.is_a? Symbol
@symbols << o @symbols << o
end end