Package org.bytedeco.javacpp
Class FunctionPointer
- java.lang.Object
-
- org.bytedeco.javacpp.Pointer
-
- org.bytedeco.javacpp.FunctionPointer
-
- All Implemented Interfaces:
java.lang.AutoCloseable
public abstract class FunctionPointer extends Pointer
All peer classes to function pointers must derive from FunctionPointer. Defining a subclass letsGenerator
create a native function type. A C++ function object gets instantiated for each call toallocate()
as well. That function object can be accessed by annotating any method parameter withByVal
orByRef
. By default, an actual function pointer gets passedByPtr
.To use FunctionPointer, subclass and add a native method named
call()
orapply()
, along with its return type and parameters, as well as the usualnative void allocate()
method to support explicit allocation, which is typically a requirement for callback functions. We can implement a callback in Java by further subclassing and overridingcall/apply()
.If you have an address to a native function, it is also possible to call it by defining a
ValueSetter
method with a singlePointer
parameter, along withnative
declarations forallocate()
andcall()
. After allocating the object and setting the value, we can be call it from Java.- See Also:
Generator
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.bytedeco.javacpp.Pointer
Pointer.CustomDeallocator, Pointer.Deallocator, Pointer.DeallocatorReference, Pointer.DeallocatorThread, Pointer.NativeDeallocator, Pointer.ProxyDeallocator, Pointer.ReferenceCounter
-
-
Field Summary
-
Fields inherited from class org.bytedeco.javacpp.Pointer
address, capacity, deallocatorThread, limit, maxBytes, maxPhysicalBytes, maxRetries, position
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
FunctionPointer()
protected
FunctionPointer(Pointer p)
-
Method Summary
-
Methods inherited from class org.bytedeco.javacpp.Pointer
address, asBuffer, asByteBuffer, availablePhysicalBytes, calloc, capacity, capacity, close, deallocate, deallocate, deallocateReferences, deallocator, deallocator, equals, fill, formatBytes, free, getDirectBufferAddress, getPointer, getPointer, getPointer, getPointer, hashCode, init, interruptDeallocatorThread, isNull, isNull, limit, limit, malloc, maxBytes, maxPhysicalBytes, memchr, memcmp, memcpy, memmove, memset, offsetAddress, offsetof, offsetof, parseBytes, physicalBytes, physicalBytesInaccurate, position, position, put, realloc, referenceCount, releaseReference, retainReference, setNull, sizeof, sizeof, toString, totalBytes, totalCount, totalPhysicalBytes, withDeallocator, zero
-
-
-
-
Constructor Detail
-
FunctionPointer
protected FunctionPointer()
-
FunctionPointer
protected FunctionPointer(Pointer p)
-
-