crystal-mruby-gobject
crystal-mruby-gobject
mruby bindings for crystal
Dependencies
Ubuntu:
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
Clone the repo
git clone https://github.com/ppibburr/crystal-mruby-gobject
cd crystal-mruby-gobject
Example
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
Repository
crystal-mruby-gobject
Owner
Statistic
- 10
- 1
- 0
- 0
- 1
- over 8 years ago
- April 19, 2016
License
Links
Synced at
Thu, 21 Nov 2024 19:46:23 GMT
Languages