Skip to content

Commit

Permalink
Add expressionAllowed param to getPropertyOption
Browse files Browse the repository at this point in the history
- move non-runtimed valued properties to excludedBecauseDoneByHand
- update function calls
- update tests to ensure we no longer get warnings about textStandardExponentRep

DAFFODIL-2928
  • Loading branch information
olabusayoT committed Sep 30, 2024
1 parent e02ae7f commit b5be895
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ trait TextStandardExponentRepMixin extends PropertyMixin {

lazy val textStandardExponentRep: Found = {
val tsec = getPropertyOption("textStandardExponentCharacter")
val tser = getPropertyOption("textStandardExponentRep")
val tser = getPropertyOption("textStandardExponentRep", expressionAllowed = true)
(tsec, tser) match {
case (Some(tsecStr), Some(tserStr)) => {
SDW(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,11 @@ trait FindPropertyMixin extends PropTypes {
*
* See JIRA DFDL-506.
*/
final def getPropertyOption(pname: String): Option[String] = {
val lookupRes = findPropertyOption(pname)
final def getPropertyOption(
pname: String,
expressionAllowed: Boolean = false
): Option[String] = {
val lookupRes = findPropertyOption(pname, expressionAllowed)
val res = lookupRes match {
case Found(v, _, _, _) => Some(v)
case _ => None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,15 @@ class PropertyGenerator(arg: Node) {
"separatorSuppressionPolicy",
"textOutputMinLength",
"textStandardExponentCharacter",
"textStandardExponentRep"
"textStandardExponentRep",
"textStandardInfinityRep",
"textStandardNaNRep",
"textStandardZeroRep",
"nilValue",
"textStringPadCharacter",
"textNumberPadCharacter",
"textBooleanPadCharacter",
"textCalendarPadCharacter"
)
val exclusions =
notFormatProperties ++ notScopedFormatProperties ++ excludedBecauseDoneByHand
Expand Down Expand Up @@ -454,14 +462,6 @@ trait CurrencyMixin extends PropertyMixin {
"occursCount",
"inputValueCalc",
"outputValueCalc",
"textStandardInfinityRep",
"textStandardNaNRep",
"textStandardZeroRep",
"nilValue",
"textStringPadCharacter",
"textNumberPadCharacter",
"textBooleanPadCharacter",
"textCalendarPadCharacter",
"calendarLanguage",
"choiceDispatchKey"
)
Expand Down Expand Up @@ -642,12 +642,16 @@ object Currency {
*/
def generateNonEnumStringPropInit(propName: String) = {
val template =
"""registerToStringFunction(()=>{getPropertyOption("currency") match {
"""registerToStringFunction(()=>{getPropertyOption("currency", expressionAllowed) match {
case None => ""
case Some(value) => "currency='" + value.toString + "'"
}
})"""
val res = template.replaceAll("currency", propName)
val expressionAllowStr = excludeRuntimeProperties(propName).toString
val res =
template
.replaceAll("currency", propName)
.replaceAll("expressionAllowed", expressionAllowStr)
res
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,13 @@ class TestPropertyGenerator {
assertTrue(mx.contains("""LengthKindMixin"""))
assertTrue(mx.contains("""def lengthPropertiesAGInit(): Unit = {"""))
assertTrue(
mx.contains("""registerToStringFunction(()=>{getPropertyOption("lengthPattern") match {
mx.contains(
"""registerToStringFunction(()=>{getPropertyOption("lengthPattern", false) match {
case None => ""
case Some(value) => "lengthPattern='" + value.toString + "'"
}
})""")
})"""
)
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3711,7 +3711,8 @@

<tdml:parserTestCase name="dynamicExp" root="dynamicExp"
model="textprops"
description="Parse a double with dynamic text number properties" roundTrip="false">
description="Parse a double with dynamic text number properties" roundTrip="false"
ignoreUnexpectedWarnings="false">

<tdml:document>
<tdml:documentPart type="text"><![CDATA[_|@|1234567_89@2]]]></tdml:documentPart>
Expand Down Expand Up @@ -3797,7 +3798,8 @@

<tdml:parserTestCase name="expCaseInsensitive" root="expCaseInsensitive"
model="textprops"
description="Parse a double with a case insensitive exp" roundTrip="false">
description="Parse a double with a case insensitive exp" roundTrip="false"
ignoreUnexpectedWarnings="false">

<tdml:document>
<tdml:documentPart type="text"><![CDATA[1234567.89AbC2]]]></tdml:documentPart>
Expand Down

0 comments on commit b5be895

Please sign in to comment.