Module org.jnetpcap
Package org.jnetpcap.internal
Class ForeignInitializer<T extends ForeignDowncall<E>,E extends Throwable>
java.lang.Object
org.jnetpcap.internal.ForeignInitializer<T,E>
- Type Parameters:
T
- the generic typeE
- the element type
- All Implemented Interfaces:
AutoCloseable
- Direct Known Subclasses:
PcapForeignInitializer
public class ForeignInitializer<T extends ForeignDowncall<E>,E extends Throwable>
extends Object
implements AutoCloseable
The Class ForeignInitializer.
- Author:
- Sly Technologies Inc, repos@slytechs.com, mark
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
The Enum CType.static interface
ForeignInitializer.DowncallSupplier<T extends ForeignDowncall<?>>
The Interface DowncallSupplier.static interface
The Interface MethodHandleLookup.static interface
The Interface MissingSymbolsPolicy. -
Constructor Summary
ModifierConstructorDescriptionForeignInitializer
(String name) Instantiates a new foreign initializer.ForeignInitializer
(String name, MethodHandles.Lookup lookup) Instantiates a new foreign initializer.protected
ForeignInitializer
(String name, ForeignInitializer.DowncallSupplier<T> newFunctionSupplier, BiFunction<String, Throwable, T> exceptionSupplier, MethodHandles.Lookup lookup) Instantiates a new foreign initializer. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Close.Create ForeignDowncall from given signature.downcall
(String symbolName, ForeignInitializer.CType returnType, ForeignInitializer.CType... arggumentTypes) Downcall.getName()
Gets the name.void
makeAccessible
(boolean b) Make accessible.void
setMissingSymbolsPolicy
(ForeignInitializer.MissingSymbolsPolicy missingSymbolsPolicy) Sets the missing symbols policy.void
Sets the name.<U> ForeignUpcall
<U> Upcall.<U> ForeignUpcall
<U> upcallStatic
(Class<?> clazz, String signature) Upcall static.<U> ForeignUpcall
<U> upcallStatic
(Class<?> clazz, String methodName, ForeignInitializer.CType returnType, ForeignInitializer.CType... argTypes) Upcall static.<U> ForeignUpcall
<U> upcallVirtual
(String signature, Class<?> clazz, Consumer<Method> methodSetup) Upcall virtual.
-
Constructor Details
-
ForeignInitializer
Instantiates a new foreign initializer.- Parameters:
name
- the name
-
ForeignInitializer
protected ForeignInitializer(String name, ForeignInitializer.DowncallSupplier<T> newFunctionSupplier, BiFunction<String, Throwable, T> exceptionSupplier, MethodHandles.Lookup lookup) Instantiates a new foreign initializer.- Parameters:
name
- the namenewFunctionSupplier
- the new function supplierexceptionSupplier
- the exception supplierlookup
- the lookup
-
ForeignInitializer
Instantiates a new foreign initializer.- Parameters:
name
- the namelookup
- the lookup
-
-
Method Details
-
close
Close.- Specified by:
close
in interfaceAutoCloseable
- Throws:
ExceptionInInitializerError
- the exception in initializer error- See Also:
-
downcall
Create ForeignDowncall from given signature. Function name must be part of the signature. For example given this signature"getpid()I;"
where 'getpid' is the function name and will be used as a symbol to lookup the native function.- Parameters:
signature
- the signature- Returns:
- the foreign function
-
downcall
public T downcall(String symbolName, ForeignInitializer.CType returnType, ForeignInitializer.CType... arggumentTypes) Downcall.- Parameters:
symbolName
- the symbol namereturnType
- the return typearggumentTypes
- the arggument types- Returns:
- the t
-
getName
-
makeAccessible
public void makeAccessible(boolean b) Make accessible.- Parameters:
b
- the b
-
setMissingSymbolsPolicy
Sets the missing symbols policy.- Parameters:
missingSymbolsPolicy
- the new missing symbols policy
-
setName
-
upcallStatic
Upcall static.- Type Parameters:
U
- the generic type- Parameters:
clazz
- the clazzsignature
- the signature- Returns:
- the foreign upcall
-
upcallStatic
public <U> ForeignUpcall<U> upcallStatic(Class<?> clazz, String methodName, ForeignInitializer.CType returnType, ForeignInitializer.CType... argTypes) Upcall static.- Type Parameters:
U
- the generic type- Parameters:
clazz
- the clazzmethodName
- the method namereturnType
- the return typeargTypes
- the arg types- Returns:
- the foreign upcall
-
upcall
Upcall.- Type Parameters:
U
- the generic type- Parameters:
signature
- the signatureclazz
- the clazz- Returns:
- the foreign upcall
-
upcallVirtual
public <U> ForeignUpcall<U> upcallVirtual(String signature, Class<?> clazz, Consumer<Method> methodSetup) Upcall virtual.- Type Parameters:
U
- the generic type- Parameters:
signature
- the signatureclazz
- the clazzmethodSetup
- the method setup- Returns:
- the foreign upcall
-