class FFI::Struct

Constants

TypeMap

Public Class Methods

by_ref() click to toggle source
# File lib/ffi-compiler/fake_ffi/ffi.rb, line 166
def self.by_ref
  StructByReference.new(self)
end
by_value() click to toggle source
# File lib/ffi-compiler/fake_ffi/ffi.rb, line 162
def self.by_value
  StructByValue.new(self)
end
find_type(type) click to toggle source
# File lib/ffi-compiler/fake_ffi/ffi.rb, line 151
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
layout(*args) click to toggle source
# File lib/ffi-compiler/fake_ffi/ffi.rb, line 140
def self.layout(*args)
  fields = []
  i = 0
  while i < args.length
    fields << { name: args[i], type: find_type(args[i+1]) }
    i += 2
  end
  FFI.exporter.struct(self.to_s, fields)
end