Created
June 2, 2015 21:09
-
-
Save fcheung/1d525c097e6e520bc039 to your computer and use it in GitHub Desktop.
binding from inside c method
This file contains 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
gem 'RubyInline' | |
require 'inline' | |
class Test | |
inline do |builder| | |
builder.include "<time.h>" | |
builder.c_raw <<-SRC, :arity => 1 | |
VALUE dummy(VALUE self, VALUE arg){ | |
VALUE ret = rb_funcall(self, rb_intern("binding"), 0); | |
return ret; | |
} | |
SRC | |
end | |
end | |
binding_from_method = Test.new.dummy(123) | |
puts binding_from_method.local_variables.inspect |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment