Skip to content

Instantly share code, notes, and snippets.

@waynerobinson
Created June 18, 2013 08:52
Show Gist options
  • Save waynerobinson/5803743 to your computer and use it in GitHub Desktop.
Save waynerobinson/5803743 to your computer and use it in GitHub Desktop.
class SomeMethod
extend FFI::Library
attach_function :cmethod, :pointer
def mystical_value=(value)
@value = FFI::MemoryPointer.new(:string, value)
cmethod(@value)
end
end
class MethodMethod2
extend FFI::Library
ffi_lib FFI::Library::LIBC
attach_function :malloc, [:size_t], :pointer
attach_function :cmethod, :pointer
def mystical_value=(value)
ptr = LibC.malloc(value.size)
ptr.write_string(value)
cmethod(ptr)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment