Github user mbeckerle commented on a diff in the pull request:
https://github.com/apache/incubator-daffodil/pull/12#discussion_r153953134
--- Diff:
daffodil-runtime1/src/main/scala/edu/illinois/ncsa/daffodil/processors/ProcessorStateBases.scala
---
@@ -104,11 +117,72 @@ abstract class ParseOrUnparseState protected (
with SavesErrorsAndWarnings
with LocalBufferMixin
with EncoderDecoderMixin
- with Logging {
+ with Logging
+ with FormatInfo {
+
+ final def replacingDecoder: CharsetDecoder = decoderEntry.replacingCoder
+ final def reportingDecoder: CharsetDecoder = decoderEntry.reportingCoder
def this(vmap: VariableMap, diags: List[Diagnostic], dataProc:
Maybe[DataProcessor], tunable: DaffodilTunables) =
this(new VariableBox(vmap), diags, dataProc, tunable)
+ /*
+ * Implemnet the FormatInfo trait needed by the I/O layer.
+ */
+ def infoset: DIElement
+
+ private def simpleElement = infoset.asInstanceOf[DISimple]
+
+ def binaryFloatRep: BinaryFloatRep =
simpleElement.erd.maybeBinaryFloatRepEv.get.evaluate(this)
+ def bitOrder: BitOrder = infoset.runtimeData.defaultBitOrder
+ def byteOrder: ByteOrder =
infoset.erd.maybeByteOrderEv.get.evaluate(this)
+ def isFixedWidthEncoding: Boolean = {
coderCacheEntry_.isFixedWidthEncoding }
+ def maybeCharWidthInBits: MaybeInt = {
coderCacheEntry_.maybeCharWidthInBits }
+ def encodingMandatoryAlignmentInBits: Int = { decoder;
coderCacheEntry_.encodingMandatoryAlignmentInBits }
+ def maybeUTF16Width: Maybe[UTF16Width] =
infoset.runtimeData.encodingInfo.maybeUTF16Width
+ def fillByte: Byte =
infoset.runtimeData.maybeFillByteEv.get.evaluate(this).toByte
+ def decoder = {
+ val de = decoderEntry
+ if (encodingErrorPolicy eq EncodingErrorPolicy.Error)
+ de.reportingCoder
+ else
+ de.replacingCoder
+ }
+
+ def encoder = {
+ val ee = encoderEntry
+ if (encodingErrorPolicy eq EncodingErrorPolicy.Error)
+ ee.reportingCoder
+ else
+ ee.replacingCoder
+ }
+
+ def encodingErrorPolicy: EncodingErrorPolicy = {
+ val eep = infoset.runtimeData.encodingInfo.defaultEncodingErrorPolicy
+ eep
+ }
+
+ def decoderEntry = {
--- End diff --
Protected or private?
---