Package org.jruby.ext.ffi
Class Factory
java.lang.Object
org.jruby.ext.ffi.Factory
- Direct Known Subclasses:
Factory,NoImplFactory
A factory that can create a FFI Provider
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract intalignmentOf(NativeType type) abstract MemoryIOallocateDirectMemory(Ruby runtime, int size, boolean clear) Allocates memory on the native C heap and wraps it in aMemoryIOaccessor.abstract MemoryIOallocateDirectMemory(Ruby runtime, int size, int align, boolean clear) Allocates memory on the native C heap and wraps it in aMemoryIOaccessor.abstract MemoryIOallocateTransientDirectMemory(Ruby runtime, int size, int align, boolean clear) Allocates transient native memory (not from C heap) and wraps it in aMemoryIOaccessor.abstract CallbackManagerstatic final FactoryGets an instance ofFFIProvidervoidinit(Ruby runtime, RubyModule FFI) Registers FFI ruby classes/modulesabstract AbstractInvokernewFunction(Ruby runtime, Pointer address, CallbackInfo cbInfo) abstract intsizeOf(NativeType type) abstract MemoryIOwrapDirectMemory(Ruby runtime, long address) Wraps a native C memory address in aMemoryIOaccessor.
-
Constructor Details
-
Factory
protected Factory()
-
-
Method Details
-
getInstance
Gets an instance ofFFIProvider- Returns:
- an instance of
FFIProvider
-
init
Registers FFI ruby classes/modules- Parameters:
runtime- The ruby runtimeFFI- the module to register the classes under
-
allocateDirectMemory
Allocates memory on the native C heap and wraps it in aMemoryIOaccessor.- Parameters:
size- The number of bytes to allocate.clear- If the memory should be cleared.- Returns:
- A new
AllocatedDirectMemoryIO.
-
allocateDirectMemory
Allocates memory on the native C heap and wraps it in aMemoryIOaccessor.- Parameters:
size- The number of bytes to allocate.align- The minimum alignment of the memoryclear- 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 aMemoryIOaccessor.- Parameters:
size- The number of bytes to allocate.align- The minimum alignment of the memoryclear- If the memory should be cleared.- Returns:
- A new
AllocatedDirectMemoryIO.
-
wrapDirectMemory
Wraps a native C memory address in aMemoryIOaccessor.- Parameters:
address- The native address to wrap.- Returns:
- A new
MemoryIO.
-
getCallbackManager
-
newFunction
-
sizeOf
-
alignmentOf
-