niftools / pyffi

PyFFI is a Python library for processing block structured files.
http://www.niftools.org/pyffi
Other
48 stars 26 forks source link

Fixed : PyFFI xml fringe behaviors #23

Closed Dexesttp closed 8 years ago

Dexesttp commented 8 years ago

Wrong result when choosing between different types

When applying a condition to choose between different options to parse an array attribute, the option can be between different embedded data types in arrays that have the same name.

In this specific case, the PyFFI parser didn't reply with the right result but did reply with the embedded type of the first choice. This was due to the embedded type handling being done beforehand.

The fist commit fixes this behavior by retrieving the right option's embedded type and setting the actual result embedded type to the retrieved value. It first however checks for the existence of such value, in case the data isn't an array to begin with.

Optional attribute "template" treated as mandatory

The "template" attribute, used in nif.xml to handle Ptr and Ref target type check, was specified as optional in the official PyFFI documentation. However, it was required for PyFFI to work. The second commit aims to fix this inconsistency.

It does so by checking if the _template attribute is set before attempting to compare the target against the template's description. If the template is defined and the target doesn't match the description, then the checker throws an error as usual. Otherwise, the checker validates the data.