intel/genxml: Collapse leading underscores on prefixed value defines
We prefix names with an underscore to make them "safe" C identifiers when necessary. For example, a value of "32x32" would become "_32x32". However, when specifying something like <field ... prefix="BLOCK_SIZE"> <value name="32x32" value="0"/> </field> we already have a prefix that makes the field name safe. We'd rather generate a name with a single underscore, i.e. #define BLOCK_SIZE_32x32 0 rather than #define BLOCK_SIZE__32x32 0 This also fixes up affected defines in crocus. Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13809>
This commit is contained in:
parent
cd7d3c7ae3
commit
ebc0099d89
|
@ -35,9 +35,9 @@ static uint32_t
|
||||||
color_depth_for_cpp(int cpp)
|
color_depth_for_cpp(int cpp)
|
||||||
{
|
{
|
||||||
switch (cpp) {
|
switch (cpp) {
|
||||||
case 4: return COLOR_DEPTH__32bit;
|
case 4: return COLOR_DEPTH_32bit;
|
||||||
case 2: return COLOR_DEPTH__565;
|
case 2: return COLOR_DEPTH_565;
|
||||||
case 1: return COLOR_DEPTH__8bit;
|
case 1: return COLOR_DEPTH_8bit;
|
||||||
default:
|
default:
|
||||||
unreachable("not reached");
|
unreachable("not reached");
|
||||||
}
|
}
|
||||||
|
|
|
@ -336,7 +336,11 @@ class Field(object):
|
||||||
prefix = self.prefix + '_' if self.prefix else ''
|
prefix = self.prefix + '_' if self.prefix else ''
|
||||||
|
|
||||||
for value in self.values:
|
for value in self.values:
|
||||||
print("#define %-40s %d" % (prefix + value.name, value.value))
|
name = value.name
|
||||||
|
if self.prefix and value.name[0] == '_':
|
||||||
|
name = name[1:]
|
||||||
|
|
||||||
|
print("#define %-40s %d" % (prefix + name, value.value))
|
||||||
|
|
||||||
class Group(object):
|
class Group(object):
|
||||||
def __init__(self, parser, parent, start, count, size):
|
def __init__(self, parser, parent, start, count, size):
|
||||||
|
|
Loading…
Reference in New Issue