diff options
author | Jon Leech <[email protected]> | 2021-06-06 23:10:19 -0700 |
---|---|---|
committer | Jon Leech <[email protected]> | 2021-06-06 23:10:45 -0700 |
commit | 07c4a37bcf41ea50aef6e98236abdfe8089fb4c6 (patch) | |
tree | 313a5be92b1fe1778de102812588310dadf6ff09 /registry/generator.py | |
parent | 7fe877c90abf00bc71b3c68f49db4c9bb1010411 (diff) | |
download | Vulkan-Headers-07c4a37bcf41ea50aef6e98236abdfe8089fb4c6.tar.gz Vulkan-Headers-07c4a37bcf41ea50aef6e98236abdfe8089fb4c6.zip |
Update for Vulkan-Docs 1.2.180v1.2.180
Diffstat (limited to 'registry/generator.py')
-rw-r--r-- | registry/generator.py | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/registry/generator.py b/registry/generator.py index 6203c65..19bbc3c 100644 --- a/registry/generator.py +++ b/registry/generator.py @@ -691,6 +691,47 @@ class OutputGenerator: return (section, '\n'.join(body)) + def buildConstantCDecl(self, enuminfo, name, alias): + """Generate the C declaration for a constant (a single <enum> + value). + + <enum> tags may specify their values in several ways, but are + usually just integers or floating-point numbers.""" + + (_, strVal) = self.enumToValue(enuminfo.elem, False) + + if self.misracppstyle() and enuminfo.elem.get('type') and not alias: + # Generate e.g.: static constexpr uint32_t x = ~static_cast<uint32_t>(1U); + # This appeases MISRA "underlying type" rules. + typeStr = enuminfo.elem.get('type'); + invert = '~' in strVal + number = strVal.strip("()~UL") + if typeStr != "float": + number += 'U' + strVal = "~" if invert else "" + strVal += "static_cast<" + typeStr + ">(" + number + ")" + body = 'static constexpr ' + typeStr.ljust(9) + name.ljust(33) + ' {' + strVal + '};' + elif enuminfo.elem.get('type') and not alias: + # Generate e.g.: #define x (~0ULL) + typeStr = enuminfo.elem.get('type'); + invert = '~' in strVal + paren = '(' in strVal + number = strVal.strip("()~UL") + if typeStr != "float": + if typeStr == "uint64_t": + number += 'ULL' + else: + number += 'U' + strVal = "~" if invert else "" + strVal += number + if paren: + strVal = "(" + strVal + ")"; + body = '#define ' + name.ljust(33) + ' ' + strVal; + else: + body = '#define ' + name.ljust(33) + ' ' + strVal + + return body + def makeDir(self, path): """Create a directory, if not already done. |