ri > FFI::Generator

= FFI::Generator < Object

(from /home/chedong/.local/share/rdoc)
------------------------------------------------------------------------
Generate files with C structs for FFI::Struct and C constants.

== A simple example

In file zlib.rb.ffi:
  module Zlib
    @@@
    constants do |c|
      c.include "zlib.h"
      c.const :ZLIB_VERNUM
    end
    @@@

    class ZStream < FFI::Struct

      struct do |s|
        s.name "struct z_stream_s"
        s.include "zlib.h"

        s.field :next_in,   :pointer
        s.field :avail_in,  :uint
        s.field :total_in,  :ulong
      end
      @@@
    end
  end

Translate the file:
  require "ffi/tools/generator"
  FFI::Generator.new "zlib.rb.ffi", "zlib.rb"

Generates the file zlib.rb with constant values and offsets:
  module Zlib
  ZLIB_VERNUM = 4784

  class ZStream < FFI::Struct
    layout :next_in, :pointer, 0,
           :avail_in, :uint, 8,
           :total_in, :ulong, 16
  end

@see FFI::Generator::Task for easy integration in a Rakefile
------------------------------------------------------------------------
= Class methods:

  new

= Instance methods:

  constants
  struct
  to_s

Generated by phpman v4.9.26-1-g511901d · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-07-29 18:39 @216.73.216.177
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Valid XHTML 1.0 Transitional!Valid CSS!