jadams-tresys commented on a change in pull request #207: Added support for
enumerations and TypeValueCalc
URL: https://github.com/apache/incubator-daffodil/pull/207#discussion_r275967710
##########
File path:
daffodil-core/src/main/scala/org/apache/daffodil/dsom/SimpleTypes.scala
##########
@@ -40,14 +69,71 @@ trait NonPrimTypeMixin {
}
}
-sealed trait SimpleTypeBase extends TypeBase {
- def primType: NodeInfo.PrimType = {
- optRestriction.map { _.primType }.getOrElse {
- optUnion.map { _.primType }.getOrElse {
- Assert.invariantFailed("must be either a restriction or union")
+sealed trait SimpleTypeBase extends TypeBase
+ with hasOptRepTypeMixin {
+
+ def primType: PrimType
+
+}
+
+/*
+ * For components which can define dfdl:repValues and dfdl:repValueRanges
+ * Construct the repValueSet using only the above mentioned attributes on the
element itself
+ * Applies to simpleType and enumeration
+ *
+ * In the case of simpleType, it is possible that optRepValueSetFromAttribute
will be none
+ * but the element will still have an optRepValueSet for another source (eg.
children elements)
+ */
+sealed trait HasRepValueAttributes extends AnnotatedSchemaComponent {
+ def optRepTypeFactory: Option[SimpleTypeFactory]
+ def optRepValueSet: Option[RepValueSet[AnyRef]]
+
+ lazy val (repValuesAttrCooked: Seq[AnyRef], repValueRangesAttrCooked:
Seq[(RangeBound[BigInt], RangeBound[BigInt])]) = optRepTypeFactory match {
+ case Some(repType) => {
+ val repValueSetRaw =
findPropertyOptionThisComponentOnly("repValues").toOption
+ .map(_.split("\\s+").toSeq).getOrElse(Seq())
+ val repValueRangesRaw =
findPropertyOptionThisComponentOnly("repValueRanges").toOption
+ .map(_.split("\\s+").toSeq).getOrElse(Seq())
+ repType.primType match {
+ case PrimType.String => {
+ if (repValueRangesRaw.size > 0) context.SDE("repValueRanges set when
using a string repType")
+ val repValueSetCooked =
repValueRangesRaw.map(RepValueCooker.convertConstant(_, context, false))
+ (repValueSetCooked, Seq())
+ }
+ //I need to double check the type hierarchy, but I think all integer
types are subtypes of SignedInteger
Review comment:
That appears to be correct, so I would go ahead and remove this comment.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services