Skip to content
Use extend Lua using Ruby with MRuby
C Ruby Lua
Latest commit 47ea62a Dec 24, 2012 @RyanScottLewis Update README.md
Failed to load latest commit information.
lib 0.1-0 release Dec 24, 2012
spec 0.1-0 release Dec 24, 2012
.gitmodules add Lua and MRuby submodules Dec 20, 2012
Makefile Makefile that simply calls Rakefile Dec 20, 2012
README.md Update README.md Dec 24, 2012
Rakefile Use Rake instead of Make Dec 19, 2012
mruby-0.1-0.rockspec 0.1-0 release Dec 24, 2012

README.md

lua-mruby

Use mruby from within lua.

Install

LuaRocks

NOTE: This is not implemented yet.

$ luarocks install mruby

Source

NOTE: If rake is not installed, you can use the minirake executable in lib/mruby/minirake/.
The Makefile simply calls rake.

$ rake

Or:

$ make

This will compile a mruby.so file in the pkg directory which you can simply require within Lua.

Usage

MRuby Table

The mruby table contains a few helper functions just for evaluating and running MRuby code.

run

The run function simply runs MRuby code. It returns a 0 if it ran without any exceptions raised and 1 if an exception was raised.

mruby.run(" puts 'Hello, World!' ") -- prints "Hello, World!"

eval

The eval function will evaluate MRuby code. The return value will converted into a Lua object.

print(
  mruby.eval(" 'Hello,' ").." World!"
) -- prints "Hello, World!"

print(
  mruby.eval(" 50 + 50 ") + 100
) -- prints 200

C Functions/Types

NOTE: This has not been implemented yet.

All MRuby C functions/types have been ported directly to Lua.
The name of the functions/types are identical to those of the C functions/types.

mrb_interpreter = mrb_open()
mrb_code = " puts 'Hello, World!' "
mrb_parser_state = mrb_parse_string(mrb_interpreter, mrb_code, nil)
mrb_generated_code = mrb_generate_code(mrb_interpreter, mrb_parser_state.tree)
mrb_result = mrb_run( mrb_interpreter, mrb_proc_new(mrb_interpreter, mrb_interpreter.irep[mrb_generated_code]), mrb_nil_value() )
mrb_close(mrb_interpreter)

Acknowlegements

matsumoto-r for mruby-on-Lua. This wouldn't exist, if not for him.

Copyright

Copyright © 2012-2013 Ryan Scott Lewis ryan@rynet.us.

The MIT License (MIT) - See LICENSE for further details.

Something went wrong with that request. Please try again.