Class Overrides

java.lang.Object
org.javagi.gobject.types.Overrides

@NullMarked public class Overrides extends Object
Helper class to register method overrides in a new GType.
  • Constructor Details

    • Overrides

      public Overrides()
  • Method Details

    • overrideClassMethods

      public static <TC extends TypeClass> @Nullable Consumer<TypeClass> overrideClassMethods(Class<?> cls)
      Find declared methods that override methods defined in a GObject type class, and return a class initializer lambda that will register the method overrides in the class virtual function table.
      Parameters:
      cls - the class that possibly declares method overrides
      Returns:
      a lambda to run during class initialization that will register the virtual functions
    • lookupVirtualMethodParent

      public static MemorySegment lookupVirtualMethodParent(MemorySegment address, MemoryLayout layout, String name)
      Returns a function pointer to the specified virtual method. The pointer is retrieved from the TypeClass of the parent class of the instance.
      Parameters:
      address - the memory address of the object instance
      layout - the memory layout of the object's TypeClass
      name - the name of the virtual method (as defined in the TypeClass)
      Returns:
      a function pointer to the requested virtual method
    • lookupVirtualMethodParent

      public static MemorySegment lookupVirtualMethodParent(MemorySegment address, MemoryLayout layout, String name, Type ifaceType)
      Returns a function pointer to the specified virtual method. The pointer is retrieved from the TypeInterface with the specified GType, implemented by the parent class of the instance.
      Parameters:
      address - the memory address of the object instance
      layout - the memory layout of the parent object's TypeClass
      name - the name of the virtual method (as defined in the TypeInterface)
      ifaceType - the GType of the interface that declares the virtual method
      Returns:
      a function pointer to the requested virtual method