Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Use extend Lua using Ruby with MRuby

branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

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.