Top Description Fields Constructors Methods
jnr.ffi.byref

public final Class ShortByReference

extends AbstractNumberReference<Short>
Class Inheritance
Imports
jnr.ffi.Pointer, .Runtime

ShortByReference is used when the address of a primitive short value must be passed as a parameter to a function.

For example, the following C code,

extern void get_a(short * ap);

short foo(void) {
    short a;
    // pass a reference to 'a' so get_a() can fill it out
    get_a(&a);

    return a;
}

Would be declared in java as

interface Lib {
    void get_a(@Out ShortByReference ap);
}

and used like this

ShortByReference ap = new ShortByReference();
lib.get_a(ap);
System.out.printf("a from lib=%d\n", a.getValue());

Field Summary

Inherited from jnr.ffi.byref.AbstractNumberReference:
value

Constructor Summary

AccessConstructor and Description
public
ShortByReference()

Creates a new reference to a short value initialized to zero.

public
ShortByReference(Short
the initial native value
value
)

Creates a new reference to a short value.

public
ShortByReference(short
the initial native value
value
)

Creates a new reference to a short value.

Method Summary

Modifier and TypeMethod and Description
public void
fromNative(Runtime
the current runtime.
runtime
,
Pointer
the native memory buffer.
buffer
,
long
the memory offset.
offset
)

Implements jnr.ffi.byref.ByReference.fromNative.

Copies the short value from native memory
public final int

Returns:

the size of a byte in bytes
nativeSize
(Runtime
the current runtime.
runtime
)

Implements jnr.ffi.byref.ByReference.nativeSize.

Gets the native size of type of reference in bytes.
public void
toNative(Runtime
the current runtime.
runtime
,
Pointer
the native memory buffer.
buffer
,
long
the memory offset.
offset
)

Implements jnr.ffi.byref.ByReference.toNative.

Copies the short value to native memory
Inherited from jnr.ffi.byref.AbstractNumberReference:
byteValuecheckNulldoubleValuefloatValuegetValueintValuelongValueshortValue

Constructor Detail

ShortByReferenceback to summary
public ShortByReference()

Creates a new reference to a short value initialized to zero.

ShortByReferenceback to summary
public ShortByReference(Short value)

Creates a new reference to a short value.

Parameters
value:Short

the initial native value

ShortByReferenceback to summary
public ShortByReference(short value)

Creates a new reference to a short value.

Parameters
value:short

the initial native value

Method Detail

fromNativeback to summary
public void fromNative(Runtime runtime, Pointer buffer, long offset)

Implements jnr.ffi.byref.ByReference.fromNative.

Copies the short value from native memory

Parameters
runtime:Runtime

the current runtime.

buffer:Pointer

the native memory buffer.

offset:long

the memory offset.

nativeSizeback to summary
public final int nativeSize(Runtime runtime)

Implements jnr.ffi.byref.ByReference.nativeSize.

Gets the native size of type of reference in bytes.

Parameters
runtime:Runtime

the current runtime.

Returns:int

the size of a byte in bytes

toNativeback to summary
public void toNative(Runtime runtime, Pointer buffer, long offset)

Implements jnr.ffi.byref.ByReference.toNative.

Copies the short value to native memory

Parameters
runtime:Runtime

the current runtime.

buffer:Pointer

the native memory buffer.

offset:long

the memory offset.