Package jnr.ffi.byref

Class LongLongByReference

  • All Implemented Interfaces:
    java.io.Serializable, ByReference<java.lang.Long>

    public final class LongLongByReference
    extends AbstractNumberReference<java.lang.Long>
    LongLongByReference is used when the address of a native long long value must be passed as a parameter to a function.

    For example, the following C code,

     
     extern void get_a(long long * ap);
    
     long long foo(void) {
         long long a;
         // pass a reference to 'a' so get_a() can fill it out
         get_a(&a);
    
         return a;
     }
     
     

    Would be declared in java as

     
     interface Lib {
         void get_a(@Out LongLongByReference ap);
     }
     
     

    and used like this

     LongLongByReference ap = new LongLongByReference();
     lib.get_a(ap);
     System.out.printf("a from lib=%d\n", a.longValue());
     
    See Also:
    Serialized Form
    • Constructor Detail

      • LongLongByReference

        public LongLongByReference()
        Creates a new reference to a long long value initialized to zero.
      • LongLongByReference

        public LongLongByReference​(java.lang.Long value)
        Creates a new reference to a native longlong value
        Parameters:
        value - the initial native value
      • LongLongByReference

        public LongLongByReference​(long value)
        Creates a new reference to a native longlong value
        Parameters:
        value - the initial native value
    • Method Detail

      • toNative

        public void toNative​(Runtime runtime,
                             Pointer memory,
                             long offset)
        Copies the value to native memory
        Parameters:
        runtime - the current runtime.
        memory - the native memory buffer.
        offset - the memory offset.
      • fromNative

        public void fromNative​(Runtime runtime,
                               Pointer memory,
                               long offset)
        Copies the value from native memory
        Parameters:
        runtime - the current runtime.
        memory - the native memory buffer.
        offset - the memory offset.
      • nativeSize

        public final int nativeSize​(Runtime runtime)
        Gets the native size of type of reference in bytes.
        Parameters:
        runtime - the current runtime.
        Returns:
        the size of a byte in bytes