Created
June 18, 2013 08:52
-
-
Save waynerobinson/5803743 to your computer and use it in GitHub Desktop.
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
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