1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 14:18:12 +00:00

LibGfx/TIFF: Automatically export all enums associated with tags

This commit is contained in:
Lucas CHOLLET 2023-11-30 23:22:08 -05:00 committed by Andreas Kling
parent 9c12112916
commit 4280f4d2c7

View file

@ -79,10 +79,19 @@ def export_enum_to_cpp(e: Type[Enum], special_name: Optional[str] = None) -> str
for entry in e:
output += f' {entry.name} = {entry.value},\n'
output += "};"
output += "};\n"
return output
def export_tag_related_enums(tags: List[Tag]) -> str:
exported_enums = []
for tag in tags:
if tag.associated_enum:
exported_enums.append(export_enum_to_cpp(tag.associated_enum))
return '\n'.join(exported_enums)
def promote_type(t: TIFFType) -> TIFFType:
if t == TIFFType.UnsignedShort:
return TIFFType.UnsignedLong
@ -224,11 +233,7 @@ struct Rational {{
// Note that u16 is not include on purpose
using Value = Variant<u8, String, u32, Rational<u32>, i32, Rational<i32>>;
// This enum is progressively defined across sections but summarized in:
// Appendix A: TIFF Tags Sorted by Number
{export_enum_to_cpp(Compression)}
{export_enum_to_cpp(Predictor)}
{export_tag_related_enums(known_tags)}
{HANDLE_TAG_SIGNATURE};