123456789_123456789_123456789_123456789_123456789_

Class: FFI::StructGenerator::Field

Relationships & Source Files
Inherits: Object
Defined in: lib/ffi/tools/struct_generator.rb

Overview

A field in a ::FFI::Struct.

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(name, type) ⇒ Field

[ GitHub ]

  
# 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

#name (readonly)

[ GitHub ]

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

attr_reader :name

#offset (rw)

[ GitHub ]

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

attr_reader :offset

#offset=(o) (rw)

[ GitHub ]

  
# File 'lib/ffi/tools/struct_generator.rb', line 180

def offset=(o)
  @offset = o
end

#size (rw)

[ GitHub ]

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

attr_accessor :size

#type (readonly)

[ GitHub ]

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

attr_reader :type

Instance Method Details

#to_config(name)

[ GitHub ]

  
# 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