early-access version 2251

This commit is contained in:
pineappleEA
2021-11-28 11:31:20 +01:00
parent a657cf53a1
commit faf5b13e48
58 changed files with 171227 additions and 121316 deletions

View File

@@ -43,7 +43,10 @@ def enquote(s):
"""Return string argument with surrounding quotes,
for serialization into Python code."""
if s:
return "'{}'".format(s)
if isinstance(s, str):
return "'{}'".format(s)
else:
return s
return None
@@ -119,8 +122,11 @@ class GeneratorOptions:
removeExtensions=None,
emitExtensions=None,
emitSpirv=None,
emitFormats=None,
reparentEnums=True,
sortProcedure=regSortFeatures):
sortProcedure=regSortFeatures,
requireCommandAliases=False,
):
"""Constructor.
Arguments:
@@ -152,6 +158,8 @@ class GeneratorOptions:
to None.
- emitSpirv - regex matching names of extensions and capabilities
to actually emit interfaces for.
- emitFormats - regex matching names of formats to actually emit
interfaces for.
- reparentEnums - move <enum> elements which extend an enumerated
type from <feature> or <extension> elements to the target <enums>
element. This is required for almost all purposes, but the
@@ -217,6 +225,10 @@ class GeneratorOptions:
"""regex matching names of extensions and capabilities
to actually emit interfaces for."""
self.emitFormats = self.emptyRegex(emitFormats)
"""regex matching names of formats
to actually emit interfaces for."""
self.reparentEnums = reparentEnums
"""boolean specifying whether to remove <enum> elements from
<feature> or <extension> when extending an <enums> type."""
@@ -230,6 +242,10 @@ class GeneratorOptions:
self.codeGenerator = False
"""True if this generator makes compilable code"""
self.requireCommandAliases = requireCommandAliases
"""True if alias= attributes of <command> tags are transitively
required."""
def emptyRegex(self, pat):
"""Substitute a regular expression which matches no version
or extension names for None or the empty string."""
@@ -257,6 +273,17 @@ class OutputGenerator:
'basetype': 'basetypes',
}
def breakName(self, name, msg):
"""Break into debugger if this is a special name"""
# List of string names to break on
bad = (
)
if name in bad and True:
print('breakName {}: {}'.format(name, msg))
pdb.set_trace()
def __init__(self, errFile=sys.stderr, warnFile=sys.stderr, diagFile=sys.stdout):
"""Constructor
@@ -553,7 +580,7 @@ class OutputGenerator:
# Work around this by chasing the aliases to get the actual value.
while numVal is None:
alias = self.registry.tree.find("enums/enum[@name='" + strVal + "']")
(numVal, strVal) = self.enumToValue(alias, True)
(numVal, strVal) = self.enumToValue(alias, True, bitwidth, True)
decl += "static const {} {} = {};\n".format(flagTypeName, name, strVal)
if numVal is not None:
@@ -778,7 +805,6 @@ class OutputGenerator:
self.warnFile.flush()
if self.diagFile:
self.diagFile.flush()
self.outFile.flush()
if self.outFile != sys.stdout and self.outFile != sys.stderr:
self.outFile.close()
@@ -887,6 +913,14 @@ class OutputGenerator:
Extend to generate as desired in your derived class."""
return
def genFormat(self, format, formatinfo, alias):
"""Generate interface for a format element.
- formatinfo - FormatInfo
Extend to generate as desired in your derived class."""
return
def makeProtoName(self, name, tail):
"""Turn a `<proto>` `<name>` into C-language prototype
and typedef declarations for that name.
@@ -939,6 +973,9 @@ class OutputGenerator:
# Clear prefix for subsequent iterations
prefix = ''
paramdecl = paramdecl + prefix
if aligncol == 0:
# Squeeze out multiple spaces other than the indentation
paramdecl = indent + ' '.join(paramdecl.split())