All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.gnome.gobject.WeakNotify Maven / Gradle / Ivy

There is a newer version: 0.11.2
Show newest version
/* Java-GI - Java language bindings for GObject-Introspection-based libraries
 * Copyright (C) 2022-2023 Jan-Willem Harmannij
 *
 * SPDX-License-Identifier: LGPL-2.1-or-later
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, see .
 */

 /* This file has been generated with Java-GI.
  * Do not edit this file directly!
  * Visit https://jwharm.github.io/java-gi for more information.
  */

package org.gnome.gobject;

import io.github.jwharm.javagi.gobject.*;
import io.github.jwharm.javagi.gobject.types.*;
import io.github.jwharm.javagi.base.*;
import io.github.jwharm.javagi.interop.*;
import java.lang.foreign.*;
import java.lang.invoke.*;
import org.jetbrains.annotations.*;

/**
 * A {@link WeakNotify} function can be added to an object as a callback that gets
 * triggered when the object is finalized.
 * 

* Since the object is already being disposed when the {@link WeakNotify} is called, * there's not much you could do with the object, apart from e.g. using its * address as hash-index or the like. *

* In particular, this means it’s invalid to call g_object_ref(), * g_weak_ref_init(), g_weak_ref_set(), g_object_add_toggle_ref(), * g_object_weak_ref(), g_object_add_weak_pointer() or any function which calls * them on the object from this callback. */ @FunctionalInterface public interface WeakNotify { /** * A {@link WeakNotify} function can be added to an object as a callback that gets * triggered when the object is finalized. *

* Since the object is already being disposed when the {@link WeakNotify} is called, * there's not much you could do with the object, apart from e.g. using its * address as hash-index or the like. *

* In particular, this means it’s invalid to call g_object_ref(), * g_weak_ref_init(), g_weak_ref_set(), g_object_add_toggle_ref(), * g_object_weak_ref(), g_object_add_weak_pointer() or any function which calls * them on the object from this callback. */ void run(@Nullable java.lang.foreign.MemorySegment data, org.gnome.gobject.GObject whereTheObjectWas); /** * The {@code upcall} method is called from native code. The parameters * are marshalled and {@link #run} is executed. */ @ApiStatus.Internal default void upcall(MemorySegment data, MemorySegment whereTheObjectWas) { run(data, (org.gnome.gobject.GObject) InstanceCache.getForType(whereTheObjectWas, org.gnome.gobject.GObject::new, false)); } /** * Creates a callback that can be called from native code and executes the {@code run} method. * @return the memory address of the callback function */ default MemorySegment toCallback() { FunctionDescriptor _fdesc = FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS); MethodHandle _handle = Interop.upcallHandle(MethodHandles.lookup(), WeakNotify.class, _fdesc); return Linker.nativeLinker().upcallStub(_handle.bindTo(this), _fdesc, SegmentScope.global()); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy