Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nifxml 0.9 specification sync #8

Open
wants to merge 27 commits into
base: develop
Choose a base branch
from

Conversation

hexabits
Copy link
Member

@hexabits hexabits commented Dec 17, 2017

Updated for XML features up to 0.9

  • Added XML features:
    • userver2
    • prefix for <enum>/<bitflags>
    • suffix for add
    • mult and div operators for expressions
  • Support nested compounds correctly for some generation features. No manual maintenance of a compound list.
  • Support abstract <add> members, which means ignore on read/write. This is found in Usage/Access members on NiDataStream.
  • Filter duplicate includes when generating list of includes for a cpp file
  • Cast duplicate names with differing types. For example:
    • ushort is smaller than uint, so on read/write e.g. bodyFlags can just be cast to the smaller type, but the class member variable is stored as uint. Source XML:
    <add name="Body Flags" type="uint" vercond="(User Version 2 &lt; 76)" />
    <add name="Body Flags" type="ushort" vercond="(User Version 2 &gt;= 76)" />
  • Python 3 support

On several occasions the newer nif.xml now has version-exclusive names which are identical yet have different types.  Such as uint in one version and ushort in another.  Adding the cast to read/write will adjust the read/write size appropriately.

Note this does not fix all duplicate names, just the ones where a cast during read/write is all that is necessary.

The first type also has to be the largest as declaration for the type depends on the first name, and subsequent smaller types will reuse that name.
NiDataStream uses two members to store args extracted from the RTTI string for the name that are not actually read/written during I/O so the current generation for this object is incorrect.
For some reason nifxml.py lists a bunch of compounds which are often nested in order to write the toString code correctly.  Added the new constraint descriptors to it.
The mapping for XML type to niflib type is now internal instead of in nif.xml.  Type names are synced to nifxml 0.9.
The list of includes was not first reduced to unique includes before writing, so the same file would be included over and over again.
Added Compound.has_arr() which recursively checks all members for an array size.  This removes the need for a manually maintained list of compounds with arrays.
Required to pass a child member of BSVertexDesc through to BSVertexData.

Comment out BSVertexDesc as a native type for now, as niflib doesn't have such a type yet anyway.
@hexabits hexabits requested review from neomonkeus and a team December 17, 2017 23:29
This is only the first step of many...
…e/include

Reduced the constant code() calls for each line and used multi-line string templates instead.

Created specialized CFile methods for includes, include guards, and namespaces to make it even more legible.
A function, parse_XML now must be called to actually fill the Blocks/Compounds.  This gives another script a chance to monkeypatch the classes before calling the function.

Moved all the niflib specific methods to gen_niflib and then monkeypatch the classes with them.

Pass native types dict as a parameter instead of referencing it globally.

Fixed nifxml_doc generation also.
Wasn't actually looking at the member count attribute.  Thanks, Python.
Also improve the include() function for CFile so that quotes are not required.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants