class FFI::Struct
Constants
- TypeMap
Public Class Methods
by_ref(flags = :inout)
click to toggle source
# File lib/ffi-compiler/fake_ffi/ffi.rb, line 277 def self.by_ref(flags = :inout) self.ptr(flags) end
by_value()
click to toggle source
# File lib/ffi-compiler/fake_ffi/ffi.rb, line 273 def self.by_value self.val end
callback(params, ret)
click to toggle source
# File lib/ffi-compiler/fake_ffi/ffi.rb, line 241 def self.callback(params, ret) FFI::CallbackInfo.new(find_type(ret), params.map { |e| find_type(e) }) end
find_type(type)
click to toggle source
# File lib/ffi-compiler/fake_ffi/ffi.rb, line 246 def self.find_type(type) t = TypeMap[type] return t unless t.nil? if type.is_a?(Class) && type < Struct return TypeMap[type] = StructByValue.new(type) end TypeMap[type] = FFI.find_type(type) end
in()
click to toggle source
# File lib/ffi-compiler/fake_ffi/ffi.rb, line 257 def self.in ptr(:in) end
layout(*args)
click to toggle source
# File lib/ffi-compiler/fake_ffi/ffi.rb, line 207 def self.layout(*args) return if args.size.zero? fields = [] if args.first.kind_of?(Hash) args.first.each do |name, type| fields << { :name => name, :type => find_type(type), :offset => nil } end else i = 0 while i < args.size name, type, offset = args[i], args[i+1], nil i += 2 if args[i].kind_of?(Integer) offset = args[i] i += 1 end fields << { :name => name, :type => find_type(type), :offset => offset } end end FFI.exporter.struct(self.to_s, fields) end
new()
click to toggle source
# File lib/ffi-compiler/fake_ffi/ffi.rb, line 229 def initialize @data = {} end
out()
click to toggle source
# File lib/ffi-compiler/fake_ffi/ffi.rb, line 261 def self.out ptr(:out) end
ptr(flags = :inout)
click to toggle source
# File lib/ffi-compiler/fake_ffi/ffi.rb, line 265 def self.ptr(flags = :inout) StructByReference.new(self) end
val()
click to toggle source
# File lib/ffi-compiler/fake_ffi/ffi.rb, line 269 def self.val StructByValue.new(self) end
Public Instance Methods
[](name)
click to toggle source
# File lib/ffi-compiler/fake_ffi/ffi.rb, line 233 def [](name) @data[name] end
[]=(name, value)
click to toggle source
# File lib/ffi-compiler/fake_ffi/ffi.rb, line 237 def []=(name, value) @data[name] = value end