You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@daffodil.apache.org by mbeckerle <gi...@git.apache.org> on 2017/11/29 23:18:00 UTC
[GitHub] incubator-daffodil pull request #12: Revised daffodil-io module to require p...
GitHub user mbeckerle opened a pull request:
https://github.com/apache/incubator-daffodil/pull/12
Revised daffodil-io module to require passing in a FormatInfo object.
Not expect this to get approved without substantial revisions.
This is another large patch set - many files are touched.
This is just one part in addressing this major issue of daffodil
schema compiler slowness/speed.
It should also fix DAFFODIL-1843
The FormatInfo object is used to obtain the very commonly used format
properties like byteOrder, bitOrder, etc. This eliminates the need to
call setters that set these properties, eliminates the need to
save/restore them on backtracking, and when evaluating unparser
suspensions. Instead, the daffodil runtime just passes an object
(the PState/UState) which contains this information - getting it from
the ERD of an element most likely, or if runtime defined, from an
Evaluatable object which caches the property value on the infoset
element.
Once incorporated into daffodil, this will facilitate elimination of
most of the "change" processors (e.g., EncodingChangeParser,
ByteOrderChangeParser) the insertion of which uses compile-time
context-upward analysis.
There is some overhead in this change - performance impact will have to
be measured. It should reduce backtracking overheads to compensate
perhaps.
DAFFODIL-1444, DAFFODIL-1843
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/mbeckerle/incubator-daffodil daffodil-1444-schema-compiler
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/incubator-daffodil/pull/12.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #12
----
commit 79e9ee5648d43cbb8980484ea7fb5681b98b9731
Author: Mike Beckerle <mb...@tresys.com>
Date: 2017-05-31T13:44:57Z
Revised daffodil-io module to require passing in a FormatInfo object.
This is just one part in addressing this major issue of daffodil
schema compiler slowness/speed.
It should also fix DAFFODIL-1843
The FormatInfo object is used to obtain the very commonly used format
properties like byteOrder, bitOrder, etc. This eliminates the need to
call setters that set these properties, eliminates the need to
save/restore them on backtracking, and when evaluating unparser
suspensions. Instead, the daffodil runtime just passes an object
(the PState/UState) which contains this information - getting it from
the ERD of an element most likely, or if runtime defined, from an
Evaluatable object which caches the property value on the infoset
element.
Once incorporated into daffodil, this will facilitate elimination of
most of the "change" processors (e.g., EncodingChangeParser,
ByteOrderChangeParser) the insertion of which uses compile-time
context-upward analysis.
There is some overhead in this change - performance impact will have to
be measured. It should reduce backtracking overheads to compensate
perhaps.
DAFFODIL-1444, DAFFODIL-1843
----
---
[GitHub] incubator-daffodil pull request #12: Revised daffodil-io module to require p...
Posted by stevedlawrence <gi...@git.apache.org>.
Github user stevedlawrence commented on a diff in the pull request:
https://github.com/apache/incubator-daffodil/pull/12#discussion_r154092763
--- Diff: daffodil-core/src/main/scala/edu/illinois/ncsa/daffodil/grammar/primitives/ByteOrderChange.scala ---
@@ -29,26 +29,26 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
* SOFTWARE.
*/
-
--- End diff --
Delete file. All comments.
---
[GitHub] incubator-daffodil pull request #12: Revised daffodil-io module to require p...
Posted by mbeckerle <gi...@git.apache.org>.
Github user mbeckerle commented on a diff in the pull request:
https://github.com/apache/incubator-daffodil/pull/12#discussion_r153951574
--- Diff: daffodil-io/src/main/scala/edu/illinois/ncsa/daffodil/io/FormatInfo.scala ---
@@ -0,0 +1,49 @@
+package edu.illinois.ncsa.daffodil.io
+
+import java.nio.charset.CharsetDecoder
+import java.nio.charset.CharsetEncoder
+import edu.illinois.ncsa.daffodil.schema.annotation.props.gen.BitOrder
+import edu.illinois.ncsa.daffodil.schema.annotation.props.gen.ByteOrder
+import edu.illinois.ncsa.daffodil.schema.annotation.props.gen.BinaryFloatRep
+import edu.illinois.ncsa.daffodil.util.MaybeInt
+import java.nio.charset.Charset
+import java.nio.charset.CodingErrorAction
+import edu.illinois.ncsa.daffodil.schema.annotation.props.gen.EncodingErrorPolicy
+import edu.illinois.ncsa.daffodil.util.Maybe
+import edu.illinois.ncsa.daffodil.schema.annotation.props.gen.UTF16Width
+
+/**
+ * Abstract interface to obtain format properties.
+ *
+ * By passing in an object that provides quick access to these, we avoid the
+ * need to have setters/getters that change state in the I/O layer.
+ */
+trait FormatInfo {
+ def encoder: CharsetEncoder
+ def decoder: CharsetDecoder
+ def reportingDecoder: CharsetDecoder
+ def replacingDecoder: CharsetDecoder
+ def codingErrorAction: CodingErrorAction
+ def isFixedWidthEncoding: Boolean
+ def byteOrder: ByteOrder
+ final def jByteOrder = byteOrder match {
+ case ByteOrder.BigEndian => java.nio.ByteOrder.BIG_ENDIAN
+ case _ => java.nio.ByteOrder.LITTLE_ENDIAN
+ }
+ def bitOrder: BitOrder
+ def fillByte: Byte
+ final lazy val fillLong = {
+ var fl: Long = 0L
+ val fb = fillByte
+ 1 to 8 foreach { _ =>
+ fl = (fl << 8) + fb
+ }
+ fl
+ }
+ def binaryFloatRep: BinaryFloatRep
+ def maybeCharWidthInBits: MaybeInt
+ def maybeUTF16Width: Maybe[UTF16Width]
+ def encodingMandatoryAlignmentInBits: Int
+ def priorEncoding: Charset
+ def encodingErrorPolicy: EncodingErrorPolicy
--- End diff --
This can't be runtime dependent. Perhaps this can be private in implementations?
---
[GitHub] incubator-daffodil pull request #12: Revised daffodil-io module to require p...
Posted by mbeckerle <gi...@git.apache.org>.
Github user mbeckerle commented on a diff in the pull request:
https://github.com/apache/incubator-daffodil/pull/12#discussion_r154233249
--- Diff: daffodil-core/src/main/scala/edu/illinois/ncsa/daffodil/grammar/ByteOrderMixin.scala ---
@@ -71,17 +69,17 @@ trait ByteOrderAnalysisMixin extends GrammarMixin { self: Term =>
}
-trait ByteOrderMixin extends ByteOrderAnalysisMixin { self: ElementBase =>
--- End diff --
Mixin is used by the BitOrderMixin
---
[GitHub] incubator-daffodil pull request #12: Revised daffodil-io module to require p...
Posted by mbeckerle <gi...@git.apache.org>.
Github user mbeckerle commented on a diff in the pull request:
https://github.com/apache/incubator-daffodil/pull/12#discussion_r153948202
--- Diff: daffodil-core/src/main/scala/edu/illinois/ncsa/daffodil/grammar/BitOrderMixin.scala ---
@@ -74,9 +74,9 @@ trait BitOrderMixin extends GrammarMixin with ByteOrderAnalysisMixin { self: Ter
protected final lazy val needsBitOrderChange = {
enclosingTerm.isEmpty || (
optionBitOrder.isDefined &&
- thereIsAByteOrderDefined && // if there is no byte order, then there's no need for bit order. The two go together. An all-textual format doesn't need either one.
- (!isKnownSameBitOrder ||
- (isArray && !hasUniformBitOrderThroughout)))
+ thereIsAByteOrderDefined && // if there is no byte order, then there's no need for bit order. The two go together. An all-textual format doesn't need either one.
--- End diff --
Do we have a coding standard for sub-expression indenting? This change is just whitespace change. Eclipse does this automatically on save.
---
[GitHub] incubator-daffodil pull request #12: Revised daffodil-io module to require p...
Posted by mbeckerle <gi...@git.apache.org>.
Github user mbeckerle commented on a diff in the pull request:
https://github.com/apache/incubator-daffodil/pull/12#discussion_r153949285
--- Diff: daffodil-core/src/main/scala/edu/illinois/ncsa/daffodil/grammar/TermGrammarMixin.scala ---
@@ -62,7 +61,7 @@ trait TermGrammarMixin
protected lazy val hasEncoding = optionEncodingRaw.isDefined
- protected lazy val termIOPropertiesChange = prod("ioPropertiesChange") { bitOrderChange ~ encodingChange }
+ protected lazy val termIOPropertiesChange = prod("ioPropertiesChange") { bitOrderChange }
--- End diff --
prod here is overkill.
---
[GitHub] incubator-daffodil issue #12: Revised daffodil-io module to require passing ...
Posted by mbeckerle <gi...@git.apache.org>.
Github user mbeckerle commented on the issue:
https://github.com/apache/incubator-daffodil/pull/12
Suggested approach:
Start with the file FormatInfo.scala (in daffodil-io). Then look at the changes to daffodil-io, where many operations are now passed a FormatInfo. Then look at the runtime changes.
---
[GitHub] incubator-daffodil pull request #12: Revised daffodil-io module to require p...
Posted by mbeckerle <gi...@git.apache.org>.
Github user mbeckerle commented on a diff in the pull request:
https://github.com/apache/incubator-daffodil/pull/12#discussion_r153948479
--- Diff: daffodil-core/src/main/scala/edu/illinois/ncsa/daffodil/grammar/ByteOrderMixin.scala ---
@@ -71,17 +69,17 @@ trait ByteOrderAnalysisMixin extends GrammarMixin { self: Term =>
}
-trait ByteOrderMixin extends ByteOrderAnalysisMixin { self: ElementBase =>
-
- protected final lazy val byteOrderChange =
- prod("byteOrderChange",
- enclosingTerm.isEmpty || (
- (thereIsAByteOrderDefined &&
- !isKnownSameByteOrder) || // need to change on the way in
- (isArray && !hasUniformByteOrderThroughout))) { // need to change because of repetition
- // (when we start next iteration, it's not the same as when we started first iteration)
- // THis will SDE if there is no byte order defined for the array element (might only be byteOrder on things within the array)
- // So we're artificially requiring byte order on all arrays that do not have a uniform byte order.
- ByteOrderChange(this)
- }
-}
+//trait ByteOrderMixin extends ByteOrderAnalysisMixin { self: ElementBase =>
--- End diff --
Check that methods of ByteOrderAnalysisMixin are used somewhere. Otherwise that trait can also be commented out/deleted.
---
[GitHub] incubator-daffodil pull request #12: Revised daffodil-io module to require p...
Posted by mbeckerle <gi...@git.apache.org>.
Github user mbeckerle commented on a diff in the pull request:
https://github.com/apache/incubator-daffodil/pull/12#discussion_r153950949
--- Diff: daffodil-io/src/main/scala/edu/illinois/ncsa/daffodil/io/FormatInfo.scala ---
@@ -0,0 +1,49 @@
+package edu.illinois.ncsa.daffodil.io
+
+import java.nio.charset.CharsetDecoder
+import java.nio.charset.CharsetEncoder
+import edu.illinois.ncsa.daffodil.schema.annotation.props.gen.BitOrder
+import edu.illinois.ncsa.daffodil.schema.annotation.props.gen.ByteOrder
+import edu.illinois.ncsa.daffodil.schema.annotation.props.gen.BinaryFloatRep
+import edu.illinois.ncsa.daffodil.util.MaybeInt
+import java.nio.charset.Charset
+import java.nio.charset.CodingErrorAction
+import edu.illinois.ncsa.daffodil.schema.annotation.props.gen.EncodingErrorPolicy
+import edu.illinois.ncsa.daffodil.util.Maybe
+import edu.illinois.ncsa.daffodil.schema.annotation.props.gen.UTF16Width
+
+/**
+ * Abstract interface to obtain format properties.
+ *
+ * By passing in an object that provides quick access to these, we avoid the
+ * need to have setters/getters that change state in the I/O layer.
+ */
+trait FormatInfo {
+ def encoder: CharsetEncoder
--- End diff --
add scaladoc per method. Explain things like why we have decoder/encoder as well as reportingDecoder and replacingDecoder, and why codingErrorAction shows through to here.
Ex: fillByte is here because it can be specified as a character, in which case you need the charset encoding to figure out the corresponding byte.
---
[GitHub] incubator-daffodil pull request #12: Revised daffodil-io module to require p...
Posted by mbeckerle <gi...@git.apache.org>.
Github user mbeckerle commented on a diff in the pull request:
https://github.com/apache/incubator-daffodil/pull/12#discussion_r154237898
--- Diff: daffodil-core/src/main/scala/edu/illinois/ncsa/daffodil/grammar/ByteOrderMixin.scala ---
@@ -49,39 +47,39 @@ trait ByteOrderAnalysisMixin extends GrammarMixin { self: Term =>
}
}
- protected lazy val isKnownSameByteOrder: Boolean = {
- val optPrior = nearestPriorPhysicalTermSatisfying(term =>
- term.isInstanceOf[ElementBase] &&
- term.thereIsAByteOrderDefined).asInstanceOf[Option[ElementBase]]
- val optThis = this match { case e: ElementBase => Some(e); case _ => None }
- val optPriorByteOrder = optPrior.flatMap { _.byteOrderEv.optConstant }
- val optThisByteOrder = optThis.flatMap { _.byteOrderEv.optConstant }
- val res =
- if (optThisByteOrder.isDefined &&
- optPriorByteOrder.isDefined)
- optThisByteOrder =:= optPriorByteOrder
- else
- false
- res
- }
-
- protected lazy val hasUniformByteOrderThroughout: Boolean = termChildren.map { t =>
- t.thereIsAByteOrderDefined && t.isKnownSameByteOrder && t.hasUniformByteOrderThroughout
- }.forall(x => x)
+ // protected lazy val isKnownSameByteOrder: Boolean = {
+ // val optPrior = nearestPriorPhysicalTermSatisfying(term =>
+ // term.isInstanceOf[ElementBase] &&
+ // term.thereIsAByteOrderDefined).asInstanceOf[Option[ElementBase]]
+ // val optThis = this match { case e: ElementBase => Some(e); case _ => None }
+ // val optPriorByteOrder = optPrior.flatMap { _.byteOrderEv.optConstant }
+ // val optThisByteOrder = optThis.flatMap { _.byteOrderEv.optConstant }
+ // val res =
+ // if (optThisByteOrder.isDefined &&
+ // optPriorByteOrder.isDefined)
+ // optThisByteOrder =:= optPriorByteOrder
+ // else
+ // false
+ // res
+ // }
+ //
+ // protected lazy val hasUniformByteOrderThroughout: Boolean = termChildren.map { t =>
+ // t.thereIsAByteOrderDefined && t.isKnownSameByteOrder && t.hasUniformByteOrderThroughout
+ // }.forall(x => x)
}
-trait ByteOrderMixin extends ByteOrderAnalysisMixin { self: ElementBase =>
-
- protected final lazy val byteOrderChange =
- prod("byteOrderChange",
- enclosingTerm.isEmpty || (
- (thereIsAByteOrderDefined &&
- !isKnownSameByteOrder) || // need to change on the way in
- (isArray && !hasUniformByteOrderThroughout))) { // need to change because of repetition
- // (when we start next iteration, it's not the same as when we started first iteration)
- // THis will SDE if there is no byte order defined for the array element (might only be byteOrder on things within the array)
- // So we're artificially requiring byte order on all arrays that do not have a uniform byte order.
- ByteOrderChange(this)
- }
-}
+//trait ByteOrderMixin extends ByteOrderAnalysisMixin { self: ElementBase =>
+//
--- End diff --
Delete commented code
---
[GitHub] incubator-daffodil pull request #12: Revised daffodil-io module to require p...
Posted by stevedlawrence <gi...@git.apache.org>.
Github user stevedlawrence commented on a diff in the pull request:
https://github.com/apache/incubator-daffodil/pull/12#discussion_r154094249
--- Diff: daffodil-core/src/main/scala/edu/illinois/ncsa/daffodil/grammar/primitives/PrimitivesBinaryNumber.scala ---
@@ -49,13 +49,18 @@ import edu.illinois.ncsa.daffodil.processors.unparsers.BinaryDoubleUnparser
import edu.illinois.ncsa.daffodil.processors.unparsers.BinaryFloatUnparser
class BinaryIntegerRuntimeLength(val e: ElementBase, signed: Boolean) extends Terminal(e, true) {
+
+ e.byteOrderEv // insure defined
--- End diff --
Also, does it make sense to have this somewhere else in the grammar? Maybe related to dfdl:representation when it is "binary"? Removes duplication and makes it less easier to miss things.
---
[GitHub] incubator-daffodil pull request #12: Revised daffodil-io module to require p...
Posted by mbeckerle <gi...@git.apache.org>.
Github user mbeckerle commented on a diff in the pull request:
https://github.com/apache/incubator-daffodil/pull/12#discussion_r153951373
--- Diff: daffodil-io/src/main/scala/edu/illinois/ncsa/daffodil/io/FormatInfo.scala ---
@@ -0,0 +1,49 @@
+package edu.illinois.ncsa.daffodil.io
+
+import java.nio.charset.CharsetDecoder
+import java.nio.charset.CharsetEncoder
+import edu.illinois.ncsa.daffodil.schema.annotation.props.gen.BitOrder
+import edu.illinois.ncsa.daffodil.schema.annotation.props.gen.ByteOrder
+import edu.illinois.ncsa.daffodil.schema.annotation.props.gen.BinaryFloatRep
+import edu.illinois.ncsa.daffodil.util.MaybeInt
+import java.nio.charset.Charset
+import java.nio.charset.CodingErrorAction
+import edu.illinois.ncsa.daffodil.schema.annotation.props.gen.EncodingErrorPolicy
+import edu.illinois.ncsa.daffodil.util.Maybe
+import edu.illinois.ncsa.daffodil.schema.annotation.props.gen.UTF16Width
+
+/**
+ * Abstract interface to obtain format properties.
+ *
+ * By passing in an object that provides quick access to these, we avoid the
+ * need to have setters/getters that change state in the I/O layer.
+ */
+trait FormatInfo {
+ def encoder: CharsetEncoder
+ def decoder: CharsetDecoder
+ def reportingDecoder: CharsetDecoder
+ def replacingDecoder: CharsetDecoder
+ def codingErrorAction: CodingErrorAction
+ def isFixedWidthEncoding: Boolean
+ def byteOrder: ByteOrder
+ final def jByteOrder = byteOrder match {
+ case ByteOrder.BigEndian => java.nio.ByteOrder.BIG_ENDIAN
+ case _ => java.nio.ByteOrder.LITTLE_ENDIAN
+ }
+ def bitOrder: BitOrder
+ def fillByte: Byte
+ final lazy val fillLong = {
+ var fl: Long = 0L
+ val fb = fillByte
+ 1 to 8 foreach { _ =>
+ fl = (fl << 8) + fb
+ }
+ fl
+ }
+ def binaryFloatRep: BinaryFloatRep
+ def maybeCharWidthInBits: MaybeInt
+ def maybeUTF16Width: Maybe[UTF16Width]
+ def encodingMandatoryAlignmentInBits: Int
+ def priorEncoding: Charset
--- End diff --
TBD: priorEncoding - why is this exposed here. Look at uses.
---
[GitHub] incubator-daffodil pull request #12: Revised daffodil-io module to require p...
Posted by mbeckerle <gi...@git.apache.org>.
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?
---
[GitHub] incubator-daffodil pull request #12: Revised daffodil-io module to require p...
Posted by stevedlawrence <gi...@git.apache.org>.
Github user stevedlawrence commented on a diff in the pull request:
https://github.com/apache/incubator-daffodil/pull/12#discussion_r154359478
--- Diff: daffodil-runtime1/src/main/scala/edu/illinois/ncsa/daffodil/processors/ProcessorStateBases.scala ---
@@ -120,57 +118,56 @@ abstract class ParseOrUnparseState protected (
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 = {
+ /*
+ * Implemnet the FormatInfo trait needed by the I/O layer.
+ */
+ final def replacingDecoder: CharsetDecoder = decoderEntry.replacingCoder
+ final def reportingDecoder: CharsetDecoder = decoderEntry.reportingCoder
+ final def binaryFloatRep: BinaryFloatRep = simpleElement.erd.maybeBinaryFloatRepEv.get.evaluate(this)
+ final def bitOrder: BitOrder = infoset.runtimeData.defaultBitOrder
+ final def byteOrder: ByteOrder = infoset.erd.maybeByteOrderEv.get.evaluate(this)
--- End diff --
Could this be infoset.runtimeData.maybeByteOrderEv, just to be consident with the other defs here?
---
[GitHub] incubator-daffodil pull request #12: Revised daffodil-io module to require p...
Posted by mbeckerle <gi...@git.apache.org>.
Github user mbeckerle commented on a diff in the pull request:
https://github.com/apache/incubator-daffodil/pull/12#discussion_r154122788
--- Diff: daffodil-core/src/main/scala/edu/illinois/ncsa/daffodil/dsom/RuntimePropertyMixins.scala ---
@@ -252,11 +265,20 @@ trait ElementRuntimeValuedPropertiesMixin
ExpressionCompilers.String.compile(qn, NodeInfo.NonEmptyString, byteOrderRaw)
}.value
- final lazy val byteOrderEv = LV('byteOrderEv) {
- val ev = new ByteOrderEv(byteOrderExpr, elementRuntimeData)
- ev.compile()
- ev
- }.value
+ final lazy val byteOrderEv = {
+ byteOrderRaw // must be defined
--- End diff --
Agree. I will fix this so that things do getOrElse, where the Else results in the SDE that is desired, and try to use that idiom for all these things where there is a maybe and a required case.
Also I'll search and see if the maybe cases are needed. I expect they are, because there are so many situations in DFDL where a property is not required, but lots of code paths that don't want to have to conditionalize for all those cases, so carrying around a Maybe that happens to be Nope avoids code complexity.
Ex: there is a maybeFillByteEv, because ERDs always contain it, regardless of whether the format actually needs fill byte or not. When a format needs fill byte and it is not defined something elsewhere in the compiler should be asking for the fillByte property and get an SDE. But in rare case where fillByte isn't needed (such as parser-only schema) one might not run into this, in which case the maybeFillByteEv will be Nope.
---
[GitHub] incubator-daffodil pull request #12: Revised daffodil-io module to require p...
Posted by mbeckerle <gi...@git.apache.org>.
Github user mbeckerle commented on a diff in the pull request:
https://github.com/apache/incubator-daffodil/pull/12#discussion_r153950528
--- Diff: daffodil-io/src/main/scala/edu/illinois/ncsa/daffodil/io/FormatInfo.scala ---
@@ -0,0 +1,49 @@
+package edu.illinois.ncsa.daffodil.io
+
+import java.nio.charset.CharsetDecoder
+import java.nio.charset.CharsetEncoder
+import edu.illinois.ncsa.daffodil.schema.annotation.props.gen.BitOrder
+import edu.illinois.ncsa.daffodil.schema.annotation.props.gen.ByteOrder
+import edu.illinois.ncsa.daffodil.schema.annotation.props.gen.BinaryFloatRep
+import edu.illinois.ncsa.daffodil.util.MaybeInt
+import java.nio.charset.Charset
+import java.nio.charset.CodingErrorAction
+import edu.illinois.ncsa.daffodil.schema.annotation.props.gen.EncodingErrorPolicy
+import edu.illinois.ncsa.daffodil.util.Maybe
+import edu.illinois.ncsa.daffodil.schema.annotation.props.gen.UTF16Width
+
+/**
+ * Abstract interface to obtain format properties.
--- End diff --
Enhance comment.
This trait is the abstract interface the I/O layer uses to obtain properties that are runtime-evaluatable, or are influenced by runtime-evaluatable properties.
---
[GitHub] incubator-daffodil pull request #12: Revised daffodil-io module to require p...
Posted by mbeckerle <gi...@git.apache.org>.
Github user mbeckerle commented on a diff in the pull request:
https://github.com/apache/incubator-daffodil/pull/12#discussion_r153947357
--- Diff: daffodil-core/src/main/scala/edu/illinois/ncsa/daffodil/dsom/RuntimePropertyMixins.scala ---
@@ -609,10 +631,16 @@ trait SimpleTypeRuntimeValuedPropertiesMixin
ExpressionCompilers.String.compile(qn, NodeInfo.NonEmptyString, binaryFloatRepRaw)
}.value
- final lazy val binaryFloatRepEv = {
- val ev = new BinaryFloatRepEv(binaryFloatRepExpr, erd)
- ev.compile()
- ev
+ final lazy val binaryFloatRepEv = maybeBinaryFloatRepEv.get
--- End diff --
Use getOrElse here, so that code that asks for binaryFloatRepEv doesn't get Nope.get error if the property isn't defined.
Here and for the other similar situations, as this pattern appears a fair bit.
---
[GitHub] incubator-daffodil pull request #12: Revised daffodil-io module to require p...
Posted by stevedlawrence <gi...@git.apache.org>.
Github user stevedlawrence commented on a diff in the pull request:
https://github.com/apache/incubator-daffodil/pull/12#discussion_r154115511
--- Diff: daffodil-io/src/main/scala/edu/illinois/ncsa/daffodil/io/FormatInfo.scala ---
@@ -0,0 +1,49 @@
+package edu.illinois.ncsa.daffodil.io
+
+import java.nio.charset.CharsetDecoder
+import java.nio.charset.CharsetEncoder
+import edu.illinois.ncsa.daffodil.schema.annotation.props.gen.BitOrder
+import edu.illinois.ncsa.daffodil.schema.annotation.props.gen.ByteOrder
+import edu.illinois.ncsa.daffodil.schema.annotation.props.gen.BinaryFloatRep
+import edu.illinois.ncsa.daffodil.util.MaybeInt
+import java.nio.charset.Charset
+import java.nio.charset.CodingErrorAction
+import edu.illinois.ncsa.daffodil.schema.annotation.props.gen.EncodingErrorPolicy
+import edu.illinois.ncsa.daffodil.util.Maybe
+import edu.illinois.ncsa.daffodil.schema.annotation.props.gen.UTF16Width
+
+/**
+ * Abstract interface to obtain format properties.
+ *
+ * By passing in an object that provides quick access to these, we avoid the
+ * need to have setters/getters that change state in the I/O layer.
+ */
+trait FormatInfo {
+ def encoder: CharsetEncoder
+ def decoder: CharsetDecoder
+ def reportingDecoder: CharsetDecoder
+ def replacingDecoder: CharsetDecoder
+ def codingErrorAction: CodingErrorAction
+ def isFixedWidthEncoding: Boolean
+ def byteOrder: ByteOrder
+ final def jByteOrder = byteOrder match {
+ case ByteOrder.BigEndian => java.nio.ByteOrder.BIG_ENDIAN
+ case _ => java.nio.ByteOrder.LITTLE_ENDIAN
+ }
+ def bitOrder: BitOrder
+ def fillByte: Byte
+ final lazy val fillLong = {
+ var fl: Long = 0L
+ val fb = fillByte
+ 1 to 8 foreach { _ =>
--- End diff --
I think this might actually be wrong being a lazy val. fillByte can change, so fillLong should also be a def. It looks like fillLong is only used in skip(), which probably isn't used all that often. Maybe just put this code in skip()?
---
[GitHub] incubator-daffodil pull request #12: Revised daffodil-io module to require p...
Posted by stevedlawrence <gi...@git.apache.org>.
Github user stevedlawrence commented on a diff in the pull request:
https://github.com/apache/incubator-daffodil/pull/12#discussion_r154359647
--- Diff: daffodil-runtime1/src/main/scala/edu/illinois/ncsa/daffodil/processors/ProcessorStateBases.scala ---
@@ -120,57 +118,56 @@ abstract class ParseOrUnparseState protected (
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 = {
+ /*
+ * Implemnet the FormatInfo trait needed by the I/O layer.
+ */
+ final def replacingDecoder: CharsetDecoder = decoderEntry.replacingCoder
+ final def reportingDecoder: CharsetDecoder = decoderEntry.reportingCoder
+ final def binaryFloatRep: BinaryFloatRep = simpleElement.erd.maybeBinaryFloatRepEv.get.evaluate(this)
+ final def bitOrder: BitOrder = infoset.runtimeData.defaultBitOrder
+ final def byteOrder: ByteOrder = infoset.erd.maybeByteOrderEv.get.evaluate(this)
--- End diff --
Likewise for binaryFloatRep?
---
[GitHub] incubator-daffodil pull request #12: Revised daffodil-io module to require p...
Posted by stevedlawrence <gi...@git.apache.org>.
Github user stevedlawrence commented on a diff in the pull request:
https://github.com/apache/incubator-daffodil/pull/12#discussion_r154090337
--- Diff: daffodil-core/src/main/scala/edu/illinois/ncsa/daffodil/dsom/RuntimePropertyMixins.scala ---
@@ -252,11 +265,20 @@ trait ElementRuntimeValuedPropertiesMixin
ExpressionCompilers.String.compile(qn, NodeInfo.NonEmptyString, byteOrderRaw)
}.value
- final lazy val byteOrderEv = LV('byteOrderEv) {
- val ev = new ByteOrderEv(byteOrderExpr, elementRuntimeData)
- ev.compile()
- ev
- }.value
+ final lazy val byteOrderEv = {
+ byteOrderRaw // must be defined
--- End diff --
This is different than fillByteEv and binaryFloatRepEv. Those just do a get without calling the raw to make sure it exists. Should fillByte and binaryFloatRepEv be doing the same thing as this? Are the maybe versions even necessary? Looks like they're just always calling .get without checking if they are Nope or not.
---
[GitHub] incubator-daffodil pull request #12: Revised daffodil-io module to require p...
Posted by mbeckerle <gi...@git.apache.org>.
Github user mbeckerle commented on a diff in the pull request:
https://github.com/apache/incubator-daffodil/pull/12#discussion_r153946659
--- Diff: daffodil-test/src/test/resources/edu/illinois/ncsa/daffodil/section06/entities/charClassEntities.dfdl.xsd ---
@@ -43,7 +43,7 @@
<annotation>
<appinfo source="http://www.ogf.org/dfdl/">
<dfdl:format ref="tns:daffodilTest1" initiator="" terminator="" leadingSkip="0"
- trailingSkip="0" textBidi="no" floating="no" encoding="ASCII"
+ trailingSkip="0" textBidi="no" floating="no" encoding="utf-8"
--- End diff --
encoding="utf-8" no longer needed here and elsewhere in this schema, as it is in the default format.
---
[GitHub] incubator-daffodil issue #12: Revised daffodil-io module to require passing ...
Posted by mbeckerle <gi...@git.apache.org>.
Github user mbeckerle commented on the issue:
https://github.com/apache/incubator-daffodil/pull/12
More thorough testing:
3 tests fail in daffodil-cli,
PCAP one test fails (test_pcap_test_http_ipv6),
LInk16 gets bitOrder bugs (related to DAFFODIL-1843 I think),
VMF test_K02_10 gets stack overflow in DFDL schema compiler, and test_K07_1, 4, 7, 8, 9 and test1_K07_1 all also fail with similar bitOrder problem.
---
[GitHub] incubator-daffodil pull request #12: Revised daffodil-io module to require p...
Posted by stevedlawrence <gi...@git.apache.org>.
Github user stevedlawrence commented on a diff in the pull request:
https://github.com/apache/incubator-daffodil/pull/12#discussion_r154087359
--- Diff: daffodil-io/src/main/scala/edu/illinois/ncsa/daffodil/io/FormatInfo.scala ---
@@ -0,0 +1,49 @@
+package edu.illinois.ncsa.daffodil.io
--- End diff --
Remember to add Apache license header to new files.
---
[GitHub] incubator-daffodil pull request #12: Revised daffodil-io module to require p...
Posted by stevedlawrence <gi...@git.apache.org>.
Github user stevedlawrence commented on a diff in the pull request:
https://github.com/apache/incubator-daffodil/pull/12#discussion_r154092356
--- Diff: daffodil-core/src/main/scala/edu/illinois/ncsa/daffodil/grammar/TermGrammarMixin.scala ---
@@ -62,7 +61,7 @@ trait TermGrammarMixin
protected lazy val hasEncoding = optionEncodingRaw.isDefined
- protected lazy val termIOPropertiesChange = prod("ioPropertiesChange") { bitOrderChange ~ encodingChange }
+ protected lazy val termIOPropertiesChange = prod("ioPropertiesChange") { bitOrderChange }
--- End diff --
So removing the bitOrderChange parser is not part of this? Are there things actually preventing this, or just something not gotten to yet.
---
[GitHub] incubator-daffodil pull request #12: Revised daffodil-io module to require p...
Posted by stevedlawrence <gi...@git.apache.org>.
Github user stevedlawrence commented on a diff in the pull request:
https://github.com/apache/incubator-daffodil/pull/12#discussion_r154091772
--- Diff: daffodil-core/src/main/scala/edu/illinois/ncsa/daffodil/grammar/ByteOrderMixin.scala ---
@@ -71,17 +69,17 @@ trait ByteOrderAnalysisMixin extends GrammarMixin { self: Term =>
}
-trait ByteOrderMixin extends ByteOrderAnalysisMixin { self: ElementBase =>
--- End diff --
Can we also delete the ByteOrderAnalysisMixin above, and thus this whole file? I think that's just for determining if a byte order change parser is needed, which no longer exists.
---
[GitHub] incubator-daffodil pull request #12: Revised daffodil-io module to require p...
Posted by stevedlawrence <gi...@git.apache.org>.
Github user stevedlawrence commented on a diff in the pull request:
https://github.com/apache/incubator-daffodil/pull/12#discussion_r154360329
--- Diff: eclipse-projects/io-lib/.classpath ---
@@ -1,88 +1,106 @@
+<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <!-- This file is updated by the UpdateEclipseClasspath app. -->
- <classpathentry kind="src" path="src/main/scala"/><classpathentry kind="con" path="org.scala-ide.sdt.launching.SCALA_CONTAINER"/><classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/><classpathentry combineaccessrules="false" kind="src" path="/daffodil-lib"/><classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/><classpathentry combineaccessrules="false" kind="src" path="/daffodil-macro-lib"/><classpathentry kind="output" path="bin"/><!--
-***********
-*********** Entries below this comment are maintained using the UpdateEclipseClasspaths
-*********** Utility and should not be modified by hand or using the Eclipse
-*********** BuildPath... GUI dialog.
-***********
---><classpathentry sourcepath="lib_managed/srcs/xml-resolver/xml-resolver/xml-resolver-1.2-sources.jar" exported="true" kind="lib" path="lib_managed/jars/xml-resolver/xml-resolver/xml-resolver-1.2.jar">
-
- </classpathentry><classpathentry sourcepath="lib_managed/srcs/com.novocode/junit-interface/junit-interface-0.11-sources.jar" exported="true" kind="lib" path="lib_managed/jars/com.novocode/junit-interface/junit-interface-0.11.jar">
- <attributes>
- <attribute name="javadoc_location" value="jar:file:lib_managed/docs/com.novocode/junit-interface/junit-interface-0.11-javadoc.jar!/"/>
- </attributes>
- </classpathentry><classpathentry sourcepath="lib_managed/srcs/org.scala-lang.modules/scala-parser-combinators_2.11/scala-parser-combinators_2.11-1.0.4-sources.jar" exported="true" kind="lib" path="lib_managed/jars/org.scala-lang.modules/scala-parser-combinators_2.11/scala-parser-combinators_2.11-1.0.4.jar">
- <attributes>
- <attribute name="javadoc_location" value="jar:file:lib_managed/docs/org.scala-lang.modules/scala-parser-combinators_2.11/scala-parser-combinators_2.11-1.0.4-javadoc.jar!/"/>
- </attributes>
- </classpathentry><classpathentry sourcepath="lib_managed/srcs/org.scala-lang.modules/scala-xml_2.11/scala-xml_2.11-1.0.6-sources.jar" exported="true" kind="lib" path="lib_managed/jars/org.scala-lang.modules/scala-xml_2.11/scala-xml_2.11-1.0.6.jar">
- <attributes>
- <attribute name="javadoc_location" value="jar:file:lib_managed/docs/org.scala-lang.modules/scala-xml_2.11/scala-xml_2.11-1.0.6-javadoc.jar!/"/>
- </attributes>
- </classpathentry><classpathentry sourcepath="lib_managed/srcs/xml-apis/xml-apis/xml-apis-1.4.01-sources.jar" exported="true" kind="lib" path="lib_managed/jars/xml-apis/xml-apis/xml-apis-1.4.01.jar">
- <attributes>
- <attribute name="javadoc_location" value="jar:file:lib_managed/docs/xml-apis/xml-apis/xml-apis-1.4.01-javadoc.jar!/"/>
- </attributes>
- </classpathentry><classpathentry sourcepath="lib_managed/srcs/org.hamcrest/hamcrest-core/hamcrest-core-1.3-sources.jar" exported="true" kind="lib" path="lib_managed/jars/org.hamcrest/hamcrest-core/hamcrest-core-1.3.jar">
- <attributes>
- <attribute name="javadoc_location" value="jar:file:lib_managed/docs/org.hamcrest/hamcrest-core/hamcrest-core-1.3-javadoc.jar!/"/>
- </attributes>
- </classpathentry><classpathentry sourcepath="lib_managed/srcs/jline/jline/jline-2.12.1-sources.jar" exported="true" kind="lib" path="lib_managed/jars/jline/jline/jline-2.12.1.jar">
- <attributes>
- <attribute name="javadoc_location" value="jar:file:lib_managed/docs/jline/jline/jline-2.12.1-javadoc.jar!/"/>
- </attributes>
- </classpathentry><classpathentry sourcepath="lib_managed/srcs/org.scala-sbt/test-interface/test-interface-1.0-sources.jar" exported="true" kind="lib" path="lib_managed/jars/org.scala-sbt/test-interface/test-interface-1.0.jar">
- <attributes>
- <attribute name="javadoc_location" value="jar:file:lib_managed/docs/org.scala-sbt/test-interface/test-interface-1.0-javadoc.jar!/"/>
- </attributes>
- </classpathentry><classpathentry sourcepath="lib_managed/srcs/net.sf.expectit/expectit-core/expectit-core-0.8.1-sources.jar" exported="true" kind="lib" path="lib_managed/jars/net.sf.expectit/expectit-core/expectit-core-0.8.1.jar">
- <attributes>
- <attribute name="javadoc_location" value="jar:file:lib_managed/docs/net.sf.expectit/expectit-core/expectit-core-0.8.1-javadoc.jar!/"/>
- </attributes>
- </classpathentry><classpathentry sourcepath="lib_managed/srcs/org.fusesource.jansi/jansi/jansi-1.14-sources.jar" exported="true" kind="lib" path="lib_managed/jars/org.fusesource.jansi/jansi/jansi-1.14.jar">
- <attributes>
- <attribute name="javadoc_location" value="jar:file:lib_managed/docs/org.fusesource.jansi/jansi/jansi-1.14-javadoc.jar!/"/>
- </attributes>
- </classpathentry><classpathentry sourcepath="lib_managed/srcs/org.codehaus.woodstox/stax2-api/stax2-api-3.1.4-sources.jar" exported="true" kind="lib" path="lib_managed/jars/org.codehaus.woodstox/stax2-api/stax2-api-3.1.4.jar">
- <attributes>
- <attribute name="javadoc_location" value="jar:file:lib_managed/docs/org.codehaus.woodstox/stax2-api/stax2-api-3.1.4-javadoc.jar!/"/>
- </attributes>
- </classpathentry><classpathentry sourcepath="lib_managed/srcs/com.ibm.icu/icu4j/icu4j-51.1-sources.jar" exported="true" kind="lib" path="lib_managed/jars/com.ibm.icu/icu4j/icu4j-51.1.jar">
- <attributes>
- <attribute name="javadoc_location" value="jar:file:lib_managed/docs/com.ibm.icu/icu4j/icu4j-51.1-javadoc.jar!/"/>
- </attributes>
- </classpathentry><classpathentry sourcepath="lib_managed/srcs/com.fasterxml.jackson.core/jackson-core/jackson-core-2.8.8-sources.jar" exported="true" kind="lib" path="lib_managed/jars/com.fasterxml.jackson.core/jackson-core/jackson-core-2.8.8.jar">
- <attributes>
- <attribute name="javadoc_location" value="jar:file:lib_managed/docs/com.fasterxml.jackson.core/jackson-core/jackson-core-2.8.8-javadoc.jar!/"/>
- </attributes>
- </classpathentry><classpathentry sourcepath="lib_managed/srcs/commons-io/commons-io/commons-io-2.5-sources.jar" exported="true" kind="lib" path="lib_managed/jars/commons-io/commons-io/commons-io-2.5.jar">
- <attributes>
- <attribute name="javadoc_location" value="jar:file:lib_managed/docs/commons-io/commons-io/commons-io-2.5-javadoc.jar!/"/>
- </attributes>
- </classpathentry><classpathentry sourcepath="lib_managed/srcs/org.scalacheck/scalacheck_2.11/scalacheck_2.11-1.13.4-sources.jar" exported="true" kind="lib" path="lib_managed/jars/org.scalacheck/scalacheck_2.11/scalacheck_2.11-1.13.4.jar">
- <attributes>
- <attribute name="javadoc_location" value="jar:file:lib_managed/docs/org.scalacheck/scalacheck_2.11/scalacheck_2.11-1.13.4-javadoc.jar!/"/>
- </attributes>
- </classpathentry><classpathentry sourcepath="lib_managed/srcs/com.fasterxml.woodstox/woodstox-core/woodstox-core-5.0.3-sources.jar" exported="true" kind="lib" path="lib_managed/jars/com.fasterxml.woodstox/woodstox-core/woodstox-core-5.0.3.jar">
- <attributes>
- <attribute name="javadoc_location" value="jar:file:lib_managed/docs/com.fasterxml.woodstox/woodstox-core/woodstox-core-5.0.3-javadoc.jar!/"/>
- </attributes>
- </classpathentry><classpathentry sourcepath="lib_managed/srcs/junit/junit/junit-4.11-sources.jar" exported="true" kind="lib" path="lib_managed/jars/junit/junit/junit-4.11.jar">
- <attributes>
- <attribute name="javadoc_location" value="jar:file:lib_managed/docs/junit/junit/junit-4.11-javadoc.jar!/"/>
- </attributes>
- </classpathentry><classpathentry sourcepath="lib_managed/srcs/org.rogach/scallop_2.11/scallop_2.11-0.9.5-sources.jar" exported="true" kind="lib" path="lib_managed/jars/org.rogach/scallop_2.11/scallop_2.11-0.9.5.jar">
- <attributes>
- <attribute name="javadoc_location" value="jar:file:lib_managed/docs/org.rogach/scallop_2.11/scallop_2.11-0.9.5-javadoc.jar!/"/>
- </attributes>
- </classpathentry><classpathentry sourcepath="lib_managed/srcs/xerces/xercesImpl/xercesImpl-2.10.0-sources.jar" exported="true" kind="lib" path="lib_managed/jars/xerces/xercesImpl/xercesImpl-2.10.0.jar">
- <attributes>
- <attribute name="javadoc_location" value="jar:file:lib_managed/docs/xerces/xercesImpl/xercesImpl-2.10.0-javadoc.jar!/"/>
- </attributes>
- </classpathentry><classpathentry sourcepath="lib_managed/srcs/org.jdom/jdom2/jdom2-2.0.6-sources.jar" exported="true" kind="lib" path="lib_managed/jars/org.jdom/jdom2/jdom2-2.0.6.jar">
- <attributes>
- <attribute name="javadoc_location" value="jar:file:lib_managed/docs/org.jdom/jdom2/jdom2-2.0.6-javadoc.jar!/"/>
- </attributes>
- </classpathentry>
- </classpath>
\ No newline at end of file
+ <classpathentry kind="src" path="src/main/scala"/>
+ <classpathentry kind="con" path="org.scala-ide.sdt.launching.SCALA_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/daffodil-lib"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/daffodil-macro-lib"/>
+ <classpathentry exported="true" kind="lib" path="lib_managed/jars/xml-resolver/xml-resolver/xml-resolver-1.2.jar" sourcepath="lib_managed/srcs/xml-resolver/xml-resolver/xml-resolver-1.2-sources.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib_managed/jars/com.novocode/junit-interface/junit-interface-0.11.jar" sourcepath="lib_managed/srcs/com.novocode/junit-interface/junit-interface-0.11-sources.jar">
+ <attributes>
+ <attribute name="javadoc_location" value="jar:file:lib_managed/docs/com.novocode/junit-interface/junit-interface-0.11-javadoc.jar!/"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry exported="true" kind="lib" path="lib_managed/jars/org.scala-lang.modules/scala-parser-combinators_2.11/scala-parser-combinators_2.11-1.0.4.jar" sourcepath="lib_managed/srcs/org.scala-lang.modules/scala-parser-combinators_2.11/scala-parser-combinators_2.11-1.0.4-sources.jar">
+ <attributes>
+ <attribute name="javadoc_location" value="jar:file:lib_managed/docs/org.scala-lang.modules/scala-parser-combinators_2.11/scala-parser-combinators_2.11-1.0.4-javadoc.jar!/"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry exported="true" kind="lib" path="lib_managed/jars/org.scala-lang.modules/scala-xml_2.11/scala-xml_2.11-1.0.6.jar" sourcepath="lib_managed/srcs/org.scala-lang.modules/scala-xml_2.11/scala-xml_2.11-1.0.6-sources.jar">
+ <attributes>
+ <attribute name="javadoc_location" value="jar:file:lib_managed/docs/org.scala-lang.modules/scala-xml_2.11/scala-xml_2.11-1.0.6-javadoc.jar!/"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry exported="true" kind="lib" path="lib_managed/jars/xml-apis/xml-apis/xml-apis-1.4.01.jar" sourcepath="lib_managed/srcs/xml-apis/xml-apis/xml-apis-1.4.01-sources.jar">
+ <attributes>
+ <attribute name="javadoc_location" value="jar:file:lib_managed/docs/xml-apis/xml-apis/xml-apis-1.4.01-javadoc.jar!/"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry exported="true" kind="lib" path="lib_managed/jars/org.hamcrest/hamcrest-core/hamcrest-core-1.3.jar" sourcepath="lib_managed/srcs/org.hamcrest/hamcrest-core/hamcrest-core-1.3-sources.jar">
+ <attributes>
+ <attribute name="javadoc_location" value="jar:file:lib_managed/docs/org.hamcrest/hamcrest-core/hamcrest-core-1.3-javadoc.jar!/"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry exported="true" kind="lib" path="lib_managed/jars/jline/jline/jline-2.12.1.jar" sourcepath="lib_managed/srcs/jline/jline/jline-2.12.1-sources.jar">
+ <attributes>
+ <attribute name="javadoc_location" value="jar:file:lib_managed/docs/jline/jline/jline-2.12.1-javadoc.jar!/"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry exported="true" kind="lib" path="lib_managed/jars/org.scala-sbt/test-interface/test-interface-1.0.jar" sourcepath="lib_managed/srcs/org.scala-sbt/test-interface/test-interface-1.0-sources.jar">
+ <attributes>
+ <attribute name="javadoc_location" value="jar:file:lib_managed/docs/org.scala-sbt/test-interface/test-interface-1.0-javadoc.jar!/"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry exported="true" kind="lib" path="lib_managed/jars/net.sf.expectit/expectit-core/expectit-core-0.8.1.jar" sourcepath="lib_managed/srcs/net.sf.expectit/expectit-core/expectit-core-0.8.1-sources.jar">
+ <attributes>
+ <attribute name="javadoc_location" value="jar:file:lib_managed/docs/net.sf.expectit/expectit-core/expectit-core-0.8.1-javadoc.jar!/"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry exported="true" kind="lib" path="lib_managed/jars/org.fusesource.jansi/jansi/jansi-1.14.jar" sourcepath="lib_managed/srcs/org.fusesource.jansi/jansi/jansi-1.14-sources.jar">
+ <attributes>
+ <attribute name="javadoc_location" value="jar:file:lib_managed/docs/org.fusesource.jansi/jansi/jansi-1.14-javadoc.jar!/"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry exported="true" kind="lib" path="lib_managed/jars/org.codehaus.woodstox/stax2-api/stax2-api-3.1.4.jar" sourcepath="lib_managed/srcs/org.codehaus.woodstox/stax2-api/stax2-api-3.1.4-sources.jar">
+ <attributes>
+ <attribute name="javadoc_location" value="jar:file:lib_managed/docs/org.codehaus.woodstox/stax2-api/stax2-api-3.1.4-javadoc.jar!/"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry exported="true" kind="lib" path="lib_managed/jars/com.ibm.icu/icu4j/icu4j-51.1.jar" sourcepath="lib_managed/srcs/com.ibm.icu/icu4j/icu4j-51.1-sources.jar">
+ <attributes>
+ <attribute name="javadoc_location" value="jar:file:lib_managed/docs/com.ibm.icu/icu4j/icu4j-51.1-javadoc.jar!/"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry exported="true" kind="lib" path="lib_managed/jars/com.fasterxml.jackson.core/jackson-core/jackson-core-2.8.8.jar" sourcepath="lib_managed/srcs/com.fasterxml.jackson.core/jackson-core/jackson-core-2.8.8-sources.jar">
+ <attributes>
+ <attribute name="javadoc_location" value="jar:file:lib_managed/docs/com.fasterxml.jackson.core/jackson-core/jackson-core-2.8.8-javadoc.jar!/"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry exported="true" kind="lib" path="lib_managed/jars/commons-io/commons-io/commons-io-2.5.jar" sourcepath="lib_managed/srcs/commons-io/commons-io/commons-io-2.5-sources.jar">
+ <attributes>
+ <attribute name="javadoc_location" value="jar:file:lib_managed/docs/commons-io/commons-io/commons-io-2.5-javadoc.jar!/"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry exported="true" kind="lib" path="lib_managed/jars/org.scalacheck/scalacheck_2.11/scalacheck_2.11-1.13.4.jar" sourcepath="lib_managed/srcs/org.scalacheck/scalacheck_2.11/scalacheck_2.11-1.13.4-sources.jar">
+ <attributes>
+ <attribute name="javadoc_location" value="jar:file:lib_managed/docs/org.scalacheck/scalacheck_2.11/scalacheck_2.11-1.13.4-javadoc.jar!/"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry exported="true" kind="lib" path="lib_managed/jars/com.fasterxml.woodstox/woodstox-core/woodstox-core-5.0.3.jar" sourcepath="lib_managed/srcs/com.fasterxml.woodstox/woodstox-core/woodstox-core-5.0.3-sources.jar">
+ <attributes>
+ <attribute name="javadoc_location" value="jar:file:lib_managed/docs/com.fasterxml.woodstox/woodstox-core/woodstox-core-5.0.3-javadoc.jar!/"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry exported="true" kind="lib" path="lib_managed/jars/junit/junit/junit-4.11.jar" sourcepath="lib_managed/srcs/junit/junit/junit-4.11-sources.jar">
+ <attributes>
+ <attribute name="javadoc_location" value="jar:file:lib_managed/docs/junit/junit/junit-4.11-javadoc.jar!/"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry exported="true" kind="lib" path="lib_managed/jars/org.rogach/scallop_2.11/scallop_2.11-0.9.5.jar" sourcepath="lib_managed/srcs/org.rogach/scallop_2.11/scallop_2.11-0.9.5-sources.jar">
+ <attributes>
+ <attribute name="javadoc_location" value="jar:file:lib_managed/docs/org.rogach/scallop_2.11/scallop_2.11-0.9.5-javadoc.jar!/"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry exported="true" kind="lib" path="lib_managed/jars/xerces/xercesImpl/xercesImpl-2.10.0.jar" sourcepath="lib_managed/srcs/xerces/xercesImpl/xercesImpl-2.10.0-sources.jar">
+ <attributes>
+ <attribute name="javadoc_location" value="jar:file:lib_managed/docs/xerces/xercesImpl/xercesImpl-2.10.0-javadoc.jar!/"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry exported="true" kind="lib" path="lib_managed/jars/org.jdom/jdom2/jdom2-2.0.6.jar" sourcepath="lib_managed/srcs/org.jdom/jdom2/jdom2-2.0.6-sources.jar">
+ <attributes>
+ <attribute name="javadoc_location" value="jar:file:lib_managed/docs/org.jdom/jdom2/jdom2-2.0.6-javadoc.jar!/"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
--- End diff --
Did eclipse overwrite this?
---
[GitHub] incubator-daffodil pull request #12: Revised daffodil-io module to require p...
Posted by stevedlawrence <gi...@git.apache.org>.
Github user stevedlawrence commented on a diff in the pull request:
https://github.com/apache/incubator-daffodil/pull/12#discussion_r154092500
--- Diff: daffodil-core/src/main/scala/edu/illinois/ncsa/daffodil/grammar/EncodingChangeMixin.scala ---
@@ -30,44 +30,44 @@
* SOFTWARE.
*/
-package edu.illinois.ncsa.daffodil.grammar
--- End diff --
Delete file, all comments.
---
[GitHub] incubator-daffodil pull request #12: Revised daffodil-io module to require p...
Posted by mbeckerle <gi...@git.apache.org>.
Github user mbeckerle commented on a diff in the pull request:
https://github.com/apache/incubator-daffodil/pull/12#discussion_r154232304
--- Diff: daffodil-io/src/main/scala/edu/illinois/ncsa/daffodil/io/FormatInfo.scala ---
@@ -0,0 +1,49 @@
+package edu.illinois.ncsa.daffodil.io
+
+import java.nio.charset.CharsetDecoder
+import java.nio.charset.CharsetEncoder
+import edu.illinois.ncsa.daffodil.schema.annotation.props.gen.BitOrder
+import edu.illinois.ncsa.daffodil.schema.annotation.props.gen.ByteOrder
+import edu.illinois.ncsa.daffodil.schema.annotation.props.gen.BinaryFloatRep
+import edu.illinois.ncsa.daffodil.util.MaybeInt
+import java.nio.charset.Charset
+import java.nio.charset.CodingErrorAction
+import edu.illinois.ncsa.daffodil.schema.annotation.props.gen.EncodingErrorPolicy
+import edu.illinois.ncsa.daffodil.util.Maybe
+import edu.illinois.ncsa.daffodil.schema.annotation.props.gen.UTF16Width
+
+/**
+ * Abstract interface to obtain format properties.
+ *
+ * By passing in an object that provides quick access to these, we avoid the
+ * need to have setters/getters that change state in the I/O layer.
+ */
+trait FormatInfo {
+ def encoder: CharsetEncoder
+ def decoder: CharsetDecoder
+ def reportingDecoder: CharsetDecoder
+ def replacingDecoder: CharsetDecoder
+ def codingErrorAction: CodingErrorAction
+ def isFixedWidthEncoding: Boolean
+ def byteOrder: ByteOrder
+ final def jByteOrder = byteOrder match {
+ case ByteOrder.BigEndian => java.nio.ByteOrder.BIG_ENDIAN
+ case _ => java.nio.ByteOrder.LITTLE_ENDIAN
+ }
+ def bitOrder: BitOrder
+ def fillByte: Byte
+ final lazy val fillLong = {
+ var fl: Long = 0L
+ val fb = fillByte
+ 1 to 8 foreach { _ =>
+ fl = (fl << 8) + fb
+ }
+ fl
+ }
+ def binaryFloatRep: BinaryFloatRep
+ def maybeCharWidthInBits: MaybeInt
+ def maybeUTF16Width: Maybe[UTF16Width]
+ def encodingMandatoryAlignmentInBits: Int
+ def priorEncoding: Charset
+ def encodingErrorPolicy: EncodingErrorPolicy
--- End diff --
Actually this trait is not only for runtime-valued properties. It's for any properties or things derived from properties.
---
[GitHub] incubator-daffodil pull request #12: Revised daffodil-io module to require p...
Posted by mbeckerle <gi...@git.apache.org>.
Github user mbeckerle commented on a diff in the pull request:
https://github.com/apache/incubator-daffodil/pull/12#discussion_r153948953
--- Diff: daffodil-core/src/main/scala/edu/illinois/ncsa/daffodil/grammar/EncodingChangeMixin.scala ---
@@ -30,44 +30,44 @@
* SOFTWARE.
*/
-package edu.illinois.ncsa.daffodil.grammar
-
-import edu.illinois.ncsa.daffodil.processors._
-import edu.illinois.ncsa.daffodil.dsom.Term
-import edu.illinois.ncsa.daffodil.equality._
-import edu.illinois.ncsa.daffodil.grammar.primitives.EncodingChange
-
-trait EncodingChangeMixin extends GrammarMixin { self: Term =>
-
- private lazy val enclosingEncoding = enclosingTerm.map(_.encodingEv)
- private lazy val priorSiblingEncoding = priorSibling.map(_.encodingEv)
- private lazy val encodingBefore: Evaluatable[String] = priorSiblingEncoding.getOrElse(enclosingEncoding.getOrElse(encodingEv))
-
- protected lazy val isKnownSameEncoding: Boolean = {
- if (enclosingTerm.isEmpty) false // root always gets a encoding change.
- else {
- val thisEncoding = encodingEv
- val otherEncoding = encodingBefore
- if (thisEncoding.isConstant && otherEncoding.isConstant &&
- thisEncoding.optConstant.get =:= otherEncoding.optConstant.get) {
- if (priorSiblingEncoding.isDefined) {
- // in addition to having the same encoding as the prior sibling, all
- // children of that prior sibling must have the same encoding.
- // Otherwise, a child could change the encoding and it might not be
- // the same as ours.
- priorSibling.get.hasUniformEncodingThroughout
- } else {
- true
- }
- } else {
- false
- }
- }
- }
-
- protected lazy val hasUniformEncodingThroughout: Boolean = termChildren.map { t => t.isKnownSameEncoding && t.hasUniformEncodingThroughout }.forall(x => x)
-
- protected final lazy val encodingChange = prod("encodingChange",
- !isKnownSameEncoding ||
- (isArray && !hasUniformEncodingThroughout)) { EncodingChange(this) }
-}
+//package edu.illinois.ncsa.daffodil.grammar
--- End diff --
file can be deleted.
However, until this whole approach of calling back to the FormatInfo object is shown to be acceptable performance-wise, it is worth keeping these.
---
[GitHub] incubator-daffodil pull request #12: Revised daffodil-io module to require p...
Posted by stevedlawrence <gi...@git.apache.org>.
Github user stevedlawrence commented on a diff in the pull request:
https://github.com/apache/incubator-daffodil/pull/12#discussion_r154093171
--- Diff: daffodil-core/src/main/scala/edu/illinois/ncsa/daffodil/grammar/primitives/EncodingChange.scala ---
@@ -30,31 +30,31 @@
* SOFTWARE.
*/
-package edu.illinois.ncsa.daffodil.grammar.primitives
--- End diff --
Delete file, all comments.
---
[GitHub] incubator-daffodil pull request #12: Revised daffodil-io module to require p...
Posted by stevedlawrence <gi...@git.apache.org>.
Github user stevedlawrence commented on a diff in the pull request:
https://github.com/apache/incubator-daffodil/pull/12#discussion_r154100863
--- Diff: daffodil-runtime1/src/main/scala/edu/illinois/ncsa/daffodil/processors/parsers/ByteOrderChange1.scala ---
@@ -30,25 +30,25 @@
* SOFTWARE.
*/
-package edu.illinois.ncsa.daffodil.processors.parsers
--- End diff --
Delete file, all comments.
---
[GitHub] incubator-daffodil pull request #12: Revised daffodil-io module to require p...
Posted by stevedlawrence <gi...@git.apache.org>.
Github user stevedlawrence commented on a diff in the pull request:
https://github.com/apache/incubator-daffodil/pull/12#discussion_r154093528
--- Diff: daffodil-core/src/main/scala/edu/illinois/ncsa/daffodil/grammar/primitives/PrimitivesBinaryNumber.scala ---
@@ -49,13 +49,18 @@ import edu.illinois.ncsa.daffodil.processors.unparsers.BinaryDoubleUnparser
import edu.illinois.ncsa.daffodil.processors.unparsers.BinaryFloatUnparser
class BinaryIntegerRuntimeLength(val e: ElementBase, signed: Boolean) extends Terminal(e, true) {
+
+ e.byteOrderEv // insure defined
--- End diff --
Typo her and below: s/insure/ensure
---
[GitHub] incubator-daffodil pull request #12: Revised daffodil-io module to require p...
Posted by mbeckerle <gi...@git.apache.org>.
Github user mbeckerle commented on a diff in the pull request:
https://github.com/apache/incubator-daffodil/pull/12#discussion_r153951013
--- Diff: daffodil-io/src/main/scala/edu/illinois/ncsa/daffodil/io/FormatInfo.scala ---
@@ -0,0 +1,49 @@
+package edu.illinois.ncsa.daffodil.io
+
+import java.nio.charset.CharsetDecoder
+import java.nio.charset.CharsetEncoder
+import edu.illinois.ncsa.daffodil.schema.annotation.props.gen.BitOrder
+import edu.illinois.ncsa.daffodil.schema.annotation.props.gen.ByteOrder
+import edu.illinois.ncsa.daffodil.schema.annotation.props.gen.BinaryFloatRep
+import edu.illinois.ncsa.daffodil.util.MaybeInt
+import java.nio.charset.Charset
+import java.nio.charset.CodingErrorAction
+import edu.illinois.ncsa.daffodil.schema.annotation.props.gen.EncodingErrorPolicy
+import edu.illinois.ncsa.daffodil.util.Maybe
+import edu.illinois.ncsa.daffodil.schema.annotation.props.gen.UTF16Width
+
+/**
+ * Abstract interface to obtain format properties.
+ *
+ * By passing in an object that provides quick access to these, we avoid the
+ * need to have setters/getters that change state in the I/O layer.
+ */
+trait FormatInfo {
+ def encoder: CharsetEncoder
+ def decoder: CharsetDecoder
+ def reportingDecoder: CharsetDecoder
+ def replacingDecoder: CharsetDecoder
+ def codingErrorAction: CodingErrorAction
+ def isFixedWidthEncoding: Boolean
+ def byteOrder: ByteOrder
+ final def jByteOrder = byteOrder match {
+ case ByteOrder.BigEndian => java.nio.ByteOrder.BIG_ENDIAN
+ case _ => java.nio.ByteOrder.LITTLE_ENDIAN
+ }
+ def bitOrder: BitOrder
+ def fillByte: Byte
--- End diff --
bug: below fillLong can't be lazy val. Must be def.
---
[GitHub] incubator-daffodil pull request #12: Revised daffodil-io module to require p...
Posted by stevedlawrence <gi...@git.apache.org>.
Github user stevedlawrence commented on a diff in the pull request:
https://github.com/apache/incubator-daffodil/pull/12#discussion_r154103501
--- Diff: daffodil-runtime1/src/main/scala/edu/illinois/ncsa/daffodil/processors/EvByteOrder.scala ---
@@ -60,22 +59,27 @@ class Ok private () extends Serializable {
}
object Ok extends Ok()
-class CheckByteAndBitOrderEv(t: TermRuntimeData, bitOrder: BitOrder, maybeByteOrder: Maybe[ByteOrderEv])
+class CheckByteAndBitOrderEv(t: TermRuntimeData, bitOrder: BitOrder)
extends Evaluatable[Ok](t)
with InfosetCachedEvaluatable[Ok] { // can't use unit here, not <: AnyRef
- override lazy val runtimeDependencies = maybeByteOrder.toList
+ override lazy val runtimeDependencies = Nil
- final protected def compute(state: ParseOrUnparseState): Ok = {
- if (maybeByteOrder.isEmpty) return Ok
- val byteOrderEv = maybeByteOrder.get
- val byteOrder = byteOrderEv.evaluate(state)
- bitOrder match {
- case BitOrder.MostSignificantBitFirst => // ok
- case BitOrder.LeastSignificantBitFirst =>
- if (byteOrder =:= ByteOrder.BigEndian) {
- t.schemaDefinitionError("Bit order 'leastSignificantBitFirst' requires byte order 'littleEndian', but byte order was '%s'.", byteOrder)
+ override final protected def compute(state: ParseOrUnparseState): Ok = {
+ t match {
+ case erd: ElementRuntimeData => {
+ if (erd.maybeByteOrderEv.isEmpty) return Ok
--- End diff --
Should avoid using return. I guess this was here originally, but since your modifying this code, it would be good to fix.
---
[GitHub] incubator-daffodil pull request #12: Revised daffodil-io module to require p...
Posted by mbeckerle <gi...@git.apache.org>.
Github user mbeckerle commented on a diff in the pull request:
https://github.com/apache/incubator-daffodil/pull/12#discussion_r153951208
--- Diff: daffodil-io/src/main/scala/edu/illinois/ncsa/daffodil/io/FormatInfo.scala ---
@@ -0,0 +1,49 @@
+package edu.illinois.ncsa.daffodil.io
+
+import java.nio.charset.CharsetDecoder
+import java.nio.charset.CharsetEncoder
+import edu.illinois.ncsa.daffodil.schema.annotation.props.gen.BitOrder
+import edu.illinois.ncsa.daffodil.schema.annotation.props.gen.ByteOrder
+import edu.illinois.ncsa.daffodil.schema.annotation.props.gen.BinaryFloatRep
+import edu.illinois.ncsa.daffodil.util.MaybeInt
+import java.nio.charset.Charset
+import java.nio.charset.CodingErrorAction
+import edu.illinois.ncsa.daffodil.schema.annotation.props.gen.EncodingErrorPolicy
+import edu.illinois.ncsa.daffodil.util.Maybe
+import edu.illinois.ncsa.daffodil.schema.annotation.props.gen.UTF16Width
+
+/**
+ * Abstract interface to obtain format properties.
+ *
+ * By passing in an object that provides quick access to these, we avoid the
+ * need to have setters/getters that change state in the I/O layer.
+ */
+trait FormatInfo {
+ def encoder: CharsetEncoder
+ def decoder: CharsetDecoder
+ def reportingDecoder: CharsetDecoder
+ def replacingDecoder: CharsetDecoder
+ def codingErrorAction: CodingErrorAction
+ def isFixedWidthEncoding: Boolean
+ def byteOrder: ByteOrder
+ final def jByteOrder = byteOrder match {
+ case ByteOrder.BigEndian => java.nio.ByteOrder.BIG_ENDIAN
+ case _ => java.nio.ByteOrder.LITTLE_ENDIAN
+ }
+ def bitOrder: BitOrder
+ def fillByte: Byte
+ final lazy val fillLong = {
+ var fl: Long = 0L
+ val fb = fillByte
+ 1 to 8 foreach { _ =>
--- End diff --
Use a while loop, or inline code this whole thing. This is inner-most performance sensitive code.
---
[GitHub] incubator-daffodil pull request #12: Revised daffodil-io module to require p...
Posted by stevedlawrence <gi...@git.apache.org>.
Github user stevedlawrence commented on a diff in the pull request:
https://github.com/apache/incubator-daffodil/pull/12#discussion_r154115656
--- Diff: daffodil-io/src/main/scala/edu/illinois/ncsa/daffodil/io/FormatInfo.scala ---
@@ -0,0 +1,49 @@
+package edu.illinois.ncsa.daffodil.io
+
+import java.nio.charset.CharsetDecoder
+import java.nio.charset.CharsetEncoder
+import edu.illinois.ncsa.daffodil.schema.annotation.props.gen.BitOrder
+import edu.illinois.ncsa.daffodil.schema.annotation.props.gen.ByteOrder
+import edu.illinois.ncsa.daffodil.schema.annotation.props.gen.BinaryFloatRep
+import edu.illinois.ncsa.daffodil.util.MaybeInt
+import java.nio.charset.Charset
+import java.nio.charset.CodingErrorAction
+import edu.illinois.ncsa.daffodil.schema.annotation.props.gen.EncodingErrorPolicy
+import edu.illinois.ncsa.daffodil.util.Maybe
+import edu.illinois.ncsa.daffodil.schema.annotation.props.gen.UTF16Width
+
+/**
+ * Abstract interface to obtain format properties.
+ *
+ * By passing in an object that provides quick access to these, we avoid the
+ * need to have setters/getters that change state in the I/O layer.
+ */
+trait FormatInfo {
+ def encoder: CharsetEncoder
+ def decoder: CharsetDecoder
+ def reportingDecoder: CharsetDecoder
+ def replacingDecoder: CharsetDecoder
+ def codingErrorAction: CodingErrorAction
+ def isFixedWidthEncoding: Boolean
+ def byteOrder: ByteOrder
+ final def jByteOrder = byteOrder match {
+ case ByteOrder.BigEndian => java.nio.ByteOrder.BIG_ENDIAN
+ case _ => java.nio.ByteOrder.LITTLE_ENDIAN
+ }
+ def bitOrder: BitOrder
+ def fillByte: Byte
+ final lazy val fillLong = {
+ var fl: Long = 0L
+ val fb = fillByte
+ 1 to 8 foreach { _ =>
--- End diff --
Ah, mentioned above, sorry.
---
[GitHub] incubator-daffodil pull request #12: Revised daffodil-io module to require p...
Posted by mbeckerle <gi...@git.apache.org>.
Github user mbeckerle commented on a diff in the pull request:
https://github.com/apache/incubator-daffodil/pull/12#discussion_r154124026
--- Diff: daffodil-core/src/main/scala/edu/illinois/ncsa/daffodil/grammar/TermGrammarMixin.scala ---
@@ -62,7 +61,7 @@ trait TermGrammarMixin
protected lazy val hasEncoding = optionEncodingRaw.isDefined
- protected lazy val termIOPropertiesChange = prod("ioPropertiesChange") { bitOrderChange ~ encodingChange }
+ protected lazy val termIOPropertiesChange = prod("ioPropertiesChange") { bitOrderChange }
--- End diff --
Yes. Unfortunately one cannot get rid of bitOrderChange parser unless we build into the main combinators a check for bitOrderChange every time bitOrder is accessed. That's for parsing. Because a parser proceeds in-linear order through the data this works because the notion of "prior bit order" is well defined.
For unparsing, bitOrderChange is trickier due to suspensions and jumping back to handle them. (There's still a bug in that logic. DAFFODIL-1843) But that's why I left in bitOrderChange for now.
---
[GitHub] incubator-daffodil pull request #12: Revised daffodil-io module to require p...
Posted by mbeckerle <gi...@git.apache.org>.
Github user mbeckerle commented on a diff in the pull request:
https://github.com/apache/incubator-daffodil/pull/12#discussion_r153953270
--- 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
--- End diff --
Look at callers for all these methods and see if some of these can be protected or private.
---