Top Description Fields Constructors Methods
org.jruby.ext.ffi.jffi

pack-priv final Class NativeClosureProxy

extends Object
implements Closure
Class Inheritance
All Implemented Interfaces
com.kenai.jffi.Closure
Imports
com.kenai.jffi.CallingConvention, .Closure, org.jruby.Ruby, .RubyNumeric, .RubyProc, org.jruby.ext.ffi.*, org.jruby.runtime.Block, .CallSite, .ThreadContext, org.jruby.runtime.builtin.IRubyObject, org.jruby.runtime.callsite.FunctionalCachingCallSite, java.lang.ref.WeakReference

Wraps a ruby proc in a JFFI Closure

Field Summary

Modifier and TypeField and Description
private final CallSite
protected final NativeFunctionInfo
private static final int
private final WeakReference<Object>
protected final Ruby

Constructor Summary

AccessConstructor and Description
pack-priv
NativeClosureProxy(Ruby runtime, NativeFunctionInfo closureInfo, Object proc)

pack-priv
NativeClosureProxy(Ruby runtime, NativeFunctionInfo closureInfo, Object proc, CallSite callSite)

Method Summary

Modifier and TypeMethod and Description
private static final long

Returns:

a java long value.
addressValue
(ThreadContext context, IRubyObject
The Ruby object to convert
value
)

Extracts the primitive value from a Ruby object.

private static final IRubyObject

Returns:

A new Ruby object.
fromNative
(ThreadContext
the thread context
context
,
Type
The type of the native parameter
type
,
Closure.Buffer
The JFFI Closure parameter buffer.
buffer
,
int
The index of the parameter in the buffer.
index
)

Converts a native value into a ruby object.

private static final IRubyObject

Returns:

A new Ruby string object or nil if string is NULL.
getStringParameter
(Ruby
The ruby runtime to create the ruby string in
runtime
,
Closure.Buffer
The JFFI Closure parameter buffer.
buffer
,
int
The index of the parameter in the buffer.
index
)

Converts a native string value into a ruby string object.

public void
protected final void
invoke(Closure.Buffer buffer, Object recv)

private static final long

Returns:

a java long value.
longValue
(ThreadContext context, IRubyObject
The Ruby object to convert
value
)

Extracts the primitive value from a Ruby object.

private static final void
setReturnValue(ThreadContext
The thread context
context
,
Type
The ruby type of the return value
type
,
Closure.Buffer
The native parameter buffer
buffer
,
IRubyObject
The ruby value
value
)

Converts a ruby return value into a native callback return value.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

callSiteback to summary
private final CallSite callSite
closureInfoback to summary
protected final NativeFunctionInfo closureInfo
LONG_SIZEback to summary
private static final int LONG_SIZE
procback to summary
private final WeakReference<Object> proc
runtimeback to summary
protected final Ruby runtime

Constructor Detail

NativeClosureProxyback to summary
pack-priv NativeClosureProxy(Ruby runtime, NativeFunctionInfo closureInfo, Object proc)
NativeClosureProxyback to summary
pack-priv NativeClosureProxy(Ruby runtime, NativeFunctionInfo closureInfo, Object proc, CallSite callSite)

Method Detail

addressValueback to summary
private static final long addressValue(ThreadContext context, IRubyObject value)

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:IRubyObject

The Ruby object to convert

Returns:long

a java long value.

fromNativeback to summary
private static final IRubyObject fromNative(ThreadContext context, Type type, Closure.Buffer buffer, int index)

Converts a native value into a ruby object.

Parameters
context:ThreadContext

the thread context

type:Type

The type of the native parameter

buffer:Closure.Buffer

The JFFI Closure parameter buffer.

index:int

The index of the parameter in the buffer.

Returns:IRubyObject

A new Ruby object.

getStringParameterback to summary
private static final IRubyObject getStringParameter(Ruby runtime, Closure.Buffer buffer, int index)

Converts a native string value into a ruby string object.

Parameters
runtime:Ruby

The ruby runtime to create the ruby string in

buffer:Closure.Buffer

The JFFI Closure parameter buffer.

index:int

The index of the parameter in the buffer.

Returns:IRubyObject

A new Ruby string object or nil if string is NULL.

invokeback to summary
public void invoke(Closure.Buffer buffer)

Implements com.kenai.jffi.Closure.invoke.

invokeback to summary
protected final void invoke(Closure.Buffer buffer, Object recv)
longValueback to summary
private static final long longValue(ThreadContext context, IRubyObject value)

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:IRubyObject

The Ruby object to convert

Returns:long

a java long value.

setReturnValueback to summary
private static final void setReturnValue(ThreadContext context, Type type, Closure.Buffer buffer, IRubyObject value)

Converts a ruby return value into a native callback return value.

Parameters
context:ThreadContext

The thread context

type:Type

The ruby type of the return value

buffer:Closure.Buffer

The native parameter buffer

value:IRubyObject

The ruby value