Closed hexabits closed 7 years ago
@neomonkeus So do you understand nifdocsys enough to look into how to go about changing gen_niflib.py to prepend this prefix? I looked at it very briefly and I can see that it writes them starting here https://github.com/niftools/nifdocsys/blob/master/gen_niflib.py#L412 but I don't see yet where it sanitizes the names to remove spaces and such.
@aperture-it Since you were able to so easily change genniflib.py for uniquename
do you think you could look into adding this prefix
attribute for <enum>
and <bitflags>
? Regarding 9b45d8a4bf0fb5818ee15851776953e23e153524 ... all you would have to do was add `prefix="ESCV"and
prefix="LSCV_"to the
instead of changing every
It also has the benefit of foolproofing name changes or additions so that future nif.xml edits do not break niflib.
Yes, adding prefixes and suffixes is not complex. In fact, this is not done in gen_niflib.py, but in nifxml.py.
Did you mean to post this in #64? If you are proposing an alternative to uniquename
we should discuss it there.
I have removed the _
from the prefix in my proposed syntax to be consistent with the suffix proposal in #64. The underscore can be added by the parser.
There have been numerous issues and inter-project fights over the values of the
name
attribute in<option>
. There is also a usability issue in that it is impossible to edit enum or bitflags options by hand and know that you haven't created a non-unique name. niflib needs unique option names for the codegen from nif.xml (See: https://github.com/niftools/nifdocsys/blob/master/gen_niflib.py#L412)There is an additional problem in that the nice neat names we give to option tags for the UI become much uglier when adding the unique prefix for the enum (See #62).
I propose:
Add a prefix attribute to
<enum>
and<bitflags>
The prefix attribute would be prepended to each
name
, preventing collisions. For applications where the uniqueness doesn't matter and where thename
are used for UI, this keeps the name clean but allows codegen to enforce uniqueness via the prefix.Example
It's also the easiest way to ensure uniqueness when editing by hand as you no longer need to check the entire file for the the same
name
string, only assure that it is unique inside that enum/bitflag.Adoption
For this to work, gen_niflib.py would have to be updated to account for the new prefix attribute. It would have to prepend the prefix to each name attribute on write.