Package org.jruby.ext.ffi.jffi
Class NativeClosureProxy
java.lang.Object
org.jruby.ext.ffi.jffi.NativeClosureProxy
- All Implemented Interfaces:
com.kenai.jffi.Closure
Wraps a ruby proc in a JFFI Closure
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.kenai.jffi.Closure
com.kenai.jffi.Closure.Buffer, com.kenai.jffi.Closure.Handle -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final CallSiteprotected final NativeFunctionInfoprivate static final intprivate final WeakReference<Object>protected final Ruby -
Constructor Summary
ConstructorsConstructorDescriptionNativeClosureProxy(Ruby runtime, NativeFunctionInfo closureInfo, Object proc) NativeClosureProxy(Ruby runtime, NativeFunctionInfo closureInfo, Object proc, CallSite callSite) -
Method Summary
Modifier and TypeMethodDescriptionprivate static final longaddressValue(IRubyObject value) Extracts the primitive value from a Ruby object.private static final IRubyObjectfromNative(Ruby runtime, Type type, com.kenai.jffi.Closure.Buffer buffer, int index) Converts a native value into a ruby object.private static final IRubyObjectgetStringParameter(Ruby runtime, com.kenai.jffi.Closure.Buffer buffer, int index) Converts a native string value into a ruby string object.voidinvoke(com.kenai.jffi.Closure.Buffer buffer) protected final voidprivate static final longlongValue(IRubyObject value) Extracts the primitive value from a Ruby object.private static final voidsetReturnValue(Ruby runtime, Type type, com.kenai.jffi.Closure.Buffer buffer, IRubyObject value) Converts a ruby return value into a native callback return value.
-
Field Details
-
LONG_SIZE
private static final int LONG_SIZE -
runtime
-
closureInfo
-
proc
-
callSite
-
-
Constructor Details
-
NativeClosureProxy
NativeClosureProxy(Ruby runtime, NativeFunctionInfo closureInfo, Object proc) -
NativeClosureProxy
NativeClosureProxy(Ruby runtime, NativeFunctionInfo closureInfo, Object proc, CallSite callSite)
-
-
Method Details
-
invoke
public void invoke(com.kenai.jffi.Closure.Buffer buffer) - Specified by:
invokein interfacecom.kenai.jffi.Closure
-
invoke
-
longValue
Extracts the primitive value from a Ruby object. This is similar to Util.longValue(), except it won't throw exceptions for invalid values.- Parameters:
value- The Ruby object to convert- Returns:
- a java long value.
-
addressValue
Extracts the primitive value from a Ruby object. This is similar to Util.longValue(), except it won't throw exceptions for invalid values.- Parameters:
value- The Ruby object to convert- Returns:
- a java long value.
-
setReturnValue
private static final void setReturnValue(Ruby runtime, Type type, com.kenai.jffi.Closure.Buffer buffer, IRubyObject value) Converts a ruby return value into a native callback return value.- Parameters:
runtime- The ruby runtime the callback is attached totype- The ruby type of the return valuebuffer- The native parameter buffervalue- The ruby value
-
fromNative
private static final IRubyObject fromNative(Ruby runtime, Type type, com.kenai.jffi.Closure.Buffer buffer, int index) Converts a native value into a ruby object.- Parameters:
runtime- The ruby runtime to create the ruby object intype- The type of the native parameterbuffer- The JFFI Closure parameter buffer.index- The index of the parameter in the buffer.- Returns:
- A new Ruby object.
-
getStringParameter
private static final IRubyObject getStringParameter(Ruby runtime, com.kenai.jffi.Closure.Buffer buffer, int index) Converts a native string value into a ruby string object.- Parameters:
runtime- The ruby runtime to create the ruby string inbuffer- The JFFI Closure parameter buffer.index- The index of the parameter in the buffer.- Returns:
- A new Ruby string object or nil if string is NULL.
-