Interface ITypeFactory<T>

All Known Implementing Classes:
AbstractTypeFactory

public interface ITypeFactory<T>
  • Method Summary

    Modifier and Type
    Method
    Description
    create​(Nd dom, long address)
     
    void
    destruct​(Nd dom, long address)
    Invokes any cleanup code for this object.
    void
    destructFields​(Nd dom, long address)
    Invokes the delete method on all the fields of the object, and calls deleteFields on the superclass' type (if any).
    Returns the deletion semantics used for this object.
     
    int
     
    boolean
    If this returns false, the delete and deleteFields methods both always do nothing.
    boolean
    isReadyForDeletion​(Nd dom, long address)
    Returns true if this object is orphaned.
  • Method Details

    • destructFields

      void destructFields(Nd dom, long address)
      Invokes the delete method on all the fields of the object, and calls deleteFields on the superclass' type (if any). Does not perform any higher-level cleanup operations. This is only intended to be called from the deleteFields methods of a subtype or the delete method of this class.

      When destructing a type with a superclass, the correct destruction behavior is:

      • External code invokes the delete method on ITypeFactory
      • The ITypeFactory.delete method calls an instance method on the class (typically called T#delete()), which performs high-level deletion operations (if any).
      • T.delete also calls T.super.delete() (if any)
      • ITypeFactory.delete calls ITypeFactory.deleteFields, which performs low-level deletion operations on the fields, then calls ITypeFactory.deleteFields on the base type.
    • create

      T create(Nd dom, long address)
    • destruct

      void destruct(Nd dom, long address)
      Invokes any cleanup code for this object. In particular, it deallocates any memory allocated by the type's fields. Does not free the memory at address, though. This is used for both objects which were allocated their own memory block and objects which are embedded as fields within a larger object. If the object was given its own memory block, it is the caller's responsibility to invoke free after calling this method.
    • hasDestructor

      boolean hasDestructor()
      If this returns false, the delete and deleteFields methods both always do nothing.
    • getRecordSize

      int getRecordSize()
    • getElementClass

      Class<?> getElementClass()
    • isReadyForDeletion

      boolean isReadyForDeletion(Nd dom, long address)
      Returns true if this object is orphaned. If the object is refcounted, this means the refcount is 0. If the object is deleted via an owner pointer, this means the owner pointer is null.
    • getDeletionSemantics

      StructDef.DeletionSemantics getDeletionSemantics()
      Returns the deletion semantics used for this object.