final class Native
extends java.lang.Object
Native class is used for interfacing with native extensions.
It's singleton instance is tied to the Ruby runtime in which it was
created and cannot be used in another runtime. The reason for this is, that
C extensions loaded into the process space cannot be isolated from other runtimes
and thus cannot be used twice within the same operating system process.| Modifier and Type | Field and Description |
|---|---|
private static Native |
INSTANCE |
private static java.lang.String |
jrubyHome |
private static java.lang.String |
libName |
private Ruby |
runtime |
private static com.kenai.jffi.Library |
shim |
| Modifier and Type | Method and Description |
|---|---|
(package private) long |
callFunction(long fn,
long data) |
long |
callInit(ThreadContext ctx,
long init) |
IRubyObject |
callMethod(ThreadContext ctx,
long fn,
IRubyObject recv,
int arity,
IRubyObject[] args)
General method to execute a C method with the given arity and arguments.
|
(package private) IRubyObject |
callMethod(ThreadContext ctx,
long fn,
long recv,
int arity,
long[] args) |
(package private) IRubyObject |
callMethod0(long fn,
long recv) |
(package private) IRubyObject |
callMethod1(long fn,
long recv,
long arg0) |
(package private) IRubyObject |
callMethod2(long fn,
long recv,
long arg0,
long arg1) |
(package private) IRubyObject |
callMethod3(long fn,
long recv,
long arg0,
long arg1,
long arg2) |
(package private) IRubyObject |
callProcMethod(long fn,
long args_ary) |
(package private) static void |
freeHandle(long handle) |
(package private) void |
gc() |
private static java.lang.String |
getCextLibraryPath()
Gets the path within the jar file of the jruby-cext native library.
|
private static java.io.InputStream |
getCextLibraryStream()
Gets an InputStream representing the stub library image stored in
the jar file.
|
(package private) long |
getFalse() |
(package private) static Native |
getInstance(Ruby runtime) |
(package private) long |
getNil() |
(package private) long |
getTrue() |
private void |
initNative(Ruby runtime) |
private void |
load(Ruby runtime)
Loads and initializes the "jruby-cext" native library.
|
private java.io.File |
loadFromJar()
Copies the "jruby-cext" library to a temporary file to allow the operating
system routines to load it into the process space.
|
private java.io.File |
loadFromJrubyHome()
Tries loading the "jruby-cext" library from the classpath, the JRuby Jar or the
jruby home in the file-system.
|
(package private) long |
newFixnumHandle(IRubyObject obj,
long value) |
(package private) long |
newFloatHandle(IRubyObject obj,
double value) |
(package private) long |
newHandle(IRubyObject obj,
int type) |
(package private) long |
newIOHandle(IRubyObject obj,
int fileno,
int i) |
private static Native INSTANCE
private static com.kenai.jffi.Library shim
private static final java.lang.String libName
private static final java.lang.String jrubyHome
private final Ruby runtime
private Native(Ruby runtime)
private void load(Ruby runtime)
private java.io.File loadFromJrubyHome()
private java.io.File loadFromJar()
private static final java.io.InputStream getCextLibraryStream()
private static final java.lang.String getCextLibraryPath()
public final IRubyObject callMethod(ThreadContext ctx, long fn, IRubyObject recv, int arity, IRubyObject[] args)
public final long callInit(ThreadContext ctx, long init)
private final void initNative(Ruby runtime)
final IRubyObject callMethod(ThreadContext ctx, long fn, long recv, int arity, long[] args)
final IRubyObject callMethod0(long fn, long recv)
final IRubyObject callMethod1(long fn, long recv, long arg0)
final IRubyObject callMethod2(long fn, long recv, long arg0, long arg1)
final IRubyObject callMethod3(long fn, long recv, long arg0, long arg1, long arg2)
final long callFunction(long fn,
long data)
final IRubyObject callProcMethod(long fn, long args_ary)
static void freeHandle(long handle)
final long newHandle(IRubyObject obj, int type)
final long newFixnumHandle(IRubyObject obj, long value)
final long newFloatHandle(IRubyObject obj, double value)
final long newIOHandle(IRubyObject obj, int fileno, int i)
final void gc()
final long getNil()
final long getTrue()
final long getFalse()