Skip to content

Instantly share code, notes, and snippets.

@kbrock
Forked from havenwood/hello.cr
Last active September 8, 2015 15:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kbrock/3be56968ebc22ce6c585 to your computer and use it in GitHub Desktop.
Save kbrock/3be56968ebc22ce6c585 to your computer and use it in GitHub Desktop.
"Hello, world!" from MRuby embedded in Crystal
export MRUBY_HOME=/opt/rubies/mruby-20150906
crystal run --link-flags -L${MRUBY_HOME}/lib/ hello.cr
@[Link("mruby")]
lib MRuby
type MRubyState = Void*
fun open = mrb_open : MRubyState
fun load_string = mrb_load_string(mrb : MRubyState, code : Pointer(UInt8))
fun close = mrb_close(mrb : MRubyState)
end
CODE = <<-RUBY_CODE
puts 'Hello, world!'
RUBY_CODE
MRB = MRuby.open
MRuby.load_string MRB, CODE
MRuby.close MRB
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment