mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
mruby-enumerator: remove internal attribute methods; ref #6068
Removed methods: obj, args, kwd, meth, fib.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user