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.
Function#C_CONVENTION Use C calling convention (default)
Function#ALT_CONVENTION Use alternate calling convention (e.g. stdcall)
Function#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
| Modifier and Type | Class and Description |
|---|---|
| private static class | |
| private static class | |
| public static interface | Function.PostCallRead
Any argument which implements this interface will have the
|
| Modifier and Type | Field and Description |
|---|---|
| public static final int | ALT_CONVENTION
First alternate convention (currently used only for w32 stdcall). |
| public static final int | C_CONVENTION
Standard C calling convention. |
| pack-priv final int | |
| pack-priv final String | |
| private final String | |
| pack-priv static final Integer | |
| pack-priv static final Integer | |
| private static final VarArgsChecker | IS_VARARGS
For checking if methods declare varargs |
| private NativeLibrary | |
| private static final int | |
| public static final int | MAX_NARGS
Maximum number of arguments supported by a JNA function call. |
| pack-priv static final String | OPTION_INVOKING_METHOD
For internal JNA use. |
| pack-priv final Map | |
| public static final int | THROW_LAST_ERROR
Whether to throw an exception if last error is non-zero after call. |
| public static final int | USE_VARARGS
Mask for number of fixed args (max 255) for varargs calls. |
| private static final int | USE_VARARGS_SHIFT
Offset of USE_VARARGS in call flags |
| Access | Constructor and Description |
|---|---|
| pack-priv | Function(NativeLibrary
NativeLibrary in which to find the functionName of the native function to be linked with functionName, int Function call flags callFlags, String Encoding for conversion between Java and native strings. encoding)Create a new |
| pack-priv | Function(Pointer
Address of the native function functionAddress, int Function call flags callFlags, String Encoding for conversion between Java and native strings. encoding)Create a new |
| Modifier and Type | Method and Description |
|---|---|
| private void | |
| pack-priv static Object[] | concatenateVarArgs(Object[] inArgs)
Concatenate varargs with normal args to obtain a simple argument array. |
| private Object | convertArgument(Object[] args, int index, Method invokingMethod, TypeMapper mapper, boolean allowObjects, Class<?> expectedType)
|
| public boolean | equals(Object
the reference object with which to compare. o)Overrides com. |
| pack-priv static int | |
| public int | |
| public static Function | getFunction(String
Library in which to find the native function libraryName, String Name of the native function to be linked with functionName)Obtain a |
| public static Function | getFunction(String
Library in which to find the function libraryName, String Name of the native function to be linked with functionName, int Function call flags callFlags)Obtain a |
| public static Function | getFunction(String
Library in which to find the function libraryName, String Name of the native function to be linked with functionName, int Function call flags callFlags, String Encoding to use for conversion between Java and native
strings. encoding)Obtain a |
| public static Function | getFunction(Pointer
Native function pointer p)Obtain a |
| public static Function | getFunction(Pointer
Native function pointer p, int Function call flags callFlags)Obtain a |
| public static Function | getFunction(Pointer
Native function pointer p, int Function call flags callFlags, String Encoding to use for conversion between Java and native
strings. encoding)Obtain a |
| public String | |
| public int | hashCode()
Overrides com. Functions which are
equivalent.
|
| public Object | |
| public Object | |
| pack-priv Object | |
| pack-priv Object | |
| pack-priv Object | |
| public void | |
| public double | |
| public float | |
| public int | |
| public long | |
| public Object | |
| private Pointer | |
| public Pointer | |
| private String | Returns: The value returned by the target native function, as a Stringcalling convention to be used callFlags, Object[] Arguments to pass to the native function args, boolean whether the native string uses wide)wchar_t; if
false, char is assumedCall the native function being represented by this object |
| public String | invokeString(Object[]
Arguments passed to native function args, boolean Whether the return value is of type wide)wchar_t*;
if false, the return value is of type char*.Convenience method for
|
| public void | |
| private boolean | |
| pack-priv static boolean | |
| public String | toString()
Overrides com. |
| pack-priv static Boolean |
| ALT_CONVENTION | back to summary |
|---|---|
| public static final int ALT_CONVENTION First alternate convention (currently used only for w32 stdcall). | |
| C_CONVENTION | back to summary |
|---|---|
| public static final int C_CONVENTION Standard C calling convention. | |
| callFlags | back to summary |
|---|---|
| pack-priv final int callFlags | |
| encoding | back to summary |
|---|---|
| pack-priv final String encoding | |
| functionName | back to summary |
|---|---|
| private final String functionName | |
| INTEGER_FALSE | back to summary |
|---|---|
| pack-priv static final Integer INTEGER_FALSE | |
| INTEGER_TRUE | back to summary |
|---|---|
| pack-priv static final Integer INTEGER_TRUE | |
| IS_VARARGS | back to summary |
|---|---|
| private static final VarArgsChecker IS_VARARGS For checking if methods declare varargs | |
| library | back to summary |
|---|---|
| private NativeLibrary library | |
| MASK_CC | back to summary |
|---|---|
| private static final int MASK_CC
| |
| MAX_NARGS | back to summary |
|---|---|
| public static final int MAX_NARGS Maximum number of arguments supported by a JNA function call. | |
| OPTION_INVOKING_METHOD | back to summary |
|---|---|
| pack-priv static final String OPTION_INVOKING_METHOD For internal JNA use. | |
| options | back to summary |
|---|---|
| pack-priv final Map<String, ?> options | |
| THROW_LAST_ERROR | back to summary |
|---|---|
| public static final int THROW_LAST_ERROR Whether to throw an exception if last error is non-zero after call. | |
| USE_VARARGS | back to summary |
|---|---|
| public static final int USE_VARARGS Mask for number of fixed args (max 255) for varargs calls. | |
| USE_VARARGS_SHIFT | back to summary |
|---|---|
| private static final int USE_VARARGS_SHIFT Offset of USE_VARARGS in call flags | |
| Function | back to summary |
|---|---|
| pack-priv Function(NativeLibrary library, String functionName, int callFlags, String encoding) Create a new The allocated instance represents a pointer to the named native function from the supplied library, called with the given calling convention.
| |
| Function | back to summary |
|---|---|
| pack-priv Function(Pointer functionAddress, int callFlags, String encoding) Create a new The allocated instance represents a pointer to the given function address, called with the given calling convention.
| |
| checkCallingConvention | back to summary |
|---|---|
| private void checkCallingConvention(int convention) throws IllegalArgumentException | |
| concatenateVarArgs | back to summary |
|---|---|
| pack-priv static Object[] concatenateVarArgs(Object[] inArgs) Concatenate varargs with normal args to obtain a simple argument array. | |
| convertArgument | back to summary |
|---|---|
| private Object convertArgument(Object[] args, int index, Method invokingMethod, TypeMapper mapper, boolean allowObjects, Class<?> expectedType) | |
| equals | back to summary |
|---|---|
| public boolean equals(Object o) Overrides com. Two function pointers are equal if they share the same peer address and calling convention.
| |
| fixedArgs | back to summary |
|---|---|
| pack-priv static int fixedArgs(Method m) Varargs are only supported on 1.5+. | |
| getCallingConvention | back to summary |
|---|---|
| public int getCallingConvention() | |
| getFunction | back to summary |
|---|---|
| public static Function getFunction(String libraryName, String functionName) Obtain a The allocated instance represents a pointer to the named native function from the named library, called with the standard "C" calling convention.
| |
| getFunction | back to summary |
|---|---|
| public static Function getFunction(String libraryName, String functionName, int callFlags) Obtain a The allocated instance represents a pointer to the named native function from the named library.
| |
| getFunction | back to summary |
|---|---|
| public static Function getFunction(String libraryName, String functionName, int callFlags, String encoding) Obtain a The allocated instance represents a pointer to the named native function from the named library.
| |
| getFunction | back to summary |
|---|---|
| public static Function getFunction(Pointer p) Obtain a The allocated instance represents a pointer to the native function pointer.
| |
| getFunction | back to summary |
|---|---|
| public static Function getFunction(Pointer p, int callFlags) Obtain a The allocated instance represents a pointer to the native function pointer.
| |
| getFunction | back to summary |
|---|---|
| public static Function getFunction(Pointer p, int callFlags, String encoding) Obtain a The allocated instance represents a pointer to the native function pointer.
| |
| getName | back to summary |
|---|---|
| public String getName() | |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides com. Provide a unique hash code for
| |
| invoke | back to summary |
|---|---|
| public Object invoke(Class<?> returnType, Object[] inArgs) Invoke the native function with the given arguments, returning the native result as an Object. | |
| invoke | back to summary |
|---|---|
| public Object invoke(Class<?> returnType, Object[] inArgs, Map<String, ?> options) Invoke the native function with the given arguments, returning the native result as an Object. | |
| invoke | back to summary |
|---|---|
| pack-priv Object invoke(Method invokingMethod, Class<?>[] paramTypes, Class<?> returnType, Object[] inArgs, Map<String, ?> options) Invoke the native function with the given arguments, returning the
native result as an Object. This method can be called if invoking method and parameter
types are already at hand. When calling | |
| invoke | back to summary |
|---|---|
| pack-priv Object invoke(Object[] args, Class<?> returnType, boolean allowObjects) | |
| invoke | back to summary |
|---|---|
| pack-priv Object invoke(Object[] args, Class<?> returnType, boolean allowObjects, int fixedArgs) | |
| invoke | back to summary |
|---|---|
| public void invoke(Object[] args) Call the native function being represented by this object
| |
| invokeDouble | back to summary |
|---|---|
| public double invokeDouble(Object[] args) Convenience method for
| |
| invokeFloat | back to summary |
|---|---|
| public float invokeFloat(Object[] args) Convenience method for
| |
| invokeInt | back to summary |
|---|---|
| public int invokeInt(Object[] args) Convenience method for
| |
| invokeLong | back to summary |
|---|---|
| public long invokeLong(Object[] args) Convenience method for
| |
| invokeObject | back to summary |
|---|---|
| public Object invokeObject(Object[] args) Convenience method for
| |
| invokePointer | back to summary |
|---|---|
| private Pointer invokePointer(int callFlags, Object[] args) | |
| invokePointer | back to summary |
|---|---|
| public Pointer invokePointer(Object[] args) Convenience method for
| |
| invokeString | back to summary |
|---|---|
| private String invokeString(int callFlags, Object[] args, boolean wide) Call the native function being represented by this object | |
| invokeString | back to summary |
|---|---|
| public String invokeString(Object[] args, boolean wide) Convenience method for
| |
| invokeVoid | back to summary |
|---|---|
| public void invokeVoid(Object[] args) Convenience method for
| |
| isPrimitiveArray | back to summary |
|---|---|
| private boolean isPrimitiveArray(Class<?> argClass) | |
| isVarArgs | back to summary |
|---|---|
| pack-priv static boolean isVarArgs(Method m) Varargs are only supported on 1.5+. | |
| toString | back to summary |
|---|---|
| public String toString() Overrides com. Provide a human-readable representation of this object.
| |
| valueOf | back to summary |
|---|---|
| pack-priv static Boolean valueOf(boolean b) Implementation of Boolean.valueOf for older VMs. | |
| Modifier and Type | Field and Description |
|---|---|
| private final NativeMapped[] |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | read()
Implements com. |
| original | back to summary |
|---|---|
| private final NativeMapped[] original | |
| NativeMappedArray | back to summary |
|---|---|
| public NativeMappedArray(NativeMapped[] arg) | |
| read | back to summary |
|---|---|
| public void read() Implements com. Doc from com. Perform any necessary post-call synchronization. Normally this just means reading from native memory any changes made by the native function call.
| |
| Modifier and Type | Field and Description |
|---|---|
| private final Pointer[] |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | read()
Implements com. |
| original | back to summary |
|---|---|
| private final Pointer[] original | |
| PointerArray | back to summary |
|---|---|
| public PointerArray(Pointer[] arg) | |
| read | back to summary |
|---|---|
| public void read() Implements com. Doc from com. Perform any necessary post-call synchronization. Normally this just means reading from native memory any changes made by the native function call.
| |
read method called immediately after function invocation.
| Modifier and Type | Method and Description |
|---|---|
| public void |
| read | back to summary |
|---|---|
| public void read() Perform any necessary post-call synchronization. Normally this just means reading from native memory any changes made by the native function call. | |