-
-
Save kbrock/3be56968ebc22ce6c585 to your computer and use it in GitHub Desktop.
"Hello, world!" from MRuby embedded in Crystal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export MRUBY_HOME=/opt/rubies/mruby-20150906 | |
crystal run --link-flags -L${MRUBY_HOME}/lib/ hello.cr |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@[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