stevedlawrence commented on a change in pull request #80: added a layer 
transform that swaps bytes within an array of 32 bit words
URL: https://github.com/apache/incubator-daffodil/pull/80#discussion_r202673284
 
 

 ##########
 File path: 
daffodil-core/src/test/scala/org/apache/daffodil/layers/TestLayers.scala
 ##########
 @@ -358,4 +358,65 @@ a few lines of pointless text like this.""".replace("\n", 
" ")
     val areTracing = false
     TestUtils.testUnparsing(sch, infoset, data, areTracing)
   }
+
+  val le32BitData = Array[Byte](0x01,                   // BE MSBF
+                                0x43, 0x33, 0x33, 0x32, // fourbyteswap + LE 
LSBF (parsed right to left four bytes at a time)
+                                            0x55, 0x54, // fourbyteswap + LE 
LSBF
+                                0x67)                   // BE MSBF
+
+  val le32BitSchema =
+    SchemaUtils.dfdlTestSchema(
+      <dfdl:format ref="tns:GeneralFormat" bitOrder="leastSignificantBitFirst"
+                   byteOrder="littleEndian" alignmentUnits="bits" alignment="1"
+                   lengthKind="explicit" lengthUnits="bits"/>,
+      <xs:element name="e1" dfdl:lengthKind="implicit">
+        <xs:complexType>
+          <xs:sequence>
+            <xs:element name="s0" type="xs:hexBinary" dfdl:length="4" 
dfdl:byteOrder="bigEndian" dfdl:bitOrder="mostSignificantBitFirst"/>
+            <xs:element name="s1" type="xs:hexBinary" dfdl:length="4" 
dfdl:byteOrder="bigEndian" dfdl:bitOrder="mostSignificantBitFirst"/>
+            <xs:sequence dfdl:layerTransform="fourbyteswap" 
dfdl:layerLengthKind="explicit" dfdl:layerLengthUnits="bytes" 
dfdl:layerLength="6">
+              <xs:sequence>
+                <xs:element name="s2" type="xs:hexBinary" dfdl:length="4"/>
+                <xs:element name="s3" type="xs:hexBinary" dfdl:length="24"/>
+                <xs:element name="s4" type="xs:hexBinary" dfdl:length="8"/>
+                <xs:element name="s5" type="xs:hexBinary" dfdl:length="12"/>
+              </xs:sequence>
+            </xs:sequence>
+            <xs:element name="s6" type="xs:hexBinary" dfdl:length="4" 
dfdl:byteOrder="bigEndian" dfdl:bitOrder="mostSignificantBitFirst"/>
+            <xs:element name="s7" type="xs:hexBinary" dfdl:length="4" 
dfdl:byteOrder="bigEndian" dfdl:bitOrder="mostSignificantBitFirst"/>
+          </xs:sequence>
+        </xs:complexType>
+      </xs:element>, elementFormDefault = "qualified")
+  /*
+  val le32BitSchema =
+    SchemaUtils.dfdlTestSchema(
+      <dfdl:format ref="tns:GeneralFormat" bitOrder="leastSignificantBitFirst"
+                   byteOrder="littleEndian" alignmentUnits="bits" alignment="1"
+                   lengthKind="explicit" lengthUnits="bits"/>,
+      <xs:element name="e1">
+        <xs:complexType>
+          <xs:sequence>
+            <xs:sequence dfdl:layerTransform="fourbyteswap" 
dfdl:layerLengthKind="explicit" dfdl:layerLengthUnits="bytes" 
dfdl:layerLength="6">
+              <xs:sequence>
+                <xs:element name="s2" type="xs:hexBinary" dfdl:length="4"/>
+                <xs:element name="s3" type="xs:hexBinary" dfdl:length="24"/>
+                <xs:element name="s4" type="xs:hexBinary" dfdl:length="8"/>
+                <xs:element name="s5" type="xs:hexBinary" dfdl:length="4"/>
+              </xs:sequence>
+            </xs:sequence>
+          </xs:sequence>
+        </xs:complexType>
+      </xs:element>, elementFormDefault = "qualified")
+  */
 
 Review comment:
   Can this commented out schema be removed or a test added to use it? Looks 
like it just a simpler version of the other schema? I wouldn't be against 
having both schemas tested.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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

Reply via email to