Last active
August 29, 2015 14:24
-
-
Save mfpiccolo/19556ec31d0decf9c8f8 to your computer and use it in GitHub Desktop.
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
require 'ffi' | |
module Scrape | |
extend FFI::Library | |
ffi_lib './target/debug/libscrape.dylib' | |
class TwoNumbers < FFI::Struct | |
layout :first, :int32, | |
:second, :int32 | |
end | |
attach_function :add_struct_vals, [TwoNumbers.by_value], :int32 | |
end | |
tn = Scrape::TwoNumbers.new | |
tn[:first] = 10 | |
tn[:second] = 20 | |
puts Scrape.add_struct_vals(tn) == 30 ? "Gone Dun It!" : "Uhhhh????" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment