mruby-enumerator: remove internal attribute methods; ref #6068

Removed methods: obj, args, kwd, meth, fib.
This commit is contained in:
Yukihiro "Matz" Matsumoto
2023-09-30 23:28:01 +09:00
parent 298155d59e
commit 735fa246bf
2 changed files with 20 additions and 13 deletions
+6 -3
View File
@@ -47,9 +47,12 @@ class Enumerator
raise ArgumentError, "undefined method #{meth}"
end
lz = Lazy.new(self, &block)
lz.obj = self
lz.meth = meth
lz.args = args
obj = self
lz.instance_eval {
@obj = obj
@meth = meth
@args = args
}
lz
end
alias enum_for to_enum
+14 -10
View File
@@ -132,16 +132,20 @@ class Enumerator
@stop_exc = false
end
attr_accessor :obj, :meth, :args, :kwd
attr_reader :fib
def initialize_copy(obj)
raise TypeError, "can't copy type #{obj.class}" unless obj.kind_of? Enumerator
raise TypeError, "can't copy execution context" if obj.fib
@obj = obj.obj
@meth = obj.meth
@args = obj.args
@kwd = obj.kwd
raise TypeError, "can't copy execution context" if obj.instance_eval{@fib}
meth = args = kwd = fib = nil
obj.instance_eval {
obj = @obj
meth = @meth
args = @args
kwd = @kwd
}
@obj = obj
@meth = meth
@args = args
@kwd = kwd
@fib = nil
@lookahead = nil
@feedvalue = nil
@@ -274,14 +278,14 @@ class Enumerator
obj = self
if 0 < argv.length
obj = self.dup
args = obj.args
args = obj.instance_eval{@args}
if !args.empty?
args = args.dup
args.concat argv
else
args = argv.dup
end
obj.args = args
obj.instance_eval{@args = args}
end
return obj unless block
enumerator_block_call(&block)