Class FFI::StructGenerator
In: lib/ffi/tools/struct_generator.rb
Parent: Object

Generates an FFI Struct layout.

Given the @@@ portion in:

  module Zlib::ZStream < FFI::Struct
    @@@
    name "struct z_stream_s"
    include "zlib.h"

    field :next_in,   :pointer
    field :avail_in,  :uint
    field :total_in,  :ulong

    # ...
    @@@
  end

StructGenerator will create the layout:

  layout :next_in, :pointer, 0,
         :avail_in, :uint, 4,
         :total_in, :ulong, 8,
         # ...

StructGenerator does its best to pad the layout it produces to preserve line numbers. Place the struct definition as close to the top of the file for best results.

Methods

calculate   dump_config   field   found?   generate_layout   get_field   include   name   new   options   options=  

Classes and Modules

Class FFI::StructGenerator::Field

Attributes

fields  [R] 
size  [RW] 

Public Class methods

Public Instance methods

[Validate]