Created
January 14, 2013 20:11
-
-
Save benolee/4532938 to your computer and use it in GitHub Desktop.
playing with Fiddle::Function
This file contains hidden or 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
| >> require 'fiddle' | |
| => true | |
| >> func = Fiddle::Function.new(DL::Handle::DEFAULT['rb_eval_string'], [DL::TYPE_VOIDP], DL::TYPE_VOIDP) | |
| => #<Fiddle::Function:0x000001010404c8> | |
| >> func.call("1 + 1") | |
| => #<DL::CPtr:0x00000101821930 ptr=0x00000000000005 size=0 free=0x00000000000000> | |
| >> func.call("1 + 1").to_value | |
| => 2 | |
| >> func.call("puts 'hello'").to_value | |
| hello | |
| => nil |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment