make frame and message indexed
also auto generate a replacement for previous offset class method (dry)
This commit is contained in:
@ -19,9 +19,8 @@ module Parfait
|
||||
class Frame < Object
|
||||
attribute :next_frame
|
||||
|
||||
def self.offset
|
||||
1 + Space.object_space.get_class_by_name(:Frame).object_layout.instance_length
|
||||
end
|
||||
include Indexed
|
||||
self.offset(2) # 1 == the next_frame attributes above + layout. (indexed_length gets added)
|
||||
|
||||
end
|
||||
end
|
||||
|
@ -139,6 +139,14 @@ module Parfait
|
||||
def offset( offset )
|
||||
offset += 1 # for the attribute we add (indexed_length)
|
||||
|
||||
# define methods on the class that includes.
|
||||
# weird syntax, but at least it's possible
|
||||
(class << self;self;end).send :define_method , :get_length_index do
|
||||
offset
|
||||
end
|
||||
(class << self;self;end).send :define_method , :get_indexed do |index|
|
||||
offset + index
|
||||
end
|
||||
define_method :get_offset do
|
||||
offset
|
||||
end
|
||||
|
@ -9,8 +9,11 @@
|
||||
|
||||
module Parfait
|
||||
class Message < Object
|
||||
attributes [:next_message , :frame, :caller]
|
||||
attributes [:receiver , :return_address , :return_value , :name]
|
||||
attributes [:next_message , :receiver , :frame , :return_address ]
|
||||
attributes [:return_value, :caller , :name ]
|
||||
|
||||
include Indexed
|
||||
self.offset(8) # 8 == the seven attributes above + layout. (indexed_length gets added)
|
||||
|
||||
def initialize next_m
|
||||
self.next_message = next_m
|
||||
@ -28,9 +31,5 @@ module Parfait
|
||||
index = @layout.get_index(name)
|
||||
get_at(index)
|
||||
end
|
||||
|
||||
def self.offset
|
||||
1 + Space.object_space.get_class_by_name(:Message).object_layout.instance_length
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user