diff options
author | Brandon Fosdick <bfoz@bfoz.net> | 2015-01-26 15:39:16 -0800 |
---|---|---|
committer | Brandon Fosdick <bfoz@bfoz.net> | 2015-01-26 15:39:16 -0800 |
commit | d409ba50f20338a73a8cc915062610aefe6ddba9 (patch) | |
tree | 8f2cc921e72d07651b42d39b6ce8a9930c5a0ccd | |
parent | 262fd7935ed82796cf6539a9b66966cfc85af7e1 (diff) | |
download | ffi-d409ba50f20338a73a8cc915062610aefe6ddba9.tar.gz |
Added an example for structures containing pointers to functions
Some libraries emulate a class hierarchy using structures full of pointers to functions
-rw-r--r-- | lib/ffi/struct.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/ffi/struct.rb b/lib/ffi/struct.rb index c699e0b..599ee9b 100644 --- a/lib/ffi/struct.rb +++ b/lib/ffi/struct.rb @@ -256,6 +256,12 @@ module FFI # :field2 => :pointer, # :field3 => :string # end + # @example Creating a layout with pointers to functions + # class MyFunctionTable < Struct + # layout :function1, callback([:int, :int], :int), + # :function2, callback([:pointer], :void), + # :field3, :string + # end # @note Creating a layout from a hash +spec+ is supported only for Ruby 1.9. def layout(*spec) #raise RuntimeError, "struct layout already defined for #{self.inspect}" if defined?(@layout) |