Class TypeInstance

java.lang.Object
org.javagi.base.ProxyInstance
org.gnome.gobject.TypeInstance
All Implemented Interfaces:
Proxy
Direct Known Subclasses:
Bitmask, DoubleRange, Event, Expression, FlagSet, Fraction, FractionRange, GObject, Int64Range, IntRange, ParamSpec, RenderNode, ValueArray, ValueList

@Generated("org.javagi.JavaGI") public class TypeInstance extends ProxyInstance
An opaque structure used as the base of all type instances.
  • Constructor Details

    • TypeInstance

      public TypeInstance(MemorySegment address)
      Create a TypeInstance proxy instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • TypeInstance

      public TypeInstance(Arena arena)
      Allocate a new TypeInstance.
      Parameters:
      arena - to control the memory allocation scope
    • TypeInstance

      public TypeInstance()
      Allocate a new TypeInstance. The memory is allocated with Arena.ofAuto().
    • TypeInstance

      public TypeInstance(TypeClass gClass, Arena arena)
      Allocate a new TypeInstance with the fields set to the provided values.
      Parameters:
      gClass - value for the field gClass
      arena - to control the memory allocation scope
    • TypeInstance

      public TypeInstance(TypeClass gClass)
      Allocate a new TypeInstance with the fields set to the provided values. The memory is allocated with Arena.ofAuto().
      Parameters:
      gClass - value for the field gClass
  • Method Details

    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • readGClass

      public TypeClass readGClass()
      Read the value of the field g_class.
      Returns:
      The value of the field g_class
    • writeGClass

      public void writeGClass(TypeClass gClass)
      Write a value in the field g_class.
      Parameters:
      gClass - The new value for the field g_class
    • getPrivate

      public @Nullable MemorySegment getPrivate(Type privateType)
    • callParent

      protected void callParent(boolean callParent)
      Set the flag that determines if for virtual method calls, g_type_class_peek_parent() is used to obtain the function pointer of the parent type instead of the instance class.
      Parameters:
      callParent - true to call the parent vfunc instead of an overridden vfunc
    • callParent

      public boolean callParent()
      Returns the flag that determines if for virtual method calls, g_type_class_peek_parent() is used to obtain the function pointer of the parent type instead of the instance class.
      Returns:
      true when parent vfunc is called instead of an overridden vfunc, or false when the overridden vfunc of the instance is called.
    • cast

      public <T extends TypeInstance> T cast(Class<T> to)
      Cast this instance to the requested type, if the GTypes are compatible.
      Type Parameters:
      T - the type of the intended class (must be a GTypeInstance)
      Parameters:
      to - the intended class
      Returns:
      a new instance of the requested class
      Throws:
      IllegalArgumentException - when to is not a registered GType
      ClassCastException - when the GType of this instance does not derive from the GType of to