Skip to content

ppibburr/crystal-mruby-gobject

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

mruby bindings for crystal

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published