From fc8de10964baa41dd1d0547c73b07353efa61e4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20R=C3=BCger?= Date: Mon, 9 Sep 2019 11:54:45 +0300 Subject: [PATCH] remove parfait module magic since we are now ruby sorcerers, not just wizards, we remove the Parfait module in the compiler (Still have to avoid the name clashes) --- lib/parfait.rb | 8 ++++---- lib/parfait/data_object.rb | 2 ++ lib/parfait/factory.rb | 29 ++++++++++++++++------------- lib/parfait/integer.rb | 2 ++ lib/parfait/object.rb | 3 ++- 5 files changed, 26 insertions(+), 18 deletions(-) diff --git a/lib/parfait.rb b/lib/parfait.rb index 381efd5e..ba1c6a81 100644 --- a/lib/parfait.rb +++ b/lib/parfait.rb @@ -20,12 +20,12 @@ module Parfait end end - ["object" , "data_object","integer","factory" ].each do |file_name| - path = File.expand_path( "../parfait/#{file_name}.rb" , __FILE__) - module_eval( File.read path) - end end +require_relative "parfait/object" +require_relative "parfait/data_object" +require_relative "parfait/integer" +require_relative "parfait/factory" require_relative "parfait/behaviour" require_relative "parfait/class" require_relative "parfait/meta_class" diff --git a/lib/parfait/data_object.rb b/lib/parfait/data_object.rb index 5cca15ca..9944ddc3 100644 --- a/lib/parfait/data_object.rb +++ b/lib/parfait/data_object.rb @@ -19,6 +19,7 @@ # DataObjects still have a type, and so can have objects before the data starts # # A marker class +module Parfait class DataObject < Object def self.type_length @@ -52,3 +53,4 @@ 32 end end +end diff --git a/lib/parfait/factory.rb b/lib/parfait/factory.rb index a38449ad..86c3b417 100644 --- a/lib/parfait/factory.rb +++ b/lib/parfait/factory.rb @@ -1,16 +1,18 @@ - # A factory has the one job of handing out new instances - # - # A factory is for a specific type (currently, may change by size at some point) - # - # get_next_object is the main entry point, all other functions help to get more - # memory and objects as needed - # - # A factory keeps a reserve, and in case the freelist is empty, switches that in _immediately - # This is especially useful for messages, that can then be used even they run out. - # - # The idea (especially for messages) is to call out from the MessageSetup to the - # factory when the next (not current) is nil. - # This is btw just as easy a check, as the next needs to be gotten to swap the list. +# A factory has the one job of handing out new instances +# +# A factory is for a specific type (currently, may change by size at some point) +# +# get_next_object is the main entry point, all other functions help to get more +# memory and objects as needed +# +# A factory keeps a reserve, and in case the freelist is empty, switches that in _immediately +# This is especially useful for messages, that can then be used even they run out. +# +# The idea (especially for messages) is to call out from the MessageSetup to the +# factory when the next (not current) is nil. +# This is btw just as easy a check, as the next needs to be gotten to swap the list. + +module Parfait class Factory < Object attr :type , :for_type , :next_object , :reserve , :attribute_name , :page_size @@ -113,3 +115,4 @@ obj end end +end diff --git a/lib/parfait/integer.rb b/lib/parfait/integer.rb index 6783db61..550abf45 100644 --- a/lib/parfait/integer.rb +++ b/lib/parfait/integer.rb @@ -3,6 +3,7 @@ # - they have fixed value # - they are immutable fo rthe most part (or to the user) # +module Parfait class Integer < Data4 attr :type, :next_integer @@ -90,3 +91,4 @@ 1 # 0 type end end +end diff --git a/lib/parfait/object.rb b/lib/parfait/object.rb index 4b26fd42..2865c15a 100644 --- a/lib/parfait/object.rb +++ b/lib/parfait/object.rb @@ -12,7 +12,7 @@ # The Type also defines the class of the object # The Type is **always** the first entry (index 0) in an object - +module Parfait class Object attr :type @@ -99,3 +99,4 @@ end end +end