Skip to content

Instantly share code, notes, and snippets.

@headius
Created August 28, 2012 05:41
Show Gist options
  • Save headius/3495252 to your computer and use it in GitHub Desktop.
Save headius/3495252 to your computer and use it in GitHub Desktop.
system ~/projects/talkfilters-2.3.8 $ cat talkfilters_ffi.rb
require 'ffi'
module TalkFilters
extend FFI::Library
ffi_lib 'talkfilters'
attach_function :gtf_filter_pirate, [:string, :pointer, :uint], :int
def self.pirate(input)
ptr = FFI::MemoryPointer.new(:pointer, input.size * 2)
output = gtf_filter_pirate(input, ptr, input.size * 2)
ptr.read_string
end
end
p TalkFilters.pirate ARGV[0]
system ~/projects/talkfilters-2.3.8 $ jruby talkfilters_ffi.rb "The quick brown fox jumped over the lazy dog."
"Th' quick brown fox jumped o'er th' lazy dog. Pass the grog!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment