Establish the asymetry between DataInputStream and DataOutputStream
authorMike Beckerle <mbeckerle@tresys.com>
Wed, 6 Apr 2016 18:39:01 +0000 (14:39 -0400)
committerMike Beckerle <mbeckerle@tresys.com>
Tue, 3 May 2016 19:41:02 +0000 (15:41 -0400)
commit7577561c48b69b4b646167870bd341b1d8754c47
tree7f581bb2080029c1da41e1ecfc86ad98a07a0e45
parent940b5f494e366a0f5b009852ca6904e2c33049ee
Establish the asymetry between DataInputStream and DataOutputStream

The primary contribution of this commit is to establish the asymetry
between DataInputStream and DataOutputStream with respect to the
positions and limits in the bit stream.

For the DataInputStream, we have this concept of the current bitPos0b,
and optionally there may be abound called bitLimit0b. There are 1b
variants of these.

For parsing, these are always absolute values, that is they contain bit
position relative the ultimate start of the input stream where parsing
began.

For DataOutputStream, we have slighly different concepts.

There are absolute and relative variants. The absolute bitPosOb or
absBitPos0b is symmetric to the parser's bitPos0b. It's the position
relative to the ultimate start of the output stream.

However, we often do not know this value. So the UState and
DataOutputStream have a maybeAbsBitPos0b which can be MaybeULong.Nope if
the value isn't known.

In addition we have the relative or relBitPos0b. This is relative to the
start of whatever buffer we are doing unparsing into.

When unparsing, we often have to unparse into a buffer where the
ultimate actual absolute position isn't yet known, but we have to do the
unparsing anyway, for example so that we can measure exactly how long
something is.

Conversely, sometimes we simply must have the absolute output bit
position, for example, when computing the number of bits to insert to
achieve the required alignment.

Hence we have relBitPos0b - always known and is a value >= 0, and we
have maybeAbsBitPos0b which is a MaybeULong. If known it is >=0.

Corresponding to bit position we have bit limit, which is measured in
the same 0b or 1b units, but is *always* a maybe type, because even in
the case where we know the absolute position, we still may or may not
have any limit in place. Hence the UState and DataOutputStream have a

maybeRelBitLimit0b
and
maybeAbsBitLimit0b.

One invariant is this: when the absolute bit pos is known, then it is
the same as the relative bit pos. Similarly when the absolute bit limit
is known, then the relative bit limit is known and is equal.

All deprecation warnings fixed.

No warnings now. Turned back on -Xfatal-warnings in scala compile
options.

There is still CachedDynamic in here, which is now using Evaluatable, so
we have the caches on top of the caches still.

Added missing maybeAbsBitPos0b and 1b methods.
38 files changed:
build.sbt
daffodil-core/src/main/scala/edu/illinois/ncsa/daffodil/dsom/ElementBase.scala
daffodil-core/src/main/scala/edu/illinois/ncsa/daffodil/dsom/RuntimePropertyMixins.scala
daffodil-core/src/main/scala/edu/illinois/ncsa/daffodil/dsom/TermEncodingMixin.scala
daffodil-core/src/main/scala/edu/illinois/ncsa/daffodil/grammar/ElementBaseGrammarMixin.scala
daffodil-core/src/main/scala/edu/illinois/ncsa/daffodil/grammar/EncodingChangeMixin.scala
daffodil-core/src/main/scala/edu/illinois/ncsa/daffodil/processors/PrimitivesBinaryNumber.scala
daffodil-core/src/main/scala/edu/illinois/ncsa/daffodil/processors/PrimitivesLengthKind.scala
daffodil-core/src/main/scala/edu/illinois/ncsa/daffodil/processors/PrimitivesTextNumber.scala
daffodil-core/src/main/scala/edu/illinois/ncsa/daffodil/processors/RepPrims.scala
daffodil-core/src/main/scala/edu/illinois/ncsa/daffodil/processors/SpecifiedLength.scala
daffodil-io/src/main/scala/edu/illinois/ncsa/daffodil/io/ByteBufferDataInputStream.scala
daffodil-io/src/main/scala/edu/illinois/ncsa/daffodil/io/CharBufferDataOutputStream.scala
daffodil-io/src/main/scala/edu/illinois/ncsa/daffodil/io/DataInputStream.scala
daffodil-io/src/main/scala/edu/illinois/ncsa/daffodil/io/DataInputStreamImplMixin.scala
daffodil-io/src/main/scala/edu/illinois/ncsa/daffodil/io/DataOutputStream.scala
daffodil-io/src/main/scala/edu/illinois/ncsa/daffodil/io/DataOutputStreamImplMixin.scala
daffodil-io/src/main/scala/edu/illinois/ncsa/daffodil/io/DataStreamCommon.scala
daffodil-io/src/main/scala/edu/illinois/ncsa/daffodil/io/DataStreamCommonImplMixin.scala
daffodil-io/src/main/scala/edu/illinois/ncsa/daffodil/io/DirectOrBufferedDataOutputStream.scala
daffodil-io/src/test/scala-debug/edu/illinois/ncsa/daffodil/io/TestDataOutputStream.scala [new file with mode: 0644]
daffodil-macro-lib/src/main/scala/edu/illinois/ncsa/daffodil/io/IOMacros.scala
daffodil-runtime1-unparser/src/main/scala/edu/illinois/ncsa/daffodil/processors/unparsers/DelimitedUnparsers.scala
daffodil-runtime1-unparser/src/main/scala/edu/illinois/ncsa/daffodil/processors/unparsers/HexBinaryLengthUnparser.scala
daffodil-runtime1-unparser/src/main/scala/edu/illinois/ncsa/daffodil/processors/unparsers/SpecifiedLengthUnparsers.scala
daffodil-runtime1-unparser/src/main/scala/edu/illinois/ncsa/daffodil/processors/unparsers/StringLengthUnparsers.scala
daffodil-runtime1/src/main/scala/edu/illinois/ncsa/daffodil/dsom/CompiledExpression1.scala
daffodil-runtime1/src/main/scala/edu/illinois/ncsa/daffodil/processors/Dynamic.scala
daffodil-runtime1/src/main/scala/edu/illinois/ncsa/daffodil/processors/EncodingRuntimeData.scala
daffodil-runtime1/src/main/scala/edu/illinois/ncsa/daffodil/processors/PrimitivesTextNumber1.scala
daffodil-runtime1/src/main/scala/edu/illinois/ncsa/daffodil/processors/parsers/BinaryNumberParsers.scala
daffodil-runtime1/src/main/scala/edu/illinois/ncsa/daffodil/processors/parsers/BinaryNumberTraits.scala
daffodil-runtime1/src/main/scala/edu/illinois/ncsa/daffodil/processors/parsers/HasVariableLength.scala
daffodil-runtime1/src/main/scala/edu/illinois/ncsa/daffodil/processors/parsers/HexBinaryLengthParsers.scala
daffodil-runtime1/src/main/scala/edu/illinois/ncsa/daffodil/processors/parsers/RepParsers.scala
daffodil-runtime1/src/main/scala/edu/illinois/ncsa/daffodil/processors/parsers/SpecifiedLengthParsers.scala
daffodil-runtime1/src/main/scala/edu/illinois/ncsa/daffodil/processors/unparsers/UState.scala
eclipse-projects/io-lib/.classpath