tuxji opened a new pull request #471:
URL: https://github.com/apache/incubator-daffodil/pull/471
Expand the C code generator to support binary floating numbers.
Rename test element ex_ints to ex_nums and add floating numbers to it.
Modify the C code generator to emit one-line parser and unparser
subroutine calls instead of emitting 14-16 lines of low level parsing
/ unparsing C code for each field. Define each variation of these
14-16 lines for each type of numerical field as subroutines inside
parsers.c and unparsers.c in the c/libruntime directory instead.
Move the orion-command test element from TestRuntime2.dfdl.xsd to its
own schema (orion-command.xml) with its own tests and data files.
Currently orion-command.tdml will pass using daffodil-runtime1, but
fail if using daffodil-runtime2. We need to make the C code generator
support array elements in orion-command.xml's VideoSettings element.
Changelog:
In TestCLIGenerateC.scala, rename ex_ints to ex_nums.
In daffodil_main.c, update the parseSelf and unparseSelf calls since
they now return void instead of const char *error_msg.
In xml_reader.c, define new strtofnum and strtodnum functions to
support reading floating point numbers from XML data. Rename
xmlIntegerElem to xmlNumberElem and make it call strtofnum and
strtodnum as well as strtounum and strtonum. Run clang-format on the
code.
In xml_writer.c, rename xmlIntegerElem to xmlNumberElem and make it
write floating point numbers as well as integers. Run clang-format on
the code.
In infoset.c, make walkInfosetNode call visitNumberElem for primitive
floats/doubles as well as primitive integers.
In infoset.h, change signatures of parseSelf and unparseSelf. Rename
VisitIntegerElem to VisitNumberElem. Add enumerations for primitive
floats/doubles. Add const char *error_msg to PState and UState
structs so parser/unparser subroutines can set it when needed.
Add parsers.{c,h} with subroutines to parse binary floating point
numbers and integers.
Add unparsers.{c,h} with subroutines to unparse binary floating point
numbers and integers.
Rename ex_ints.{c,h} to ex_nums.{c,h} and bring them up to date with
generated_code.{c,h} emitted by C code generator after latest changes.
In Runtime2CodeGenerator.scala, add BinaryFloat and BinaryDouble cases
within the generateCode function and make them call
BinaryFloatCodeGenerator. Also add and call a noop function to
facilitate setting a breakpoint within the generateCode function.
Add BinaryFloatCodeGenerator.scala and make it emit one-line
subroutine calls for parsing and unparsing binary floating point
numbers. Note that binary floating point numbers can be little-endian
or big-endian just like binary integers.
In BinaryIntegerKnownLengthCodeGenerator.scala, remove minimum 8-bit
alignment restriction since C code can read and write numbers without
needing alignment to 8-bit boundaries. Change to emit one-line parse
and unparse subroutine calls (the low level parsing and unparsing code
is in c/libruntime/parsers.c and unparsers.c now).
In CodeGeneratorState.scala, add qualifiedName and localName methods
and invoke them to generate unique C file-scope names for ERD objects
while continuing to generate non-unique field names. Support binary
floating numbers as well as binary integers and initialize their
fields with signaling NaNs. Change parseSelf and unparseSelf to
return void instead of const char *error_msg. Expand to handle floats
as well as integers. Shorten ${C}_compute_ERD_offsets to
${C}_compute_offsets. Remove unneeded headers from generated_code.c.
In TestRuntime2.dfdl.xsd, rename ex_ints to ex_nums and make it define
float/double numbers as well as integers. Move orion_command and its
simple types to orion-command.xml.
In TestRuntime2.tdml, rename ex_ints tests to ex_nums. Move
orion_command tests to orion-command.tdml.
Rename orion_command_parse.dat to command_parse.dat.
Rename orion_command_unparse.xml to command_unparse.xml.
Rename ex_ints test data files to ex_nums and add float/double numbers
to their contents.
Add orion-command.tdml with test cases for Command and VideoSettings
elements and corresponding data files (e.g., video_settings_parse.dat
and video_settings_unparse.xml).
Add orion-command.xml schema with Command, CameraState, and
VideoSettings elements.
Add TestOrionCommand.scala to run orion-command.tdml as part of sbt
tests.
In TestRuntime2.scala, rename ex_ints to ex_nums. Move orion_command
test cases to TestOrionCommand.scala.
In Dependencies.scala, update dev.dirs:directories version to latest
version.
In Rat.scala, tell Rat to ignore new test data files. Also ignore
orion-command.xml schema since we got it from a third party without
any license (we may keep it around only temporarily while developing C
code generator and remove it once Daffodil can generate C code for
array elements).
----------------------------------------------------------------
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]