This is an automated email from the ASF dual-hosted git repository.
olabusayo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/daffodil.git
The following commit(s) were added to refs/heads/main by this push:
new 97463b782 Add expressionAllowed param to getPropertyOption
97463b782 is described below
commit 97463b7820d144b2cccd77e2a0d10bd26b5cb368
Author: olabusayoT <[email protected]>
AuthorDate: Mon Sep 23 10:56:46 2024 -0400
Add expressionAllowed param to getPropertyOption
- move non-runtimed valued properties to excludedBecauseDoneByHand
- update function calls
- update tests to ensure we no longer get warnings about
textStandardExponentRep
DAFFODIL-2928
---
.../lib/schema/annotation/props/ByHandMixins.scala | 2 +-
.../schema/annotation/props/PropertyScoping.scala | 7 ++++--
.../daffodil/propGen/PropertyGenerator.scala | 26 +++++++++++++---------
.../daffodil/propGen/TestPropertyGenerator.scala | 6 +++--
.../text_number_props/TextNumberProps.tdml | 6 +++--
5 files changed, 29 insertions(+), 18 deletions(-)
diff --git
a/daffodil-lib/src/main/scala/org/apache/daffodil/lib/schema/annotation/props/ByHandMixins.scala
b/daffodil-lib/src/main/scala/org/apache/daffodil/lib/schema/annotation/props/ByHandMixins.scala
index a4ec9f80a..165d48a4e 100644
---
a/daffodil-lib/src/main/scala/org/apache/daffodil/lib/schema/annotation/props/ByHandMixins.scala
+++
b/daffodil-lib/src/main/scala/org/apache/daffodil/lib/schema/annotation/props/ByHandMixins.scala
@@ -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(
diff --git
a/daffodil-lib/src/main/scala/org/apache/daffodil/lib/schema/annotation/props/PropertyScoping.scala
b/daffodil-lib/src/main/scala/org/apache/daffodil/lib/schema/annotation/props/PropertyScoping.scala
index dd1aa9d4f..dddab9950 100644
---
a/daffodil-lib/src/main/scala/org/apache/daffodil/lib/schema/annotation/props/PropertyScoping.scala
+++
b/daffodil-lib/src/main/scala/org/apache/daffodil/lib/schema/annotation/props/PropertyScoping.scala
@@ -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
diff --git
a/daffodil-propgen/src/main/scala/org/apache/daffodil/propGen/PropertyGenerator.scala
b/daffodil-propgen/src/main/scala/org/apache/daffodil/propGen/PropertyGenerator.scala
index 69af3c4e3..695c9ab3d 100644
---
a/daffodil-propgen/src/main/scala/org/apache/daffodil/propGen/PropertyGenerator.scala
+++
b/daffodil-propgen/src/main/scala/org/apache/daffodil/propGen/PropertyGenerator.scala
@@ -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
@@ -454,14 +462,6 @@ trait CurrencyMixin extends PropertyMixin {
"occursCount",
"inputValueCalc",
"outputValueCalc",
- "textStandardInfinityRep",
- "textStandardNaNRep",
- "textStandardZeroRep",
- "nilValue",
- "textStringPadCharacter",
- "textNumberPadCharacter",
- "textBooleanPadCharacter",
- "textCalendarPadCharacter",
"calendarLanguage",
"choiceDispatchKey"
)
@@ -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
}
diff --git
a/daffodil-propgen/src/test/scala/org/apache/daffodil/propGen/TestPropertyGenerator.scala
b/daffodil-propgen/src/test/scala/org/apache/daffodil/propGen/TestPropertyGenerator.scala
index 352ebed09..bea0e4faf 100644
---
a/daffodil-propgen/src/test/scala/org/apache/daffodil/propGen/TestPropertyGenerator.scala
+++
b/daffodil-propgen/src/test/scala/org/apache/daffodil/propGen/TestPropertyGenerator.scala
@@ -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 + "'"
}
- })""")
+ })"""
+ )
)
}
diff --git
a/daffodil-test/src/test/resources/org/apache/daffodil/section13/text_number_props/TextNumberProps.tdml
b/daffodil-test/src/test/resources/org/apache/daffodil/section13/text_number_props/TextNumberProps.tdml
index 69f99fa31..8093dcfa8 100644
---
a/daffodil-test/src/test/resources/org/apache/daffodil/section13/text_number_props/TextNumberProps.tdml
+++
b/daffodil-test/src/test/resources/org/apache/daffodil/section13/text_number_props/TextNumberProps.tdml
@@ -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>
@@ -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>