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
Nested ClassesModifier and TypeClassDescriptionstatic enumThe Enum CType.static interfaceForeignInitializer.DowncallSupplier<T extends ForeignDowncall<?>>The Interface DowncallSupplier.static interfaceThe Interface MethodHandleLookup.static interfaceThe Interface MissingSymbolsPolicy. -
Constructor Summary
ConstructorsModifierConstructorDescriptionForeignInitializer(String name) Instantiates a new foreign initializer.ForeignInitializer(String name, MethodHandles.Lookup lookup) Instantiates a new foreign initializer.protectedForeignInitializer(String name, ForeignInitializer.DowncallSupplier<T> newFunctionSupplier, BiFunction<String, Throwable, T> exceptionSupplier, MethodHandles.Lookup lookup) Instantiates a new foreign initializer. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close.Create ForeignDowncall from given signature.downcall(String symbolName, ForeignInitializer.CType returnType, ForeignInitializer.CType... arggumentTypes) Downcall.getName()Gets the name.voidmakeAccessible(boolean b) Make accessible.voidsetMissingSymbolsPolicy(ForeignInitializer.MissingSymbolsPolicy missingSymbolsPolicy) Sets the missing symbols policy.voidSets 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:
closein 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
-