mruby bindings for crystal
Install gobject-introspection
sudo apt-get install libgirepository1.0-dev
Clone and install mruby-vala:
git clone https://github.com/ppibburr/mruby-vala
cd mruby-vala
sudo make mruby
make
sudo make install
cd ..
alternatively mruby-vala
.debs provided here
git clone https://github.com/ppibburr/crystal-mruby-gobject
cd crystal-mruby-gobject
require "./libs/mruby-gobject/mruby"
mrb = MRuby::Context.new
mrb.define_method("add3", LibMRuby::FuncCB.new() {|ctx, mrb_self, _|
_mrb, this, args = MRuby.state(ctx, mrb_self)
_mrb.returns(MRuby.fixnum(args[0]) + 3)
}, nil)
mrb.define_method("concat_bar", LibMRuby::FuncCB.new() {|ctx, mrb_self, _|
_mrb, this, args = MRuby.state(ctx, mrb_self)
_mrb.returns(MRuby.string(args[0]) + "bar")
}, nil)
result = mrb.load_string("
puts concat_bar('foo')
p add3(3)
")
puts "\n"
pp result
pp MRuby.float result
pp MRuby.string result
pp MRuby.bool result