Esempio n. 1
0
 /**
  * Defines the specified struct as inner of this struct.
  *
  * @param struct the inner struct.
  * @return the specified struct.
  * @throws IllegalArgumentException if the specified struct is already an inner struct.
  */
 protected /*<S extends Struct> S*/ Struct inner(/*S*/ Struct struct) {
   if (struct._outer != null)
     throw new java.lang.IllegalArgumentException("struct: Already an inner struct");
   struct._outer = this;
   final int bitSize = struct.size() << 3;
   updateIndexes(struct._alignment, bitSize, bitSize);
   struct._outerOffset = (_bitIndex - bitSize) >> 3;
   return (/*S*/ Struct) struct;
 }
Esempio n. 2
0
 /**
  * Returns the byte buffer for this struct. This method will allocate a new <b>direct</b> buffer
  * if none has been set.
  *
  * <p>Changes to the buffer's content are visible in this struct, and vice versa.
  *
  * <p>The buffer of an inner struct is the same as its parent struct.
  *
  * <p>The position of a {@link Struct.Member struct's member} within the byte buffer is given by
  * {@link Struct.Member#position member.position()}
  *
  * @return the current byte buffer or a new direct buffer if none set.
  * @see #setByteBuffer
  */
 public final ByteBuffer getByteBuffer() {
   if (_outer != null) return _outer.getByteBuffer();
   return (_byteBuffer != null) ? _byteBuffer : newBuffer();
 }
Esempio n. 3
0
 /**
  * Returns the absolute position of this struct within its associated {@link #getByteBuffer byte
  * buffer}.
  *
  * @return the absolute position of this struct in the byte buffer.
  */
 public final int getByteBufferPosition() {
   return (_outer != null) ? _outer.getByteBufferPosition() + _outerOffset : _outerOffset;
 }