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

public final Class FFIUtil

extends Object
Class Inheritance
Imports
java.util.Arrays, .Collection, .EnumMap, .Map, org.jruby.Ruby, .RubyHash, .RubyModule, .RubyString, org.jruby.ext.ffi.CallbackInfo, .NativeType, .StructLayout, .Type, org.jruby.runtime.ThreadContext, org.jruby.runtime.builtin.IRubyObject

Some utility functions for FFI <=> jffi conversions

Field Summary

Modifier and TypeField and Description
private static final MemoryIO
private static final Map<NativeType, Type>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private static final Map<NativeType, Type>
private static Type
pack-priv static final Type
pack-priv static final Type
pack-priv static final IRubyObject

Returns:

A ruby string.
getString
(Ruby
The ruby runtime for the resulting string.
runtime
,
long
The memory address to read the string from.
address
)

Reads a nul-terminated string from native memory and boxes it up in a ruby string.

pack-priv static Array

Returns:

A new Struct descriptor.
newArray
(Type.Array
The structure layout
arrayType
)

Creates a new JFFI type descriptor for an array

pack-priv static final Aggregate

Returns:

A new Struct descriptor.
newStruct
(StructLayout
The structure layout
layout
)

Creates a new JFFI Struct descriptor for a StructLayout

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

IOback to summary
private static final MemoryIO IO
typeMapback to summary
private static final Map<NativeType, Type> typeMap

Constructor Detail

FFIUtilback to summary
private FFIUtil()

Method Detail

buildTypeMapback to summary
private static final Map<NativeType, Type> buildTypeMap()
cacheFFITypeback to summary
private static Type cacheFFIType(Type type)
getFFITypeback to summary
pack-priv static final Type getFFIType(Type type)
getFFITypeback to summary
pack-priv static final Type getFFIType(NativeType type)
getStringback to summary
pack-priv static final IRubyObject getString(Ruby runtime, long address)

Reads a nul-terminated string from native memory and boxes it up in a ruby string.

Parameters
runtime:Ruby

The ruby runtime for the resulting string.

address:long

The memory address to read the string from.

Returns:IRubyObject

A ruby string.

newArrayback to summary
pack-priv static Array newArray(Type.Array arrayType)

Creates a new JFFI type descriptor for an array

Parameters
arrayType:Type.Array

The structure layout

Returns:Array

A new Struct descriptor.

newStructback to summary
pack-priv static final Aggregate newStruct(StructLayout layout)

Creates a new JFFI Struct descriptor for a StructLayout

Parameters
layout:StructLayout

The structure layout

Returns:Aggregate

A new Struct descriptor.