Translate Lua functions to Ruby procs
norman opened this issue · 1 comments
norman commented
Currently ruby-lua exposes functions inside Lua tables as nil:
1.9.3p194 :006 > lua.var('string')
=> {"sub"=>nil, "upper"=>nil, "len"=>nil, "gfind"=>nil, "rep"=>nil, "find"=>nil, "match"=>nil, "char"=>nil, "dump"=>nil, "gmatch"=>nil, "reverse"=>nil, "byte"=>nil, "format"=>nil, "gsub"=>nil, "lower"=>nil}
1.9.3p194 :007 >
Is there some reasonably simple way to expose them, perhaps as Ruby procs which call the Lua function?
It would also be great to be able to call Lua functions from inside tables, to avoid having to export everything to a global:
1.9.3p194 :010 > lua.call(false, 'string.len', 'foo')
SystemCallError: unknown error - error running lua function `string.len': attempt to call a nil value
from (irb):10:in `call'
from (irb):10
from /Users/norman/.rvm/gems/ruby-1.9.3-p194-perf/gems/railties-3.2.6/lib/rails/commands/console.rb:47:in `start'
from /Users/norman/.rvm/gems/ruby-1.9.3-p194-perf/gems/railties-3.2.6/lib/rails/commands/console.rb:8:in `start'
from /Users/norman/.rvm/gems/ruby-1.9.3-p194-perf/gems/railties-3.2.6/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
norman commented
Awesome, thanks!