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.



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

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

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#offsetObject

Returns the value of attribute offset.



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

def offset
  @offset
end

#sizeObject

Returns the value of attribute size.



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

def size
  @size
end

#typeObject (readonly)

Returns the value of attribute type.



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

def type
  @type
end

Instance Method Details

#to_config(name) ⇒ Object



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

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