http://rubyforge.org/frs/?group_id=4845&release_id=16367
- スタックがずれていたのを修正。
- コルーチンの呼び出しに対応。
- method_missingを実装。
require 'rua' error_handler = lambda do |e| p e end rua = Rua.new(error_handler) rua.openlibs(:all) #rua.openlibs(:base, :package, :string) #rua.secure = false rua.str = 'xxx' rua.num = 100 rua.proc = lambda do puts 'proc called.' end rua.err = lambda do raise 'err called.' end rua.Time = Time puts rua.eval(<<-EOS) print('hello Rua!') print(str) print(num) proc() err() print(Time.new().to_s()) f = function() print('f() called.') end return true EOS rua.f.call p rua.eval('return 1, 2, 3') co = rua.eval(<<-EOS) function foo (a) print('foo', a) return coroutine.yield(2 * a) end return coroutine.create(function (a, b) print('co-body', a, b) local r = foo(a + 1) print('co-body', r) local r, s = coroutine.yield(a + b, a - b) print('co-body', r, s) return b, 'end' end) EOS p co.resume(1, 10) p co.resume('r') p co.resume('x', 'y') p co.resume('x', 'y')