Repository navigation
Add a build/write-prefetch unparse path driven by a dedicated Builder tree #1736
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,6 +28,9 @@ import org.apache.daffodil.lib.schema.annotation.props.gen.LengthKind | |
| import org.apache.daffodil.lib.schema.annotation.props.gen.Representation | ||
| import org.apache.daffodil.lib.schema.annotation.props.gen.TestKind | ||
| import org.apache.daffodil.lib.util.Maybe | ||
| import org.apache.daffodil.runtime1.infoset.ElementInfosetBuilder | ||
| import org.apache.daffodil.runtime1.infoset.InfosetBuilder | ||
| import org.apache.daffodil.runtime1.infoset.NadaInfosetBuilder | ||
| import org.apache.daffodil.runtime1.processors.parsers.CaptureEndOfContentLengthParser | ||
| import org.apache.daffodil.runtime1.processors.parsers.CaptureEndOfValueLengthParser | ||
| import org.apache.daffodil.runtime1.processors.parsers.CaptureStartOfContentLengthParser | ||
|
|
@@ -44,6 +47,7 @@ import org.apache.daffodil.unparsers.runtime1.CaptureStartOfValueLengthUnparser | |
| import org.apache.daffodil.unparsers.runtime1.ElementOVCSpecifiedLengthUnparser | ||
| import org.apache.daffodil.unparsers.runtime1.ElementOVCUnspecifiedLengthUnparser | ||
| import org.apache.daffodil.unparsers.runtime1.ElementSpecifiedLengthUnparser | ||
| import org.apache.daffodil.unparsers.runtime1.ElementUnparserBase | ||
| import org.apache.daffodil.unparsers.runtime1.ElementUnparserInputValueCalc | ||
| import org.apache.daffodil.unparsers.runtime1.ElementUnspecifiedLengthUnparser | ||
| import org.apache.daffodil.unparsers.runtime1.ElementUnusedUnparser | ||
|
|
@@ -111,6 +115,12 @@ class ElementCombinator( | |
|
|
||
| private lazy val eRepTypeUnparser: Maybe[Unparser] = repTypeElementGram.maybeUnparser | ||
|
|
||
| private lazy val isSpecifiedLength: Boolean = | ||
| (context.lengthKind._eq_(LengthKind.Explicit)) || | ||
| (context.isSimpleType && | ||
| (context.lengthKind._eq_(LengthKind.Implicit)) && | ||
| (context.impliedRepresentation._eq_(Representation.Text))) | ||
|
|
||
| override lazy val unparser: Unparser = { | ||
| if (context.isOutputValueCalc) { | ||
| new ElementOVCSpecifiedLengthUnparser( | ||
|
|
@@ -122,12 +132,7 @@ class ElementCombinator( | |
| eAfterUnparser, | ||
| context.ovcCompiledExpression | ||
| ) | ||
| } else if ( | ||
| (context.lengthKind._eq_(LengthKind.Explicit)) || | ||
| (context.isSimpleType && | ||
| (context.lengthKind._eq_(LengthKind.Implicit)) && | ||
| (context.impliedRepresentation._eq_(Representation.Text))) | ||
| ) { | ||
| } else if (isSpecifiedLength) { | ||
|
|
||
| new ElementSpecifiedLengthUnparser( | ||
| context.erd, | ||
|
|
@@ -143,6 +148,26 @@ class ElementCombinator( | |
| } | ||
| } | ||
|
|
||
| private lazy val eBuilder: InfosetBuilder = { | ||
| if (eValue.isEmpty) { | ||
| NadaInfosetBuilder | ||
| } else { | ||
| eValue.builder | ||
| } | ||
| } | ||
| private lazy val eRepTypeBuilder: InfosetBuilder = repTypeElementGram.builder | ||
|
|
||
| // Shares the memoized unparser above for unparseBegin/unparseEnd, so | ||
| // build and the unparse see identical node-creation behavior. | ||
| override lazy val builder: InfosetBuilder = { | ||
| if (context.isOutputValueCalc || isSpecifiedLength) { | ||
| val eu = unparser.asInstanceOf[ElementUnparserBase] | ||
| val contentBuilder = eRepTypeBuilder.orElse(eBuilder) | ||
| new ElementInfosetBuilder(context.erd, eu, contentBuilder) | ||
| } else { | ||
| subComb.builder | ||
| } | ||
| } | ||
| } | ||
|
|
||
| case class ElementUnused(ctxt: ElementBase) | ||
|
|
@@ -374,6 +399,14 @@ class ElementParseAndUnspecifiedLength( | |
| new ElementUnparserInputValueCalc(context.erd, uSetVar) | ||
| } | ||
| } | ||
|
|
||
| // Shares the memoized unparser above for unparseBegin/unparseEnd, so | ||
| // build and the unparse see identical nilled/OVC/IVC node-creation behavior. | ||
| override lazy val builder: InfosetBuilder = { | ||
| val eu = unparser.asInstanceOf[ElementUnparserBase] | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here, I would rather see the same logic rather than type matching. It's much easier to visually verify the conditionalsare the same rather than figuring out which Unparsers are created.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one doesn't pattern match but uses the elementUnparser to call unparseBegin/End |
||
| val contentBuilder = eRepTypeBuilder.orElse(eBuilder) | ||
| new ElementInfosetBuilder(context.erd, eu, contentBuilder) | ||
| } | ||
| } | ||
|
|
||
| abstract class ElementCombinatorBase( | ||
|
|
@@ -449,4 +482,8 @@ abstract class ElementCombinatorBase( | |
|
|
||
| def unparser: Unparser | ||
|
|
||
| lazy val eBuilder: InfosetBuilder = eGram.builder | ||
|
|
||
| lazy val eRepTypeBuilder: InfosetBuilder = repTypeElementGram.builder | ||
|
|
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This only effects the TDML tests. Should we be doing something similar for the Scala unit tests so that we test eventDriven with those as well?