|
JNA API> 3.3.0 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.sun.jna.Pointer
com.sun.jna.Function
public class Function
An abstraction for a native function pointer. An instance of
Function represents a pointer to some native function.
invoke(Class,Object[],Map) is the primary means to call
the function.
C_CONVENTION Use C calling convention (default)
ALT_CONVENTION Use alternate calling convention (e.g. stdcall)
THROW_LAST_ERROR Throw a LastErrorException if
the native function sets the system error to a non-zero value (errno or
GetLastError). Setting this flag will cause the system error to be cleared
prior to native function invocation.
Pointer| Nested Class Summary | |
|---|---|
static interface |
Function.PostCallRead
Any argument which implements this interface will have the Function.PostCallRead.read() method called immediately after function invocation. |
| Field Summary | |
|---|---|
static int |
ALT_CONVENTION
First alternate convention (currently used only for w32 stdcall). |
static int |
C_CONVENTION
Standard C calling convention. |
(package private) int |
callFlags
|
(package private) static Integer |
INTEGER_FALSE
|
(package private) static Integer |
INTEGER_TRUE
|
static int |
MAX_NARGS
Maximum number of arguments supported by a JNA function call. |
(package private) static String |
OPTION_INVOKING_METHOD
For internal JNA use. |
(package private) Map |
options
|
static int |
THROW_LAST_ERROR
Whether to throw an exception if last error is non-zero after call. |
| Fields inherited from class com.sun.jna.Pointer |
|---|
NULL, peer, SIZE |
| Constructor Summary | |
|---|---|
Function(NativeLibrary library,
String functionName,
int callFlags)
Create a new Function that is linked with a native
function that follows the given calling convention. |
|
Function(Pointer functionAddress,
int callFlags)
Create a new Function that is linked with a native
function that follows the given calling convention. |
|
| Method Summary | |
|---|---|
(package private) static Object[] |
concatenateVarArgs(Object[] inArgs)
Concatenate varargs with normal args to obtain a simple argument array. |
boolean |
equals(Object o)
Two function pointers are equal if they share the same peer address and calling convention. |
int |
getCallingConvention()
|
static Function |
getFunction(Pointer p)
Obtain a Function representing a native
function pointer. |
static Function |
getFunction(Pointer p,
int callFlags)
Obtain a Function representing a native
function pointer. |
static Function |
getFunction(String libraryName,
String functionName)
Obtain a Function representing a native
function that follows the standard "C" calling convention. |
static Function |
getFunction(String libraryName,
String functionName,
int callFlags)
Obtain a Function representing a native
function. |
String |
getName()
|
int |
hashCode()
Provide a unique hash code for Functions which are
equivalent. |
Object |
invoke(Class returnType,
Object[] inArgs)
Invoke the native function with the given arguments, returning the native result as an Object. |
Object |
invoke(Class returnType,
Object[] inArgs,
Map options)
Invoke the native function with the given arguments, returning the native result as an Object. |
void |
invoke(Object[] args)
Call the native function being represented by this object |
(package private) Object |
invoke(Object[] args,
Class returnType,
boolean allowObjects)
|
double |
invokeDouble(Object[] args)
Convenience method for invoke(Double.class, args). |
float |
invokeFloat(Object[] args)
Convenience method for invoke(Float.class, args). |
int |
invokeInt(Object[] args)
Convenience method for invoke(Integer.class, args). |
long |
invokeLong(Object[] args)
Convenience method for invoke(Long.class, args). |
Object |
invokeObject(Object[] args)
Convenience method for invokeObject(Object.class, args). |
Pointer |
invokePointer(Object[] args)
Convenience method for invoke(Pointer.class, args). |
String |
invokeString(Object[] args,
boolean wide)
Convenience method for invoke(String.class, args)
or invoke(WString.class, args) |
void |
invokeVoid(Object[] args)
Convenience method for invoke(Void.class, args). |
(package private) static boolean |
isVarArgs(Method m)
Varargs are only supported on 1.5+. |
String |
toString()
Provide a human-readable representation of this object. |
(package private) static Boolean |
valueOf(boolean b)
Implementation of Boolean.valueOf for older VMs. |
| Methods inherited from class com.sun.jna.Pointer |
|---|
clear, createConstant, createConstant, getByte, getByteArray, getByteBuffer, getChar, getCharArray, getDouble, getDoubleArray, getFloat, getFloatArray, getInt, getIntArray, getLong, getLongArray, getNativeLong, getPointer, getPointerArray, getPointerArray, getShort, getShortArray, getString, getString, getStringArray, getStringArray, getStringArray, getStringArray, getValue, indexOf, nativeValue, nativeValue, read, read, read, read, read, read, read, read, setByte, setChar, setDouble, setFloat, setInt, setLong, setMemory, setNativeLong, setPointer, setShort, setString, setString, setValue, share, share, write, write, write, write, write, write, write, write |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int MAX_NARGS
public static final int C_CONVENTION
public static final int ALT_CONVENTION
public static final int THROW_LAST_ERROR
static final Integer INTEGER_TRUE
static final Integer INTEGER_FALSE
int callFlags
final Map options
static final String OPTION_INVOKING_METHOD
| Constructor Detail |
|---|
Function(NativeLibrary library,
String functionName,
int callFlags)
Function that is linked with a native
function that follows the given calling convention.
The allocated instance represents a pointer to the named native function from the supplied library, called with the given calling convention.
library - NativeLibrary in which to find the functionfunctionName - Name of the native function to be linked withcallFlags - Function call flags
{@link - UnsatisfiedLinkError} if the given function name is
not found within the library.
Function(Pointer functionAddress,
int callFlags)
Function that is linked with a native
function that follows the given calling convention.
The allocated instance represents a pointer to the given function address, called with the given calling convention.
functionAddress - Address of the native functioncallFlags - Function call flags| Method Detail |
|---|
public static Function getFunction(String libraryName,
String functionName)
Function representing a native
function that follows the standard "C" calling convention.
The allocated instance represents a pointer to the named native function from the named library, called with the standard "C" calling convention.
libraryName - Library in which to find the native functionfunctionName - Name of the native function to be linked with
{@link - UnsatisfiedLinkError} if the library is not found or
the given function name is not found within the library.
public static Function getFunction(String libraryName,
String functionName,
int callFlags)
Function representing a native
function.
The allocated instance represents a pointer to the named native function from the named library.
libraryName - Library in which to find the functionfunctionName - Name of the native function to be linked withcallFlags - Function call flags
{@link - UnsatisfiedLinkError} if the library is not found or
the given function name is not found within the library.public static Function getFunction(Pointer p)
Function representing a native
function pointer. In general, this function should be used by dynamic
languages; Java code should allow JNA to bind to a specific Callback
interface instead by defining a return type or Structure field type.
The allocated instance represents a pointer to the native function pointer.
p - Native function pointer
public static Function getFunction(Pointer p,
int callFlags)
Function representing a native
function pointer. In general, this function should be used by dynamic
languages; Java code should allow JNA to bind to a specific Callback
interface instead by defining a return type or Structure field type.
The allocated instance represents a pointer to the native function pointer.
p - Native function pointercallFlags - Function call flagspublic String getName()
public int getCallingConvention()
public Object invoke(Class returnType,
Object[] inArgs)
public Object invoke(Class returnType,
Object[] inArgs,
Map options)
Object invoke(Object[] args,
Class returnType,
boolean allowObjects)
implementationpublic void invoke(Object[] args)
args - Arguments to pass to the native functionpublic String toString()
toString in class Pointerpublic Object invokeObject(Object[] args)
invokeObject(Object.class, args).
public Pointer invokePointer(Object[] args)
invoke(Pointer.class, args).
public String invokeString(Object[] args,
boolean wide)
invoke(String.class, args)
or invoke(WString.class, args)
args - Arguments passed to native functionwide - Whether the return value is of type wchar_t*;
if false, the return value is of type char*.public int invokeInt(Object[] args)
invoke(Integer.class, args).
public long invokeLong(Object[] args)
invoke(Long.class, args).
public float invokeFloat(Object[] args)
invoke(Float.class, args).
public double invokeDouble(Object[] args)
invoke(Double.class, args).
public void invokeVoid(Object[] args)
invoke(Void.class, args).
public boolean equals(Object o)
equals in class Pointero - A Pointer instance
Pointer,
and the C pointers being pointed to by these objects are also
equal. Returns false otherwise.public int hashCode()
Functions which are
equivalent.
hashCode in class Pointerstatic Object[] concatenateVarArgs(Object[] inArgs)
static boolean isVarArgs(Method m)
static Boolean valueOf(boolean b)
|
JNA API> 3.3.0 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||