Package de.intarsys.nativec.jna
Class JnaNativeInterface
java.lang.Object
de.intarsys.nativec.jna.JnaNativeInterface
- All Implemented Interfaces:
INativeInterface
An
INativeInterface
implemented using JNA, a LGPL licensed Java
native interface abstraction.
In our point of view, JNA has the power of deploying all what we wanted to have, but is ill designed in some key hot spots - so we worked around and built on top of our own interfaces.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addSearchPath
(String path) Add a directory to the search path.allocate
(int size) Allocate c memory and return the respectiveINativeHandle
.createCallback
(ICallback callback) createFunction
(long address) Create anINativeFunction
from a function pointer.createFunction
(long address, Object callingConvention) createHandle
(long address) Create a voidINativeHandle
to a memory address.createLibrary
(String name) Load a newINativeLibrary
.createLibrary
(String name, Object callingConvention) Load a newINativeLibrary
.protected com.sun.jna.Pointer
createMemory
(int size) int
longSize()
The platform long size.int
The platform pointer size.int
The platform wide char size.
-
Constructor Details
-
JnaNativeInterface
public JnaNativeInterface()
-
-
Method Details
-
addSearchPath
Description copied from interface:INativeInterface
Add a directory to the search path.- Specified by:
addSearchPath
in interfaceINativeInterface
- Parameters:
path
- The path to be added;
-
allocate
Description copied from interface:INativeInterface
Allocate c memory and return the respectiveINativeHandle
.- Specified by:
allocate
in interfaceINativeInterface
- Parameters:
size
- The size in bytes.- Returns:
- The new allocated
INativeHandle
-
createCallback
- Specified by:
createCallback
in interfaceINativeInterface
-
createFunction
Description copied from interface:INativeInterface
Create anINativeFunction
from a function pointer.There is no special handling for the 0 address!
- Specified by:
createFunction
in interfaceINativeInterface
- Parameters:
address
- The function pointer.- Returns:
- The function object.
-
createFunction
- Specified by:
createFunction
in interfaceINativeInterface
-
createHandle
Description copied from interface:INativeInterface
Create a voidINativeHandle
to a memory address.There is no special handling for the 0 address!
- Specified by:
createHandle
in interfaceINativeInterface
- Parameters:
address
- The memory address.- Returns:
- The handle to the memory address.
-
createLibrary
Description copied from interface:INativeInterface
Load a newINativeLibrary
.- Specified by:
createLibrary
in interfaceINativeInterface
- Parameters:
name
- The name of the library to load.- Returns:
- The new
INativeLibrary
-
createLibrary
Description copied from interface:INativeInterface
Load a newINativeLibrary
.- Specified by:
createLibrary
in interfaceINativeInterface
- Parameters:
name
- The name of the library to load.callingConvention
- The calling convention to use as default for functions in this library.- Returns:
- The new
INativeLibrary
-
createMemory
protected com.sun.jna.Pointer createMemory(int size) -
getSearchPaths
-
longSize
public int longSize()Description copied from interface:INativeInterface
The platform long size.- Specified by:
longSize
in interfaceINativeInterface
- Returns:
- The platform long size.
-
pointerSize
public int pointerSize()Description copied from interface:INativeInterface
The platform pointer size.- Specified by:
pointerSize
in interfaceINativeInterface
- Returns:
- The platform pointer size.
-
wideCharSize
public int wideCharSize()Description copied from interface:INativeInterface
The platform wide char size.- Specified by:
wideCharSize
in interfaceINativeInterface
- Returns:
- The platform wide char size.
-