Package org.gnome.glib
Class Hook
java.lang.Object
org.javagi.base.ProxyInstance
org.gnome.glib.Hook
- All Implemented Interfaces:
Proxy
The
GHook struct represents a single hook function in a GHookList.-
Constructor Summary
ConstructorsConstructorDescriptionHook()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 HookAllocates space for aGHookand initializes it.intcompareIds(Hook sibling) Compares the ids of twoGHookelements, returning a negative value if the second id is greater than the first.static booleanDestroys aGHook, given its ID.static voiddestroyLink(HookList hookList, Hook hook) Removes oneGHookfrom aGHookList, marking it inactive and calling g_hook_unref() on it.static Hookfind(HookList hookList, boolean needValids, @Nullable HookFindFunc func) Finds aGHookin aGHookListusing the given function to test for a match.static HookfindData(HookList hookList, boolean needValids, @Nullable MemorySegment data) Finds aGHookin aGHookListwith the given data.static HookfindFunc(HookList hookList, boolean needValids, @Nullable MemorySegment func) Finds aGHookin aGHookListwith the given function.static HookfindFuncData(HookList hookList, boolean needValids, MemorySegment func, @Nullable MemorySegment data) Finds aGHookin aGHookListwith the given function and data.static HookfirstValid(HookList hookList, boolean mayBeInCall) Returns the firstGHookin aGHookListwhich has not been destroyed.static voidCalls theGHookListfinalizeHookfunction if it exists, and frees the memory allocated for theGHook.static HookReturns theGHookwith the given id, ornullif it is not found.static MemoryLayoutThe memory layout of the native struct.static voidinsertBefore(HookList hookList, @Nullable Hook sibling, Hook hook) Inserts aGHookinto aGHookList, before a givenGHook.static voidinsertSorted(HookList hookList, Hook hook, @Nullable HookCompareFunc func) Inserts aGHookinto aGHookList, sorted by the given function.static HookReturns the nextGHookin aGHookListwhich has not been destroyed.static voidPrepends aGHookon the start of aGHookList.readData()Read the value of the fielddata.@Nullable DestroyNotifyRead the value of the fielddestroy.intRead the value of the fieldflags.readFunc()Read the value of the fieldfunc.intRead the value of the fieldhook_id.readNext()Read the value of the fieldnext.readPrev()Read the value of the fieldprev.intRead the value of the fieldref_count.static HookIncrements the reference count for aGHook.static voidDecrements the reference count of aGHook.voidwriteData(MemorySegment data) Write a value in the fielddata.voidwriteDestroy(@Nullable DestroyNotify destroy, Arena _arena) Write a value in the fielddestroy.voidwriteFlags(int flags) Write a value in the fieldflags.voidwriteFunc(MemorySegment func) Write a value in the fieldfunc.voidwriteHookId(int hookId) Write a value in the fieldhook_id.voidWrite a value in the fieldnext.voidWrite a value in the fieldprev.voidwriteRefCount(int refCount) Write a value in the fieldref_count.Methods inherited from class org.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 fielddatanext- value for the fieldnextprev- value for the fieldprevrefCount- value for the fieldrefCounthookId- value for the fieldhookIdflags- value for the fieldflagsfunc- value for the fieldfuncdestroy- value for the fielddestroyarena- 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 fielddatanext- value for the fieldnextprev- value for the fieldprevrefCount- value for the fieldrefCounthookId- value for the fieldhookIdflags- value for the fieldflagsfunc- value for the fieldfuncdestroy- 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- aGHookListhookId- a hook ID- Returns:
trueif theGHookwas found in theGHookListand destroyed
-
destroyLink
-
find
Finds aGHookin aGHookListusing the given function to test for a match.- Parameters:
hookList- aGHookListneedValids-trueifGHookelements which have been destroyed should be skippedfunc- the function to call for eachGHook, which should returntruewhen theGHookhas been found- Returns:
- the found
GHookornullif no matchingGHookis found
-
findData
Finds aGHookin aGHookListwith the given data.- Parameters:
hookList- aGHookListneedValids-trueifGHookelements which have been destroyed should be skippeddata- the data to find- Returns:
- the
GHookwith the givendataornullif no matchingGHookis found
-
findFunc
Finds aGHookin aGHookListwith the given function.- Parameters:
hookList- aGHookListneedValids-trueifGHookelements which have been destroyed should be skippedfunc- the function to find- Returns:
- the
GHookwith the givenfuncornullif no matchingGHookis found
-
findFuncData
public static Hook findFuncData(HookList hookList, boolean needValids, MemorySegment func, @Nullable MemorySegment data) Finds aGHookin aGHookListwith the given function and data.- Parameters:
hookList- aGHookListneedValids-trueifGHookelements which have been destroyed should be skippedfunc- the function to finddata- the data to find- Returns:
- the
GHookwith the givenfuncanddataornullif no matchingGHookis found
-
firstValid
Returns the firstGHookin aGHookListwhich has not been destroyed. The reference count for theGHookis 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- aGHookListmayBeInCall-trueif hooks which are currently running (e.g. in another thread) are considered valid. If set tofalse, these are skipped- Returns:
- the first valid
GHook, ornullif none are valid
-
free
-
get
-
insertBefore
-
insertSorted
Inserts aGHookinto aGHookList, sorted by the given function.- Parameters:
hookList- aGHookListhook- theGHookto insertfunc- the comparison function used to sort theGHookelements
-
nextValid
Returns the nextGHookin aGHookListwhich has not been destroyed. The reference count for theGHookis incremented, so you must call g_hook_unref() to restore it when no longer needed. (Or continue to call g_hook_next_valid() untilnullis returned.)- Parameters:
hookList- aGHookListhook- the currentGHookmayBeInCall-trueif hooks which are currently running (e.g. in another thread) are considered valid. If set tofalse, these are skipped- Returns:
- the next valid
GHook, ornullif none are valid
-
prepend
-
ref
-
unref
-
compareIds
Compares the ids of twoGHookelements, returning a negative value if the second id is greater than the first.- Parameters:
sibling- aGHookto compare with this Hook- Returns:
- a value <= 0 if the id of
siblingis >= the id of this Hook
-