Created
May 19, 2009 20:35
-
-
Save albanpeignier/114378 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 'rubygems' | |
require 'ffi' | |
pointer = FFI::MemoryPointer.new(:char, 3) | |
puts "pointer: #{pointer.inspect} (#{pointer.type_size})" | |
# => pointer: #<MemoryPointer address=0x1713e50 size=3> (1) | |
first = pointer + pointer.type_size | |
puts "first: #{first.inspect}" | |
# => first: #<Native Pointer address=0x1713e51> | |
second = first + pointer.type_size | |
puts "second: #{second.inspect}" | |
# => second: #<Native Pointer address=0x1713e52> | |
first = pointer[1] | |
puts "first: #{first.inspect}" | |
# => first: #<Native Pointer address=0x1713e51> | |
second = first[1] | |
puts "second: #{second.inspect}" | |
# => test_plus.rb:16: undefined method `[]' for #<Native Pointer address=0x1713e51> (NoMethodError) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment