[Ruby] RubyInline
3.8.3が公開されました。(ruby-talk:343455)。
Ruby スクリプトに他の言語を埋め込むためのライブラリ。
Cレベルの static 変数を定義するためのメソッド Inline::C#add_static が追加されました。
Inline::C#add_static を試してみた。
$ sudo gem install RubyInline
$ cat hello.rb
require 'inline'
class Hello
inline do |builder|
builder.add_static("HStr", 'rb_str_new2("hello world")');
# ->
# static VALUE HStr;
# HStr = rb_str_new2("hello world");
builder.c 'VALUE hello() {return HStr;}'
end
end
puts Hello.new.hello
$ ruby hello.rb
hello world
ということで、1.9.2dev でも使えました。
| 固定リンク
この記事へのコメントは終了しました。
コメント