Class CFacade

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected long __io__address
      Address of the data for this instance in an existing block.
      protected int __io__arch_index
      The architecure index is used internally to determine the position of a struct member variable from its descriptor, in respect to the encoding of the underlying block.
      protected Block __io__block
      Block, which contains the data of the instance.
      protected BlockTable __io__blockTable
      Block table which contains the block with the data of the associated instance.
      protected int __io__pointersize
      This is the address width used by the encoding of the underlying data.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected CFacade​(long address, Block block, BlockTable blockTable)
      Common constructor for a facade on an existing instance of a DNA struct, a pointer or an array.
      protected CFacade​(CFacade other, long targetAddress)
      Copy constructor, which assigns the instantiated facade to a another address.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      CPointer<java.lang.Object> __io__addressof​(long[] fieldDescriptor)
      This method creates a void pointer on the field identified by 'fieldDescriptor' of the struct represented by the facade (see static fields __DNA__FIELD__<fieldname> in the facades).
      static <T extends CFacade>
      CPointer<T>
      __io__addressof​(T object)
      This method creates a pointer on the given instance (object).
      protected boolean __io__equals​(CFacade facade, long address)
      Tests whether the facade references the given address in the same file as the given facade.
      protected void __io__generic__copy​(CFacade source)
      This method does a highlevel copy of the given source to this object.
      protected static void __io__generic__copy​(CFacade target, CFacade source)
      Does a high-level copy (meber by member) from source to target.
      static boolean __io__instanceof​(CFacade object, java.lang.Class<?> clazz)
      Tests whether the given object is an instance or some subclass of class clazz.
      protected static void __io__native__copy​(Block targetBlock, long targetAddress, CFacade source)
      This method performs a low level copy of the given object to the given target address in the target block.
      static CFacade __io__newInstance​(java.lang.Class<? extends CFacade> type, long address, Block block, BlockTable blockTable)
      Creates a new facade instance of the given type.
      protected boolean __io__same__encoding​(CFacade facadeA, CFacade facadeB)
      Tests whether the underlying data blocks of both facades use the same encoding (byte order and address length).
      long __io__sizeof​(java.lang.Class<?> ctype)
      This method returns the size of the C type which corresponds to the given Java type according to the type mapping of Java Blend.
      static long __io__sizeof​(java.lang.Class<?> ctype, int addressWidth)
      This method returns the size of the C type which corresponds to the given Java type according to the type mapping of Java Blend.
      static boolean __io__subclassof​(java.lang.Class<?> type, java.lang.Class<?> superType)
      Tests whether the given type is a subclass of superType.
      boolean equals​(java.lang.Object obj)  
      int hashCode()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • __io__address

        protected long __io__address
        Address of the data for this instance in an existing block.
      • __io__blockTable

        protected BlockTable __io__blockTable
        Block table which contains the block with the data of the associated instance.
      • __io__block

        protected Block __io__block
        Block, which contains the data of the instance.
      • __io__arch_index

        protected int __io__arch_index
        The architecure index is used internally to determine the position of a struct member variable from its descriptor, in respect to the encoding of the underlying block.
      • __io__pointersize

        protected int __io__pointersize
        This is the address width used by the encoding of the underlying data.
    • Constructor Detail

      • CFacade

        protected CFacade​(long address,
                          Block block,
                          BlockTable blockTable)
        Common constructor for a facade on an existing instance of a DNA struct, a pointer or an array.

        Preconditions:

        • There must exist a block in the blockTable which is assigned to the given address
        Parameters:
        address - Start address of the instance.
        block - The block which contains the address.
        blockTable - Block table, which contains the block.
      • CFacade

        protected CFacade​(CFacade other,
                          long targetAddress)
        Copy constructor, which assigns the instantiated facade to a another address. Useful when iterating over multiple instances of the same struct type in a block.

        Preconditions:

        targetAddress has to be in the block which is currently assigned to the 'other' facade.
        Parameters:
        other - Instance to be copied.
        targetAddress - Start address of the instance.
    • Method Detail

      • __io__sizeof

        public long __io__sizeof​(java.lang.Class<?> ctype)
        This method returns the size of the C type which corresponds to the given Java type according to the type mapping of Java Blend. The method uses the architecture specifications (i.e. pointer size) associated with the block of the instance, this method was called on.
        Parameters:
        ctype - The type which size is requested. Any kind of type representing a C data type, such as any of the sub-classes of CFacade, a CArrayFacade, CPointer or any of the primitive types (long, int, char ...).
        Returns:
        sizeof(ctype)
      • __io__sizeof

        public static long __io__sizeof​(java.lang.Class<?> ctype,
                                        int addressWidth)
        This method returns the size of the C type which corresponds to the given Java type according to the type mapping of Java Blend.
        Parameters:
        ctype - Any kind of type representing a C data type, such as any of the sub-classes of CFacade, a CArrayFacade, CPointer or any of the primitive types (long, int, char ...).
        addressWidth - Size of a pointer in bytes, based on architecture specifications (i.e. 4/8 bytes)
        Returns:
        sizeof(ctype)
      • __io__addressof

        public static <T extends CFacadeCPointer<T> __io__addressof​(T object)
        This method creates a pointer on the given instance (object).
        Parameters:
        object - The instance whose pointer is requested.
        Returns:
        pointer on the given instance
      • __io__addressof

        public CPointer<java.lang.Object> __io__addressof​(long[] fieldDescriptor)
        This method creates a void pointer on the field identified by 'fieldDescriptor' of the struct represented by the facade (see static fields __DNA__FIELD__<fieldname> in the facades).

        The returned pointer has to be casted (by means of CPointer.cast(Class) and similar methods) in order to use pointer arithmetics on it. We had the choice here to either carry all type information for every field over to the runtime model (and waste a lot of performance) or deal with the risk of having void pointers. Since it is very rare that pointers on fields are needed, we decided to go with this approach.

        This method is highly dangerous because we do not check, whether the field descriptor actually belongs to the facade and it is directly interpreted as offset to the structs base address.

        Parameters:
        fieldDescriptor - The __DNA__FIELD__<fieldname> descriptor of the field, who's address will be determined.
        Returns:
        Pointer on requested field.
      • __io__subclassof

        public static boolean __io__subclassof​(java.lang.Class<?> type,
                                               java.lang.Class<?> superType)
        Tests whether the given type is a subclass of superType.
        Parameters:
        type - type to be tested.
        superType - expected base class of the given type.
        Returns:
        true if true.
      • __io__instanceof

        public static boolean __io__instanceof​(CFacade object,
                                               java.lang.Class<?> clazz)
        Tests whether the given object is an instance or some subclass of class clazz.
      • __io__newInstance

        public static CFacade __io__newInstance​(java.lang.Class<? extends CFacade> type,
                                                long address,
                                                Block block,
                                                BlockTable blockTable)
                                         throws java.lang.InstantiationException,
                                                java.lang.IllegalAccessException,
                                                java.lang.IllegalArgumentException,
                                                java.lang.reflect.InvocationTargetException,
                                                java.lang.NoSuchMethodException,
                                                java.lang.SecurityException
        Creates a new facade instance of the given type.
        Parameters:
        type - The type of facade to instantiate.
        address - The associated address for the instantiated facade.
        block - The block, which contains the address.
        blockTable - the global block map of the associated file.
        Returns:
        new facade instance of the given type
        Throws:
        java.lang.InstantiationException
        java.lang.IllegalAccessException
        java.lang.IllegalArgumentException
        java.lang.reflect.InvocationTargetException
        java.lang.NoSuchMethodException
        java.lang.SecurityException
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • __io__equals

        protected boolean __io__equals​(CFacade facade,
                                       long address)
        Tests whether the facade references the given address in the same file as the given facade.
        Parameters:
        facade -
        address -
        Returns:
        address (virtual) of the object, wrapped by the given facade.
      • __io__native__copy

        protected static void __io__native__copy​(Block targetBlock,
                                                 long targetAddress,
                                                 CFacade source)
                                          throws java.io.IOException

        This method performs a low level copy of the given object to the given target address in the target block. This requires, that the target

          Parameters:
          targetBlock - Block, which will receive the written data.
          targetAddress - Target address where the data will be written to. This address has to be in range of the given target block.
          source - facade with the data to be copied to the given address.
          Throws:
          java.io.IOException
        • __io__generic__copy

          protected void __io__generic__copy​(CFacade source)
                                      throws java.io.IOException
          This method does a highlevel copy of the given source to this object.

          The method is used in case a lowlevel copy (see __io__native__copy(Block, long, CFacade)) is not possible due to different encodings of the underlying blocks (see __io__same__encoding(CFacade, CFacade).

          Mandatory Preconditions

          • This object and the source object are of exactly the same type.
          • The source is not a CPointer.
            • The method is overridden by CArrayFacade.

          Parameters:
          source - An object derived from CFacade or CArrayFacade, but not CPointer.
          Throws:
          java.io.IOException
        • __io__generic__copy

          protected static void __io__generic__copy​(CFacade target,
                                                    CFacade source)
                                             throws java.io.IOException
          Does a high-level copy (meber by member) from source to target. Same as target.__io__generic__copy(source).
          Parameters:
          target - Facade, which gets its data overriden with the values of source.
          source - Facade, which data gets copied to target.
          Throws:
          java.io.IOException
          See Also:
          __io__generic__copy(CFacade)
        • __io__same__encoding

          protected boolean __io__same__encoding​(CFacade facadeA,
                                                 CFacade facadeB)
          Tests whether the underlying data blocks of both facades use the same encoding (byte order and address length).