Class: FFI::StructGenerator::Field

Inherits:
Object
  • Object
show all
Defined in:
lib/ffi/tools/struct_generator.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.



172
173
174
175
176
177
# File 'lib/ffi/tools/struct_generator.rb', line 172

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

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



167
168
169
# File 'lib/ffi/tools/struct_generator.rb', line 167

def name
  @name
end

#offsetObject

Returns the value of attribute offset.



169
170
171
# File 'lib/ffi/tools/struct_generator.rb', line 169

def offset
  @offset
end

#sizeObject

Returns the value of attribute size.



170
171
172
# File 'lib/ffi/tools/struct_generator.rb', line 170

def size
  @size
end

#typeObject (readonly)

Returns the value of attribute type.



168
169
170
# File 'lib/ffi/tools/struct_generator.rb', line 168

def type
  @type
end

Instance Method Details

#to_config(name) ⇒ Object



183
184
185
186
187
188
189
# File 'lib/ffi/tools/struct_generator.rb', line 183

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