Class Factory

java.lang.Object
org.jruby.ext.ffi.Factory
Direct Known Subclasses:
Factory, NoImplFactory

public abstract class Factory extends Object
A factory that can create a FFI Provider
  • Constructor Details

    • Factory

      protected Factory()
  • Method Details

    • getInstance

      public static final Factory getInstance()
      Gets an instance of FFIProvider
      Returns:
      an instance of FFIProvider
    • init

      public void init(Ruby runtime, RubyModule FFI)
      Registers FFI ruby classes/modules
      Parameters:
      runtime - The ruby runtime
      FFI - the module to register the classes under
    • allocateDirectMemory

      public abstract MemoryIO allocateDirectMemory(Ruby runtime, int size, boolean clear)
      Allocates memory on the native C heap and wraps it in a MemoryIO accessor.
      Parameters:
      size - The number of bytes to allocate.
      clear - If the memory should be cleared.
      Returns:
      A new AllocatedDirectMemoryIO.
    • allocateDirectMemory

      public abstract MemoryIO allocateDirectMemory(Ruby runtime, int size, int align, boolean clear)
      Allocates memory on the native C heap and wraps it in a MemoryIO accessor.
      Parameters:
      size - The number of bytes to allocate.
      align - The minimum alignment of the memory
      clear - If the memory should be cleared.
      Returns:
      A new AllocatedDirectMemoryIO.
    • allocateTransientDirectMemory

      public abstract MemoryIO allocateTransientDirectMemory(Ruby runtime, int size, int align, boolean clear)
      Allocates transient native memory (not from C heap) and wraps it in a MemoryIO accessor.
      Parameters:
      size - The number of bytes to allocate.
      align - The minimum alignment of the memory
      clear - If the memory should be cleared.
      Returns:
      A new AllocatedDirectMemoryIO.
    • wrapDirectMemory

      public abstract MemoryIO wrapDirectMemory(Ruby runtime, long address)
      Wraps a native C memory address in a MemoryIO accessor.
      Parameters:
      address - The native address to wrap.
      Returns:
      A new MemoryIO.
    • getCallbackManager

      public abstract CallbackManager getCallbackManager()
    • newFunction

      public abstract AbstractInvoker newFunction(Ruby runtime, Pointer address, CallbackInfo cbInfo)
    • sizeOf

      public abstract int sizeOf(NativeType type)
    • alignmentOf

      public abstract int alignmentOf(NativeType type)