Package org.gnome.glib
Class Hook
java.lang.Object
io.github.jwharm.javagi.base.ProxyInstance
org.gnome.glib.Hook
- All Implemented Interfaces:
Proxy
The
GHook
struct represents a single hook function in a GHookList
.-
Constructor Summary
ConstructorDescriptionHook()
Allocate a new Hook.Allocate a new Hook.Hook
(MemorySegment address) Create a Hook proxy instance for the provided memory address.Hook
(MemorySegment data, Hook next, Hook prev, int refCount, int hookId, int flags, MemorySegment func, DestroyNotify destroy) Allocate a new Hook with the fields set to the provided values.Hook
(MemorySegment data, Hook next, Hook prev, int refCount, int hookId, int flags, MemorySegment func, DestroyNotify destroy, Arena arena) Allocate a new Hook with the fields set to the provided values. -
Method Summary
Modifier and TypeMethodDescriptionstatic Hook
Allocates space for aGHook
and initializes it.int
compareIds
(Hook sibling) Compares the ids of twoGHook
elements, returning a negative value if the second id is greater than the first.static boolean
Destroys aGHook
, given its ID.static void
destroyLink
(HookList hookList, Hook hook) Removes oneGHook
from aGHookList
, marking it inactive and calling g_hook_unref() on it.static Hook
find
(HookList hookList, boolean needValids, HookFindFunc func) Finds aGHook
in aGHookList
using the given function to test for a match.static Hook
findData
(HookList hookList, boolean needValids, @Nullable MemorySegment data) Finds aGHook
in aGHookList
with the given data.static Hook
findFunc
(HookList hookList, boolean needValids, @Nullable MemorySegment func) Finds aGHook
in aGHookList
with the given function.static Hook
findFuncData
(HookList hookList, boolean needValids, MemorySegment func, @Nullable MemorySegment data) Finds aGHook
in aGHookList
with the given function and data.static Hook
firstValid
(HookList hookList, boolean mayBeInCall) Returns the firstGHook
in aGHookList
which has not been destroyed.static void
Calls theGHookList
finalizeHook
function if it exists, and frees the memory allocated for theGHook
.static Hook
Returns theGHook
with the given id, ornull
if it is not found.static MemoryLayout
The memory layout of the native struct.static void
insertBefore
(HookList hookList, @Nullable Hook sibling, Hook hook) Inserts aGHook
into aGHookList
, before a givenGHook
.static void
insertSorted
(HookList hookList, Hook hook, HookCompareFunc func) Inserts aGHook
into aGHookList
, sorted by the given function.static Hook
Returns the nextGHook
in aGHookList
which has not been destroyed.static void
Prepends aGHook
on the start of aGHookList
.readData()
Read the value of the fielddata
.Read the value of the fielddestroy
.int
Read the value of the fieldflags
.readFunc()
Read the value of the fieldfunc
.int
Read the value of the fieldhook_id
.readNext()
Read the value of the fieldnext
.readPrev()
Read the value of the fieldprev
.int
Read the value of the fieldref_count
.static Hook
Increments the reference count for aGHook
.static void
Decrements the reference count of aGHook
.void
writeData
(MemorySegment data) Write a value in the fielddata
.void
writeDestroy
(DestroyNotify destroy, Arena _arena) Write a value in the fielddestroy
.void
writeFlags
(int flags) Write a value in the fieldflags
.void
writeFunc
(MemorySegment func) Write a value in the fieldfunc
.void
writeHookId
(int hookId) Write a value in the fieldhook_id
.void
Write a value in the fieldnext
.void
Write a value in the fieldprev
.void
writeRefCount
(int refCount) Write a value in the fieldref_count
.Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
Hook
Create a Hook proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
Hook
Allocate a new Hook.- Parameters:
arena
- to control the memory allocation scope
-
Hook
public Hook()Allocate a new Hook. The memory is allocated withArena.ofAuto()
. -
Hook
public Hook(MemorySegment data, Hook next, Hook prev, int refCount, int hookId, int flags, MemorySegment func, DestroyNotify destroy, Arena arena) Allocate a new Hook with the fields set to the provided values.- Parameters:
data
- value for the fielddata
next
- value for the fieldnext
prev
- value for the fieldprev
refCount
- value for the fieldrefCount
hookId
- value for the fieldhookId
flags
- value for the fieldflags
func
- value for the fieldfunc
destroy
- value for the fielddestroy
arena
- to control the memory allocation scope
-
Hook
public Hook(MemorySegment data, Hook next, Hook prev, int refCount, int hookId, int flags, MemorySegment func, DestroyNotify destroy) Allocate a new Hook with the fields set to the provided values. The memory is allocated withArena.ofAuto()
.- Parameters:
data
- value for the fielddata
next
- value for the fieldnext
prev
- value for the fieldprev
refCount
- value for the fieldrefCount
hookId
- value for the fieldhookId
flags
- value for the fieldflags
func
- value for the fieldfunc
destroy
- value for the fielddestroy
-
-
Method Details
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
readData
Read the value of the fielddata
.- Returns:
- The value of the field
data
-
writeData
Write a value in the fielddata
.- Parameters:
data
- The new value for the fielddata
-
readNext
-
writeNext
Write a value in the fieldnext
.- Parameters:
next
- The new value for the fieldnext
-
readPrev
-
writePrev
Write a value in the fieldprev
.- Parameters:
prev
- The new value for the fieldprev
-
readRefCount
public int readRefCount()Read the value of the fieldref_count
.- Returns:
- The value of the field
ref_count
-
writeRefCount
public void writeRefCount(int refCount) Write a value in the fieldref_count
.- Parameters:
refCount
- The new value for the fieldref_count
-
readHookId
public int readHookId()Read the value of the fieldhook_id
.- Returns:
- The value of the field
hook_id
-
writeHookId
public void writeHookId(int hookId) Write a value in the fieldhook_id
.- Parameters:
hookId
- The new value for the fieldhook_id
-
readFlags
public int readFlags()Read the value of the fieldflags
.- Returns:
- The value of the field
flags
-
writeFlags
public void writeFlags(int flags) Write a value in the fieldflags
.- Parameters:
flags
- The new value for the fieldflags
-
readFunc
Read the value of the fieldfunc
.- Returns:
- The value of the field
func
-
writeFunc
Write a value in the fieldfunc
.- Parameters:
func
- The new value for the fieldfunc
-
readDestroy
Read the value of the fielddestroy
.- Returns:
- The value of the field
destroy
-
writeDestroy
Write a value in the fielddestroy
.- Parameters:
destroy
- The new value for the fielddestroy
_arena
- to control the memory allocation scope
-
alloc
-
destroy
Destroys aGHook
, given its ID.- Parameters:
hookList
- aGHookList
hookId
- a hook ID- Returns:
true
if theGHook
was found in theGHookList
and destroyed
-
destroyLink
-
find
Finds aGHook
in aGHookList
using the given function to test for a match.- Parameters:
hookList
- aGHookList
needValids
-true
ifGHook
elements which have been destroyed should be skippedfunc
- the function to call for eachGHook
, which should returntrue
when theGHook
has been found- Returns:
- the found
GHook
ornull
if no matchingGHook
is found
-
findData
public static Hook findData(HookList hookList, boolean needValids, @Nullable @Nullable MemorySegment data) Finds aGHook
in aGHookList
with the given data.- Parameters:
hookList
- aGHookList
needValids
-true
ifGHook
elements which have been destroyed should be skippeddata
- the data to find- Returns:
- the
GHook
with the givendata
ornull
if no matchingGHook
is found
-
findFunc
public static Hook findFunc(HookList hookList, boolean needValids, @Nullable @Nullable MemorySegment func) Finds aGHook
in aGHookList
with the given function.- Parameters:
hookList
- aGHookList
needValids
-true
ifGHook
elements which have been destroyed should be skippedfunc
- the function to find- Returns:
- the
GHook
with the givenfunc
ornull
if no matchingGHook
is found
-
findFuncData
public static Hook findFuncData(HookList hookList, boolean needValids, MemorySegment func, @Nullable @Nullable MemorySegment data) Finds aGHook
in aGHookList
with the given function and data.- Parameters:
hookList
- aGHookList
needValids
-true
ifGHook
elements which have been destroyed should be skippedfunc
- the function to finddata
- the data to find- Returns:
- the
GHook
with the givenfunc
anddata
ornull
if no matchingGHook
is found
-
firstValid
Returns the firstGHook
in aGHookList
which has not been destroyed. The reference count for theGHook
is incremented, so you must call g_hook_unref() to restore it when no longer needed. (Or call g_hook_next_valid() if you are stepping through theGHookList
.)- Parameters:
hookList
- aGHookList
mayBeInCall
-true
if hooks which are currently running (e.g. in another thread) are considered valid. If set tofalse
, these are skipped- Returns:
- the first valid
GHook
, ornull
if none are valid
-
free
-
get
-
insertBefore
-
insertSorted
Inserts aGHook
into aGHookList
, sorted by the given function.- Parameters:
hookList
- aGHookList
hook
- theGHook
to insertfunc
- the comparison function used to sort theGHook
elements
-
nextValid
Returns the nextGHook
in aGHookList
which has not been destroyed. The reference count for theGHook
is incremented, so you must call g_hook_unref() to restore it when no longer needed. (Or continue to call g_hook_next_valid() untilnull
is returned.)- Parameters:
hookList
- aGHookList
hook
- the currentGHook
mayBeInCall
-true
if hooks which are currently running (e.g. in another thread) are considered valid. If set tofalse
, these are skipped- Returns:
- the next valid
GHook
, ornull
if none are valid
-
prepend
-
ref
-
unref
-
compareIds
Compares the ids of twoGHook
elements, returning a negative value if the second id is greater than the first.- Parameters:
sibling
- aGHook
to compare with this Hook- Returns:
- a value <= 0 if the id of
sibling
is >= the id of this Hook
-