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 int
alignmentOf
(NativeType type) abstract MemoryIO
allocateDirectMemory
(Ruby runtime, int size, boolean clear) Allocates memory on the native C heap and wraps it in aMemoryIO
accessor.abstract MemoryIO
allocateDirectMemory
(Ruby runtime, int size, int align, boolean clear) Allocates memory on the native C heap and wraps it in aMemoryIO
accessor.abstract MemoryIO
allocateTransientDirectMemory
(Ruby runtime, int size, int align, boolean clear) Allocates transient native memory (not from C heap) and wraps it in aMemoryIO
accessor.abstract CallbackManager
static final Factory
Gets an instance ofFFIProvider
void
init
(Ruby runtime, RubyModule FFI) Registers FFI ruby classes/modulesabstract AbstractInvoker
newFunction
(Ruby runtime, Pointer address, CallbackInfo cbInfo) abstract int
sizeOf
(NativeType type) abstract MemoryIO
wrapDirectMemory
(Ruby runtime, long address) Wraps a native C memory address in aMemoryIO
accessor.
-
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 aMemoryIO
accessor.- 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 aMemoryIO
accessor.- 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 aMemoryIO
accessor.- 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 aMemoryIO
accessor.- Parameters:
address
- The native address to wrap.- Returns:
- A new
MemoryIO
.
-
getCallbackManager
-
newFunction
-
sizeOf
-
alignmentOf
-