From 9bd2195a1595b4ce43f438123add5d17be3975e5 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Mon, 4 Mar 2019 19:56:53 +0200 Subject: [PATCH] use cattr instead of metaclass so we can catch it in the compiler, like also attr define cattr in adapter, no change in tests ! --- lib/parfait/factory.rb | 2 +- lib/risc/parfait_adapter.rb | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/parfait/factory.rb b/lib/parfait/factory.rb index 7d760d91..783c504e 100644 --- a/lib/parfait/factory.rb +++ b/lib/parfait/factory.rb @@ -16,7 +16,7 @@ @page_size = 1024 @reserve_size = 10 - class << self; attr_accessor :page_size ; attr :reserve_size end + cattr :page_size , :reserve_size # initialize for a given type (for_type). The attribute that is used to create the # list is the first that starts with next_ . "next" itself would have been nice and general diff --git a/lib/risc/parfait_adapter.rb b/lib/risc/parfait_adapter.rb index 154b8b7c..b22cee2a 100644 --- a/lib/risc/parfait_adapter.rb +++ b/lib/risc/parfait_adapter.rb @@ -54,6 +54,14 @@ module Parfait @memory._set(index , value) end end + + def self.cattr( *names ) + names.each do |ca| + class_eval "@@#{ca} = 0" + class_eval "def self.#{ca}; return @#{ca};end" + class_eval "def self.#{ca}=(val); @#{ca} = val;end" + end + end end # new list from ruby array to be precise