com.sun.jna
public class Function extends Pointer
Function
represents a pointer to some native function.
(Class,Object[],Map)
is the primary means to call
the function.
Function call behavior may be modified by passing one of the following call
flags:
See Also: Pointer
Nested Class Summary | |
---|---|
interface | Function.PostCallRead Any argument which implements this interface will have the
PostCallRead method called immediately after function invocation. |
Field Summary | |
---|---|
static int | ALT_CONVENTION First alternate convention (currently used only for w32 stdcall). |
int | callFlags |
static int | C_CONVENTION Standard C calling convention. |
static Integer | INTEGER_FALSE |
static Integer | INTEGER_TRUE |
static int | MAX_NARGS Maximum number of arguments supported by a JNA function call. |
Map | options |
static String | OPTION_INVOKING_METHOD For internal JNA use. |
static int | THROW_LAST_ERROR Whether to throw an exception if last error is non-zero after call. |
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 | |
---|---|
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(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.
|
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. |
String | getName() |
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. |
Object | invoke(Object[] args, Class returnType, boolean allowObjects) |
void | invoke(Object[] args)
Call the native function being represented by this object
|
double | invokeDouble(Object[] args) Convenience method for
(Class,Object[]) invoke(Double.class, args) . |
float | invokeFloat(Object[] args) Convenience method for
(Class,Object[]) invoke(Float.class, args) . |
int | invokeInt(Object[] args) Convenience method for
(Class,Object[]) invoke(Integer.class, args) . |
long | invokeLong(Object[] args) Convenience method for
(Class,Object[]) invoke(Long.class, args) . |
Object | invokeObject(Object[] args) Convenience method for
(Class,Object[]) invokeObject(Object.class, args) . |
Pointer | invokePointer(Object[] args) Convenience method for
(Class,Object[]) invoke(Pointer.class, args) . |
String | invokeString(Object[] args, boolean wide) Convenience method for
(Class,Object[]) invoke(String.class, args)
or |
void | invokeVoid(Object[] args) Convenience method for
(Class,Object[]) invoke(Void.class, args) . |
static boolean | isVarArgs(Method m) Varargs are only supported on 1.5+. |
String | toString() Provide a human-readable representation of this object. |
static Boolean | valueOf(boolean b) Implementation of Boolean.valueOf for older VMs. |
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.
Parameters: library NativeLibrary in which to find the function functionName Name of the native function to be linked with callFlags Function call flags
Throws: UnsatisfiedLinkError if the given function name is not found within the library.
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.
Parameters: functionAddress Address of the native function callFlags Function call flags
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.
Parameters: libraryName Library in which to find the native function functionName Name of the native function to be linked with
Throws: UnsatisfiedLinkError if the library is not found or the given function name is not found within the library.
Function
representing a native
function.
The allocated instance represents a pointer to the named native function from the named library.
Parameters: libraryName Library in which to find the function functionName Name of the native function to be linked with callFlags Function call flags
Throws: UnsatisfiedLinkError if the library is not found or the given function name is not found within the library.
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.
Parameters: p Native function pointer
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.
Parameters: p Native function pointer callFlags Function call flags
See Also: implementation
Parameters: args Arguments to pass to the native function
(Class,Object[]) invoke(Double.class, args)
.(Class,Object[]) invoke(Float.class, args)
.(Class,Object[]) invoke(Integer.class, args)
.(Class,Object[]) invoke(Long.class, args)
.(Class,Object[]) invokeObject(Object.class, args)
.(Class,Object[]) invoke(Pointer.class, args)
.(Class,Object[]) invoke(String.class, args)
or (Class,Object[]) invoke(WString.class, args)
Parameters: args Arguments passed to native function wide Whether the return value is of type wchar_t*
;
if false, the return value is of type char*
.
(Class,Object[]) invoke(Void.class, args)
.