Class: FFI::Generators::Structures::Field

Inherits:
Object
  • Object
show all
Defined in:
lib/ffi2/generators/structures.rb

Overview

A field in a Struct.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, type) ⇒ Field

Returns a new instance of Field.



44
45
46
47
48
49
# File 'lib/ffi2/generators/structures.rb', line 44

def initialize(name, type)
  @name = name
  @type = type
  @offset = nil
  @size = nil
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



39
40
41
# File 'lib/ffi2/generators/structures.rb', line 39

def name
  @name
end

#offsetObject

Returns the value of attribute offset.



41
42
43
# File 'lib/ffi2/generators/structures.rb', line 41

def offset
  @offset
end

#sizeObject

Returns the value of attribute size.



42
43
44
# File 'lib/ffi2/generators/structures.rb', line 42

def size
  @size
end

#typeObject (readonly)

Returns the value of attribute type.



40
41
42
# File 'lib/ffi2/generators/structures.rb', line 40

def type
  @type
end

Instance Method Details

#to_config(name) ⇒ Object



55
56
57
58
59
60
61
# File 'lib/ffi2/generators/structures.rb', line 55

def to_config(name)
  buf = []
  buf << "rbx.platform.#{name}.#{@name}.offset = #{@offset}"
  buf << "rbx.platform.#{name}.#{@name}.size = #{@size}"
  buf << "rbx.platform.#{name}.#{@name}.type = #{@type}" if @type
  buf
end